PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 2.2.16
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v2.2.16
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 | admin/CampaignSettings.php +44 -62 2.1.32.2.16 View file →
@@ -46,52 +46,13 @@
46 46
47 47 // Campaign settings metabox.
48 48 add_filter('add_meta_boxes', [$this, 'add_settings_metabox_template'], 10);
49 49
50 - add_filter('after_delete_post', [$this, 'maybe_delete_running_countdown'], 10);
51 -
52 50 add_action("updated_post_meta", [$this, 'maybe_reset_running_countdown'], 10, 4);
53 -
54 - // Skip trash
55 - add_action("trashed_post", [$this, 'skip_trash']);
56 -
57 - // Edit delete link text.
58 - add_action('post_submitbox_start', [$this, 'delete_permanently_link']);
59 51 }
60 52
61 - public function delete_permanently_link($post)
62 - {
63 - if ($post->post_type !== HURRYT_POST_TYPE) {
64 - return;
65 - }
66 - ?>
67 53
68 - <div id="delete-action" class="is-delete-permanently">
69 - <?php if (current_user_can("delete_post", $post->ID)) {
70 - $delete_text = __('Delete', "hurrytimer"); ?>
71 - <a class="submitdelete deletion" href="<?php echo get_delete_post_link(
72 - $post->ID
73 - ); ?>">
74 - <?php echo $delete_text; ?></a>
75 - <?php
76 - } ?>
77 - </div>
78 - <?php
79 - }
80 -
81 54 /**
82 - * Skip trash when deleting.
83 - *
84 - * @param int $post_id
85 - *
86 - * @return void
87 - */
88 - public function skip_trash($post_id)
89 - {
90 - wp_delete_post($post_id, true);
91 - }
92 -
93 - /**
94 55 * Edit notices messages.
95 56 *
96 57 * @param array $messages
97 58 *
@@ -101,18 +62,18 @@
101 62 {
102 63 global $post;
103 64 global $post_id;
104 65 $messages[HURRYT_POST_TYPE] = array(
105 - 0 => '',
106 - 1 => __('Campaign updated', "hurrytimer"),
107 - 2 => '',
108 - 3 => '',
109 - 4 => __('Campaign updated.', "hurrytimer"),
110 - 5 => '',
111 - 6 => __('Campaign published', "hurrytimer"),
112 - 7 => __('Campaign saved.', "hurrytimer"),
113 - 8 => __('Campaign submitted.', "hurrytimer"),
114 - 9 => sprintf(
66 + 0 => '',
67 + 1 => __('Campaign updated', "hurrytimer"),
68 + 2 => '',
69 + 3 => '',
70 + 4 => __('Campaign updated.', "hurrytimer"),
71 + 5 => '',
72 + 6 => __('Campaign published', "hurrytimer"),
73 + 7 => __('Campaign saved.', "hurrytimer"),
74 + 8 => __('Campaign submitted.', "hurrytimer"),
75 + 9 => sprintf(
115 76 __(
116 77 'Campaign scheduled for: <strong>%1$s</strong>.',
117 78 "hurrytimer"
118 79 ),
@@ -142,9 +103,9 @@
142 103 $object_id,
143 104 $meta_key,
144 105 $meta_value
145 106 ) {
146 - if ( ! in_array($meta_key, ['duration'])) {
107 + if (!in_array($meta_key, ['duration'])) {
147 108 return;
148 109 }
149 110
150 111 // (new EvergreenCampaign($object_id))->reset();
@@ -189,13 +150,12 @@
189 150
190 151 if (Utils\Helpers::isNewPost($post_id)) {
191 152 return;
192 153 }
193 -
194 - $isActive = Utils\Helpers::isPostActive($post_id);
195 - $publich_date = Utils\Helpers::format_date($post->post_date);
154 + $isActive = Utils\Helpers::isPostActive($post_id);
155 + $publich_date = Utils\Helpers::format_date($post->post_date);
196 156 $deactivateUrl = Utils\Helpers::deactivateUrl($post_id);
197 - $activateUrl = Utils\Helpers::activateUrl($post_id);
157 + $activateUrl = Utils\Helpers::activateUrl($post_id);
198 158
199 159 include HURRYT_DIR . '/admin/templates/post-publish-metabox.php';
200 160
201 161 }
@@ -212,9 +172,9 @@
212 172 {
213 173 if (wp_is_post_revision($post_id)) {
214 174 return;
215 175 }
216 - if ( ! current_user_can('edit_post', $post_id)) {
176 + if (!current_user_can('edit_post', $post_id)) {
217 177 return;
218 178 }
219 179 $countdown = new Campaign($post_id);
220 180 $countdown->storeSettings($_POST);
@@ -269,8 +229,10 @@
269 229 {
270 230 global $post_id;
271 231 $campaign = new Campaign($post_id);
272 232 $campaign->loadSettings();
233 + $resetCampaignAllVisitorsUrl = $this->createResetEvergreenCampaign('all');
234 + $resetCampaignCurrentAdminUrl = $this->createResetEvergreenCampaign('admin');
273 235 $products = $this->getWcProductsNames($campaign->wcProductsSelection,
274 236 $campaign->wcProductsSelectionType);
275 237 include HURRYT_DIR . '/admin/templates/campaign-settings.php';
276 238
@@ -275,8 +237,27 @@
275 237 include HURRYT_DIR . '/admin/templates/campaign-settings.php';
276 238
277 239 }
278 240
241 + public function createResetEvergreenCampaign($scope = 'admin')
242 + {
243 + global $post_id;
244 +
245 + return wp_nonce_url(
246 + add_query_arg(
247 + array(
248 + 'hurryt-action' => 'reset-evergreen-compaign',
249 + 'hurryt-scope' => $scope,
250 + 'postid' => $post_id,
251 + 'post' => $post_id,
252 + 'action' => 'edit',
253 + ),
254 + network_admin_url('post.php')
255 + ),
256 + 'reset-evergreen-compaign'
257 + );
258 + }
259 +
279 260 /**
280 261 * @param array $ids
281 262 * @param $selection
282 263 *
@@ -293,16 +274,16 @@
293 274 case C::WC_PS_TYPE_ALL:
294 275 break;
295 276 case C::WC_PS_TYPE_INCLUDE_PRODUCTS:
296 277 case C::WC_PS_TYPE_EXCLUDE_PRODUCTS:
297 - $args = [
278 + $args = [
298 279 'post_type' => 'product',
299 - 'post__in' => $ids,
280 + 'post__in' => $ids,
300 281 ];
301 282 $products = get_posts($args);
302 283 foreach ($products as $product) {
303 284 $result[] = [
304 - 'id' => $product->ID,
285 + 'id' => $product->ID,
305 286 'text' => $product->post_title,
306 287 ];
307 288 }
308 289 break;
@@ -307,12 +288,12 @@
307 288 }
308 289 break;
309 290 case C::WC_PS_TYPE_INCLUDE_CATEGORIES:
310 291 case C::WC_PS_TYPE_EXCLUDE_CATEGORIES:
311 - $ids = array_map('intval', $ids);
292 + $ids = array_map('intval', $ids);
312 293 $args = [
313 - 'taxonomy' => 'product_cat',
314 - 'term_ids' => $ids,
294 + 'taxonomy' => 'product_cat',
295 + 'term_ids' => $ids,
315 296 'hide_empty' => false,
316 297 ];
317 298
318 299 $categories = get_terms($args);
@@ -323,9 +304,9 @@
323 304 return in_array($_category->term_id, $ids);
324 305 });
325 306 foreach ($categories as $category) {
326 307 $result[] = [
327 - 'id' => $category->term_id,
308 + 'id' => $category->term_id,
328 309 'text' => $category->name,
329 310 ];
330 311 }
331 312 break;
@@ -334,5 +315,6 @@
334 315 }
335 316
336 317 return $result;
337 318 }
319 +
338 320 }