| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 2.1.14 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2024 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Blocks\Generic; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
class Countdown extends \FireBox\Core\Blocks\Block |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Block identifier. |
| 23 |
* |
| 24 |
* @var string |
| 25 |
*/ |
| 26 |
protected $name = 'countdown'; |
| 27 |
|
| 28 |
/** |
| 29 |
* Callback |
| 30 |
* |
| 31 |
* @param array $attributes |
| 32 |
* @param string $content |
| 33 |
* |
| 34 |
* @return mixed |
| 35 |
*/ |
| 36 |
public function render_callback($attributes, $content) |
| 37 |
{ |
| 38 |
if (!class_exists('\FPFramework\Base\Widgets\Helper')) |
| 39 |
{ |
| 40 |
return; |
| 41 |
} |
| 42 |
|
| 43 |
if (!isset($attributes['value'])) |
| 44 |
{ |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
$payload = [ |
| 49 |
'countdown_type' => $attributes['countdownType'], |
| 50 |
'value' => $attributes['value'], |
| 51 |
'timezone' => $attributes['timezone'], |
| 52 |
'dynamic_days' => $attributes['dynamicDays'], |
| 53 |
'dynamic_hours' => $attributes['dynamicHours'], |
| 54 |
'dynamic_minutes' => $attributes['dynamicMinutes'], |
| 55 |
'dynamic_seconds' => $attributes['dynamicSeconds'], |
| 56 |
'digits_wrapper_padding' => $attributes['digitsWrapperPadding'], |
| 57 |
'digits_wrapper_background_color' => $attributes['digitsWrapperBackgroundColor'], |
| 58 |
'digits_wrapper_border_radius' => $attributes['digitsWrapperBorderRadius'], |
| 59 |
'finish_text' => $attributes['finishText'], |
| 60 |
'redirect_url' => $attributes['redirectURL'], |
| 61 |
'countdown_action' => $attributes['countdownAction'], |
| 62 |
'theme' => $attributes['theme'], |
| 63 |
'format' => $attributes['format'], |
| 64 |
'days' => $attributes['days'], |
| 65 |
'days_label' => $attributes['daysLabel'], |
| 66 |
'hours' => $attributes['hours'], |
| 67 |
'hours_label' => $attributes['hoursLabel'], |
| 68 |
'minutes' => $attributes['minutes'], |
| 69 |
'minutes_label' => $attributes['minutesLabel'], |
| 70 |
'seconds' => $attributes['seconds'], |
| 71 |
'seconds_label' => $attributes['secondsLabel'], |
| 72 |
'background_color' => $attributes['backgroundColor'], |
| 73 |
'item_background_color' => $attributes['itemBackgroundColor'], |
| 74 |
'unit_label_text_color' => $attributes['unitLabelTextColor'], |
| 75 |
'digit_background_color' => $attributes['digitBackgroundColor'], |
| 76 |
'digit_text_color' => $attributes['digitTextColor'], |
| 77 |
'unit_label_margin_top' => $attributes['unitLabelMarginTop'], |
| 78 |
'separator' => $attributes['separator'], |
| 79 |
'double_zeroes_format' => $attributes['doubleZeroesFormat'], |
| 80 |
'align' => $attributes['align'], |
| 81 |
'margin' => $attributes['margin'], |
| 82 |
'padding' => $attributes['padding'], |
| 83 |
'gap' => $attributes['gap'], |
| 84 |
'digits_gap' => $attributes['digitsGap'], |
| 85 |
'item_size' => $attributes['itemSize'], |
| 86 |
'item_border_color' => $attributes['itemBorderColor'], |
| 87 |
'item_border_width' => $attributes['itemBorderWidth'], |
| 88 |
'item_border_style' => $attributes['itemBorderStyle'], |
| 89 |
'item_border_radius' => $attributes['itemBorderRadius'], |
| 90 |
'digits_padding' => $attributes['digitsPadding'], |
| 91 |
'digits_wrapper_min_width' => $attributes['digitsWrapperMinWidth'], |
| 92 |
'digit_min_width' => $attributes['digitMinWidth'], |
| 93 |
'digit_border_radius' => $attributes['digitBorderRadius'], |
| 94 |
'digits_font_size' => $attributes['digitsFontSize'], |
| 95 |
'label_font_size' => $attributes['labelFontSize'], |
| 96 |
'digits_font_weight' => $attributes['digitsFontWeight'], |
| 97 |
'label_font_weight' => $attributes['labelFontWeight'], |
| 98 |
]; |
| 99 |
|
| 100 |
return \FPFramework\Base\Widgets\Helper::render('Countdown', $payload); |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Registers assets both on front-end and back-end. |
| 105 |
* |
| 106 |
* @return void |
| 107 |
*/ |
| 108 |
public function assets() |
| 109 |
{ |
| 110 |
\FPFramework\Base\Widgets\Countdown::register_assets(); |
| 111 |
\FPFramework\Base\Widgets\Countdown::localize_script(); |
| 112 |
|
| 113 |
wp_enqueue_script('fpframework-countdown-widget'); |
| 114 |
} |
| 115 |
} |