| 1 |
<?php |
| 2 |
|
| 3 |
namespace King_Addons\Animations; |
| 4 |
|
| 5 |
use Elementor\Base_Data_Control; |
| 6 |
|
| 7 |
if (!defined('ABSPATH')) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
class Animations extends Base_Data_Control |
| 12 |
{ |
| 13 |
private static array $_animations = []; |
| 14 |
|
| 15 |
private static array $pro_animations = [ |
| 16 |
'Fade' => [ |
| 17 |
'fade-in' => 'Fade In', |
| 18 |
'fade-out' => 'Fade Out', |
| 19 |
], |
| 20 |
'Slide' => [ |
| 21 |
'pro-sltp' => 'Slide Top (Pro)', |
| 22 |
'pro-slrt' => 'Slide Right (Pro)', |
| 23 |
'pro-slxrt' => 'Slide X Right (Pro)', |
| 24 |
'pro-slbt' => 'Slide Bottom (Pro)', |
| 25 |
'pro-sllt' => 'Slide Left (Pro)', |
| 26 |
'pro-slxlt' => 'Slide X Left (Pro)', |
| 27 |
], |
| 28 |
'Skew' => [ |
| 29 |
'pro-sktp' => 'Skew Top (Pro)', |
| 30 |
'pro-skrt' => 'Skew Right (Pro)', |
| 31 |
'pro-skbt' => 'Skew Bottom (Pro)', |
| 32 |
'pro-sklt' => 'Skew Left (Pro)', |
| 33 |
], |
| 34 |
'Scale' => [ |
| 35 |
'pro-scup' => 'Scale Up (Pro)', |
| 36 |
'pro-scdn' => 'Scale Down (Pro)', |
| 37 |
], |
| 38 |
'Roll' => [ |
| 39 |
'pro-rllt' => 'Roll Left (Pro)', |
| 40 |
'pro-rlrt' => 'Roll Right (Pro)', |
| 41 |
], |
| 42 |
]; |
| 43 |
|
| 44 |
private static array $free_animations = [ |
| 45 |
'Fade' => [ |
| 46 |
'fade-in' => 'Fade In', |
| 47 |
'fade-out' => 'Fade Out', |
| 48 |
], |
| 49 |
'Slide' => [ |
| 50 |
'slide-top' => 'Slide Top', |
| 51 |
'slide-right' => 'Slide Right', |
| 52 |
'slide-x-right' => 'Slide X Right', |
| 53 |
'slide-bottom' => 'Slide Bottom', |
| 54 |
'slide-left' => 'Slide Left', |
| 55 |
'slide-x-left' => 'Slide X Left', |
| 56 |
], |
| 57 |
'Skew' => [ |
| 58 |
'skew-top' => 'Skew Top', |
| 59 |
'skew-right' => 'Skew Right', |
| 60 |
'skew-bottom' => 'Skew Bottom', |
| 61 |
'skew-left' => 'Skew Left', |
| 62 |
], |
| 63 |
'Scale' => [ |
| 64 |
'scale-up' => 'Scale Up', |
| 65 |
'scale-down' => 'Scale Down', |
| 66 |
], |
| 67 |
'Roll' => [ |
| 68 |
'roll-left' => 'Roll Left', |
| 69 |
'roll-right' => 'Roll Right', |
| 70 |
], |
| 71 |
]; |
| 72 |
|
| 73 |
public function get_type(): string |
| 74 |
{ |
| 75 |
return 'king-addons-animations'; |
| 76 |
} |
| 77 |
|
| 78 |
public static function get_animations(): array |
| 79 |
{ |
| 80 |
self::$_animations = king_addons_freemius()->can_use_premium_code__premium_only() |
| 81 |
? self::$free_animations |
| 82 |
: self::$pro_animations; |
| 83 |
|
| 84 |
return self::$_animations; |
| 85 |
} |
| 86 |
|
| 87 |
public function content_template(): void |
| 88 |
{ |
| 89 |
$control_uid = $this->get_control_uid(); ?> |
| 90 |
<div class="elementor-control-field"> |
| 91 |
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title"> |
| 92 |
{{{ data.label }}} |
| 93 |
</label> |
| 94 |
<div class="elementor-control-input-wrapper"> |
| 95 |
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}"> |
| 96 |
<option value="none"><?php echo esc_html__('None', 'king-addons'); ?></option> |
| 97 |
<?php foreach (self::get_animations() as $group_name => $animations_group) : ?> |
| 98 |
<optgroup label="<?php echo esc_attr($group_name); ?>"> |
| 99 |
<?php foreach ($animations_group as $animation_key => $animation_val) : ?> |
| 100 |
<option value="<?php echo esc_attr($animation_key); ?>"> |
| 101 |
<?php echo esc_html($animation_val); ?> |
| 102 |
</option> |
| 103 |
<?php endforeach; ?> |
| 104 |
</optgroup> |
| 105 |
<?php endforeach; ?> |
| 106 |
</select> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
<# if ( data.description ) { #> |
| 110 |
<div class="elementor-control-field-description"> |
| 111 |
{{{ data.description }}} |
| 112 |
</div> |
| 113 |
<# } #> |
| 114 |
<?php } |
| 115 |
} |
| 116 |
|
| 117 |
class Animations_Alternative extends Animations |
| 118 |
{ |
| 119 |
public function get_type(): string |
| 120 |
{ |
| 121 |
return 'king-addons-animations-alt'; |
| 122 |
} |
| 123 |
|
| 124 |
public function content_template(): void |
| 125 |
{ |
| 126 |
$animations = self::get_animations(); |
| 127 |
$control_uid = $this->get_control_uid(); |
| 128 |
|
| 129 |
unset($animations['Slide']['slide-x-right'], $animations['Slide']['slide-x-left']); |
| 130 |
?> |
| 131 |
<div class="elementor-control-field"> |
| 132 |
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title"> |
| 133 |
{{{ data.label }}} |
| 134 |
</label> |
| 135 |
<div class="elementor-control-input-wrapper"> |
| 136 |
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}"> |
| 137 |
<option value="none"><?php echo esc_html__('None', 'king-addons'); ?></option> |
| 138 |
<?php foreach ($animations as $group_name => $animations_group) : ?> |
| 139 |
<optgroup label="<?php echo esc_attr($group_name); ?>"> |
| 140 |
<?php foreach ($animations_group as $animation_key => $animation_val) : ?> |
| 141 |
<option value="<?php echo esc_attr($animation_key); ?>"> |
| 142 |
<?php echo esc_html($animation_val); ?> |
| 143 |
</option> |
| 144 |
<?php endforeach; ?> |
| 145 |
</optgroup> |
| 146 |
<?php endforeach; ?> |
| 147 |
</select> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
<# if ( data.description ) { #> |
| 151 |
<div class="elementor-control-field-description"> |
| 152 |
{{{ data.description }}} |
| 153 |
</div> |
| 154 |
<# } #> |
| 155 |
<?php } |
| 156 |
} |