| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor box shadow control. |
| 10 |
* |
| 11 |
* A base control for creating box shadows control. Displays input fields for |
| 12 |
* horizontal shadow, vertical shadow, shadow blur, shadow spread and shadow |
| 13 |
* color. |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
*/ |
| 17 |
class Control_Box_Shadow extends Control_Base_Multiple { |
| 18 |
|
| 19 |
/** |
| 20 |
* Get box shadow control type. |
| 21 |
* |
| 22 |
* Retrieve the control type, in this case `box_shadow`. |
| 23 |
* |
| 24 |
* @since 1.0.0 |
| 25 |
* @access public |
| 26 |
* |
| 27 |
* @return string Control type. |
| 28 |
*/ |
| 29 |
public function get_type() { |
| 30 |
return 'box_shadow'; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Get box shadow control default value. |
| 35 |
* |
| 36 |
* Retrieve the default value of the box shadow control. Used to return the |
| 37 |
* default values while initializing the box shadow control. |
| 38 |
* |
| 39 |
* @since 1.0.0 |
| 40 |
* @access public |
| 41 |
* |
| 42 |
* @return array Control default value. |
| 43 |
*/ |
| 44 |
public function get_default_value() { |
| 45 |
return [ |
| 46 |
'horizontal' => 0, |
| 47 |
'vertical' => 0, |
| 48 |
'blur' => 10, |
| 49 |
'spread' => 0, |
| 50 |
'color' => 'rgba(0,0,0,0.5)', |
| 51 |
]; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Get box shadow control sliders. |
| 56 |
* |
| 57 |
* Retrieve the sliders of the box shadow control. Sliders are used while |
| 58 |
* rendering the control output in the editor. |
| 59 |
* |
| 60 |
* @since 1.0.0 |
| 61 |
* @access public |
| 62 |
* |
| 63 |
* @return array Control sliders. |
| 64 |
*/ |
| 65 |
public function get_sliders() { |
| 66 |
return [ |
| 67 |
'horizontal' => [ |
| 68 |
'label' => __( 'Horizontal', 'elementor' ), |
| 69 |
'min' => -100, |
| 70 |
'max' => 100, |
| 71 |
], |
| 72 |
'vertical' => [ |
| 73 |
'label' => __( 'Vertical', 'elementor' ), |
| 74 |
'min' => -100, |
| 75 |
'max' => 100, |
| 76 |
], |
| 77 |
'blur' => [ |
| 78 |
'label' => __( 'Blur', 'elementor' ), |
| 79 |
'min' => 0, |
| 80 |
'max' => 100, |
| 81 |
], |
| 82 |
'spread' => [ |
| 83 |
'label' => __( 'Spread', 'elementor' ), |
| 84 |
'min' => -100, |
| 85 |
'max' => 100, |
| 86 |
], |
| 87 |
]; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Render box shadow control output in the editor. |
| 92 |
* |
| 93 |
* Used to generate the control HTML in the editor using Underscore JS |
| 94 |
* template. The variables for the class are available using `data` JS |
| 95 |
* object. |
| 96 |
* |
| 97 |
* @since 1.0.0 |
| 98 |
* @access public |
| 99 |
*/ |
| 100 |
public function content_template() { |
| 101 |
?> |
| 102 |
<div class="elementor-shadow-box"> |
| 103 |
<div class="elementor-control-field elementor-color-picker-wrapper"> |
| 104 |
<label class="elementor-control-title"><?php echo __( 'Color', 'elementor' ); ?></label> |
| 105 |
<div class="elementor-control-input-wrapper elementor-control-unit-1"> |
| 106 |
<div class="elementor-color-picker-placeholder"></div> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
<?php |
| 110 |
foreach ( $this->get_sliders() as $slider_name => $slider ) : |
| 111 |
$control_uid = $this->get_control_uid( $slider_name ); |
| 112 |
?> |
| 113 |
<div class="elementor-shadow-slider elementor-control-type-slider"> |
| 114 |
<label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title"><?php echo $slider['label']; ?></label> |
| 115 |
<div class="elementor-control-input-wrapper"> |
| 116 |
<div class="elementor-slider" data-input="<?php echo esc_attr( $slider_name ); ?>"></div> |
| 117 |
<div class="elementor-slider-input elementor-control-unit-2"> |
| 118 |
<input id="<?php echo esc_attr( $control_uid ); ?>" type="number" min="<?php echo esc_attr( $slider['min'] ); ?>" max="<?php echo esc_attr( $slider['max'] ); ?>" data-setting="<?php echo esc_attr( $slider_name ); ?>"/> |
| 119 |
</div> |
| 120 |
</div> |
| 121 |
</div> |
| 122 |
<?php endforeach; ?> |
| 123 |
</div> |
| 124 |
<?php |
| 125 |
} |
| 126 |
} |
| 127 |
|