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