Simplify https:// conversion in plugins_url()/content_url() functions

git-svn-id: http://svn.automattic.com/wordpress/trunk@12964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-05 12:45:21 +00:00
parent 226600f5b2
commit dede5d2f46
1 changed files with 3 additions and 7 deletions

View File

@ -1838,12 +1838,9 @@ function includes_url($path = '') {
* @return string Content url link with optional path appended. * @return string Content url link with optional path appended.
*/ */
function content_url($path = '') { function content_url($path = '') {
$scheme = ( is_ssl() ? 'https' : 'http' );
$url = WP_CONTENT_URL; $url = WP_CONTENT_URL;
if ( 0 === strpos($url, 'http') ) { if ( 0 === strpos($url, 'http') && is_ssl() )
if ( is_ssl() ) $url = str_replace( 'http://', 'https://', $url );
$url = str_replace( 'http://', "{$scheme}://", $url );
}
if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
$url .= '/' . ltrim($path, '/'); $url .= '/' . ltrim($path, '/');
@ -1863,7 +1860,6 @@ function content_url($path = '') {
* @return string Plugins url link with optional path appended. * @return string Plugins url link with optional path appended.
*/ */
function plugins_url($path = '', $plugin = '') { function plugins_url($path = '', $plugin = '') {
$scheme = ( is_ssl() ? 'https' : 'http' );
$mu_plugin_dir = WPMU_PLUGIN_DIR; $mu_plugin_dir = WPMU_PLUGIN_DIR;
foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) { foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {
@ -1877,7 +1873,7 @@ function plugins_url($path = '', $plugin = '') {
$url = WP_PLUGIN_URL; $url = WP_PLUGIN_URL;
if ( 0 === strpos($url, 'http') && is_ssl() ) if ( 0 === strpos($url, 'http') && is_ssl() )
$url = str_replace( 'http://', "{$scheme}://", $url ); $url = str_replace( 'http://', 'https://', $url );
if ( !empty($plugin) && is_string($plugin) ) { if ( !empty($plugin) && is_string($plugin) ) {
$folder = dirname(plugin_basename($plugin)); $folder = dirname(plugin_basename($plugin));