plugin_dir_url() WordPress Function

The plugin_dir_url() function is used to retrieve the URL of a given plugin directory. This function is useful for retrieving the URL of a plugin when you need to reference its files from within another plugin or theme.

plugin_dir_url( string $file ) #

Get the URL directory path (with trailing slash) for the plugin __FILE__ passed in.


Parameters

$file

(string)(Required)The filename of the plugin (__FILE__).


Top ↑

Return

(string) the URL path of the directory that contains the plugin.


Top ↑

Source

File: wp-includes/plugin.php

function plugin_dir_url( $file ) {
	return trailingslashit( plugins_url( '', $file ) );
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.