/** * Return an instance of this class. * * @since 1.0 * @return object - A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Initialize the plugin by loading admin scripts * and styles and adding a settings page and menu. * * @since 1.0 */ private function __construct() { // Get plugin class and data $this->lock_your_updates = Lock_Your_Updates::get_instance(); // These filters are what disables plugins and themes from being updated $this->add_disable_updates_filter('plugins'); $this->add_disable_updates_filter('themes'); // Gets active themes and plugins data for the network admin add_action('load-plugins.php', array($this, 'set_active_plugins_themes_by_site'), 1); add_action('load-themes.php', array($this, 'set_active_plugins_themes_by_site'), 1); // Processes the locking and unlocking of plugins and themes add_action('load-plugins.php', array($this, 'lock_unlock_plugins_themes'), 2); add_action('load-themes.php', array($this, 'lock_unlock_plugins_themes'), 2); // 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 columns to plugin and theme tables add_filter('manage_plugins-network_columns', array($this, 'manage_plugins_themes_columns'), 1000); add_filter('manage_plugins_columns', array($this, 'manage_plugins_themes_columns'), 1000); add_filter('manage_themes-network_columns', array($this, 'manage_plugins_themes_columns'), 1000); // Add values to custom plugin and theme table columns add_action('manage_plugins_custom_column', array($this, 'manage_plugins_themes_custom_column'), 1, 3); add_action('manage_themes_custom_column', array($this, 'manage_plugins_themes_custom_column'), 1, 3); // Add links to plugins row actions add_filter('network_admin_plugin_action_links', array($this, 'plugins_action_links'), 20, 4); add_filter('plugin_action_links', array($this, 'plugins_action_links'), 20, 4); // Add links to themes row actions add_filter('theme_action_links', array($this, 'themes_action_links'), 20, 3); // Allows us to print our own messages after theme rows add_action('after_theme_row', array($this, 'after_theme_plugin_row'), 1, 3); add_action('after_plugin_row', array($this, 'after_theme_plugin_row'), 1, 3); // A few filters for dealing with the plugin's options foreach ($this->options as $option_name) { // Sanitizes our options when they're retrieved add_filter('option_' . $option_name, array($this, 'sanitize_get_option'), 1); add_filter('site_option_' . $option_name, array($this, 'sanitize_get_option'), 1); // Sanitizes our options before they're saved add_filter('pre_update_option_' . $option_name, array($this, 'sanitize_pre_update_option'), 1, 2); add_filter('pre_update_site_option_' . $option_name, array($this, 'sanitize_pre_update_option'), 1, 2); } // Allows us to tweak the update data add_filter('wp_get_update_data', array($this, 'filter_update_data'), 1, 2); // Process bulk actions add_action('admin_init', array($this, 'process_bulk_actions'), 1); // AJAX function to retrieve item data add_action('wp_ajax_lock_your_updates_get_item_data', array($this, 'wp_ajax_get_item_data')); // AJAX function to retrieve theme action buttons add_action('wp_ajax_lock_your_updates_get_theme_action_buttons', array($this, 'wp_ajax_get_theme_action_buttons')); // AJAX function to save item note add_action('wp_ajax_lock_your_updates_save_item_notes', array($this, 'wp_ajax_save_item_notes')); // AJAX function to retrieve item's "preview notes" row add_action('wp_ajax_lock_your_updates_get_item_preview_notes_row', array($this, 'wp_ajax_get_item_preview_notes_row')); // AJAX function to retrieve theme's "preview notes" area add_action('wp_ajax_lock_your_updates_get_themes_preview_notes_area', array($this, 'wp_ajax_get_themes_preview_notes_area')); }