base-multiple.php (2079B)
1 <?php 2 namespace Elementor; 3 4 if ( ! defined( 'ABSPATH' ) ) { 5 exit; // Exit if accessed directly. 6 } 7 8 /** 9 * Elementor control base multiple. 10 * 11 * An abstract class for creating new controls in the panel that return 12 * more than a single value. Each value of the multi-value control will 13 * be returned as an item in a `key => value` array. 14 * 15 * @since 1.0.0 16 * @abstract 17 */ 18 abstract class Control_Base_Multiple extends Base_Data_Control { 19 20 /** 21 * Get multiple control default value. 22 * 23 * Retrieve the default value of the multiple control. Used to return the default 24 * values while initializing the multiple control. 25 * 26 * @since 1.0.0 27 * @access public 28 * 29 * @return array Control default value. 30 */ 31 public function get_default_value() { 32 return []; 33 } 34 35 /** 36 * Get multiple control value. 37 * 38 * Retrieve the value of the multiple control from a specific Controls_Stack settings. 39 * 40 * @since 1.0.0 41 * @access public 42 * 43 * @param array $control Control 44 * @param array $settings Settings 45 * 46 * @return mixed Control values. 47 */ 48 public function get_value( $control, $settings ) { 49 $value = parent::get_value( $control, $settings ); 50 51 if ( empty( $control['default'] ) ) { 52 $control['default'] = []; 53 } 54 55 if ( ! is_array( $value ) ) { 56 $value = []; 57 } 58 59 $control['default'] = array_merge( 60 $this->get_default_value(), 61 $control['default'] 62 ); 63 64 return array_merge( 65 $control['default'], 66 $value 67 ); 68 } 69 70 /** 71 * Get multiple control style value. 72 * 73 * Retrieve the style of the control. Used when adding CSS rules to the control 74 * while extracting CSS from the `selectors` data argument. 75 * 76 * @since 1.0.5 77 * @since 2.3.3 New `$control_data` parameter added. 78 * @access public 79 * 80 * @param string $css_property CSS property. 81 * @param array $control_value Control value. 82 * @param array $control_data Control Data. 83 * 84 * @return array Control style value. 85 */ 86 public function get_style_value( $css_property, $control_value, array $control_data ) { 87 return $control_value[ strtolower( $css_property ) ]; 88 } 89 }