acf_plugin_dir_url()
This function will calculate the url to a plugin folder. Different to the WP plugin_dir_url(), this function can calculate for urls outside of the plugins folder (theme include).
Хуков нет.
Возвращает
Строку. The plugin directory path.
Использование
acf_plugin_dir_url( $file );
- $file(строка) (обязательный)
- A file path inside the ACF plugin to get the plugin directory path from.
Список изменений
| С версии 5.6.8 | Введена. |
Код acf_plugin_dir_url() acf plugin dir url ACF 6.4.2
function acf_plugin_dir_url( $file ) {
$path = plugin_dir_path( $file );
$path = wp_normalize_path( $path );
// check plugins.
$check_path = wp_normalize_path( realpath( WP_PLUGIN_DIR ) );
if ( strpos( $path, $check_path ) === 0 ) {
return str_replace( $check_path, plugins_url(), $path );
}
// check wp-content.
$check_path = wp_normalize_path( realpath( WP_CONTENT_DIR ) );
if ( strpos( $path, $check_path ) === 0 ) {
return str_replace( $check_path, content_url(), $path );
}
// check root.
$check_path = wp_normalize_path( realpath( ABSPATH ) );
if ( strpos( $path, $check_path ) === 0 ) {
return str_replace( $check_path, site_url( '/' ), $path );
}
// return.
return plugin_dir_url( $file );
}