Move Comments with Tako metabox. Copyright (C) <2016> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ define( 'TAKO_DIR', dirname( __FILE__ ) ); require TAKO_DIR . '/template.php'; class Tako { /*--------------------------------------------* * Constructor *--------------------------------------------*/ /** * Initializes the plugin by adding meta box, filters, and JS files. */ public function __construct() { add_action( 'add_meta_boxes', array( &$this, 'tako_add_meta_box' ) ); add_action( 'edit_comment', array( &$this, 'tako_save_meta_box' ) ); add_action( 'admin_enqueue_scripts', array( &$this, 'tako_load_scripts') ); add_action( 'wp_ajax_tako_chosen_post_type', array( &$this, 'tako_chosen_post_type_callback' ) ); add_action( 'admin_footer-edit-comments.php', array( &$this, 'tako_bulk_action_for_comments' ) ); add_action( 'admin_enqueue_scripts', array( &$this, 'tako_bulk_action_script' ) ); add_action( 'wp_ajax_tako_post_types', array( &$this, 'tako_post_types_callback' ) ); add_action( 'wp_ajax_tako_move_bulk', array( &$this, 'tako_move_bulk_callback' ) ); } /** * Enqueue the CSS & JS file and ensure that it only loads in the edit comment page */ public function tako_load_scripts( $hook ) { if ( $hook == 'comment.php' || $hook == 'edit-comments.php' ) { wp_enqueue_script( 'tako_dropdown', plugins_url( 'js/tako-dropdown.js' , __FILE__ ) ); wp_localize_script( 'tako_dropdown', 'tako_object', array( 'tako_ajax_nonce' => wp_create_nonce( 'tako-ajax-nonce' ) ) ); // Chosen.js & css wp_enqueue_script( 'tako_chosen', plugins_url( 'js/tako-chosen.js', __FILE__ ) ); wp_enqueue_style( 'tako_chosen_style', plugins_url( 'css/tako-chosen.css', __FILE__ ) ); } } /*--------------------------------------------* * Core Functions *---------------------------------------------*/ /** * This is needed in order to add a new meta box in the edit comment page */ public function tako_add_meta_box() { add_meta_box( 'tako_move_comments' ,__( 'Move Comments with Tako', 'tako_lang' ) ,array( &$this, 'tako_meta_box' ) ,'comment' ,'normal' ,'high' ); } /** * The callback for the meta box in order to print the HTML form of the Meta Box * @param array $comment Getting the comment information for the current comment */ public function tako_meta_box( $comment ) { wp_nonce_field( plugin_basename( __FILE__ ), 'tako_nonce' ); $post_types = get_post_types( '', 'names' ); $current_post = get_the_title( $comment->comment_post_ID ); $html = ''; $html .= '
    '; $html .= '
  1. ' . __( 'This post currently belongs to a post titled ', 'tako_lang' ) . '' . $current_post . '' . '
  2. '; $html .= '
  3. ' . __( 'Choose the post type that you want to move this comment to ', 'tako_lang' ); $html .= '  '; $html .= ''; $html .= '
  4. '; $html .= '
  5. ' . __( 'Choose and search for the post title that you want to move this comment to ', 'tako_lang' ); $html .= '