| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor sub controls stack. |
| 10 |
* |
| 11 |
* An abstract class that can be used to divide a large ControlsStack into small parts. |
| 12 |
* |
| 13 |
* @abstract |
| 14 |
*/ |
| 15 |
abstract class Sub_Controls_Stack { |
| 16 |
/** |
| 17 |
* @var Controls_Stack |
| 18 |
*/ |
| 19 |
protected $parent; |
| 20 |
|
| 21 |
/** |
| 22 |
* Get self ID. |
| 23 |
* |
| 24 |
* Retrieve the self ID. |
| 25 |
* |
| 26 |
* @access public |
| 27 |
* @abstract |
| 28 |
*/ |
| 29 |
abstract public function get_id(); |
| 30 |
|
| 31 |
/** |
| 32 |
* Get self title. |
| 33 |
* |
| 34 |
* Retrieve the self title. |
| 35 |
* |
| 36 |
* @access public |
| 37 |
* @abstract |
| 38 |
*/ |
| 39 |
abstract public function get_title(); |
| 40 |
|
| 41 |
/** |
| 42 |
* Constructor. |
| 43 |
* |
| 44 |
* Initializing the base class by setting parent stack. |
| 45 |
* |
| 46 |
* @access public |
| 47 |
* @param Controls_Stack $parent |
| 48 |
*/ |
| 49 |
public function __construct( $parent ) { |
| 50 |
$this->parent = $parent; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Get control ID. |
| 55 |
* |
| 56 |
* Retrieve the control ID. Note that the sub controls stack may have a special prefix |
| 57 |
* to distinguish them from regular controls, and from controls in other |
| 58 |
* sub stack. |
| 59 |
* |
| 60 |
* By default do nothing, and return the original id. |
| 61 |
* |
| 62 |
* @access protected |
| 63 |
* |
| 64 |
* @param string $control_base_id Control base ID. |
| 65 |
* |
| 66 |
* @return string Control ID. |
| 67 |
*/ |
| 68 |
protected function get_control_id( $control_base_id ) { |
| 69 |
return $control_base_id; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Add new control. |
| 74 |
* |
| 75 |
* Register a single control to allow the user to set/update data. |
| 76 |
* |
| 77 |
* @access public |
| 78 |
* |
| 79 |
* @param string $id Control ID. |
| 80 |
* @param array $args Control arguments. |
| 81 |
* @param array $options |
| 82 |
* |
| 83 |
* @return bool True if added, False otherwise. |
| 84 |
*/ |
| 85 |
public function add_control( $id, $args, $options = [] ) { |
| 86 |
return $this->parent->add_control( $this->get_control_id( $id ), $args, $options ); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Update control. |
| 91 |
* |
| 92 |
* Change the value of an existing control. |
| 93 |
* |
| 94 |
* @access public |
| 95 |
* |
| 96 |
* @param string $id Control ID. |
| 97 |
* @param array $args Control arguments. Only the new fields you want to update. |
| 98 |
* @param array $options Optional. Some additional options. |
| 99 |
*/ |
| 100 |
public function update_control( $id, $args, array $options = [] ) { |
| 101 |
$this->parent->update_control( $this->get_control_id( $id ), $args, $options ); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Remove control. |
| 106 |
* |
| 107 |
* Unregister an existing control. |
| 108 |
* |
| 109 |
* @access public |
| 110 |
* |
| 111 |
* @param string $id Control ID. |
| 112 |
*/ |
| 113 |
public function remove_control( $id ) { |
| 114 |
$this->parent->remove_control( $this->get_control_id( $id ) ); |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Add new group control. |
| 119 |
* |
| 120 |
* Register a set of related controls grouped together as a single unified |
| 121 |
* control. |
| 122 |
* |
| 123 |
* @access public |
| 124 |
* |
| 125 |
* @param string $group_name Group control name. |
| 126 |
* @param array $args Group control arguments. Default is an empty array. |
| 127 |
* @param array $options |
| 128 |
* |
| 129 |
*/ |
| 130 |
public function add_group_control( $group_name, $args, $options = [] ) { |
| 131 |
$args['name'] = $this->get_control_id( $args['name'] ); |
| 132 |
$this->parent->add_group_control( $group_name, $args, $options ); |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Add new responsive control. |
| 137 |
* |
| 138 |
* Register a set of controls to allow editing based on user screen size. |
| 139 |
* |
| 140 |
* @access public |
| 141 |
* |
| 142 |
* @param string $id Responsive control ID. |
| 143 |
* @param array $args Responsive control arguments. |
| 144 |
* @param array $options |
| 145 |
*/ |
| 146 |
public function add_responsive_control( $id, $args, $options = [] ) { |
| 147 |
$this->parent->add_responsive_control( $this->get_control_id( $id ), $args, $options ); |
| 148 |
} |
| 149 |
|
| 150 |
/** |
| 151 |
* Update responsive control. |
| 152 |
* |
| 153 |
* Change the value of an existing responsive control. |
| 154 |
* |
| 155 |
* @access public |
| 156 |
* |
| 157 |
* @param string $id Responsive control ID. |
| 158 |
* @param array $args Responsive control arguments. |
| 159 |
*/ |
| 160 |
public function update_responsive_control( $id, $args ) { |
| 161 |
$this->parent->update_responsive_control( $this->get_control_id( $id ), $args ); |
| 162 |
} |
| 163 |
|
| 164 |
/** |
| 165 |
* Remove responsive control. |
| 166 |
* |
| 167 |
* Unregister an existing responsive control. |
| 168 |
* |
| 169 |
* @access public |
| 170 |
* |
| 171 |
* @param string $id Responsive control ID. |
| 172 |
*/ |
| 173 |
public function remove_responsive_control( $id ) { |
| 174 |
$this->parent->remove_responsive_control( $this->get_control_id( $id ) ); |
| 175 |
} |
| 176 |
|
| 177 |
/** |
| 178 |
* Start controls section. |
| 179 |
* |
| 180 |
* Used to add a new section of controls to the stack. |
| 181 |
* |
| 182 |
* @access public |
| 183 |
* |
| 184 |
* @param string $id Section ID. |
| 185 |
* @param array $args Section arguments. |
| 186 |
*/ |
| 187 |
|
| 188 |
public function start_controls_section( $id, $args = [] ) { |
| 189 |
$this->parent->start_controls_section( $this->get_control_id( $id ), $args ); |
| 190 |
} |
| 191 |
|
| 192 |
/** |
| 193 |
* End controls section. |
| 194 |
* |
| 195 |
* Used to close an existing open controls section. |
| 196 |
* |
| 197 |
* @access public |
| 198 |
*/ |
| 199 |
public function end_controls_section() { |
| 200 |
$this->parent->end_controls_section(); |
| 201 |
} |
| 202 |
|
| 203 |
/** |
| 204 |
* Start controls tabs. |
| 205 |
* |
| 206 |
* Used to add a new set of tabs inside a section. |
| 207 |
* |
| 208 |
* @access public |
| 209 |
* |
| 210 |
* @param string $id Control ID. |
| 211 |
*/ |
| 212 |
public function start_controls_tabs( $id ) { |
| 213 |
$this->parent->start_controls_tabs( $this->get_control_id( $id ) ); |
| 214 |
} |
| 215 |
|
| 216 |
public function start_controls_tab( $id, $args ) { |
| 217 |
$this->parent->start_controls_tab( $this->get_control_id( $id ), $args ); |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
/** |
| 222 |
* End controls tabs. |
| 223 |
* |
| 224 |
* Used to close an existing open controls tabs. |
| 225 |
* |
| 226 |
* @access public |
| 227 |
*/ |
| 228 |
public function end_controls_tab() { |
| 229 |
$this->parent->end_controls_tab(); |
| 230 |
} |
| 231 |
|
| 232 |
/** |
| 233 |
* End controls tabs. |
| 234 |
* |
| 235 |
* Used to close an existing open controls tabs. |
| 236 |
* |
| 237 |
* @access public |
| 238 |
*/ |
| 239 |
public function end_controls_tabs() { |
| 240 |
$this->parent->end_controls_tabs(); |
| 241 |
} |
| 242 |
} |
| 243 |
|