Welcome, visitor! Log in
 

Source View: comment_on_draft

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN  (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
0  <?php
1  require( dirname(__FILE__) . '/wp-config.php' );
2  
3  $comment_post_ID = (int) $_POST['comment_post_ID'];
4  
5  $status = $wpdb->get_row("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");
6  
7  if ( empty($status->comment_status) ) {
8       do_action('comment_id_not_found', $comment_post_ID);
9       exit;
10  } elseif ( 'closed' ==  $status->comment_status ) {
11       do_action('comment_closed', $comment_post_ID);
12       die( __('Sorry, comments are closed for this item.') );
13  } elseif ( 'draft' == $status->post_status ) {
14       do_action('comment_on_draft', $comment_post_ID);
15       exit;
16  }
17  
18  $comment_author       = trim($_POST['author']);
19  $comment_author_email = trim($_POST['email']);
20  $comment_author_url   = trim($_POST['url']);
21  $comment_content      = trim($_POST['comment']);
22  
23  // If the user is logged in
24  get_currentuserinfo();
25  if ( $user_ID ) :
26       $comment_author       = addslashes($user_identity);
27       $comment_author_email = addslashes($user_email);
28       $comment_author_url   = addslashes($user_url);
29  else :