wordpress  4.4.2
About: WordPress is a blogging system that has evolved to a full content management system.
  Fossies Dox: wordpress-4.4.2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

comment.php
Go to the documentation of this file.
1 <?php
39 function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
40  global $wpdb;
41 
42  // If manual moderation is enabled, skip all checks and return false.
43  if ( 1 == get_option('comment_moderation') )
44  return false;
45 
47  $comment = apply_filters( 'comment_text', $comment );
48 
49  // Check for the number of external links if a max allowed number is set.
50  if ( $max_links = get_option( 'comment_max_links' ) ) {
51  $num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out );
52 
61  $num_links = apply_filters( 'comment_max_links_url', $num_links, $url );
62 
63  /*
64  * If the number of links in the comment exceeds the allowed amount,
65  * fail the check by returning false.
66  */
67  if ( $num_links >= $max_links )
68  return false;
69  }
70 
71  $mod_keys = trim(get_option('moderation_keys'));
72 
73  // If moderation 'keys' (keywords) are set, process them.
74  if ( !empty($mod_keys) ) {
75  $words = explode("\n", $mod_keys );
76 
77  foreach ( (array) $words as $word) {
78  $word = trim($word);
79 
80  // Skip empty lines.
81  if ( empty($word) )
82  continue;
83 
84  /*
85  * Do some escaping magic so that '#' (number of) characters in the spam
86  * words don't break things:
87  */
88  $word = preg_quote($word, '#');
89 
90  /*
91  * Check the comment fields for moderation keywords. If any are found,
92  * fail the check for the given field by returning false.
93  */
94  $pattern = "#$word#i";
95  if ( preg_match($pattern, $author) ) return false;
96  if ( preg_match($pattern, $email) ) return false;
97  if ( preg_match($pattern, $url) ) return false;
98  if ( preg_match($pattern, $comment) ) return false;
99  if ( preg_match($pattern, $user_ip) ) return false;
100  if ( preg_match($pattern, $user_agent) ) return false;
101  }
102  }
103 
104  /*
105  * Check if the option to approve comments by previously-approved authors is enabled.
106  *
107  * If it is enabled, check whether the comment author has a previously-approved comment,
108  * as well as whether there are any moderation keywords (if set) present in the author
109  * email address. If both checks pass, return true. Otherwise, return false.
110  */
111  if ( 1 == get_option('comment_whitelist')) {
112  if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
113  // expected_slashed ($author, $email)
114  $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
115  if ( ( 1 == $ok_to_comment ) &&
116  ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
117  return true;
118  else
119  return false;
120  } else {
121  return false;
122  }
123  }
124  return true;
125 }
126 
139 function get_approved_comments( $post_id, $args = array() ) {
140  if ( ! $post_id ) {
141  return array();
142  }
143 
144  $defaults = array(
145  'status' => 1,
146  'post_id' => $post_id,
147  'order' => 'ASC',
148  );
149  $r = wp_parse_args( $args, $defaults );
150 
151  $query = new WP_Comment_Query;
152  return $query->query( $r );
153 }
154 
170 function get_comment( &$comment = null, $output = OBJECT ) {
171  if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) {
172  $comment = $GLOBALS['comment'];
173  }
174 
175  if ( $comment instanceof WP_Comment ) {
176  $_comment = $comment;
177  } elseif ( is_object( $comment ) ) {
178  $_comment = new WP_Comment( $comment );
179  } else {
180  $_comment = WP_Comment::get_instance( $comment );
181  }
182 
183  if ( ! $_comment ) {
184  return null;
185  }
186 
194  $_comment = apply_filters( 'get_comment', $_comment );
195 
196  if ( $output == OBJECT ) {
197  return $_comment;
198  } elseif ( $output == ARRAY_A ) {
199  return $_comment->to_array();
200  } elseif ( $output == ARRAY_N ) {
201  return array_values( $_comment->to_array() );
202  }
203  return $_comment;
204 }
205 
217 function get_comments( $args = '' ) {
218  $query = new WP_Comment_Query;
219  return $query->query( $args );
220 }
221 
233  $status = array(
234  'hold' => __('Unapproved'),
235  /* translators: comment status */
236  'approve' => _x('Approved', 'adjective'),
237  /* translators: comment status */
238  'spam' => _x('Spam', 'adjective'),
239  /* translators: comment status */
240  'trash' => _x('Trash', 'adjective'),
241  );
242 
243  return $status;
244 }
245 
255 function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) {
256  switch ( $comment_type ) {
257  case 'pingback' :
258  case 'trackback' :
259  $supports = 'trackbacks';
260  $option = 'ping';
261  break;
262  default :
263  $supports = 'comments';
264  $option = 'comment';
265  }
266 
267  // Set the status.
268  if ( 'page' === $post_type ) {
269  $status = 'closed';
270  } elseif ( post_type_supports( $post_type, $supports ) ) {
271  $status = get_option( "default_{$option}_status" );
272  } else {
273  $status = 'closed';
274  }
275 
286  return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type );
287 }
288 
301 function get_lastcommentmodified($timezone = 'server') {
302  global $wpdb;
303  static $cache_lastcommentmodified = array();
304 
305  if ( isset($cache_lastcommentmodified[$timezone]) )
306  return $cache_lastcommentmodified[$timezone];
307 
308  $add_seconds_server = date('Z');
309 
310  switch ( strtolower($timezone)) {
311  case 'gmt':
312  $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
313  break;
314  case 'blog':
315  $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
316  break;
317  case 'server':
318  $lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server));
319  break;
320  }
321 
322  $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
323 
324  return $lastcommentmodified;
325 }
326 
341 function get_comment_count( $post_id = 0 ) {
342  global $wpdb;
343 
344  $post_id = (int) $post_id;
345 
346  $where = '';
347  if ( $post_id > 0 ) {
348  $where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id);
349  }
350 
351  $totals = (array) $wpdb->get_results("
352  SELECT comment_approved, COUNT( * ) AS total
353  FROM {$wpdb->comments}
354  {$where}
355  GROUP BY comment_approved
356  ", ARRAY_A);
357 
358  $comment_count = array(
359  'approved' => 0,
360  'awaiting_moderation' => 0,
361  'spam' => 0,
362  'trash' => 0,
363  'post-trashed' => 0,
364  'total_comments' => 0,
365  'all' => 0,
366  );
367 
368  foreach ( $totals as $row ) {
369  switch ( $row['comment_approved'] ) {
370  case 'trash':
371  $comment_count['trash'] = $row['total'];
372  break;
373  case 'post-trashed':
374  $comment_count['post-trashed'] = $row['total'];
375  break;
376  case 'spam':
377  $comment_count['spam'] = $row['total'];
378  $comment_count['total_comments'] += $row['total'];
379  break;
380  case '1':
381  $comment_count['approved'] = $row['total'];
382  $comment_count['total_comments'] += $row['total'];
383  $comment_count['all'] += $row['total'];
384  break;
385  case '0':
386  $comment_count['awaiting_moderation'] = $row['total'];
387  $comment_count['total_comments'] += $row['total'];
388  $comment_count['all'] += $row['total'];
389  break;
390  default:
391  break;
392  }
393  }
394 
395  return $comment_count;
396 }
397 
398 //
399 // Comment meta functions
400 //
401 
414 function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) {
415  return add_metadata('comment', $comment_id, $meta_key, $meta_value, $unique);
416 }
417 
433 function delete_comment_meta($comment_id, $meta_key, $meta_value = '') {
434  return delete_metadata('comment', $comment_id, $meta_key, $meta_value);
435 }
436 
449 function get_comment_meta($comment_id, $key = '', $single = false) {
450  return get_metadata('comment', $comment_id, $key, $single);
451 }
452 
470 function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '') {
471  return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value);
472 }
473 
484  if ( $user->exists() )
485  return;
486 
494  $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
495  $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
496  setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
497  setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
498  setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
499 }
500 
510  if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
521  $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] );
522  $comment_author = wp_unslash($comment_author);
523  $comment_author = esc_attr($comment_author);
524  $_COOKIE['comment_author_' . COOKIEHASH] = $comment_author;
525  }
526 
527  if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) {
538  $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] );
539  $comment_author_email = wp_unslash($comment_author_email);
540  $comment_author_email = esc_attr($comment_author_email);
541  $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
542  }
543 
544  if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) {
555  $comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] );
556  $comment_author_url = wp_unslash($comment_author_url);
557  $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
558  }
559 }
560 
571 function wp_allow_comment( $commentdata ) {
572  global $wpdb;
573 
574  // Simple duplicate check
575  // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
576  $dupe = $wpdb->prepare(
577  "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ",
578  wp_unslash( $commentdata['comment_post_ID'] ),
579  wp_unslash( $commentdata['comment_parent'] ),
580  wp_unslash( $commentdata['comment_author'] )
581  );
582  if ( $commentdata['comment_author_email'] ) {
583  $dupe .= $wpdb->prepare(
584  "OR comment_author_email = %s ",
585  wp_unslash( $commentdata['comment_author_email'] )
586  );
587  }
588  $dupe .= $wpdb->prepare(
589  ") AND comment_content = %s LIMIT 1",
590  wp_unslash( $commentdata['comment_content'] )
591  );
592 
593  $dupe_id = $wpdb->get_var( $dupe );
594 
605  $dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata );
606 
607  if ( $dupe_id ) {
615  do_action( 'comment_duplicate_trigger', $commentdata );
616  if ( defined( 'DOING_AJAX' ) ) {
617  die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
618  }
619  wp_die( __( 'Duplicate comment detected; it looks as though you&#8217;ve already said that!' ), 409 );
620  }
621 
633  do_action(
634  'check_comment_flood',
635  $commentdata['comment_author_IP'],
636  $commentdata['comment_author_email'],
637  $commentdata['comment_date_gmt']
638  );
639 
640  if ( ! empty( $commentdata['user_id'] ) ) {
641  $user = get_userdata( $commentdata['user_id'] );
642  $post_author = $wpdb->get_var( $wpdb->prepare(
643  "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1",
644  $commentdata['comment_post_ID']
645  ) );
646  }
647 
648  if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
649  // The author and the admins get respect.
650  $approved = 1;
651  } else {
652  // Everyone else's comments will be checked.
653  if ( check_comment(
654  $commentdata['comment_author'],
655  $commentdata['comment_author_email'],
656  $commentdata['comment_author_url'],
657  $commentdata['comment_content'],
658  $commentdata['comment_author_IP'],
659  $commentdata['comment_agent'],
660  $commentdata['comment_type']
661  ) ) {
662  $approved = 1;
663  } else {
664  $approved = 0;
665  }
666 
667  if ( wp_blacklist_check(
668  $commentdata['comment_author'],
669  $commentdata['comment_author_email'],
670  $commentdata['comment_author_url'],
671  $commentdata['comment_content'],
672  $commentdata['comment_author_IP'],
673  $commentdata['comment_agent']
674  ) ) {
675  $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
676  }
677  }
678 
687  $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
688  return $approved;
689 }
690 
705 function check_comment_flood_db( $ip, $email, $date ) {
706  global $wpdb;
707  // don't throttle admins or moderators
708  if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
709  return;
710  }
711  $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
712 
713  if ( is_user_logged_in() ) {
715  $check_column = '`user_id`';
716  } else {
717  $user = $ip;
718  $check_column = '`comment_author_IP`';
719  }
720 
721  $sql = $wpdb->prepare(
722  "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( $check_column = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1",
723  $hour_ago,
724  $user,
725  $email
726  );
727  $lasttime = $wpdb->get_var( $sql );
728  if ( $lasttime ) {
729  $time_lastcomment = mysql2date('U', $lasttime, false);
730  $time_newcomment = mysql2date('U', $date, false);
740  $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment );
741  if ( $flood_die ) {
750  do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
751 
752  if ( defined('DOING_AJAX') )
753  die( __('You are posting comments too quickly. Slow down.') );
754 
755  wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
756  }
757  }
758 }
759 
769  $comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());
771  for ( $i = 0; $i < $count; $i++ ) {
772  $type = $comments[$i]->comment_type;
773  if ( empty($type) )
774  $type = 'comment';
775  $comments_by_type[$type][] = &$comments[$i];
776  if ( 'trackback' == $type || 'pingback' == $type )
777  $comments_by_type['pings'][] = &$comments[$i];
778  }
779 
780  return $comments_by_type;
781 }
782 
797 function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
798  global $wp_query;
799 
800  if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
801  return $wp_query->max_num_comment_pages;
802 
803  if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) )
804  $comments = $wp_query->comments;
805 
806  if ( empty($comments) )
807  return 0;
808 
809  if ( ! get_option( 'page_comments' ) ) {
810  return 1;
811  }
812 
813  if ( !isset($per_page) )
814  $per_page = (int) get_query_var('comments_per_page');
815  if ( 0 === $per_page )
816  $per_page = (int) get_option('comments_per_page');
817  if ( 0 === $per_page )
818  return 1;
819 
820  if ( !isset($threaded) )
821  $threaded = get_option('thread_comments');
822 
823  if ( $threaded ) {
824  $walker = new Walker_Comment;
825  $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
826  } else {
827  $count = ceil( count( $comments ) / $per_page );
828  }
829 
830  return $count;
831 }
832 
853 function get_page_of_comment( $comment_ID, $args = array() ) {
854  global $wpdb;
855 
856  $page = null;
857 
858  if ( !$comment = get_comment( $comment_ID ) )
859  return;
860 
861  $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
862  $args = wp_parse_args( $args, $defaults );
863  $original_args = $args;
864 
865  // Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option.
866  if ( get_option( 'page_comments' ) ) {
867  if ( '' === $args['per_page'] ) {
868  $args['per_page'] = get_query_var( 'comments_per_page' );
869  }
870 
871  if ( '' === $args['per_page'] ) {
872  $args['per_page'] = get_option( 'comments_per_page' );
873  }
874  }
875 
876  if ( empty($args['per_page']) ) {
877  $args['per_page'] = 0;
878  $args['page'] = 0;
879  }
880 
881  if ( $args['per_page'] < 1 ) {
882  $page = 1;
883  }
884 
885  if ( null === $page ) {
886  if ( '' === $args['max_depth'] ) {
887  if ( get_option('thread_comments') )
888  $args['max_depth'] = get_option('thread_comments_depth');
889  else
890  $args['max_depth'] = -1;
891  }
892 
893  // Find this comment's top level parent if threading is enabled
894  if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent )
895  return get_page_of_comment( $comment->comment_parent, $args );
896 
897  $comment_args = array(
898  'type' => $args['type'],
899  'post_id' => $comment->comment_post_ID,
900  'fields' => 'ids',
901  'count' => true,
902  'status' => 'approve',
903  'parent' => 0,
904  'date_query' => array(
905  array(
906  'column' => "$wpdb->comments.comment_date_gmt",
907  'before' => $comment->comment_date_gmt,
908  )
909  ),
910  );
911 
912  $comment_query = new WP_Comment_Query();
913  $older_comment_count = $comment_query->query( $comment_args );
914 
915  // No older comments? Then it's page #1.
916  if ( 0 == $older_comment_count ) {
917  $page = 1;
918 
919  // Divide comments older than this one by comments per page to get this comment's page number
920  } else {
921  $page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] );
922  }
923  }
924 
950  return apply_filters( 'get_page_of_comment', (int) $page, $args, $original_args );
951 }
952 
966 function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
979  do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );
980 
981  $mod_keys = trim( get_option('blacklist_keys') );
982  if ( '' == $mod_keys )
983  return false; // If moderation keys are empty
984  $words = explode("\n", $mod_keys );
985 
986  foreach ( (array) $words as $word ) {
987  $word = trim($word);
988 
989  // Skip empty lines
990  if ( empty($word) ) { continue; }
991 
992  // Do some escaping magic so that '#' chars in the
993  // spam words don't break things:
994  $word = preg_quote($word, '#');
995 
996  $pattern = "#$word#i";
997  if (
998  preg_match($pattern, $author)
999  || preg_match($pattern, $email)
1000  || preg_match($pattern, $url)
1001  || preg_match($pattern, $comment)
1002  || preg_match($pattern, $user_ip)
1003  || preg_match($pattern, $user_agent)
1004  )
1005  return true;
1006  }
1007  return false;
1008 }
1009 
1026 function wp_count_comments( $post_id = 0 ) {
1027  $post_id = (int) $post_id;
1028 
1037  $filtered = apply_filters( 'wp_count_comments', array(), $post_id );
1038  if ( ! empty( $filtered ) ) {
1039  return $filtered;
1040  }
1041 
1042  $count = wp_cache_get( "comments-{$post_id}", 'counts' );
1043  if ( false !== $count ) {
1044  return $count;
1045  }
1046 
1047  $stats = get_comment_count( $post_id );
1048  $stats['moderated'] = $stats['awaiting_moderation'];
1049  unset( $stats['awaiting_moderation'] );
1050 
1051  $stats_object = (object) $stats;
1052  wp_cache_set( "comments-{$post_id}", $stats_object, 'counts' );
1053 
1054  return $stats_object;
1055 }
1056 
1074 function wp_delete_comment($comment_id, $force_delete = false) {
1075  global $wpdb;
1076  if (!$comment = get_comment($comment_id))
1077  return false;
1078 
1079  if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) )
1080  return wp_trash_comment($comment_id);
1081 
1089  do_action( 'delete_comment', $comment->comment_ID );
1090 
1091  // Move children up a level.
1092  $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID) );
1093  if ( !empty($children) ) {
1094  $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment->comment_ID));
1095  clean_comment_cache($children);
1096  }
1097 
1098  // Delete metadata
1099  $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) );
1100  foreach ( $meta_ids as $mid )
1101  delete_metadata_by_mid( 'comment', $mid );
1102 
1103  if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) )
1104  return false;
1105 
1113  do_action( 'deleted_comment', $comment->comment_ID );
1114 
1115  $post_id = $comment->comment_post_ID;
1116  if ( $post_id && $comment->comment_approved == 1 )
1118 
1119  clean_comment_cache( $comment->comment_ID );
1120 
1122  do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' );
1123 
1124  wp_transition_comment_status('delete', $comment->comment_approved, $comment);
1125  return true;
1126 }
1127 
1138 function wp_trash_comment($comment_id) {
1139  if ( !EMPTY_TRASH_DAYS )
1140  return wp_delete_comment($comment_id, true);
1141 
1142  if ( !$comment = get_comment($comment_id) )
1143  return false;
1144 
1152  do_action( 'trash_comment', $comment->comment_ID );
1153 
1154  if ( wp_set_comment_status( $comment, 'trash' ) ) {
1155  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1156  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1157  add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
1158  add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() );
1159 
1167  do_action( 'trashed_comment', $comment->comment_ID );
1168  return true;
1169  }
1170 
1171  return false;
1172 }
1173 
1182 function wp_untrash_comment($comment_id) {
1183  $comment = get_comment( $comment_id );
1184  if ( ! $comment ) {
1185  return false;
1186  }
1187 
1195  do_action( 'untrash_comment', $comment->comment_ID );
1196 
1197  $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1198  if ( empty($status) )
1199  $status = '0';
1200 
1201  if ( wp_set_comment_status( $comment, $status ) ) {
1202  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1203  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1211  do_action( 'untrashed_comment', $comment->comment_ID );
1212  return true;
1213  }
1214 
1215  return false;
1216 }
1217 
1226 function wp_spam_comment( $comment_id ) {
1227  $comment = get_comment( $comment_id );
1228  if ( ! $comment ) {
1229  return false;
1230  }
1231 
1239  do_action( 'spam_comment', $comment->comment_ID );
1240 
1241  if ( wp_set_comment_status( $comment, 'spam' ) ) {
1242  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1243  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1244  add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
1245  add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() );
1253  do_action( 'spammed_comment', $comment->comment_ID );
1254  return true;
1255  }
1256 
1257  return false;
1258 }
1259 
1268 function wp_unspam_comment( $comment_id ) {
1269  $comment = get_comment( $comment_id );
1270  if ( ! $comment ) {
1271  return false;
1272  }
1273 
1281  do_action( 'unspam_comment', $comment->comment_ID );
1282 
1283  $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1284  if ( empty($status) )
1285  $status = '0';
1286 
1287  if ( wp_set_comment_status( $comment, $status ) ) {
1288  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1289  delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1297  do_action( 'unspammed_comment', $comment->comment_ID );
1298  return true;
1299  }
1300 
1301  return false;
1302 }
1303 
1312 function wp_get_comment_status($comment_id) {
1313  $comment = get_comment($comment_id);
1314  if ( !$comment )
1315  return false;
1316 
1317  $approved = $comment->comment_approved;
1318 
1319  if ( $approved == null )
1320  return false;
1321  elseif ( $approved == '1' )
1322  return 'approved';
1323  elseif ( $approved == '0' )
1324  return 'unapproved';
1325  elseif ( $approved == 'spam' )
1326  return 'spam';
1327  elseif ( $approved == 'trash' )
1328  return 'trash';
1329  else
1330  return false;
1331 }
1332 
1353 function wp_transition_comment_status($new_status, $old_status, $comment) {
1354  /*
1355  * Translate raw statuses to human readable formats for the hooks.
1356  * This is not a complete list of comment status, it's only the ones
1357  * that need to be renamed
1358  */
1359  $comment_statuses = array(
1360  0 => 'unapproved',
1361  'hold' => 'unapproved', // wp_set_comment_status() uses "hold"
1362  1 => 'approved',
1363  'approve' => 'approved', // wp_set_comment_status() uses "approve"
1364  );
1365  if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
1366  if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
1367 
1368  // Call the hooks
1369  if ( $new_status != $old_status ) {
1379  do_action( 'transition_comment_status', $new_status, $old_status, $comment );
1390  do_action( "comment_{$old_status}_to_{$new_status}", $comment );
1391  }
1406  do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );
1407 }
1408 
1422  // Cookies should already be sanitized.
1423 
1424  $comment_author = '';
1425  if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
1426  $comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
1427 
1428  $comment_author_email = '';
1429  if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
1430  $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
1431 
1432  $comment_author_url = '';
1433  if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
1434  $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
1435 
1449  return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') );
1450 }
1451 
1487 function wp_insert_comment( $commentdata ) {
1488  global $wpdb;
1489  $data = wp_unslash( $commentdata );
1490 
1491  $comment_author = ! isset( $data['comment_author'] ) ? '' : $data['comment_author'];
1492  $comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email'];
1493  $comment_author_url = ! isset( $data['comment_author_url'] ) ? '' : $data['comment_author_url'];
1494  $comment_author_IP = ! isset( $data['comment_author_IP'] ) ? '' : $data['comment_author_IP'];
1495 
1496  $comment_date = ! isset( $data['comment_date'] ) ? current_time( 'mysql' ) : $data['comment_date'];
1497  $comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt'];
1498 
1499  $comment_post_ID = ! isset( $data['comment_post_ID'] ) ? '' : $data['comment_post_ID'];
1500  $comment_content = ! isset( $data['comment_content'] ) ? '' : $data['comment_content'];
1501  $comment_karma = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma'];
1502  $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved'];
1503  $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent'];
1504  $comment_type = ! isset( $data['comment_type'] ) ? '' : $data['comment_type'];
1505  $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent'];
1506 
1507  $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id'];
1508 
1509  $compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' );
1510  if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
1511  return false;
1512  }
1513 
1514  $id = (int) $wpdb->insert_id;
1515 
1516  if ( $comment_approved == 1 ) {
1517  wp_update_comment_count( $comment_post_ID );
1518  }
1519  $comment = get_comment( $id );
1520 
1521  // If metadata is provided, store it.
1522  if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) {
1523  foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) {
1524  add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true );
1525  }
1526  }
1527 
1536  do_action( 'wp_insert_comment', $id, $comment );
1537 
1538  wp_cache_set( 'last_changed', microtime(), 'comment' );
1539 
1540  return $id;
1541 }
1542 
1555 function wp_filter_comment($commentdata) {
1556  if ( isset( $commentdata['user_ID'] ) ) {
1567  $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
1568  } elseif ( isset( $commentdata['user_id'] ) ) {
1570  $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] );
1571  }
1572 
1580  $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
1582  $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
1590  $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );
1598  $commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] );
1600  $commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] );
1602  $commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] );
1603  $commentdata['filtered'] = true;
1604  return $commentdata;
1605 }
1606 
1617 function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
1618  if ( $block ) // a plugin has already blocked... we'll let that decision stand
1619  return $block;
1620  if ( ($time_newcomment - $time_lastcomment) < 15 )
1621  return true;
1622  return false;
1623 }
1624 
1664 function wp_new_comment( $commentdata ) {
1665  global $wpdb;
1666 
1667  if ( isset( $commentdata['user_ID'] ) ) {
1668  $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
1669  }
1670 
1671  $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
1672 
1680  $commentdata = apply_filters( 'preprocess_comment', $commentdata );
1681 
1682  $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
1683  if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
1684  $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
1685  } elseif ( isset( $commentdata['user_id'] ) ) {
1686  $commentdata['user_id'] = (int) $commentdata['user_id'];
1687  }
1688 
1689  $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
1690  $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
1691  $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
1692 
1693  if ( ! isset( $commentdata['comment_author_IP'] ) ) {
1694  $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
1695  }
1696  $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] );
1697 
1698  if ( ! isset( $commentdata['comment_agent'] ) ) {
1699  $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT']: '';
1700  }
1701  $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 );
1702 
1703  if ( empty( $commentdata['comment_date'] ) ) {
1704  $commentdata['comment_date'] = current_time('mysql');
1705  }
1706 
1707  if ( empty( $commentdata['comment_date_gmt'] ) ) {
1708  $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 );
1709  }
1710 
1711  $commentdata = wp_filter_comment($commentdata);
1712 
1713  $commentdata['comment_approved'] = wp_allow_comment($commentdata);
1714 
1715  $comment_ID = wp_insert_comment($commentdata);
1716  if ( ! $comment_ID ) {
1717  $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' );
1718 
1719  foreach ( $fields as $field ) {
1720  if ( isset( $commentdata[ $field ] ) ) {
1721  $commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] );
1722  }
1723  }
1724 
1725  $commentdata = wp_filter_comment( $commentdata );
1726 
1727  $commentdata['comment_approved'] = wp_allow_comment( $commentdata );
1728 
1729  $comment_ID = wp_insert_comment( $commentdata );
1730  if ( ! $comment_ID ) {
1731  return false;
1732  }
1733  }
1734 
1743  do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'] );
1744 
1745  return $comment_ID;
1746 }
1747 
1756 function wp_new_comment_notify_moderator( $comment_ID ) {
1757  $comment = get_comment( $comment_ID );
1758 
1759  // Only send notifications for pending comments.
1760  $maybe_notify = ( '0' == $comment->comment_approved );
1761 
1763  $maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_ID );
1764 
1765  if ( ! $maybe_notify ) {
1766  return false;
1767  }
1768 
1769  return wp_notify_moderator( $comment_ID );
1770 }
1771 
1783 function wp_new_comment_notify_postauthor( $comment_ID ) {
1784  $comment = get_comment( $comment_ID );
1785 
1786  $maybe_notify = get_option( 'comments_notify' );
1787 
1797  $maybe_notify = apply_filters( 'notify_post_author', $maybe_notify, $comment_ID );
1798 
1799  /*
1800  * wp_notify_postauthor() checks if notifying the author of their own comment.
1801  * By default, it won't, but filters can override this.
1802  */
1803  if ( ! $maybe_notify ) {
1804  return false;
1805  }
1806 
1807  // Only send notifications for approved comments.
1808  if ( ! isset( $comment->comment_approved ) || '1' != $comment->comment_approved ) {
1809  return false;
1810  }
1811 
1812  return wp_notify_postauthor( $comment_ID );
1813 }
1814 
1830 function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
1831  global $wpdb;
1832 
1833  switch ( $comment_status ) {
1834  case 'hold':
1835  case '0':
1836  $status = '0';
1837  break;
1838  case 'approve':
1839  case '1':
1840  $status = '1';
1841  add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' );
1842  break;
1843  case 'spam':
1844  $status = 'spam';
1845  break;
1846  case 'trash':
1847  $status = 'trash';
1848  break;
1849  default:
1850  return false;
1851  }
1852 
1853  $comment_old = clone get_comment($comment_id);
1854 
1855  if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) {
1856  if ( $wp_error )
1857  return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
1858  else
1859  return false;
1860  }
1861 
1862  clean_comment_cache( $comment_old->comment_ID );
1863 
1864  $comment = get_comment( $comment_old->comment_ID );
1865 
1876  do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status );
1877 
1878  wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
1879 
1880  wp_update_comment_count($comment->comment_post_ID);
1881 
1882  return true;
1883 }
1884 
1897 function wp_update_comment($commentarr) {
1898  global $wpdb;
1899 
1900  // First, get all of the original fields
1901  $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
1902  if ( empty( $comment ) ) {
1903  return 0;
1904  }
1905 
1906  // Make sure that the comment post ID is valid (if specified).
1907  if ( isset( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) {
1908  return 0;
1909  }
1910 
1911  // Escape data pulled from DB.
1913 
1914  $old_status = $comment['comment_approved'];
1915 
1916  // Merge old and new fields with new fields overwriting old ones.
1917  $commentarr = array_merge($comment, $commentarr);
1918 
1919  $commentarr = wp_filter_comment( $commentarr );
1920 
1921  // Now extract the merged array.
1922  $data = wp_unslash( $commentarr );
1923 
1931  $data['comment_content'] = apply_filters( 'comment_save_pre', $data['comment_content'] );
1932 
1933  $data['comment_date_gmt'] = get_gmt_from_date( $data['comment_date'] );
1934 
1935  if ( ! isset( $data['comment_approved'] ) ) {
1936  $data['comment_approved'] = 1;
1937  } elseif ( 'hold' == $data['comment_approved'] ) {
1938  $data['comment_approved'] = 0;
1939  } elseif ( 'approve' == $data['comment_approved'] ) {
1940  $data['comment_approved'] = 1;
1941  }
1942 
1943  $comment_ID = $data['comment_ID'];
1944  $comment_post_ID = $data['comment_post_ID'];
1945  $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id' );
1946  $data = wp_array_slice_assoc( $data, $keys );
1947  $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
1948 
1949  clean_comment_cache( $comment_ID );
1950  wp_update_comment_count( $comment_post_ID );
1960  do_action( 'edit_comment', $comment_ID );
1961  $comment = get_comment($comment_ID);
1962  wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
1963  return $rval;
1964 }
1965 
1981  static $_defer = false;
1982 
1983  if ( is_bool($defer) ) {
1984  $_defer = $defer;
1985  // flush any deferred counts
1986  if ( !$defer )
1987  wp_update_comment_count( null, true );
1988  }
1989 
1990  return $_defer;
1991 }
1992 
2013 function wp_update_comment_count($post_id, $do_deferred=false) {
2014  static $_deferred = array();
2015 
2016  if ( $do_deferred ) {
2017  $_deferred = array_unique($_deferred);
2018  foreach ( $_deferred as $i => $_post_id ) {
2019  wp_update_comment_count_now($_post_id);
2020  unset( $_deferred[$i] );
2021  }
2022  }
2023 
2024  if ( wp_defer_comment_counting() ) {
2025  $_deferred[] = $post_id;
2026  return true;
2027  }
2028  elseif ( $post_id ) {
2030  }
2031 
2032 }
2033 
2045  global $wpdb;
2046  $post_id = (int) $post_id;
2047  if ( !$post_id )
2048  return false;
2049 
2050  wp_cache_delete( 'comments-0', 'counts' );
2051  wp_cache_delete( "comments-{$post_id}", 'counts' );
2052 
2053  if ( !$post = get_post($post_id) )
2054  return false;
2055 
2056  $old = (int) $post->comment_count;
2057  $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
2058  $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
2059 
2061 
2071  do_action( 'wp_update_comment_count', $post_id, $new, $old );
2073  do_action( 'edit_post', $post_id, $post );
2074 
2075  return true;
2076 }
2077 
2078 //
2079 // Ping and trackback functions.
2080 //
2081 
2095 function discover_pingback_server_uri( $url, $deprecated = '' ) {
2096  if ( !empty( $deprecated ) )
2097  _deprecated_argument( __FUNCTION__, '2.7' );
2098 
2099  $pingback_str_dquote = 'rel="pingback"';
2100  $pingback_str_squote = 'rel=\'pingback\'';
2101 
2103  $parsed_url = parse_url($url);
2104 
2105  if ( ! isset( $parsed_url['host'] ) ) // Not an URL. This should never happen.
2106  return false;
2107 
2108  //Do not search for a pingback server on our own uploads
2109  $uploads_dir = wp_upload_dir();
2110  if ( 0 === strpos($url, $uploads_dir['baseurl']) )
2111  return false;
2112 
2113  $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
2114 
2115  if ( is_wp_error( $response ) )
2116  return false;
2117 
2118  if ( wp_remote_retrieve_header( $response, 'x-pingback' ) )
2119  return wp_remote_retrieve_header( $response, 'x-pingback' );
2120 
2121  // Not an (x)html, sgml, or xml page, no use going further.
2122  if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) )
2123  return false;
2124 
2125  // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file)
2126  $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
2127 
2128  if ( is_wp_error( $response ) )
2129  return false;
2130 
2131  $contents = wp_remote_retrieve_body( $response );
2132 
2133  $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
2134  $pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
2135  if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
2136  $quote = ($pingback_link_offset_dquote) ? '"' : '\'';
2137  $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
2138  $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
2139  $pingback_href_start = $pingback_href_pos+6;
2140  $pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
2141  $pingback_server_url_len = $pingback_href_end - $pingback_href_start;
2142  $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
2143 
2144  // We may find rel="pingback" but an incomplete pingback URL
2145  if ( $pingback_server_url_len > 0 ) { // We got it!
2146  return $pingback_server_url;
2147  }
2148  }
2149 
2150  return false;
2151 }
2152 
2160 function do_all_pings() {
2161  global $wpdb;
2162 
2163  // Do pingbacks
2164  while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
2165  delete_metadata_by_mid( 'post', $ping->meta_id );
2166  pingback( $ping->post_content, $ping->ID );
2167  }
2168 
2169  // Do Enclosures
2170  while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
2171  delete_metadata_by_mid( 'post', $enclosure->meta_id );
2172  do_enclose( $enclosure->post_content, $enclosure->ID );
2173  }
2174 
2175  // Do Trackbacks
2176  $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
2177  if ( is_array($trackbacks) )
2178  foreach ( $trackbacks as $trackback )
2179  do_trackbacks($trackback);
2180 
2181  //Do Update Services/Generic Pings
2182  generic_ping();
2183 }
2184 
2195  global $wpdb;
2196 
2197  $post = get_post( $post_id );
2198  $to_ping = get_to_ping($post_id);
2199  $pinged = get_pung($post_id);
2200  if ( empty($to_ping) ) {
2201  $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) );
2202  return;
2203  }
2204 
2205  if ( empty($post->post_excerpt) ) {
2207  $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID );
2208  } else {
2210  $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
2211  }
2212 
2213  $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
2214  $excerpt = wp_html_excerpt($excerpt, 252, '&#8230;');
2215 
2217  $post_title = apply_filters( 'the_title', $post->post_title, $post->ID );
2218  $post_title = strip_tags($post_title);
2219 
2220  if ( $to_ping ) {
2221  foreach ( (array) $to_ping as $tb_ping ) {
2222  $tb_ping = trim($tb_ping);
2223  if ( !in_array($tb_ping, $pinged) ) {
2224  trackback($tb_ping, $post_title, $excerpt, $post_id);
2225  $pinged[] = $tb_ping;
2226  } else {
2227  $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) );
2228  }
2229  }
2230  }
2231 }
2232 
2241 function generic_ping( $post_id = 0 ) {
2242  $services = get_option('ping_sites');
2243 
2244  $services = explode("\n", $services);
2245  foreach ( (array) $services as $service ) {
2246  $service = trim($service);
2247  if ( '' != $service )
2248  weblog_ping($service);
2249  }
2250 
2251  return $post_id;
2252 }
2253 
2265  global $wp_version;
2266  include_once(ABSPATH . WPINC . '/class-IXR.php');
2267  include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php');
2268 
2269  // original code by Mort (http://mort.mine.nu:8080)
2270  $post_links = array();
2271 
2272  $pung = get_pung($post_ID);
2273 
2274  // Step 1
2275  // Parsing the post, external links (if any) are stored in the $post_links array
2276  $post_links_temp = wp_extract_urls( $content );
2277 
2278  // Step 2.
2279  // Walking thru the links array
2280  // first we get rid of links pointing to sites, not to specific files
2281  // Example:
2282  // http://dummy-weblog.org
2283  // http://dummy-weblog.org/
2284  // http://dummy-weblog.org/post.php
2285  // We don't wanna ping first and second types, even if they have a valid <link/>
2286 
2287  foreach ( (array) $post_links_temp as $link_test ) :
2288  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
2289  && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
2290  if ( $test = @parse_url($link_test) ) {
2291  if ( isset($test['query']) )
2292  $post_links[] = $link_test;
2293  elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) )
2294  $post_links[] = $link_test;
2295  }
2296  endif;
2297  endforeach;
2298 
2299  $post_links = array_unique( $post_links );
2309  do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) );
2310 
2311  foreach ( (array) $post_links as $pagelinkedto ) {
2312  $pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
2313 
2314  if ( $pingback_server_url ) {
2315  @ set_time_limit( 60 );
2316  // Now, the RPC call
2317  $pagelinkedfrom = get_permalink($post_ID);
2318 
2319  // using a timeout of 3 seconds should be enough to cover slow servers
2320  $client = new WP_HTTP_IXR_Client($pingback_server_url);
2321  $client->timeout = 3;
2334  $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom );
2335  // when set to true, this outputs debug messages by itself
2336  $client->debug = false;
2337 
2338  if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered
2339  add_ping( $post_ID, $pagelinkedto );
2340  }
2341  }
2342 }
2343 
2352 function privacy_ping_filter($sites) {
2353  if ( '0' != get_option('blog_public') )
2354  return $sites;
2355  else
2356  return '';
2357 }
2358 
2374 function trackback($trackback_url, $title, $excerpt, $ID) {
2375  global $wpdb;
2376 
2377  if ( empty($trackback_url) )
2378  return;
2379 
2380  $options = array();
2381  $options['timeout'] = 10;
2382  $options['body'] = array(
2383  'title' => $title,
2384  'url' => get_permalink($ID),
2385  'blog_name' => get_option('blogname'),
2386  'excerpt' => $excerpt
2387  );
2388 
2389  $response = wp_safe_remote_post( $trackback_url, $options );
2390 
2391  if ( is_wp_error( $response ) )
2392  return;
2393 
2394  $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) );
2395  return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) );
2396 }
2397 
2408 function weblog_ping($server = '', $path = '') {
2409  global $wp_version;
2410  include_once(ABSPATH . WPINC . '/class-IXR.php');
2411  include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php');
2412 
2413  // using a timeout of 3 seconds should be enough to cover slow servers
2414  $client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
2415  $client->timeout = 3;
2416  $client->useragent .= ' -- WordPress/'.$wp_version;
2417 
2418  // when set to true, this outputs debug messages by itself
2419  $client->debug = false;
2420  $home = trailingslashit( home_url() );
2421  if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
2422  $client->query('weblogUpdates.ping', get_option('blogname'), $home);
2423 }
2424 
2434 function pingback_ping_source_uri( $source_uri ) {
2435  return (string) wp_http_validate_url( $source_uri );
2436 }
2437 
2450 function xmlrpc_pingback_error( $ixr_error ) {
2451  if ( $ixr_error->code === 48 )
2452  return $ixr_error;
2453  return new IXR_Error( 0, '' );
2454 }
2455 
2456 //
2457 // Cache
2458 //
2459 
2467 function clean_comment_cache($ids) {
2468  foreach ( (array) $ids as $id ) {
2469  wp_cache_delete( $id, 'comment' );
2470  }
2471 
2472  wp_cache_set( 'last_changed', microtime(), 'comment' );
2473 }
2474 
2488 function update_comment_cache( $comments, $update_meta_cache = true ) {
2489  foreach ( (array) $comments as $comment )
2490  wp_cache_add($comment->comment_ID, $comment, 'comment');
2491 
2492  if ( $update_meta_cache ) {
2493  // Avoid `wp_list_pluck()` in case `$comments` is passed by reference.
2494  $comment_ids = array();
2495  foreach ( $comments as $comment ) {
2496  $comment_ids[] = $comment->comment_ID;
2497  }
2498  update_meta_cache( 'comment', $comment_ids );
2499  }
2500 }
2501 
2514 function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) {
2515  global $wpdb;
2516 
2517  $non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' );
2518  if ( !empty( $non_cached_ids ) ) {
2519  $fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
2520 
2521  update_comment_cache( $fresh_comments, $update_meta_cache );
2522  }
2523 }
2524 
2525 //
2526 // Internal
2527 //
2528 
2539 function _close_comments_for_old_posts( $posts, $query ) {
2540  if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
2541  return $posts;
2542 
2550  $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
2551  if ( ! in_array( $posts[0]->post_type, $post_types ) )
2552  return $posts;
2553 
2554  $days_old = (int) get_option( 'close_comments_days_old' );
2555  if ( ! $days_old )
2556  return $posts;
2557 
2558  if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
2559  $posts[0]->comment_status = 'closed';
2560  $posts[0]->ping_status = 'closed';
2561  }
2562 
2563  return $posts;
2564 }
2565 
2577  if ( ! $open )
2578  return $open;
2579 
2580  if ( !get_option('close_comments_for_old_posts') )
2581  return $open;
2582 
2583  $days_old = (int) get_option('close_comments_days_old');
2584  if ( !$days_old )
2585  return $open;
2586 
2587  $post = get_post($post_id);
2588 
2590  $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
2591  if ( ! in_array( $post->post_type, $post_types ) )
2592  return $open;
2593 
2594  // Undated drafts should not show up as comments closed.
2595  if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
2596  return $open;
2597  }
2598 
2599  if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
2600  return false;
2601 
2602  return $open;
2603 }
2604 
2626 function wp_handle_comment_submission( $comment_data ) {
2627 
2628  $comment_post_ID = $comment_parent = 0;
2629  $comment_author = $comment_author_email = $comment_author_url = $comment_content = $_wp_unfiltered_html_comment = null;
2630 
2631  if ( isset( $comment_data['comment_post_ID'] ) ) {
2632  $comment_post_ID = (int) $comment_data['comment_post_ID'];
2633  }
2634  if ( isset( $comment_data['author'] ) && is_string( $comment_data['author'] ) ) {
2635  $comment_author = trim( strip_tags( $comment_data['author'] ) );
2636  }
2637  if ( isset( $comment_data['email'] ) && is_string( $comment_data['email'] ) ) {
2638  $comment_author_email = trim( $comment_data['email'] );
2639  }
2640  if ( isset( $comment_data['url'] ) && is_string( $comment_data['url'] ) ) {
2641  $comment_author_url = trim( $comment_data['url'] );
2642  }
2643  if ( isset( $comment_data['comment'] ) && is_string( $comment_data['comment'] ) ) {
2644  $comment_content = trim( $comment_data['comment'] );
2645  }
2646  if ( isset( $comment_data['comment_parent'] ) ) {
2647  $comment_parent = absint( $comment_data['comment_parent'] );
2648  }
2649  if ( isset( $comment_data['_wp_unfiltered_html_comment'] ) && is_string( $comment_data['_wp_unfiltered_html_comment'] ) ) {
2650  $_wp_unfiltered_html_comment = trim( $comment_data['_wp_unfiltered_html_comment'] );
2651  }
2652 
2653  $post = get_post( $comment_post_ID );
2654 
2655  if ( empty( $post->comment_status ) ) {
2656 
2664  do_action( 'comment_id_not_found', $comment_post_ID );
2665 
2666  return new WP_Error( 'comment_id_not_found' );
2667 
2668  }
2669 
2670  // get_post_status() will get the parent status for attachments.
2671  $status = get_post_status( $post );
2672 
2673  if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
2674  return new WP_Error( 'comment_id_not_found' );
2675  }
2676 
2677  $status_obj = get_post_status_object( $status );
2678 
2679  if ( ! comments_open( $comment_post_ID ) ) {
2680 
2688  do_action( 'comment_closed', $comment_post_ID );
2689 
2690  return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );
2691 
2692  } elseif ( 'trash' == $status ) {
2693 
2701  do_action( 'comment_on_trash', $comment_post_ID );
2702 
2703  return new WP_Error( 'comment_on_trash' );
2704 
2705  } elseif ( ! $status_obj->public && ! $status_obj->private ) {
2706 
2714  do_action( 'comment_on_draft', $comment_post_ID );
2715 
2716  return new WP_Error( 'comment_on_draft' );
2717 
2718  } elseif ( post_password_required( $comment_post_ID ) ) {
2719 
2727  do_action( 'comment_on_password_protected', $comment_post_ID );
2728 
2729  return new WP_Error( 'comment_on_password_protected' );
2730 
2731  } else {
2732 
2740  do_action( 'pre_comment_on_post', $comment_post_ID );
2741 
2742  }
2743 
2744  // If the user is logged in
2745  $user = wp_get_current_user();
2746  if ( $user->exists() ) {
2747  if ( empty( $user->display_name ) ) {
2748  $user->display_name=$user->user_login;
2749  }
2750  $comment_author = $user->display_name;
2751  $comment_author_email = $user->user_email;
2752  $comment_author_url = $user->user_url;
2753  $user_ID = $user->ID;
2754  if ( current_user_can( 'unfiltered_html' ) ) {
2755  if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
2756  || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID )
2757  ) {
2758  kses_remove_filters(); // start with a clean slate
2759  kses_init_filters(); // set up the filters
2760  }
2761  }
2762  } else {
2763  if ( get_option( 'comment_registration' ) ) {
2764  return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to post a comment.' ), 403 );
2765  }
2766  }
2767 
2768  $comment_type = '';
2769 
2770  if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
2771  if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
2772  return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
2773  } elseif ( ! is_email( $comment_author_email ) ) {
2774  return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
2775  }
2776  }
2777 
2778  if ( '' == $comment_content ) {
2779  return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
2780  }
2781 
2782  $commentdata = compact(
2783  'comment_post_ID',
2784  'comment_author',
2785  'comment_author_email',
2786  'comment_author_url',
2787  'comment_content',
2788  'comment_type',
2789  'comment_parent',
2790  'user_ID'
2791  );
2792 
2793  $comment_id = wp_new_comment( wp_slash( $commentdata ) );
2794  if ( ! $comment_id ) {
2795  return new WP_Error( 'comment_save_error', __( '<strong>ERROR</strong>: The comment could not be saved. Please try again later.' ), 500 );
2796  }
2797 
2798  return get_comment( $comment_id );
2799 
2800 }
get_post_status($ID= '')
Definition: post.php:549
const ARRAY_N
Definition: wp-db.php:36
wp_cache_get($key, $group= '', $force=false, &$found=null)
Definition: cache.php:120
get_default_comment_status($post_type= 'post', $comment_type= 'comment')
Definition: comment.php:255
pingback_ping_source_uri($source_uri)
Definition: comment.php:2434
endif
Definition: about.php:203
delete_comment_meta($comment_id, $meta_key, $meta_value= '')
Definition: comment.php:433
do_action($tag, $arg= '')
Definition: plugin.php:482
update_meta_cache($meta_type, $object_ids)
Definition: meta.php:785
$comment
wp_trash_comment($comment_id)
Definition: comment.php:1138
$user_id
Definition: user-edit.php:14
$_COOKIE
Definition: xmlrpc.php:16
wp_get_current_commenter()
Definition: comment.php:1421
global $post_type
if write Inc Temple Place Suite USA that s fine as long as you include a copy of the sourcecode when you sell it Or you can distribute your code without getID3 and say download it from getid3 sourceforge net Why is it called but I could essentially write it today with a one line substr(file_get_contents($filename),-128))
$keys
Definition: wp-cron.php:61
$GLOBALS['wp_press_this']
update_comment_cache($comments, $update_meta_cache=true)
Definition: comment.php:2488
get_post_status_object($post_status)
Definition: post.php:747
add_ping($post_id, $uri)
Definition: post.php:3891
wp_die($message= '', $title= '', $args=array())
Definition: functions.php:2455
kses_remove_filters()
Definition: kses.php:1647
_close_comments_for_old_posts($posts, $query)
Definition: comment.php:2539
$post_id
wp_delete_comment($comment_id, $force_delete=false)
Definition: comment.php:1074
home_url()
Definition: noop.php:76
privacy_ping_filter($sites)
Definition: comment.php:2352
j j j j j j j j j j j compact
const ABSPATH
trackback($trackback_url, $title, $excerpt, $ID)
Definition: comment.php:2374
const OBJECT
Definition: wp-db.php:20
if(current_theme_supports( 'post-formats')&&post_type_supports($post_type, 'post-formats')) add_meta_box( 'formatdiv' _x( 'Format', 'post format')
wp_array_slice_assoc($array, $keys)
Definition: functions.php:3253
post_password_required($post=null)
get_pung($post_id)
Definition: post.php:3957
get_approved_comments($post_id, $args=array())
Definition: comment.php:139
sanitize_comment_cookies()
Definition: comment.php:509
add_action()
Definition: noop.php:41
update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value= '')
Definition: comment.php:470
wp_slash($value)
get_bloginfo()
Definition: noop.php:56
wp_extract_urls($content)
Definition: functions.php:516
COOKIE_DOMAIN
Definition: wp-login.php:401
apply_filters()
Definition: noop.php:26
absint($maybeint)
Definition: functions.php:3528
check_comment_flood_db($ip, $email, $date)
Definition: comment.php:705
delete_metadata_by_mid($meta_type, $meta_id)
Definition: meta.php:698
wp_handle_comment_submission($comment_data)
Definition: comment.php:2626
wp_remote_retrieve_header($response, $header)
Definition: http.php:231
check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type)
Definition: comment.php:39
if(isset($_REQUEST['post_id'])) $id
get_comment_statuses()
Definition: comment.php:232
get_option()
Definition: noop.php:31
$path
Definition: wp-load.php:56
is_wp_error($thing)
wp_unspam_comment($comment_id)
Definition: comment.php:1268
generic_ping($post_id=0)
Definition: comment.php:2241
$out
wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent)
Definition: comment.php:966
wp_cache_set($key, $data, $group= '', $expire=0)
Definition: cache.php:196
get_lastcommentmodified($timezone= 'server')
Definition: comment.php:301
get_comment_count($post_id=0)
Definition: comment.php:341
wp_set_comment_status($comment_id, $comment_status, $wp_error=false)
Definition: comment.php:1830
const ARRAY_A
Definition: wp-db.php:31
get_metadata($meta_type, $object_id, $meta_key= '', $single=false)
Definition: meta.php:458
get_post($post=null, $output=OBJECT, $filter= 'raw')
Definition: post.php:426
$title
Definition: about.php:33
kses_init_filters()
Definition: kses.php:1619
separate_comments(&$comments)
Definition: comment.php:768
add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique=false)
Definition: meta.php:30
if(get_option('db_upgraded')) elseif(get_option('db_version')!=$wp_db_version &&empty($_POST))
Definition: admin.php:45
function WordCounter prototype count
Definition: word-count.js:69
wp_safe_remote_get($url, $args=array())
Definition: http.php:67
wp_filter_comment($commentdata)
Definition: comment.php:1555
object
Definition: iris.min.js:4
get_comment_meta($comment_id, $key= '', $single=false)
Definition: comment.php:449
if(defined( 'RELOCATE')&&RELOCATE) $secure
Definition: wp-login.php:399
weblog_ping($server= '', $path= '')
Definition: comment.php:2408
wp_cache_add($key, $data, $group= '', $expire=0)
Definition: cache.php:27
mysql2date($format, $date, $translate=true)
Definition: functions.php:26
if(!empty($_GET['action'])&&in_array($_GET['action'], $core_actions_get)) add_action( 'wp_ajax_'.$_GET['action'] str_replace( '-', '_', $_GET['action'])
Definition: admin-ajax.php:73
get_to_ping($post_id)
Definition: post.php:3983
$comments
do_enclose($content, $post_ID)
Definition: functions.php:553
get_comment(&$comment=null, $output=OBJECT)
Definition: comment.php:170
delete_metadata($meta_type, $object_id, $meta_key, $meta_value= '', $delete_all=false)
Definition: meta.php:310
$excerpt
const WPINC
wp media string
Definition: media-editor.js:37
wp_count_comments($post_id=0)
Definition: comment.php:1026
wp_safe_remote_post($url, $args=array())
Definition: http.php:88
wp_safe_remote_head($url, $args=array())
Definition: http.php:109
global $post
wp_defer_comment_counting($defer=null)
Definition: comment.php:1980
trailingslashit($string)
wp_cache_delete($key, $group= '')
Definition: cache.php:81
wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment)
Definition: comment.php:1617
if(has_action( 'welcome_panel')&&current_user_can( 'edit_theme_options')) $option
Definition: index.php:101
clean_comment_cache($ids)
Definition: comment.php:2467
clean_post_cache($post)
Definition: post.php:5485
get_comment_pages_count($comments=null, $per_page=null, $threaded=null)
Definition: comment.php:797
is_email($email, $deprecated=false)
static get_instance($id)
wp_get_comment_status($comment_id)
Definition: comment.php:1312
wp_untrash_comment($comment_id)
Definition: comment.php:1182
$ID
get_page_of_comment($comment_ID, $args=array())
Definition: comment.php:853
_close_comments_for_old_post($open, $post_id)
Definition: comment.php:2576
get_current_user_id()
Definition: user.php:351
wp_parse_args($args, $defaults= '')
Definition: functions.php:3216
comments_open($post_id=null)
wp_html_excerpt($str, $count, $more=null)
get_comments($args= '')
Definition: comment.php:217
_deprecated_argument($function, $version, $message=null)
Definition: functions.php:3714
is_local_attachment($url)
Definition: post.php:4616
wp_set_comment_cookies($comment, $user)
Definition: comment.php:483
_prime_comment_caches($comment_ids, $update_meta_cache=true)
Definition: comment.php:2514
discover_pingback_server_uri($url, $deprecated= '')
Definition: comment.php:2095
update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value= '')
Definition: meta.php:143
$_SERVER['REQUEST_URI']
Definition: edit-tags.php:316
wp_new_comment_notify_moderator($comment_ID)
Definition: comment.php:1756
wp_unslash($value)
post_type_supports($post_type, $feature)
Definition: post.php:1548
url_to_postid($url)
Definition: rewrite.php:429
wp_new_comment($commentdata)
Definition: comment.php:1664
esc_attr()
Definition: noop.php:21
global $wp_version
wp_spam_comment($comment_id)
Definition: comment.php:1226
current_time($type, $gmt=0)
Definition: functions.php:61
wp_update_comment($commentarr)
Definition: comment.php:1897
jQuery fn die
do_all_pings()
Definition: comment.php:2160
get_query_var($var, $default= '')
Definition: query.php:26
do_trackbacks($post_id)
Definition: comment.php:2194
$content
Definition: feed-rss2.php:98
wp_remote_retrieve_body($response)
Definition: http.php:283
add_comment_meta($comment_id, $meta_key, $meta_value, $unique=false)
Definition: comment.php:414
xmlrpc_pingback_error($ixr_error)
Definition: comment.php:2450
do_action_ref_array()
Definition: noop.php:51
wp_http_validate_url($url)
Definition: http.php:508
wp_insert_comment($commentdata)
Definition: comment.php:1487
wp_new_comment_notify_postauthor($comment_ID)
Definition: comment.php:1783
wp_allow_comment($commentdata)
Definition: comment.php:571
pingback($content, $post_ID)
Definition: comment.php:2264
if(!defined( 'WP_ADMIN'))
Definition: admin-ajax.php:17
j j j j j j j j j j j j j j j j j j j j j j clone
wp_upload_dir($time=null)
Definition: functions.php:1812
_get_non_cached_ids($object_ids, $cache_key)
Definition: functions.php:4798
get_gmt_from_date($string, $format= 'Y-m-d H:i:s')
wp_update_comment_count_now($post_id)
Definition: comment.php:2044
if(current_theme_supports( 'post-formats')&&post_type_supports($post_type, 'post-formats')) add_meta_box( 'formatdiv' null
global $wpdb
Definition: schema.php:18
function defined(id)
Definition: plugin.js:46
wp_transition_comment_status($new_status, $old_status, $comment)
Definition: comment.php:1353
if(current_theme_supports( 'post-formats')&&post_type_supports($post_type, 'post-formats')) add_meta_box( 'formatdiv'foreach(get_object_taxonomies($post) as $tax_name) if($thumbnail_support &&current_user_can( 'upload_files')) add_meta_box('postimagediv'if(post_type_supports($post_type, 'excerpt')) add_meta_box('postexcerpt' __('Excerpt')
wp_update_comment_count($post_id, $do_deferred=false)
Definition: comment.php:2013
current_user_can($capability)
endforeach
Definition: export.php:205