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 +513 -186 2.0.22.6.2 View file →
@@ -1,8 +1,11 @@
1 1 <?php
2 2
3 3 namespace Hurrytimer;
4 -use \Hurrytimer\Utils\Helpers;
4 +
5 +use DateTime;
6 +use Hurrytimer\CSS_Builder;
7 +
5 8 class Admin
6 9 {
7 10 /**
8 11 * The ID of this plugin.
@@ -24,73 +27,215 @@
24 27
25 28 /**
26 29 * Initialize the class and set its properties.
27 30 *
31 + * @param string $pluginName The name of this plugin.
32 + * @param string $version The version of this plugin.
33 + *
28 34 * @since 1.0.0
29 35 *
30 - * @param string $pluginName The name of this plugin.
31 - * @param string $version The version of this plugin.
32 36 */
33 - public function __construct($pluginName, $version)
37 + public function __construct( $pluginName, $version )
34 38 {
35 -
36 39 $this->pluginName = $pluginName;
37 40 $this->version = $version;
38 - add_action('wp_ajax_wcSearchProducts', [$this, 'ajaxWcSearchProducts']);
39 - add_action('admin_init', [$this, 'activateCampaign']);
40 - add_action('admin_init', [$this, 'deactivateCampaign']);
41 - add_filter('post_row_actions', [$this, 'campaignsListRowActions']);
42 - add_action('admin_menu', [$this, 'menu']);
43 - add_filter('bulk_actions-edit-' . HURRYT_POST_TYPE,
44 - [$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', ] );
45 57
46 - add_filter('manage_' . HURRYT_POST_TYPE . '_posts_columns',
47 - [$this, 'campaignsListColumns']);
58 + add_filter( 'manage_' . HURRYT_POST_TYPE . '_posts_columns',
59 + [ $this, 'campaignsListColumns', ] );
48 60
49 - add_action('manage_' . HURRYT_POST_TYPE . '_posts_custom_column',
50 - [$this, 'countdownListColumnsContent'], 10, 2);
51 61
52 - add_action('views_edit-' . HURRYT_POST_TYPE,
53 - [$this, 'countdown_list_header_links'], 10);
54 - add_filter(
55 - 'bulk_post_updated_messages',
56 - [$this, 'customBulkPostUpdatedMessages'], 10, 2);
62 + add_action( 'manage_' . HURRYT_POST_TYPE . '_posts_custom_column',
63 + [ $this, 'countdownListColumnsContent' ], 10, 2 );
57 64
58 - add_action('admin_menu', [$this, 'helpTabs']);
59 - add_action('admin_notices', [$this, 'countdown_activation_notice']);
60 - add_filter('admin_footer_text', [$this, 'admin_footer_text']);
61 - // @removeIf(pro)
62 - add_filter('plugin_action_links_' . HURRYT_BASENAME, [$this, 'pluginLinks']);
63 - // @endRemoveIf(pro)
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 +
78 + //removeIf(pro)
79 + add_action( 'admin_notices', [ $this, 'leave_review_notice' ] );
80 + //endRemoveIf(pro)
81 +
82 + add_action( 'wp_ajax_hurryt_dismiss_headline_moved_notice', [ $this, 'dismiss_headline_moved_notice' ] );
83 +
64 84 }
65 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 + }
66 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 +
67 195 public function admin_footer_text()
68 196 {
69 197 $screen = get_current_screen();
70 - if ($screen->post_type === HURRYT_POST_TYPE) {
198 + if ( $screen->post_type === HURRYT_POST_TYPE ) {
71 199 include HURRYT_DIR . 'admin/templates/footer-rate-plugin.php';
72 200 }
73 201 }
74 - // @removeIf(pro)
75 - function pluginLinks($links){
76 - $links[] = '<a href="https://hurrytimer.com/pricing" target="_blank">PREMIUM</a>';
202 +
203 + public function set_plugin_action_links( $links )
204 + {
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;
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 +
77 222 return $links;
78 223 }
79 - // @endRemoveIf(pro)
80 224
225 +
81 226 public function countdown_activation_notice()
82 227 {
83 - $post_id = filter_input(INPUT_GET, 'post', FILTER_VALIDATE_INT);
84 - $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' );
85 230
86 - if ( ! $post_id || ! $status || ! ($post = get_post($post_id))) {
231 + if ( !$post_id || !$status || !( $post = get_post( $post_id ) ) ) {
87 232 return;
88 233 }
89 234 if (
90 - $status === "ctivate-compaign"
235 + $status === "activate-compaign"
91 236 &&
92 - ! Utils\Helpers::isPostActive($post_id)
237 + !Utils\Helpers::isPostActive( $post_id )
93 238 ) { ?>
94 239 <div class="notice notice-success is-dismissible">
95 240 <p><?php _e(
96 241 'Countdown timer deactivated.',
@@ -98,9 +243,9 @@
98 243 ); ?></p>
99 244 </div>
100 245 <?php } else { ?>
101 246 <div class="notice notice-success is-dismissible">
102 - <p><?php _e('Countdown timer activated.', "hurrytimer"); ?></p>
247 + <p><?php _e( 'Countdown timer activated.', "hurrytimer" ); ?></p>
103 248 </div>
104 249 <?php }
105 250 }
106 251
@@ -105,51 +250,49 @@
105 250 }
106 251
107 252 public function helpTabs()
108 253 {
109 - add_action('load-edit.php', [$this, 'editHelpTabs']);
110 - add_action('load-post-new.php', [$this, 'editHelpTabs']);
111 - 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' ] );
112 257 }
113 258
114 259 public function editHelpTabs()
115 260 {
116 261 $screen = get_current_screen();
117 - if (strpos($screen->id, 'hurrytimer_countdown') === false) {
262 + if ( strpos( $screen->id, 'hurrytimer_countdown' ) === false ) {
118 263 return;
119 264 }
120 265 $screen->remove_help_tabs();
121 266 }
122 267
123 - public function customBulkPostUpdatedMessages(
124 - $bulk_messages,
125 - $bulk_counts
126 - ) {
127 - $bulk_messages[HURRYT_POST_TYPE] = [
268 + public function customBulkPostUpdatedMessages( $bulk_messages, $bulk_counts )
269 + {
270 + $bulk_messages[ HURRYT_POST_TYPE ] = [
128 271 'updated' => _n(
129 272 '%s countdown timer updated.',
130 273 '%s countdown timers updated.',
131 - $bulk_counts['updated']
274 + $bulk_counts[ 'updated' ]
132 275 ),
133 276 'locked' => _n(
134 277 '%s countdown timer not updated, somebody is editing it.',
135 278 '%s countdown timers not updated, somebody is editing them.',
136 - $bulk_counts['locked']
279 + $bulk_counts[ 'locked' ]
137 280 ),
138 281 'deleted' => _n(
139 282 '%s countdown timer permanently deleted.',
140 283 '%s countdown timers permanently deleted.',
141 - $bulk_counts['deleted']
284 + $bulk_counts[ 'deleted' ]
142 285 ),
143 286 'trashed' => _n(
144 287 '%s countdown timer deleted.',
145 288 '%s countdown timers deleted.',
146 - $bulk_counts['trashed']
289 + $bulk_counts[ 'trashed' ]
147 290 ),
148 291 'untrashed' => _n(
149 292 '%s countdown timer restored from the Trash.',
150 293 '%s countdown timers restored from the Trash.',
151 - $bulk_counts['untrashed']
294 + $bulk_counts[ 'untrashed' ]
152 295 ),
153 296 ];
154 297
155 298 return $bulk_messages;
@@ -154,62 +297,61 @@
154 297
155 298 return $bulk_messages;
156 299 }
157 300
158 - public function countdown_list_header_links($views)
301 + public function countdownListColumnsContent( $column, $post_id )
159 302 {
160 - unset($views['trash']);
161 -
162 - return $views;
163 - }
164 -
165 - public function countdownListColumnsContent($column, $post_id)
166 - {
167 - $campaign = new Campaign($post_id);
168 - switch ($column) {
303 + $campaign = new Campaign( $post_id );
304 + switch ( $column ) {
169 305 case 'status':
170 - echo $campaign->isPublished()
171 - ? __('Active', "hurrytimer")
172 - : __('Inactive', "hurrytimer");
306 + echo $campaign->is_published()
307 + ? __( 'Active', "hurrytimer" )
308 + : __( 'Inactive', "hurrytimer" );
173 309 break;
174 310 case 'mode':
175 - echo $campaign->isEvergreen()
176 - ? __('Evergreen', "hurrytimer")
177 - : __('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 + }
178 320 break;
179 - case 'CampaignShortcode':
180 - echo '<pre class="htmr-list-shortcode">[hurrytimer id="' .
181 - $post_id .
182 - '"]</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 +
183 326 break;
184 327 }
185 328 }
186 329
187 - public function campaignsListBulkActions($actions)
330 + public function campaignsListBulkActions( $actions )
188 331 {
189 - unset($actions['edit']);
190 -
332 + unset( $actions[ 'edit' ] );
191 333 return $actions;
192 334 }
193 335
194 - public function campaignsListColumns($columns)
336 + public function campaignsListColumns( $columns )
195 337 {
196 338 $allowed_columns = [];
197 - foreach ($columns as $column_name => $value) {
198 - if (in_array($column_name, ['cb', 'title', 'date'])) {
199 - $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;
200 342 }
201 343 }
202 344
203 345 $columns = $allowed_columns;
204 - $date = $columns['date'];
205 - unset($columns['date']);
206 - $columns = array_merge($columns, [
207 - 'status' => __('Status', "hurrytimer"),
208 - 'mode' => __('Mode', "hurrytimer"),
209 - 'CampaignShortcode' => __('CampaignShortcode', "hurrytimer"),
210 - ]);
211 - $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;
212 354
213 355 return $columns;
214 356 }
215 357
@@ -219,44 +361,51 @@
219 361 * @since 1.0.0
220 362 */
221 363 public function enqueueStyles()
222 364 {
223 - wp_enqueue_style('wp-color-picker');
224 - wp_enqueue_style('iris');
225 - wp_dequeue_style('select2');
365 + $version = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : $this->version;
226 366
227 - wp_enqueue_style("codemirror",
228 - HURRYT_URL . 'assets/css/codemirror.css', [], "5.42.2",
229 - 'all');
230 - wp_enqueue_style(
231 - 'hurryt-select2',
232 - HURRYT_URL . 'assets/css/select2.css', array(),
233 - '4.0.5', 'all'
234 - );
367 + wp_enqueue_style( 'wp-color-picker' );
368 + wp_dequeue_style( 'select2' );
235 369
236 - wp_enqueue_style(
237 - 'hurryt-base-css',
238 - HURRYT_URL . 'assets/css/base.css', array(),
239 - $this->version, 'all'
240 - );
241 -
242 - wp_enqueue_style($this->pluginName,
243 - HURRYT_URL . 'assets/css/admin.css', ['hurryt-base-css', 'hurryt-select2'],
244 - $this->version, 'all');
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(
378 + 'hurryt-select2',
379 + HURRYT_URL . 'assets/css/select2.css',
380 + array(),
381 + '4.0.5',
382 + 'all'
383 + );
384 +
385 + wp_enqueue_style(
386 + 'hurryt-base-css',
387 + HURRYT_URL . 'assets/css/main.css',
388 + array(),
389 + $version,
390 + 'all'
391 + );
392 +
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 + );
245 400 }
246 401
247 - public function campaignsListRowActions($actions)
402 + public function campaignsListRowActions( $actions )
248 403 {
249 404 global $post;
250 - if ($post->post_type === HURRYT_POST_TYPE) {
251 - unset($actions['inline hide-if-no-js']);
252 - unset($actions['trash']);
405 + if ( $post->post_type === HURRYT_POST_TYPE ) {
406 + unset( $actions[ 'inline hide-if-no-js' ] );
253 407 }
254 - $actions['delete'] = '<a href="' .
255 - get_delete_post_link($post->ID) .
256 - '">' .
257 - __('Delete', "hurrytimer") .
258 - '</a>';
259 408
260 409 return $actions;
261 410 }
262 411
@@ -266,100 +415,213 @@
266 415 * @since 1.0.0
267 416 */
268 417 public function enqueueScripts()
269 418 {
270 - wp_enqueue_script('jquery-ui-core');
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' );
271 424
272 - wp_enqueue_script('wp-color-picker');
273 - wp_enqueue_script('iris');
274 - wp_enqueue_script('jquery-ui-slider');
275 - wp_dequeue_script('select2');
276 - //removeIf(pro)
277 425 wp_enqueue_script(
278 - "jq-modal",
279 - HURRYT_URL . 'assets/js/jquery.modal.min.js',
280 - ['jquery'],
281 - "0.9.1",
282 - true);
283 - //endRemoveIf(pro)
284 -
426 + 'hurryt-cookie',
427 + HURRYT_URL . 'assets/js/cookie.min.js',
428 + [],
429 + '2.2.0',
430 + true
431 + );
432 +
285 433 wp_enqueue_script(
286 434 'jq-date-picker-addon',
287 435 HURRYT_URL . 'assets/js/timepicker-addon.js',
288 - ['jquery-ui-datepicker'],
289 - '1.6.3',
290 - true);
436 + [ 'jquery-ui-datepicker' ],
437 + '1.6.3',
438 + true
439 + );
291 440
292 - wp_enqueue_script(
293 - 'hurryt-select2',
294 - HURRYT_URL . 'assets/js/select2.min.js',
295 - ['jquery'],
296 - '4.0.5',
297 - true);
441 + wp_enqueue_script(
442 + 'hurryt-select2',
443 + HURRYT_URL . 'assets/js/select2.min.js',
444 + [ 'jquery' ],
445 + '4.0.5',
446 + true
447 + );
298 448
299 - $deps = ['jq-date-picker-addon', 'hurryt-select2'];
449 + $deps = [ 'wp-color-picker', 'hurryt-cookie', 'jq-date-picker-addon', 'hurryt-select2' ];
300 450
451 + $version = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : $this->version;
452 +
301 453 wp_enqueue_script(
302 454 $this->pluginName,
303 455 HURRYT_URL . 'assets/js/admin.js',
304 456 $deps,
305 - $this->version,
306 - true);
457 + $version,
458 + true
459 + );
307 460
308 - wp_localize_script($this->pluginName, 'hurrytimer_ajax_object',
309 - array(
310 - 'ajax_url' => admin_url('admin-ajax.php'),
311 - 'headline_pos' => [
312 - 'above_timer' => C::HEADLINE_POSITION_ABOVE_TIMER,
313 - 'below_timer' => C::HEADLINE_POSITION_BELOW_TIMER,
314 - ],
315 - 'mode' => [
316 - 'evergreen' => C::MODE_EVERGREEN,
317 - 'regular' => C::MODE_REGULAR,
318 - ],
319 - ));
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 +
320 477 }
321 478
322 479 public function menu()
323 480 {
324 - add_menu_page('HurryTimer', 'HurryTimer', 'manage_options', 'hurrytimer', null, 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNjkuNTYgNzAuNjIiPiAgPGRlZnM+ICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYzNiZGI3MTYtYmI3Ny00MzUxLTllOGYtYTUwY2Y3ODEzNDNlIiB5MT0iMzUuMzEiIHgyPSI2NS4wNyIgeTI9IjM1LjMxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+ICAgICAgPHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZjg1Mzdm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);
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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNjkuNTYgNzAuNjIiPiAgPGRlZnM+ICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYzNiZGI3MTYtYmI3Ny00MzUxLTllOGYtYTUwY2Y3ODEzNDNlIiB5MT0iMzUuMzEiIHgyPSI2NS4wNyIgeTI9IjM1LjMxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+ICAgICAgPHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZjg1MzdmIi8+ICAgICAgPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNjNjIi8+ICAgIDwvbGluZWFyR3JhZGllbnQ+ICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYzk5ODViMWMtYjg3Zi00M2Y1LWFiMzItNWE4ZWZiMzQ1ZDA1IiB4MT0iMTUuODgiIHkxPSIyOS4zIiB4Mj0iNjkuNTYiIHkyPSIyOS4zIiB4bGluazpocmVmPSIjYzNiZGI3MTYtYmI3Ny00MzUxLTllOGYtYTUwY2Y3ODEzNDNlIi8+ICA8L2RlZnM+ICA8dGl0bGU+QXNzZXQgMzwvdGl0bGU+ICA8ZyBpZD0iMGIwNjBiYzEtNGVlNS00YjUwLTkxMjctYTFjZWRmNGYxZDljIiBkYXRhLW5hbWU9IkxheWVyIDIiPiAgICA8ZyBpZD0iNmRiZGQyZWItOWY5My00YWMwLWE3YTQtYjE0ODY1MDQyYzNiIiBkYXRhLW5hbWU9IkxheWVyIDEiPiAgICAgIDxnPiAgICAgICAg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WiIgc3R5bGU9ImZpbGw6IHVybCgjYzNiZGI3MTYtYmI3Ny00MzUxLTllOGYtYTUwY2Y3ODEzNDNlKSIvPiAgICAgICAgPHBhdGggZD0iTTU3LjY3LDEyLjk1bDEsMEwzOS45NCwzNC4yOSwzNSwzMC40YTIuNDEsMi40MSwwLDAsMC0zLjI0LjI0TDE2LjU0LDQ2LjcyYTIuNDEsMi40MSwwLDAsMCwuMDksMy40MWgwQTIuNDEsMi40MSwwLDAsMCwyMCw1MGwxMy43LTE0LjQ5LDUsMy45NGEyLjQxLDIuNDEsMCwwLDAsMy4zLS4zMUw2OS41Niw3LjgxbC0xMiwuMzJhMi40MSwyLjQxLDAsMCwwLC4xMyw0LjgyWiIgc3R5bGU9ImZpbGw6IHVybCgjYzk5ODViMWMtYjg3Zi00M2Y1LWFiMzItNWE4ZWZiMzQ1ZDA1KSIvPiAgICAgIDwvZz4gICAgPC9nPiAgPC9nPjwvc3ZnPg=='
489 + );
325 490 add_submenu_page(
326 491 'hurrytimer',
327 - __('Add Campaign', 'hurrytimer'),
328 - __('Add Campaign', 'hurrytimer'),
329 - 'manage_options',
492 + __( 'Add Campaign', 'hurrytimer' ),
493 + __( 'Add Campaign', 'hurrytimer' ),
494 + apply_filters( 'hurryt_admin_capability', 'edit_posts', 'add_campaign' ),
330 495 'post-new.php?post_type=hurrytimer_countdown'
331 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 +
332 507 }
333 508
509 + public function settings()
510 + {
511 + include_once HURRYT_DIR . 'admin/templates/settings.php';
512 + }
513 +
334 514 public function activateCampaign()
335 515 {
336 516 if (
337 - isset($_GET['hurrytimer_action']) && $_GET['hurrytimer_action'] === "activate-compaign"
338 - && isset($_GET['_wpnonce'])
339 - && 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' )
340 521 ) {
341 - $postId = intval($_GET['post']);
342 - wp_update_post(['ID' => $postId, 'post_status' => 'publish']);
522 + $postId = intval( $_GET[ 'post' ] );
523 + wp_update_post( [ 'ID' => $postId, 'post_status' => 'publish' ] );
343 524 }
344 525 }
345 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 +
346 607 public function deactivateCampaign()
347 608 {
348 609 if (
349 - isset($_GET['hurrytimer_action'])
350 - && $_GET['hurrytimer_action'] === "deactivate-compaign"
351 - && isset($_GET['_wpnonce'])
352 - && 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' )
353 614 ) {
354 - $postId = intval($_GET['post']);
355 - wp_update_post(['ID' => $postId, 'post_status' => 'draft']);
615 + $postId = intval( $_GET[ 'post' ] );
616 + wp_update_post( [ 'ID' => $postId, 'post_status' => 'draft' ] );
356 617 }
357 618 }
358 619
359 620 public function settingsBox()
360 621 {
361 - require plugin_dir_path(dirname(__FILE__)) . 'admin/CampaignSettings.php';
622 + require plugin_dir_path( dirname( __FILE__ ) ) .
623 + 'admin/CampaignSettings.php';
362 624 new CampaignSettings();
363 625 }
364 626
365 627 //removeIf(pro)
@@ -366,9 +628,9 @@
366 628 public function upgradeBanner()
367 629 {
368 630 add_meta_box(
369 631 'hurrytimer-upgrade-banner',
370 - __('Get the most of Hurrytimer', 'hurrytimer'),
632 + __( 'Get the Most of HurryTimer', 'hurrytimer' ),
371 633 function () {
372 634 include HURRYT_DIR . 'admin/templates/upgrade-banner.php';
373 635 },
374 636 HURRYT_POST_TYPE,
@@ -377,9 +639,8 @@
377 639 );
378 640 }
379 641 //endRemoveIf(pro)
380 642
381 -
382 643 /**
383 644 * Search products
384 645 *
385 646 * @return void
@@ -385,17 +646,17 @@
385 646 * @return void
386 647 */
387 648 public function ajaxWcSearchProducts()
388 649 {
389 - $search = sanitize_text_field($_GET['search']);
390 - $selection = sanitize_text_field($_GET['productsSelection']);
391 - $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' ] );
392 653
393 654 if (
394 - in_array($selection, [
655 + in_array( $selection, [
395 656 C::WC_PS_TYPE_INCLUDE_CATEGORIES,
396 657 C::WC_PS_TYPE_EXCLUDE_CATEGORIES,
397 - ])
658 + ] )
398 659 ) {
399 660 $args = [
400 661 "hide_empty" => false,
401 662 "taxonomy" => "product_cat",
@@ -402,28 +663,94 @@
402 663 "name__like" => $search,
403 664 'exclude' => $exclude,
404 665 ];
405 666
406 - $items = get_terms($args);
407 - $results = array_map(function ($item) {
667 + $items = get_terms( $args );
668 + $results = array_map( function ( $item ) {
408 669 return [
409 670 "id" => $item->term_id,
410 671 "text" => $item->name,
411 672 ];
412 - }, $items);
673 + }, $items );
413 674 } else {
414 675 $args = [
415 - 's' => $search,
416 - 'post_type' => 'product',
417 - '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
418 681 ];
419 - $items = get_posts($args);
420 - $results = array_map(function ($item) {
682 + $items = get_posts( $args );
683 + $results = array_map( function ( $item ) {
421 684 return [
422 685 "id" => $item->ID,
423 686 "text" => $item->post_title,
424 687 ];
425 - }, $items);
688 + }, $items );
426 689 }
427 - 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();
428 755 }
429 756 }