| 1 |
<?php |
| 2 |
/** |
| 3 |
* Counter script generation |
| 4 |
* |
| 5 |
* @package WP_Plugin |
| 6 |
* @copyright Copyright (c) 2018, Dmytro Lobov |
| 7 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 8 |
* @since 1.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
$script['selector'] = '.counter-box-' . $id; |
| 16 |
$script['type'] = $param['type']; |
| 17 |
|
| 18 |
if ( $param['type'] === 'CountToDate' || $param['type'] === 'ContFromDate' || $param['type'] === 'CountToWeekday' ) { |
| 19 |
|
| 20 |
$script['date_options'] = [ |
| 21 |
'date' => ( $param['type'] === 'CountToWeekday' ) ? $param['dayweek'] : $param['date'], |
| 22 |
'time' => $param['time'], |
| 23 |
'timezone' => $param['timezone'], |
| 24 |
]; |
| 25 |
} elseif ( $param['type'] === 'Timer' || $param['type'] === 'UserTimer' || $param['type'] === 'TimerStopGo' ) { |
| 26 |
$script['timer_options'] = [ |
| 27 |
'day' => $param['day'], |
| 28 |
'hours' => $param['hours'], |
| 29 |
'minutes' => $param['minutes'], |
| 30 |
'seconds' => $param['seconds'], |
| 31 |
]; |
| 32 |
} elseif ( $param['type'] === 'Counter' ) { |
| 33 |
$script['counter_options'] = [ |
| 34 |
'start' => $param['start'], |
| 35 |
'finish' => $param['finish'], |
| 36 |
'speed' => [ |
| 37 |
'min' => $param['speed_min'], |
| 38 |
'max' => $param['speed_max'], |
| 39 |
], |
| 40 |
'increment' => [ |
| 41 |
'min' => $param['increment_min'], |
| 42 |
'max' => $param['increment_max'], |
| 43 |
], |
| 44 |
'round' => $param['rounding'], |
| 45 |
'delimiter' => empty( $param['delimiter'] ) ? '0' : $param['delimiter'], |
| 46 |
'remember' => empty( $param['remember'] ) ? '0' : $param['remember'], |
| 47 |
]; |
| 48 |
} |
| 49 |
|
| 50 |
$script['targets'] = []; |
| 51 |
|
| 52 |
if ( ! empty( $param['hideCounter'] ) ) { |
| 53 |
$script['targets']['hideCounter'] = '1'; |
| 54 |
} |
| 55 |
|
| 56 |
if ( ! empty( $param['showMessage'] ) ) { |
| 57 |
$script['targets']['showMessage'] = $param['message']; |
| 58 |
} |
| 59 |
|
| 60 |
if ( ! empty( $param['hideBlock_checkbox'] ) ) { |
| 61 |
$script['targets']['hideBlock'] = $param['hideBlock']; |
| 62 |
} |
| 63 |
|
| 64 |
if ( ! empty( $param['showBlock_checkbox'] ) ) { |
| 65 |
$script['targets']['showBlock'] = $param['showBlock']; |
| 66 |
} |
| 67 |
|
| 68 |
if ( ! empty( $param['redirect_checkbox'] ) ) { |
| 69 |
$script['targets']['redirect'] = $param['redirect']; |
| 70 |
} |
| 71 |
|
| 72 |
if ( ! empty( $param['action_checkbox'] ) ) { |
| 73 |
$script['targets']['action'] = $param['action']; |
| 74 |
} |
| 75 |
|
| 76 |
$script['container_css'] = ''; |
| 77 |
$script['number_css'] = ''; |
| 78 |
|
| 79 |
if ( ! empty( $param['width_unit'] ) && $param['width_unit'] !== 'auto' ) { |
| 80 |
$script['number_css'] .= 'width:' . $param['width'] . 'px;'; |
| 81 |
} |
| 82 |
|
| 83 |
if ( ! empty( $param['height_unit'] ) && $param['height_unit'] !== 'auto' ) { |
| 84 |
$script['number_css'] .= 'height:' . $param['height'] . 'px;'; |
| 85 |
$script['number_css'] .= 'line-height:' . $param['height'] . 'px;'; |
| 86 |
} |
| 87 |
|
| 88 |
if ( ! empty( $param['background'] ) ) { |
| 89 |
$script['number_css'] .= 'background:' . $param['background'] . ';'; |
| 90 |
} |
| 91 |
|
| 92 |
if ( ! empty( $param['border_radius'] ) ) { |
| 93 |
$script['number_css'] .= 'border-radius:' . $param['border_radius'] . 'px;'; |
| 94 |
} |
| 95 |
|
| 96 |
if ( ! empty( $param['border_style'] ) && $param['border_style'] !== 'none' ) { |
| 97 |
$script['number_css'] .= 'border-style:' . $param['border_style'] . ';'; |
| 98 |
$script['number_css'] .= 'border-width:' . $param['border_width'] . ';'; |
| 99 |
$script['number_css'] .= 'border-color:' . $param['border_color'] . ';'; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|