Countdown, Coming Soon – Countdown & Clock - Version 1.4.6

Version Description

  • Display Countdown to Everyver automatically (new feature)
  • Circle Countdown responsiveness improvement
Download this release

Release Info

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

Code changes from version 1.4.5 to 1.4.6

CountdownInit.php CHANGED
@@ -39,20 +39,19 @@ class CountdownInit {
39
  require_once YCD_HELPERS_PATH.'ScriptsIncluder.php';
40
  require_once YCD_HELPERS_PATH.'MultipleChoiceButton.php';
41
  require_once YCD_HELPERS_PATH.'AdminHelper.php';
 
 
 
42
  require_once YCD_CLASSES_PATH.'Tickbox.php';
43
  require_once YCD_CLASSES_PATH.'YcdWidget.php';
44
  require_once YCD_CLASSES_PATH.'CountdownType.php';
45
  require_once YCD_COUNTDOWNS_PATH.'CountdownModel.php';
46
- if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
47
- require_once YCD_CLASSES_PATH.'Checker.php';
48
- }
49
  require_once YCD_COUNTDOWNS_PATH.'Countdown.php';
50
  require_once YCD_CSS_PATH.'Css.php';
51
  require_once YCD_JS_PATH.'Js.php';
52
  require_once YCD_CLASSES_PATH.'RegisterPostType.php';
53
- if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
54
- require_once YCD_CLASSES_PATH.'IncludeManager.php';
55
- }
56
  require_once YCD_CLASSES_PATH.'Actions.php';
57
  require_once YCD_CLASSES_PATH.'Ajax.php';
58
  require_once YCD_CLASSES_PATH.'Filters.php';
39
  require_once YCD_HELPERS_PATH.'ScriptsIncluder.php';
40
  require_once YCD_HELPERS_PATH.'MultipleChoiceButton.php';
41
  require_once YCD_HELPERS_PATH.'AdminHelper.php';
42
+ require_once YCD_CLASSES_PATH.'DisplayRuleChecker.php';
43
+ require_once YCD_CLASSES_PATH.'ConditionBuilder.php';
44
+ require_once YCD_CLASSES_PATH.'DisplayConditionBuilder.php';
45
  require_once YCD_CLASSES_PATH.'Tickbox.php';
46
  require_once YCD_CLASSES_PATH.'YcdWidget.php';
47
  require_once YCD_CLASSES_PATH.'CountdownType.php';
48
  require_once YCD_COUNTDOWNS_PATH.'CountdownModel.php';
49
+ require_once YCD_CLASSES_PATH.'Checker.php';
 
 
50
  require_once YCD_COUNTDOWNS_PATH.'Countdown.php';
51
  require_once YCD_CSS_PATH.'Css.php';
52
  require_once YCD_JS_PATH.'Js.php';
53
  require_once YCD_CLASSES_PATH.'RegisterPostType.php';
54
+ require_once YCD_CLASSES_PATH.'IncludeManager.php';
 
 
55
  require_once YCD_CLASSES_PATH.'Actions.php';
56
  require_once YCD_CLASSES_PATH.'Ajax.php';
57
  require_once YCD_CLASSES_PATH.'Filters.php';
assets/css/admin.css CHANGED
@@ -540,4 +540,28 @@ div.ycd-tabs-text-header > div.ycd-toggle-icon-open {
540
  height: 30px;
541
  display: inline-block;
542
  cursor: pointer;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
  }
540
  height: 30px;
541
  display: inline-block;
542
  cursor: pointer;
543
+ }
544
+
545
+ .ycd-condition-delete {
546
+ display: none !important;
547
+ }
548
+
549
+ .ycd-condition-add {
550
+ display: none !important;
551
+ }
552
+
553
+ .ycd-condion-wrapper:not(:only-child) .ycd-condition-delete {
554
+ display: inline-block !important;
555
+ }
556
+
557
+ .ycd-condion-wrapper:nth-last-child .ycd-condition-add {
558
+ display: inline-block !important;
559
+ }
560
+
561
+ .ycd-condion-wrapper:last-child .ycd-condition-add {
562
+ display: inline-block !important;
563
+ }
564
+
565
+ .ycd-condition-delete {
566
+ margin-left: 5px;
567
  }
assets/js/Admin.js CHANGED
@@ -658,4 +658,162 @@ YcdAdmin.prototype.initCountdownDateTimePicker = function() {
658
 
659
  jQuery(document).ready(function() {
660
  new YcdAdmin();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  });
658
 
659
  jQuery(document).ready(function() {
660
  new YcdAdmin();
661
+ });
662
+
663
+ /*Conditions builder*/
664
+ function YcdConditionBuilder() {
665
+ }
666
+
667
+ YcdConditionBuilder.prototype.init = function() {
668
+ this.conditionsBuilder();
669
+ this.select2();
670
+ };
671
+
672
+ YcdConditionBuilder.prototype.select2 = function() {
673
+ var select2 = jQuery('.js-ycd-select');
674
+
675
+ if(!select2.length) {
676
+ return false;
677
+ }
678
+ select2.each(function() {
679
+ var type = jQuery(this).data('select-type');
680
+
681
+ var options = {
682
+ width: '100%'
683
+ };
684
+
685
+ if (type == 'ajax') {
686
+ options = jQuery.extend(options, {
687
+ minimumInputLength: 1,
688
+ ajax: {
689
+ url: ajaxurl,
690
+ dataType: 'json',
691
+ delay: 250,
692
+ type: "POST",
693
+ data: function(params) {
694
+
695
+ var searchKey = jQuery(this).attr('data-value-param');
696
+ var postType = jQuery(this).attr('data-post-type');
697
+
698
+ return {
699
+ action: 'ycd_select2_search_data',
700
+ nonce_ajax: ycd_admin_localized.nonce,
701
+ postType: postType,
702
+ searchTerm: params.term,
703
+ searchKey: searchKey
704
+ };
705
+ },
706
+ processResults: function(data) {
707
+ return {
708
+ results: jQuery.map(data.items, function(item) {
709
+
710
+ return {
711
+ text: item.text,
712
+ id: item.id
713
+ }
714
+
715
+ })
716
+ };
717
+ }
718
+ }
719
+ });
720
+ }
721
+
722
+ jQuery(this).select2(options);
723
+ });
724
+ };
725
+
726
+ YcdConditionBuilder.prototype.conditionsBuilder = function() {
727
+ this.conditionsBuilderEdit();
728
+ this.conditionsBuilderAdd();
729
+ this.conditionsBuilderDelte();
730
+ };
731
+
732
+ YcdConditionBuilder.prototype.conditionsBuilderAdd = function() {
733
+ var params = jQuery('.ycd-condition-add');
734
+
735
+ if(!params.length) {
736
+ return false;
737
+ }
738
+ var that = this;
739
+ params.bind('click', function() {
740
+ var currentWrapper = jQuery(this).parents('.ycd-condion-wrapper').first();
741
+ var selectedParams = currentWrapper.find('.js-conditions-param').val();
742
+
743
+ that.addViaAjax(selectedParams, currentWrapper);
744
+ });
745
+ };
746
+
747
+ YcdConditionBuilder.prototype.conditionsBuilderDelte = function() {
748
+ var params = jQuery('.ycd-condition-delete');
749
+
750
+ if(!params.length) {
751
+ return false;
752
+ }
753
+
754
+ params.bind('click', function() {
755
+ var currentWrapper = jQuery(this).parents('.ycd-condion-wrapper').first();
756
+
757
+ currentWrapper.remove();
758
+ });
759
+ };
760
+
761
+ YcdConditionBuilder.prototype.conditionsBuilderEdit = function() {
762
+ var params = jQuery('.js-conditions-param');
763
+
764
+ if(!params.length) {
765
+ return false;
766
+ }
767
+ var that = this;
768
+ params.bind('change', function() {
769
+ var selectedParams = jQuery(this).val();
770
+ var currentWrapper = jQuery(this).parents('.ycd-condion-wrapper').first();
771
+
772
+ that.changeViaAjax(selectedParams, currentWrapper);
773
+ });
774
+ };
775
+
776
+ YcdConditionBuilder.prototype.addViaAjax = function(selectedParams, currentWrapper) {
777
+ var conditionId = parseInt(currentWrapper.data('condition-id'))+1;
778
+ var conditionsClassName = currentWrapper.parent().data('child-class');
779
+
780
+ var that = this;
781
+
782
+ var data = {
783
+ action: 'ycd_add_conditions_row',
784
+ nonce: ycd_admin_localized.nonce,
785
+ conditionId: conditionId,
786
+ conditionsClassName: conditionsClassName,
787
+ selectedParams: selectedParams
788
+ };
789
+
790
+ jQuery.post(ajaxurl, data, function(response) {
791
+ currentWrapper.after(response);
792
+ that.init();
793
+ });
794
+ };
795
+
796
+ YcdConditionBuilder.prototype.changeViaAjax = function(selectedParams, currentWrapper) {
797
+ var conditionId = currentWrapper.data('condition-id');
798
+ var conditionsClassName = currentWrapper.parent().data('child-class');
799
+
800
+ var that = this;
801
+
802
+ var data = {
803
+ action: 'ycd_edit_conditions_row',
804
+ nonce: ycd_admin_localized.nonce,
805
+ conditionId: conditionId,
806
+ conditionsClassName: conditionsClassName,
807
+ selectedParams: selectedParams
808
+ };
809
+
810
+ jQuery.post(ajaxurl, data, function(response) {
811
+ currentWrapper.replaceWith(response);
812
+ that.init();
813
+ });
814
+ };
815
+
816
+ jQuery(document).ready(function() {
817
+ var obj = new YcdConditionBuilder();
818
+ obj.init();
819
  });
assets/js/Countdown.js CHANGED
@@ -96,18 +96,20 @@ YcdCountdown.prototype.showingLimitation = function() {
96
 
97
  YcdCountdown.prototype.responsive = function() {
98
  var scale = function () {
99
- var scaleDegree = jQuery('.ycd-circle-wrapper').width()/jQuery('.ycd-time-circle').width();
 
100
 
101
- if(jQuery('.ycd-time-circle').width() > jQuery('.ycd-circle-wrapper').width()) {
102
- jQuery('.ycd-time-circle').css({
103
- 'transform': 'scale('+ scaleDegree +', '+scaleDegree+')'
104
- });
105
- }
106
- else {
107
- jQuery('.ycd-time-circle').css({
108
- 'transform': 'scale('+ 1 +', '+1+')'
109
- });
110
- }
 
111
  };
112
 
113
  scale();
96
 
97
  YcdCountdown.prototype.responsive = function() {
98
  var scale = function () {
99
+ jQuery('.ycd-circle-wrapper').each(function () {
100
+ var scaleDegree = jQuery(this).width()/jQuery('.ycd-time-circle', this).width();
101
 
102
+ if(jQuery('.ycd-time-circle', this).width() > jQuery(this).width()) {
103
+ jQuery('.ycd-time-circle', this).css({
104
+ 'transform': 'scale('+ scaleDegree +', '+scaleDegree+')'
105
+ });
106
+ }
107
+ else {
108
+ jQuery('.ycd-time-circle', this).css({
109
+ 'transform': 'scale('+ 1 +', '+1+')'
110
+ });
111
+ }
112
+ });
113
  };
114
 
115
  scale();
assets/views/displaySettings.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use ycd\DisplayConditionBuilder;
3
+ use ycd\AdminHelper;
4
+
5
+ $defaultData = AdminHelper::defaultData();
6
+ $savedData = $this->getOptionValue('ycd-display-settings');
7
+ $obj = new DisplayConditionBuilder();
8
+ $obj->setSavedData($savedData);
9
+ ?>
10
+ <div class="ystp-bootstrap-wrapper">
11
+ <div class="row form-group">
12
+ <div class="col-md-5">
13
+ <label for="ycd-countdown-text-size" class="ycd-label-of-select"><?php _e('Position Of Countdown', YCD_TEXT_DOMAIN); ?></label>
14
+ </div>
15
+ <div class="col-md-7">
16
+ <?php echo AdminHelper::selectBox($defaultData['position-countdown'], esc_attr($this->getOptionValue('ycd-position-countdown')), array('name' => 'ycd-position-countdown', 'class' => 'js-ycd-select')); ?>
17
+ </div>
18
+ </div>
19
+ <?php echo $obj->render(); ?>
20
+ </div>
assets/views/generalOptions.php CHANGED
@@ -125,6 +125,20 @@ $dueDate = $this->getOptionValue('ycd-date-time-picker');
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>
@@ -155,7 +169,7 @@ $dueDate = $this->getOptionValue('ycd-date-time-picker');
155
  <div class="row">
156
  <div class="col-md-12">
157
  <div>
158
- <label for="ycd-edtitor-css" class="ycd-label-of-switch"><?php _e('Custom CSS', YCD_TEXT_DOMAIN); ?></label>
159
  </div>
160
  <textarea id="ycd-edtitor-css" id="ycd-edtitor-css" rows="5" name="ycd-custom-css" class="widefat textarea"><?php echo esc_attr($this->getOptionValue('ycd-custom-css')); ?></textarea>
161
  </div>
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('Display On', YCD_TEXT_DOMAIN); ?></label>
131
+ </div>
132
+ <div class="col-md-6">
133
+ <label class="ycd-switch">
134
+ <input type="checkbox" id="ycd-countdown-display-on" name="ycd-countdown-display-on" class="ycd-accordion-checkbox" <?php echo $this->getOptionValue('ycd-countdown-display-on'); ?>>
135
+ <span class="ycd-slider ycd-round"></span>
136
+ </label>
137
+ </div>
138
+ </div>
139
+ <div class="ycd-accordion-content ycd-hide-content">
140
+ <?php require_once dirname(__FILE__).'/displaySettings.php'; ?>
141
+ </div>
142
  <div class="row">
143
  <div class="col-md-6">
144
  <label for="ycd-countdown-end-sound" class="ycd-label-of-switch"><?php _e('Timer End Sound', YCD_TEXT_DOMAIN); ?></label>
169
  <div class="row">
170
  <div class="col-md-12">
171
  <div>
172
+ <label for="ycd-edtitor-css" class="ycd-label-of-switch"><?php _e('Custom css', YCD_TEXT_DOMAIN); ?></label>
173
  </div>
174
  <textarea id="ycd-edtitor-css" id="ycd-edtitor-css" rows="5" name="ycd-custom-css" class="widefat textarea"><?php echo esc_attr($this->getOptionValue('ycd-custom-css')); ?></textarea>
175
  </div>
classes/Actions.php CHANGED
@@ -36,7 +36,7 @@ class Actions {
36
  }
37
  add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'));
38
  add_filter('mce_external_plugins', array($this, 'editorButton'));
39
- }
40
 
41
  public function editorButton($buttons) {
42
  $isLoadedMediaData = $this->isLoadedMediaData();
@@ -47,9 +47,7 @@ class Actions {
47
  }
48
 
49
  public function enqueueScripts() {
50
- if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
51
- $includeManager = new IncludeManager();
52
- }
53
  }
54
 
55
  public function adminHead() {
@@ -230,7 +228,7 @@ class Actions {
230
  if(YCD_PKG_VERSION == YCD_FREE_VERSION) {
231
  add_meta_box('ycdUpgrade', __('Upgrade', YCD_TEXT_DOMAIN), array($this, 'upgradeToPro'), YCD_COUNTDOWN_POST_TYPE, 'side', 'high');
232
  }
233
- add_meta_box('ycdSupport', __('Support', YCD_TEXT_DOMAIN), array($this, 'support'), YCD_COUNTDOWN_POST_TYPE, 'side', 'high');
234
  }
235
 
236
  public function upgradeToPro() {
36
  }
37
  add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'));
38
  add_filter('mce_external_plugins', array($this, 'editorButton'));
39
+ }
40
 
41
  public function editorButton($buttons) {
42
  $isLoadedMediaData = $this->isLoadedMediaData();
47
  }
48
 
49
  public function enqueueScripts() {
50
+ $includeManager = new IncludeManager();
 
 
51
  }
52
 
53
  public function adminHead() {
228
  if(YCD_PKG_VERSION == YCD_FREE_VERSION) {
229
  add_meta_box('ycdUpgrade', __('Upgrade', YCD_TEXT_DOMAIN), array($this, 'upgradeToPro'), YCD_COUNTDOWN_POST_TYPE, 'side', 'high');
230
  }
231
+ add_meta_box('ycdSupport', __('Support', YCD_TEXT_DOMAIN), array($this, 'support'), YCD_COUNTDOWN_POST_TYPE, 'side');
232
  }
233
 
234
  public function upgradeToPro() {
classes/Ajax.php CHANGED
@@ -16,6 +16,11 @@ class Ajax {
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() {
@@ -47,7 +52,7 @@ class Ajax {
47
  check_ajax_referer('ycd_ajax_nonce', 'nonce');
48
  parse_str($_POST['formData'], $params);
49
 
50
- $headers = 'MIME-Versions: 1.0'."\r\n";
51
  //$headers .= 'From: '.$sendFromEmail.''."\r\n";
52
  $headers .= 'Content-types: text/plain; charset=UTF-8'."\r\n";
53
  $message = '<b>Report type</b>: '.$params['report_type'].'<br>';
@@ -70,6 +75,50 @@ class Ajax {
70
  update_post_meta($postId, 'ycd_enable', $checked);
71
  wp_die();
72
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  new Ajax();
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
+ // conditions builder
21
+ add_action('wp_ajax_ycd_select2_search_data', array($this, 'select2Ajax'));
22
+ add_action('wp_ajax_ycd_edit_conditions_row', array($this, 'conditionsRow'));
23
+ add_action('wp_ajax_ycd_add_conditions_row', array($this, 'conditionsRow'));
24
  }
25
 
26
  public function changeReviewPeriod() {
52
  check_ajax_referer('ycd_ajax_nonce', 'nonce');
53
  parse_str($_POST['formData'], $params);
54
 
55
+ $headers = 'MIME-Versions: 1.0'."\r\n";
56
  //$headers .= 'From: '.$sendFromEmail.''."\r\n";
57
  $headers .= 'Content-types: text/plain; charset=UTF-8'."\r\n";
58
  $message = '<b>Report type</b>: '.$params['report_type'].'<br>';
75
  update_post_meta($postId, 'ycd_enable', $checked);
76
  wp_die();
77
  }
78
+
79
+ public function select2Ajax() {
80
+ check_ajax_referer('ycd_ajax_nonce', 'nonce_ajax');
81
+
82
+ $postTypeName = sanitize_text_field($_POST['postType']);
83
+ $search = sanitize_text_field($_POST['searchTerm']);
84
+
85
+ $args = array(
86
+ 's' => $search,
87
+ 'post__in' => ! empty( $_REQUEST['include'] ) ? array_map( 'intval', $_REQUEST['include'] ) : null,
88
+ 'page' => ! empty( $_REQUEST['page'] ) ? absint( $_REQUEST['page'] ) : null,
89
+ 'posts_per_page' => 100,
90
+ 'post_type' => $postTypeName
91
+ );
92
+
93
+ $searchResults = AdminHelper::getPostTypeData($args);
94
+
95
+ if (empty($searchResults)) {
96
+ $results['items'] = array();
97
+ }
98
+
99
+ /*Selected custom post type convert for select2 format*/
100
+ foreach ($searchResults as $id => $name) {
101
+ $results['items'][] = array(
102
+ 'id' => $id,
103
+ 'text' => $name
104
+ );
105
+ }
106
+
107
+ echo json_encode($results);
108
+ wp_die();
109
+ }
110
+
111
+ public function conditionsRow() {
112
+ check_ajax_referer('ycd_ajax_nonce', 'nonce');
113
+ $selectedParams = sanitize_text_field($_POST['selectedParams']);
114
+ $conditionId = (int)$_POST['conditionId'];
115
+ $childClassName = $_POST['conditionsClassName'];
116
+ $childClassName = __NAMESPACE__.'\\'.$childClassName;
117
+ $obj = new $childClassName();
118
+
119
+ echo $obj->renderConditionRowFromParam($selectedParams, $conditionId);
120
+ wp_die();
121
+ }
122
  }
123
 
124
  new Ajax();
classes/Checker.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ycd;
3
+
4
+ class Checker
5
+ {
6
+ private $post;
7
+ private $countdownObj;
8
+
9
+ public function setPost($post) {
10
+ $this->post = $post;
11
+ }
12
+
13
+ public function getPost() {
14
+ return $this->post;
15
+ }
16
+
17
+ public function setCountdownObj($countdownObj) {
18
+ $this->countdownObj = $countdownObj;
19
+ }
20
+
21
+ public function getCountdownObj() {
22
+ return $this->countdownObj;
23
+ }
24
+
25
+ public static function isAllow($post, $countdownObj) {
26
+
27
+ if(empty($countdownObj) || !is_object($countdownObj)) {
28
+ return false;
29
+ }
30
+ if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
31
+ if(!CheckerPro::allowToShow($countdownObj)) {
32
+ return false;
33
+ }
34
+ }
35
+ $obj = new self();
36
+ $obj->setPost($post);
37
+ $obj->setCountdownObj($countdownObj);
38
+
39
+ if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
40
+ $allowOptionsToShow = CheckerPro::allowOptionsToShow($countdownObj);
41
+ if($allowOptionsToShow) {
42
+ return $allowOptionsToShow;
43
+ }
44
+ }
45
+
46
+ $allowDisplay = DisplayRuleChecker::isAllow($countdownObj);
47
+ if($allowDisplay) {
48
+ return true;
49
+ }
50
+
51
+ return false;
52
+ }
53
+
54
+ private function allowToLoad() {
55
+
56
+ }
57
+ }
classes/ConditionBuilder.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ycd;
3
+
4
+ class ConditionBuilder {
5
+
6
+ private $columnCount = 3;
7
+ private $valueFromFirst = true;
8
+ private $currentIndex;
9
+ private $nameString = '';
10
+ private $paramKey;
11
+ private $configData;
12
+
13
+ public function setColumnCount($columnCount) {
14
+ $this->columnCount = $columnCount;
15
+ }
16
+
17
+ public function getColumnCount() {
18
+ return $this->columnCount;
19
+ }
20
+
21
+ public function setValueFromFirst($valueFromFirst) {
22
+ $this->valueFromFirst = $valueFromFirst;
23
+ }
24
+
25
+ public function getValueFromFirst() {
26
+ return $this->valueFromFirst;
27
+ }
28
+
29
+ public function setSavedData($savedData) {
30
+ $this->savedData = $savedData;
31
+ }
32
+
33
+ public function getSavedData() {
34
+ return $this->savedData;
35
+ }
36
+
37
+ public function setConfigData($configData) {
38
+ $this->configData = $configData;
39
+ }
40
+
41
+ public function getConfigData() {
42
+ return $this->configData;
43
+ }
44
+
45
+ public function setCurrentIndex($currentIndex) {
46
+ $this->currentIndex = $currentIndex;
47
+ }
48
+
49
+ public function getCurrentIndex() {
50
+ return $this->currentIndex;
51
+ }
52
+
53
+ public function setNameString($nameString) {
54
+ $this->nameString = $nameString;
55
+ }
56
+
57
+ public function getNameString() {
58
+ return $this->nameString;
59
+ }
60
+
61
+ public function setParamKey($paramKey) {
62
+ $this->paramKey = $paramKey;
63
+ }
64
+
65
+ public function getParamKey() {
66
+ return $this->paramKey;
67
+ }
68
+
69
+ public function getChildClassName() {
70
+ $path = explode('\\', get_class($this));
71
+
72
+ return array_pop($path);
73
+ }
74
+
75
+ public function render() {
76
+ $childClassName = $this->getChildClassName();
77
+ $content = '<div class="ycd-conditions-wrapper" data-child-class="'.$childClassName.'">';
78
+ $content .= $this->renderConditions();
79
+ $content .= '</div>';
80
+
81
+ return $content;
82
+ }
83
+
84
+ private function renderConditions() {
85
+ $savedData = $this->getSavedData();
86
+
87
+ if(empty($savedData)) {
88
+ return '<div>'.__('No Data', YCD_TEXT_DOMAIN).'</div>';
89
+ }
90
+ $conditions = '';
91
+ foreach($savedData as $currentIndex => $data) {
92
+ $conditions .= $this->getConditionRowFromCurrentData($data, $currentIndex);
93
+ }
94
+
95
+ return $conditions;
96
+ }
97
+
98
+ private function getConditionRowFromCurrentData($data, $currentIndex) {
99
+ $conditions = '';
100
+ $configData = $this->getConfigData();
101
+
102
+ $configValues = $configData['values'];
103
+ $attributes = $configData['attributes'];
104
+ $valueFromFirst = $this->getValueFromFirst();
105
+ $savedData = $this->getSavedData();
106
+
107
+ $conditions = '<div class="ycd-condion-wrapper row form-group" data-value-from-first="'.$valueFromFirst.'" data-condition-id="'.esc_attr($currentIndex).'">';
108
+ if(empty($data['key3']) && isset($configData['values'][$data['key1']])) {
109
+ $data['key3'] = '';
110
+ }
111
+ $currentConditionIndex = 1;
112
+ foreach($data as $keyName => $value) {
113
+ $paramKey = $keyName;
114
+ // get 3th column key
115
+ if($currentConditionIndex > 1) {
116
+ if($valueFromFirst) {
117
+ if($keyName == 'key3') {
118
+ $paramKey = $data['key1'];
119
+ }
120
+ }
121
+ else {
122
+ $lastIndex = --$currentConditionIndex;
123
+ $paramKey = $data['key'.$lastIndex];
124
+ }
125
+ }
126
+ $this->setParamKey($paramKey);
127
+
128
+ if(empty($attributes[$paramKey])) {
129
+ continue;
130
+ }
131
+ ++$currentConditionIndex;
132
+ $this->setCurrentIndex($currentIndex);
133
+ $attributes[$paramKey]['savedValue'] = $value;
134
+
135
+ $conditions .= $this->renderCurrentConditionRow($configValues, $attributes, $keyName, $currentIndex);
136
+ }
137
+ $conditions .= $this->renderCondtionConfig($currentIndex, $data);
138
+ $conditions .= '</div>';
139
+
140
+ return $conditions;
141
+ }
142
+
143
+ public function renderCurrentConditionRow($configValues, $attributes, $keyName, $key) {
144
+ $paramKey = $this->getParamKey();
145
+ $nameString = $this->getNameString();
146
+ $name = $nameString.'['.$key.']['.$keyName.']';
147
+ $currentData = $configValues[$paramKey];
148
+ $currentAttributes = $attributes[$paramKey];
149
+ $conditions = $this->renderConditionRow($name, $currentData, $currentAttributes);
150
+
151
+ return $conditions;
152
+ }
153
+
154
+ private function renderConditionRow($name, $currentData, $attributes) {
155
+ $fieldHtml = '<div class="col-md-3">';
156
+
157
+ $fieldHtml .= $this->renderConditionRowHeader($name, $currentData, $attributes);
158
+ if($attributes['fieldType'] == 'select') {
159
+ $fieldAttributes = $attributes['fieldAttributes'];
160
+ if(!empty($fieldAttributes['multiple'])) {
161
+ $name .= '[]';
162
+ }
163
+ $fieldAttributes['name'] = $name;
164
+ $savedValue = $attributes['savedValue'];
165
+ if(!empty($fieldAttributes['data-select-type']) && $fieldAttributes['data-select-type'] == 'ajax') {
166
+ $currentData = $savedValue;
167
+ $savedValue = array_keys($savedValue);
168
+ }
169
+ $fieldHtml .= AdminHelper::selectBox($currentData, $savedValue, $fieldAttributes);
170
+ }
171
+ $fieldHtml .= '</div>';
172
+
173
+ return $fieldHtml;
174
+ }
175
+
176
+ private function renderConditionRowHeader($name, $currentData, $attributes) {
177
+ $fieldHtml = '<div class="ycd-condition-header">';
178
+
179
+ if(!empty($attributes['label'])) {
180
+ $fieldHtml .= '<label>'.__($attributes['label'], YCD_TEXT_DOMAIN).'</label>';
181
+ }
182
+ $fieldHtml .= '</div>';
183
+
184
+ return $fieldHtml;
185
+ }
186
+
187
+ private function renderCondtionConfig($currentConditionIndex, $data) {
188
+ if(empty($data) || $data['key1'] == 'select_settings') {
189
+ return '';
190
+ }
191
+ $html = '<div class="col-md-3"><div class="ycd-condition-header ycd-conditions-buttons"><label></label></div>';
192
+ $html .= '<div data-condition-id="'.esc_attr($currentConditionIndex).'" class="ycd-condition-add btn btn-primary">'.__('Add', YCD_TEXT_DOMAIN).'</div>';
193
+ $html .= '<div data-condition-id="'.esc_attr($currentConditionIndex).'" class="ycd-condition-delete btn btn-danger">'.__('Delete', YCD_TEXT_DOMAIN).'</div>';
194
+ $html .= '</div>';
195
+
196
+ return $html;
197
+ }
198
+
199
+ public function renderConditionRowFromParam($param, $currentIndex) {
200
+ $savedData = array(
201
+ 'key1' => $param,
202
+ 'key2' => '',
203
+ 'key3' => ''
204
+ );
205
+ if($param == 'select_settings') {
206
+ $savedData = array(
207
+ 'key1' => $param
208
+ );
209
+ }
210
+
211
+ return $this->getConditionRowFromCurrentData($savedData, $currentIndex);
212
+ }
213
+
214
+ public function filterForSave() {
215
+ $settings = $this->getSavedData();
216
+ $configData = $this->getConfigData();
217
+
218
+ $configValues = $configData['values'];
219
+ $attributes = $configData['attributes'];
220
+
221
+ foreach($settings as $index => $setting) {
222
+ $valueFromFirst = $this->getValueFromFirst();
223
+ $valueKey = $setting['key1'];
224
+ if (!$valueFromFirst) {
225
+ $valueKey = $setting['key2'];
226
+ }
227
+ if(empty($setting['key3'])) {
228
+ $settings[$index]['key3'] = array();
229
+ continue;
230
+ }
231
+ $currentAttributes = $attributes[$valueKey]['fieldAttributes'];
232
+ if(!empty($currentAttributes['data-select-type'])) {
233
+
234
+ $args = array(
235
+ 'post__in' => array_values($setting['key3']),
236
+ 'posts_per_page' => 10,
237
+ 'post_type' => $currentAttributes['data-post-type']
238
+ );
239
+
240
+ $searchResults = AdminHelper::getPostTypeData($args);
241
+ $settings[$index]['key3'] = $searchResults;
242
+ }
243
+ }
244
+
245
+ return $settings;
246
+ }
247
+ }
classes/DisplayConditionBuilder.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ycd;
3
+
4
+ class DisplayConditionBuilder extends ConditionBuilder {
5
+ public function __construct() {
6
+ global $YCD_DISPLAY_SETTINGS_CONFIG;
7
+ $configData = $YCD_DISPLAY_SETTINGS_CONFIG;
8
+ $this->setConfigData($configData);
9
+ $this->setNameString('ycd-display-settings');
10
+ }
11
+ }
classes/DisplayRuleChecker.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ycd;
3
+
4
+ class DisplayRuleChecker {
5
+ private $typeObj;
6
+
7
+ public function setTypeObj($typeObj) {
8
+ $this->typeObj = $typeObj;
9
+ }
10
+
11
+ public function getTypeObj() {
12
+ return $this->typeObj;
13
+ }
14
+
15
+ public static function isAllow($countdownObj) {
16
+ $obj = new self();
17
+ $obj->setTypeObj($countdownObj);
18
+ $isDisplayOn = $countdownObj->getOptionValue('ycd-countdown-display-on');
19
+
20
+ if(!$isDisplayOn) {
21
+ return $isDisplayOn;
22
+ }
23
+
24
+ $status = $obj->checkDisplaySettings();
25
+
26
+ return $status;
27
+ }
28
+
29
+ private function checkDisplaySettings() {
30
+ $countdownObj = $this->getTypeObj();
31
+
32
+ $settings = $countdownObj->getOptionValue('ycd-display-settings');
33
+
34
+ if(empty($settings)) {
35
+ return false;
36
+ }
37
+ $status = array();
38
+
39
+ foreach ($settings as $setting) {
40
+
41
+ if($setting['key1'] == 'everywhere') {
42
+ return true;
43
+ }
44
+
45
+ $isAllowSettings = $this->checkSetting($setting);
46
+ $status[] = $isAllowSettings;
47
+ }
48
+
49
+ return (in_array('is1', $status) && !in_array('isnot1', $status));
50
+ }
51
+
52
+ private function checkSetting($setting) {
53
+ global $post;
54
+ $post_type = get_post_type($post->ID);
55
+
56
+ if('selected_'.$post_type == $setting['key1']) {
57
+
58
+ if(in_array($post->ID, array_keys($setting['key3']))) {
59
+ return ($setting['key2'].'1');
60
+ }
61
+ return '';
62
+ }
63
+
64
+ if('all_'.$post_type == $setting['key1']) {
65
+ return ($setting['key2'].'1');
66
+ }
67
+
68
+ return '';
69
+ }
70
+ }
classes/IncludeManager.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ycd;
3
+ use \WP_Query;
4
+
5
+ class IncludeManager {
6
+
7
+ private $allowedCountdowns;
8
+
9
+ public function __construct() {
10
+ $this->init();
11
+ }
12
+
13
+ public function setAllowedCountdowns($allowedCountdowns)
14
+ {
15
+ $this->allowedCountdowns = $allowedCountdowns;
16
+ }
17
+
18
+ public function getAllowedCountdowns()
19
+ {
20
+ return $this->allowedCountdowns;
21
+ }
22
+
23
+ public function init() {
24
+ $countdownPosts = new WP_Query(
25
+ array(
26
+ 'post_type' => YCD_COUNTDOWN_POST_TYPE,
27
+ 'posts_per_page' => - 1
28
+ )
29
+ );
30
+ $posts = array();
31
+
32
+ while ($countdownPosts->have_posts()) {
33
+ $countdownPosts->next_post();
34
+ $countdownPost = $countdownPosts->post;
35
+
36
+ if (empty($countdownPost) || empty($countdownPost->ID) || !Countdown::isActivePost($countdownPost->ID)) {
37
+ continue;
38
+ }
39
+ $countdownObj = Countdown::find($countdownPost->ID);
40
+
41
+ if(empty($countdownObj) || !is_object($countdownObj)) {
42
+ continue;
43
+ }
44
+ $isAllow = Countdown::allowToLoad($countdownPost, $countdownObj);
45
+
46
+ if(!$isAllow) {
47
+ continue;
48
+ }
49
+
50
+ $posts[] = $countdownObj;
51
+ }
52
+ $this->setAllowedCountdowns($posts);
53
+ $this->includeCountdowns();
54
+ }
55
+
56
+ private function includeCountdowns() {
57
+ $countdowns = $this->getAllowedCountdowns();
58
+
59
+ if(empty($countdowns)) {
60
+ return false;
61
+ }
62
+
63
+ foreach($countdowns as $countdown) {
64
+ $this->includeCountdown($countdown);
65
+ }
66
+
67
+ return true;
68
+ }
69
+
70
+ private function includeCountdown($countdown) {
71
+ $content = $countdown->addToContent();
72
+
73
+ add_action('wp_head',function() use ($content) {
74
+ echo $content;
75
+ });
76
+ }
77
+ }
classes/countdown/CircleCountdown.php CHANGED
@@ -239,6 +239,26 @@ class CircleCountdown extends Countdown {
239
  echo $styles;
240
  }
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  public function getViewContent() {
243
  $this->includeStyles();
244
  $id = $this->getId();
@@ -267,9 +287,9 @@ class CircleCountdown extends Countdown {
267
  ob_get_clean();
268
  $content .= $this->renderProgressBar();
269
  $content .= $this->renderSubscriptionForm();
270
- $content .= '<div class="ycd-circle-after-countdown" data-key="'.YCD_AFTER_COUNTDOWN_KEY.'">'.$this->getOptionValue('ycd-circle-countdown-after-countdown').'</div>';
271
  $content .= '</div>';
272
 
273
- return $content;
274
  }
275
  }
239
  echo $styles;
240
  }
241
 
242
+ public function addToContent() {
243
+ add_filter('the_content', array($this, 'getTheContentFilter'),1, 1);
244
+ }
245
+
246
+ public function getTheContentFilter($content) {
247
+ $id = $this->getId();
248
+ $position = $this->getOptionValue('ycd-position-countdown');
249
+ $explodedData = explode( '_', $position);
250
+ $vertical = $explodedData[0];
251
+ $horizontal = $explodedData[1];
252
+
253
+ $countdownContent = $this->getViewContent();
254
+ $allContent = $content.$countdownContent;
255
+ if ($vertical == 'top') {
256
+ $allContent = $countdownContent.$content;
257
+ }
258
+ $allContent .= '<style>.ycd-circle-'.$id.'-wrapper {text-align: '.$horizontal.' !important;}</style>';
259
+ return $allContent;
260
+ }
261
+
262
  public function getViewContent() {
263
  $this->includeStyles();
264
  $id = $this->getId();
287
  ob_get_clean();
288
  $content .= $this->renderProgressBar();
289
  $content .= $this->renderSubscriptionForm();
290
+ $content .= '<div class="ycd-circle-after-countdown" data-key="">'.$this->getOptionValue('ycd-circle-countdown-after-countdown').'</div>';
291
  $content .= '</div>';
292
 
293
+ return $content;
294
  }
295
  }
classes/countdown/Countdown.php CHANGED
@@ -139,6 +139,7 @@ abstract class Countdown {
139
  if (empty($defaultData['type'])) {
140
  $defaultData['type'] = 'string';
141
  }
 
142
  $sanitizedValue = $obj->sanitizeValueByType($value, $defaultData['type']);
143
  $obj->insertIntoSanitizedData(array('name' => $name,'value' => $sanitizedValue));
144
  }
@@ -146,6 +147,21 @@ abstract class Countdown {
146
  $result = $obj->save();
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  public function save() {
150
  $options = $this->getSanitizedData();
151
  $postId = $this->getId();
@@ -340,6 +356,16 @@ abstract class Countdown {
340
  return $savedData;
341
  }
342
  $savedData = $savedData[0];
 
 
 
 
 
 
 
 
 
 
343
 
344
  return $savedData;
345
  }
@@ -561,7 +587,7 @@ abstract class Countdown {
561
  'minutes' => (int)$this->getOptionValue('ycd-countdown-duration-minutes'),
562
  'secondsSaved' => (int)$this->getOptionValue('ycd-countdown-duration-seconds')
563
  );
564
- $allSeconds = $this->gettProgressAllSeconds();
565
  $currentSeconds = $this->getProgressCurrentSeconds();
566
 
567
  $args = array(
@@ -709,7 +735,7 @@ abstract class Countdown {
709
  $type = $_GET['ycd_type'];
710
  }
711
 
712
- return $type;
713
  }
714
 
715
  public function isExpired() {
@@ -789,15 +815,15 @@ abstract class Countdown {
789
  }
790
 
791
  public function allowOpen() {
792
- $id = $this->getId();
793
- $status = true;
794
 
795
- if(!empty($_COOKIE['YcdDontShow'.$id]) && $this->getOptionValue('ycd-countdown-showing-limitation')) {
796
- $status = false;
797
- }
798
 
799
- return $status;
800
- }
801
 
802
  protected function scheduleOptions(&$options) {
803
  $modifiedObj = $this->getCircleSeconds();
139
  if (empty($defaultData['type'])) {
140
  $defaultData['type'] = 'string';
141
  }
142
+ $obj->saveConditionSettings($data);
143
  $sanitizedValue = $obj->sanitizeValueByType($value, $defaultData['type']);
144
  $obj->insertIntoSanitizedData(array('name' => $name,'value' => $sanitizedValue));
145
  }
147
  $result = $obj->save();
148
  }
149
 
150
+ private function saveConditionSettings($data) {
151
+ if(empty($data['ycd-display-settings'])) {
152
+ return '';
153
+ }
154
+
155
+ $postId = $this->getId();
156
+ $settings = $data['ycd-display-settings'];
157
+
158
+ $obj = new DisplayConditionBuilder();
159
+ $obj->setSavedData($settings);
160
+ $settings = $obj->filterForSave();
161
+
162
+ update_post_meta($postId, 'ycd-display-settings', $settings);
163
+ }
164
+
165
  public function save() {
166
  $options = $this->getSanitizedData();
167
  $postId = $this->getId();
356
  return $savedData;
357
  }
358
  $savedData = $savedData[0];
359
+ $displaySettings = self::getDisplaySettings($postId);
360
+ if(!empty($displaySettings)) {
361
+ $savedData['ycd-display-settings'] = $displaySettings;
362
+ }
363
+
364
+ return $savedData;
365
+ }
366
+
367
+ public static function getDisplaySettings($postId) {
368
+ $savedData = get_post_meta($postId, 'ycd-display-settings', true);
369
 
370
  return $savedData;
371
  }
587
  'minutes' => (int)$this->getOptionValue('ycd-countdown-duration-minutes'),
588
  'secondsSaved' => (int)$this->getOptionValue('ycd-countdown-duration-seconds')
589
  );
590
+ $allSeconds = $this->gettProgressAllSeconds();
591
  $currentSeconds = $this->getProgressCurrentSeconds();
592
 
593
  $args = array(
735
  $type = $_GET['ycd_type'];
736
  }
737
 
738
+ return $type;
739
  }
740
 
741
  public function isExpired() {
815
  }
816
 
817
  public function allowOpen() {
818
+ $id = $this->getId();
819
+ $status = true;
820
 
821
+ if(!empty($_COOKIE['YcdDontShow'.$id]) && $this->getOptionValue('ycd-countdown-showing-limitation')) {
822
+ $status = false;
823
+ }
824
 
825
+ return $status;
826
+ }
827
 
828
  protected function scheduleOptions(&$options) {
829
  $modifiedObj = $this->getCircleSeconds();
config/config.php CHANGED
@@ -55,13 +55,87 @@ class YcdCountdownConfig {
55
  self::addDefine('YCD_CRON_REPEAT_INTERVAL', 1);
56
  self::addDefine('YCD_AJAX_SUCCESS', 1);
57
  self::addDefine('YCD_TABLE_LIMIT', 15);
58
- self::addDefine('YCD_VERSION', 1.45);
59
- self::addDefine('YCD_VERSION_PRO', 1.29);
60
  self::addDefine('YCD_FREE_VERSION', 1);
61
  self::addDefine('YCD_SILVER_VERSION', 2);
62
  self::addDefine('YCD_GOLD_VERSION', 3);
63
  self::addDefine('YCD_PLATINUM_VERSION', 4);
64
  require_once(dirname(__FILE__).'/config-pkg.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
  public static function getVersionString() {
55
  self::addDefine('YCD_CRON_REPEAT_INTERVAL', 1);
56
  self::addDefine('YCD_AJAX_SUCCESS', 1);
57
  self::addDefine('YCD_TABLE_LIMIT', 15);
58
+ self::addDefine('YCD_VERSION', 1.46);
59
+ self::addDefine('YCD_VERSION_PRO', 1.3);
60
  self::addDefine('YCD_FREE_VERSION', 1);
61
  self::addDefine('YCD_SILVER_VERSION', 2);
62
  self::addDefine('YCD_GOLD_VERSION', 3);
63
  self::addDefine('YCD_PLATINUM_VERSION', 4);
64
  require_once(dirname(__FILE__).'/config-pkg.php');
65
+ self::displaySettings();
66
+ }
67
+
68
+ private static function displaySettings() {
69
+ global $YCD_DISPLAY_SETTINGS_CONFIG;
70
+ $keys = array(
71
+ 'select_settings' => 'Select settings',
72
+ 'everywhere' => 'Everywhere',
73
+ 'selected_post' => 'Select posts',
74
+ 'all_post' => 'All posts',
75
+ 'selected_page' => 'Select pages',
76
+ 'all_page' => 'All pages',
77
+ );
78
+
79
+ $values = array(
80
+ 'key1' => $keys,
81
+ 'key2' => array('is' => 'Is', 'isnot' => 'Is not'),
82
+ 'selected_post' => array(),
83
+ 'all_post' => array(),
84
+ 'selected_page' => array(),
85
+ 'all_page' => array(),
86
+ 'everywhere' => array()
87
+ );
88
+
89
+ $attributes = array(
90
+ 'key1' => array(
91
+ 'label' => __('Select Conditions'),
92
+ 'fieldType' => 'select',
93
+ 'fieldAttributes' => array(
94
+ 'class' => 'ycd-condition-select js-ycd-select js-conditions-param',
95
+ 'value' => ''
96
+ )
97
+ ),
98
+ 'key2' => array(
99
+ 'label' => __('Select Conditions'),
100
+ 'fieldType' => 'select',
101
+ 'fieldAttributes' => array(
102
+ 'class' => 'ycd-condition-select js-ycd-select',
103
+ 'value' => ''
104
+ )
105
+ ),
106
+ 'selected_post' => array(
107
+ 'label' => __('Select Post(s)'),
108
+ 'fieldType' => 'select',
109
+ 'fieldAttributes' => array(
110
+ 'data-post-type' => 'post',
111
+ 'data-select-type' => 'ajax',
112
+ 'multiple' => 'multiple',
113
+ 'class' => 'ycd-condition-select js-ycd-select',
114
+ 'value' => ''
115
+ )
116
+ ),
117
+ 'selected_page' => array(
118
+ 'label' => __('Select Page(s)'),
119
+ 'fieldType' => 'select',
120
+ 'fieldAttributes' => array(
121
+ 'data-post-type' => 'page',
122
+ 'data-select-type' => 'ajax',
123
+ 'multiple' => 'multiple',
124
+ 'class' => 'ycd-condition-select js-ycd-select',
125
+ 'value' => ''
126
+ )
127
+ ),
128
+ );
129
+
130
+ $keys = apply_filters('ycdConditionsDisplayKeys', $keys);
131
+ $values = apply_filters('ycdConditionsDisplayValues', $values);
132
+ $attributes = apply_filters('ycdConditionsDisplayAttributes', $attributes);
133
+
134
+ $YCD_DISPLAY_SETTINGS_CONFIG = array(
135
+ 'keys' => $keys,
136
+ 'values' => $values,
137
+ 'attributes' => $attributes
138
+ );
139
  }
140
 
141
  public static function getVersionString() {
config/optionsConfig.php CHANGED
@@ -202,6 +202,9 @@ class YcdCountdownOptionsConfig {
202
  $options[] = array('name' => 'ycd-circle-box-blur-radius', 'type' => 'text', 'defaultValue' => '5');
203
  $options[] = array('name' => 'ycd-circle-box-spread-radius', 'type' => 'text', 'defaultValue' => 1);
204
  $options[] = array('name' => 'ycd-circle-box-shadow-color', 'type' => 'text', 'defaultValue' => '#ffffff');
 
 
 
205
 
206
  $YCD_OPTIONS = apply_filters('ycdCountdownDefaultOptions', $options);
207
  }
202
  $options[] = array('name' => 'ycd-circle-box-blur-radius', 'type' => 'text', 'defaultValue' => '5');
203
  $options[] = array('name' => 'ycd-circle-box-spread-radius', 'type' => 'text', 'defaultValue' => 1);
204
  $options[] = array('name' => 'ycd-circle-box-shadow-color', 'type' => 'text', 'defaultValue' => '#ffffff');
205
+ $options[] = array('name' => 'ycd-display-settings', 'type' => 'ycd', 'defaultValue' => array(array('key1' => 'select_settings')));
206
+ $options[] = array('name' => 'ycd-countdown-display-on', 'type' => 'checkbox', 'defaultValue' => '');
207
+ $options[] = array('name' => 'ycd-position-countdown', 'type' => 'text', 'defaultValue' => 'top_center');
208
 
209
  $YCD_OPTIONS = apply_filters('ycdCountdownDefaultOptions', $options);
210
  }
countdown-builder.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Countdown builder
4
  * Description: The best countdown plugin
5
- * Version: 1.4.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.4.6
6
  * Author: Adam Skaat
7
  * Author URI: https://edmonsoft.com/countdown
8
  * License: GPLv2
helpers/AdminHelper.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  namespace ycd;
 
3
 
4
  class AdminHelper {
5
 
@@ -459,6 +460,15 @@ class AdminHelper {
459
  'right' => __('Right', YCD_TEXT_DOMAIN)
460
  );
461
 
 
 
 
 
 
 
 
 
 
462
  $data['userRoles'] = self::getAllUserRoles();
463
  $data['countries-names'] = apply_filters('ycdCountries', array());
464
  $data['countries-is'] = array(
@@ -1023,4 +1033,34 @@ class AdminHelper {
1023
 
1024
  return $dayOfWeek;
1025
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1026
  }
1
  <?php
2
  namespace ycd;
3
+ use \WP_Query;
4
 
5
  class AdminHelper {
6
 
460
  'right' => __('Right', YCD_TEXT_DOMAIN)
461
  );
462
 
463
+ $data['position-countdown'] = array(
464
+ 'top_left' => __('Top Left', YCD_TEXT_DOMAIN),
465
+ 'top_center' => __('Top Center', YCD_TEXT_DOMAIN),
466
+ 'top_right' => __('Top Right', YCD_TEXT_DOMAIN),
467
+ 'bottom_left' => __('Bottom Left', YCD_TEXT_DOMAIN),
468
+ 'bottom_center' => __('Bottom Center', YCD_TEXT_DOMAIN),
469
+ 'bottom_right' => __('Bottom Right', YCD_TEXT_DOMAIN),
470
+ );
471
+
472
  $data['userRoles'] = self::getAllUserRoles();
473
  $data['countries-names'] = apply_filters('ycdCountries', array());
474
  $data['countries-is'] = array(
1033
 
1034
  return $dayOfWeek;
1035
  }
1036
+
1037
+ public static function getPostTypeData($args = array())
1038
+ {
1039
+ $query = self::getQueryDataByArgs($args);
1040
+
1041
+ $posts = array();
1042
+ foreach ($query->posts as $post) {
1043
+ $posts[$post->ID] = $post->post_title;
1044
+ }
1045
+
1046
+ return $posts;
1047
+ }
1048
+
1049
+ public static function getQueryDataByArgs($args = array())
1050
+ {
1051
+ $defaultArgs = array(
1052
+ 'offset' => 0,
1053
+ 'orderby' => 'date',
1054
+ 'order' => 'DESC',
1055
+ 'post_status' => 'publish',
1056
+ 'suppress_filters' => true,
1057
+ 'post_type' => 'post',
1058
+ 'posts_per_page' => 1000
1059
+ );
1060
+
1061
+ $args = wp_parse_args($args, $defaultArgs);
1062
+ $query = new WP_Query($args);
1063
+
1064
+ return $query;
1065
+ }
1066
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: adamskaat
3
  Tags: countdown, timer, countdown timer
4
  Requires at least: 3.8
5
- Tested up to: 5.1.1
6
- Stable tag: 1.4.5
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -64,6 +64,10 @@ You need to select the .zip file, there is no need to extract the zip file, just
64
 
65
 
66
  == Changelog ==
 
 
 
 
67
  = 1.4.5 =
68
  * Countdown Showing Limitation (new feature)
69
  * Countdown Showing Animation (new feature)
2
  Contributors: adamskaat
3
  Tags: countdown, timer, countdown timer
4
  Requires at least: 3.8
5
+ Tested up to: 5.2
6
+ Stable tag: 1.4.6
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
64
 
65
 
66
  == Changelog ==
67
+ = 1.4.6 =
68
+ * Display Countdown to Everyver automatically (new feature)
69
+ * Circle Countdown responsiveness improvement
70
+
71
  = 1.4.5 =
72
  * Countdown Showing Limitation (new feature)
73
  * Countdown Showing Animation (new feature)