Summery Summery
Retrieves a URL within the plugins or mu-plugins directory.
Syntax Syntax
Description Description
Defaults to the plugins directory URL if no arguments are supplied.
Parameters Parameters
- $path
-
(Optional) Extra path appended to the end of the URL, including the relative directory if $plugin is supplied.
Default value: ''
- $plugin
-
(Optional) A full path to a file inside a plugin or mu-plugin. The URL will be relative to its directory. Typically this is done by passing
__FILE__
as the argument.Default value: ''
Return Return
(string) Plugins URL link with optional paths appended.
Source Source
File: wp-includes/link-template.php
* if no path is specified. */ return apply_filters( 'content_url', $url, $path ); } /** * Retrieves a URL within the plugins or mu-plugins directory. * * Defaults to the plugins directory URL if no arguments are supplied. * * @since 2.6.0 * * @param string $path Optional. Extra path appended to the end of the URL, including * the relative directory if $plugin is supplied. Default empty. * @param 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. * @return string Plugins URL link with optional paths appended. */ 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, '/' ); }
Advertisement
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |