Ticket #25522: 25522.3.diff
File 25522.3.diff, 26.4 KB (added by , 12 years ago) |
---|
-
src/wp-includes/comment.php
44 44 if ( 1 == get_option('comment_moderation') ) 45 45 return false; // If moderation is set to manual 46 46 47 /** This filter is documented in wp-includes/comment-template.php */ 47 48 $comment = apply_filters( 'comment_text', $comment ); 48 49 49 50 // Check # of external links 50 51 if ( $max_links = get_option( 'comment_max_links' ) ) { 51 52 $num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out ); 52 $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); // provide for counting of $url as a link 53 /** 54 * Filter the maximum number of links allowed in a comment. 55 * 56 * @since 3.0.0 57 * 58 * @param int $num_links The number of links allowed. 59 * @param string $url Comment author's URL. Included in allowed links total. 60 */ 61 $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); 53 62 if ( $num_links >= $max_links ) 54 63 return false; 55 64 } … … 147 156 } 148 157 } 149 158 150 $_comment = apply_filters('get_comment', $_comment); 159 /** 160 * Fires after a comment is retrieved. 161 * 162 * @since 2.3.0 163 * 164 * @param mixed $_comment Comment data. 165 */ 166 $_comment = apply_filters( 'get_comment', $_comment ); 151 167 152 168 if ( $output == OBJECT ) { 153 169 return $_comment; … … 251 267 $this->meta_query = new WP_Meta_Query(); 252 268 $this->meta_query->parse_query_vars( $this->query_vars ); 253 269 270 /** 271 * Fires before comments are retrieved. 272 * 273 * @since 3.1.0 274 * 275 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query. 276 */ 254 277 do_action_ref_array( 'pre_get_comments', array( &$this ) ); 255 278 extract( $this->query_vars, EXTR_SKIP ); 256 279 … … 376 399 } 377 400 378 401 $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits', 'groupby' ); 402 /** 403 * Filter the comment query clauses. 404 * 405 * @since 3.1.0 406 * 407 * @param array $pieces An array containing the query pieces, passed by reference. 408 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query. 409 */ 379 410 $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); 380 411 foreach ( $pieces as $piece ) 381 412 $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; … … 389 420 return $wpdb->get_var( $query ); 390 421 391 422 $comments = $wpdb->get_results( $query ); 423 /** 424 * Filter the comment query results. 425 * 426 * @since 3.1.0 427 * 428 * @param array $comments An array of comment data, passed by reference. 429 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query. 430 */ 392 431 $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) ); 393 432 394 433 wp_cache_add( $cache_key, $comments, 'comment' ); … … 629 668 if ( $user->exists() ) 630 669 return; 631 670 632 $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000); 671 /** 672 * Filter the lifetime of the comment cookie. 673 * 674 * @since 2.8.0 675 * 676 * @param int $seconds Comment cookie lifetime. Default '30000000'. 677 */ 678 $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 ); 633 679 setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); 634 680 setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); 635 681 setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); … … 645 691 */ 646 692 function sanitize_comment_cookies() { 647 693 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { 648 $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); 694 /** 695 * Filter the comment author's name cookie before it is set. 696 * 697 * @since 1.5.2 698 * 699 * @param string $author_cookie The comment author name cookie. 700 */ 701 $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH] ); 649 702 $comment_author = wp_unslash($comment_author); 650 703 $comment_author = esc_attr($comment_author); 651 704 $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author; … … 652 705 } 653 706 654 707 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { 655 $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); 708 /** 709 * Filter the comment author's email cookie before it is set. 710 * 711 * @since 1.5.2 712 * 713 * @param string $author_email_cookie The comment author email cookie. 714 */ 715 $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH] ); 656 716 $comment_author_email = wp_unslash($comment_author_email); 657 717 $comment_author_email = esc_attr($comment_author_email); 658 718 $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; … … 659 719 } 660 720 661 721 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { 662 $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); 722 /** 723 * Filter the comment author's URL cookie before it is set. 724 * 725 * @since 1.5.2 726 * 727 * @param string $author_url_cookie The comment author URL cookie. 728 */ 729 $comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH] ); 663 730 $comment_author_url = wp_unslash($comment_author_url); 664 731 $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; 665 732 } … … 688 755 $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", wp_unslash( $comment_author_email ) ); 689 756 $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", wp_unslash( $comment_content ) ); 690 757 if ( $wpdb->get_var($dupe) ) { 758 /** 759 * Fires when a duplicate comment is detected. 760 * 761 * @since 3.0.0 762 * 763 * @param array $commentdata Comment data. 764 */ 691 765 do_action( 'comment_duplicate_trigger', $commentdata ); 692 766 if ( defined('DOING_AJAX') ) 693 767 die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); … … 695 769 wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); 696 770 } 697 771 772 /** 773 * Fires before a comment is approved. 774 * 775 * Allows for checking of comment flooding. 776 * 777 * @since 2.3.0 778 * 779 * @param string $comment_author_IP The comment author's IP address. 780 * @param string $comment_author_email The comment author's email. 781 * @param string $comment_date_gmt The GMT date the comment was posted. 782 */ 698 783 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 699 784 700 785 if ( ! empty( $user_id ) ) { … … 705 790 if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { 706 791 // The author and the admins get respect. 707 792 $approved = 1; 708 793 } else { 709 794 // Everyone else's comments will be checked. 710 795 if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) ) 711 796 $approved = 1; … … 715 800 $approved = 'spam'; 716 801 } 717 802 803 /** 804 * Filter the comment's approval status before it is set. 805 * 806 * @since 2.1.0 807 * 808 * @param int|string $approved The approval status. Accepts 1, 0, or 'spam'. 809 * @param array $commentdata Comment data. 810 */ 718 811 $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); 719 812 return $approved; 720 813 } … … 744 837 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 838 $time_lastcomment = mysql2date('U', $lasttime, false); 746 839 $time_newcomment = mysql2date('U', $date, false); 747 $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); 840 /** 841 * Filter the comment flood variable. 842 * 843 * @since 2.1.0 844 * 845 * @param bool $bool Whether comment flooding is occurring. Default false. 846 * @param string $time_lastcomment Time when the last comment was posted. 847 * @param string $time_newcomment Time when the new comment was posted. 848 */ 849 $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment ); 748 850 if ( $flood_die ) { 749 do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 851 /** 852 * Fires before comment flood message is triggered. 853 * 854 * @since 1.5.2 855 * 856 * @param string $time_lastcomment Time when the last comment was posted. 857 * @param string $time_newcomment Time when the new comment was posted. 858 */ 859 do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); 750 860 751 861 if ( defined('DOING_AJAX') ) 752 862 die( __('You are posting comments too quickly. Slow down.') ); … … 902 1012 * @return bool True if comment contains blacklisted content, false if comment does not 903 1013 */ 904 1014 function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { 905 do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); 1015 /** 1016 * Fires before the comment is tested for blacklisted characters or words. 1017 * 1018 * @since 1.5.2 1019 * 1020 * @param string $author The comment author. 1021 * @param string $email The comment author's email. 1022 * @param string $url The comment author's URL. 1023 * @param string $comment The comment content. 1024 * @param string $user_ip The comment author's IP address. 1025 * @param string $user_agent The comment author's browser user agent. 1026 */ 1027 do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); 906 1028 907 1029 $mod_keys = trim( get_option('blacklist_keys') ); 908 1030 if ( '' == $mod_keys ) … … 954 1076 955 1077 $post_id = (int) $post_id; 956 1078 957 $stats = apply_filters('wp_count_comments', array(), $post_id); 1079 /** 1080 * Filter the comments count for the given post. 1081 * 1082 * @since 2.7.0 1083 * 1084 * @param array $count An empty array. 1085 * @param int $post_id The post ID. 1086 */ 1087 $stats = apply_filters( 'wp_count_comments', array(), $post_id ); 958 1088 if ( !empty($stats) ) 959 1089 return $stats; 960 1090 … … 1019 1149 if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) ) 1020 1150 return wp_trash_comment($comment_id); 1021 1151 1022 do_action('delete_comment', $comment_id); 1152 /** 1153 * Fires before a comment is deleted. 1154 * 1155 * @since 1.2.1 1156 * 1157 * @param int $comment_id The comment ID. 1158 */ 1159 do_action( 'delete_comment', $comment_id ); 1023 1160 1024 1161 // Move children up a level. 1025 1162 $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) ); … … 1035 1172 1036 1173 if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) 1037 1174 return false; 1038 do_action('deleted_comment', $comment_id);1039 1175 1176 /** 1177 * Fires after the comment metadata has been deleted. 1178 * 1179 * @since 2.9.0 1180 * 1181 * @param int $comment_id The comment ID. 1182 */ 1183 do_action( 'deleted_comment', $comment_id ); 1184 1040 1185 $post_id = $comment->comment_post_ID; 1041 1186 if ( $post_id && $comment->comment_approved == 1 ) 1042 1187 wp_update_comment_count($post_id); … … 1043 1188 1044 1189 clean_comment_cache($comment_id); 1045 1190 1046 do_action('wp_set_comment_status', $comment_id, 'delete'); 1191 /** 1192 * Fires before changing the comment's status to 'delete'. 1193 * 1194 * @since 1.5.2 1195 * 1196 * @param int $comment_id The comment ID. 1197 * @param string $status The new status 'delete'. 1198 */ 1199 do_action( 'wp_set_comment_status', $comment_id, 'delete' ); 1047 1200 wp_transition_comment_status('delete', $comment->comment_approved, $comment); 1048 1201 return true; 1049 1202 } … … 1068 1221 if ( !$comment = get_comment($comment_id) ) 1069 1222 return false; 1070 1223 1071 do_action('trash_comment', $comment_id); 1224 /** 1225 * Fires before a comment is sent to Trash. 1226 * 1227 * @since 2.9.0 1228 * 1229 * @param int $comment_id The comment ID. 1230 */ 1231 do_action( 'trash_comment', $comment_id ); 1072 1232 1073 1233 if ( wp_set_comment_status($comment_id, 'trash') ) { 1074 1234 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 1075 1235 add_comment_meta($comment_id, '_wp_trash_meta_time', time() ); 1076 do_action('trashed_comment', $comment_id); 1236 1237 /** 1238 * Fires after a comment is sent to Trash. 1239 * 1240 * @since 2.9.0 1241 * 1242 * @param int $comment_id The comment ID. 1243 */ 1244 do_action( 'trashed_comment', $comment_id ); 1077 1245 return true; 1078 1246 } 1079 1247 … … 1094 1262 if ( ! (int)$comment_id ) 1095 1263 return false; 1096 1264 1097 do_action('untrash_comment', $comment_id); 1265 /** 1266 * Fires before a comment is restored from Trash. 1267 * 1268 * @since 2.9.0 1269 * 1270 * @param int $comment_id The comment ID. 1271 */ 1272 do_action( 'untrash_comment', $comment_id ); 1098 1273 1099 1274 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); 1100 1275 if ( empty($status) ) … … 1103 1278 if ( wp_set_comment_status($comment_id, $status) ) { 1104 1279 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 1105 1280 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1106 do_action('untrashed_comment', $comment_id); 1281 /** 1282 * Fires after a comment is restored from Trash. 1283 * 1284 * @since 2.9.0 1285 * 1286 * @param int $comment_id The comment ID. 1287 */ 1288 do_action( 'untrashed_comment', $comment_id ); 1107 1289 return true; 1108 1290 } 1109 1291 … … 1124 1306 if ( !$comment = get_comment($comment_id) ) 1125 1307 return false; 1126 1308 1127 do_action('spam_comment', $comment_id); 1309 /** 1310 * Fires before a comment is marked as Spam. 1311 * 1312 * @since 2.9.0 1313 * 1314 * @param int $comment_id The comment ID. 1315 */ 1316 do_action( 'spam_comment', $comment_id ); 1128 1317 1129 1318 if ( wp_set_comment_status($comment_id, 'spam') ) { 1130 1319 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 1131 do_action('spammed_comment', $comment_id); 1320 /** 1321 * Fires after a comment is marked as Spam. 1322 * 1323 * @since 2.9.0 1324 * 1325 * @param int $comment_id The comment ID. 1326 */ 1327 do_action( 'spammed_comment', $comment_id ); 1132 1328 return true; 1133 1329 } 1134 1330 … … 1149 1345 if ( ! (int)$comment_id ) 1150 1346 return false; 1151 1347 1152 do_action('unspam_comment', $comment_id); 1348 /** 1349 * Fires before a comment is unmarked as Spam. 1350 * 1351 * @since 2.9.0 1352 * 1353 * @param int $comment_id The comment ID. 1354 */ 1355 do_action( 'unspam_comment', $comment_id ); 1153 1356 1154 1357 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); 1155 1358 if ( empty($status) ) … … 1157 1360 1158 1361 if ( wp_set_comment_status($comment_id, $status) ) { 1159 1362 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1160 do_action('unspammed_comment', $comment_id); 1363 /** 1364 * Fires after a comment is unmarked as Spam. 1365 * 1366 * @since 2.9.0 1367 * 1368 * @param int $comment_id The comment ID. 1369 */ 1370 do_action( 'unspammed_comment', $comment_id ); 1161 1371 return true; 1162 1372 } 1163 1373 … … 1227 1437 1228 1438 // Call the hooks 1229 1439 if ( $new_status != $old_status ) { 1230 do_action('transition_comment_status', $new_status, $old_status, $comment); 1231 do_action("comment_{$old_status}_to_{$new_status}", $comment); 1440 /** 1441 * Fires 1442 * 1443 * @since 2.7.0 1444 * 1445 * @param int|string $new_status The new comment status. 1446 * @param int|string $old_status The old comment status. 1447 * @param string $comment The comment data. 1448 */ 1449 do_action( 'transition_comment_status', $new_status, $old_status, $comment ); 1450 /** 1451 * Fires 1452 * 1453 * @since 2.7.0 1454 * 1455 * @param obj $comment Comment object. 1456 */ 1457 do_action( "comment_{$old_status}_to_{$new_status}", $comment ); 1232 1458 } 1233 do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment); 1459 /** 1460 * Fires 1461 * 1462 * @since 2.7.0 1463 * 1464 * @param int $comment_ID The comment ID. 1465 * @param obj $comment Comment object. 1466 */ 1467 do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment ); 1234 1468 } 1235 1469 1236 1470 /** … … 1260 1494 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) 1261 1495 $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; 1262 1496 1263 return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url')); 1497 /** 1498 * Filter the current commenter's name, email, and URL. 1499 * 1500 * @since 3.1.0 1501 * 1502 * @param string $comment_author The comment author's name. 1503 * @param string $comment_author_email The comment author's email. 1504 * @param string $comment_author_url The comment author's URL. 1505 */ 1506 return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') ); 1264 1507 } 1265 1508 1266 1509 /** … … 1305 1548 wp_update_comment_count($comment_post_ID); 1306 1549 1307 1550 $comment = get_comment($id); 1308 do_action('wp_insert_comment', $id, $comment);1309 1551 1552 /** 1553 * Fires after the comment is inserted into the database. 1554 * 1555 * @since 2.8.0 1556 * 1557 * @param int $id The comment ID. 1558 * @param obj $comment Comment object. 1559 */ 1560 do_action( 'wp_insert_comment', $id, $comment ); 1561 1310 1562 wp_cache_set( 'last_changed', microtime(), 'comment' ); 1311 1563 1312 1564 return $id; … … 1333 1585 */ 1334 1586 function wp_filter_comment($commentdata) { 1335 1587 if ( isset($commentdata['user_ID']) ) 1336 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); 1588 /** 1589 * Filter the user ID before it is set. 1590 * 1591 * @since 1.5.2 1592 * 1593 * @param int $user_ID The user ID. 1594 */ 1595 $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] ); 1337 1596 elseif ( isset($commentdata['user_id']) ) 1338 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']); 1339 $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); 1340 $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']); 1341 $commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']); 1342 $commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']); 1343 $commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']); 1344 $commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']); 1597 /** This filter is documented in wp-includes/comment.php */ 1598 $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] ); 1599 /** 1600 * Filter the comment author's browser user agent before it is set. 1601 * 1602 * @since 1.5.2 1603 * 1604 * @param int $comment_agent The comment author's browser user agent. 1605 */ 1606 $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); 1607 /** This filter is documented in wp-includes/comment.php */ 1608 $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] ); 1609 /** 1610 * Filter the comment content before it is set. 1611 * 1612 * @since 1.5.2 1613 * 1614 * @param int $comment_content The comment content. 1615 */ 1616 $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] ); 1617 /** 1618 * Filter the comment author's IP before it is set. 1619 * 1620 * @since 1.5.2 1621 * 1622 * @param int $comment_author_ip The comment author's IP. 1623 */ 1624 $commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] ); 1625 /** This filter is documented in wp-includes/comment.php */ 1626 $commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] ); 1627 /** This filter is documented in wp-includes/comment.php */ 1628 $commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] ); 1345 1629 $commentdata['filtered'] = true; 1346 1630 return $commentdata; 1347 1631 } … … 1381 1665 * @return int The ID of the comment after adding. 1382 1666 */ 1383 1667 function wp_new_comment( $commentdata ) { 1384 $commentdata = apply_filters('preprocess_comment', $commentdata); 1668 /** 1669 * Filter the comment data before being inserted into the database. 1670 * 1671 * @since 1.5.2 1672 * 1673 * @param int|string $commentdata The comment data. 1674 */ 1675 $commentdata = apply_filters( 'preprocess_comment', $commentdata ); 1385 1676 1386 1677 $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; 1387 1678 if ( isset($commentdata['user_ID']) ) … … 1405 1696 1406 1697 $comment_ID = wp_insert_comment($commentdata); 1407 1698 1408 do_action('comment_post', $comment_ID, $commentdata['comment_approved']); 1699 /** 1700 * Fires 1701 * 1702 * @since 1.2.1 1703 * 1704 * @param int $comment_ID The comment ID. 1705 * @param string $comment_approved 1706 */ 1707 do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'] ); 1409 1708 1410 1709 if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching 1411 1710 if ( '0' == $commentdata['comment_approved'] ) { … … 1475 1774 1476 1775 $comment = get_comment($comment_id); 1477 1776 1478 do_action('wp_set_comment_status', $comment_id, $comment_status); 1777 /** 1778 * Fires after the comment is handled. 1779 * 1780 * This action accepts the following comment status: 'hold', 'approve', 'spam', 1781 * or 'trash'. If the comment status is not in the list, then false is returned. 1782 * 1783 * @since 1.5.2 1784 * 1785 * @param int $comment_id The comment ID. 1786 * @param string $comment_status The comment status. 1787 */ 1788 do_action( 'wp_set_comment_status', $comment_id, $comment_status ); 1479 1789 wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment); 1480 1790 1481 1791 wp_update_comment_count($comment->comment_post_ID); … … 1516 1826 // Now extract the merged array. 1517 1827 extract(wp_unslash($commentarr), EXTR_SKIP); 1518 1828 1519 $comment_content = apply_filters('comment_save_pre', $comment_content); 1829 /** 1830 * Filter the comment content before being updated. 1831 * 1832 * @since 1.5.2 1833 * 1834 * @param int|string $comment_content The comment data. 1835 */ 1836 $comment_content = apply_filters( 'comment_save_pre', $comment_content ); 1520 1837 1521 1838 $comment_date_gmt = get_gmt_from_date($comment_date); 1522 1839 … … 1532 1849 1533 1850 clean_comment_cache($comment_ID); 1534 1851 wp_update_comment_count($comment_post_ID); 1535 do_action('edit_comment', $comment_ID); 1852 /** 1853 * Fires 1854 * 1855 * @since 1.2.1 1856 * 1857 * @param int $comment_ID The comment ID. 1858 */ 1859 do_action( 'edit_comment', $comment_ID ); 1536 1860 $comment = get_comment($comment_ID); 1537 1861 wp_transition_comment_status($comment->comment_approved, $old_status, $comment); 1538 1862 return $rval; … … 1629 1953 1630 1954 clean_post_cache( $post ); 1631 1955 1632 do_action('wp_update_comment_count', $post_id, $new, $old); 1633 do_action('edit_post', $post_id, $post); 1956 /** 1957 * Fires after updating the comment count. 1958 * 1959 * @since 2.3.0 1960 * 1961 * @param int $post_id The post ID. 1962 * @param int $new The new comment count. 1963 * @param int $old The old comment count. 1964 */ 1965 do_action( 'wp_update_comment_count', $post_id, $new, $old ); 1966 /** This action is documented in wp-includes/post.php */ 1967 do_action( 'edit_post', $post_id, $post ); 1634 1968 1635 1969 return true; 1636 1970 } … … 1761 2095 } 1762 2096 1763 2097 if ( empty($post->post_excerpt) ) 1764 $excerpt = apply_filters('the_content', $post->post_content, $post->ID); 2098 /** This filter is documented in wp-admin/post-template.php */ 2099 $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); 1765 2100 else 1766 $excerpt = apply_filters('the_excerpt', $post->post_excerpt); 2101 /** This filter is documented in wp-admin/post-template.php */ 2102 $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); 1767 2103 $excerpt = str_replace(']]>', ']]>', $excerpt); 1768 2104 $excerpt = wp_html_excerpt($excerpt, 252, '…'); 1769 2105 1770 2106 /** This filter is documented in wp-includes/post-template.php */ 1771 $post_title = apply_filters( 'the_title', $post->post_title, $post->ID);2107 $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); 1772 2108 $post_title = strip_tags($post_title); 1773 2109 1774 2110 if ( $to_ping ) { … … 1851 2187 endforeach; 1852 2188 1853 2189 $post_links = array_unique( $post_links ); 2190 /** 2191 * Fires 2192 * 2193 * @since 2.0.0 2194 * 2195 * @param array &$post_links The post links to be checked, passed by reference. 2196 * @param array &$pung Whether a link has already been pinged, passed by reference. 2197 * @param int $post_ID The post ID. 2198 */ 1854 2199 do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) ); 1855 2200 1856 2201 foreach ( (array) $post_links as $pagelinkedto ) { … … 1858 2203 1859 2204 if ( $pingback_server_url ) { 1860 2205 @ set_time_limit( 60 ); 1861 2206 // Now, the RPC call 1862 2207 $pagelinkedfrom = get_permalink($post_ID); 1863 2208 1864 2209 // using a timeout of 3 seconds should be enough to cover slow servers 1865 2210 $client = new WP_HTTP_IXR_Client($pingback_server_url); 1866 2211 $client->timeout = 3; 1867 $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom); 2212 /** 2213 * Filter the 2214 * 2215 * @since 2.9.0 2216 * 2217 * @param int|string $client->useragent . ' -- WordPress/' . $wp_version 2218 * @param string $client->useragent 2219 * @param string $pingback_server_url The server URL being linked to. 2220 * @param string $pagelinkedto URL of page linked to. 2221 * @param string $pagelinkedfrom URL of page linked from. 2222 */ 2223 $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom ); 1868 2224 // when set to true, this outputs debug messages by itself 1869 2225 $client->debug = false; 1870 2226 … … 2041 2397 if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) 2042 2398 return $posts; 2043 2399 2400 /** 2401 * Filter the post types that comments should be closed on automatically. 2402 * 2403 * @since 3.2.0 2404 * 2405 * @param array $post_types An array of registered post types. Default 'post'. 2406 */ 2044 2407 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2045 2408 if ( ! in_array( $posts[0]->post_type, $post_types ) ) 2046 2409 return $posts; … … 2080 2443 2081 2444 $post = get_post($post_id); 2082 2445 2446 /** This filter is documented in wp-includes/comment.php */ 2083 2447 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2084 2448 if ( ! in_array( $post->post_type, $post_types ) ) 2085 2449 return $open;