Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (7 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-admin/includes/ajax-actions.php

    r47088 r47122  
    2323        $response = array();
    2424
    25         // screen_id is the same as $current_screen->id and the JS global 'pagenow'.
     25        // 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'.
    2626        if ( ! empty( $_POST['screen_id'] ) ) {
    2727                $screen_id = sanitize_key( $_POST['screen_id'] );
    … …  
    273273        $return = array();
    274274
    275         // Check the type of request
    276         // Current allowed values are `add` and `search`
     275        // Check the type of request.
     276        // Current allowed values are `add` and `search`.
    277277        if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) {
    278278                $type = $_REQUEST['autocomplete_type'];
    … …  
    281281        }
    282282
    283         // Check the desired field for value
    284         // Current allowed values are `user_email` and `user_login`
     283        // Check the desired field for value.
     284        // Current allowed values are `user_email` and `user_login`.
    285285        if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) {
    286286                $field = $_REQUEST['autocomplete_field'];
    … …  
    289289        }
    290290
    291         // Exclude current users of this blog
     291        // Exclude current users of this blog.
    292292        if ( isset( $_REQUEST['site_id'] ) ) {
    293293                $id = absint( $_REQUEST['site_id'] );
    … …  
    434434        $url      = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : '';
    435435
    436         // JS didn't send us everything we need to know. Just die with success message
     436        // JS didn't send us everything we need to know. Just die with success message.
    437437        if ( ! $total || ! $per_page || ! $page || ! $url ) {
    438438                $time           = time();
    … …  
    483483        }
    484484
    485         // Only do the expensive stuff on a page-break, and about 1 other time per page
     485        // Only do the expensive stuff on a page-break, and about 1 other time per page.
    486486        if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
    487487                $post_id = 0;
    … …  
    601601                $checked_categories[] = $cat_id;
    602602
    603                 if ( $parent ) { // Do these all at once in a second
     603                if ( $parent ) { // Do these all at once in a second.
    604604                        continue;
    605605                }
    … …  
    627627        }
    628628
    629         if ( $parent ) { // Foncy - replace the parent and all its children
     629        if ( $parent ) { // Foncy - replace the parent and all its children.
    630630                $parent  = get_term( $parent, $taxonomy->name );
    631631                $term_id = $parent->term_id;
    632632
    633                 while ( $parent->parent ) { // get the top parent
     633                while ( $parent->parent ) { // Get the top parent.
    634634                        $parent = get_term( $parent->parent, $taxonomy->name );
    635635                        if ( is_wp_error( $parent ) ) {
    … …  
    717717                $r = wp_untrash_comment( $comment );
    718718
    719                 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { // undo trash, not in trash
     719                // Undo trash, not in trash.
     720                if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
    720721                        $delta = 1;
    721722                }
    … …  
    733734                $r = wp_unspam_comment( $comment );
    734735
    735                 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { // undo spam, not in spam
     736                // Undo spam, not in spam.
     737                if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
    736738                        $delta = 1;
    737739                }
    … …  
    742744        }
    743745
    744         if ( $r ) { // Decide if we need to send back '1' or a more complicated response including page links and comment counts
     746        if ( $r ) {
     747                // Decide if we need to send back '1' or a more complicated response including page links and comment counts.
    745748                _wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
    746749        }
    … …  
    990993        }
    991994
    992         // Decide if we need to send back '1' or a more complicated response including page links and comment counts
     995        // Decide if we need to send back '1' or a more complicated response including page links and comment counts.
    993996        _wp_ajax_delete_comment_response( $comment->comment_ID );
    994997        wp_die( 0 );
    … …  
    11621165        }
    11631166
    1164         // We need raw tag names here, so don't filter the output
     1167        // We need raw tag names here, so don't filter the output.
    11651168        $return = wp_generate_tag_cloud(
    11661169                $tags,
    … …  
    12891292
    12901293                        if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
    1291                                 kses_remove_filters(); // start with a clean slate
    1292                                 kses_init_filters(); // set up the filters
     1294                                kses_remove_filters(); // Start with a clean slate.
     1295                                kses_init_filters();   // Set up the filters.
    12931296                                remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
    12941297                                add_filter( 'pre_comment_content', 'wp_filter_kses' );
    … …  
    14791482                        $_menu_item  = reset( $_menu_items );
    14801483
    1481                         // Restore the missing menu item properties
     1484                        // Restore the missing menu item properties.
    14821485                        $menu_item_data['menu-item-description'] = $_menu_item->description;
    14831486                }
    … …  
    14991502                        $menu_obj        = wp_setup_nav_menu_item( $menu_obj );
    15001503                        $menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title;
    1501                         $menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
     1504                        $menu_obj->label = $menu_obj->title; // Don't show "(pending)" in ajax-added items.
    15021505                        $menu_items[]    = $menu_obj;
    15031506                }
    … …  
    15491552                if ( $post->post_status == 'auto-draft' ) {
    15501553                        $post_data                = array();
    1551                         $post_data['action']      = 'draft'; // Warning fix
     1554                        $post_data['action']      = 'draft'; // Warning fix.
    15521555                        $post_data['post_ID']     = $pid;
    15531556                        $post_data['post_type']   = $post->post_type;
    … …  
    16091612
    16101613                if ( ! $meta ) {
    1611                         wp_die( 0 ); // if meta doesn't exist
     1614                        wp_die( 0 ); // If meta doesn't exist.
    16121615                }
    16131616
    … …  
    17321735
    17331736        if ( is_array( $hidden ) ) {
    1734                 $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); // postboxes that are always shown
     1737                // Postboxes that are always shown.
     1738                $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) );
    17351739                update_user_option( $user->ID, "metaboxhidden_$page", $hidden, true );
    17361740        }
    … …  
    26212625 */
    26222626function wp_ajax_set_post_thumbnail() {
    2623         $json = ! empty( $_REQUEST['json'] ); // New-style request
     2627        $json = ! empty( $_REQUEST['json'] ); // New-style request.
    26242628
    26252629        $post_ID = intval( $_POST['post_id'] );
    … …  
    32273231        } else {
    32283232                $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
    3229                 $rel  = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized
     3233                $rel  = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized.
    32303234
    32313235                if ( ! empty( $url ) ) {
    … …  
    32883292
    32893293        if ( $check_embed !== $fallback ) {
    3290                 // TinyMCE view for [embed] will parse this
     3294                // TinyMCE view for [embed] will parse this.
    32913295                $html = '[embed]' . $src . '[/embed]';
    32923296        } elseif ( $link_text ) {
    … …  
    33283332        $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
    33293333
    3330         // screen_id is the same as $current_screen->id and the JS global 'pagenow'.
     3334        // 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'.
    33313335        if ( ! empty( $_POST['screen_id'] ) ) {
    33323336                $screen_id = sanitize_key( $_POST['screen_id'] );
    … …  
    33933397        do_action( 'heartbeat_tick', $response, $screen_id );
    33943398
    3395         // Send the current time according to the server
     3399        // Send the current time according to the server.
    33963400        $response['server_time'] = time();
    33973401
    … …  
    37363740        }
    37373741
    3738         // the embed shortcode requires a post
     3742        // The embed shortcode requires a post.
    37393743        if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    37403744                if ( 'embed' === $shortcode ) {
Note: See TracChangeset for help on using the changeset viewer.