Changeset 47122 for trunk/src/wp-includes/comment.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/comment.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r47060 r47122 439 439 440 440 // 441 // Comment meta functions 441 // Comment meta functions. 442 442 // 443 443 … … 658 658 global $wpdb; 659 659 660 // Simple duplicate check 660 // Simple duplicate check. 661 661 // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 662 662 $dupe = $wpdb->prepare( … … 870 870 } 871 871 872 // don't throttle admins or moderators872 // Don't throttle admins or moderators. 873 873 if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) { 874 874 return false; … … 1094 1094 } 1095 1095 1096 // Find this comment's top level parent if threading is enabled1096 // Find this comment's top-level parent if threading is enabled. 1097 1097 if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) { 1098 1098 return get_page_of_comment( $comment->comment_parent, $args ); … … 1121 1121 $page = 1; 1122 1122 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. 1124 1124 } else { 1125 1125 $page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] ); … … 1181 1181 $max_length = 0; 1182 1182 1183 // No point if we can't get the DB column lengths 1183 // No point if we can't get the DB column lengths. 1184 1184 if ( is_wp_error( $col_length ) ) { 1185 1185 break; … … 1273 1273 $mod_keys = trim( get_option( 'blacklist_keys' ) ); 1274 1274 if ( '' == $mod_keys ) { 1275 return false; // If moderation keys are empty 1275 return false; // If moderation keys are empty. 1276 1276 } 1277 1277 … … 1284 1284 $word = trim( $word ); 1285 1285 1286 // Skip empty lines 1286 // Skip empty lines. 1287 1287 if ( empty( $word ) ) { 1288 1288 continue; } 1289 1289 1290 // Do some escaping magic so that '#' chars in the1291 // spam words don't break things:1290 // Do some escaping magic so that '#' chars 1291 // in the spam words don't break things: 1292 1292 $word = preg_quote( $word, '#' ); 1293 1293 … … 1408 1408 } 1409 1409 1410 // Delete metadata 1410 // Delete metadata. 1411 1411 $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) ); 1412 1412 foreach ( $meta_ids as $mid ) { … … 1691 1691 function wp_transition_comment_status( $new_status, $old_status, $comment ) { 1692 1692 /* 1693 * Translate raw statuses to human readable formats for the hooks.1693 * Translate raw statuses to human-readable formats for the hooks. 1694 1694 * 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. 1696 1696 */ 1697 1697 $comment_statuses = array( 1698 1698 0 => 'unapproved', 1699 'hold' => 'unapproved', // wp_set_comment_status() uses "hold" 1699 'hold' => 'unapproved', // wp_set_comment_status() uses "hold". 1700 1700 1 => 'approved', 1701 'approve' => 'approved', // wp_set_comment_status() uses "approve"1701 'approve' => 'approved', // wp_set_comment_status() uses "approve". 1702 1702 ); 1703 1703 if ( isset( $comment_statuses[ $new_status ] ) ) { … … 1708 1708 } 1709 1709 1710 // Call the hooks 1710 // Call the hooks. 1711 1711 if ( $new_status != $old_status ) { 1712 1712 /** … … 2021 2021 */ 2022 2022 function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) { 2023 if ( $block ) { // a plugin has already blocked... we'll let that decision stand2023 if ( $block ) { // A plugin has already blocked... we'll let that decision stand. 2024 2024 return $block; 2025 2025 } … … 2322 2322 global $wpdb; 2323 2323 2324 // First, get all of the original fields 2324 // First, get all of the original fields. 2325 2325 $comment = get_comment( $commentarr['comment_ID'], ARRAY_A ); 2326 2326 if ( empty( $comment ) ) { … … 2431 2431 if ( is_bool( $defer ) ) { 2432 2432 $_defer = $defer; 2433 // flush any deferred counts2433 // Flush any deferred counts. 2434 2434 if ( ! $defer ) { 2435 2435 wp_update_comment_count( null, true ); … … 2587 2587 } 2588 2588 2589 // Do not search for a pingback server on our own uploads2589 // Do not search for a pingback server on our own uploads. 2590 2590 $uploads_dir = wp_get_upload_dir(); 2591 2591 if ( 0 === strpos( $url, $uploads_dir['baseurl'] ) ) { … … 2614 2614 } 2615 2615 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). 2617 2617 $response = wp_safe_remote_get( 2618 2618 $url, … … 2640 2640 $pingback_server_url = substr( $contents, $pingback_href_start, $pingback_server_url_len ); 2641 2641 2642 // We may find rel="pingback" but an incomplete pingback URL 2642 // We may find rel="pingback" but an incomplete pingback URL. 2643 2643 if ( $pingback_server_url_len > 0 ) { // We got it! 2644 2644 return $pingback_server_url; … … 2805 2805 include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); 2806 2806 2807 // original code by Mort (http://mort.mine.nu:8080)2807 // Original code by Mort (http://mort.mine.nu:8080). 2808 2808 $post_links = array(); 2809 2809 … … 2819 2819 } 2820 2820 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 */ 2823 2825 $post_links_temp = wp_extract_urls( $content ); 2824 2826 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 ) ) { 2837 2842 $test = @parse_url( $link_test ); 2838 2843 if ( $test ) { … … 2843 2848 } 2844 2849 } 2845 endif;2846 endforeach;2850 } 2851 } 2847 2852 2848 2853 $post_links = array_unique( $post_links ); 2854 2849 2855 /** 2850 2856 * Fires just before pinging back links found in a post. … … 2863 2869 if ( $pingback_server_url ) { 2864 2870 set_time_limit( 60 ); 2865 // Now, the RPC call 2871 // Now, the RPC call. 2866 2872 $pagelinkedfrom = get_permalink( $post ); 2867 2873 2868 // using a timeout of 3 seconds should be enough to cover slow servers2874 // Using a timeout of 3 seconds should be enough to cover slow servers. 2869 2875 $client = new WP_HTTP_IXR_Client( $pingback_server_url ); 2870 2876 $client->timeout = 3; … … 2882 2888 */ 2883 2889 $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 itself2890 // When set to true, this outputs debug messages by itself. 2885 2891 $client->debug = false; 2886 2892 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. 2888 2894 add_ping( $post, $pagelinkedto ); 2889 2895 } … … 2961 2967 include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); 2962 2968 2963 // using a timeout of 3 seconds should be enough to cover slow servers2969 // Using a timeout of 3 seconds should be enough to cover slow servers. 2964 2970 $client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' == $path ) ) ? false : $path ) ); 2965 2971 $client->timeout = 3; 2966 2972 $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' ); 2967 2973 2968 // when set to true, this outputs debug messages by itself2974 // When set to true, this outputs debug messages by itself. 2969 2975 $client->debug = false; 2970 2976 $home = trailingslashit( home_url() ); 2971 if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // then try a normal ping2977 if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping. 2972 2978 $client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home ); 2973 2979 } … … 3007 3013 3008 3014 // 3009 // Cache 3015 // Cache. 3010 3016 // 3011 3017 … … 3086 3092 3087 3093 // 3088 // Internal 3094 // Internal. 3089 3095 // 3090 3096 … … 3317 3323 } 3318 3324 3319 // If the user is logged in 3325 // If the user is logged in. 3320 3326 $user = wp_get_current_user(); 3321 3327 if ( $user->exists() ) { … … 3331 3337 || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID ) 3332 3338 ) { 3333 kses_remove_filters(); // start with a clean slate3334 kses_init_filters(); // set up the filters3339 kses_remove_filters(); // Start with a clean slate. 3340 kses_init_filters(); // Set up the filters. 3335 3341 remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); 3336 3342 add_filter( 'pre_comment_content', 'wp_filter_kses' );
Note: See TracChangeset
for help on using the changeset viewer.