/** * Initialize the plugin by loading admin scripts & styles and adding a * settings page and menu. * * @since 1.0.0 */ private function __construct() { $this->plugin_slug = PT_CV_DOMAIN; // Redirect to "Add View" page when click "Add new" link in "All Views" page add_action('admin_init', array($this, 'redirect_add_new')); // Load admin style sheet and JavaScript. add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles')); add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); add_action('admin_enqueue_scripts', array($this, 'remove_unwanted_assets'), 1000); add_action('admin_print_footer_scripts', array($this, 'print_footer_scripts')); // Add the options page and menu item. add_action('admin_menu', array($this, 'add_plugin_admin_menu')); // Ajax action $action = 'preview_request'; add_action('wp_ajax_' . $action, array('PT_CV_Functions', 'ajax_callback_' . $action)); // Output assets content at footer of page add_action(PT_CV_PREFIX_ . 'preview_footer', array('PT_CV_Html', 'assets_of_view_types')); // Add an action link pointing to the options page. $plugin_basename = plugin_basename(PT_CV_PATH . $this->plugin_slug . '.php'); add_filter('plugin_action_links_' . $plugin_basename, array($this, 'filter_add_action_links')); // Filter link of actions in All Views page add_filter('post_row_actions', array($this, 'filter_view_row_actions'), 10, 2); // Add Shortcode column add_filter('manage_pt_view_posts_columns', array($this, 'filter_view_custom_column_header')); add_action('manage_pt_view_posts_custom_column', array($this, 'action_view_custom_column_content'), 10, 2); // Filter link of Title in All Views page add_filter('get_edit_post_link', array($this, 'filter_get_edit_post_link'), 10, 3); // Filter Title of Edit View page add_filter('admin_title', array($this, 'filter_admin_title'), 10, 2); // Custom hooks for both preview & frontend PT_CV_Hooks::init(); // Custom settings page PT_CV_Plugin::init(); }
/** * Initialize the plugin by setting localization and loading public scripts * and styles. * * @since 1.0.0 */ private function __construct() { // Init session add_action('init', array($this, 'register_session'), 1); // Load plugin text domain add_action('init', array($this, 'load_plugin_textdomain'), 11); // Register content add_action('init', array($this, 'content_register')); // Activate plugin when new blog is added add_action('wpmu_new_blog', array($this, 'activate_new_site')); // Load public-facing style sheet and JavaScript. add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'), 0); add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); // Update view count of post add_action('wp_head', array(&$this, 'head_actions')); // Output assets content at footer of page add_action('wp_footer', array('PT_CV_Html', 'assets_of_view_types'), 100); // Load assets if they are not enqueued to 'wp_enqueue_scripts' add_action('wp_footer', array($this, 'enqueue_assets'), 2); // Ajax action $action = 'pagination_request'; add_action('wp_ajax_' . $action, array('PT_CV_Functions', 'ajax_callback_' . $action)); add_action('wp_ajax_nopriv_' . $action, array('PT_CV_Functions', 'ajax_callback_' . $action)); // Custom hooks for both preview & frontend PT_CV_Hooks::init(); }
/** * Initialize the plugin by loading admin scripts & styles and adding a * settings page and menu. * * @since 1.0.0 */ private function __construct() { /* * @TODO : * * - Uncomment following lines if the admin class should only be available for super admins */ /* if( ! is_super_admin() ) { return; } */ /* * Call $plugin_slug from public plugin class. */ $plugin = PT_Content_Views::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); // Fix redirect error add_action('init', array($this, 'do_output_buffer')); // Redirect to "Add View" page when click "Add new" link in "All Views" page add_action('admin_init', array($this, 'redirect_add_new')); // Load admin style sheet and JavaScript. add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles')); add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); add_action('admin_print_footer_scripts', array($this, 'print_footer_scripts')); // Add the options page and menu item. add_action('admin_menu', array($this, 'add_plugin_admin_menu')); // Ajax action $action = 'preview_request'; add_action('wp_ajax_' . $action, array('PT_CV_Functions', 'ajax_callback_' . $action)); // Output assets content at footer of page add_action(PT_CV_PREFIX_ . 'preview_footer', array('PT_CV_Html', 'assets_of_view_types')); // Add an action link pointing to the options page. $plugin_basename = plugin_basename(plugin_dir_path(dirname(__FILE__)) . $this->plugin_slug . '.php'); add_filter('plugin_action_links_' . $plugin_basename, array($this, 'filter_add_action_links')); // Filter link of actions in All Views page add_filter('post_row_actions', array($this, 'filter_view_row_actions'), 10, 2); // Add Shortcode column add_filter('manage_pt_view_posts_columns', array($this, 'filter_view_custom_column_header')); add_action('manage_pt_view_posts_custom_column', array($this, 'action_view_custom_column_content'), 10, 2); // Filter link of Title in All Views page add_filter('get_edit_post_link', array($this, 'filter_get_edit_post_link'), 10, 3); // Filter Title of Edit View page add_filter('admin_title', array($this, 'filter_admin_title'), 10, 2); // Custom hooks for both preview & frontend PT_CV_Hooks::init(); // Custom settings page PT_CV_Plugin::init(); }