PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 2.6.2
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v2.6.2
2.15.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 All 62 releases
← All changes | includes/Admin.php +491 -174 2.1.32.6.2 View file →
@@ -1,9 +1,10 @@
1 1 <?php
2 2
3 3 namespace Hurrytimer;
4 4
5 -use \Hurrytimer\Utils\Helpers;
5 +use DateTime;
6 +use Hurrytimer\CSS_Builder;
6 7
7 8 class Admin
8 9 {
9 10 /**
@@ -27,77 +28,214 @@
27 28 /**
28 29 * Initialize the class and set its properties.
29 30 *
30 31 * @param string $pluginName The name of this plugin.
31 - * @param string $version The version of this plugin.
32 + * @param string $version The version of this plugin.
32 33 *
33 34 * @since 1.0.0
34 35 *
35 36 */
36 - public function __construct($pluginName, $version)
37 + public function __construct( $pluginName, $version )
37 38 {
38 -
39 39 $this->pluginName = $pluginName;
40 40 $this->version = $version;
41 - add_action('wp_ajax_wcSearchProducts', [$this, 'ajaxWcSearchProducts']);
42 - add_action('admin_init', [$this, 'activateCampaign']);
43 - add_action('admin_init', [$this, 'deactivateCampaign']);
44 - add_filter('post_row_actions', [$this, 'campaignsListRowActions']);
45 - add_action('admin_menu', [$this, 'menu']);
46 - add_filter('bulk_actions-edit-' . HURRYT_POST_TYPE,
47 - [$this, 'campaignsListBulkActions']);
41 + add_action( 'wp_insert_post', [ $this, 'regenerate_css' ], 10, 3 );
42 + add_action( 'wp_ajax_wcSearchProducts', [ $this, 'ajaxWcSearchProducts' ] );
43 + add_action( 'wp_ajax_add_wc_condition_group', [ $this, 'ajaxAddWcConditionGroup' ] );
44 + add_action( 'wp_ajax_add_wc_condition', [ $this, 'ajaxAddWcCondition' ] );
45 + add_action( 'wp_ajax_load_wc_condition', [ $this, 'ajaxLoadWcCondition' ] );
46 + add_action( 'wp_ajax_hurryt_dismiss_leave_review_notice', [ $this, 'dismiss_leave_review_ajax' ] );
47 + add_action( 'wp_ajax_hurryt_remind_leave_review_notice', [ $this, 'remind_leave_review_ajax' ] );
48 + add_action( 'admin_init', [ $this, 'activateCampaign' ] );
49 + add_action( 'admin_init', [ $this, 'deactivateCampaign' ] );
50 + add_action( 'admin_init', [ $this, 'resetEvergreenCampaign' ] );
51 + add_action( 'admin_init', [ $this, 'resetAllEvergreenCampaigns' ] );
52 + add_action( 'admin_init', [ $this, 'pluginSettings' ] );
53 + add_filter( 'post_row_actions', [ $this, 'campaignsListRowActions' ] );
54 + add_action( 'admin_menu', [ $this, 'menu' ] );
55 + add_filter( 'bulk_actions-edit-' . HURRYT_POST_TYPE,
56 + [ $this, 'campaignsListBulkActions', ] );
48 57
49 - add_filter('manage_' . HURRYT_POST_TYPE . '_posts_columns',
50 - [$this, 'campaignsListColumns']);
58 + add_filter( 'manage_' . HURRYT_POST_TYPE . '_posts_columns',
59 + [ $this, 'campaignsListColumns', ] );
51 60
52 - add_action('manage_' . HURRYT_POST_TYPE . '_posts_custom_column',
53 - [$this, 'countdownListColumnsContent'], 10, 2);
54 61
55 - add_action('views_edit-' . HURRYT_POST_TYPE,
56 - [$this, 'countdown_list_header_links'], 10);
57 - add_filter(
58 - 'bulk_post_updated_messages',
59 - [$this, 'customBulkPostUpdatedMessages'], 10, 2);
62 + add_action( 'manage_' . HURRYT_POST_TYPE . '_posts_custom_column',
63 + [ $this, 'countdownListColumnsContent' ], 10, 2 );
60 64
61 - add_action('admin_menu', [$this, 'helpTabs']);
62 - add_action('admin_notices', [$this, 'countdown_activation_notice']);
63 - add_filter('admin_footer_text', [$this, 'admin_footer_text']);
65 + add_filter( 'bulk_post_updated_messages',
66 + [ $this, 'customBulkPostUpdatedMessages' ], 10, 2 );
67 +
68 + add_action( 'admin_menu', [ $this, 'helpTabs' ] );
69 + add_action( 'admin_notices', [ $this, 'resetEvergreenCampaignNotice' ] );
70 + add_action( 'admin_notices', [ $this, 'resetAllEvergreenCampaignNotice' ] );
71 +
72 + add_action( 'admin_notices', [ $this, 'countdown_activation_notice' ] );
73 + add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ] );
74 + add_filter( 'wp_insert_post_data', [ $this, 'mark_post_being_saved' ] );
75 +
76 + add_filter( 'plugin_action_links_' . HURRYT_BASENAME, [ $this, 'set_plugin_action_links' ] );
77 +
64 78 //removeIf(pro)
65 - add_filter('plugin_action_links_' . HURRYT_BASENAME, [$this, 'pluginLinks']);
79 + add_action( 'admin_notices', [ $this, 'leave_review_notice' ] );
66 80 //endRemoveIf(pro)
81 +
82 + add_action( 'wp_ajax_hurryt_dismiss_headline_moved_notice', [ $this, 'dismiss_headline_moved_notice' ] );
83 +
67 84 }
68 85
86 + public function dismiss_leave_review_ajax(){
87 + check_ajax_referer( 'hurryt-admin', 'nonce' );
88 + add_option('hurryt_leave_review_dismissed','1');
89 + }
90 + public function remind_leave_review_ajax(){
91 + check_ajax_referer( 'hurryt-admin', 'nonce' );
92 + set_transient('hurryt_remind_review_notice','1', 86400);
93 + }
69 94
95 + public function dismiss_headline_moved_notice(){
96 + check_ajax_referer( 'hurryt-admin', 'nonce' );
97 + add_option('hurryt_headline_moved_notice_dismissed','1');
98 +
99 + }
100 +
101 + private function should_ask_for_review(){
102 +
103 + $campaigns = get_posts([
104 + 'post_type' => HURRYT_POST_TYPE,
105 + 'post_status'=> 'publish',
106 + 'posts_per_page'=> 1,
107 + 'orderby'=> 'post_date',
108 + 'order' => 'ASC'
109 + ]);
110 +
111 + if( is_wp_error($campaigns) || empty( $campaigns ) || ! is_array( $campaigns )){
112 + return false;
113 + }
114 +
115 + $post_date = new DateTime( $campaigns[0]->post_date);
116 +
117 + $now = new DateTime( current_time('mysql') );
118 +
119 + $diff = $post_date->diff($now);
120 +
121 + if( ! $diff ){
122 + return false;
123 + }
124 +
125 + return $diff->d >=1;
126 + }
127 +
128 + public function leave_review_notice(){
129 + if(! apply_filters('hurryt_show_plugin_review_notice', true) ){
130 + return;
131 + }
132 +
133 + if( ! $this->should_ask_for_review() ){
134 + return;
135 + }
136 +
137 + if(get_transient('hurryt_remind_review_notice')){
138 + return;
139 + }
140 + if(get_option('hurryt_leave_review_dismissed')){
141 + return;
142 + }
143 + if(isset($_COOKIE['hurryt_leave_review_remind'])){
144 + return;
145 + }
146 + if(isset($_COOKIE['hurryt_leave_review_dismissed'])){
147 + return;
148 + }
149 + ?>
150 + <div class="notice notice-info is-dismissible">
151 + <h3>Support the development of HurryTimer plugin!</h3>
152 + <p>Thank you for choosing <b>HurryTimer</b>. If you liked the plugin, kindly leave us a 5-star review on <a href="https://wordpress.org/support/plugin/hurrytimer/reviews/?filter=5" target="_blank">WordPress.org</a>. We really appreciate your support!</p>
153 +
154 + <p> <a href="https://wordpress.org/support/plugin/hurrytimer/reviews/?filter=5" class="button-primary">Leave a review</a>
155 + &nbsp;<button type="button" class="button button-default" id="hurryt-remind-review-notice" >Remind me later</a>
156 + &nbsp; <button type="button" class="button-link" id="hurryt-dismiss-review-notice" style="margin-left:10px">Already done!</a>
157 +
158 +</p>
159 + </div>
160 + <?php
161 + }
162 +
163 + function mark_post_being_saved( $data ) {
164 +
165 + global $hurryt_saving_post;
166 +
167 + $hurryt_saving_post = 1;
168 +
169 + return $data;
170 + }
171 +
172 + /**
173 + * Generate published campaigns CSS file.
174 + *
175 + * @param $post_id
176 + * @param $post
177 + * @param $update
178 + */
179 + function regenerate_css( $post_id, $post, $update )
180 + {
181 + if ( wp_is_post_revision( $post_id ) ) {
182 + return;
183 + }
184 +
185 + if ( $post->post_type !== HURRYT_POST_TYPE ) {
186 + return;
187 + }
188 +
189 + if ( $update ) {
190 + CSS_Builder::get_instance()->build();
191 + }
192 +
193 + }
194 +
70 195 public function admin_footer_text()
71 196 {
72 197 $screen = get_current_screen();
73 - if ($screen->post_type === HURRYT_POST_TYPE) {
198 + if ( $screen->post_type === HURRYT_POST_TYPE ) {
74 199 include HURRYT_DIR . 'admin/templates/footer-rate-plugin.php';
75 200 }
76 201 }
77 202
78 - //removeIf(pro)
79 - function pluginLinks($links)
203 + public function set_plugin_action_links( $links )
80 204 {
81 - $links[] = '<a href="https://hurrytimer.com/pricing" target="_blank">PREMIUM</a>';
205 + $settings_url = admin_url( 'admin.php?page=hurrytimer_settings' );
206 + $settings_anchor = '<a href="' . $settings_url . '">' . __( 'Settings' ) . '</a>';
207 + $manage_url = admin_url( 'edit.php?post_type=' . HURRYT_POST_TYPE );
208 + $manage_anchor = '<a href="' . $manage_url . '">' . __( 'Campaigns', 'hurrytimer' ) . '</a>';
209 + $links[] = $manage_anchor;
210 + $links[] = $settings_anchor;
82 211
212 + //removeIf(pro)
213 + $manage_license_link = admin_url( 'admin.php?page=hurrytimer_license' );
214 + $manage_license_anchor = '<a href="' . $manage_license_link . '">' . __( 'License' ) . '</a>';
215 + $links[] = $manage_license_anchor;
216 +
217 + $links[]
218 + = '<a href="https://hurrytimer.com/?utm_source=plugin&utm_medium=installed_plugins&utm_campaign=go_pro" target="_blank" class="hurryt-text-green-500 hurryt-font-bold">Go Pro</a>';
219 +
220 + //endRemoveIf(pro)
221 +
83 222 return $links;
84 223 }
85 224
86 - //endRemoveIf(pro)
87 225
88 226 public function countdown_activation_notice()
89 227 {
90 - $post_id = filter_input(INPUT_GET, 'post', FILTER_VALIDATE_INT);
91 - $status = filter_input(INPUT_GET, 'hurrytimer_action');
228 + $post_id = filter_input( INPUT_GET, 'post', FILTER_VALIDATE_INT );
229 + $status = filter_input( INPUT_GET, 'hurrytimer_action' );
92 230
93 - if ( ! $post_id || ! $status || ! ($post = get_post($post_id))) {
231 + if ( !$post_id || !$status || !( $post = get_post( $post_id ) ) ) {
94 232 return;
95 233 }
96 234 if (
97 - $status === "ctivate-compaign"
235 + $status === "activate-compaign"
98 236 &&
99 - ! Utils\Helpers::isPostActive($post_id)
237 + !Utils\Helpers::isPostActive( $post_id )
100 238 ) { ?>
101 239 <div class="notice notice-success is-dismissible">
102 240 <p><?php _e(
103 241 'Countdown timer deactivated.',
@@ -105,9 +243,9 @@
105 243 ); ?></p>
106 244 </div>
107 245 <?php } else { ?>
108 246 <div class="notice notice-success is-dismissible">
109 - <p><?php _e('Countdown timer activated.', "hurrytimer"); ?></p>
247 + <p><?php _e( 'Countdown timer activated.', "hurrytimer" ); ?></p>
110 248 </div>
111 249 <?php }
112 250 }
113 251
@@ -112,51 +250,49 @@
112 250 }
113 251
114 252 public function helpTabs()
115 253 {
116 - add_action('load-edit.php', [$this, 'editHelpTabs']);
117 - add_action('load-post-new.php', [$this, 'editHelpTabs']);
118 - add_action('load-post.php', [$this, 'editHelpTabs']);
254 + add_action( 'load-edit.php', [ $this, 'editHelpTabs' ] );
255 + add_action( 'load-post-new.php', [ $this, 'editHelpTabs' ] );
256 + add_action( 'load-post.php', [ $this, 'editHelpTabs' ] );
119 257 }
120 258
121 259 public function editHelpTabs()
122 260 {
123 261 $screen = get_current_screen();
124 - if (strpos($screen->id, 'hurrytimer_countdown') === false) {
262 + if ( strpos( $screen->id, 'hurrytimer_countdown' ) === false ) {
125 263 return;
126 264 }
127 265 $screen->remove_help_tabs();
128 266 }
129 267
130 - public function customBulkPostUpdatedMessages(
131 - $bulk_messages,
132 - $bulk_counts
133 - ) {
134 - $bulk_messages[HURRYT_POST_TYPE] = [
268 + public function customBulkPostUpdatedMessages( $bulk_messages, $bulk_counts )
269 + {
270 + $bulk_messages[ HURRYT_POST_TYPE ] = [
135 271 'updated' => _n(
136 272 '%s countdown timer updated.',
137 273 '%s countdown timers updated.',
138 - $bulk_counts['updated']
274 + $bulk_counts[ 'updated' ]
139 275 ),
140 276 'locked' => _n(
141 277 '%s countdown timer not updated, somebody is editing it.',
142 278 '%s countdown timers not updated, somebody is editing them.',
143 - $bulk_counts['locked']
279 + $bulk_counts[ 'locked' ]
144 280 ),
145 281 'deleted' => _n(
146 282 '%s countdown timer permanently deleted.',
147 283 '%s countdown timers permanently deleted.',
148 - $bulk_counts['deleted']
284 + $bulk_counts[ 'deleted' ]
149 285 ),
150 286 'trashed' => _n(
151 287 '%s countdown timer deleted.',
152 288 '%s countdown timers deleted.',
153 - $bulk_counts['trashed']
289 + $bulk_counts[ 'trashed' ]
154 290 ),
155 291 'untrashed' => _n(
156 292 '%s countdown timer restored from the Trash.',
157 293 '%s countdown timers restored from the Trash.',
158 - $bulk_counts['untrashed']
294 + $bulk_counts[ 'untrashed' ]
159 295 ),
160 296 ];
161 297
162 298 return $bulk_messages;
@@ -161,62 +297,61 @@
161 297
162 298 return $bulk_messages;
163 299 }
164 300
165 - public function countdown_list_header_links($views)
301 + public function countdownListColumnsContent( $column, $post_id )
166 302 {
167 - unset($views['trash']);
168 -
169 - return $views;
170 - }
171 -
172 - public function countdownListColumnsContent($column, $post_id)
173 - {
174 - $campaign = new Campaign($post_id);
175 - switch ($column) {
303 + $campaign = new Campaign( $post_id );
304 + switch ( $column ) {
176 305 case 'status':
177 - echo $campaign->isPublished()
178 - ? __('Active', "hurrytimer")
179 - : __('Inactive', "hurrytimer");
306 + echo $campaign->is_published()
307 + ? __( 'Active', "hurrytimer" )
308 + : __( 'Inactive', "hurrytimer" );
180 309 break;
181 310 case 'mode':
182 - echo $campaign->isEvergreen()
183 - ? __('Evergreen', "hurrytimer")
184 - : __('Regular', "hurrytimer");
311 + if ( $campaign->is_evergreen() ) {
312 + echo __( 'Evergreen', "hurrytimer" );
313 + }
314 + if ( $campaign->is_one_time() ) {
315 + echo __( 'One-Time', "hurrytimer" );
316 + }
317 + if ( $campaign->is_recurring() ) {
318 + echo __( 'Recurring', "hurrytimer" );
319 + }
185 320 break;
186 - case 'CampaignShortcode':
187 - echo '<pre class="htmr-list-shortcode">[hurrytimer id="' .
188 - $post_id .
189 - '"]</pre>';
321 + case 'shortcode':
322 + ?>
323 +<input style="min-width:100%" type="text" readonly onfocus="this.select()" value="[hurrytimer id=&quot;<?php echo $post_id ?>&quot;]">
324 + <?php
325 +
190 326 break;
191 327 }
192 328 }
193 329
194 - public function campaignsListBulkActions($actions)
330 + public function campaignsListBulkActions( $actions )
195 331 {
196 - unset($actions['edit']);
197 -
332 + unset( $actions[ 'edit' ] );
198 333 return $actions;
199 334 }
200 335
201 - public function campaignsListColumns($columns)
336 + public function campaignsListColumns( $columns )
202 337 {
203 338 $allowed_columns = [];
204 - foreach ($columns as $column_name => $value) {
205 - if (in_array($column_name, ['cb', 'title', 'date'])) {
206 - $allowed_columns[$column_name] = $value;
339 + foreach ( $columns as $column_name => $value ) {
340 + if ( in_array( $column_name, [ 'cb', 'title', 'date' ] ) ) {
341 + $allowed_columns[ $column_name ] = $value;
207 342 }
208 343 }
209 344
210 345 $columns = $allowed_columns;
211 - $date = $columns['date'];
212 - unset($columns['date']);
213 - $columns = array_merge($columns, [
214 - 'status' => __('Status', "hurrytimer"),
215 - 'mode' => __('Mode', "hurrytimer"),
216 - 'CampaignShortcode' => __('CampaignShortcode', "hurrytimer"),
217 - ]);
218 - $columns['date'] = $date;
346 + $date = $columns[ 'date' ];
347 + unset( $columns[ 'date' ] );
348 + $columns = array_merge( $columns, [
349 + 'status' => __( 'Status', "hurrytimer" ),
350 + 'mode' => __( 'Mode', "hurrytimer" ),
351 + 'shortcode' => __( 'Shortcode', "hurrytimer" ),
352 + ] );
353 + $columns[ 'date' ] = $date;
219 354
220 355 return $columns;
221 356 }
222 357
@@ -226,45 +361,51 @@
226 361 * @since 1.0.0
227 362 */
228 363 public function enqueueStyles()
229 364 {
230 - $version = defined('WP_DEBUG') && WP_DEBUG ? time() : $this->version;
231 - wp_enqueue_style('wp-color-picker');
232 - wp_enqueue_style('iris');
233 - wp_dequeue_style('select2');
365 + $version = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : $this->version;
234 366
235 - wp_enqueue_style("codemirror",
236 - HURRYT_URL . 'assets/css/codemirror.css', [], "5.42.2",
237 - 'all');
367 + wp_enqueue_style( 'wp-color-picker' );
368 + wp_dequeue_style( 'select2' );
369 +
238 370 wp_enqueue_style(
371 + "codemirror",
372 + HURRYT_URL . 'assets/css/codemirror.css',
373 + [],
374 + "5.42.2",
375 + 'all'
376 + );
377 + wp_enqueue_style(
239 378 'hurryt-select2',
240 - HURRYT_URL . 'assets/css/select2.css', array(),
241 - '4.0.5', 'all'
379 + HURRYT_URL . 'assets/css/select2.css',
380 + array(),
381 + '4.0.5',
382 + 'all'
242 383 );
243 384
244 385 wp_enqueue_style(
245 386 'hurryt-base-css',
246 - HURRYT_URL . 'assets/css/base.css', array(),
247 - $version, 'all'
387 + HURRYT_URL . 'assets/css/main.css',
388 + array(),
389 + $version,
390 + 'all'
248 391 );
249 392
250 - wp_enqueue_style($this->pluginName,
251 - HURRYT_URL . 'assets/css/admin.css', ['hurryt-base-css', 'hurryt-select2'],
252 - $version, 'all');
393 + wp_enqueue_style(
394 + $this->pluginName,
395 + HURRYT_URL . 'assets/css/admin.css',
396 + [ 'wp-color-picker', 'hurryt-base-css', 'hurryt-select2' ],
397 + $version,
398 + 'all'
399 + );
253 400 }
254 401
255 - public function campaignsListRowActions($actions)
402 + public function campaignsListRowActions( $actions )
256 403 {
257 404 global $post;
258 - if ($post->post_type === HURRYT_POST_TYPE) {
259 - unset($actions['inline hide-if-no-js']);
260 - unset($actions['trash']);
405 + if ( $post->post_type === HURRYT_POST_TYPE ) {
406 + unset( $actions[ 'inline hide-if-no-js' ] );
261 407 }
262 - $actions['delete'] = '<a href="' .
263 - get_delete_post_link($post->ID) .
264 - '">' .
265 - __('Delete', "hurrytimer") .
266 - '</a>';
267 408
268 409 return $actions;
269 410 }
270 411
@@ -274,102 +415,213 @@
274 415 * @since 1.0.0
275 416 */
276 417 public function enqueueScripts()
277 418 {
278 - wp_enqueue_script('jquery-ui-core');
279 - wp_enqueue_script('jquery-ui-tooltip');
280 - wp_enqueue_script('wp-color-picker');
281 - wp_enqueue_script('iris');
282 - wp_enqueue_script('jquery-ui-slider');
283 - wp_dequeue_script('select2');
284 - //removeIf(pro)
419 + wp_enqueue_script( 'jquery-ui-core' );
420 + wp_enqueue_script( 'jquery-ui-tooltip' );
421 + wp_enqueue_script( 'wp-color-picker' );
422 + wp_enqueue_script( 'jquery-ui-slider' );
423 + wp_dequeue_script( 'select2' );
424 +
285 425 wp_enqueue_script(
286 - "jq-modal",
287 - HURRYT_URL . 'assets/js/jquery.modal.min.js',
288 - ['jquery'],
289 - "0.9.1",
290 - true);
291 - //endRemoveIf(pro)
426 + 'hurryt-cookie',
427 + HURRYT_URL . 'assets/js/cookie.min.js',
428 + [],
429 + '2.2.0',
430 + true
431 + );
292 432
293 433 wp_enqueue_script(
294 434 'jq-date-picker-addon',
295 435 HURRYT_URL . 'assets/js/timepicker-addon.js',
296 - ['jquery-ui-datepicker'],
436 + [ 'jquery-ui-datepicker' ],
297 437 '1.6.3',
298 - true);
438 + true
439 + );
299 440
300 441 wp_enqueue_script(
301 442 'hurryt-select2',
302 443 HURRYT_URL . 'assets/js/select2.min.js',
303 - ['jquery'],
444 + [ 'jquery' ],
304 445 '4.0.5',
305 - true);
446 + true
447 + );
306 448
307 - $deps = ['jq-date-picker-addon', 'hurryt-select2'];
449 + $deps = [ 'wp-color-picker', 'hurryt-cookie', 'jq-date-picker-addon', 'hurryt-select2' ];
308 450
451 + $version = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : $this->version;
452 +
309 453 wp_enqueue_script(
310 454 $this->pluginName,
311 455 HURRYT_URL . 'assets/js/admin.js',
312 456 $deps,
313 - $this->version,
314 - true);
457 + $version,
458 + true
459 + );
315 460
316 - wp_localize_script($this->pluginName, 'hurrytimer_ajax_object',
317 - array(
318 - 'ajax_url' => admin_url('admin-ajax.php'),
319 - 'headline_pos' => [
320 - 'above_timer' => C::HEADLINE_POSITION_ABOVE_TIMER,
321 - 'below_timer' => C::HEADLINE_POSITION_BELOW_TIMER,
322 - ],
323 - 'mode' => [
324 - 'evergreen' => C::MODE_EVERGREEN,
325 - 'regular' => C::MODE_REGULAR,
326 - ],
327 - ));
461 + wp_localize_script( $this->pluginName, 'hurrytimer_ajax_object', array(
462 + 'ajax_nonce' => wp_create_nonce( 'hurryt-admin' ),
463 + 'ajax_url' => admin_url( 'admin-ajax.php' ),
464 + 'headline_pos' => [
465 + 'above_timer' => C::HEADLINE_POSITION_ABOVE_TIMER,
466 + 'below_timer' => C::HEADLINE_POSITION_BELOW_TIMER,
467 + ],
468 + 'mode' => [
469 + 'evergreen' => C::MODE_EVERGREEN,
470 + 'regular' => C::MODE_REGULAR,
471 + 'recurring' => C::MODE_RECURRING,
472 + ],
473 + 'COOKIEPATH' => defined( 'COOKIEPATH' ) ? COOKIEPATH : '',
474 + 'COOKIE_DOMAIN' => defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '',
475 + ) );
476 +
328 477 }
329 478
330 479 public function menu()
331 480 {
332 - add_menu_page('HurryTimer', 'HurryTimer', 'manage_options', 'hurrytimer', null,
333 - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNjkuNTYgNzAuNjIiPiAgPGRlZnM+ICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYzNiZGI3MTYtYmI3Ny00MzUxLTllOGYtYTUwY2Y3ODEzNDNlIiB5MT0iMzUuMzEiIHgyPSI2NS4wNyIgeTI9IjM1LjMxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+ICAgICAgPHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZjg1MzdmIi8+ICAgICAgPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNjNjIi8+ICAgIDwvbGluZWFyR3JhZGllbnQ+ICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYzk5ODViMWMtYjg3Zi00M2Y1LWFiMz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wwLDAsMC0xLTQuMVE0Ni42OCw4LjczLDQ1LjIsOC4xYTMyLjM5LDMyLjM5LDAsMCwwLTQuNjktMS41N1YyLjQxQTIuNDEsMi40MSwwLDAsMCwzOC4xLDBIMjguNDJBMi40MSwyLjQxLDAsMCwwLDI2LDIuNDFWNi4yaDBhMzIuMzcsMzIuMzcsMCwwLDAtMTEuNjQsNC45Yy0uMzUuMjQtLjY5LjQ5LTEsLjc0TDExLjQ4LDEwYTIuNDEsMi40MSwwLDAsMC0zLjQxLDBMNC44MiwxMy4yNWEyLjQxLDIuNDEsMCwwLDAsMCwzLjQxTDYuNiwxOC40NGMtLjM2LjQ3LS43MSwxLTEsMS40NWEzMi41MywzMi41MywwLDEsMCw1OCw4LjQ0WiIgc3R5bGU9ImZpbGw6IHVybCgjYzNiZGI3MTYtYmI3Ny00MzUxLTllOGYtYTUwY2Y3ODEzNDNlKSIvPiAgICAgICAgPHBhdGggZD0iTTU3LjY3LDEyLjk1bDEsMEwzOS45NCwzNC4yOSwzNSwzMC40YTIuNDEsMi40MSwwLDAsMC0zLjI0LjI0TDE2LjU0LDQ2LjcyYTIuNDEsMi40MSwwLDAsMCwuMDksMy40MWgwQTIuNDEsMi40MSwwLDAsMCwyMCw1MGwxMy43LTE0LjQ5LDUsMy45NGEyLjQxLDIuNDEsMCwwLDAsMy4zLS4zMUw2OS41Niw3LjgxbC0xMiwuMzJhMi40MSwyLjQxLDAsMCwwLC4xMyw0LjgyWiIgc3R5bGU9ImZpbGw6IHVybCgjYzk5ODViMWMtYjg3Zi00M2Y1LWFiMzItNWE4ZWZiMzQ1ZDA1KSIvPiAgICAgIDwvZz4gICAgPC9nPiAgPC9nPjwvc3ZnPg==',
334 - 55);
481 +
482 + add_menu_page(
483 + 'HurryTimer',
484 + 'HurryTimer',
485 + apply_filters( 'hurryt_admin_capability', 'edit_posts', 'campaigns_list' ),
486 + 'hurrytimer',
487 + null,
488 + 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cD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C40YTIuNDEsMi40MSwwLDAsMC0zLjI0LjI0TDE2LjU0LDQ2LjcyYTIuNDEsMi40MSwwLDAsMCwuMDksMy40MWgwQTIuNDEsMi40MSwwLDAsMCwyMCw1MGwxMy43LTE0LjQ5LDUsMy45NGEyLjQxLDIuNDEsMCwwLDAsMy4zLS4zMUw2OS41Niw3LjgxbC0xMiwuMzJhMi40MSwyLjQxLDAsMCwwLC4xMyw0LjgyWiIgc3R5bGU9ImZpbGw6IHVybCgjYzk5ODViMWMtYjg3Zi00M2Y1LWFiMzItNWE4ZWZiMzQ1ZDA1KSIvPiAgICAgIDwvZz4gICAgPC9nPiAgPC9nPjwvc3ZnPg=='
489 + );
335 490 add_submenu_page(
336 491 'hurrytimer',
337 - __('Add Campaign', 'hurrytimer'),
338 - __('Add Campaign', 'hurrytimer'),
339 - 'manage_options',
492 + __( 'Add Campaign', 'hurrytimer' ),
493 + __( 'Add Campaign', 'hurrytimer' ),
494 + apply_filters( 'hurryt_admin_capability', 'edit_posts', 'add_campaign' ),
340 495 'post-new.php?post_type=hurrytimer_countdown'
341 496 );
497 +
498 + add_submenu_page(
499 + 'hurrytimer',
500 + __( 'Settings', 'hurrytimer' ),
501 + __( 'Settings', 'hurrytimer' ),
502 + apply_filters( 'hurryt_admin_capability', 'manage_options', 'settings' ),
503 + 'hurrytimer_settings',
504 + [ $this, 'settings' ]
505 + );
506 +
507 + }
508 +
509 + public function settings()
510 + {
511 + include_once HURRYT_DIR . 'admin/templates/settings.php';
342 512 }
343 513
344 514 public function activateCampaign()
345 515 {
346 516 if (
347 - isset($_GET['hurrytimer_action']) && $_GET['hurrytimer_action'] === "activate-compaign"
348 - && isset($_GET['_wpnonce'])
349 - && wp_verify_nonce($_GET['_wpnonce'], 'activate-compaign')
517 + isset( $_GET[ 'hurrytimer_action' ] )
518 + && $_GET[ 'hurrytimer_action' ] === "activate-compaign"
519 + && isset( $_GET[ '_wpnonce' ] )
520 + && wp_verify_nonce( $_GET[ '_wpnonce' ], 'activate-compaign' )
350 521 ) {
351 - $postId = intval($_GET['post']);
352 - wp_update_post(['ID' => $postId, 'post_status' => 'publish']);
522 + $postId = intval( $_GET[ 'post' ] );
523 + wp_update_post( [ 'ID' => $postId, 'post_status' => 'publish' ] );
353 524 }
354 525 }
355 526
527 + function resetEvergreenCampaignNotice()
528 + {
529 + if (
530 + isset( $_GET[ 'hurryt-action' ] )
531 + && isset( $_GET[ 'hurryt-scope' ] )
532 + && isset( $_GET[ 'post' ] )
533 + && $_GET[ 'hurryt-action' ] === "reset-evergreen-compaign"
534 + && isset( $_GET[ '_wpnonce' ] )
535 + && wp_verify_nonce( $_GET[ '_wpnonce' ], 'reset-evergreen-compaign' )
536 + ) {
537 + $scopeText
538 + = $_GET[ 'hurryt-scope' ] === 'admin'
539 + ? ' you '
540 + : ' all visitors '; ?>
541 + <div class="notice notice-success is-dismissible">
542 + <p><?php _e(
543 + "Campaign has been reset for $scopeText successfully.",
544 + 'hurrytimer'
545 + ); ?></p>
546 + </div>
547 + <?php
548 + }
549 + }
550 +
551 + function resetAllEvergreenCampaignNotice()
552 + {
553 + if (
554 + isset( $_GET[ 'hurryt-page' ] )
555 + && isset( $_GET[ 'hurryt-scope' ] )
556 + && isset( $_GET[ 'hurryt-action' ] )
557 + && $_GET[ 'hurryt-page' ] === "hurrytimer_settings"
558 + && $_GET[ 'hurryt-action' ] === "reset-all-evergreen-compaigns"
559 + && isset( $_GET[ '_wpnonce' ] )
560 + && wp_verify_nonce( $_GET[ '_wpnonce' ], 'reset-all-evergreen-compaigns' )
561 + ) {
562 + $scopeText
563 + = $_GET[ 'hurryt-scope' ] === 'admin'
564 + ? ' you '
565 + : ' all visitors '; ?>
566 + <div class="notice notice-success is-dismissible">
567 + <p><?php _e(
568 + "All evergreen campaigns have been reset for $scopeText successfully.",
569 + 'hurrytimer'
570 + ); ?></p>
571 + </div>
572 + <?php
573 + }
574 + }
575 +
576 + public function resetEvergreenCampaign()
577 + {
578 + if (
579 + isset( $_GET[ 'hurryt-action' ] )
580 + && isset( $_GET[ 'hurryt-scope' ] )
581 + && isset( $_GET[ 'post' ] )
582 + && $_GET[ 'hurryt-action' ] === "reset-evergreen-compaign"
583 + && isset( $_GET[ '_wpnonce' ] )
584 + && wp_verify_nonce( $_GET[ '_wpnonce' ], 'reset-evergreen-compaign' )
585 + ) {
586 + $postId = intval( $_GET[ 'post' ] );
587 +
588 + $campaign = new EvergreenCampaign( $postId );
589 + $campaign->reset( sanitize_text_field( $_GET[ 'hurryt-scope' ] ) );
590 + }
591 + }
592 +
593 + public function resetAllEvergreenCampaigns()
594 + {
595 +
596 + if ( isset( $_GET[ 'hurryt-scope' ] )
597 + && isset( $_GET[ 'hurryt-action' ] )
598 + && $_GET[ 'hurryt-action' ] === "reset-all-evergreen-compaigns"
599 + && isset( $_GET[ '_wpnonce' ] )
600 + && wp_verify_nonce( $_GET[ '_wpnonce' ], 'reset-all-evergreen-compaigns' )
601 + ) {
602 + $evergreenCampaign = new EvergreenCampaign();
603 + $evergreenCampaign->resetAll( sanitize_text_field( $_GET[ 'hurryt-scope' ] ) );
604 + }
605 + }
606 +
356 607 public function deactivateCampaign()
357 608 {
358 609 if (
359 - isset($_GET['hurrytimer_action'])
360 - && $_GET['hurrytimer_action'] === "deactivate-compaign"
361 - && isset($_GET['_wpnonce'])
362 - && wp_verify_nonce($_GET['_wpnonce'], 'deactivate-compaign')
610 + isset( $_GET[ 'hurrytimer_action' ] )
611 + && $_GET[ 'hurrytimer_action' ] === "deactivate-compaign"
612 + && isset( $_GET[ '_wpnonce' ] )
613 + && wp_verify_nonce( $_GET[ '_wpnonce' ], 'deactivate-compaign' )
363 614 ) {
364 - $postId = intval($_GET['post']);
365 - wp_update_post(['ID' => $postId, 'post_status' => 'draft']);
615 + $postId = intval( $_GET[ 'post' ] );
616 + wp_update_post( [ 'ID' => $postId, 'post_status' => 'draft' ] );
366 617 }
367 618 }
368 619
369 620 public function settingsBox()
370 621 {
371 - require plugin_dir_path(dirname(__FILE__)) . 'admin/CampaignSettings.php';
622 + require plugin_dir_path( dirname( __FILE__ ) ) .
623 + 'admin/CampaignSettings.php';
372 624 new CampaignSettings();
373 625 }
374 626
375 627 //removeIf(pro)
@@ -376,9 +628,9 @@
376 628 public function upgradeBanner()
377 629 {
378 630 add_meta_box(
379 631 'hurrytimer-upgrade-banner',
380 - __('Get the Most of HurryTimer', 'hurrytimer'),
632 + __( 'Get the Most of HurryTimer', 'hurrytimer' ),
381 633 function () {
382 634 include HURRYT_DIR . 'admin/templates/upgrade-banner.php';
383 635 },
384 636 HURRYT_POST_TYPE,
@@ -387,9 +639,8 @@
387 639 );
388 640 }
389 641 //endRemoveIf(pro)
390 642
391 -
392 643 /**
393 644 * Search products
394 645 *
395 646 * @return void
@@ -395,17 +646,17 @@
395 646 * @return void
396 647 */
397 648 public function ajaxWcSearchProducts()
398 649 {
399 - $search = sanitize_text_field($_GET['search']);
400 - $selection = sanitize_text_field($_GET['productsSelection']);
401 - $exclude = array_map('intval', $_GET['exclude']);
650 + $search = sanitize_text_field( $_GET[ 'search' ] );
651 + $selection = sanitize_text_field( $_GET[ 'productsSelection' ] );
652 + $exclude = array_map( 'intval', $_GET[ 'exclude' ] );
402 653
403 654 if (
404 - in_array($selection, [
655 + in_array( $selection, [
405 656 C::WC_PS_TYPE_INCLUDE_CATEGORIES,
406 657 C::WC_PS_TYPE_EXCLUDE_CATEGORIES,
407 - ])
658 + ] )
408 659 ) {
409 660 $args = [
410 661 "hide_empty" => false,
411 662 "taxonomy" => "product_cat",
@@ -412,28 +663,94 @@
412 663 "name__like" => $search,
413 664 'exclude' => $exclude,
414 665 ];
415 666
416 - $items = get_terms($args);
417 - $results = array_map(function ($item) {
667 + $items = get_terms( $args );
668 + $results = array_map( function ( $item ) {
418 669 return [
419 670 "id" => $item->term_id,
420 671 "text" => $item->name,
421 672 ];
422 - }, $items);
673 + }, $items );
423 674 } else {
424 675 $args = [
425 - 's' => $search,
426 - 'post_type' => 'product',
427 - 'post__not_in' => $exclude,
676 + 's' => $search,
677 + 'post_type' => 'product',
678 + 'post__not_in' => $exclude,
679 + 'post_status' => 'any',
680 + 'posts_per_page' => -1
428 681 ];
429 - $items = get_posts($args);
430 - $results = array_map(function ($item) {
682 + $items = get_posts( $args );
683 + $results = array_map( function ( $item ) {
431 684 return [
432 685 "id" => $item->ID,
433 686 "text" => $item->post_title,
434 687 ];
435 - }, $items);
688 + }, $items );
436 689 }
437 - exit(json_encode(["results" => $results, "pagination" => true]));
690 + exit( json_encode( [ "results" => $results, "pagination" => true ] ) );
691 + }
692 +
693 + public function pluginSettings()
694 + {
695 + register_setting( 'hurrytimer_settings', 'hurryt_settings' );
696 + add_settings_section(
697 + 'hurryt_settings_general',
698 + __( 'General', 'hurrytimer' ),
699 + null,
700 + 'hurrytimer_settings'
701 + );
702 + add_settings_field(
703 + 'hurryt_disable_actions_edit_mode',
704 + 'Disable actions in the admin area',
705 + function ( $args ) {
706 + $options = get_option( 'hurryt_settings' ); ?>
707 + <label for="">
708 + <input type="checkbox"
709 + name="hurryt_settings[disable_actions]" <?php checked(
710 + isset( $options[ 'disable_actions' ] )
711 + && $options[ 'disable_actions' ],
712 + 1
713 + ); ?> id="hurryt-disable-actions" value="1"/>
714 + </label>
715 + <p class="description">
716 + Don't run actions when editing or previewing a page in the admin area.
717 + </p>
718 + <?php
719 + },
720 + 'hurrytimer_settings',
721 + 'hurryt_settings_general'
722 + );
723 + }
724 +
725 + function ajaxAddWcConditionGroup()
726 + {
727 + check_ajax_referer( 'hurryt-admin', 'nonce' );
728 +
729 + ob_start();
730 + include HURRYT_DIR . 'admin/templates/wc-condition-group.php';
731 + echo ob_get_clean();
732 + wp_die();
733 + }
734 +
735 + function ajaxAddWcCondition()
736 + {
737 + check_ajax_referer( 'hurryt-admin', 'nonce' );
738 +
739 + ob_start();
740 + $groupId = sanitize_key( $_GET[ 'group_id' ] );
741 + include HURRYT_DIR . 'admin/templates/wc-condition.php';
742 + echo ob_get_clean();
743 + wp_die();
744 + }
745 +
746 + function ajaxLoadWcCondition()
747 + {
748 + check_ajax_referer( 'hurryt-admin', 'nonce' );
749 + ob_start();
750 + $groupId = sanitize_key( $_GET[ 'group_id' ] );
751 + $selected = hurryt_wc_conditions()[ sanitize_key( $_GET[ 'condition_key' ] ) ];
752 + include HURRYT_DIR . 'admin/templates/wc-condition.php';
753 + echo ob_get_clean();
754 + wp_die();
438 755 }
439 756 }