plugins_url
函数
plugins_url ( $path = '', $plugin = '' )
- 参数
-
-
(string)
$path
Optional. Extra path appended to the end of the URL, including the relative directory if $plugin is supplied. Default empty.- Required: 否
- Default: (empty)
-
(string)
$plugin
Optional. A full path to a file inside a plugin or mu-plugin. The URL will be relative to its directory. Default empty. Typically this is done by passing `__FILE__` as the argument.- Required: 否
- Default: (empty)
-
(string)
- 返回值
-
- (string) Plugins URL link with optional paths appended.
- 定义位置
-
-
wp-includes/link-template.php
, line 3562
-
wp-includes/link-template.php
- 引入
- 2.6.0
- 弃用
- –
检索插件或mu-plugins目录下的一个URL。
如果没有提供参数,则默认为插件目录中的URL。
function plugins_url( $path = '', $plugin = '' ) {
$path = wp_normalize_path( $path );
$plugin = wp_normalize_path( $plugin );
$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
if ( ! empty( $plugin ) && 0 === strpos( $plugin, $mu_plugin_dir ) ) {
$url = WPMU_PLUGIN_URL;
} else {
$url = WP_PLUGIN_URL;
}
$url = set_url_scheme( $url );
if ( ! empty( $plugin ) && is_string( $plugin ) ) {
$folder = dirname( plugin_basename( $plugin ) );
if ( '.' !== $folder ) {
$url .= '/' . ltrim( $folder, '/' );
}
}
if ( $path && is_string( $path ) ) {
$url .= '/' . ltrim( $path, '/' );
}
/**
* Filters the URL to the plugins directory.
*
* @since 2.8.0
*
* @param string $url The complete URL to the plugins directory including scheme and path.
* @param string $path Path relative to the URL to the plugins directory. Blank string
* if no path is specified.
* @param string $plugin The plugin file path to be relative to. Blank string if no plugin
* is specified.
*/
return apply_filters( 'plugins_url', $url, $path, $plugin );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


