/** * Retrieve a Reflection object for the file a shortcode is in. * * @uses $this->shortcode * @uses $this->reflection_object */ private function set_reflection_object() { $shortcodes = $GLOBALS['shortcode_tags']; if (empty($this->shortcode) || !isset($shortcodes[$this->shortcode])) { // Not a registered shortcode. return; } $callback = $shortcodes[$this->shortcode]; if (!is_string($callback) && (!is_array($callback) || is_array($callback) && (!is_string($callback[0]) && !is_object($callback[0]))) && (!is_object($callback) || is_object($callback) && !Debug_Bar_Shortcodes_Render::is_closure($callback))) { // Not a valid callback. return; } /* Set up reflection. */ if (is_string($callback) && false === strpos($callback, '::') || is_object($callback) && Debug_Bar_Shortcodes_Render::is_closure($callback)) { $this->reflection_object = new ReflectionFunction($callback); } else { if (is_string($callback) && false !== strpos($callback, '::')) { $this->reflection_object = new ReflectionMethod($callback); } else { if (is_array($callback)) { $this->reflection_object = new ReflectionMethod($callback[0], $callback[1]); } } } if (isset($this->reflection_object) && false === $this->reflection_object->isUserDefined()) { // Not a user defined callback, i.e. native PHP, nothing to find out about it (shouldn't ever happen). $this->reflection_object = null; } }
/** * 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 (!isset($_POST['dbs-nonce']) || false === wp_verify_nonce($_POST['dbs-nonce'], 'debug-bar-shortcodes')) { exit('-1'); } // Verify we have received the data needed to do anything. if (!isset($_POST['shortcode']) || '' === $_POST['shortcode']) { exit('-1'); } $output_rendering = new Debug_Bar_Shortcodes_Render(); $shortcode = trim($_POST['shortcode']); // Exit early if this is a non-existent shortcode - shouldn't happen, but hack knows ;-). if (false === shortcode_exists($shortcode)) { $response = array('id' => 0, 'data' => ''); $output_rendering->send_ajax_response($response); exit; } // Send the request to our handler. switch ($_POST['action']) { case 'debug-bar-shortcodes-find': $output_rendering->ajax_find_shortcode_uses($shortcode); break; case 'debug-bar-shortcodes-retrieve': $output_rendering->ajax_retrieve_details($shortcode); break; default: // Intentionally empty. 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() { $output_rendering = new Debug_Bar_Shortcodes_Render(); $output_rendering->display(); }