From fcd681da157f74e0b6c568e14efd8152cc2f59c0 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 15 Jul 2008 00:10:07 +0000 Subject: [PATCH] plugins_url() git-svn-id: https://develop.svn.wordpress.org/trunk@8334 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/link-template.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 61ae13c81e..8f1d27f0d9 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -871,4 +871,29 @@ function content_url($path = '') { return $url; } +/** Return the plugins url + * + * + * @package WordPress + * @since 2.6 + * + * Returns the url to the plugins directory + * + * @param string $path Optional path relative to the plugins url + * @return string Plugins url link with optional path appended +*/ +function plugins_url($path = '') { + $scheme = ( is_ssl() ? 'https' : 'http' ); + $url = WP_PLUGIN_URL; + if ( 0 === strpos($url, 'http') ) { + if ( is_ssl() ) + $url = str_replace( 'http://', "{$scheme}://", $url ); + } + + if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) + $url .= '/' . ltrim($path, '/'); + + return $url; +} + ?>