Countdown, Coming Soon – Countdown & Clock - Version 1.3.6

Version Description

  • Gutenberg block (new)
  • Html editor countdown button (new)
  • Schedule (new)
  • Backend side improvement
  • Bug fixed
Download this release

Release Info

Developer adamskaat
Plugin Icon 128x128 Countdown, Coming Soon – Countdown & Clock
Version 1.3.6
Comparing to
See all releases

Code changes from version 1.3.5 to 1.3.6

CountdownInit.php CHANGED
@@ -3,76 +3,78 @@ namespace ycd;
3
 
4
  class CountdownInit {
5
 
6
- private static $instance = null;
7
- private $actions;
8
- private $filters;
9
 
10
- private function __construct() {
11
- $this->init();
12
- }
13
 
14
- private function __clone() {
15
- }
16
 
17
- public static function getInstance() {
18
- if(!isset(self::$instance)) {
19
- self::$instance = new self();
20
- }
21
- return self::$instance;
22
- }
23
 
24
- public function init() {
25
- register_activation_hook(YCD_PREFIX, array($this, 'activate'));
26
- $this->includeData();
27
- $this->actions();
28
- $this->filters();
29
- }
30
 
31
- private function includeData() {
32
- if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
33
- require_once YCD_HELPERS_PATH.'CheckerPro.php';
34
- }
35
- require_once YCD_HELPERS_PATH.'HelperFunctions.php';
36
- require_once YCD_HELPERS_PATH.'ScriptsIncluder.php';
37
- require_once YCD_HELPERS_PATH.'MultipleChoiceButton.php';
38
- require_once YCD_HELPERS_PATH.'AdminHelper.php';
39
- require_once YCD_CLASSES_PATH.'Tickbox.php';
40
- require_once YCD_CLASSES_PATH.'YcdWidget.php';
41
- require_once YCD_CLASSES_PATH.'CountdownType.php';
42
- require_once YCD_COUNTDOWNS_PATH.'CountdownModel.php';
43
- if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
44
- require_once YCD_CLASSES_PATH.'Checker.php';
45
- }
46
- require_once YCD_COUNTDOWNS_PATH.'Countdown.php';
47
- require_once YCD_CSS_PATH.'Css.php';
48
- require_once YCD_JS_PATH.'Js.php';
49
- require_once YCD_CLASSES_PATH.'RegisterPostType.php';
50
- if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
51
- require_once YCD_CLASSES_PATH.'IncludeManager.php';
52
- }
53
- require_once YCD_CLASSES_PATH.'Actions.php';
54
- require_once YCD_CLASSES_PATH.'Ajax.php';
 
 
55
  require_once YCD_CLASSES_PATH.'Filters.php';
56
  require_once YCD_CLASSES_PATH.'Installer.php';
57
- if (YCD_PKG_VERSION > YCD_FREE_VERSION) {
58
- require_once YCD_CLASSES_PATH.'Subscription.php';
59
- require_once YCD_CLASSES_PATH.'AjaxPro.php';
60
- require_once YCD_CLASSES_PATH.'ActionsPro.php';
61
- require_once YCD_CLASSES_PATH.'FiltersPro.php';
62
- }
63
- }
64
 
65
- public function actions() {
66
- $this->actions = new Actions();
67
- }
68
 
69
- public function filters() {
70
- $this->filters = new Filters();
71
- }
72
 
73
- public function activate() {
74
- Installer::install();
75
- }
76
  }
77
 
78
  CountdownInit::getInstance();
3
 
4
  class CountdownInit {
5
 
6
+ private static $instance = null;
7
+ private $actions;
8
+ private $filters;
9
 
10
+ private function __construct() {
11
+ $this->init();
12
+ }
13
 
14
+ private function __clone() {
15
+ }
16
 
17
+ public static function getInstance() {
18
+ if(!isset(self::$instance)) {
19
+ self::$instance = new self();
20
+ }
21
+ return self::$instance;
22
+ }
23
 
24
+ public function init() {
25
+ register_activation_hook(YCD_PREFIX, array($this, 'activate'));
26
+ $this->includeData();
27
+ $this->actions();
28
+ $this->filters();
29
+ }
30
 
31
+ private function includeData() {
32
+ if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
33
+ require_once YCD_HELPERS_PATH.'AdminHelperPro.php';
34
+ require_once YCD_HELPERS_PATH.'CheckerPro.php';
35
+ }
36
+ require_once(YCD_HELPERS_PATH.'ShowReviewNotice.php');
37
+ require_once YCD_HELPERS_PATH.'HelperFunctions.php';
38
+ require_once YCD_HELPERS_PATH.'ScriptsIncluder.php';
39
+ require_once YCD_HELPERS_PATH.'MultipleChoiceButton.php';
40
+ require_once YCD_HELPERS_PATH.'AdminHelper.php';
41
+ require_once YCD_CLASSES_PATH.'Tickbox.php';
42
+ require_once YCD_CLASSES_PATH.'YcdWidget.php';
43
+ require_once YCD_CLASSES_PATH.'CountdownType.php';
44
+ require_once YCD_COUNTDOWNS_PATH.'CountdownModel.php';
45
+ if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
46
+ require_once YCD_CLASSES_PATH.'Checker.php';
47
+ }
48
+ require_once YCD_COUNTDOWNS_PATH.'Countdown.php';
49
+ require_once YCD_CSS_PATH.'Css.php';
50
+ require_once YCD_JS_PATH.'Js.php';
51
+ require_once YCD_CLASSES_PATH.'RegisterPostType.php';
52
+ if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
53
+ require_once YCD_CLASSES_PATH.'IncludeManager.php';
54
+ }
55
+ require_once YCD_CLASSES_PATH.'Actions.php';
56
+ require_once YCD_CLASSES_PATH.'Ajax.php';
57
  require_once YCD_CLASSES_PATH.'Filters.php';
58
  require_once YCD_CLASSES_PATH.'Installer.php';
59
+ if (YCD_PKG_VERSION > YCD_FREE_VERSION) {
60
+ require_once YCD_CLASSES_PATH.'Subscription.php';
61
+ require_once YCD_CLASSES_PATH.'AjaxPro.php';
62
+ require_once YCD_CLASSES_PATH.'ActionsPro.php';
63
+ require_once YCD_CLASSES_PATH.'FiltersPro.php';
64
+ }
65
+ }
66
 
67
+ public function actions() {
68
+ $this->actions = new Actions();
69
+ }
70
 
71
+ public function filters() {
72
+ $this->filters = new Filters();
73
+ }
74
 
75
+ public function activate() {
76
+ Installer::install();
77
+ }
78
  }
79
 
80
  CountdownInit::getInstance();
assets/css/admin.css CHANGED
@@ -488,6 +488,6 @@ div.ycd-tabs-text-header > div.ycd-toggle-icon-open {
488
  font-weight: 500 !important;
489
  }
490
 
491
- .select2-container {
492
  width: 100% !important;
493
  }
488
  font-weight: 500 !important;
489
  }
490
 
491
+ .ycd-select-wrapper .select2-container {
492
  width: 100% !important;
493
  }
assets/js/Countdown.js CHANGED
@@ -155,10 +155,73 @@ YcdCountdown.prototype.livePreview = function() {
155
  this.changePadding();
156
  this.changeAlignment();
157
  this.changeNumberStyles();
 
 
 
 
 
158
  };
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  YcdCountdown.prototype.changeDateType = function() {
161
- var types = jQuery('.ycd-date-duration');
162
 
163
  if(!types.length) {
164
  return false;
@@ -558,6 +621,9 @@ YcdCountdown.prototype.addTimeToClock = function(options, countDown) {
558
  var selectedTimezone = options['ycd-circle-time-zone'];
559
  var seconds = this.setCounterTime(val, selectedTimezone);
560
  }
 
 
 
561
  else {
562
  var hours = parseInt(options['ycd-countdown-duration-hours']);
563
  var minutes = parseInt(options['ycd-countdown-duration-minutes']);
155
  this.changePadding();
156
  this.changeAlignment();
157
  this.changeNumberStyles();
158
+
159
+ /* change schedule */
160
+ this.changeScheduleWeekDay();
161
+ this.changeScheduleHour();
162
+ this.changeSchedileTimeZone();
163
  };
164
 
165
+ YcdCountdown.prototype.changeSchedileTimeZone = function() {
166
+ var timeZone = jQuery('.js-ycd-schedule-time-zone');
167
+
168
+ if(!timeZone.length) {
169
+ return false;
170
+ }
171
+ that = this;
172
+ var countdowns = jQuery('.ycd-time-circle');
173
+ timeZone.bind('change', function() {
174
+ var name = jQuery(this).attr('name');
175
+ var val = jQuery('option:selected', this).val();
176
+ var options = countdowns.data('options');
177
+ options[name] = val;
178
+ countdowns.data('options', options);
179
+ countdowns = that.addTimeToClock(options, countdowns);
180
+ jQuery('.ycd-time-circle').TimeCircles().restart();
181
+ });
182
+ }
183
+
184
+ YcdCountdown.prototype.changeScheduleHour = function() {
185
+ var hours = jQuery('.js-datetimepicker-seconds');
186
+
187
+ if(!hours.length) {
188
+ return false;
189
+ }
190
+
191
+ var countdowns = jQuery('.ycd-time-circle');
192
+ hours.bind('change', function() {
193
+ var name = jQuery(this).attr('name');
194
+ var val = jQuery(this).val();
195
+ var options = countdowns.data('options');
196
+ options[name] = val;
197
+ countdowns.data('options', options);
198
+ countdowns = that.addTimeToClock(options, countdowns);
199
+ jQuery('.ycd-time-circle').TimeCircles().restart();
200
+ });
201
+ }
202
+
203
+ YcdCountdown.prototype.changeScheduleWeekDay = function() {
204
+ var weekDay = jQuery('.ycd-date-week-day');
205
+
206
+ if(!weekDay.length) {
207
+ return false;
208
+ }
209
+ that = this;
210
+ var countdowns = jQuery('.ycd-time-circle');
211
+ weekDay.bind('change', function() {
212
+ var name = jQuery(this).attr('name');
213
+ var val = jQuery('option:selected', this).val();
214
+ var options = countdowns.data('options');
215
+ options[name] = val;
216
+ options[jQuery(this).data('week-number-key')] = YcdCountdownProFunctionality.weekDayNumberFromName(val);
217
+ countdowns.data('options', options);
218
+ countdowns = that.addTimeToClock(options, countdowns);
219
+ jQuery('.ycd-time-circle').TimeCircles().restart();
220
+ })
221
+ }
222
+
223
  YcdCountdown.prototype.changeDateType = function() {
224
+ var types = jQuery('.ycd-date-type');
225
 
226
  if(!types.length) {
227
  return false;
621
  var selectedTimezone = options['ycd-circle-time-zone'];
622
  var seconds = this.setCounterTime(val, selectedTimezone);
623
  }
624
+ else if(options['ycd-countdown-date-type'] == 'schedule') {
625
+ var seconds = YcdCountdownProFunctionality.schedule(options);
626
+ }
627
  else {
628
  var hours = parseInt(options['ycd-countdown-duration-hours']);
629
  var minutes = parseInt(options['ycd-countdown-duration-minutes']);
assets/js/Js.php CHANGED
@@ -28,7 +28,24 @@ class Js {
28
  return YCD_COUNTDOWN_POST_TYPE.'_page_'.YCD_COUNTDOWN_NEWSLETTER;
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  public function enqueueStyles($hook) {
 
 
 
 
 
32
  ScriptsIncluder::registerScript('Admin.js');
33
  ScriptsIncluder::localizeScript('Admin.js', 'ycd_admin_localized', array(
34
  'nonce' => wp_create_nonce('ycd_ajax_nonce'),
28
  return YCD_COUNTDOWN_POST_TYPE.'_page_'.YCD_COUNTDOWN_NEWSLETTER;
29
  }
30
 
31
+ private function gutenbergParams() {
32
+ $settings = array(
33
+ 'allCountdowns' => Countdown::shapeIdTitleData(),
34
+ 'title' => __('Countdowns', YCD_TEXT_DOMAIN),
35
+ 'description' => __('This block will help you to add countdown’s shortcode inside the page content', YCD_TEXT_DOMAIN),
36
+ 'logo_classname' => 'sgpb-gutenberg-logo',
37
+ 'coountdown_select' => __('Select countdown', YCD_TEXT_DOMAIN)
38
+ );
39
+
40
+ return $settings;
41
+ }
42
+
43
  public function enqueueStyles($hook) {
44
+ $blockSettings = $this->gutenbergParams();
45
+ ScriptsIncluder::registerScript('WpCountdownBlockMin.js', array('dirUrl' => YCD_COUNTDOWN_ADMIN_JS_URL));
46
+ ScriptsIncluder::localizeScript('WpCountdownBlockMin.js', 'YCD_GUTENBERG_PARAMS', $blockSettings);
47
+ ScriptsIncluder::enqueueScript('WpCountdownBlockMin.js');
48
+
49
  ScriptsIncluder::registerScript('Admin.js');
50
  ScriptsIncluder::localizeScript('Admin.js', 'ycd_admin_localized', array(
51
  'nonce' => wp_create_nonce('ycd_ajax_nonce'),
assets/js/admin/WpCountdownBlock.js ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function WpCountdownBlock() {
2
+
3
+ }
4
+
5
+ WpCountdownBlock.prototype.init = function() {
6
+ if (typeof wp == 'undefined' || typeof wp.element == 'undefined' || typeof wp.blocks == 'undefined' || typeof wp.editor == 'undefined' || typeof wp.components == 'undefined') {
7
+ return false;
8
+ }
9
+ var localizedParams = YCD_GUTENBERG_PARAMS;
10
+
11
+ var __ = wp.i18n;
12
+ var createElement = wp.element.createElement;
13
+ var registerBlockType = wp.blocks.registerBlockType;
14
+ var InspectorControls = wp.editor.InspectorControls;
15
+ var _wp$components = wp.components,
16
+ SelectControl = _wp$components.SelectControl,
17
+ TextareaControl = _wp$components.TextareaControl,
18
+ ToggleControl = _wp$components.ToggleControl,
19
+ PanelBody = _wp$components.PanelBody,
20
+ ServerSideRender = _wp$components.ServerSideRender,
21
+ Placeholder = _wp$components.Placeholder;
22
+
23
+ registerBlockType('countdownbuilder/countdowns', {
24
+ title: localizedParams.title,
25
+ description: localizedParams.description,
26
+ keywords: ['countdown', 'countdowns', 'countdown builder'],
27
+ category: 'widgets',
28
+ icon: 'welcome-widgets-menus',
29
+ attributes: {
30
+ countdownId: {
31
+ type: 'number'
32
+ }
33
+ },
34
+ edit(props) {
35
+ const {
36
+ attributes: {
37
+ countdownId = '',
38
+ displayTitle = false,
39
+ displayDesc = false
40
+ },
41
+ setAttributes
42
+ } = props;
43
+
44
+ const countdownOptions = [];
45
+ let allCountdowns = YCD_GUTENBERG_PARAMS.allCountdowns;
46
+ for(var id in allCountdowns) {
47
+ var currentdownObj = {
48
+ value: id,
49
+ label: allCountdowns[id]
50
+ }
51
+ countdownOptions.push(currentdownObj);
52
+ }
53
+ countdownOptions.unshift({
54
+ value: '',
55
+ label: YCD_GUTENBERG_PARAMS.coountdown_select
56
+ })
57
+ let jsx;
58
+
59
+ function selectCountdown(value) {
60
+ setAttributes({
61
+ countdownId: value
62
+ });
63
+ }
64
+
65
+ function setContent(value) {
66
+ setAttributes({
67
+ content: value
68
+ });
69
+ }
70
+
71
+ function toggleDisplayTitle(value) {
72
+ setAttributes({
73
+ displayTitle: value
74
+ });
75
+ }
76
+
77
+ function toggleDisplayDesc(value) {
78
+ setAttributes({
79
+ displayDesc: value
80
+ });
81
+ }
82
+
83
+ jsx = [
84
+ <InspectorControls key="countdownbuilder-gutenberg-form-selector-inspector-controls">
85
+ <PanelBody title={'countdown builder title'}>
86
+ <SelectControl
87
+ label = {''}
88
+ value = {countdownId}
89
+ options = {countdownOptions}
90
+ onChange = {selectCountdown}
91
+ />
92
+ <ToggleControl
93
+ label = {YCD_GUTENBERG_PARAMS.i18n.show_title}
94
+ checked = {displayTitle}
95
+ onChange = {toggleDisplayTitle}
96
+ />
97
+ <ToggleControl
98
+ label = {YCD_GUTENBERG_PARAMS.i18n.show_description}
99
+ checked = {displayDesc}
100
+ onChange = {toggleDisplayDesc}
101
+ />
102
+ </PanelBody>
103
+ </InspectorControls>
104
+ ];
105
+
106
+ if (countdownId) {
107
+ return '[ycd_countdown id="'+countdownId+'"][/ycd_countdown]';
108
+ }
109
+ else {
110
+ jsx.push(
111
+ <Placeholder
112
+ key="ycd-gutenberg-form-selector-wrap"
113
+ className="ycd-gutenberg-form-selector-wrapper">
114
+ <img class={YCD_GUTENBERG_PARAMS.logo_classname} src={ YCD_GUTENBERG_PARAMS.logo_url }/>
115
+ <SelectControl
116
+ key = "ycd-gutenberg-form-selector-select-control"
117
+ value = {countdownId}
118
+ options = {countdownOptions}
119
+ onChange = {selectCountdown}
120
+ />
121
+ <SelectControl
122
+ key = "ycd-gutenberg-form-selector-select-control"
123
+ onChange = {selectCountdown}
124
+ />
125
+ </Placeholder>
126
+ );
127
+ }
128
+
129
+ return jsx;
130
+ },
131
+ save(props) {
132
+
133
+ return '[ycd_countdown id="'+props.attributes.countdownId+'"][/ycd_countdown]';
134
+ }
135
+ });
136
+ };
137
+
138
+ jQuery(document).ready(function () {
139
+ var block = new WpCountdownBlock();
140
+ block.init();
141
+ });
assets/js/admin/WpCountdownBlockMin.js ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ function WpCountdownBlock() {}
4
+
5
+ WpCountdownBlock.prototype.init = function () {
6
+ if (typeof wp == 'undefined' || typeof wp.element == 'undefined' || typeof wp.blocks == 'undefined' || typeof wp.editor == 'undefined' || typeof wp.components == 'undefined') {
7
+ return false;
8
+ }
9
+ var localizedParams = YCD_GUTENBERG_PARAMS;
10
+
11
+ var __ = wp.i18n;
12
+ var createElement = wp.element.createElement;
13
+ var registerBlockType = wp.blocks.registerBlockType;
14
+ var InspectorControls = wp.editor.InspectorControls;
15
+ var _wp$components = wp.components,
16
+ SelectControl = _wp$components.SelectControl,
17
+ TextareaControl = _wp$components.TextareaControl,
18
+ ToggleControl = _wp$components.ToggleControl,
19
+ PanelBody = _wp$components.PanelBody,
20
+ ServerSideRender = _wp$components.ServerSideRender,
21
+ Placeholder = _wp$components.Placeholder;
22
+
23
+ registerBlockType('countdownbuilder/countdowns', {
24
+ title: localizedParams.title,
25
+ description: localizedParams.description,
26
+ keywords: ['countdown', 'countdowns', 'countdown builder'],
27
+ category: 'widgets',
28
+ icon: 'welcome-widgets-menus',
29
+ attributes: {
30
+ countdownId: {
31
+ type: 'number'
32
+ }
33
+ },
34
+ edit: function edit(props) {
35
+ var _props$attributes = props.attributes,
36
+ _props$attributes$cou = _props$attributes.countdownId,
37
+ countdownId = _props$attributes$cou === undefined ? '' : _props$attributes$cou,
38
+ _props$attributes$dis = _props$attributes.displayTitle,
39
+ displayTitle = _props$attributes$dis === undefined ? false : _props$attributes$dis,
40
+ _props$attributes$dis2 = _props$attributes.displayDesc,
41
+ displayDesc = _props$attributes$dis2 === undefined ? false : _props$attributes$dis2,
42
+ setAttributes = props.setAttributes;
43
+
44
+ const countdownOptions = [];
45
+ let allCountdowns = YCD_GUTENBERG_PARAMS.allCountdowns;
46
+ for(var id in allCountdowns) {
47
+ var currentdownObj = {
48
+ value: id,
49
+ label: allCountdowns[id]
50
+ }
51
+ countdownOptions.push(currentdownObj);
52
+ }
53
+ countdownOptions.unshift({
54
+ value: '',
55
+ label: YCD_GUTENBERG_PARAMS.coountdown_select
56
+ })
57
+ var jsx = void 0;
58
+
59
+ function selectCountdown(value) {
60
+ setAttributes({
61
+ countdownId: value
62
+ });
63
+ }
64
+
65
+ function setContent(value) {
66
+ setAttributes({
67
+ content: value
68
+ });
69
+ }
70
+
71
+ function toggleDisplayTitle(value) {
72
+ setAttributes({
73
+ displayTitle: value
74
+ });
75
+ }
76
+
77
+ function toggleDisplayDesc(value) {
78
+ setAttributes({
79
+ displayDesc: value
80
+ });
81
+ }
82
+
83
+ jsx = [React.createElement(
84
+ InspectorControls,
85
+ { key: 'countdownbuilder-gutenberg-form-selector-inspector-controls' },
86
+ React.createElement(
87
+ PanelBody,
88
+ { title: 'countdown builder title' },
89
+ React.createElement(SelectControl, {
90
+ label: 'Select countdown',
91
+ value: countdownId,
92
+ options: countdownOptions,
93
+ onChange: selectCountdown
94
+ }),
95
+ React.createElement(ToggleControl, {
96
+ label: 'Select countdown',
97
+ checked: displayTitle,
98
+ onChange: toggleDisplayTitle
99
+ }),
100
+ React.createElement(ToggleControl, {
101
+ label: '',
102
+ checked: displayDesc,
103
+ onChange: toggleDisplayDesc
104
+ })
105
+ )
106
+ )];
107
+
108
+ if (countdownId) {
109
+ return '[ycd_countdown id="' + countdownId + '"][/ycd_countdown]';
110
+ } else {
111
+ jsx.push(React.createElement(
112
+ Placeholder,
113
+ {
114
+ key: 'ycd-gutenberg-form-selector-wrap',
115
+ className: 'ycd-gutenberg-form-selector-wrapper' },
116
+ React.createElement('img', { 'class': YCD_GUTENBERG_PARAMS.logo_classname, src: YCD_GUTENBERG_PARAMS.logo_url }),
117
+ React.createElement(SelectControl, {
118
+ key: 'ycd-gutenberg-form-selector-select-control',
119
+ value: countdownId,
120
+ options: countdownOptions,
121
+ onChange: selectCountdown
122
+ }),
123
+ React.createElement(SelectControl, {
124
+ key: 'ycd-gutenberg-form-selector-select-control',
125
+ onChange: selectCountdown
126
+ })
127
+ ));
128
+ }
129
+
130
+ return jsx;
131
+ },
132
+ save: function save(props) {
133
+
134
+ return '[ycd_countdown id="' + props.attributes.countdownId + '"][/ycd_countdown]';
135
+ }
136
+ });
137
+ };
138
+
139
+ jQuery(document).ready(function () {
140
+ var block = new WpCountdownBlock();
141
+ block.init();
142
+ });
assets/js/admin/ycd-tinymce-plugin.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).on('tinymce-editor-setup', function( event, editor ) {
2
+ editor.settings.toolbar1 += ',mybutton';
3
+ editor.addButton( 'mybutton', {
4
+ text: 'Countdowns',
5
+ icon: false,
6
+ onclick: function () {
7
+ jQuery('#ycd-dialog').dialog({
8
+ width: 450,
9
+ modal: true,
10
+ title: "Insert the shortcode",
11
+ dialogClass: "ycd-countdown-builder"
12
+ });
13
+ }
14
+ });
15
+ });
assets/views/generalOptions.php CHANGED
@@ -16,7 +16,7 @@ $dueDate = $this->getOptionValue('ycd-date-time-picker');
16
  <div class="col-md-6">
17
  <label for="ycd-date-time-picker" class="ycd-label-of-input"></label>
18
  </div>
19
- <div class="col-md-3">
20
  <input type="text" id="ycd-date-time-picker" class="form-control ycd-date-time-picker" name="ycd-date-time-picker" value="<?php echo esc_attr($dueDate); ?>">
21
  </div>
22
  </div>
@@ -24,8 +24,10 @@ $dueDate = $this->getOptionValue('ycd-date-time-picker');
24
  <div class="col-md-6">
25
  <label for="ycd-date-time-picker" class="ycd-label-of-input"><?php _e('Time Zone', YCD_TEXT_DOMAIN); ?></label>
26
  </div>
27
- <div class="col-md-3">
 
28
  <?php echo AdminHelper::selectBox($defaultData['time-zone'], esc_attr($this->getOptionValue('ycd-circle-time-zone')), array('name' => 'ycd-circle-time-zone', 'class' => 'js-ycd-select js-circle-time-zone')); ?>
 
29
  </div>
30
  </div>
31
  </div>
@@ -47,6 +49,82 @@ $dueDate = $this->getOptionValue('ycd-date-time-picker');
47
  </div>
48
  </div>
49
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  <div class="row">
51
  <div class="col-md-6">
52
  <label for="ycd-countdown-end-sound" class="ycd-label-of-switch"><?php _e('Timer End Sound', YCD_TEXT_DOMAIN); ?></label>
16
  <div class="col-md-6">
17
  <label for="ycd-date-time-picker" class="ycd-label-of-input"></label>
18
  </div>
19
+ <div class="col-md-6">
20
  <input type="text" id="ycd-date-time-picker" class="form-control ycd-date-time-picker" name="ycd-date-time-picker" value="<?php echo esc_attr($dueDate); ?>">
21
  </div>
22
  </div>
24
  <div class="col-md-6">
25
  <label for="ycd-date-time-picker" class="ycd-label-of-input"><?php _e('Time Zone', YCD_TEXT_DOMAIN); ?></label>
26
  </div>
27
+ <div class="col-md-6">
28
+ <div class="ycd-select-wrapper">
29
  <?php echo AdminHelper::selectBox($defaultData['time-zone'], esc_attr($this->getOptionValue('ycd-circle-time-zone')), array('name' => 'ycd-circle-time-zone', 'class' => 'js-ycd-select js-circle-time-zone')); ?>
30
+ </div>
31
  </div>
32
  </div>
33
  </div>
49
  </div>
50
  </div>
51
  </div>
52
+ <div id="ycd-date-schedule" class="ycd-countdown-show-text ycd-hide">
53
+ <div class="row form-group">
54
+ <div class="col-md-6">
55
+ <label for="ycd-schedule-time-picker" class="ycd-label-of-input"><?php _e('Time Zone', YCD_TEXT_DOMAIN); ?></label>
56
+ </div>
57
+ <div class="col-md-6">
58
+ <div class="ycd-select-wrapper">
59
+ <?php echo AdminHelper::selectBox($defaultData['time-zone'], esc_attr($this->getOptionValue('ycd-schedule-time-zone')), array('name' => 'ycd-schedule-time-zone', 'class' => 'js-ycd-select js-ycd-schedule-time-zone')); ?>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ <div class="row form-group">
64
+ <div class="col-md-6">
65
+ <label><?php _e('Start', YCD_TEXT_DOMAIN); ?></label>
66
+ </div>
67
+ </div>
68
+ <div class="row form-group">
69
+ <div class="col-md-6">
70
+ <label><?php _e('Week day', YCD_TEXT_DOMAIN); ?></label>
71
+ </div>
72
+ <div class="col-md-6">
73
+ <div class="ycd-select-wrapper">
74
+ <?php echo AdminHelper::selectBox(
75
+ $defaultData['week-days'],
76
+ esc_attr($this->getOptionValue('ycd-schedule-start-day')),
77
+ array(
78
+ 'name' => 'ycd-schedule-start-day',
79
+ 'data-week-number-key' => 'startDayNumber',
80
+ 'class' => 'js-ycd-select ycd-date-week-day js-ycd-schedule-start-day'
81
+ )); ?>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <div class="row form-group">
86
+ <div class="col-md-6">
87
+ </div>
88
+ <div class="col-md-2">
89
+ <label class="ycd-label-of-input"><?php _e('from', YCD_TEXT_DOMAIN); ?></label>
90
+ </div>
91
+ <div class="col-md-4">
92
+ <input type="text" name="ycd-schedule-start-from" class="form-control js-datetimepicker-seconds" value="<?php echo esc_attr($this->getOptionValue('ycd-schedule-start-from')); ?>" autocomplete="off">
93
+ </div>
94
+ </div>
95
+ <div class="row form-group">
96
+ <div class="col-md-6">
97
+ <label><?php _e('End', YCD_TEXT_DOMAIN); ?></label>
98
+ </div>
99
+ </div>
100
+ <div class="row form-group">
101
+ <div class="col-md-6">
102
+ <label><?php _e('Week day', YCD_TEXT_DOMAIN); ?></label>
103
+ </div>
104
+ <div class="col-md-6">
105
+ <div class="ycd-select-wrapper">
106
+ <?php echo AdminHelper::selectBox($defaultData['week-days'],
107
+ esc_attr($this->getOptionValue('ycd-schedule-end-day')),
108
+ array(
109
+ 'name' => 'ycd-schedule-end-day',
110
+ 'data-week-number-key' => 'endDayNumber',
111
+ 'class' => 'js-ycd-select ycd-date-week-day js-ycd-schedule-end-day'
112
+ )
113
+ ); ?>
114
+ </div>
115
+ </div>
116
+ </div>
117
+ <div class="row form-group">
118
+ <div class="col-md-6">
119
+ </div>
120
+ <div class="col-md-2">
121
+ <label class="ycd-label-of-input"><?php _e('to', YCD_TEXT_DOMAIN); ?></label>
122
+ </div>
123
+ <div class="col-md-4">
124
+ <input type="text" name="ycd-schedule-end-to" class="form-control js-datetimepicker-seconds" value="<?php echo esc_attr($this->getOptionValue('ycd-schedule-end-to')); ?>" autocomplete="off">
125
+ </div>
126
+ </div>
127
+ </div>
128
  <div class="row">
129
  <div class="col-md-6">
130
  <label for="ycd-countdown-end-sound" class="ycd-label-of-switch"><?php _e('Timer End Sound', YCD_TEXT_DOMAIN); ?></label>
classes/Actions.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  namespace ycd;
3
  use \YcdCountdownOptionsConfig;
 
4
 
5
  class Actions {
6
  public $customPostTypeObj;
@@ -25,6 +26,14 @@ class Actions {
25
  add_action('admin_head', array($this, 'adminHead'));
26
  }
27
  add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'));
 
 
 
 
 
 
 
 
28
  }
29
 
30
  public function enqueueScripts() {
@@ -83,9 +92,20 @@ class Actions {
83
  }
84
 
85
  public function postTypeInit() {
 
86
  $this->customPostTypeObj = new RegisterPostType();
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
89
  public function addSubMenu() {
90
  $this->customPostTypeObj->addSubMenu();
91
  }
@@ -167,10 +187,9 @@ class Actions {
167
  echo '<div>Date: Expired</div>';
168
  }
169
  else {
170
- $timezone = $countdownObj->getOptionValue('ycd-circle-time-zone');
171
- $current = new \DateTime('now', new \DateTimeZone($timezone));
172
- $dueDate = $countdownObj->getOptionValue('ycd-date-time-picker');
173
- echo '<div>Expires after '.human_time_diff(strtotime($dueDate), strtotime($current->format('Y-m-d H:i:s'))).'</div>';
174
  }
175
 
176
  }
1
  <?php
2
  namespace ycd;
3
  use \YcdCountdownOptionsConfig;
4
+ use \YcdShowReviewNotice;
5
 
6
  class Actions {
7
  public $customPostTypeObj;
26
  add_action('admin_head', array($this, 'adminHead'));
27
  }
28
  add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'));
29
+ add_filter('mce_external_plugins', array($this, 'editirButton'));
30
+ }
31
+
32
+ public function editirButton( $buttons) {
33
+ new Tickbox(true);
34
+ $buttons['countdownBuilder'] = plugins_url( '/../assets/js/admin/ycd-tinymce-plugin.js',__FILE__ );
35
+
36
+ return $buttons;
37
  }
38
 
39
  public function enqueueScripts() {
92
  }
93
 
94
  public function postTypeInit() {
95
+ $this->revieNotice();
96
  $this->customPostTypeObj = new RegisterPostType();
97
  }
98
 
99
+ private function revieNotice() {
100
+ add_action('admin_notices', array($this, 'showReviewNotice'));
101
+ add_action('network_admin_notices', array($this, 'showReviewNotice'));
102
+ add_action('user_admin_notices', array($this, 'showReviewNotice'));
103
+ }
104
+
105
+ public function showReviewNotice() {
106
+ echo new YcdShowReviewNotice();
107
+ }
108
+
109
  public function addSubMenu() {
110
  $this->customPostTypeObj->addSubMenu();
111
  }
187
  echo '<div>Date: Expired</div>';
188
  }
189
  else {
190
+ $dateString = $countdownObj->getExpireDate();
191
+
192
+ echo '<div>Expires after '.$dateString.'</div>';
 
193
  }
194
 
195
  }
classes/Ajax.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  namespace ycd;
3
  use \YcdCountdownConfig;
 
4
 
5
  class Ajax {
6
 
@@ -11,6 +12,35 @@ class Ajax {
11
  public function init() {
12
  add_action('wp_ajax_ycd-switch', array($this, 'switchCountdown'));
13
  add_action('wp_ajax_ycdSupport', array($this, 'ycdSupport'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
  public function ycdSupport() {
1
  <?php
2
  namespace ycd;
3
  use \YcdCountdownConfig;
4
+ use \DateTime;
5
 
6
  class Ajax {
7
 
12
  public function init() {
13
  add_action('wp_ajax_ycd-switch', array($this, 'switchCountdown'));
14
  add_action('wp_ajax_ycdSupport', array($this, 'ycdSupport'));
15
+
16
+ // review panel
17
+ add_action('wp_ajax_ycd_dont_show_review_notice', array($this, 'dontShowReview'));
18
+ add_action('wp_ajax_ycd_change_review_show_period', array($this, 'changeReviewPeriod'));
19
+ }
20
+
21
+ public function changeReviewPeriod() {
22
+ check_ajax_referer('ycdReviewNotice', 'ajaxNonce');
23
+ $messageType = sanitize_text_field($_POST['messageType']);
24
+
25
+ $timeDate = new DateTime('now');
26
+ $timeDate->modify('+'.YCD_SHOW_REVIEW_PERIOD.' day');
27
+
28
+ $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
29
+ update_option('YcdShowNextTime', $timeNow);
30
+ $usageDays = get_option('YcdUsageDays');
31
+ $usageDays += YCD_SHOW_REVIEW_PERIOD;
32
+ update_option('YcdUsageDays', $usageDays);
33
+
34
+ echo YCD_AJAX_SUCCESS;
35
+ wp_die();
36
+ }
37
+
38
+ public function dontShowReview() {
39
+ check_ajax_referer('ycdReviewNotice', 'ajaxNonce');
40
+ update_option('YcdDontShowReviewNotice', 1);
41
+
42
+ echo YCD_AJAX_SUCCESS;
43
+ wp_die();
44
  }
45
 
46
  public function ycdSupport() {
classes/Filters.php CHANGED
@@ -34,6 +34,9 @@ class Filters {
34
  $defaults['countdownExpireTime']['fields'][3]['label']['name'] .= '<span class="ycd-pro-span">PRO</span>';
35
  $defaults['countdownExpireTime']['fields'][3]['attr']['class'] .= ' ycd-option-wrapper-pro';
36
 
 
 
 
37
  return $defaults;
38
  }
39
 
34
  $defaults['countdownExpireTime']['fields'][3]['label']['name'] .= '<span class="ycd-pro-span">PRO</span>';
35
  $defaults['countdownExpireTime']['fields'][3]['attr']['class'] .= ' ycd-option-wrapper-pro';
36
 
37
+ @$defaults['countdown-date-type']['fields'][2]['label']['name'] .= '<span class="ycd-pro-span">PRO</span>';
38
+ @$defaults['countdown-date-type']['fields'][2]['attr']['class'] .= ' ycd-option-wrapper-pro';
39
+
40
  return $defaults;
41
  }
42
 
classes/Installer.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  namespace ycd;
 
3
 
4
  class Installer {
5
 
@@ -9,6 +10,7 @@ class Installer {
9
  return false;
10
  }
11
 
 
12
  self::deleteCountdowns();
13
  }
14
 
@@ -48,6 +50,7 @@ class Installer {
48
 
49
  public static function install() {
50
  self::createTables();
 
51
 
52
  if(is_multisite() && get_current_blog_id() == 1) {
53
  global $wp_version;
1
  <?php
2
  namespace ycd;
3
+ use \YcdShowReviewNotice;
4
 
5
  class Installer {
6
 
10
  return false;
11
  }
12
 
13
+ YcdShowReviewNotice::deleteInitialDates();
14
  self::deleteCountdowns();
15
  }
16
 
50
 
51
  public static function install() {
52
  self::createTables();
53
+ YcdShowReviewNotice::setInitialDates();
54
 
55
  if(is_multisite() && get_current_blog_id() == 1) {
56
  global $wp_version;
classes/Tickbox.php CHANGED
@@ -2,7 +2,12 @@
2
  namespace ycd;
3
 
4
  class Tickbox {
5
- public function __construct() {
 
 
 
 
 
6
  $this->mediaButton();
7
  add_action( 'admin_footer', array($this, 'ycdAdminTickBox'));
8
  }
@@ -21,7 +26,9 @@ class Tickbox {
21
 
22
  }
23
 
24
- echo $output;
 
 
25
  }
26
 
27
 
@@ -31,7 +38,7 @@ class Tickbox {
31
  // Only run in post/page creation and edit screens
32
  if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) { ?>
33
  <script type="text/javascript">
34
- function insertDownload() {
35
  var id = jQuery('.ycd-countdowns').val();
36
 
37
  // Return early if no download is selected
@@ -78,7 +85,7 @@ class Tickbox {
78
  });
79
  </script>
80
  <?php
81
- $popups = Countdown::getPopupsObj();
82
  $idTitle = Countdown::shapeIdTitleData($popups);
83
  ?>
84
 
@@ -93,7 +100,7 @@ class Tickbox {
93
  <?php endif; ?>
94
  </p>
95
  <p class="submit">
96
- <input type="button" id="edd-insert-download" class="button-primary" value="<?php _e('Insert', YCD_TEXT_DOMAIN)?>" onclick="insertDownload();" />
97
  <a id="edd-cancel-download-insert" class="button-secondary" onclick="jQuery('#ycd-dialog').dialog('close')();"><?php _e( 'Cancel', 'easy-digital-downloads' ); ?></a>
98
  </p>
99
  </div>
2
  namespace ycd;
3
 
4
  class Tickbox {
5
+ private $isEditorButton = false;
6
+
7
+ public function __construct($isEditorButton = false) {
8
+ if (isset($isEditorButton)) {
9
+ $this->isEditorButton = $isEditorButton;
10
+ }
11
  $this->mediaButton();
12
  add_action( 'admin_footer', array($this, 'ycdAdminTickBox'));
13
  }
26
 
27
  }
28
 
29
+ if (!$this->isEditorButton) {
30
+ echo $output;
31
+ }
32
  }
33
 
34
 
38
  // Only run in post/page creation and edit screens
39
  if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) { ?>
40
  <script type="text/javascript">
41
+ function insertCountdownDownload() {
42
  var id = jQuery('.ycd-countdowns').val();
43
 
44
  // Return early if no download is selected
85
  });
86
  </script>
87
  <?php
88
+ $popups = Countdown::getCountdownsObj();
89
  $idTitle = Countdown::shapeIdTitleData($popups);
90
  ?>
91
 
100
  <?php endif; ?>
101
  </p>
102
  <p class="submit">
103
+ <input type="button" id="edd-insert-download" class="button-primary" value="<?php _e('Insert', YCD_TEXT_DOMAIN)?>" onclick="insertCountdownDownload();" />
104
  <a id="edd-cancel-download-insert" class="button-secondary" onclick="jQuery('#ycd-dialog').dialog('close')();"><?php _e( 'Cancel', 'easy-digital-downloads' ); ?></a>
105
  </p>
106
  </div>
classes/YcdWidget.php CHANGED
@@ -12,20 +12,20 @@ class ycd_countdown_widget extends WP_Widget {
12
  // Widget name will appear in UI
13
  __('Countdown Builder', YCD_TEXT_DOMAIN),
14
  // Widget description
15
- array( 'description' => __('Countdown Builder widget', YCD_TEXT_DOMAIN),)
16
  );
17
  }
18
 
19
  // Creating widget front-end
20
- public function widget( $args, $instance ) {
21
  $cdId = (int)@$instance['ycdOption'];
22
 
23
  echo do_shortcode('[ycd_countdown id='.$cdId.']');
24
  }
25
 
26
  // Widget Backend
27
- public function form( $instance ) {
28
- $popups = Countdown::getPopupsObj();
29
  $idTitle = Countdown::shapeIdTitleData($popups);
30
  // Widget admin form
31
  $optionSaved = @$this->get_field_name('ycdOption');
@@ -39,7 +39,7 @@ class ycd_countdown_widget extends WP_Widget {
39
  }
40
 
41
  // Updating widget replacing old instances with new
42
- public function update( $new_instance, $old_instance = array()) {
43
 
44
  $instance = array();
45
 
12
  // Widget name will appear in UI
13
  __('Countdown Builder', YCD_TEXT_DOMAIN),
14
  // Widget description
15
+ array('description' => __('Countdown Builder widget', YCD_TEXT_DOMAIN),)
16
  );
17
  }
18
 
19
  // Creating widget front-end
20
+ public function widget($args, $instance) {
21
  $cdId = (int)@$instance['ycdOption'];
22
 
23
  echo do_shortcode('[ycd_countdown id='.$cdId.']');
24
  }
25
 
26
  // Widget Backend
27
+ public function form($instance) {
28
+ $popups = Countdown::getCountdownsObj();
29
  $idTitle = Countdown::shapeIdTitleData($popups);
30
  // Widget admin form
31
  $optionSaved = @$this->get_field_name('ycdOption');
39
  }
40
 
41
  // Updating widget replacing old instances with new
42
+ public function update($new_instance, $old_instance = array()) {
43
 
44
  $instance = array();
45
 
classes/countdown/CircleCountdown.php CHANGED
@@ -8,6 +8,8 @@ if (YCD_PKG_VERSION > YCD_FREE_VERSION) {
8
  }
9
  class CircleCountdown extends Countdown {
10
 
 
 
11
  public function __construct() {
12
  add_action('add_meta_boxes', array($this, 'mainOptions'));
13
  add_filter('ycdCountdownDefaultOptions', array($this, 'defaultOptions'), 1, 1);
@@ -22,6 +24,8 @@ class CircleCountdown extends Countdown {
22
  $this->includeGeneralScripts();
23
  ScriptsIncluder::registerScript('ycdGoogleFonts.js');
24
  ScriptsIncluder::enqueueScript('ycdGoogleFonts.js');
 
 
25
  ScriptsIncluder::registerScript('Countdown.js');
26
  ScriptsIncluder::enqueueScript('Countdown.js');
27
  ScriptsIncluder::registerScript('TimeCircles.js');
@@ -48,7 +52,9 @@ class CircleCountdown extends Countdown {
48
 
49
  public function prepareOptions() {
50
  $options = array();
51
- $options['ycd-seconds'] = $this->getCircleSeconds();
 
 
52
  $options['ycd-countdown-date-type'] = $this->getOptionValue('ycd-countdown-date-type');
53
  $options['ycd-countdown-duration-hours'] = $this->getOptionValue('ycd-countdown-duration-hours');
54
  $options['ycd-countdown-duration-minutes'] = $this->getOptionValue('ycd-countdown-duration-minutes');
@@ -63,6 +69,17 @@ class CircleCountdown extends Countdown {
63
  $options['use_background'] = $this->getOptionValue('ycd-countdown-background-circle');
64
  $options['ycd-date-time-picker'] = $this->getOptionValue('ycd-date-time-picker');
65
  $options['ycd-circle-time-zone'] = $this->getOptionValue('ycd-circle-time-zone');
 
 
 
 
 
 
 
 
 
 
 
66
  $options['time'] = array(
67
  'Years' => array(
68
  'text' => $this->getOptionValue('ycd-countdown-years-text'),
@@ -142,7 +159,6 @@ class CircleCountdown extends Countdown {
142
  $circleAlignment = $this->getOptionValue('ycd-circle-alignment');
143
  $padding = $this->getOptionValue('ycd-countdown-padding').'px';
144
 
145
-
146
  ob_start();
147
  ?>
148
  <style type="text/css">
8
  }
9
  class CircleCountdown extends Countdown {
10
 
11
+ public $expireSeconds;
12
+ public $datesNumber;
13
  public function __construct() {
14
  add_action('add_meta_boxes', array($this, 'mainOptions'));
15
  add_filter('ycdCountdownDefaultOptions', array($this, 'defaultOptions'), 1, 1);
24
  $this->includeGeneralScripts();
25
  ScriptsIncluder::registerScript('ycdGoogleFonts.js');
26
  ScriptsIncluder::enqueueScript('ycdGoogleFonts.js');
27
+ ScriptsIncluder::registerScript('CountdownProFunctionality.js');
28
+ ScriptsIncluder::enqueueScript('CountdownProFunctionality.js');
29
  ScriptsIncluder::registerScript('Countdown.js');
30
  ScriptsIncluder::enqueueScript('Countdown.js');
31
  ScriptsIncluder::registerScript('TimeCircles.js');
52
 
53
  public function prepareOptions() {
54
  $options = array();
55
+ $modifiedObj = $this->getCircleSeconds();
56
+ $modifiedSavedData = $modifiedObj->datesNumber;
57
+ $options['ycd-seconds'] = $modifiedObj->expireSeconds;
58
  $options['ycd-countdown-date-type'] = $this->getOptionValue('ycd-countdown-date-type');
59
  $options['ycd-countdown-duration-hours'] = $this->getOptionValue('ycd-countdown-duration-hours');
60
  $options['ycd-countdown-duration-minutes'] = $this->getOptionValue('ycd-countdown-duration-minutes');
69
  $options['use_background'] = $this->getOptionValue('ycd-countdown-background-circle');
70
  $options['ycd-date-time-picker'] = $this->getOptionValue('ycd-date-time-picker');
71
  $options['ycd-circle-time-zone'] = $this->getOptionValue('ycd-circle-time-zone');
72
+ $options['ycd-schedule-time-zone'] = $this->getOptionValue('ycd-schedule-time-zone');
73
+ // Day numbers
74
+
75
+ $options['startDay'] = $this->getOptionValue('ycd-schedule-start-day');
76
+ $options['startDayNumber'] = $modifiedSavedData['startDayNumber'];
77
+ $options['endDay'] = $this->getOptionValue('ycd-schedule-end-day');
78
+ $options['endDayNumber'] = $modifiedSavedData['endDayNumber'];
79
+ $options['currentDayNumber'] = $modifiedSavedData['currentDayNumber'];
80
+ $options['ycd-schedule-end-to'] = $this->getOptionValue('ycd-schedule-end-to');
81
+ $options['ycd-schedule-start-from'] = $this->getOptionValue('ycd-schedule-start-from');
82
+
83
  $options['time'] = array(
84
  'Years' => array(
85
  'text' => $this->getOptionValue('ycd-countdown-years-text'),
159
  $circleAlignment = $this->getOptionValue('ycd-circle-alignment');
160
  $padding = $this->getOptionValue('ycd-countdown-padding').'px';
161
 
 
162
  ob_start();
163
  ?>
164
  <style type="text/css">
classes/countdown/Countdown.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
  namespace ycd;
3
  use \YcdCountdownOptionsConfig;
 
 
4
 
5
  abstract class Countdown {
6
 
@@ -13,6 +15,9 @@ abstract class Countdown {
13
  private $shortCodeContent;
14
  private $isCountdown = true;
15
 
 
 
 
16
  abstract protected function getViewContent();
17
 
18
  public function setId($id) {
@@ -81,6 +86,14 @@ abstract class Countdown {
81
  return $this->savedData;
82
  }
83
 
 
 
 
 
 
 
 
 
84
  public function insertIntoSanitizedData($sanitizedData) {
85
  if (!empty($sanitizedData)) {
86
  $this->sanitizedData[$sanitizedData['name']] = $sanitizedData['value'];
@@ -428,9 +441,9 @@ abstract class Countdown {
428
  return ($var ? 'checked' : '');
429
  }
430
 
431
- public static function getPopupsObj($agrs = array()) {
432
  $postStatus = array('publish');
433
- $popups = array();
434
 
435
  if (!empty($agrs['postStatus'])) {
436
  $postStatus = $agrs['postStatus'];
@@ -444,22 +457,26 @@ abstract class Countdown {
444
  ));
445
 
446
  if(empty($posts)) {
447
- return $popups;
448
  }
449
 
450
  foreach ($posts as $post) {
451
- $popupObj = self::find($post->ID);
452
 
453
- if(empty($popupObj)) {
454
  continue;
455
  }
456
- $popups[] = $popupObj;
457
  }
458
 
459
- return $popups;
460
  }
461
 
462
- public static function shapeIdTitleData($contdowns) {
 
 
 
 
463
  $idTitle = array();
464
 
465
  if(empty($contdowns)) {
@@ -554,15 +571,45 @@ abstract class Countdown {
554
  }
555
 
556
  public function isExpired() {
 
 
557
  $timezone = $this->getOptionValue('ycd-circle-time-zone');
558
  $dueDate = $this->getOptionValue('ycd-date-time-picker');
559
  $dueDate .= ':00';
560
- $timeDate = new \DateTime('now', new \DateTimeZone($timezone));
561
  $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
562
  $seconds = strtotime($dueDate)-$timeNow;
 
 
 
 
 
563
 
564
  return ($seconds < 0);
565
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
 
567
  public static function allowToLoad($contdownPost, $countdownObj) {
568
  $isAllow = Checker::isAllow($contdownPost, $countdownObj);
@@ -571,14 +618,22 @@ abstract class Countdown {
571
  }
572
 
573
  protected function getCircleSeconds() {
574
- if($this->getOptionValue('ycd-countdown-date-type') == 'dueDate') {
 
 
 
 
575
  $dueDate = $this->getOptionValue('ycd-date-time-picker');
576
  $timezone = $this->getOptionValue('ycd-circle-time-zone');
577
  $dueDate .= ':00';
578
- $timeDate = new \DateTime('now', new \DateTimeZone($timezone));
579
  $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
580
  $seconds = strtotime($dueDate)-$timeNow;
581
  }
 
 
 
 
582
  else {
583
  $hours = (int)$this->getOptionValue('ycd-countdown-duration-hours');
584
  $minutes = (int)$this->getOptionValue('ycd-countdown-duration-minutes');
@@ -586,7 +641,8 @@ abstract class Countdown {
586
 
587
  $seconds = $hours*60*60 + $minutes*60 + $secondsSaved;
588
  }
 
589
 
590
- return $seconds;
591
  }
592
  }
1
  <?php
2
  namespace ycd;
3
  use \YcdCountdownOptionsConfig;
4
+ use \DateTime;
5
+ use \DateTimeZone;
6
 
7
  abstract class Countdown {
8
 
15
  private $shortCodeContent;
16
  private $isCountdown = true;
17
 
18
+ //expire seconds
19
+ public $expireSeconds = 0;
20
+
21
  abstract protected function getViewContent();
22
 
23
  public function setId($id) {
86
  return $this->savedData;
87
  }
88
 
89
+ public function setExpireSeconds($expireSeconds) {
90
+ $this->expireSeconds = $expireSeconds;
91
+ }
92
+
93
+ public function getExpireSeconds() {
94
+ return $this->expireSeconds;
95
+ }
96
+
97
  public function insertIntoSanitizedData($sanitizedData) {
98
  if (!empty($sanitizedData)) {
99
  $this->sanitizedData[$sanitizedData['name']] = $sanitizedData['value'];
441
  return ($var ? 'checked' : '');
442
  }
443
 
444
+ public static function getCountdownsObj($agrs = array()) {
445
  $postStatus = array('publish');
446
+ $countdowns = array();
447
 
448
  if (!empty($agrs['postStatus'])) {
449
  $postStatus = $agrs['postStatus'];
457
  ));
458
 
459
  if(empty($posts)) {
460
+ return $countdowns;
461
  }
462
 
463
  foreach ($posts as $post) {
464
+ $countdownObj = self::find($post->ID);
465
 
466
+ if(empty($countdownObj)) {
467
  continue;
468
  }
469
+ $countdowns[] = $countdownObj;
470
  }
471
 
472
+ return $countdowns;
473
  }
474
 
475
+ public static function shapeIdTitleData($contdowns = false) {
476
+
477
+ if (empty($contdowns)) {
478
+ $contdowns = self::getCountdownsObj();
479
+ }
480
  $idTitle = array();
481
 
482
  if(empty($contdowns)) {
571
  }
572
 
573
  public function isExpired() {
574
+ $dateType = $this->getOptionValue('ycd-countdown-date-type');
575
+
576
  $timezone = $this->getOptionValue('ycd-circle-time-zone');
577
  $dueDate = $this->getOptionValue('ycd-date-time-picker');
578
  $dueDate .= ':00';
579
+ $timeDate = new DateTime('now', new DateTimeZone($timezone));
580
  $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
581
  $seconds = strtotime($dueDate)-$timeNow;
582
+
583
+ if($dateType == 'schedule') {
584
+ $seconds = $this->getCircleSeconds();
585
+ return !$seconds->expireSeconds;
586
+ }
587
 
588
  return ($seconds < 0);
589
  }
590
+
591
+ public function getExpireDate() {
592
+ $dateType = $this->getOptionValue('ycd-countdown-date-type');
593
+
594
+ $timezone = $this->getOptionValue('ycd-circle-time-zone');
595
+ $current = new DateTime('now', new \DateTimeZone($timezone));
596
+ $dueDate = $this->getOptionValue('ycd-date-time-picker');
597
+ $currentDate = $current->format('Y-m-d H:i:s');
598
+ if($dateType == 'schedule') {
599
+ $timezone = $this->getOptionValue('ycd-schedule-time-zone');
600
+
601
+ $current = new DateTime('now', new DateTimeZone($timezone));
602
+ $currentDate = $current->format('Y-m-d H:i:s');
603
+
604
+ $endTo = $this->getOptionValue('ycd-schedule-end-day');
605
+ $endTimeClock = $this->getOptionValue('ycd-schedule-end-to');
606
+ $endDateObj = AdminHelperPro::getSheduleDate($endTo, $endTimeClock, $timezone);
607
+ $dueDate = $endDateObj->format('Y-m-d H:i:s');
608
+ }
609
+ $dateString = human_time_diff(strtotime($dueDate), strtotime($currentDate));
610
+
611
+ return $dateString;
612
+ }
613
 
614
  public static function allowToLoad($contdownPost, $countdownObj) {
615
  $isAllow = Checker::isAllow($contdownPost, $countdownObj);
618
  }
619
 
620
  protected function getCircleSeconds() {
621
+ $seconds = 0;
622
+ $filteredObj = $this;
623
+ $dateType = $this->getOptionValue('ycd-countdown-date-type');
624
+
625
+ if($dateType == 'dueDate') {
626
  $dueDate = $this->getOptionValue('ycd-date-time-picker');
627
  $timezone = $this->getOptionValue('ycd-circle-time-zone');
628
  $dueDate .= ':00';
629
+ $timeDate = new DateTime('now', new DateTimeZone($timezone));
630
  $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
631
  $seconds = strtotime($dueDate)-$timeNow;
632
  }
633
+ else if($dateType == 'schedule') {
634
+ $filteredObj = apply_filters('ycdScheduleExpireSecond', $this);
635
+ $seconds = $this->getExpireSeconds();
636
+ }
637
  else {
638
  $hours = (int)$this->getOptionValue('ycd-countdown-duration-hours');
639
  $minutes = (int)$this->getOptionValue('ycd-countdown-duration-minutes');
641
 
642
  $seconds = $hours*60*60 + $minutes*60 + $secondsSaved;
643
  }
644
+ $filteredObj->expireSeconds = $seconds;
645
 
646
+ return $filteredObj;
647
  }
648
  }
config/config.php CHANGED
@@ -16,6 +16,7 @@ class YcdCountdownConfig {
16
  self::addDefine('YCD_COUNTDOWN_ASSETS_URL', YCD_COUNTDOWN_URL.'assets/');
17
  self::addDefine('YCD_COUNTDOWN_CSS_URL', YCD_COUNTDOWN_ASSETS_URL.'css/');
18
  self::addDefine('YCD_COUNTDOWN_JS_URL', YCD_COUNTDOWN_ASSETS_URL.'js/');
 
19
  self::addDefine('YCD_COUNTDOWN_IMG_URL', YCD_COUNTDOWN_ASSETS_URL.'img/');
20
  self::addDefine('YCD_COUNTDOWN_LIB_URL', YCD_COUNTDOWN_URL.'lib/');
21
  self::addDefine('YCD_COUNTDOWN_PATH', WP_PLUGIN_DIR.'/'.YCD_FOLDER_NAME.'/');
@@ -42,12 +43,15 @@ class YcdCountdownConfig {
42
  self::addDefine('YCD_COUNTDOWN_WIDGET', 'ycd_countdown_widget');
43
  self::addDefine('YCD_TEXT_DOMAIN', 'ycdCountdown');
44
  self::addDefine('YCD_COUNTDOWN_PRO_URL', 'https://edmonsoft.com/countdown');
 
45
  self::addDefine('YCD_FILTER_REPEAT_INTERVAL', 50);
 
46
  self::addDefine('YCD_PRODUCTS_LIMIT', 1000);
47
- self::addDefine('YCD_CRON_REPEAT_INTERVAL', 1);
 
48
  self::addDefine('YCD_TABLE_LIMIT', 15);
49
- self::addDefine('YCD_VERSION', 1.35);
50
- self::addDefine('YCD_VERSION_PRO', 1.22);
51
  self::addDefine('YCD_FREE_VERSION', 1);
52
  self::addDefine('YCD_SILVER_VERSION', 2);
53
  self::addDefine('YCD_GOLD_VERSION', 3);
16
  self::addDefine('YCD_COUNTDOWN_ASSETS_URL', YCD_COUNTDOWN_URL.'assets/');
17
  self::addDefine('YCD_COUNTDOWN_CSS_URL', YCD_COUNTDOWN_ASSETS_URL.'css/');
18
  self::addDefine('YCD_COUNTDOWN_JS_URL', YCD_COUNTDOWN_ASSETS_URL.'js/');
19
+ self::addDefine('YCD_COUNTDOWN_ADMIN_JS_URL', YCD_COUNTDOWN_JS_URL.'admin/');
20
  self::addDefine('YCD_COUNTDOWN_IMG_URL', YCD_COUNTDOWN_ASSETS_URL.'img/');
21
  self::addDefine('YCD_COUNTDOWN_LIB_URL', YCD_COUNTDOWN_URL.'lib/');
22
  self::addDefine('YCD_COUNTDOWN_PATH', WP_PLUGIN_DIR.'/'.YCD_FOLDER_NAME.'/');
43
  self::addDefine('YCD_COUNTDOWN_WIDGET', 'ycd_countdown_widget');
44
  self::addDefine('YCD_TEXT_DOMAIN', 'ycdCountdown');
45
  self::addDefine('YCD_COUNTDOWN_PRO_URL', 'https://edmonsoft.com/countdown');
46
+ self::addDefine('YCD_COUNTDOWN_REVIEW_URL', 'https://wordpress.org/support/plugin/countdown-builder/reviews/?filter=5');
47
  self::addDefine('YCD_FILTER_REPEAT_INTERVAL', 50);
48
+ self::addDefine('YCD_SHOW_REVIEW_PERIOD', 30);
49
  self::addDefine('YCD_PRODUCTS_LIMIT', 1000);
50
+ self::addDefine('YCD_CRON_REPEAT_INTERVAL', 1);
51
+ self::addDefine('YCD_AJAX_SUCCESS', 1);
52
  self::addDefine('YCD_TABLE_LIMIT', 15);
53
+ self::addDefine('YCD_VERSION', 1.36);
54
+ self::addDefine('YCD_VERSION_PRO', 1.23);
55
  self::addDefine('YCD_FREE_VERSION', 1);
56
  self::addDefine('YCD_SILVER_VERSION', 2);
57
  self::addDefine('YCD_GOLD_VERSION', 3);
config/proOptionsConfig.php CHANGED
@@ -32,6 +32,10 @@ class proOptionsConfig {
32
  $defaults[] = array('name' => 'ycd-woo-selected-products', 'type' => 'html', 'defaultValue' => '');
33
  $defaults[] = array('name' => 'ycd-woo-countdown-after-countdown', 'type' => 'html', 'defaultValue' => '');
34
  $defaults[] = array('name' => 'ycd-woo-countdown-before-countdown', 'type' => 'html', 'defaultValue' => '');
 
 
 
 
35
 
36
  return $defaults;
37
  }
32
  $defaults[] = array('name' => 'ycd-woo-selected-products', 'type' => 'html', 'defaultValue' => '');
33
  $defaults[] = array('name' => 'ycd-woo-countdown-after-countdown', 'type' => 'html', 'defaultValue' => '');
34
  $defaults[] = array('name' => 'ycd-woo-countdown-before-countdown', 'type' => 'html', 'defaultValue' => '');
35
+
36
+ $defaults[] = array('name' => 'ycd-schedule-start-from', 'type' => 'html', 'defaultValue' => '10:00');
37
+ $defaults[] = array('name' => 'ycd-schedule-end-to', 'type' => 'html', 'defaultValue' => '18:00');
38
+ $defaults[] = array('name' => 'ycd-schedule-time-zone', 'type' => 'html', 'defaultValue' => 'Europe/London');
39
 
40
  return $defaults;
41
  }
countdown-builder.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Countdown builder
4
  * Description: The best countdown plugin
5
- * Version: 1.3.5
6
  * Author: Adam Skaat
7
  * Author URI: https://edmonsoft.com/countdown
8
  * License: GPLv2
2
  /**
3
  * Plugin Name: Countdown builder
4
  * Description: The best countdown plugin
5
+ * Version: 1.3.6
6
  * Author: Adam Skaat
7
  * Author URI: https://edmonsoft.com/countdown
8
  * License: GPLv2
helpers/AdminHelper.php CHANGED
@@ -210,6 +210,47 @@ class AdminHelper {
210
  )
211
  )
212
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
  $data['countdown-date-type'] = array(
215
  'template' => array(
@@ -225,32 +266,7 @@ class AdminHelper {
225
  ),
226
  'buttonPosition' => 'right',
227
  'nextNewLine' => true,
228
- 'fields' => array(
229
- array(
230
- 'attr' => array(
231
- 'type' => 'radio',
232
- 'name' => 'ycd-countdown-date-type',
233
- 'class' => 'ycd-date-duration',
234
- 'data-attr-href' => 'ycd-countdown-due-date',
235
- 'value' => 'dueDate'
236
- ),
237
- 'label' => array(
238
- 'name' => __('Due Date', YCD_TEXT_DOMAIN)
239
- )
240
- ),
241
- array(
242
- 'attr' => array(
243
- 'type' => 'radio',
244
- 'name' => 'ycd-countdown-date-type',
245
- 'class' => 'ycd-date-duration',
246
- 'data-attr-href' => 'ycd-date-duration',
247
- 'value' => 'duration'
248
- ),
249
- 'label' => array(
250
- 'name' => __('Duration', YCD_TEXT_DOMAIN)
251
- )
252
- )
253
- )
254
  );
255
 
256
  $data['countdownExpireTime'] = array(
@@ -933,4 +949,31 @@ class AdminHelper {
933
  //we do not know the post type!
934
  return null;
935
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
936
  }
210
  )
211
  )
212
  );
213
+ $countdownDateTypeFields = array(
214
+ array(
215
+ 'attr' => array(
216
+ 'type' => 'radio',
217
+ 'name' => 'ycd-countdown-date-type',
218
+ 'class' => 'ycd-date-type',
219
+ 'data-attr-href' => 'ycd-countdown-due-date',
220
+ 'value' => 'dueDate'
221
+ ),
222
+ 'label' => array(
223
+ 'name' => __('Due Date', YCD_TEXT_DOMAIN)
224
+ )
225
+ ),
226
+ array(
227
+ 'attr' => array(
228
+ 'type' => 'radio',
229
+ 'name' => 'ycd-countdown-date-type',
230
+ 'class' => 'ycd-date-type',
231
+ 'data-attr-href' => 'ycd-date-duration',
232
+ 'value' => 'duration'
233
+ ),
234
+ 'label' => array(
235
+ 'name' => __('Duration', YCD_TEXT_DOMAIN)
236
+ )
237
+ )
238
+ );
239
+
240
+ if(YCD_PKG_VERSION != YCD_SILVER_VERSION) {
241
+ $countdownDateTypeFields[] = array(
242
+ 'attr' => array(
243
+ 'type' => 'radio',
244
+ 'name' => 'ycd-countdown-date-type',
245
+ 'class' => 'ycd-date-type',
246
+ 'data-attr-href' => 'ycd-date-schedule',
247
+ 'value' => 'schedule'
248
+ ),
249
+ 'label' => array(
250
+ 'name' => __('Schedule', YCD_TEXT_DOMAIN)
251
+ )
252
+ );
253
+ }
254
 
255
  $data['countdown-date-type'] = array(
256
  'template' => array(
266
  ),
267
  'buttonPosition' => 'right',
268
  'nextNewLine' => true,
269
+ 'fields' => $countdownDateTypeFields
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  );
271
 
272
  $data['countdownExpireTime'] = array(
949
  //we do not know the post type!
950
  return null;
951
  }
952
+
953
+ public static function getWeekNumberFromName($weekName) {
954
+ $date = array(
955
+ 'Monday' => 1,
956
+ 'Tuesday' => 2,
957
+ 'Wednesday' => 3,
958
+ 'Thursday' => 4,
959
+ 'Friday' => 5,
960
+ 'Saturday' => 6,
961
+ 'Sunday' => 7
962
+ );
963
+
964
+ return $date[$weekName];
965
+ }
966
+
967
+ public static function getWeekDayFromDate($date) {
968
+ if (is_object($date)) {
969
+ $date = $date->format('Y-m-d H:i:s');
970
+ }
971
+ //Convert the date string into a unix timestamp.
972
+ $unixTimestamp = strtotime($date);
973
+
974
+ //Get the day of the week using PHP's date function.
975
+ $dayOfWeek = date("l", $unixTimestamp);
976
+
977
+ return $dayOfWeek;
978
+ }
979
  }
helpers/ShowReviewNotice.php ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class YcdShowReviewNotice {
4
+
5
+ public function __toString() {
6
+ $content = '';
7
+ $allowToShow = $this->allowToShowUsageDays();
8
+
9
+ if(!$allowToShow) {
10
+ return $content;
11
+ }
12
+
13
+ $contet = $this->getReviewContent('usageDayes');
14
+
15
+ return $contet;
16
+ }
17
+
18
+ private function allowToShowUsageDays() {
19
+ $shouldOpen = true;
20
+ $dontShowAgain = get_option('YcdDontShowReviewNotice');
21
+ $periodNextTime = get_option('YcdShowNextTime');
22
+
23
+ if($dontShowAgain) {
24
+ return !$shouldOpen;
25
+ }
26
+
27
+ // When period next time does not exits it means the user is old
28
+ if(!$periodNextTime) {
29
+ YcdShowReviewNotice::setInitialDates();
30
+
31
+ return !$shouldOpen;
32
+ }
33
+ $currentData = new DateTime('now');
34
+ $timeNow = $currentData->format('Y-m-d H:i:s');
35
+ $timeNow = strtotime($timeNow);
36
+
37
+ return $periodNextTime < $timeNow;
38
+ }
39
+
40
+ private function getReviewContent($type) {
41
+ $content = $this->getMaxOpenDaysMessage($type);
42
+ ob_start();
43
+ ?>
44
+ <div id="welcome-panel" class="welcome-panel ycd-review-block">
45
+ <div class="welcome-panel-content">
46
+ <?php echo $content; ?>
47
+ </div>
48
+ </div>
49
+ <?php
50
+ $reviewContent = ob_get_contents();
51
+ ob_end_clean();
52
+
53
+ return $reviewContent;
54
+ }
55
+
56
+ private function getMainTableCreationDate() {
57
+ global $wpdb;
58
+
59
+ $query = $wpdb->prepare('SELECT table_name, create_time FROM information_schema.tables WHERE table_schema="%s" AND table_name="%s"', DB_NAME, $wpdb->prefix.'expm_maker');
60
+ $results = $wpdb->get_results($query, ARRAY_A);
61
+
62
+ if(empty($results)) {
63
+ return 0;
64
+ }
65
+
66
+ $createTime = $results[0]['create_time'];
67
+ $createTime = strtotime($createTime);
68
+ update_option('YcdInstallDate', $createTime);
69
+ $diff = time()-$createTime;
70
+ $days = floor($diff/(60*60*24));
71
+
72
+ return $days;
73
+ }
74
+
75
+ private function getPopupUsageDays() {
76
+ $installDate = get_option('YcdInstallDate');
77
+
78
+ $timeDate = new DateTime('now');
79
+ $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
80
+
81
+ $diff = $timeNow-$installDate;
82
+
83
+ $days = floor($diff/(60*60*24));
84
+
85
+ return $days;
86
+ }
87
+
88
+ private function getMaxOpenDaysMessage($type) {
89
+ $getUsageDays = $this->getPopupUsageDays();
90
+ $firstHeader = '<h1 class="ycd-review-h1"><strong class="ycd-review-strong">Wow!</strong> You’ve been using Countdown on your site for '.$getUsageDays.' days</h1>';
91
+ $popupContent = $this->getMaxOepnContent($firstHeader, $type);
92
+
93
+ $popupContent .= $this->showReviewBlockJs();
94
+
95
+ return $popupContent;
96
+ }
97
+
98
+ private function getMaxOepnContent($firstHeader, $type) {
99
+ $ajaxNonce = wp_create_nonce('ycdReviewNotice');
100
+
101
+ ob_start();
102
+ ?>
103
+ <style>
104
+ .ycd-buttons-wrapper .press{
105
+ box-sizing:border-box;
106
+ cursor:pointer;
107
+ display:inline-block;
108
+ font-size:1em;
109
+ margin:0;
110
+ padding:0.5em 0.75em;
111
+ text-decoration:none;
112
+ transition:background 0.15s linear
113
+ }
114
+ .ycd-buttons-wrapper .press-grey {
115
+ background-color:#9E9E9E;
116
+ border:2px solid #9E9E9E;
117
+ color: #FFF;
118
+ }
119
+ .ycd-buttons-wrapper .press-lightblue {
120
+ background-color:#03A9F4;
121
+ border:2px solid #03A9F4;
122
+ color: #FFF;
123
+ }
124
+ .ycd-review-wrapper{
125
+ text-align: center;
126
+ padding: 20px;
127
+ }
128
+ .ycd-review-wrapper p {
129
+ color: black;
130
+ }
131
+ .ycd-review-h1 {
132
+ font-size: 22px;
133
+ font-weight: normal;
134
+ line-height: 1.384;
135
+ }
136
+ .ycd-review-h2{
137
+ font-size: 20px;
138
+ font-weight: normal;
139
+ }
140
+ :root {
141
+ --main-bg-color: #1ac6ff;
142
+ }
143
+ .ycd-review-strong{
144
+ color: var(--main-bg-color);
145
+ }
146
+ .ycd-review-mt20{
147
+ margin-top: 20px
148
+ }
149
+ </style>
150
+ <div class="ycd-review-wrapper">
151
+ <div class="ycd-review-description">
152
+ <?php echo $firstHeader; ?>
153
+ <h2 class="ycd-review-h2">This is really great for your website score.</h2>
154
+ <p class="ycd-review-mt20">Have your input in the development of our plugin, and we’ll provide better conversions for your site!<br /> Leave your 5-star positive review and help us go further to the perfection!</p>
155
+ </div>
156
+ <div class="ycd-buttons-wrapper">
157
+ <button class="press press-grey ycd-button-1 ycd-already-did-review" data-ajaxnonce="<?php echo esc_attr($ajaxNonce); ?>">I already did</button>
158
+ <button class="press press-lightblue ycd-button-3 ycd-already-did-review" data-ajaxnonce="<?php echo esc_attr($ajaxNonce); ?>" onclick="window.open('<?php echo YCD_COUNTDOWN_REVIEW_URL; ?>')">You worth it!</button>
159
+ <button class="press press-grey ycd-button-2 ycd-show-popup-period" data-ajaxnonce="<?php echo esc_attr($ajaxNonce); ?>" data-message-type="<?php echo $type; ?>">Maybe later</button>
160
+ </div>
161
+ </div>
162
+ <?php
163
+ $content = ob_get_contents();
164
+ ob_end_clean();
165
+
166
+ return $content;
167
+ }
168
+
169
+ private function showReviewBlockJs() {
170
+ ob_start();
171
+ ?>
172
+ <script type="text/javascript">
173
+ jQuery('.ycd-already-did-review').each(function () {
174
+ jQuery(this).on('click', function () {
175
+ var ajaxNonce = jQuery(this).attr('data-ajaxnonce');
176
+
177
+ var data = {
178
+ action: 'ycd_dont_show_review_notice',
179
+ ajaxNonce: ajaxNonce
180
+ };
181
+ jQuery.post(ajaxurl, data, function(response,d) {
182
+ if(jQuery('.ycd-review-block').length) {
183
+ jQuery('.ycd-review-block').remove();
184
+ }
185
+ });
186
+ });
187
+ });
188
+
189
+ jQuery('.ycd-show-popup-period').on('click', function () {
190
+ var ajaxNonce = jQuery(this).attr('data-ajaxnonce');
191
+ var messageType = jQuery(this).attr('data-message-type');
192
+
193
+ var data = {
194
+ action: 'ycd_change_review_show_period',
195
+ messageType: messageType,
196
+ ajaxNonce: ajaxNonce
197
+ };
198
+ jQuery.post(ajaxurl, data, function(response,d) {
199
+ if(jQuery('.ycd-review-block').length) {
200
+ jQuery('.ycd-review-block').remove();
201
+ }
202
+ });
203
+ });
204
+ </script>
205
+ <?php
206
+ $script = ob_get_contents();
207
+ ob_end_clean();
208
+
209
+ return $script;
210
+ }
211
+
212
+ public static function setInitialDates() {
213
+ $usageDays = get_option('YcdUsageDays');
214
+ if(!$usageDays) {
215
+ update_option('YcdUsageDays', 0);
216
+
217
+ $timeDate = new DateTime('now');
218
+ $installTime = strtotime($timeDate->format('Y-m-d H:i:s'));
219
+ update_option('YcdInstallDate', $installTime);
220
+ $timeDate->modify('+'.YCD_SHOW_REVIEW_PERIOD.' day');
221
+
222
+ $timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
223
+ update_option('YcdShowNextTime', $timeNow);
224
+ }
225
+ }
226
+
227
+ public static function deleteInitialDates() {
228
+ delete_option('YcdUsageDays');
229
+ delete_option('YcdInstallDate');
230
+ delete_option('YcdShowNextTime');
231
+ }
232
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: adamskaat
3
  Tags: countdown, timer, countdown timer
4
  Requires at least: 3.8
5
  Tested up to: 5.0.3
6
- Stable tag: 1.3.5
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -52,6 +52,13 @@ Coming soon
52
 
53
  == Changelog ==
54
 
 
 
 
 
 
 
 
55
  = 1.3.5 =
56
  * Bug Fixed
57
 
3
  Tags: countdown, timer, countdown timer
4
  Requires at least: 3.8
5
  Tested up to: 5.0.3
6
+ Stable tag: 1.3.6
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
52
 
53
  == Changelog ==
54
 
55
+ = 1.3.6 =
56
+ * Gutenberg block (new)
57
+ * Html editor countdown button (new)
58
+ * Schedule (new)
59
+ * Backend side improvement
60
+ * Bug fixed
61
+
62
  = 1.3.5 =
63
  * Bug Fixed
64