Skip to content

Ajax Edit Comments Plugin Hooks

Ajax Edit Comments 2.0 has numerous plugin hooks for other plugin authors to tap into.

JavaScript Hook

If you have a plugin that posts comments via Ajax, you can add this code immediately after the new comment is shown.

Please note that your plugin should use the ?comment_post? filter.



if (window.AjaxEditComments) {
   AjaxEditComments.init();
}

Plugin Hook (wp_ajax_comments_comment_edited – Action)


wp_ajax_comments_comment_edited

Accepts 2 arguments ($commentID, $postID)

Example:


add_action('wp_ajax_comments_comment_edited', 'hook_example',1,2);
function hook_example($commentID = 0, $postID = 0) {
}

Plugin Hook (add_wp_ajax_comments_js_post – Action)

Accepts no arguments. Adds appropriate AEC JavaScript to a post. You would want to run this within a ?wp_print_scripts? action.

Example:


do_action('add_wp_ajax_comments_js_post');

Plugin Hook (add_wp_ajax_comments_js_admin – Action)

Accepts no arguments. Adds appropriate AEC JavaScript to admin panel. You would want to run this in the ?admin_print_scripts? action.

Example:


do_action('add_wp_ajax_comments_js_admin');

Plugin Hook (wp_ajax_comments_remove_content_filter – Action)

Accepts no arguments. Stops Ajax Edit Comments from adding in edit links into the comment?s section.

Example:


do_action('wp_ajax_comments_remove_content_filter');

Plugin Hook (add_wp_ajax_comments_css_editor – Action)

An action to add your own CSS to the comment editor.

Example:



add_action('add_wp_ajax_comments_css_editor', 'my_css');
function my_css() {
  //echo out css here
}

Plugin Hook (wp_ajax_comments_get_comment – Filter)

Allows you to return your own data values when a comment is being loaded.
Accepts 2 arguments ($responseObj, $commentObj)
You must return $responseObj

Example:

add_filter('wp_ajax_comments_get_comment', 'my_response', 1, 2);
function my_response($r, $c) {
  $response = new WP_Ajax_Response();
  $response = $r;
  $response->add( array(
    'what' => 'gravatar',
    'id' => $c->ID,
    'data' => $gravatar
  ));
  return $response;
}

Plugin Hook (wp_ajax_comments_save_comment – Filter)

Allows you to return and process your own data values when a comment is being saved.
Accepts 3 arguments ($responseObj, $commentArr, $_POST)
You must return $responseObj.

Example:

add_filter('wp_ajax_comments_save_comment', 'my_response', 1, 3);
function my_response($r, $c, $postVars) {
  $response = new WP_Ajax_Response();
  $response = $r;
  $response->add( array(
    'what' => 'gravatar',
    'id' => $c['ID'],
    'data' => $gravatar
  ));
  return $response;
}

Plugin Hook (wp_ajax_comments_editor – Action)

Allows you to add in your own table rows into the comment editor.

Example:


add_action('wp_ajax_comments_editor', 'my_table_row');
function my_table_row() {
  ?>
  <tr>

    <td><label for="URL"><?php _e('URL',$localization); ?></label></td>
    <td><span> : </span><input type="text" size="35" name="URL" id="URL" /></td>

  </tr>
  <?php
}

Return to Ajay Edit Plugins home.