/** PHP5 class constructor */ function __construct() { // activation hook used to install the plugin - saving the default options into WP options table register_activation_hook(TG_SEARCHBOXES__FILE__, array($this, 'tg_searchboxes_install')); // deac.hook - deleting the options for TG-searchboxes from WP options table register_deactivation_hook(TG_SEARCHBOXES__FILE__, array($this, 'tg_searchboxes_deactivate')); // call parent's constructor for reading the options from WP options table parent::__construct(); /** date format used in JS, needed for Calendar scripts, based on User Settings */ $this->options['date_format_js'] = $this->options['date_format'] == 'd/m/Y' ? 'dd/mm/yy' : 'mm/dd/yy'; // adding a menu to the menues on the left of the dashboard add_action('admin_menu', array($this, 'tg_searchboxes_create_menu')); // initializing the class needed to display the html for the searchboxes settings page $this->searchboxesSettingsFormRenderer = new searchboxesSettingsFormRenderer($this); add_action('admin_init', array($this->searchboxesSettingsFormRenderer, 'admin_init')); // add_action('admin_init', array($this, 'jquery_ui'), 0); // is an AJAX request or not; DOING_AJAX is set by WP automatically; AJAX req. is triggered on Add-TG-Box button click $doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false; // accepting AJAX req.s as valid only from the post editing interface; page-slug is assigned to the button $valid_ajax_call = isset($_GET['page']) && $this->page_slug == $_GET['page'] ? true : false; // have to check for possible call by editor button to show the searchboxes in a popup div done by thickbox if ($doing_ajax && $valid_ajax_call && isset($_GET['action']) && 'tg_searchboxes' == $_GET['action']) { // valid ajax req. => Editor Button clicked => then on the thickbox popup div show the content of the specified views // currently there's only 1 action+fn. for that:do_action_tg_searchboxes add_action('init', array($this, 'do_action_' . $_GET['action'])); } // the editor button will be present only on the pages in the array below $pages_with_editor_button = array('post.php', 'post-new.php', 'page.php', 'page-new.php'); foreach ($pages_with_editor_button as $page) { // if any of the given pages are loaded => edd the editor button add_action('load-' . $page, array($this, 'add_editor_button')); } return; }
/** PHP5 class constructor */ function __construct() { /** call parent's constructor for reading the options from WP options table */ parent::__construct(); // add_action('wp_enqueue_scripts', array($this, 'jquery_ui'), 0); /** adding to the dom the css files needed by the plugin in the frontend */ $this->enqueue_tg_searchboxes_css(); /** adding to the dom the js files and variables needed by the plugin in the frontend */ $this->enqueue_tg_searchboxes_js(); /** adding a hook for the shortcode "tg_searchboxes"; * WP will automatically pass the found arguments: [shortcode argument1=value1 argument2=value2] */ add_shortcode($this->shortcode_tg_searchboxes, array($this, 'tg_searchboxes_handle_tg_shortcode')); // checking if current request is to load the searchbox via external JS file $this->check_load_with_javascript(); return; }