Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




plugins_url [ WordPress Function ]

plugins_url ( $path = '', $plugin = '' )
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__
Returns:
  • (string) Plugins url link with optional path appended.
Defined at:



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.

Source


<?php
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) && === strpos($plugin$mu_plugin_dir) )
        
$url WPMU_PLUGIN_URL;
    else
        
$url WP_PLUGIN_URL;

    if ( 
=== 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);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics