/** * Initiate Frontend functionality * * @since 1.0.0 */ public function __construct() { parent::__construct(); /** * Filter whether the TablePress Default CSS code shall be loaded. * * @since 1.0.0 * * @param bool $use Whether the Default CSS shall be loaded. Default true. */ if (apply_filters('tablepress_use_default_css', true) || TablePress::$model_options->get('use_custom_css')) { add_action('wp_enqueue_scripts', array($this, 'enqueue_css')); } // add DataTables invocation calls add_action('wp_print_footer_scripts', array($this, 'add_datatables_calls'), 11); // after inclusion of files // Remove WP-Table Reloaded Shortcodes and CSS, and add TablePress Shortcodes add_action('init', array($this, 'init_shortcodes'), 20); // run on priority 20 as WP-Table Reloaded Shortcodes are registered at priority 10 // make TablePress Shortcodes work in text widgets add_filter('widget_text', array($this, 'widget_text_filter')); /** * Filter whether the WordPress search shall also search TablePress tables. * * @since 1.0.0 * * @param bool $search Whether the TablePress tables shall be searched. Default true. */ if (apply_filters('tablepress_wp_search_integration', true)) { // Extend WordPress Search to also find posts/pages that have a table with the one of the search terms in title (if shown), description (if shown), or content add_filter('posts_search', array($this, 'posts_search_filter')); } // load Template Tag functions require_once TABLEPRESS_ABSPATH . 'controllers/template-tag-functions.php'; }
/** * Initialize the Admin Controller, determine location the admin menu, set up actions. * * @since 1.0.0 */ public function __construct() { parent::__construct(); // Handler for changing the number of shown tables in the list of tables (via WP List Table class). add_filter('set-screen-option', array($this, 'save_list_tables_screen_option'), 10, 3); add_action('admin_menu', array($this, 'add_admin_menu_entry')); add_action('admin_init', array($this, 'add_admin_actions')); }
/** * Initiate Admin AJAX functionality. * * @since 1.0.0 */ public function __construct() { // Buffer all outputs, to prevent errors/warnings being printed that make the JSON invalid. ob_start(); parent::__construct(); $ajax_actions = array('hide_message', 'save_table', 'preview_table'); foreach ($ajax_actions as $action) { add_action("wp_ajax_tablepress_{$action}", array($this, "ajax_action_{$action}")); } }