Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_ajax_{$action}

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.

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

Source View

This hook occurs 2 times in this file.

Line Code
51      }
52      $s = trim( $s );
53      if ( strlen( $s ) < 2 )
54           die; // require 2 chars for matching
55      $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = 'post_tag' AND t.name LIKE ('%". $s . "%')" );
56      echo join( $results, "\n" );
57      die;
58      break;
59 default :
60      do_action( 'wp_ajax_' . $_GET['action'] );
61      die('0');
62      break;
63 endswitch;
64 endif;
65
66 $id = isset($_POST['id'])? (int) $_POST['id'] : 0;
67 switch ( $action = $_POST['action'] ) :
68 case 'delete-comment' :
69      check_ajax_referer( "delete-comment_$id" );
 
Line Code
1031      $x = new WP_Ajax_Response();
1032      $x->add( array(
1033           'what' => $what,
1034           'data' => $html
1035      ));
1036      $x->send();
1037
1038      break;
1039 default :
1040      do_action( 'wp_ajax_' . $_POST['action'] );
1041      die('0');
1042      break;
1043 endswitch;
1044 ?>
1045