← All changes
|
includes/class-wp-optimize-install-or-update-notice.php
+20
-10
3.2.7
→
4.7.0
View file →
| @@ -17,8 +17,15 @@ | ||
| 17 | 17 | * @var string |
| 18 | 18 | */ |
| 19 | 19 | private $version = '1.1'; |
| 20 | 20 | |
| 21 | + /** | |
| 22 | + * Options object | |
| 23 | + * | |
| 24 | + * @var WP_Optimize_Options | |
| 25 | + */ | |
| 26 | + protected $options; | |
| 27 | + | |
| 21 | 28 | public function __construct() { |
| 22 | 29 | $this->options = WP_Optimize()->get_options(); |
| 23 | 30 | |
| 24 | 31 | if ($this->show_current_notice()) { |
| @@ -33,14 +40,14 @@ | ||
| 33 | 40 | * @return boolean |
| 34 | 41 | */ |
| 35 | 42 | public function show_current_notice() { |
| 36 | 43 | // Check the option |
| 37 | - $latest_saved_notice = $this->options->get_option('install-or-update-notice-version', false); | |
| 44 | + $latest_saved_notice = $this->options->get_option('install-or-update-notice-version'); | |
| 38 | 45 | if ($latest_saved_notice && version_compare($latest_saved_notice, $this->version, '>=')) { |
| 39 | 46 | return false; |
| 40 | 47 | } |
| 41 | 48 | |
| 42 | - $notice_show_time = $this->options->get_option('install-or-update-notice-show-time', false); | |
| 49 | + $notice_show_time = $this->options->get_option('install-or-update-notice-show-time'); | |
| 43 | 50 | |
| 44 | 51 | // If notice has been showing for more than 14days, automatically dismiss it. |
| 45 | 52 | if ($notice_show_time && (time() - $notice_show_time) > (14 * 86400)) { |
| 46 | 53 | $this->dismiss(); |
| @@ -62,9 +69,12 @@ | ||
| 62 | 69 | public function output_notice() { |
| 63 | 70 | WP_Optimize()->include_template('notices/install-or-update-notice.php', false, array( |
| 64 | 71 | 'is_new_install' => $this->is_new_install(), |
| 65 | 72 | 'is_premium' => WP_Optimize::is_premium(), |
| 66 | - 'is_updraftplus_installed' => $this->is_updraftplus_installed() | |
| 73 | + 'is_updraftplus_installed' => $this->is_plugin_installed("updraftplus"), | |
| 74 | + 'is_ilj_installed' => $this->is_plugin_installed("internal-links"), | |
| 75 | + 'is_aios_installed' => $this->is_plugin_installed("all-in-one-wp-security-and-firewall"), | |
| 76 | + 'is_aios_prem_installed' => $this->is_plugin_installed("all-in-one-wp-security-and-firewall-premium"), | |
| 67 | 77 | )); |
| 68 | 78 | } |
| 69 | 79 | |
| 70 | 80 | /** |
| @@ -72,9 +82,9 @@ | ||
| 72 | 82 | * |
| 73 | 83 | * @return boolean |
| 74 | 84 | */ |
| 75 | 85 | private function is_new_install() { |
| 76 | - if ($this->options->get_option('newly-activated', false)) { | |
| 86 | + if ($this->options->get_option('newly-activated')) { | |
| 77 | 87 | return true; |
| 78 | 88 | } |
| 79 | 89 | |
| 80 | 90 | return false; |
| @@ -99,16 +109,16 @@ | ||
| 99 | 109 | $this->options->delete_option('install-or-update-notice-show-time'); |
| 100 | 110 | |
| 101 | 111 | return true; |
| 102 | 112 | } |
| 103 | - | |
| 113 | + | |
| 104 | 114 | /** |
| 105 | - * Check if updraftplus is installed. | |
| 115 | + * Checks if a specific plugin is installed. | |
| 106 | 116 | * |
| 107 | - * @return bool | |
| 117 | + * @param string $plugin_name The name of the plugin to check for installation status. | |
| 118 | + * @return bool True if the plugin is installed, false otherwise. | |
| 108 | 119 | */ |
| 109 | - private function is_updraftplus_installed() { | |
| 110 | - $status = WP_Optimize()->get_db_info()->get_plugin_status('updraftplus'); | |
| 111 | - | |
| 120 | + private function is_plugin_installed($plugin_name) { | |
| 121 | + $status = WP_Optimize()->get_db_info()->get_plugin_status($plugin_name); | |
| 112 | 122 | return $status['installed']; |
| 113 | 123 | } |
| 114 | 124 | } |