Changeset 26491 for trunk/src/wp-includes/comment.php
- Timestamp:
- 12/01/2013 01:11:26 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r26388 r26491 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 … … 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; … … 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 ) { … … 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, passed by reference. 276 */ 254 277 do_action_ref_array( 'pre_get_comments', array( &$this ) ); 255 278 extract( $this->query_vars, EXTR_SKIP ); … … 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 A compacted array of comment query clauses. 408 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference. 409 */ 379 410 $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); 380 411 foreach ( $pieces as $piece ) … … 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 comments. 429 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference. 430 */ 392 431 $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) ); 393 432 … … 630 669 return; 631 670 632 $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000); 671 /** 672 * Filter the lifetime of the comment cookie in seconds. 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); … … 645 691 */ 646 692 function sanitize_comment_cookies() { 647 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { 648 $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); 693 if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) { 694 /** 695 * Filter the comment author's name cookie before it is set. 696 * 697 * When this filter hook is evaluated in wp_filter_comment(), 698 * the comment author's name string is passed. 699 * 700 * @since 1.5.2 701 * 702 * @param string $author_cookie The comment author name cookie. 703 */ 704 $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] ); 649 705 $comment_author = wp_unslash($comment_author); 650 706 $comment_author = esc_attr($comment_author); 651 $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author; 652 } 653 654 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { 655 $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); 707 $_COOKIE['comment_author_' . COOKIEHASH] = $comment_author; 708 } 709 710 if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) { 711 /** 712 * Filter the comment author's email cookie before it is set. 713 * 714 * When this filter hook is evaluated in wp_filter_comment(), 715 * the comment author's email string is passed. 716 * 717 * @since 1.5.2 718 * 719 * @param string $author_email_cookie The comment author email cookie. 720 */ 721 $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] ); 656 722 $comment_author_email = wp_unslash($comment_author_email); 657 723 $comment_author_email = esc_attr($comment_author_email); … … 659 725 } 660 726 661 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { 662 $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); 727 if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) { 728 /** 729 * Filter the comment author's URL cookie before it is set. 730 * 731 * When this filter hook is evaluated in wp_filter_comment(), 732 * the comment author's URL string is passed. 733 * 734 * @since 1.5.2 735 * 736 * @param string $author_url_cookie The comment author URL cookie. 737 */ 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; … … 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 immediately after 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') ) … … 696 779 } 697 780 781 /** 782 * Fires immediately before a comment is marked approved. 783 * 784 * Allows checking for comment flooding. 785 * 786 * @since 2.3.0 787 * 788 * @param string $comment_author_IP Comment author's IP address. 789 * @param string $comment_author_email Comment author's email. 790 * @param string $comment_date_gmt GMT date the comment was posted. 791 */ 698 792 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 699 793 … … 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) ) … … 716 810 } 717 811 812 /** 813 * Filter a comment's approval status before it is set. 814 * 815 * @since 2.1.0 816 * 817 * @param bool|string $approved The approval status. Accepts 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; … … 745 847 $time_lastcomment = mysql2date('U', $lasttime, false); 746 848 $time_newcomment = mysql2date('U', $date, false); 747 $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); 849 /** 850 * Filter the comment flood status. 851 * 852 * @since 2.1.0 853 * 854 * @param bool $bool Whether a comment flood is occurring. Default false. 855 * @param int $time_lastcomment Timestamp of when the last comment was posted. 856 * @param int $time_newcomment Timestamp of when the new comment was posted. 857 */ 858 $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment ); 748 859 if ( $flood_die ) { 749 do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 860 /** 861 * Fires before the comment flood message is triggered. 862 * 863 * @since 1.5.2 864 * 865 * @param int $time_lastcomment Timestamp of when the last comment was posted. 866 * @param int $time_newcomment Timestamp of when the new comment was posted. 867 */ 868 do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); 750 869 751 870 if ( defined('DOING_AJAX') ) … … 903 1022 */ 904 1023 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); 1024 /** 1025 * Fires before the comment is tested for blacklisted characters or words. 1026 * 1027 * @since 1.5.2 1028 * 1029 * @param string $author Comment author. 1030 * @param string $email Comment author's email. 1031 * @param string $url Comment author's URL. 1032 * @param string $comment Comment content. 1033 * @param string $user_ip Comment author's IP address. 1034 * @param string $user_agent Comment author's browser user agent. 1035 */ 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') ); … … 955 1086 $post_id = (int) $post_id; 956 1087 957 $stats = apply_filters('wp_count_comments', array(), $post_id); 1088 /** 1089 * Filter the comments count for a given post. 1090 * 1091 * @since 2.7.0 1092 * 1093 * @param array $count An empty array. 1094 * @param int $post_id The post ID. 1095 */ 1096 $stats = apply_filters( 'wp_count_comments', array(), $post_id ); 958 1097 if ( !empty($stats) ) 959 1098 return $stats; … … 1020 1159 return wp_trash_comment($comment_id); 1021 1160 1022 do_action('delete_comment', $comment_id); 1161 /** 1162 * Fires immediately before a comment is deleted from the database. 1163 * 1164 * @since 1.2.1 1165 * 1166 * @param int $comment_id The comment ID. 1167 */ 1168 do_action( 'delete_comment', $comment_id ); 1023 1169 1024 1170 // Move children up a level. … … 1036 1182 if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) 1037 1183 return false; 1038 do_action('deleted_comment', $comment_id); 1184 1185 /** 1186 * Fires immediately after a comment is deleted from the database. 1187 * 1188 * @since 2.9.0 1189 * 1190 * @param int $comment_id The comment ID. 1191 */ 1192 do_action( 'deleted_comment', $comment_id ); 1039 1193 1040 1194 $post_id = $comment->comment_post_ID; … … 1044 1198 clean_comment_cache($comment_id); 1045 1199 1046 do_action('wp_set_comment_status', $comment_id, 'delete'); 1200 /** 1201 * Fires immediately before changing the comment's status to 'delete'. 1202 * 1203 * @since 1.5.2 1204 * 1205 * @param int $comment_id The comment ID. 1206 * @param string $status The new 'delete' comment status. 1207 */ 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; … … 1069 1231 return false; 1070 1232 1071 do_action('trash_comment', $comment_id); 1233 /** 1234 * Fires immediately before a comment is sent to the Trash. 1235 * 1236 * @since 2.9.0 1237 * 1238 * @param int $comment_id The comment ID. 1239 */ 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() ); 1076 do_action('trashed_comment', $comment_id); 1245 1246 /** 1247 * Fires immediately after a comment is sent to Trash. 1248 * 1249 * @since 2.9.0 1250 * 1251 * @param int $comment_id The comment ID. 1252 */ 1253 do_action( 'trashed_comment', $comment_id ); 1077 1254 return true; 1078 1255 } … … 1095 1272 return false; 1096 1273 1097 do_action('untrash_comment', $comment_id); 1274 /** 1275 * Fires immediately before a comment is restored from the Trash. 1276 * 1277 * @since 2.9.0 1278 * 1279 * @param int $comment_id The comment ID. 1280 */ 1281 do_action( 'untrash_comment', $comment_id ); 1098 1282 1099 1283 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); … … 1104 1288 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 1105 1289 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1106 do_action('untrashed_comment', $comment_id); 1290 /** 1291 * Fires immediately after a comment is restored from the Trash. 1292 * 1293 * @since 2.9.0 1294 * 1295 * @param int $comment_id The comment ID. 1296 */ 1297 do_action( 'untrashed_comment', $comment_id ); 1107 1298 return true; 1108 1299 } … … 1125 1316 return false; 1126 1317 1127 do_action('spam_comment', $comment_id); 1318 /** 1319 * Fires immediately before a comment is marked as Spam. 1320 * 1321 * @since 2.9.0 1322 * 1323 * @param int $comment_id The comment ID. 1324 */ 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); 1131 do_action('spammed_comment', $comment_id); 1329 /** 1330 * Fires immediately after a comment is marked as Spam. 1331 * 1332 * @since 2.9.0 1333 * 1334 * @param int $comment_id The comment ID. 1335 */ 1336 do_action( 'spammed_comment', $comment_id ); 1132 1337 return true; 1133 1338 } … … 1150 1355 return false; 1151 1356 1152 do_action('unspam_comment', $comment_id); 1357 /** 1358 * Fires immediately before a comment is unmarked as Spam. 1359 * 1360 * @since 2.9.0 1361 * 1362 * @param int $comment_id The comment ID. 1363 */ 1364 do_action( 'unspam_comment', $comment_id ); 1153 1365 1154 1366 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); … … 1158 1370 if ( wp_set_comment_status($comment_id, $status) ) { 1159 1371 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1160 do_action('unspammed_comment', $comment_id); 1372 /** 1373 * Fires immediately after a comment is unmarked as Spam. 1374 * 1375 * @since 2.9.0 1376 * 1377 * @param int $comment_id The comment ID. 1378 */ 1379 do_action( 'unspammed_comment', $comment_id ); 1161 1380 return true; 1162 1381 } … … 1215 1434 */ 1216 1435 function wp_transition_comment_status($new_status, $old_status, $comment) { 1217 // Translate raw statuses to human readable formats for the hooks 1218 // This is not a complete list of comment status, it's only the ones that need to be renamed 1436 /* 1437 * Translate raw statuses to human readable formats for the hooks. 1438 * This is not a complete list of comment status, it's only the ones 1439 * that need to be renamed 1440 */ 1219 1441 $comment_statuses = array( 1220 1442 0 => 'unapproved', … … 1228 1450 // Call the hooks 1229 1451 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); 1232 } 1233 do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment); 1452 /** 1453 * Fires when the comment status is in transition. 1454 * 1455 * @since 2.7.0 1456 * 1457 * @param int|string $new_status The new comment status. 1458 * @param int|string $old_status The old comment status. 1459 * @param object $comment The comment data. 1460 */ 1461 do_action( 'transition_comment_status', $new_status, $old_status, $comment ); 1462 /** 1463 * Fires when the comment status is in transition from one specific status to another. 1464 * 1465 * The dynamic portions of the hook name, $old_status, and $new_status, 1466 * refer to the old and new comment statuses, respectively. 1467 * 1468 * @since 2.7.0 1469 * 1470 * @param object $comment Comment object. 1471 */ 1472 do_action( "comment_{$old_status}_to_{$new_status}", $comment ); 1473 } 1474 /** 1475 * Fires when the status of a specific comment type is in transition. 1476 * 1477 * The dynamic portions of the hook name, $new_status, and $comment->comment_type, 1478 * refer to the new comment status, and the type of comment, respectively. 1479 * 1480 * Typical comment types include an empty string (standard comment), 'pingback', 1481 * or 'trackback'. 1482 * 1483 * @since 2.7.0 1484 * 1485 * @param int $comment_ID The comment ID. 1486 * @param obj $comment Comment object. 1487 */ 1488 do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment ); 1234 1489 } 1235 1490 … … 1261 1516 $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; 1262 1517 1263 return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url')); 1518 /** 1519 * Filter the current commenter's name, email, and URL. 1520 * 1521 * @since 3.1.0 1522 * 1523 * @param string $comment_author Comment author's name. 1524 * @param string $comment_author_email Comment author's email. 1525 * @param string $comment_author_url Comment author's URL. 1526 */ 1527 return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') ); 1264 1528 } 1265 1529 … … 1306 1570 1307 1571 $comment = get_comment($id); 1308 do_action('wp_insert_comment', $id, $comment); 1572 1573 /** 1574 * Fires immediately after a comment is inserted into the database. 1575 * 1576 * @since 2.8.0 1577 * 1578 * @param int $id The comment ID. 1579 * @param obj $comment Comment object. 1580 */ 1581 do_action( 'wp_insert_comment', $id, $comment ); 1309 1582 1310 1583 wp_cache_set( 'last_changed', microtime(), 'comment' ); … … 1321 1594 * 1322 1595 * @since 2.0.0 1323 * @uses apply_filters() Calls 'pre_user_id' hook on comment author's user ID1324 * @uses apply_filters() Calls 'pre_comment_user_agent' hook on comment author's user agent1325 * @uses apply_filters() Calls 'pre_comment_author_name' hook on comment author's name1326 * @uses apply_filters() Calls 'pre_comment_content' hook on the comment's content1327 * @uses apply_filters() Calls 'pre_comment_user_ip' hook on comment author's IP1328 * @uses apply_filters() Calls 'pre_comment_author_url' hook on comment author's URL1329 * @uses apply_filters() Calls 'pre_comment_author_email' hook on comment author's email address1330 1596 * 1331 1597 * @param array $commentdata Contains information on the comment. … … 1333 1599 */ 1334 1600 function wp_filter_comment($commentdata) { 1335 if ( isset($commentdata['user_ID']) ) 1336 $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); 1337 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']); 1601 if ( isset( $commentdata['user_ID'] ) ) { 1602 /** 1603 * Filter the comment author's user id before it is set. 1604 * 1605 * The first time this filter is evaluated, 'user_ID' is checked 1606 * (for back-compat), followed by the standard 'user_id' value. 1607 * 1608 * @since 1.5.2 1609 * 1610 * @param int $user_ID The comment author's user ID. 1611 */ 1612 $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] ); 1613 } elseif ( isset( $commentdata['user_id'] ) ) { 1614 /** This filter is documented in wp-includes/comment.php */ 1615 $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] ); 1616 } 1617 1618 /** 1619 * Filter the comment author's browser user agent before it is set. 1620 * 1621 * @since 1.5.2 1622 * 1623 * @param int $comment_agent The comment author's browser user agent. 1624 */ 1625 $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); 1626 /** This filter is documented in wp-includes/comment.php */ 1627 $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] ); 1628 /** 1629 * Filter the comment content before it is set. 1630 * 1631 * @since 1.5.2 1632 * 1633 * @param int $comment_content The comment content. 1634 */ 1635 $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] ); 1636 /** 1637 * Filter the comment author's IP before it is set. 1638 * 1639 * @since 1.5.2 1640 * 1641 * @param int $comment_author_ip The comment author's IP. 1642 */ 1643 $commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] ); 1644 /** This filter is documented in wp-includes/comment.php */ 1645 $commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] ); 1646 /** This filter is documented in wp-includes/comment.php */ 1647 $commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] ); 1345 1648 $commentdata['filtered'] = true; 1346 1649 return $commentdata; … … 1348 1651 1349 1652 /** 1350 * Whether comment should be blocked because of comment flood.1653 * Whether a comment should be blocked because of comment flood. 1351 1654 * 1352 1655 * @since 2.1.0 … … 1382 1685 */ 1383 1686 function wp_new_comment( $commentdata ) { 1384 $commentdata = apply_filters('preprocess_comment', $commentdata); 1687 /** 1688 * Filter a comment's data before it is sanitized and inserted into the database. 1689 * 1690 * @since 1.5.2 1691 * 1692 * @param array $commentdata Comment data. 1693 */ 1694 $commentdata = apply_filters( 'preprocess_comment', $commentdata ); 1385 1695 1386 1696 $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; … … 1406 1716 $comment_ID = wp_insert_comment($commentdata); 1407 1717 1408 do_action('comment_post', $comment_ID, $commentdata['comment_approved']); 1718 /** 1719 * Fires immediately after a comment is inserted into the database. 1720 * 1721 * @since 1.2.1 1722 * 1723 * @param int $comment_ID The comment ID. 1724 * @param int $comment_approved 1 (true) if the comment is approved, 0 (false) if not. 1725 */ 1726 do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'] ); 1409 1727 1410 1728 if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching … … 1476 1794 $comment = get_comment($comment_id); 1477 1795 1478 do_action('wp_set_comment_status', $comment_id, $comment_status); 1796 /** 1797 * Fires after a comment status has been updated in the database. 1798 * 1799 * The hook also fires immediately before comment status transition hooks are fired. 1800 * 1801 * @since 1.5.2 1802 * 1803 * @param int $comment_id The comment ID. 1804 * @param string|bool $comment_status The comment status. Possible values include 'hold', 1805 * 'approve', 'spam', 'trash', or false. 1806 */ 1807 do_action( 'wp_set_comment_status', $comment_id, $comment_status ); 1479 1808 wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment); 1480 1809 … … 1517 1846 extract(wp_unslash($commentarr), EXTR_SKIP); 1518 1847 1519 $comment_content = apply_filters('comment_save_pre', $comment_content); 1848 /** 1849 * Filter the comment content before it is updated in the database. 1850 * 1851 * @since 1.5.2 1852 * 1853 * @param string $comment_content The comment data. 1854 */ 1855 $comment_content = apply_filters( 'comment_save_pre', $comment_content ); 1520 1856 1521 1857 $comment_date_gmt = get_gmt_from_date($comment_date); … … 1533 1869 clean_comment_cache($comment_ID); 1534 1870 wp_update_comment_count($comment_post_ID); 1535 do_action('edit_comment', $comment_ID); 1871 /** 1872 * Fires immediately after a comment is updated in the database. 1873 * 1874 * The hook also fires immediately before comment status transition hooks are fired. 1875 * 1876 * @since 1.2.1 1877 * 1878 * @param int $comment_ID The comment ID. 1879 */ 1880 do_action( 'edit_comment', $comment_ID ); 1536 1881 $comment = get_comment($comment_ID); 1537 1882 wp_transition_comment_status($comment->comment_approved, $old_status, $comment); … … 1630 1975 clean_post_cache( $post ); 1631 1976 1632 do_action('wp_update_comment_count', $post_id, $new, $old); 1633 do_action('edit_post', $post_id, $post); 1977 /** 1978 * Fires immediately after a post's comment count is updated in the database. 1979 * 1980 * @since 2.3.0 1981 * 1982 * @param int $post_id Post ID. 1983 * @param int $new The new comment count. 1984 * @param int $old The old comment count. 1985 */ 1986 do_action( 'wp_update_comment_count', $post_id, $new, $old ); 1987 /** This action is documented in wp-includes/post.php */ 1988 do_action( 'edit_post', $post_id, $post ); 1634 1989 1635 1990 return true; … … 1761 2116 } 1762 2117 1763 if ( empty($post->post_excerpt) ) 1764 $excerpt = apply_filters('the_content', $post->post_content, $post->ID); 1765 else 1766 $excerpt = apply_filters('the_excerpt', $post->post_excerpt); 2118 if ( empty($post->post_excerpt) ) { 2119 /** This filter is documented in wp-admin/post-template.php */ 2120 $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); 2121 } else { 2122 /** This filter is documented in wp-admin/post-template.php */ 2123 $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); 2124 } 2125 1767 2126 $excerpt = str_replace(']]>', ']]>', $excerpt); 1768 2127 $excerpt = wp_html_excerpt($excerpt, 252, '…'); 1769 2128 1770 2129 /** This filter is documented in wp-includes/post-template.php */ 1771 $post_title = apply_filters( 'the_title', $post->post_title, $post->ID);2130 $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); 1772 2131 $post_title = strip_tags($post_title); 1773 2132 … … 1852 2211 1853 2212 $post_links = array_unique( $post_links ); 2213 /** 2214 * Fires just before pinging back links found in a post. 2215 * 2216 * @since 2.0.0 2217 * 2218 * @param array &$post_links An array of post links to be checked, passed by reference. 2219 * @param array &$pung Whether a link has already been pinged, passed by reference. 2220 * @param int $post_ID The post ID. 2221 */ 1854 2222 do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) ); 1855 2223 … … 1859 2227 if ( $pingback_server_url ) { 1860 2228 @ set_time_limit( 60 ); 1861 2229 // Now, the RPC call 1862 2230 $pagelinkedfrom = get_permalink($post_ID); 1863 2231 … … 1865 2233 $client = new WP_HTTP_IXR_Client($pingback_server_url); 1866 2234 $client->timeout = 3; 1867 $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom); 2235 /** 2236 * Filter the user agent sent when pinging-back a URL. 2237 * 2238 * @since 2.9.0 2239 * 2240 * @param string $concat_useragent The user agent concatenated with ' -- WordPress/' 2241 * and the WordPress version. 2242 * @param string $useragent The useragent. 2243 * @param string $pingback_server_url The server URL being linked to. 2244 * @param string $pagelinkedto URL of page linked to. 2245 * @param string $pagelinkedfrom URL of page linked from. 2246 */ 2247 $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom ); 1868 2248 // when set to true, this outputs debug messages by itself 1869 2249 $client->debug = false; … … 2042 2422 return $posts; 2043 2423 2424 /** 2425 * Filter the list of post types to automatically close comments for. 2426 * 2427 * @since 3.2.0 2428 * 2429 * @param array $post_types An array of registered post types. Default array with 'post'. 2430 */ 2044 2431 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2045 2432 if ( ! in_array( $posts[0]->post_type, $post_types ) ) … … 2081 2468 $post = get_post($post_id); 2082 2469 2470 /** This filter is documented in wp-includes/comment.php */ 2083 2471 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 2084 2472 if ( ! in_array( $post->post_type, $post_types ) )
Note: See TracChangeset
for help on using the changeset viewer.