balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

box-shadow.php (3474B)


      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' => esc_html__( 'Horizontal', 'elementor' ),
     69 				'min' => -100,
     70 				'max' => 100,
     71 			],
     72 			'vertical' => [
     73 				'label' => esc_html__( 'Vertical', 'elementor' ),
     74 				'min' => -100,
     75 				'max' => 100,
     76 			],
     77 			'blur' => [
     78 				'label' => esc_html__( 'Blur', 'elementor' ),
     79 				'min' => 0,
     80 				'max' => 100,
     81 			],
     82 			'spread' => [
     83 				'label' => esc_html__( '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 esc_html__( '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 				?>
    112 				<div class="elementor-shadow-slider elementor-control-type-slider">
    113 					<label for="<?php $this->print_control_uid( $slider_name ); ?>" class="elementor-control-title"><?php
    114 						// PHPCS - the value of $slider['label'] is already escaped.
    115 						echo $slider['label']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    116 					?></label>
    117 					<div class="elementor-control-input-wrapper">
    118 						<div class="elementor-slider" data-input="<?php echo esc_attr( $slider_name ); ?>"></div>
    119 						<div class="elementor-slider-input elementor-control-unit-2">
    120 							<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 ); ?>"/>
    121 						</div>
    122 					</div>
    123 				</div>
    124 			<?php endforeach; ?>
    125 		</div>
    126 		<?php
    127 	}
    128 }