Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-constants.php

    r41959 r42343  
    6060    }
    6161
    62     if ( ! isset($blog_id) )
     62    if ( ! isset( $blog_id ) ) {
    6363        $blog_id = 1;
    64 
    65     if ( !defined('WP_CONTENT_DIR') )
     64    }
     65
     66    if ( ! defined( 'WP_CONTENT_DIR' ) ) {
    6667        define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
     68    }
    6769
    6870    // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
    69     if ( !defined('WP_DEBUG') )
     71    if ( ! defined( 'WP_DEBUG' ) ) {
    7072        define( 'WP_DEBUG', false );
     73    }
    7174
    7275    // Add define('WP_DEBUG_DISPLAY', null); to wp-config.php use the globally configured setting for
    7376    // display_errors and not force errors to be displayed. Use false to force display_errors off.
    74     if ( !defined('WP_DEBUG_DISPLAY') )
     77    if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
    7578        define( 'WP_DEBUG_DISPLAY', true );
     79    }
    7680
    7781    // Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log.
    78     if ( !defined('WP_DEBUG_LOG') )
    79         define('WP_DEBUG_LOG', false);
    80 
    81     if ( !defined('WP_CACHE') )
    82         define('WP_CACHE', false);
     82    if ( ! defined( 'WP_DEBUG_LOG' ) ) {
     83        define( 'WP_DEBUG_LOG', false );
     84    }
     85
     86    if ( ! defined( 'WP_CACHE' ) ) {
     87        define( 'WP_CACHE', false );
     88    }
    8389
    8490    // Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified,
     
    97103     * Private
    98104     */
    99     if ( !defined('MEDIA_TRASH') )
    100         define('MEDIA_TRASH', false);
    101 
    102     if ( !defined('SHORTINIT') )
    103         define('SHORTINIT', false);
     105    if ( ! defined( 'MEDIA_TRASH' ) ) {
     106        define( 'MEDIA_TRASH', false );
     107    }
     108
     109    if ( ! defined( 'SHORTINIT' ) ) {
     110        define( 'SHORTINIT', false );
     111    }
    104112
    105113    // Constants for features added to WP that should short-circuit their plugin implementations
     
    120128     */
    121129    define( 'MINUTE_IN_SECONDS', 60 );
    122     define( 'HOUR_IN_SECONDS',   60 * MINUTE_IN_SECONDS );
    123     define( 'DAY_IN_SECONDS',    24 * HOUR_IN_SECONDS  );
    124     define( 'WEEK_IN_SECONDS',    7 * DAY_IN_SECONDS    );
    125     define( 'MONTH_IN_SECONDS',  30 * DAY_IN_SECONDS    );
    126     define( 'YEAR_IN_SECONDS',  365 * DAY_IN_SECONDS    );
     130    define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
     131    define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
     132    define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
     133    define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
     134    define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
    127135    /**#@-*/
    128136}
     
    136144 */
    137145function wp_plugin_directory_constants() {
    138     if ( !defined('WP_CONTENT_URL') )
    139         define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
     146    if ( ! defined( 'WP_CONTENT_URL' ) ) {
     147        define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); // full url - WP_CONTENT_DIR is defined further up
     148    }
    140149
    141150    /**
     
    144153     * @since 2.6.0
    145154     */
    146     if ( !defined('WP_PLUGIN_DIR') )
     155    if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
    147156        define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
     157    }
    148158
    149159    /**
     
    152162     * @since 2.6.0
    153163     */
    154     if ( !defined('WP_PLUGIN_URL') )
     164    if ( ! defined( 'WP_PLUGIN_URL' ) ) {
    155165        define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
     166    }
    156167
    157168    /**
     
    161172     * @deprecated
    162173     */
    163     if ( !defined('PLUGINDIR') )
     174    if ( ! defined( 'PLUGINDIR' ) ) {
    164175        define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
     176    }
    165177
    166178    /**
     
    169181     * @since 2.8.0
    170182     */
    171     if ( !defined('WPMU_PLUGIN_DIR') )
     183    if ( ! defined( 'WPMU_PLUGIN_DIR' ) ) {
    172184        define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
     185    }
    173186
    174187    /**
     
    177190     * @since 2.8.0
    178191     */
    179     if ( !defined('WPMU_PLUGIN_URL') )
     192    if ( ! defined( 'WPMU_PLUGIN_URL' ) ) {
    180193        define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
     194    }
    181195
    182196    /**
     
    186200     * @deprecated
    187201     */
    188     if ( !defined( 'MUPLUGINDIR' ) )
     202    if ( ! defined( 'MUPLUGINDIR' ) ) {
    189203        define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
     204    }
    190205}
    191206
     
    194209 *
    195210 * Defines constants after multisite is loaded.
     211 *
    196212 * @since 3.0.0
    197213 */
     
    202218     * @since 1.5.0
    203219     */
    204     if ( !defined( 'COOKIEHASH' ) ) {
     220    if ( ! defined( 'COOKIEHASH' ) ) {
    205221        $siteurl = get_site_option( 'siteurl' );
    206         if ( $siteurl )
     222        if ( $siteurl ) {
    207223            define( 'COOKIEHASH', md5( $siteurl ) );
    208         else
     224        } else {
    209225            define( 'COOKIEHASH', '' );
     226        }
    210227    }
    211228
     
    213230     * @since 2.0.0
    214231     */
    215     if ( !defined('USER_COOKIE') )
    216         define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
     232    if ( ! defined( 'USER_COOKIE' ) ) {
     233        define( 'USER_COOKIE', 'wordpressuser_' . COOKIEHASH );
     234    }
    217235
    218236    /**
    219237     * @since 2.0.0
    220238     */
    221     if ( !defined('PASS_COOKIE') )
    222         define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
     239    if ( ! defined( 'PASS_COOKIE' ) ) {
     240        define( 'PASS_COOKIE', 'wordpresspass_' . COOKIEHASH );
     241    }
    223242
    224243    /**
    225244     * @since 2.5.0
    226245     */
    227     if ( !defined('AUTH_COOKIE') )
    228         define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    229 
    230     /**
    231      * @since 2.6.0
    232      */
    233     if ( !defined('SECURE_AUTH_COOKIE') )
    234         define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    235 
    236     /**
    237      * @since 2.6.0
    238      */
    239     if ( !defined('LOGGED_IN_COOKIE') )
    240         define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
     246    if ( ! defined( 'AUTH_COOKIE' ) ) {
     247        define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
     248    }
     249
     250    /**
     251     * @since 2.6.0
     252     */
     253    if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) {
     254        define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
     255    }
     256
     257    /**
     258     * @since 2.6.0
     259     */
     260    if ( ! defined( 'LOGGED_IN_COOKIE' ) ) {
     261        define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
     262    }
    241263
    242264    /**
    243265     * @since 2.3.0
    244266     */
    245     if ( !defined('TEST_COOKIE') )
    246         define('TEST_COOKIE', 'wordpress_test_cookie');
     267    if ( ! defined( 'TEST_COOKIE' ) ) {
     268        define( 'TEST_COOKIE', 'wordpress_test_cookie' );
     269    }
    247270
    248271    /**
    249272     * @since 1.2.0
    250273     */
    251     if ( !defined('COOKIEPATH') )
    252         define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
     274    if ( ! defined( 'COOKIEPATH' ) ) {
     275        define( 'COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'home' ) . '/' ) );
     276    }
    253277
    254278    /**
    255279     * @since 1.5.0
    256280     */
    257     if ( !defined('SITECOOKIEPATH') )
    258         define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
    259 
    260     /**
    261      * @since 2.6.0
    262      */
    263     if ( !defined('ADMIN_COOKIE_PATH') )
     281    if ( ! defined( 'SITECOOKIEPATH' ) ) {
     282        define( 'SITECOOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'siteurl' ) . '/' ) );
     283    }
     284
     285    /**
     286     * @since 2.6.0
     287     */
     288    if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) {
    264289        define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
    265 
    266     /**
    267      * @since 2.6.0
    268      */
    269     if ( !defined('PLUGINS_COOKIE_PATH') )
    270         define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
     290    }
     291
     292    /**
     293     * @since 2.6.0
     294     */
     295    if ( ! defined( 'PLUGINS_COOKIE_PATH' ) ) {
     296        define( 'PLUGINS_COOKIE_PATH', preg_replace( '|https?://[^/]+|i', '', WP_PLUGIN_URL ) );
     297    }
    271298
    272299    /**
    273300     * @since 2.0.0
    274301     */
    275     if ( !defined('COOKIE_DOMAIN') )
    276         define('COOKIE_DOMAIN', false);
     302    if ( ! defined( 'COOKIE_DOMAIN' ) ) {
     303        define( 'COOKIE_DOMAIN', false );
     304    }
    277305}
    278306
     
    286314     * @since 2.6.0
    287315     */
    288     if ( !defined( 'FORCE_SSL_ADMIN' ) ) {
     316    if ( ! defined( 'FORCE_SSL_ADMIN' ) ) {
    289317        if ( 'https' === parse_url( get_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
    290318            define( 'FORCE_SSL_ADMIN', true );
     
    313341     * @since 2.5.0
    314342     */
    315     if ( !defined( 'AUTOSAVE_INTERVAL' ) )
     343    if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) {
    316344        define( 'AUTOSAVE_INTERVAL', 60 );
     345    }
    317346
    318347    /**
    319348     * @since 2.9.0
    320349     */
    321     if ( !defined( 'EMPTY_TRASH_DAYS' ) )
     350    if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) {
    322351        define( 'EMPTY_TRASH_DAYS', 30 );
    323 
    324     if ( !defined('WP_POST_REVISIONS') )
    325         define('WP_POST_REVISIONS', true);
     352    }
     353
     354    if ( ! defined( 'WP_POST_REVISIONS' ) ) {
     355        define( 'WP_POST_REVISIONS', true );
     356    }
    326357
    327358    /**
    328359     * @since 3.3.0
    329360     */
    330     if ( !defined( 'WP_CRON_LOCK_TIMEOUT' ) )
    331         define('WP_CRON_LOCK_TIMEOUT', 60);  // In seconds
     361    if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) {
     362        define( 'WP_CRON_LOCK_TIMEOUT', 60 );  // In seconds
     363    }
    332364}
    333365
     
    340372    /**
    341373     * Filesystem path to the current active template directory
     374     *
    342375     * @since 1.5.0
    343376     */
    344     define('TEMPLATEPATH', get_template_directory());
     377    define( 'TEMPLATEPATH', get_template_directory() );
    345378
    346379    /**
    347380     * Filesystem path to the current active template stylesheet directory
     381     *
    348382     * @since 2.1.0
    349383     */
    350     define('STYLESHEETPATH', get_stylesheet_directory());
     384    define( 'STYLESHEETPATH', get_stylesheet_directory() );
    351385
    352386    /**
     
    358392     * @see WP_Theme::get_core_default_theme()
    359393     */
    360     if ( !defined('WP_DEFAULT_THEME') )
     394    if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
    361395        define( 'WP_DEFAULT_THEME', 'twentyseventeen' );
    362 
    363 }
     396    }
     397
     398}
Note: See TracChangeset for help on using the changeset viewer.