WordPress.org

Making WordPress.org


Ignore:
Timestamp:
02/17/2018 11:57:44 AM (17 months ago)
Author:
ocean90
Message:

Locale Detection: Use class constants for the names of the GET parameter and cookie.

See #1673.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/locale-detection/class-detector.php

    r6674 r6675  
    1414
    1515    /**
     16     * Name of the cookie for the locale.
     17     */
     18    const COOKIE_NAME = 'wporg_locale';
     19
     20    /**
     21     * Name of the GET parameter for the locale.
     22     */
     23    const GET_NAME = 'locale';
     24
     25    /**
    1626     * Whether the locale was guessed or not.
    1727     *
     
    5464     */
    5565    private function set_locale() {
    56         if ( ! empty( $_GET['locale'] ) ) {
    57             $get_locale = $this->sanitize_locale( $_GET['locale'] );
     66        if ( ! empty( $_GET[ self::GET_NAME ] ) ) {
     67            $get_locale = $this->sanitize_locale( $_GET[ self::GET_NAME ] );
    5868
    5969            $this->locale = $this->check_variants( $get_locale ) ?: $this->locale;
    60         } elseif ( ! empty( $_COOKIE['wporg_locale'] ) ) {
    61             $locale = $this->sanitize_locale( $_COOKIE['wporg_locale'] );
     70        } elseif ( ! empty( $_COOKIE[ self::COOKIE_NAME ] ) ) {
     71            $locale = $this->sanitize_locale( $_COOKIE[ self::COOKIE_NAME ] );
    6272
    6373            if ( in_array( $locale, $this->active_locales, true ) ) {
     
    6878        }
    6979
    70         if ( empty( $_COOKIE['wporg_locale'] ) || $this->locale !== $_COOKIE['wporg_locale'] ) {
    71             setcookie( 'wporg_locale', $this->locale, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl() );
     80        if ( empty( $_COOKIE[ self::COOKIE_NAME ] ) || $this->locale !== $_COOKIE[ self::COOKIE_NAME ] ) {
     81            setcookie( self::COOKIE_NAME, $this->locale, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl() );
    7282        }
    7383    }
Note: See TracChangeset for help on using the changeset viewer.