Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

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

    r47088 r47122  
    399399
    400400    if ( ! file_exists( $directory ) ) {
    401         // Try prepending as the theme directory could be relative to the content directory
     401        // Try prepending as the theme directory could be relative to the content directory.
    402402        $directory = WP_CONTENT_DIR . '/' . $directory;
    403         // If this directory does not exist, return and do not register
     403        // If this directory does not exist, return and do not register.
    404404        if ( ! file_exists( $directory ) ) {
    405405            return false;
     
    447447    $relative_theme_roots = array();
    448448
    449     // Set up maybe-relative, maybe-absolute array of theme directories.
    450     // We always want to return absolute, but we need to cache relative
    451     // to use in get_theme_root().
     449    /*
     450     * Set up maybe-relative, maybe-absolute array of theme directories.
     451     * We always want to return absolute, but we need to cache relative
     452     * to use in get_theme_root().
     453     */
    452454    foreach ( $wp_theme_directories as $theme_root ) {
    453455        if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) {
     
    483485        }
    484486        if ( ! is_int( $cache_expiration ) ) {
    485             $cache_expiration = 1800; // half hour
     487            $cache_expiration = 30 * MINUTE_IN_SECONDS;
    486488        }
    487489    } else {
    488         $cache_expiration = 1800; // half hour
     490        $cache_expiration = 30 * MINUTE_IN_SECONDS;
    489491    }
    490492
     
    504506            if ( file_exists( $theme_root . '/' . $dir . '/style.css' ) ) {
    505507                // wp-content/themes/a-single-theme
    506                 // wp-content/themes is $theme_root, a-single-theme is $dir
     508                // wp-content/themes is $theme_root, a-single-theme is $dir.
    507509                $found_themes[ $dir ] = array(
    508510                    'theme_file' => $dir . '/style.css',
     
    512514                $found_theme = false;
    513515                // wp-content/themes/a-folder-of-themes/*
    514                 // wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs
     516                // wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs.
    515517                $sub_dirs = @ scandir( $theme_root . '/' . $dir );
    516518                if ( ! $sub_dirs ) {
     
    676678    $theme_root = false;
    677679
    678     // If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
     680    // If requesting the root for the current theme, consult options to avoid calling get_theme_roots().
    679681    if ( ! $skip_cache ) {
    680682        if ( get_option( 'stylesheet' ) == $stylesheet_or_template ) {
     
    12781280    $header_images = array();
    12791281
    1280     // @todo caching
     1282    // @todo Caching.
    12811283    $headers = get_posts(
    12821284        array(
     
    19851987function get_editor_stylesheets() {
    19861988    $stylesheets = array();
    1987     // load editor_style.css if the current theme supports it
     1989    // Load editor_style.css if the current theme supports it.
    19881990    if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) {
    19891991        $editor_styles = $GLOBALS['editor_styles'];
     
    21222124                'url'   => home_url( '/' ),
    21232125            ),
    2124             'page_home'       => array( // Deprecated in favor of link_home.
     2126            'page_home'       => array( // Deprecated in favor of 'link_home'.
    21252127                'type'      => 'post_type',
    21262128                'object'    => 'page',
     
    23022304                break;
    23032305
    2304             // All that's left now are posts (besides attachments). Not a default case for the sake of clarity and future work.
     2306            // All that's left now are posts (besides attachments).
     2307            // Not a default case for the sake of clarity and future work.
    23052308            case 'posts':
    23062309                foreach ( $config[ $type ] as $id => $item ) {
     
    24922495            }
    24932496
    2494             // If a constant was defined, use that value. Otherwise, define the constant to ensure
    2495             // the constant is always accurate (and is not defined later,  overriding our value).
    2496             // As stated above, the first value wins.
    2497             // Once we get to wp_loaded (just-in-time), define any constants we haven't already.
    2498             // Constants are lame. Don't reference them. This is just for backward compatibility.
     2497            /*
     2498             * If a constant was defined, use that value. Otherwise, define the constant to ensure
     2499             * the constant is always accurate (and is not defined later,  overriding our value).
     2500             * As stated above, the first value wins.
     2501             * Once we get to wp_loaded (just-in-time), define any constants we haven't already.
     2502             * Constants are lame. Don't reference them. This is just for backward compatibility.
     2503             */
    24992504
    25002505            if ( defined( 'NO_HEADER_TEXT' ) ) {
     
    28292834    }
    28302835
    2831     // If no args passed then no extra checks need be performed
     2836    // If no args passed then no extra checks need be performed.
    28322837    if ( ! $args ) {
    28332838        return true;
     
    28362841    switch ( $feature ) {
    28372842        case 'post-thumbnails':
    2838             // post-thumbnails can be registered for only certain content/post types by passing
    2839             // an array of types to add_theme_support(). If no array was passed, then
    2840             // any type is accepted
     2843            /*
     2844             * post-thumbnails can be registered for only certain content/post types
     2845             * by passing an array of types to add_theme_support().
     2846             * If no array was passed, then any type is accepted.
     2847             */
    28412848            if ( true === $_wp_theme_features[ $feature ] ) {  // Registered for all types
    28422849                return true;
     
    28472854        case 'html5':
    28482855        case 'post-formats':
    2849             // specific post formats can be registered by passing an array of types to
    2850             // add_theme_support()
    2851 
    2852             // Specific areas of HTML5 support *must* be passed via an array to add_theme_support()
    2853 
     2856            /*
     2857             * Specific post formats can be registered by passing an array of types
     2858             * to add_theme_support().
     2859             *
     2860             * Specific areas of HTML5 support *must* be passed via an array to add_theme_support().
     2861             */
    28542862            $type = $args[0];
    28552863            return in_array( $type, $_wp_theme_features[ $feature ][0] );
     
    29422950        $old_theme = wp_get_theme( $stylesheet );
    29432951
    2944         // Prevent widget & menu mapping from running since Customizer already called it up front
     2952        // Prevent widget & menu mapping from running since Customizer already called it up front.
    29452953        if ( get_option( 'theme_switched_via_customizer' ) ) {
    29462954            remove_action( 'after_switch_theme', '_wp_menus_changed' );
     
    30143022
    30153023    $theme             = null;
    3016     $changeset_uuid    = false; // Value false indicates UUID should be determined after_setup_theme to either re-use existing saved changeset or else generate a new UUID if none exists.
     3024    $autosaved         = null;
    30173025    $messenger_channel = null;
    3018     $autosaved         = null;
    3019     $branching         = false; // Set initially fo false since defaults to true for back-compat; can be overridden via the customize_changeset_branching filter.
     3026
     3027    // Value false indicates UUID should be determined after_setup_theme
     3028    // to either re-use existing saved changeset or else generate a new UUID if none exists.
     3029    $changeset_uuid = false;
     3030
     3031    // Set initially fo false since defaults to true for back-compat;
     3032    // can be overridden via the customize_changeset_branching filter.
     3033    $branching = false;
    30203034
    30213035    if ( $is_customize_admin_page && isset( $input_vars['changeset_uuid'] ) ) {
     
    32503264
    32513265                b[c] = b[c].replace( rcs, ' ' );
    3252                 // The customizer requires postMessage and CORS (if the site is cross domain)
     3266                // The customizer requires postMessage and CORS (if the site is cross domain).
    32533267                b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
    32543268            }());
Note: See TracChangeset for help on using the changeset viewer.