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/comment.php

    r47060 r47122  
    439439
    440440//
    441 // Comment meta functions
     441// Comment meta functions.
    442442//
    443443
     
    658658    global $wpdb;
    659659
    660     // Simple duplicate check
     660    // Simple duplicate check.
    661661    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    662662    $dupe = $wpdb->prepare(
     
    870870    }
    871871
    872     // don't throttle admins or moderators
     872    // Don't throttle admins or moderators.
    873873    if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
    874874        return false;
     
    10941094        }
    10951095
    1096         // Find this comment's top level parent if threading is enabled
     1096        // Find this comment's top-level parent if threading is enabled.
    10971097        if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) {
    10981098            return get_page_of_comment( $comment->comment_parent, $args );
     
    11211121            $page = 1;
    11221122
    1123             // Divide comments older than this one by comments per page to get this comment's page number
     1123            // Divide comments older than this one by comments per page to get this comment's page number.
    11241124        } else {
    11251125            $page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] );
     
    11811181            $max_length = 0;
    11821182
    1183             // No point if we can't get the DB column lengths
     1183            // No point if we can't get the DB column lengths.
    11841184            if ( is_wp_error( $col_length ) ) {
    11851185                break;
     
    12731273    $mod_keys = trim( get_option( 'blacklist_keys' ) );
    12741274    if ( '' == $mod_keys ) {
    1275         return false; // If moderation keys are empty
     1275        return false; // If moderation keys are empty.
    12761276    }
    12771277
     
    12841284        $word = trim( $word );
    12851285
    1286         // Skip empty lines
     1286        // Skip empty lines.
    12871287        if ( empty( $word ) ) {
    12881288            continue; }
    12891289
    1290         // Do some escaping magic so that '#' chars in the
    1291         // spam words don't break things:
     1290        // Do some escaping magic so that '#' chars
     1291        // in the spam words don't break things:
    12921292        $word = preg_quote( $word, '#' );
    12931293
     
    14081408    }
    14091409
    1410     // Delete metadata
     1410    // Delete metadata.
    14111411    $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) );
    14121412    foreach ( $meta_ids as $mid ) {
     
    16911691function wp_transition_comment_status( $new_status, $old_status, $comment ) {
    16921692    /*
    1693      * Translate raw statuses to human readable formats for the hooks.
     1693     * Translate raw statuses to human-readable formats for the hooks.
    16941694     * This is not a complete list of comment status, it's only the ones
    1695      * that need to be renamed
     1695     * that need to be renamed.
    16961696     */
    16971697    $comment_statuses = array(
    16981698        0         => 'unapproved',
    1699         'hold'    => 'unapproved', // wp_set_comment_status() uses "hold"
     1699        'hold'    => 'unapproved', // wp_set_comment_status() uses "hold".
    17001700        1         => 'approved',
    1701         'approve' => 'approved', // wp_set_comment_status() uses "approve"
     1701        'approve' => 'approved',   // wp_set_comment_status() uses "approve".
    17021702    );
    17031703    if ( isset( $comment_statuses[ $new_status ] ) ) {
     
    17081708    }
    17091709
    1710     // Call the hooks
     1710    // Call the hooks.
    17111711    if ( $new_status != $old_status ) {
    17121712        /**
     
    20212021 */
    20222022function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) {
    2023     if ( $block ) { // a plugin has already blocked... we'll let that decision stand
     2023    if ( $block ) { // A plugin has already blocked... we'll let that decision stand.
    20242024        return $block;
    20252025    }
     
    23222322    global $wpdb;
    23232323
    2324     // First, get all of the original fields
     2324    // First, get all of the original fields.
    23252325    $comment = get_comment( $commentarr['comment_ID'], ARRAY_A );
    23262326    if ( empty( $comment ) ) {
     
    24312431    if ( is_bool( $defer ) ) {
    24322432        $_defer = $defer;
    2433         // flush any deferred counts
     2433        // Flush any deferred counts.
    24342434        if ( ! $defer ) {
    24352435            wp_update_comment_count( null, true );
     
    25872587    }
    25882588
    2589     //Do not search for a pingback server on our own uploads
     2589    // Do not search for a pingback server on our own uploads.
    25902590    $uploads_dir = wp_get_upload_dir();
    25912591    if ( 0 === strpos( $url, $uploads_dir['baseurl'] ) ) {
     
    26142614    }
    26152615
    2616     // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file)
     2616    // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file).
    26172617    $response = wp_safe_remote_get(
    26182618        $url,
     
    26402640        $pingback_server_url     = substr( $contents, $pingback_href_start, $pingback_server_url_len );
    26412641
    2642         // We may find rel="pingback" but an incomplete pingback URL
     2642        // We may find rel="pingback" but an incomplete pingback URL.
    26432643        if ( $pingback_server_url_len > 0 ) { // We got it!
    26442644            return $pingback_server_url;
     
    28052805    include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
    28062806
    2807     // original code by Mort (http://mort.mine.nu:8080)
     2807    // Original code by Mort (http://mort.mine.nu:8080).
    28082808    $post_links = array();
    28092809
     
    28192819    }
    28202820
    2821     // Step 1
    2822     // Parsing the post, external links (if any) are stored in the $post_links array
     2821    /*
     2822     * Step 1.
     2823     * Parsing the post, external links (if any) are stored in the $post_links array.
     2824     */
    28232825    $post_links_temp = wp_extract_urls( $content );
    28242826
    2825     // Step 2.
    2826     // Walking thru the links array
    2827     // first we get rid of links pointing to sites, not to specific files
    2828     // Example:
    2829     // http://dummy-weblog.org
    2830     // http://dummy-weblog.org/
    2831     // http://dummy-weblog.org/post.php
    2832     // We don't wanna ping first and second types, even if they have a valid <link/>
    2833 
    2834     foreach ( (array) $post_links_temp as $link_test ) :
    2835         if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) // If we haven't pung it already and it isn't a link to itself
    2836                 && ! is_local_attachment( $link_test ) ) : // Also, let's never ping local attachments.
     2827    /*
     2828     * Step 2.
     2829     * Walking through the links array.
     2830     * First we get rid of links pointing to sites, not to specific files.
     2831     * Example:
     2832     * http://dummy-weblog.org
     2833     * http://dummy-weblog.org/
     2834     * http://dummy-weblog.org/post.php
     2835     * We don't wanna ping first and second types, even if they have a valid <link/>.
     2836     */
     2837    foreach ( (array) $post_links_temp as $link_test ) {
     2838        // If we haven't pung it already and it isn't a link to itself.
     2839        if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID )
     2840                // Also, let's never ping local attachments.
     2841                && ! is_local_attachment( $link_test ) ) {
    28372842            $test = @parse_url( $link_test );
    28382843            if ( $test ) {
     
    28432848                }
    28442849            }
    2845         endif;
    2846     endforeach;
     2850        }
     2851    }
    28472852
    28482853    $post_links = array_unique( $post_links );
     2854
    28492855    /**
    28502856     * Fires just before pinging back links found in a post.
     
    28632869        if ( $pingback_server_url ) {
    28642870            set_time_limit( 60 );
    2865             // Now, the RPC call
     2871            // Now, the RPC call.
    28662872            $pagelinkedfrom = get_permalink( $post );
    28672873
    2868             // using a timeout of 3 seconds should be enough to cover slow servers
     2874            // Using a timeout of 3 seconds should be enough to cover slow servers.
    28692875            $client          = new WP_HTTP_IXR_Client( $pingback_server_url );
    28702876            $client->timeout = 3;
     
    28822888             */
    28832889            $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . get_bloginfo( 'version' ), $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom );
    2884             // when set to true, this outputs debug messages by itself
     2890            // When set to true, this outputs debug messages by itself.
    28852891            $client->debug = false;
    28862892
    2887             if ( $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto ) || ( isset( $client->error->code ) && 48 == $client->error->code ) ) { // Already registered
     2893            if ( $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto ) || ( isset( $client->error->code ) && 48 == $client->error->code ) ) { // Already registered.
    28882894                add_ping( $post, $pagelinkedto );
    28892895            }
     
    29612967    include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
    29622968
    2963     // using a timeout of 3 seconds should be enough to cover slow servers
     2969    // Using a timeout of 3 seconds should be enough to cover slow servers.
    29642970    $client             = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' == $path ) ) ? false : $path ) );
    29652971    $client->timeout    = 3;
    29662972    $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );
    29672973
    2968     // when set to true, this outputs debug messages by itself
     2974    // When set to true, this outputs debug messages by itself.
    29692975    $client->debug = false;
    29702976    $home          = trailingslashit( home_url() );
    2971     if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // then try a normal ping
     2977    if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping.
    29722978        $client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home );
    29732979    }
     
    30073013
    30083014//
    3009 // Cache
     3015// Cache.
    30103016//
    30113017
     
    30863092
    30873093//
    3088 // Internal
     3094// Internal.
    30893095//
    30903096
     
    33173323    }
    33183324
    3319     // If the user is logged in
     3325    // If the user is logged in.
    33203326    $user = wp_get_current_user();
    33213327    if ( $user->exists() ) {
     
    33313337                || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID )
    33323338            ) {
    3333                 kses_remove_filters(); // start with a clean slate
    3334                 kses_init_filters(); // set up the filters
     3339                kses_remove_filters(); // Start with a clean slate.
     3340                kses_init_filters();   // Set up the filters.
    33353341                remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
    33363342                add_filter( 'pre_comment_content', 'wp_filter_kses' );
Note: See TracChangeset for help on using the changeset viewer.