Ticket #25522: 25522.2.diff
File 25522.2.diff, 22.7 KB (added by , 12 years ago) |
---|
-
src/wp-includes/comment.php
27 27 * @since 1.2.0 28 28 * @uses $wpdb 29 29 * 30 * @param string $author Comment Author's name 31 * @param string $email Comment Author's email 32 * @param string $url Comment Author's URL 33 * @param string $comment Comment contents 34 * @param string $user_ip Comment Author's IP address 35 * @param string $user_agent Comment Author's User Agent 30 * @param string $author Comment Author's name. 31 * @param string $email Comment Author's email. 32 * @param string $url Comment Author's URL. 33 * @param string $comment Comment contents. 34 * @param string $user_ip Comment Author's IP address. 35 * @param string $user_agent Comment Author's User Agent. 36 36 * @param string $comment_type Comment type, either user submitted comment, 37 * trackback, or pingback 37 * trackback, or pingback. 38 38 * @return bool Whether the checks passed (true) and the comments should be 39 * displayed or set to moderated 39 * displayed or set to moderated. 40 40 */ 41 41 function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) { 42 42 global $wpdb; … … 44 44 if ( 1 == get_option('comment_moderation') ) 45 45 return false; // If moderation is set to manual 46 46 47 /** 48 * Filter the comment text. 49 * 50 * @since 1.2.1 51 * 52 * @param string $comment The comment text. 53 */ 47 54 $comment = apply_filters( 'comment_text', $comment ); 48 55 49 56 // Check # of external links 50 57 if ( $max_links = get_option( 'comment_max_links' ) ) { 51 58 $num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out ); 59 60 /** 61 * Filters the maximum amount of links allowed in a comment 62 * 63 * @since 3.0.0 64 * 65 * @param int $num_links The number of links allowed. 66 * @param string $url Comment Author's URL. 67 */ 52 68 $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); // provide for counting of $url as a link 53 69 if ( $num_links >= $max_links ) 54 70 return false; … … 102 118 * @since 2.0.0 103 119 * @uses $wpdb 104 120 * 105 * @param int $post_id The ID of the post 121 * @param int $post_id The ID of the post. 106 122 * @return array $comments The approved comments 107 123 */ 108 124 function get_approved_comments($post_id) { … … 147 163 } 148 164 } 149 165 166 /** 167 * Fires after a comment is retrieved. 168 * 169 * @since 2.3.0 170 * 171 * @param mixed $_comment Comment data. 172 */ 150 173 $_comment = apply_filters('get_comment', $_comment); 151 174 152 175 if ( $output == OBJECT ) { … … 188 211 */ 189 212 class WP_Comment_Query { 190 213 /** 191 * Metadata query container 214 * Metadata query container. 192 215 * 193 216 * @since 3.5.0 194 217 * @access public … … 197 220 var $meta_query = false; 198 221 199 222 /** 200 * Date query container 223 * Date query container. 201 224 * 202 225 * @since 3.7.0 203 226 * @access public … … 206 229 var $date_query = false; 207 230 208 231 /** 209 * Execute the query 232 * Execute the query. 210 233 * 211 234 * @since 3.1.0 212 235 * 213 * @param string|array $query_vars 236 * @param string|array $query_vars. 214 237 * @return int|array 215 238 */ 216 239 function query( $query_vars ) { … … 251 274 $this->meta_query = new WP_Meta_Query(); 252 275 $this->meta_query->parse_query_vars( $this->query_vars ); 253 276 277 /** 278 * Fires before comments are retrieved. 279 * 280 * @since 3.1.0 281 * 282 * @param WP_Comment_Query Current instance of WP_Comment_Query. 283 */ 254 284 do_action_ref_array( 'pre_get_comments', array( &$this ) ); 255 285 extract( $this->query_vars, EXTR_SKIP ); 256 286 … … 376 406 } 377 407 378 408 $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits', 'groupby' ); 409 410 /** 411 * Filter the comments clauses 412 * 413 * @since 3.1.0 414 * 415 * @param array An array containing all the pieces. 416 * @param WP_Comment_Query Current instance of WP_Comment_Query. 417 */ 379 418 $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); 380 419 foreach ( $pieces as $piece ) 381 420 $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; … … 389 428 return $wpdb->get_var( $query ); 390 429 391 430 $comments = $wpdb->get_results( $query ); 431 432 /** 433 * Filter the comment query results. 434 * 435 * @since 3.1.0 436 * 437 * @param array An array containing the comments. 438 * @param WP_Comment_Query Current instance of WP_Comment_Query. 439 */ 392 440 $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) ); 393 441 394 442 wp_cache_add( $cache_key, $comments, 'comment' ); … … 397 445 } 398 446 399 447 /** 400 * Used internally to generate an SQL string for searching across multiple columns 448 * Used internally to generate an SQL string for searching across multiple columns. 401 449 * 402 450 * @access protected 403 451 * @since 3.1.0 … … 568 616 * @uses delete_metadata 569 617 * @link http://codex.wordpress.org/Function_Reference/delete_comment_meta 570 618 * 571 * @param int $comment_id comment ID 619 * @param int $comment_id comment ID. 572 620 * @param string $meta_key Metadata name. 573 621 * @param mixed $meta_value Optional. Metadata value. 574 622 * @return bool True on success, false on failure. … … 629 677 if ( $user->exists() ) 630 678 return; 631 679 680 /** 681 * Filter the lifetime of the comment cookie. 682 * 683 * @since 2.8.0 684 * 685 * @param int $seconds Comment cookie lifetime. Default is 30000000 seconds (ca. 347 days). 686 */ 632 687 $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000); 633 688 setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); 634 689 setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); … … 636 691 } 637 692 638 693 /** 639 * Sanitize sthe cookies sent to the user already.694 * Sanitize the cookies sent to the user already. 640 695 * 641 696 * Will only do anything if the cookies have already been created for the user. 642 697 * Mostly used after cookies had been sent to use elsewhere. … … 645 700 */ 646 701 function sanitize_comment_cookies() { 647 702 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { 703 /** 704 * Filter the comment author's name cookie before it is set. 705 * 706 * @since 2.1.0 707 * 708 * @param string $author_cookie The comment author name. 709 */ 648 710 $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); 649 711 $comment_author = wp_unslash($comment_author); 650 712 $comment_author = esc_attr($comment_author); … … 652 714 } 653 715 654 716 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { 717 /** 718 * Filter the comment author's email cookie before it is set. 719 * 720 * @since 2.8.0 721 * 722 * @param string $author_email_cookie The comment author email. 723 */ 655 724 $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); 656 725 $comment_author_email = wp_unslash($comment_author_email); 657 726 $comment_author_email = esc_attr($comment_author_email); … … 659 728 } 660 729 661 730 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { 731 /** 732 * Filter the comment author's URL cookie before it is set. 733 * 734 * @since 2.1.0 735 * 736 * @param string $author_url_cookie The comment author URL. 737 */ 662 738 $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); 663 739 $comment_author_url = wp_unslash($comment_author_url); 664 740 $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; … … 674 750 * @uses apply_filters() Calls 'comment_duplicate_trigger' hook on commentdata. 675 751 * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt 676 752 * 677 * @param array $commentdata Contains information on the comment 753 * @param array $commentdata Contains information on the comment. 678 754 * @return mixed Signifies the approval status (0|1|'spam') 679 755 */ 680 756 function wp_allow_comment($commentdata) { … … 688 764 $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", wp_unslash( $comment_author_email ) ); 689 765 $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", wp_unslash( $comment_content ) ); 690 766 if ( $wpdb->get_var($dupe) ) { 767 /** 768 * Fires when a duplicate comment is detected. 769 * 770 * @since 3.0.0 771 * 772 * @param array $commentdata Comment data. 773 */ 691 774 do_action( 'comment_duplicate_trigger', $commentdata ); 692 775 if ( defined('DOING_AJAX') ) 693 776 die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); … … 695 778 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 696 779 } 697 780 781 /** 782 * Fires before a comment gets approved. 783 * 784 * Allows for checking of comment flooding. 785 * 786 * @since 2.3.0 787 * 788 * @param string $comment_author_IP The comment author's IP address 789 * @param string $comment_author_email The comment author's email 790 * @param string $comment_date_gmt The date the comment was posted in GMT 791 */ 698 792 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 699 793 700 794 if ( ! empty( $user_id ) ) { … … 705 799 if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { 706 800 // The author and the admins get respect. 707 801 $approved = 1; 708 802 } else { 709 803 // Everyone else's comments will be checked. 710 804 if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) ) 711 805 $approved = 1; … … 715 809 $approved = 'spam'; 716 810 } 717 811 812 /** 813 * Filter the comment's approval status before it is set. 814 * 815 * @since 2.1.0 816 * 817 * @param int|string $approved The approval status. Default is either 1, 0 or 'spam'. 818 * @param array $commentdata Comment data. 819 */ 718 820 $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); 719 821 return $approved; 720 822 } … … 744 846 if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) { 745 847 $time_lastcomment = mysql2date('U', $lasttime, false); 746 848 $time_newcomment = mysql2date('U', $date, false); 849 /** 850 * Filter the comment flood variable. 851 * 852 * @since 2.1.0 853 * 854 * @param bool $bool True if comment flooding is happening, false if not. Default is false. 855 * @param string $time_lastcomment Time when the last comment was posted. 856 * @param string $time_newcomment Time when the new comment was posted. 857 */ 747 858 $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); 748 859 if ( $flood_die ) { 860 /** 861 * Fires before comment flooding message is triggered 862 * 863 * @since 2.1.0 864 * 865 * @param string $time_lastcomment Time when the last comment was posted 866 * @param string $time_newcomment Time when the new comment was posted 867 */ 749 868 do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 750 869 751 870 if ( defined('DOING_AJAX') ) … … 893 1012 * @since 1.5.0 894 1013 * @uses do_action() Calls 'wp_blacklist_check' hook for all parameters. 895 1014 * 896 * @param string $author The author of the comment 897 * @param string $email The email of the comment 898 * @param string $url The url used in the comment 899 * @param string $comment The comment content 900 * @param string $user_ip The comment author IP address 901 * @param string $user_agent The author's browser user agent 1015 * @param string $author The author of the comment. 1016 * @param string $email The email of the comment. 1017 * @param string $url The url used in the comment. 1018 * @param string $comment The comment content. 1019 * @param string $user_ip The comment author IP address. 1020 * @param string $user_agent The author's browser user agent. 902 1021 * @return bool True if comment contains blacklisted content, false if comment does not 903 1022 */ 904 1023 function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { 1024 /** 1025 * Fires before the comment is tested for blacklisted characters or words. 1026 * 1027 * @since 1.5.0 1028 * 1029 * @param string $author The author of the comment 1030 * @param string $email The email of the comment 1031 * @param string $url The url used in the comment 1032 * @param string $comment The comment content 1033 * @param string $user_ip The comment author IP address 1034 * @param string $user_agent The author's browser user agent 1035 */ 905 1036 do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); 906 1037 907 1038 $mod_keys = trim( get_option('blacklist_keys') ); … … 921 1052 922 1053 $pattern = "#$word#i"; 923 1054 if ( 924 1055 preg_match($pattern, $author) 925 1056 || preg_match($pattern, $email) 926 1057 || preg_match($pattern, $url) 927 1058 || preg_match($pattern, $comment) 928 1059 || preg_match($pattern, $user_ip) 929 1060 || preg_match($pattern, $user_agent) 930 1061 ) 931 1062 return true; 932 1063 } 933 1064 return false; … … 954 1085 955 1086 $post_id = (int) $post_id; 956 1087 1088 /** 1089 * Filter the comments count for the given post. 1090 * 1091 * @since 1092 * 1093 * @param array $count An empty array. 1094 * @param int $post_id Post ID. 1095 */ 957 1096 $stats = apply_filters('wp_count_comments', array(), $post_id); 958 1097 if ( !empty($stats) ) 959 1098 return $stats; … … 1007 1146 * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter 1008 1147 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object 1009 1148 * 1010 * @param int $comment_id Comment ID 1149 * @param int $comment_id Comment ID. 1011 1150 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. 1012 1151 * @return bool True on success, false on failure. 1013 1152 */ … … 1019 1158 if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) ) 1020 1159 return wp_trash_comment($comment_id); 1021 1160 1161 /** 1162 * Fires before a comment is deleted. 1163 * 1164 * @since 2.1.0 1165 * 1166 * @param int $comment_id Comment ID. 1167 */ 1022 1168 do_action('delete_comment', $comment_id); 1023 1169 1024 1170 // Move children up a level. … … 1035 1181 1036 1182 if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) 1037 1183 return false; 1184 1185 /** 1186 * Fires after comment metadata has been deleted. 1187 * 1188 * @since 2.9.0 1189 * 1190 * @param int $comment_id Comment ID. 1191 */ 1038 1192 do_action('deleted_comment', $comment_id); 1039 1193 1040 1194 $post_id = $comment->comment_post_ID; … … 1043 1197 1044 1198 clean_comment_cache($comment_id); 1045 1199 1200 /** 1201 * Fires before transitioning the comment's status to 'delete'. 1202 * 1203 * @since 2.1.0 1204 * 1205 * @param int $comment_id Comment ID. 1206 * @param string $status The new status 'delete'. 1207 */ 1046 1208 do_action('wp_set_comment_status', $comment_id, 'delete'); 1047 1209 wp_transition_comment_status('delete', $comment->comment_approved, $comment); 1048 1210 return true; 1049 1211 } 1050 1212 1051 1213 /** 1052 * Moves a comment to the Trash 1214 * Moves a comment to the Trash. 1053 1215 * 1054 1216 * If trash is disabled, comment is permanently deleted. 1055 1217 * … … 1068 1230 if ( !$comment = get_comment($comment_id) ) 1069 1231 return false; 1070 1232 1233 /** 1234 * Fires before a comment is sent to the trash. 1235 * 1236 * @since 2.9.0 1237 * 1238 * @param int $comment_id Comment ID. 1239 */ 1071 1240 do_action('trash_comment', $comment_id); 1072 1241 1073 1242 if ( wp_set_comment_status($comment_id, 'trash') ) { 1074 1243 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 1075 1244 add_comment_meta($comment_id, '_wp_trash_meta_time', time() ); 1245 1246 /** 1247 * Fires after a comment is sent to the trash. 1248 * 1249 * @since 2.9.0 1250 * 1251 * @param int $comment_id Comment ID. 1252 */ 1076 1253 do_action('trashed_comment', $comment_id); 1077 1254 return true; 1078 1255 } … … 1081 1258 } 1082 1259 1083 1260 /** 1084 * Removes a comment from the Trash 1261 * Removes a comment from the Trash. 1085 1262 * 1086 1263 * @since 2.9.0 1087 1264 * @uses do_action() on 'untrash_comment' before untrashing … … 1094 1271 if ( ! (int)$comment_id ) 1095 1272 return false; 1096 1273 1274 /** 1275 * Fires before a comment is restored from the trash. 1276 * 1277 * @since 2.9.0 1278 * 1279 * @param int $comment_id Comment ID. 1280 */ 1097 1281 do_action('untrash_comment', $comment_id); 1098 1282 1099 1283 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); … … 1103 1287 if ( wp_set_comment_status($comment_id, $status) ) { 1104 1288 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 1105 1289 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1290 /** 1291 * Fires after a comment is restored from the trash. 1292 * 1293 * @since 2.9.0 1294 * 1295 * @param int $comment_id Comment ID. 1296 */ 1106 1297 do_action('untrashed_comment', $comment_id); 1107 1298 return true; 1108 1299 } … … 1111 1302 } 1112 1303 1113 1304 /** 1114 * Marks a comment as Spam 1305 * Marks a comment as Spam. 1115 1306 * 1116 1307 * @since 2.9.0 1117 1308 * @uses do_action() on 'spam_comment' before spamming … … 1124 1315 if ( !$comment = get_comment($comment_id) ) 1125 1316 return false; 1126 1317 1318 /** 1319 * Fires before a comment is marked as spam. 1320 * 1321 * @since 2.9.0 1322 * 1323 * @param int $comment_id Comment ID. 1324 */ 1127 1325 do_action('spam_comment', $comment_id); 1128 1326 1129 1327 if ( wp_set_comment_status($comment_id, 'spam') ) { 1130 1328 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 1329 /** 1330 * Fires after a comment is marked as spam. 1331 * 1332 * @since 2.9.0 1333 * 1334 * @param int $comment_id Comment ID. 1335 */ 1131 1336 do_action('spammed_comment', $comment_id); 1132 1337 return true; 1133 1338 } … … 1136 1341 } 1137 1342 1138 1343 /** 1139 * Removes a comment from the Spam1344 * Fires before a comment is un-marked as Spam. 1140 1345 * 1141 1346 * @since 2.9.0 1142 1347 * @uses do_action() on 'unspam_comment' before unspamming … … 1149 1354 if ( ! (int)$comment_id ) 1150 1355 return false; 1151 1356 1357 /** 1358 * Fires after a comment is un-marked as Spam. 1359 * 1360 * @since 2.9.0 1361 * 1362 * @param int $comment_id Comment ID. 1363 */ 1152 1364 do_action('unspam_comment', $comment_id); 1153 1365 1154 1366 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); … … 1157 1369 1158 1370 if ( wp_set_comment_status($comment_id, $status) ) { 1159 1371 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1372 1373 /** 1374 * Fires after a comment is removed from the Spam. 1375 * 1376 * @since 2.9.0 1377 * 1378 * @param int $comment_id Comment ID. 1379 */ 1160 1380 do_action('unspammed_comment', $comment_id); 1161 1381 return true; 1162 1382 } … … 1169 1389 * 1170 1390 * @since 1.0.0 1171 1391 * 1172 * @param int $comment_id Comment ID 1392 * @param int $comment_id Comment ID. 1173 1393 * @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure. 1174 1394 */ 1175 1395 function wp_get_comment_status($comment_id) { … … 1305 1525 wp_update_comment_count($comment_post_ID); 1306 1526 1307 1527 $comment = get_comment($id); 1528 1529 /** 1530 * Fires after the comment is inserted. 1531 * 1532 * @since 1533 * 1534 * @param int $id Comment ID. 1535 * @param object $comment Comment object. 1536 */ 1308 1537 do_action('wp_insert_comment', $id, $comment); 1309 1538 1310 1539 wp_cache_set( 'last_changed', microtime(), 'comment' ); … … 1313 1542 } 1314 1543 1315 1544 /** 1316 * Filter s and sanitizescomment data.1545 * Filter and sanitize comment data. 1317 1546 * 1318 1547 * Sets the comment data 'filtered' field to true when finished. This can be 1319 1548 * checked as to whether the comment should be filtered and to keep from … … 1367 1596 /** 1368 1597 * Adds a new comment to the database. 1369 1598 * 1370 * Filter snew comment to ensure that the fields are sanitized and valid before1599 * Filter new comment to ensure that the fields are sanitized and valid before 1371 1600 * inserting comment into database. Calls 'comment_post' action with comment ID 1372 1601 * and whether comment is approved by WordPress. Also has 'preprocess_comment' 1373 1602 * filter for processing the comment data before the function handles it. … … 1491 1720 /** 1492 1721 * Updates an existing comment in the database. 1493 1722 * 1494 * Filter sthe comment and makes sure certain fields are valid before updating.1723 * Filter the comment and makes sure certain fields are valid before updating. 1495 1724 * 1496 1725 * @since 2.0.0 1497 1726 * @uses $wpdb … … 1584 1813 * @since 2.1.0 1585 1814 * @see wp_update_comment_count_now() For what could cause a false return value 1586 1815 * 1587 * @param int $post_id Post ID 1588 * @param bool $do_deferred Whether to process previously deferred post comment counts 1816 * @param int $post_id Post ID. 1817 * @param bool $do_deferred Whether to process previously deferred post comment counts. 1589 1818 * @return bool True on success, false on failure 1590 1819 */ 1591 1820 function wp_update_comment_count($post_id, $do_deferred=false) { … … 1617 1846 * @uses do_action() Calls 'wp_update_comment_count' hook on $post_id, $new, and $old 1618 1847 * @uses do_action() Calls 'edit_posts' hook on $post_id and $post 1619 1848 * 1620 * @param int $post_id Post ID 1849 * @param int $post_id Post ID. 1621 1850 * @return bool True on success, false on '0' $post_id or if post with ID does not exist. 1622 1851 */ 1623 1852 function wp_update_comment_count_now($post_id) { … … 1863 2092 1864 2093 if ( $pingback_server_url ) { 1865 2094 @ set_time_limit( 60 ); 1866 2095 // Now, the RPC call 1867 2096 $pagelinkedfrom = get_permalink($post_ID); 1868 2097 1869 2098 // using a timeout of 3 seconds should be enough to cover slow servers … … 1960 2189 } 1961 2190 1962 2191 /** 1963 * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI 2192 * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI. 1964 2193 * 1965 2194 * @since 3.5.1 1966 2195 * @see wp_http_validate_url() … … 2001 2230 * @package WordPress 2002 2231 * @subpackage Cache 2003 2232 * 2004 * @param int|array $ids Comment ID or array of comment IDs to remove from cache 2233 * @param int|array $ids Comment ID or array of comment IDs to remove from cache. 2005 2234 */ 2006 2235 function clean_comment_cache($ids) { 2007 2236 foreach ( (array) $ids as $id ) … … 2021 2250 * @package WordPress 2022 2251 * @subpackage Cache 2023 2252 * 2024 * @param array $comments Array of comment row objects 2253 * @param array $comments Array of comment row objects. 2025 2254 */ 2026 2255 function update_comment_cache($comments) { 2027 2256 foreach ( (array) $comments as $comment ) … … 2046 2275 if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) 2047 2276 return $posts; 2048 2277 2278 /** 2279 * Filter the post types on which old comments should be closed automatically. 2280 * 2281 * @since 3.2.0 2282 * 2283 * @param array $post_types An array of registered post types. 2284 */ 2049 2285 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2050 2286 if ( ! in_array( $posts[0]->post_type, $post_types ) ) 2051 2287 return $posts; … … 2068 2304 * @access private 2069 2305 * @since 2.7.0 2070 2306 * 2071 * @param bool $open Comments open or closed 2072 * @param int $post_id Post ID 2307 * @param bool $open Comments open or closed. 2308 * @param int $post_id Post ID. 2073 2309 * @return bool $open 2074 2310 */ 2075 2311 function _close_comments_for_old_post( $open, $post_id ) { … … 2085 2321 2086 2322 $post = get_post($post_id); 2087 2323 2324 /** This filter is documented in wp-includes/comment.php */ 2088 2325 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2089 2326 if ( ! in_array( $post->post_type, $post_types ) ) 2090 2327 return $open;