C:\xampp\htdocs\landing\wp-content\plugins\wp-optimize\includes\wp-optimize-notices.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?php

if (!defined('WPO_PLUGIN_MAIN_PATH')) die('No direct access allowed');

if (!
class_exists('Updraft_Notices_1_0')) require_once(WPO_PLUGIN_MAIN_PATH.'includes/updraft-notices.php');

class 
WP_Optimize_Notices extends Updraft_Notices_1_0 {

    protected static 
$_instance null;

    private 
$initialized false;

    protected 
$self_affiliate_id 216;

    protected 
$notices_content = array();

    
/**
     * Creates and returns the only notice instance
     *
     * @return object WP_Optimize_Notices instance
     */
    
public static function instance() {
        if (empty(
self::$_instance)) {
            
self::$_instance = new self();
        }
        return 
self::$_instance;
    }

    
/**
     * This method gets any parent notices and adds its own notices to the notice array
     *
     * @return Array returns an array of notices
     */
    
protected function populate_notices_content() {
        
        
$parent_notice_content parent::populate_notices_content();

        
$child_notice_content = array(
            
'updraftplus' => array(
                
'prefix' => '',
                
'title' => __('Make sure you backup before you optimize your database''wp-optimize'),
                
'text' => __("UpdraftPlus is the world's most trusted backup plugin from the owners of WP-Optimize"'wp-optimize'),
                
'image' => 'notices/updraft_logo.png',
                
'button_link' => 'https://wordpress.org/plugins/updraftplus/',
                
'button_meta' => 'updraftplus',
                
'dismiss_time' => 'dismiss_page_notice_until',
                
'supported_positions' => $this->dashboard_top_or_report,
                
'validity_function' => 'is_updraftplus_installed',
            ),
            
'updraftcentral' => array(
                
'prefix' => '',
                
'title' => __('Save Time and Money. Manage multiple WordPress sites from one location.''wp-optimize'),
                
'text' => __('UpdraftCentral is a highly efficient way to take backup, update and manage multiple WP sites from one location.''wp-optimize'),
                
'image' => 'notices/updraft_logo.png',
                
'button_link' => 'https://updraftcentral.com',
                
'button_meta' => 'updraftcentral',
                
'dismiss_time' => 'dismiss_page_notice_until',
                
'supported_positions' => $this->dashboard_top_or_report,
                
'validity_function' => 'is_updraftcentral_installed',
            ),
            
'rate_plugin' => array(
                
'text' => __("Hey - We noticed WP-Optimize has kept your site running fast for a while.  If you like us, please consider leaving a positive review to spread the word.  Or if you have any issues or questions please leave us a support message"'wp-optimize') . ' <a href="https://wordpress.org/support/plugin/wp-optimize/" target="_blank">' __('here''wp-optimize') . '.</a><br>' __('Thank you so much!''wp-optimize') . ' - <b>WP-Optimize</b><br>',
                
'image' => 'notices/ud_smile.png',
                
'button_link' => 'https://wordpress.org/support/plugin/wp-optimize/reviews/?rate=5#new-post',
                
'button_meta' => 'review',
                
'dismiss_time' => 'dismiss_review_notice',
                
'supported_positions' => $this->dashboard_top,
                
'validity_function' => 'show_rate_notice'
            
),
            
'translation_needed' => array(
                
'prefix' => '',
                
'title' => 'Can you translate? Want to improve WP-Optimize for speakers of your language?',
                
'text' => $this->url_start(true'translate.wordpress.org/projects/wp-plugins/wp-optimize')."Please go here for instructions - it is easy.".$this->url_end(true'translate.wordpress.org/projects/wp-plugins/wp-optimize'),
                
'text_plain' => $this->url_start(false'translate.wordpress.org/projects/wp-plugins/wp-optimize')."Please go here for instructions - it is easy.".$this->url_end(false'translate.wordpress.org/projects/wp-plugins/wp-optimize'),
                
'image' => 'notices/wp_optimize_logo.png',
                
'button_link' => false,
                
'dismiss_time' => false,
                
'supported_positions' => $this->anywhere,
                
'validity_function' => 'translation_needed',
            ),
            
'wpo-premium' => array(
                
'prefix' => '',
                
'title' => __("Perform optimizations while your visitors sleep""wp-optimize"),
                
'text' => __("WP-Optimize Premium features an advanced scheduling system that allows you to run optimizations at the quietest time of day (or night).""wp-optimize"),
                
'image' => 'notices/wp_optimize_logo.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wpo-premium',
                
'dismiss_time' => 'dismiss_notice',
                
'supported_positions' => $this->anywhere,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'wpo-premium-multisite' => array(
                
'prefix' => '',
                
'title' => __("Manage a multisite installation? Need extra control?""wp-optimize"),
                
'text' => __("WP-Optimize Premium's multisite feature includes a locking system that restricts optimization commands to users with the right permissions.""wp-optimize"),
                
'image' => 'notices/wp_optimize_logo.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wpo-premium',
                
'dismiss_time' => 'dismiss_notice',
                
'supported_positions' => $this->anywhere,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'wpo-premium2' => array(
                
'prefix' => '',
                
'title' => __("WP-Optimize Premium offers unparalleled choice and flexibility""wp-optimize"),
                
'text' => __("Upgrade today to combine over a dozen optimization options.""wp-optimize"),
                
'image' => 'notices/wp_optimize_logo.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wpo-premium',
                
'dismiss_time' => 'dismiss_notice',
                
'supported_positions' => $this->anywhere,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'wpo-premium3' => array(
                
'prefix' => '',
                
'title' => __("Remove unwanted images for better site performance.""wp-optimize"),
                
'text' => __("WP-Optimize Premium comes with a feature to easily remove orphaned images, or images that exceed a certain size from your website.""wp-optimize"),
                
'image' => 'notices/wp_optimize_logo.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wpo-premium',
                
'dismiss_time' => 'dismiss_notice',
                
'supported_positions' => $this->anywhere,
                
'validity_function' => 'is_wpo_premium_installed',
            ),

            
// The sale adverts content starts here
            
'blackfriday' => array(
                
'prefix' => '',
                
'title' => __('Black Friday - 20% off WP-Optimize Premium until November 30th''wp-optimize'),
                
'text' => __('To benefit, use this discount code:''wp-optimize').' ',
                
'image' => 'notices/black_friday.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wp-optimize',
                
'dismiss_time' => 'dismiss_season',
                
'discount_code' => 'blackfridaysale2020',
                
'valid_from' => '2020-11-20 00:00:00',
                
'valid_to' => '2020-11-30 23:59:59',
                
'supported_positions' => $this->dashboard_top_or_report,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'newyear' => array(
                
'prefix' => '',
                
'title' => __('Happy New Year - 20% off WP-Optimize Premium until January 14th''wp-optimize'),
                
'text' => __('To benefit, use this discount code:''wp-optimize').' ',
                
'image' => 'notices/new_year.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wp-optimize',
                
'dismiss_time' => 'dismiss_season',
                
'discount_code' => 'newyearsale2021',
                
'valid_from' => '2020-12-26 00:00:00',
                
'valid_to' => '2021-01-14 23:59:59',
                
'supported_positions' => $this->dashboard_top_or_report,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'spring' => array(
                
'prefix' => '',
                
'title' => __('Spring sale - 20% off WP-Optimize Premium until May 15th''wp-optimize'),
                
'text' => __('To benefit, use this discount code:''wp-optimize').' ',
                
'image' => 'notices/spring.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wp-optimize',
                
'dismiss_time' => 'dismiss_season',
                
'discount_code' => 'springsale2020',
                
'valid_from' => '2020-04-01 00:00:00',
                
'valid_to' => '2020-05-15 23:59:59',
                
'supported_positions' => $this->dashboard_top_or_report,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'summer' => array(
                
'prefix' => '',
                
'title' => __('Summer sale - 20% off WP-Optimize Premium until July 31st''wp-optimize'),
                
'text' => __('To benefit, use this discount code:''wp-optimize').' ',
                
'image' => 'notices/summer.png',
                
'button_link' => 'https://getwpo.com',
                
'button_meta' => 'wp-optimize',
                
'dismiss_time' => 'dismiss_season',
                
'discount_code' => 'summersale2020',
                
'valid_from' => '2020-07-01 00:00:00',
                
'valid_to' => '2020-07-31 23:59:59',
                
'supported_positions' => $this->dashboard_top_or_report,
                
'validity_function' => 'is_wpo_premium_installed',
            ),
            
'collection' => array(
                
'prefix' => '',
                
'title' => __('The Updraft Plugin Collection Sale''wp-optimize'),
                
'text' => __('Get 20% off any of our plugins. But hurry - offer ends 30th September, use this discount code:''wp-optimize').' ',
                
'image' => 'notices/wp_optimize_logo.png',
                
'button_link' => 'https://teamupdraft.com',
                
'campaign' => 'collection',
                
'button_meta' => 'collection',
                
'dismiss_time' => 'dismiss_season',
                
'discount_code' => 'WPO2020',
                
'valid_from' => '2020-09-01 00:00:00',
                
'valid_to' => '2020-09-30 23:59:59',
                
'supported_positions' => $this->dashboard_top_or_report,
            )
        );

        return 
array_merge($parent_notice_content$child_notice_content);
    }
    
    
/**
     * Call this method to setup the notices
     */
    
public function notices_init() {
        if (
$this->initialized) return;
        
$this->initialized true;
        
$this->notices_content = (defined('WP_OPTIMIZE_NOADS_B') && WP_OPTIMIZE_NOADS_B) ? array() : $this->populate_notices_content();
    }

    
/**
     * This method will call the parent is_plugin_installed and pass in the product updraftplus to check if that plugin is installed if it is then we shouldn't display the notice
     *
     * @param  string  $product             the plugin slug
     * @param  boolean $also_require_active a bool to indicate if the plugin should also be active
     * @return boolean                      a bool to indicate if the notice should be displayed or not
     */
    
protected function is_updraftplus_installed($product 'updraftplus'$also_require_active false) {
        return 
parent::is_plugin_installed($product$also_require_active);
    }

    
/**
     * This method will call the parent is_plugin_installed and pass in the product updraftcentral to check if that plugin is installed if it is then we shouldn't display the notice
     *
     * @param  string  $product             the plugin slug
     * @param  boolean $also_require_active a bool to indicate if the plugin should also be active
     * @return boolean                      a bool to indicate if the notice should be displayed or not
     */
    
protected function is_updraftcentral_installed($product 'updraftcentral'$also_require_active false) {
        return 
parent::is_plugin_installed($product$also_require_active);
    }

    
/**
     * This method will call the is premium function in the WPO object to check if this install is premium and if it is we won't display the notice
     *
     * @return boolean a bool to indicate if we should display the notice or not
     */
    
protected function is_wpo_premium_installed() {
        if (
WP_Optimize::is_premium()) {
            return 
false;
        }

        return 
true;
    }

    
/**
     * This method will check to see if a number of different backup plugins are installed and if they are we won't display the notice
     *
     * @param  String  $product             the plugin slug
     * @param  boolean $also_require_active a bool to indicate if the plugin should be active or not
     * @return boolean                      a bool to indicate if the notice should be displayed or not
     */
    
public function is_backup_plugin_installed($product null$also_require_active false) {
        
$backup_plugins = array('updraftplus' => 'UpdraftPlus''backwpup' => 'BackWPup''backupwordpress' => 'BackupWordPress''vaultpress' => 'VaultPress''wp-db-backup' => 'WP-DB-Backup''backupbuddy' => 'BackupBuddy');

        foreach (
$backup_plugins as $slug => $title) {
            if (!
parent::is_plugin_installed($slug$also_require_active)) {
                return 
$title;
            }
        }

        return 
apply_filters('wp_optimize_is_backup_plugin_installed'false);
    }

    
/**
     * This function will check if we should display the rate notice or not
     *
     * @return boolean - to indicate if we should show the notice or not
     */
    
protected function show_rate_notice() {
        
        
$options WP_Optimize()->get_options();
        
$installed $options->get_option('installed-for'0);
        
$installed_for time() - $installed;
        
        if (
$installed && $installed_for 28*86400) {
            return 
true;
        }

        return 
false;
    }

    
/**
     * This method calls the parent verson and will work out if the user is using a non english language and if so returns true so that they can see the translation advert.
     *
     * @param  String $plugin_base_dir the plugin base directory
     * @param  String $product_name    the name of the plugin
     * @return Boolean                 returns true if the user is using a non english language and could translate otherwise false
     */
    
protected function translation_needed($plugin_base_dir null$product_name null) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
        
return parent::translation_needed(WPO_PLUGIN_MAIN_PATH'wp-optimize');
    }
    
    
/**
     * This method is used to generate the correct URL output for the start of the URL
     *
     * @param  Boolean $html_allowed a boolean value to indicate if HTML can be used or not
     * @param  String  $url          the url to use
     * @param  Boolean $https        a boolean value to indicate if https should be used or not
     * @param  String  $website_home a string to be displayed
     * @return String                returns a string of the completed url
     */
    
protected function url_start($html_allowed$url$https false$website_home 'updraftplus.com/wp-optimize') {
        return 
parent::url_start($html_allowed$url$https$website_home);
    }

    
/**
     * This method checks to see if the notices dismiss_time parameter has been dismissed
     *
     * @param  String $dismiss_time a string containing the dimiss time ID
     * @return Boolean returns true if the notice has been dismissed and shouldn't be shown otherwise display it
     */
    
protected function check_notice_dismissed($dismiss_time) {

        
$time_now = (defined('WP_OPTIMIZE_NOTICES_FORCE_TIME') ? WP_OPTIMIZE_NOTICES_FORCE_TIME time());
    
        
$options WP_Optimize()->get_options();

        
$notice_dismiss = ($time_now $options->get_option($dismiss_time0));

        return 
$notice_dismiss;
    }

    
/**
     * Check notice data for seasonal info and return true if we should display this notice.
     *
     * @param array $notice_data
     * @return bool
     */
    
protected function skip_seasonal_notices($notice_data) {
        
$time_now defined('WPO_NOTICES_FORCE_TIME') ? WPO_NOTICES_FORCE_TIME time();
        
// Do not show seasonal notices in Premium version.
        
if (false === WP_Optimize::is_premium()) {
            
$valid_from strtotime($notice_data['valid_from']);
            
$valid_to strtotime($notice_data['valid_to']);
            
$dismiss $this->check_notice_dismissed($notice_data['dismiss_time']);
            if ((
$time_now >= $valid_from && $time_now <= $valid_to) && !$dismiss) {
                
// return true so that we return this notice to be displayed
                
return true;
            }
        }

        return 
false;
    }

    
/**
     * This method will create the chosen notice and the template to use and depending on the parameters either echo it to the page or return it
     *
     * @param  Array   $advert_information     an array with the notice information in
     * @param  Boolean $return_instead_of_echo a bool value to indicate if the notice should be printed to page or returned
     * @param  String  $position               a string to indicate what template should be used
     * @return String                          a notice to display
     */
    
protected function render_specified_notice($advert_information$return_instead_of_echo false$position 'top') {
    
        if (
'bottom' == $position) {
            
$template_file 'bottom-notice.php';
        } elseif (
'report' == $position) {
            
$template_file 'report.php';
        } elseif (
'report-plain' == $position) {
            
$template_file 'report-plain.php';
        } else {
            
$template_file 'horizontal-notice.php';
        }
        
        
$extract_variables array_merge($advert_information, array('wp_optimize_notices' => $this));

        return 
WP_Optimize()->include_template('notices/'.$template_file$return_instead_of_echo$extract_variables);
    }
}

$GLOBALS['wp_optimize_notices'] = WP_Optimize_Notices::instance();
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586