%plugin%. Please support our free work by rating this plugin with 5 stars on WordPress.org. Click here to rate us.'; /** * Plugin suggestions */ private $days_dismissing_suggestions = 180; // 6 months reappear private $suggestions_message = '%plugin% recommends the following free plugins:'; private $suggestions = array( 'force-https-littlebizzy' => array( 'name' => 'Force HTTPS', 'desc' => 'Redirects all HTTP requests to the HTTPS version and fixes all insecure static resources without altering the database (also works with CloudFlare).', 'filename' => 'force-https.php', ), 'remove-category-base-littlebizzy' => array( 'name' => 'Remove Category Base', 'desc' => 'Completely disables the category base from all URLs generated by WordPress so that there is no category slug displayed on archive permalinks, etc.', 'filename' => 'remove-category-base.php', ), 'disable-author-pages-littlebizzy' => array( 'name' => 'Disable Author Pages', 'desc' => 'Completely disables author archives which then become 404 errors, converts author links to homepage links, and works with or without fancy permalinks.', 'filename' => 'disable-author-pages.php', ), 'disable-search-littlebizzy' => array( 'name' => 'Disable Search', 'desc' => 'Completely disables the built-in WordPress search function to prevent snoopers or bots from querying your database or slowing down your website.', 'filename' => 'disable-search.php', ), 'duplicate-post-littlebizzy' => array( 'name' => 'Duplicate Post', 'desc' => 'Easily duplicate (clone) any post, custom post, or page which are then saved in Draft mode, saving you tons of time and headache (no settings page).', 'filename' => 'duplicate-post.php', ), 'server-status-littlebizzy' => array( 'name' => 'Server Status', 'desc' => 'Useful statistics about the server OS, CPU, RAM, load average, memory usage, IP address, hostname, timezone, disk space, PHP, MySQL, caches, etc.', 'filename' => 'server-status.php', ), ); // Properties // --------------------------------------------------------------------------------------------------- /** * Store missing plugins */ private $missing; /** * Default prefix * Can be changed by the external initialization. */ private $prefix = 'lbladn'; /** * Caller plugin file */ private $plugin_file; /** * Single class instance */ private static $instance; // Initialization // --------------------------------------------------------------------------------------------------- /** * Create or retrieve instance */ public static function instance($plugin_file = null) { // Avoid direct calls if (!function_exists('add_action')) die; // Check instance if (!isset(self::$instance)) self::$instance = new self($plugin_file); // Done return self::$instance; } /** * Constructor */ private function __construct($plugin_file = null) { // Main plugin file $this->plugin_file = isset($plugin_file)? $plugin_file : __FILE__; // Uninstall hook endpoint register_uninstall_hook($this->plugin_file, array(__CLASS__, 'uninstall')); // Prefix from the class name $classname = explode('_', __CLASS__); $this->prefix = strtolower($classname[0]); // Check notices if (is_admin()) { $this->check_timestamps(); $this->check_suggestions(); $this->check_rate_us(); } } // Timestamp checks // --------------------------------------------------------------------------------------------------- /** * Creates the activation timestamp only if it does not exist */ private function check_timestamps() { $timestamp =$this->get_activation_timestamp(); if (empty($timestamp)) $this->update_activation_timestamp(); } /** * Check the suggestions dismissed timestamp */ private function check_suggestions() { // Compare timestamp $timestamp = $this->get_dismissed_timestamp('suggestions'); if (empty($timestamp) || (time() - $timestamp) > ($this->days_dismissing_suggestions * 86400)) { // Check AJAX submit if (defined('DOING_AJAX') && DOING_AJAX) { add_action('wp_ajax_'.$this->prefix.'_dismiss_suggestions', array(&$this, 'dismiss_suggestions')); // Admin area (except install or activate plugins page) } elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) { add_action('wp_loaded', array(&$this, 'load_notices_suggestions'), PHP_INT_MAX); } } } /** * Check the rate us dismissed timestamp */ private function check_rate_us() { // Check plugin activation timestamp $timestamp = $this->get_activation_timestamp(); if (!empty($timestamp) && (time() - $timestamp) > ($this->days_before_display_rate_us * 86400)) { // Compare dismissed timestamp $timestamp = $this->get_dismissed_timestamp('rate_us'); if (empty($timestamp) || (time() - $timestamp) > ($this->days_dismissing_rate_us * 86400)) { // Check AJAX submit if (defined('DOING_AJAX') && DOING_AJAX) { add_action('wp_ajax_'.$this->prefix.'_dismiss_rate_us', array(&$this, 'dismiss_rate_us')); // Admin area (except install or activate plugins page) } elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) { add_action('wp_loaded', array(&$this, 'load_notices_rate_us'), PHP_INT_MAX); } } } } // Loaders // --------------------------------------------------------------------------------------------------- /** * Check and load the sugestions notices */ public function load_notices_suggestions() { // Check the disable nag constant if ($this->disable_nag_notices()) return; // Collect missing plugins $this->missing = $this->get_missing_plugins(); if (!empty($this->missing) && is_array($this->missing)) { add_action('admin_footer', array(&$this, 'admin_footer_suggestions')); add_action('admin_notices', array(&$this, 'admin_notices_suggestions')); } } /** * Check and load the rate us notices */ public function load_notices_rate_us() { // Check the disable nag constant if ($this->disable_nag_notices()) return; // Admin hooks add_action('admin_footer', array(&$this, 'admin_footer_rate_us')); add_action('admin_notices', array(&$this, 'admin_notices_rate_us')); } // Admin Notices display // --------------------------------------------------------------------------------------------------- /** * Suggestions display */ public function admin_notices_suggestions() { $plugin_data = get_plugin_data($this->plugin_file); ?>
suggestions_message); ?>
rate_us_url, str_replace('%plugin%', $plugin_data['Name'], $this->rate_us_message)); ?>