WordPress.org

Making WordPress.org


Ignore:
Timestamp:
04/15/17 20:38:02 (8 months ago)
Author:
ocean90
Message:

Theme Directory: Remove filters for option_home and option_siteurl.

This is now directly handled in sunrise.php to catch more URLs, including content_url and plugins_url.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r4530 r5341  
    11321132} 
    11331133add_action( 'wp_head', 'wporg_themes_add_hreflang_link_attributes' ); 
    1134  
    1135 /** 
    1136  * Filter the URLs to use the current localized domain name, rather than WordPress.org. 
    1137  * 
    1138  * The Theme Directory is available at multiple URLs (internationalised domains), this method allows 
    1139  * for the one blog (a single blog_id) to be presented at multiple URLs yet have correct localised links. 
    1140  * 
    1141  * This method works in conjunction with a filter in sunrise.php, duplicated here for transparency: 
    1142  * 
    1143  * // Make the Plugin Directory available at /plugins/ on all rosetta sites. 
    1144  * function wporg_themes_on_rosetta_domains( $site, $domain, $path, $segments ) { 
    1145  *     // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php 
    1146  *     if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/themes/' == substr( $path . '/', 0, 8 ) ) { 
    1147  *          $site = get_blog_details( WPORG_THEME_DIRECTORY_BLOGID, false ); 
    1148  *          if ( $site ) { 
    1149  *              $site = clone $site; 
    1150  *              // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network 
    1151  *              $site->site_id = 6; 
    1152  *              return $site; 
    1153  *          } 
    1154  *     } 
    1155  * 
    1156  *     return $site; 
    1157  * } 
    1158  * add_filter( 'pre_get_site_by_path', 'wporg_themes_on_rosetta_domains', 10, 4 ); 
    1159  * 
    1160  * @param string $url The URL to be localized. 
    1161  * @return string 
    1162  */ 
    1163 function wporg_themes_rosetta_network_localize_url( $url ) { 
    1164     static $localized_url = null; 
    1165  
    1166     if ( get_current_blog_id() != WPORG_THEME_DIRECTORY_BLOGID ) { 
    1167         return $url; 
    1168     } 
    1169  
    1170     if ( is_null( $localized_url ) ) { 
    1171         $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] ); 
    1172     } 
    1173  
    1174     return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url ); 
    1175 } 
    1176 if ( 'wordpress.org' != $_SERVER['HTTP_HOST'] && defined( 'WPORG_THEME_DIRECTORY_BLOGID' ) ) { 
    1177     add_filter( 'option_home',    'wporg_themes_rosetta_network_localize_url' ); 
    1178     add_filter( 'option_siteurl', 'wporg_themes_rosetta_network_localize_url' ); 
    1179 } 
Note: See TracChangeset for help on using the changeset viewer.