PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Types/DelayType.php +75 -80 10.1.4 → 11.1.0 View file →
@@ -5,102 +5,97 @@
5 5 use AcyMailing\Core\AcymObject;
6 6
7 7 class DelayType extends AcymObject
8 8 {
9 - var $values = [];
10 - var $num = 0;
11 - var $onChange = '';
9 + const TYPE_SECONDS_MINUTES = 0;
10 + const TYPE_MINUTES_HOURS_DAYS_WEEKS = 1;
11 + const TYPE_MINUTES_HOURS = 2;
12 + const TYPE_HOURS_DAYS_WEEKS_MONTHS = 3;
13 + const TYPE_WEEKS_MONTHS = 4;
12 14
13 - public function display($map, $value, $type = 1, $num = '', $inputClass = '', $hiddenInputClass = '')
14 - {
15 - static $i = 0;
16 - $i++;
17 - $this->num = $i;
15 + public function display(
16 + string $map,
17 + int $value,
18 + int $type = 1,
19 + string $inputClass = '',
20 + string $hiddenInputClass = ''
21 + ): void {
22 + static $num = 0;
23 + $num++;
18 24
19 - if (empty($num)) {
20 - $js = '
21 - function updateDelay'.$this->num.'(){
22 - delayvar = window.document.getElementById("delayvar'.$this->num.'");
23 - delaytype = window.document.getElementById("delaytype'.$this->num.'").value;
24 - delayvalue = window.document.getElementById("delayvalue'.$this->num.'");
25 - realValue = delayvalue.value;
26 - if(delaytype == "minute"){ realValue = realValue*60; }
27 - if(delaytype == "hour"){ realValue = realValue*3600; }
28 - if(delaytype == "day"){ realValue = realValue*86400; }
29 - if(delaytype == "week"){ realValue = realValue*604800; }
30 - if(delaytype == "month"){ realValue = realValue*2592000; }
31 - delayvar.value = realValue;
32 - delayvar.dispatchEvent(new Event("change"));
33 - }';
34 - $updateFunction = 'updateDelay'.$this->num.'();';
35 - } else {
36 - $js = '
37 - function updateDelayNum(num){
38 - delayvar = window.document.getElementById("delayvar"+num);
39 - delaytype = window.document.getElementById("delaytype"+num).value;
40 - delayvalue = window.document.getElementById("delayvalue"+num);
41 - realValue = delayvalue.value;
42 - if(delaytype == "minute"){ realValue = realValue*60; }
43 - if(delaytype == "hour"){ realValue = realValue*3600; }
44 - if(delaytype == "day"){ realValue = realValue*86400; }
45 - if(delaytype == "week"){ realValue = realValue*604800; }
46 - if(delaytype == "month"){ realValue = realValue*2592000; }
47 - delayvar.value = realValue;
48 - }';
49 - $updateFunction = 'updateDelayNum(\''.$num.'\');';
50 - $this->num = $num;
51 - }
25 + $js = '
26 + function updateDelay'.$num.'() {
27 + delayvar = window.document.getElementById("delayvar'.$num.'");
28 + delaytype = window.document.getElementById("delaytype'.$num.'").value;
29 + delayvalue = window.document.getElementById("delayvalue'.$num.'");
30 + realValue = delayvalue.value;
31 + if(delaytype === "minute"){ realValue = realValue*60; }
32 + if(delaytype === "hour"){ realValue = realValue*3600; }
33 + if(delaytype === "day"){ realValue = realValue*86400; }
34 + if(delaytype === "week"){ realValue = realValue*604800; }
35 + if(delaytype === "month"){ realValue = realValue*2592000; }
36 + delayvar.value = realValue;
37 + delayvar.dispatchEvent(new Event("change"));
38 + }';
39 + $updateFunction = 'updateDelay'.$num.'();';
52 40 acym_addScript(true, $js);
53 41
54 - $this->values = [];
42 + $values = [];
55 43
56 - if ($type == 0) {
57 - $this->values[] = acym_selectOption('second', 'ACYM_SECONDS');
58 - $this->values[] = acym_selectOption('minute', 'ACYM_MINUTES');
59 - } elseif ($type == 1) {
60 - $this->values[] = acym_selectOption('minute', 'ACYM_MINUTES');
61 - $this->values[] = acym_selectOption('hour', 'ACYM_HOURS');
62 - $this->values[] = acym_selectOption('day', 'ACYM_DAYS');
63 - $this->values[] = acym_selectOption('week', 'ACYM_WEEKS');
64 - } elseif ($type == 2) {
65 - $this->values[] = acym_selectOption('minute', 'ACYM_MINUTES');
66 - $this->values[] = acym_selectOption('hour', 'ACYM_HOURS');
67 - } elseif ($type == 3) {
68 - $this->values[] = acym_selectOption('hour', 'ACYM_HOURS');
69 - $this->values[] = acym_selectOption('day', 'ACYM_DAYS');
70 - $this->values[] = acym_selectOption('week', 'ACYM_WEEKS');
71 - $this->values[] = acym_selectOption('month', 'ACYM_MONTHS');
72 - } elseif ($type == 4) {
73 - $this->values[] = acym_selectOption('week', 'ACYM_WEEKS');
74 - $this->values[] = acym_selectOption('month', 'ACYM_MONTHS');
44 + if ($type === self::TYPE_SECONDS_MINUTES) {
45 + $values[] = acym_selectOption('second', 'ACYM_SECONDS');
46 + $values[] = acym_selectOption('minute', 'ACYM_MINUTES');
47 + } elseif ($type === self::TYPE_MINUTES_HOURS_DAYS_WEEKS) {
48 + $values[] = acym_selectOption('minute', 'ACYM_MINUTES');
49 + $values[] = acym_selectOption('hour', 'ACYM_HOURS');
50 + $values[] = acym_selectOption('day', 'ACYM_DAYS');
51 + $values[] = acym_selectOption('week', 'ACYM_WEEKS');
52 + } elseif ($type === self::TYPE_MINUTES_HOURS) {
53 + $values[] = acym_selectOption('minute', 'ACYM_MINUTES');
54 + $values[] = acym_selectOption('hour', 'ACYM_HOURS');
55 + } elseif ($type === self::TYPE_HOURS_DAYS_WEEKS_MONTHS) {
56 + $values[] = acym_selectOption('hour', 'ACYM_HOURS');
57 + $values[] = acym_selectOption('day', 'ACYM_DAYS');
58 + $values[] = acym_selectOption('week', 'ACYM_WEEKS');
59 + $values[] = acym_selectOption('month', 'ACYM_MONTHS');
60 + } elseif ($type === self::TYPE_WEEKS_MONTHS) {
61 + $values[] = acym_selectOption('week', 'ACYM_WEEKS');
62 + $values[] = acym_selectOption('month', 'ACYM_MONTHS');
75 63 }
76 64
65 + $return = $this->get($value, $type);
66 + echo '<input class="intext_input '.esc_attr($inputClass).'"
67 + onchange="'.esc_attr($updateFunction).'"
68 + type="number"
69 + min="0"
70 + id="delayvalue'.esc_attr($num).'"
71 + value="'.esc_attr($return->value).'" /> ';
77 72
78 - $return = $this->get($value, $type);
79 - $delayValue = '<input class="intext_input '.$inputClass.'" onchange="'.$updateFunction.$this->onChange.'" type="number" min="0" id="delayvalue'.$this->num.'" value="'.$return->value.'" /> ';
80 - $delayVar = '<input class="'.$hiddenInputClass.'" type="hidden" name="'.$map.'" id="delayvar'.$this->num.'" value="'.$value.'"/>';
73 + acym_select(
74 + $values,
75 + 'delaytype'.$num,
76 + $return->type,
77 + [
78 + 'class' => 'intext_select',
79 + 'onchange' => $updateFunction,
80 + ],
81 + 'value',
82 + 'text',
83 + 'delaytype'.$num,
84 + false,
85 + true
86 + );
81 87
82 - return $delayValue.acym_select(
83 - $this->values,
84 - 'delaytype'.$this->num,
85 - $return->type,
86 - [
87 - 'class' => 'intext_select',
88 - 'onchange' => $updateFunction.$this->onChange,
89 - ],
90 - 'value',
91 - 'text',
92 - 'delaytype'.$this->num
93 - ).$delayVar;
88 + echo '<input class="'.esc_attr($hiddenInputClass).'" type="hidden" name="'.esc_attr($map).'" id="delayvar'.esc_attr($num).'" value="'.esc_attr($value).'"/>';
94 89 }
95 90
96 - public function get($value, $type)
91 + public function get(int $value, int $type): object
97 92 {
98 93
99 94 $return = new \stdClass();
100 95
101 96 $return->value = $value;
102 - if ($type == 0) {
97 + if ($type === 0) {
103 98 $return->type = 'second';
104 99 $return->typeText = acym_translation('ACYM_SECONDS');
105 100 } else {
106 101 $return->type = 'minute';
@@ -110,13 +105,13 @@
110 105 if ($return->value >= 60 && $return->value % 60 == 0) {
111 106 $return->value = (int)$return->value / 60;
112 107 $return->type = 'minute';
113 108 $return->typeText = acym_translation('ACYM_MINUTES');
114 - if ($type != 0 && $return->value >= 60 && $return->value % 60 == 0) {
109 + if ($type !== 0 && $return->value >= 60 && $return->value % 60 == 0) {
115 110 $return->type = 'hour';
116 111 $return->typeText = acym_translation('ACYM_HOURS');
117 112 $return->value = $return->value / 60;
118 - if ($type != 2 && $return->value >= 24 && $return->value % 24 == 0) {
113 + if ($type !== 2 && $return->value >= 24 && $return->value % 24 == 0) {
119 114 $return->type = 'day';
120 115 $return->typeText = acym_translation('ACYM_DAYS');
121 116 $return->value = $return->value / 24;
122 117 if ($type >= 3 && $return->value >= 30 && $return->value % 30 == 0) {