根据上下文检索当前站点或网络的管理区域的URL。
原型
self_admin_url( string $path = '', string $scheme = 'admin' )
参数
$path
(string)
(Optional)
相对于管理员URL的路径。
$scheme
(string)
(Optional)
使用的方案。默认为’admin’,它服从force_ssl_admin()和is_ssl()。可以传递’http’或’https’来强制执行这些方案。
返回值
(string)
管理URL链接,附加了可选路径。
源文件
路径:wp-includes/link-template.php
<?php
...
function self_admin_url( $path = '', $scheme = 'admin' ) {
if ( is_network_admin() ) {
$url = network_admin_url( $path, $scheme );
} elseif ( is_user_admin() ) {
$url = user_admin_url( $path, $scheme );
} else {
$url = admin_url( $path, $scheme );
}
/**
* Filters the admin URL for the current site or network depending on context.
*
* @since 4.9.0
*
* @param string $url The complete URL including scheme and path.
* @param string $path Path relative to the URL. Blank string if no path is specified.
* @param string $scheme The scheme to use.
*/
return apply_filters( 'self_admin_url', $url, $path, $scheme );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/self_admin_url/