plugin_dir_url

Definition:
function plugin_dir_url( $file ) {}

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

Parameters

  • string $file: The filename of the plugin (__FILE__)

Return values

returns:the URL path of the directory that contains the plugin

Source code

function plugin_dir_url( $file ) {

	return trailingslashit( plugins_url( '', $file ) );

}

2519

plugin_dir_path

Definition:
function plugin_dir_path( $file ) {}

Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in

Parameters

  • string $file: The filename of the plugin (__FILE__)

Return values

returns:the filesystem path of the directory that contains the plugin

Source code

function plugin_dir_path( $file ) {

	return trailingslashit( dirname( $file ) );

}

2517

plugins_url

Definition:
function plugins_url($path = '', $plugin = '') {}

Retrieve the url to the plugins directory or to a specific file within that directory.
You can hardcode the plugin slug in $path or pass __FILE__ as a second argument to get the correct folder name.

Parameters

  • string $path: Optional. Path relative to the plugins url.
  • string $plugin: Optional. The plugin file that you want to be relative to – i.e. pass in __FILE__

Return values

returns:Plugins url link with optional path appended.

Defined filters

  • plugins_url
    apply_filters('plugins_url', $url, $path, $plugin)

Source code

function plugins_url($path = '', $plugin = '') {



	$mu_plugin_dir = WPMU_PLUGIN_DIR;

	foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {

		$$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs

		$$var = preg_replace('|/+|', '/', $$var);

	}



	if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) )

		$url = WPMU_PLUGIN_URL;

	else

		$url = WP_PLUGIN_URL;



	if ( 0 === strpos($url, 'http') && is_ssl() )

		$url = str_replace( 'http://', 'https://', $url );



	if ( !empty($plugin) && is_string($plugin) ) {

		$folder = dirname(plugin_basename($plugin));

		if ( '.' != $folder )

			$url .= '/' . ltrim($folder, '/');

	}



	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )

		$url .= '/' . ltrim($path, '/');



	return apply_filters('plugins_url', $url, $path, $plugin);

}

2515

plugins_search_help

Definition:
function plugins_search_help() {}

Source code

function plugins_search_help() {

	return '

	<p><strong>' . __('Search help') . '</strong></p>' .

	'<p>' . __('You may search based on 3 criteria:') . '<br />' .

	__('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' .

	__('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' .

	__('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p>

';

}

2513

plugins_api

Definition:
function plugins_api($action, $args = null) {}

Retrieve plugin installer pages from WordPress Plugins API.
It is possible for a plugin to override the Plugin API result with three filters. Assume this is for plugins, which can extend on the Plugin Info to offer more choices. This is very powerful and must be used with care, when overriding the filters.

Parameters

  • string $action
  • array|object $args: Optional. Arguments to serialize for the Plugin Info API.

Return values

returns:response object on success, WP_Error on failure.

Defined filters

  • plugins_api_args
    apply_filters('plugins_api_args', $args, $action)
  • plugins_api
    apply_filters('plugins_api', false, $action, $args)
  • plugins_api_result
    apply_filters('plugins_api_result', $res, $action, $args)

Source code

function plugins_api($action, $args = null) {



	if ( is_array($args) )

		$args = (object)$args;



	if ( !isset($args->per_page) )

		$args->per_page = 24;



	// Allows a plugin to override the WordPress.org API entirely.

	// Use the filter 'plugins_api_result' to mearly add results.

	// Please ensure that a object is returned from the following filters.

	$args = apply_filters('plugins_api_args', $args, $action);

	$res = apply_filters('plugins_api', false, $action, $args);



	if ( false === $res ) {

		$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) );

		if ( is_wp_error($request) ) {

			$res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() );

		} else {

			$res = unserialize( wp_remote_retrieve_body( $request ) );

			if ( false === $res )

				$res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body( $request ) );

		}

	} elseif ( !is_wp_error($res) ) {

		$res->external = true;

	}



	return apply_filters('plugins_api_result', $res, $action, $args);

}

2511