WordPress.org

Make WordPress Core

Changeset 47119


Ignore:
Timestamp:
01/29/2020 12:33:45 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve comments in some wp-admin files per the documentation standards.

Follow-up to [47084].

Props passoniate, apedog.
Fixes #49223, #49227.

Location:
trunk/src/wp-admin/includes
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/meta-boxes.php

    r47088 r47119  
    11<?php
    2 
    3 // -- Post related Meta Boxes
     2/**
     3 * WordPress Administration Meta Boxes API.
     4 *
     5 * @package WordPress
     6 * @subpackage Administration
     7 */
     8
     9//
     10// Post-related Meta Boxes.
     11//
    412
    513/**
     
    3139<div id="minor-publishing">
    3240
    33     <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
     41    <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
    3442<div style="display:none;">
    3543    <?php submit_button( __( 'Save' ), '', 'save' ); ?>
     
    7280<input type="hidden" name="wp-preview" id="wp-preview" value="" />
    7381</div>
    74 <?php endif; // public post type ?>
     82<?php endif; // is_post_type_viewable() ?>
    7583    <?php
    7684    /**
     
    203211
    204212    if ( 0 != $post->ID ) {
    205         if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
     213        if ( 'future' == $post->post_status ) { // Scheduled for publishing at a future date.
    206214            /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */
    207215            $stamp = __( 'Scheduled for: %s' );
    208         } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
     216        } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // Already published.
    209217            /* translators: Post date information. %s: Date on which the post was published. */
    210218            $stamp = __( 'Published on: %s' );
    211         } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
     219        } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified.
    212220            $stamp = __( 'Publish <b>immediately</b>' );
    213         } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
     221        } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified.
    214222            /* translators: Post date information. %s: Date on which the post is to be published. */
    215223            $stamp = __( 'Schedule for: %s' );
    216         } else { // draft, 1 or more saves, date specified
     224        } else { // Draft, 1 or more saves, date specified.
    217225            /* translators: Post date information. %s: Date on which the post is to be published. */
    218226            $stamp = __( 'Publish on: %s' );
     
    223231            date_i18n( $time_format, strtotime( $post->post_date ) )
    224232        );
    225     } else { // draft (no saves, and thus no date specified)
     233    } else { // Draft (no saves, and thus no date specified).
    226234        $stamp = __( 'Publish <b>immediately</b>' );
    227235        $date  = sprintf(
     
    244252endif;
    245253
    246     if ( $can_publish ) : // Contributors don't get to choose the date of publish
     254    if ( $can_publish ) : // Contributors don't get to choose the date of publish.
    247255        ?>
    248256<div class="misc-pub-section curtime misc-pub-curtime">
     
    372380<div id="minor-publishing">
    373381
    374     <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
     382    <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
    375383<div style="display:none;">
    376384    <?php submit_button( __( 'Save' ), '', 'save' ); ?>
     
    463471                $post_format = '0';
    464472            }
    465             // Add in the current one if it isn't there yet, in case the current theme doesn't support it
     473            // Add in the current one if it isn't there yet, in case the current theme doesn't support it.
    466474            if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) {
    467475                $post_formats[0][] = $post_format;
     
    592600            <?php
    593601            $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
    594             echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
     602            // Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
     603            echo "<input type='hidden' name='{$name}[]' value='0' />";
    595604            ?>
    596605            <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
     
    793802     * @param WP_Post $post WP_Post object of the current post.
    794803     */
    795     do_action( 'post_comment_status_meta_box-options', $post );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     804    do_action( 'post_comment_status_meta_box-options', $post ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
    796805    ?>
    797806</p>
     
    904913}
    905914
    906 // -- Page related Meta Boxes
     915//
     916// Page-related Meta Boxes.
     917//
    907918
    908919/**
     
    942953            <?php echo $pages; ?>
    943954            <?php
    944         endif; // end empty pages check
    945     endif;  // end hierarchical check.
     955        endif; // End empty pages check.
     956    endif;  // End hierarchical check.
    946957
    947958    if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
     
    9991010}
    10001011
    1001 // -- Link related Meta Boxes
     1012//
     1013// Link-related Meta Boxes.
     1014//
    10021015
    10031016/**
     
    10141027<div id="minor-publishing">
    10151028
    1016     <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
     1029    <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
    10171030<div style="display:none;">
    10181031    <?php submit_button( __( 'Save' ), '', 'save', false ); ?>
     
    11641177
    11651178    if ( ! empty( $deprecated ) ) {
    1166         _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented
     1179        _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
    11671180    }
    11681181
     
    14141427        // We should aim to show the revisions meta box only when there are revisions.
    14151428        if ( count( $revisions ) > 1 ) {
    1416             reset( $revisions ); // Reset pointer for key()
     1429            reset( $revisions ); // Reset pointer for key().
    14171430            $publish_callback_args = array(
    14181431                'revisions_count'        => count( $revisions ),
     
    14411454    }
    14421455
    1443     // all taxonomies
     1456    // All taxonomies.
    14441457    foreach ( get_object_taxonomies( $post ) as $tax_name ) {
    14451458        $taxonomy = get_taxonomy( $tax_name );
     
    15241537
    15251538    if ( in_array( get_post_status( $post ), $stati ) ) {
    1526         // If the post type support comments, or the post has comments, allow the
    1527         // Comments meta box.
     1539        // If the post type support comments, or the post has comments,
     1540        // allow the Comments meta box.
    15281541        if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
    15291542            add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
  • trunk/src/wp-admin/includes/misc.php

    r47088 r47119  
    179179    }
    180180
    181     // Split out the existing file into the preceding lines, and those that appear after the marker
     181    // Split out the existing file into the preceding lines, and those that appear after the marker.
    182182    $pre_lines        = array();
    183183    $post_lines       = array();
     
    202202    }
    203203
    204     // Check to see if there was a change
     204    // Check to see if there was a change.
    205205    if ( $existing_lines === $insertion ) {
    206206        flock( $fp, LOCK_UN );
     
    210210    }
    211211
    212     // Generate the new file data
     212    // Generate the new file data.
    213213    $new_file_data = implode(
    214214        "\n",
     
    222222    );
    223223
    224     // Write to the start of the file, and truncate it to that length
     224    // Write to the start of the file, and truncate it to that length.
    225225    fseek( $fp, 0 );
    226226    $bytes = fwrite( $fp, $new_file_data );
     
    297297    $web_config_file = $home_path . 'web.config';
    298298
    299     // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
     299    // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
    300300    if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable( $web_config_file ) ) ) {
    301301        $rule = $wp_rewrite->iis7_url_rewrite_rules( false );
     
    599599
    600600        if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
    601             // If it's a function or class defined locally, there's not going to be any docs available
     601            // If it's a function or class defined locally, there's not going to be any docs available.
    602602            if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
    603603                $ignore_functions[] = $tokens[ $t ][1];
    604604            }
    605             // Add this to our stack of unique references
     605            // Add this to our stack of unique references.
    606606            $functions[] = $tokens[ $t ][1];
    607607        }
     
    674674            case 'export_personal_data_requests_per_page':
    675675            case 'remove_personal_data_requests_per_page':
    676                 // Network admin
     676                // Network admin.
    677677            case 'sites_network_per_page':
    678678            case 'users_network_per_page':
     
    703703                 * @param int      $value  The number of rows to use.
    704704                 */
    705                 $value = apply_filters( 'set-screen-option', false, $option, $value );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     705                $value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
    706706
    707707                if ( false === $value ) {
     
    761761 */
    762762function iis7_delete_rewrite_rule( $filename ) {
    763     // If configuration file does not exist then rules also do not exist so there is nothing to delete
     763    // If configuration file does not exist then rules also do not exist, so there is nothing to delete.
    764764    if ( ! file_exists( $filename ) ) {
    765765        return true;
     
    818818    $xpath = new DOMXPath( $doc );
    819819
    820     // First check if the rule already exists as in that case there is no need to re-add it
     820    // First check if the rule already exists as in that case there is no need to re-add it.
    821821    $wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
    822822    if ( $wordpress_rules->length > 0 ) {
     
    824824    }
    825825
    826     // Check the XPath to the rewrite rule and create XML nodes if they do not exist
     826    // Check the XPath to the rewrite rule and create XML nodes if they do not exist.
    827827    $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
    828828    if ( $xmlnodes->length > 0 ) {
  • trunk/src/wp-admin/includes/ms-admin-filters.php

    r46586 r47119  
    88 */
    99
    10 // Media Hooks.
     10// Media hooks.
    1111add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
    1212
    13 // User Hooks
     13// User hooks.
    1414add_action( 'user_admin_notices', 'new_user_email_admin_notice' );
    1515add_action( 'network_admin_notices', 'new_user_email_admin_notice' );
     
    1717add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
    1818
    19 // Site Hooks.
     19// Site hooks.
    2020add_action( 'wpmueditblogaction', 'upload_space_setting' );
    2121
    22 // Network hooks
     22// Network hooks.
    2323add_action( 'update_site_option_admin_email', 'wp_network_admin_email_change_notification', 10, 4 );
    2424
    25 // Taxonomy Hooks
     25// Taxonomy hooks.
    2626add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
    2727
    28 // Post Hooks.
     28// Post hooks.
    2929add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
    3030
    31 // Tools Hooks.
     31// Tools hooks.
    3232add_filter( 'import_allow_create_users', 'check_import_new_users' );
    3333
    34 // Notices Hooks
     34// Notices hooks.
    3535add_action( 'admin_notices', 'site_admin_notice' );
    3636add_action( 'network_admin_notices', 'site_admin_notice' );
    3737
    38 // Update Hooks
     38// Update hooks.
    3939add_action( 'network_admin_notices', 'update_nag', 3 );
    4040add_action( 'network_admin_notices', 'maintenance_nag', 10 );
    4141
    42 // Network Admin Hooks
     42// Network Admin hooks.
    4343add_action( 'add_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
    4444add_action( 'update_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
  • trunk/src/wp-admin/includes/ms.php

    r47093 r47119  
    2121    }
    2222
    23     if ( $file['error'] != '0' ) { // there's already an error
     23    if ( $file['error'] != '0' ) { // There's already an error.
    2424        return $file;
    2525    }
     
    130130 * @since 3.0.0
    131131 *
    132  * @todo Merge with wp_delete_user() ?
     132 * @todo Merge with wp_delete_user()?
    133133 *
    134134 * @global wpdb $wpdb WordPress database abstraction object.
     
    178178            }
    179179
    180             // Clean links
     180            // Clean links.
    181181            $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
    182182
     
    221221    $space_allowed = get_space_allowed();
    222222    if ( ! is_numeric( $space_allowed ) ) {
    223         $space_allowed = 10; // Default space allowed is 10 MB
     223        $space_allowed = 10; // Default space allowed is 10 MB.
    224224    }
    225225    $space_used = get_space_used();
     
    645645        $code_lang = basename( $val, '.mo' );
    646646
    647         if ( $code_lang == 'en_US' ) { // American English
     647        if ( $code_lang == 'en_US' ) { // American English.
    648648            $flag          = true;
    649649            $ae            = __( 'American English' );
    650650            $output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
    651         } elseif ( $code_lang == 'en_GB' ) { // British English
     651        } elseif ( $code_lang == 'en_GB' ) { // British English.
    652652            $flag          = true;
    653653            $be            = __( 'British English' );
     
    659659    }
    660660
    661     if ( $flag === false ) { // WordPress english
     661    if ( $flag === false ) { // WordPress English.
    662662        $output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>';
    663663    }
    664664
    665     // Order by name
     665    // Order by name.
    666666    uksort( $output, 'strnatcasecmp' );
    667667
     
    10681068    );
    10691069
    1070     // Parse arguments
     1070    // Parse arguments.
    10711071    $parsed_args = wp_parse_args(
    10721072        $args,
     
    10781078    );
    10791079
    1080     // Setup the links array
     1080    // Setup the links array.
    10811081    $screen_links = array();
    10821082
    1083     // Loop through tabs
     1083    // Loop through tabs.
    10841084    foreach ( $parsed_args['links'] as $link_id => $link ) {
    10851085
    1086         // Skip link if user can't access
     1086        // Skip link if user can't access.
    10871087        if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) {
    10881088            continue;
    10891089        }
    10901090
    1091         // Link classes
     1091        // Link classes.
    10921092        $classes = array( 'nav-tab' );
    10931093
     
    10951095        $aria_current = '';
    10961096
    1097         // Selected is set by the parent OR assumed by the $pagenow global
     1097        // Selected is set by the parent OR assumed by the $pagenow global.
    10981098        if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
    10991099            $classes[]    = 'nav-tab-active';
     
    11011101        }
    11021102
    1103         // Escape each class
     1103        // Escape each class.
    11041104        $esc_classes = implode( ' ', $classes );
    11051105
    1106         // Get the URL for this link
     1106        // Get the URL for this link.
    11071107        $url = add_query_arg( array( 'id' => $parsed_args['blog_id'] ), network_admin_url( $link['url'] ) );
    11081108
    1109         // Add link to nav links
     1109        // Add link to nav links.
    11101110        $screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';
    11111111    }
  • trunk/src/wp-admin/includes/nav-menu.php

    r46842 r47119  
    139139 */
    140140function wp_nav_menu_setup() {
    141     // Register meta boxes
     141    // Register meta boxes.
    142142    wp_nav_menu_post_type_meta_boxes();
    143143    add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
    144144    wp_nav_menu_taxonomy_meta_boxes();
    145145
    146     // Register advanced menu items (columns)
     146    // Register advanced menu items (columns).
    147147    add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
    148148
     
    423423    }
    424424
    425     // @todo transient caching of these results with proper invalidation on updating of a post of this type
     425    // @todo Transient caching of these results with proper invalidation on updating of a post of this type.
    426426    $get_posts = new WP_Query;
    427427    $posts     = $get_posts->query( $args );
     
    922922                    // Or URL is the default.
    923923                    in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ) ) ||
    924                     ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)
     924                    // Or it's not a custom menu item (but not the custom home page).
     925                    ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) ||
    925926                    // Or it *is* a custom menu item that already exists.
    926927                    ! empty( $_item_object_data['menu-item-db-id'] )
     
    11431144    $messages            = array();
    11441145    $menu_items          = array();
    1145     // Index menu items by db ID
     1146    // Index menu items by DB ID.
    11461147    foreach ( $unsorted_menu_items as $_item ) {
    11471148        $menu_items[ $_item->db_id ] = $_item;
     
    11651166
    11661167    wp_defer_term_counting( true );
    1167     // Loop through all the menu items' POST variables
     1168    // Loop through all the menu items' POST variables.
    11681169    if ( ! empty( $_POST['menu-item-db-id'] ) ) {
    11691170        foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
    11701171
    1171             // Menu item title can't be blank
     1172            // Menu item title can't be blank.
    11721173            if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
    11731174                continue;
     
    11891190    }
    11901191
    1191     // Remove menu items from the menu that weren't in $_POST
     1192    // Remove menu items from the menu that weren't in $_POST.
    11921193    if ( ! empty( $menu_items ) ) {
    11931194        foreach ( array_keys( $menu_items ) as $menu_item_id ) {
     
    12141215        }
    12151216    }
    1216     // Remove nonexistent/deleted menus
     1217    // Remove non-existent/deleted menus.
    12171218    $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
    12181219    update_option( 'nav_menu_options', $nav_menu_option );
     
    12531254        foreach ( $data as $post_input_data ) {
    12541255            // For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
    1255             // derive the array path keys via regex and set the value in $_POST.
     1256            // derive the array path keys via regex and set the value in $_POST.
    12561257            preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
    12571258
     
    12651266
    12661267            // Build the new array value from leaf to trunk.
    1267             for ( $i = count( $array_bits ) - 1; $i >= 0; $i -- ) {
     1268            for ( $i = count( $array_bits ) - 1; $i >= 0; $i-- ) {
    12681269                if ( $i == count( $array_bits ) - 1 ) {
    12691270                    $new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
  • trunk/src/wp-admin/includes/network.php

    r47085 r47119  
    182182    if ( isset( $_POST['subdomain_install'] ) ) {
    183183        $subdomain_install = (bool) $_POST['subdomain_install'];
    184     } elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // assume nothing
     184    } elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // Assume nothing.
    185185        $subdomain_install = true;
    186186    } elseif ( ! allow_subdirectory_install() ) {
     
    189189        $subdomain_install = false;
    190190        $got_mod_rewrite   = got_mod_rewrite();
    191         if ( $got_mod_rewrite ) { // dangerous assumptions
     191        if ( $got_mod_rewrite ) { // Dangerous assumptions.
    192192            echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
    193193            printf(
     
    207207        }
    208208
    209         if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache)
     209        if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
    210210            echo '<p>';
    211211            printf(
     
    226226            <strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
    227227        <p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
    228         <?php // @todo: Link to an MS readme? ?>
     228        <?php // @todo Link to an MS readme? ?>
    229229        <table class="form-table" role="presentation">
    230230            <tr>
     
    548548    <?php
    549549    if ( iis7_supports_permalinks() ) :
    550         // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
     550        // IIS doesn't support RewriteBase, all your RewriteBase are belong to us.
    551551        $iis_subdir_match       = ltrim( $base, '/' ) . $subdir_match;
    552552        $iis_rewrite_base       = ltrim( $base, '/' ) . $rewrite_base;
     
    617617
    618618        <?php
    619     else : // end iis7_supports_permalinks(). construct an htaccess file instead:
     619    else : // End iis7_supports_permalinks(). Construct an .htaccess file instead:
    620620
    621621        $ms_files_rewriting = '';
     
    659659
    660660        <?php
    661     endif; // end IIS/Apache code branches.
     661    endif; // End IIS/Apache code branches.
    662662
    663663    if ( ! is_multisite() ) {
  • trunk/src/wp-admin/includes/plugin-install.php

    r46463 r47119  
    101101 */
    102102function plugins_api( $action, $args = array() ) {
    103     // include an unmodified $wp_version
     103    // Include an unmodified $wp_version.
    104104    include( ABSPATH . WPINC . '/version.php' );
    105105
     
    119119
    120120    if ( ! isset( $args->wp_version ) ) {
    121         $args->wp_version = substr( $wp_version, 0, 3 ); // X.y
     121        $args->wp_version = substr( $wp_version, 0, 3 ); // x.y
    122122    }
    123123
     
    286286        echo $api_tags->get_error_message();
    287287    } else {
    288         //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud()
     288        // Set up the tags in a way which can be interpreted by wp_generate_tag_cloud().
    289289        $tags = array();
    290290        foreach ( (array) $api_tags as $tag ) {
     
    438438    }
    439439
    440     // Default to a "new" plugin
     440    // Default to a "new" plugin.
    441441    $status      = 'install';
    442442    $url         = false;
     
    471471                }
    472472            } else {
    473                 $key         = array_keys( $installed_plugin );
    474                 $key         = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
     473                $key = array_keys( $installed_plugin );
     474                // Use the first plugin regardless of the name.
     475                // Could have issues for multiple plugins in one directory if they share different version numbers.
     476                $key = reset( $key );
     477
    475478                $update_file = $api->slug . '/' . $key;
    476479                if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
     
    480483                    $version = $installed_plugin[ $key ]['Version'];
    481484                } else {
    482                     //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
     485                    // If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh.
    483486                    if ( ! $loop ) {
    484487                        delete_site_transient( 'update_plugins' );
     
    489492            }
    490493        } else {
    491             // "install" & no directory with that slug
     494            // "install" & no directory with that slug.
    492495            if ( current_user_can( 'install_plugins' ) ) {
    493496                $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
     
    571574    );
    572575
    573     // Sanitize HTML
     576    // Sanitize HTML.
    574577    foreach ( (array) $api->sections as $section_name => $content ) {
    575578        $api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags );
     
    584587    $_tab = esc_attr( $tab );
    585588
    586     $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
     589    // Default to the Description tab, Do not translate, API returns English.
     590    $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description';
    587591    if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
    588592        $section_titles = array_keys( (array) $api->sections );
  • trunk/src/wp-admin/includes/plugin.php

    r47113 r47119  
    332332        }
    333333
    334         $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
     334        // Do not apply markup/translate as it will be cached.
     335        $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false );
    335336
    336337        if ( empty( $plugin_data['Name'] ) ) {
     
    358359 */
    359360function get_mu_plugins() {
    360     $wp_plugins = array();
    361     // Files in wp-content/mu-plugins directory.
     361    $wp_plugins   = array();
    362362    $plugin_files = array();
    363363
     
    365365        return $wp_plugins;
    366366    }
     367
     368    // Files in wp-content/mu-plugins directory.
    367369    $plugins_dir = @opendir( WPMU_PLUGIN_DIR );
    368370    if ( $plugins_dir ) {
     
    387389        }
    388390
    389         $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
     391        // Do not apply markup/translate as it will be cached.
     392        $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false );
    390393
    391394        if ( empty( $plugin_data['Name'] ) ) {
     
    396399    }
    397400
    398     if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) { // silence is golden
     401    if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) {
     402        // Silence is golden.
    399403        unset( $wp_plugins['index.php'] );
    400404    }
     
    432436    $_dropins = _get_dropins();
    433437
    434     // These exist in the wp-content directory.
     438    // Files in wp-content directory.
    435439    $plugins_dir = @opendir( WP_CONTENT_DIR );
    436440    if ( $plugins_dir ) {
     
    454458            continue;
    455459        }
    456         $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
     460
     461        // Do not apply markup/translate as it will be cached.
     462        $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false );
     463
    457464        if ( empty( $plugin_data['Name'] ) ) {
    458465            $plugin_data['Name'] = $plugin_file;
    459466        }
     467
    460468        $dropins[ $plugin_file ] = $plugin_data;
    461469    }
     
    478486function _get_dropins() {
    479487    $dropins = array(
    480         'advanced-cache.php'      => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
    481         'db.php'                  => array( __( 'Custom database class.' ), true ), // auto on load
    482         'db-error.php'            => array( __( 'Custom database error message.' ), true ), // auto on error
    483         'install.php'             => array( __( 'Custom installation script.' ), true ), // auto on installation
    484         'maintenance.php'         => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance
    485         'object-cache.php'        => array( __( 'External object cache.' ), true ), // auto on load
    486         'php-error.php'           => array( __( 'Custom PHP error message.' ), true ), // auto on error
    487         'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // auto on error
     488        'advanced-cache.php'      => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ),  // WP_CACHE
     489        'db.php'                  => array( __( 'Custom database class.' ), true ),          // Auto on load.
     490        'db-error.php'            => array( __( 'Custom database error message.' ), true ),  // Auto on error.
     491        'install.php'             => array( __( 'Custom installation script.' ), true ),     // Auto on installation.
     492        'maintenance.php'         => array( __( 'Custom maintenance message.' ), true ),     // Auto on maintenance.
     493        'object-cache.php'        => array( __( 'External object cache.' ), true ),          // Auto on load.
     494        'php-error.php'           => array( __( 'Custom PHP error message.' ), true ),       // Auto on error.
     495        'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // Auto on error.
    488496    );
    489497
    490498    if ( is_multisite() ) {
    491499        $dropins['sunrise.php']        = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
    492         $dropins['blog-deleted.php']   = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog
    493         $dropins['blog-inactive.php']  = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog
    494         $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog
     500        $dropins['blog-deleted.php']   = array( __( 'Custom site deleted message.' ), true );   // Auto on deleted blog.
     501        $dropins['blog-inactive.php']  = array( __( 'Custom site inactive message.' ), true );  // Auto on inactive blog.
     502        $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // Auto on archived or spammed blog.
    495503    }
    496504
     
    639647    if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
    640648        if ( ! empty( $redirect ) ) {
    641             wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); // we'll override this later if the plugin can be included without fatal error
     649            // We'll override this later if the plugin can be included without fatal error.
     650            wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
    642651        }
    643652
     
    909918    if ( ! WP_Filesystem( $credentials ) ) {
    910919        ob_start();
    911         request_filesystem_credentials( $url, '', true ); // Failed to connect, Error and request again.
     920        // Failed to connect. Error and request again.
     921        request_filesystem_credentials( $url, '', true );
    912922        $data = ob_get_clean();
    913923
     
    959969
    960970        // If plugin is in its own directory, recursively delete the directory.
    961         if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
     971        // Base check on if plugin includes directory separator AND that it's not the root plugin folder.
     972        if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) {
    962973            $deleted = $wp_filesystem->delete( $this_plugin_dir, true );
    963974        } else {
     
    12381249
    12391250//
    1240 // Menu
     1251// Menu.
    12411252//
    12421253
     
    13071318    $_registered_pages[ $hookname ] = true;
    13081319
    1309     // No parent as top level
     1320    // No parent as top level.
    13101321    $_parent_pages[ $menu_slug ] = false;
    13111322
     
    14131424        }
    14141425    }
    1415     // Sort the parent array
     1426    // Sort the parent array.
    14161427    ksort( $submenu[ $parent_slug ] );
    14171428
     
    17941805
    17951806//
    1796 // Pluggable Menu Support -- Private
     1807// Pluggable Menu Support -- Private.
    17971808//
    17981809/**
     
    19331944                }
    19341945
    1935                 if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) { // not the current page
     1946                if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) { // Not the current page.
    19361947                    continue;
    19371948                }
  • trunk/src/wp-admin/includes/post.php

    r46826 r47119  
    9393        $post_data['post_status'] = sanitize_key( $post_data['post_status'] );
    9494
    95         // No longer an auto-draft
     95        // No longer an auto-draft.
    9696        if ( 'auto-draft' === $post_data['post_status'] ) {
    9797            $post_data['post_status'] = 'draft';
     
    103103    }
    104104
    105     // What to do based on which button they pressed
     105    // What to do based on which button they pressed.
    106106    if ( isset( $post_data['saveasdraft'] ) && '' != $post_data['saveasdraft'] ) {
    107107        $post_data['post_status'] = 'draft';
     
    133133    $published_statuses = array( 'publish', 'future' );
    134134
    135     // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
     135    // Posts 'submitted for approval' are submitted to $_POST the same as if they were being published.
    136136    // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
    137137    if ( isset( $post_data['post_status'] ) && ( in_array( $post_data['post_status'], $published_statuses ) && ! current_user_can( $ptype->cap->publish_posts ) ) ) {
     
    209209    }
    210210
    211     // Pass through errors
     211    // Pass through errors.
    212212    if ( is_wp_error( $post_data ) ) {
    213213        return $post_data;
     
    269269        $revision  = current( $revisions );
    270270
    271         // Check if the revisions have been upgraded
     271        // Check if the revisions have been upgraded.
    272272        if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
    273273            _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
     
    297297    $translated = _wp_get_allowed_postdata( $post_data );
    298298
    299     // Post Formats
     299    // Post formats.
    300300    if ( isset( $post_data['post_format'] ) ) {
    301301        set_post_format( $post_ID, $post_data['post_format'] );
     
    337337    }
    338338
    339     // Meta Stuff
     339    // Meta stuff.
    340340    if ( isset( $post_data['meta'] ) && $post_data['meta'] ) {
    341341        foreach ( $post_data['meta'] as $key => $value ) {
     
    373373    }
    374374
    375     // Attachment stuff
     375    // Attachment stuff.
    376376    if ( 'attachment' == $post_data['post_type'] ) {
    377377        if ( isset( $post_data['_wp_attachment_image_alt'] ) ) {
    378378            $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
     379
    379380            if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
    380381                $image_alt = wp_strip_all_tags( $image_alt, true );
    381                 // update_meta expects slashed.
     382
     383                // update_post_meta() expects slashed.
    382384                update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
    383385            }
     
    406408
    407409    $success = wp_update_post( $translated );
    408     // If the save failed, see if we can sanity check the main fields and try again
     410
     411    // If the save failed, see if we can sanity check the main fields and try again.
    409412    if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
    410413        $fields = array( 'post_title', 'post_content', 'post_excerpt' );
     
    419422    }
    420423
    421     // Now that we have an ID we can fix any attachment anchor hrefs
     424    // Now that we have an ID we can fix any attachment anchor hrefs.
    422425    _fix_attachment_links( $post_ID );
    423426
     
    677680        }
    678681
    679         // Schedule auto-draft cleanup
     682        // Schedule auto-draft cleanup.
    680683        if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
    681684            wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
     
    817820    unset( $_POST['filter'] );
    818821
    819     // Edit don't write if we have a post id.
     822    // Edit, don't write, if we have a post ID.
    820823    if ( isset( $_POST['post_ID'] ) ) {
    821824        return edit_post();
     
    858861    add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
    859862
    860     // Now that we have an ID we can fix any attachment anchor hrefs
     863    // Now that we have an ID we can fix any attachment anchor hrefs.
    861864    _fix_attachment_links( $post_ID );
    862865
     
    883886
    884887//
    885 // Post Meta
     888// Post Meta.
    886889//
    887890
     
    914917
    915918        if ( $metakeyinput ) {
    916             $metakey = $metakeyinput; // default
     919            $metakey = $metakeyinput; // Default.
    917920        }
    918921
     
    927930
    928931    return false;
    929 } // add_meta
     932}
    930933
    931934/**
     
    10181021
    10191022//
    1020 // Private
     1023// Private.
    10211024//
    10221025
     
    10391042    }
    10401043
    1041     // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
     1044    // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero).
    10421045    if ( ! strpos( $content, '?attachment_id=' ) || ! preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) {
    10431046        return;
     
    10451048
    10461049    $site_url = get_bloginfo( 'url' );
    1047     $site_url = substr( $site_url, (int) strpos( $site_url, '://' ) ); // remove the http(s)
     1050    $site_url = substr( $site_url, (int) strpos( $site_url, '://' ) ); // Remove the http(s).
    10481051    $replace  = '';
    10491052
     
    10551058        }
    10561059
    1057         $quote  = $url_match[1]; // the quote (single or double)
     1060        $quote  = $url_match[1]; // The quote (single or double).
    10581061        $url_id = (int) $url_match[2];
    10591062        $rel_id = (int) $rel_match[1];
     
    13451348    }
    13461349
    1347     // If the user wants to set a new name -- override the current one
    1348     // Note: if empty name is supplied -- use the title instead, see #6072
     1350    // If the user wants to set a new name -- override the current one.
     1351    // Note: if empty name is supplied -- use the title instead, see #6072.
    13491352    if ( ! is_null( $name ) ) {
    13501353        $post->post_name = sanitize_title( $name ? $name : $title, $post->ID );
     
    13571360    $permalink = get_permalink( $post, true );
    13581361
    1359     // Replace custom post_type Token with generic pagename token for ease of use.
     1362    // Replace custom post_type token with generic pagename token for ease of use.
    13601363    $permalink = str_replace( "%$post->post_type%", '%pagename%', $permalink );
    13611364
    1362     // Handle page hierarchy
     1365    // Handle page hierarchy.
    13631366    if ( $ptype->hierarchical ) {
    13641367        $uri = get_page_uri( $post );
     
    14321435                $view_link = get_permalink( $post );
    14331436            } else {
    1434                 // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set
     1437                // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set.
    14351438                $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink );
    14361439            }
     
    14381441    }
    14391442
    1440     // Permalinks without a post/page name placeholder don't have anything to edit
     1443    // Permalinks without a post/page name placeholder don't have anything to edit.
    14411444    if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
    14421445        $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
     
    14491452        }
    14501453
    1451         // Encourage a pretty permalink setting
     1454        // Encourage a pretty permalink setting.
    14521455        if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option( 'show_on_front' ) && $id == get_option( 'page_on_front' ) ) ) {
    14531456            $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __( 'Change Permalinks' ) . "</a></span>\n";
     
    16931696        if ( get_post_type_object( $post->post_type )->public ) {
    16941697            if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
    1695                 // Latest content is in autosave
     1698                // Latest content is in autosave.
    16961699                $nonce                       = wp_create_nonce( 'post_preview_' . $post->ID );
    16971700                $query_args['preview_id']    = $post->ID;
     
    17481751        }
    17491752
    1750         // Allow plugins to prevent some users overriding the post lock
     1753        // Allow plugins to prevent some users overriding the post lock.
    17511754        if ( $override ) {
    17521755            ?>
     
    18201823        $new_autosave['post_author'] = $post_author;
    18211824
     1825        $post = get_post( $post_id );
     1826
    18221827        // If the new autosave has the same content as the post, delete the autosave.
    1823         $post                  = get_post( $post_id );
    18241828        $autosave_is_different = false;
    18251829        foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
     
    18501854    $post_data = wp_unslash( $post_data );
    18511855
    1852     // Otherwise create the new autosave as a special post revision
     1856    // Otherwise create the new autosave as a special post revision.
    18531857    return _wp_put_post_revision( $post_data, true );
    18541858}
     
    19231927 */
    19241928function wp_autosave( $post_data ) {
    1925     // Back-compat
     1929    // Back-compat.
    19261930    if ( ! defined( 'DOING_AUTOSAVE' ) ) {
    19271931        define( 'DOING_AUTOSAVE', true );
     
    19511955
    19521956    if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
    1953         // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
     1957        // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked.
    19541958        return edit_post( wp_slash( $post_data ) );
    19551959    } else {
    1956         // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
     1960        // Non-drafts or other users' drafts are not overwritten.
     1961        // The autosave is stored in a special post revision for each user.
    19571962        return wp_create_post_autosave( wp_slash( $post_data ) );
    19581963    }
Note: See TracChangeset for help on using the changeset viewer.