/** * Verify validity of ajax request and pass it to the internal handler */ function debug_bar_shortcodes_do_ajax() { // Verify this is a valid ajax request if (wp_verify_nonce($_POST['dbs-nonce'], 'debug-bar-shortcodes') === false) { exit('-1'); } // Verify we have received the data needed to do anything if (!isset($_POST['shortcode']) || $_POST['shortcode'] === '') { exit('-1'); } include_once plugin_dir_path(__FILE__) . 'class-debug-bar-shortcodes-info.php'; $info = new Debug_Bar_Shortcodes_Info(); $shortcode = $_POST['shortcode']; $shortcode = trim($shortcode); // Exit early if this is a non-existent shortcode - shouldn't happen, but hack knows ;-) if (shortcode_exists($shortcode) === false) { $response = array('id' => 0, 'data' => ''); $info->send_ajax_response($response); exit; } // Send the request to our handler switch ($_POST['action']) { case 'debug-bar-shortcodes-find': $info->ajax_find_shortcode_uses($shortcode); break; case 'debug-bar-shortcodes-retrieve': $info->ajax_retrieve_details($shortcode); break; } /* No valid action received (redundancy, can't really happen as wp wouldn't then call this function, but would return 0 and exit already */ exit('-1'); }
/** * Render the panel */ public function render() { include_once plugin_dir_path(__FILE__) . 'class-debug-bar-shortcodes-info.php'; $info = new Debug_Bar_Shortcodes_Info(); $info->display(); }