WordPress.org

Making WordPress.org


Ignore:
Timestamp:
04/15/2017 08:37:02 PM (4 years ago)
Author:
ocean90
Message:

Plugin 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/plugin-directory/class-plugin-directory.php

    r5334 r5340  
    485485        remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
    486486
    487         // When this plugin is used in the context of a Rosetta site, handle it gracefully.
    488         if ( 'wordpress.org' != $_SERVER['HTTP_HOST'] && defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
    489             add_filter( 'option_home',    array( $this, 'rosetta_network_localize_url' ) );
    490             add_filter( 'option_siteurl', array( $this, 'rosetta_network_localize_url' ) );
    491         }
    492 
    493487        add_filter( 'get_term', array( __NAMESPACE__ . '\I18n', 'translate_term' ) );
    494488        add_filter( 'the_content', array( $this, 'translate_post_content' ), 1, 2 );
     
    603597
    604598        do_action( 'wporg_plugins_deactivation' );
    605     }
    606 
    607     /**
    608      * Filter the URLs to use the current localized domain name, rather than WordPress.org.
    609      *
    610      * The Plugin Directory is available at multiple URLs (internationalised domains), this method allows
    611      * for the one blog (a single blog_id) to be presented at multiple URLs yet have correct localised links.
    612      *
    613      * This method works in conjunction with a filter in sunrise.php, duplicated here for transparency:
    614      *
    615      * // Make the Plugin Directory available at /plugins/ on all rosetta sites.
    616      * function wporg_plugins_on_rosetta_domains( $site, $domain, $path, $segments ) {
    617      *     // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php
    618      *     if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/plugins/' == substr( $path . '/', 0, 9 ) ) {
    619      *          $site = get_blog_details( WPORG_PLUGIN_DIRECTORY_BLOGID, false );
    620      *          if ( $site ) {
    621      *              $site = clone $site;
    622      *              // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network
    623      *              $site->site_id = 6;
    624      *              return $site;
    625      *          }
    626      *     }
    627      *
    628      *     return $site;
    629      * }
    630      * add_filter( 'pre_get_site_by_path', 'wporg_plugins_on_rosetta_domains', 10, 4 );
    631      *
    632      * @param string $url The URL to be localized.
    633      * @return string
    634      */
    635     public function rosetta_network_localize_url( $url ) {
    636         static $localized_url = null;
    637 
    638         if ( is_null( $localized_url ) ) {
    639             $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] );
    640         }
    641 
    642         return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url );
    643599    }
    644600
Note: See TracChangeset for help on using the changeset viewer.