* add new control you set the `$args` parameter, this method allows you to
* update the arguments by passing new data.
* @param string $id Responsive control ID.
* @param array $args Responsive control arguments.
* @param array $options Optional. Additional options.
final public function update_responsive_control( $id, array $args, array $options = [] ) {
$this->add_responsive_control( $id, $args, [
'recursive' => ! empty( $options['recursive'] ),
* Remove responsive control from stack.
* Unregister an existing responsive control and remove it from the stack.
* @param string $id Responsive control ID.
final public function remove_responsive_control( $id ) {
$devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] );
foreach ( $devices as $device_name ) {
$id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name;
$this->remove_control( $id . $id_suffix );
* Retrieve the name of the current class.
* @return string Class name.
final public function get_class_name() {
return get_called_class();
* Retrieve the config or, if non set, use the initial config.
* @return array|null The config.
final public function get_config() {
if ( null === $this->config ) {
// TODO: This is for backwards compatibility starting from 2.9.0.
// This if statement should be removed when the method is hard-deprecated.
if ( $this->has_own_method( '_get_initial_config', self::class ) ) {
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' );
$this->config = $this->_get_initial_config();
$this->config = $this->get_initial_config();
foreach ( $this->additional_config as $key => $value ) {
if ( isset( $this->config[ $key ] ) ) {
$this->config[ $key ] = wp_parse_args( $value, $this->config[ $key ] );
$this->config[ $key ] = $value;
* Set a specific property of the config list for this controls-stack.
public function set_config( $key, $value ) {
if ( isset( $this->additional_config[ $key ] ) ) {
$this->additional_config[ $key ] = wp_parse_args( $value, $this->additional_config[ $key ] );
$this->additional_config[ $key ] = $value;
* Get frontend settings keys.
* Retrieve settings keys for all frontend controls.
* @return array Settings keys for each control.
final public function get_frontend_settings_keys() {
foreach ( $this->get_controls() as $control ) {
if ( ! empty( $control['frontend_available'] ) ) {
$controls[] = $control['name'];
* Get controls pointer index.
* Retrieve pointer index where the next control should be added.
* While using injection point, it will return the injection point index.
* Otherwise index of the last control plus one.
* @return int Controls pointer index.
public function get_pointer_index() {
if ( null !== $this->injection_point ) {
return $this->injection_point['index'];
return count( $this->get_controls() );
* Retrieve all the items or, when requested, a specific item.
* @param string $item Optional. The requested item. Default is null.
* @return mixed The raw data.
public function get_data( $item = null ) {
if ( ! $this->settings_sanitized && ( ! $item || 'settings' === $item ) ) {
$this->data['settings'] = $this->sanitize_settings( $this->data['settings'] );
$this->settings_sanitized = true;
return self::get_items( $this->data, $item );
* @return array|mixed|null
public function get_parsed_dynamic_settings( $setting = null, $settings = null ) {
if ( null === $settings ) {
$settings = $this->get_settings();
if ( null === $this->parsed_dynamic_settings ) {
$this->parsed_dynamic_settings = $this->parse_dynamic_settings( $settings );
return self::get_items( $this->parsed_dynamic_settings, $setting );
* Retrieve the settings from all the active controls.
* @param array|null $settings Optional. Controls settings. Default is null.
* @param array|null $controls Optional. An array of controls. Default is null.
* @return array Active settings.
* @since 2.1.0 Added the `controls` and the `settings` parameters.
public function get_active_settings( $settings = null, $controls = null ) {
$is_first_request = ! $settings && ! $this->active_settings;
if ( $this->active_settings ) {
return $this->active_settings;
$settings = $this->get_controls_settings();
$controls = $this->get_controls();
$controls_objs = Plugin::$instance->controls_manager->get_controls();
foreach ( $settings as $setting_key => $setting ) {
if ( ! isset( $controls[ $setting_key ] ) ) {
$active_settings[ $setting_key ] = $setting;
$control = $controls[ $setting_key ];
if ( $this->is_control_visible( $control, $settings, $controls ) ) {
$control_obj = $controls_objs[ $control['type'] ] ?? null;
if ( $control_obj instanceof Control_Repeater ) {
foreach ( $setting as & $item ) {
$item = $this->get_active_settings( $item, $control['fields'] );
$active_settings[ $setting_key ] = $setting;
$active_settings[ $setting_key ] = null;
if ( $is_first_request ) {
$this->active_settings = $active_settings;
* Get settings for display.
* Retrieve all the settings or, when requested, a specific setting for display.
* Unlike `get_settings()` method, this method retrieves only active settings
* that passed all the conditions, rendered all the shortcodes and all the dynamic
* @param string $setting_key Optional. The key of the requested setting.
* @return mixed The settings.
public function get_settings_for_display( $setting_key = null ) {
if ( ! $this->parsed_active_settings ) {
$this->parsed_active_settings = $this->get_active_settings( $this->get_parsed_dynamic_settings(), $this->get_controls() );
return self::get_items( $this->parsed_active_settings, $setting_key );
* Parse dynamic settings.
* Retrieve the settings with rendered dynamic tags.
* @param array $settings Optional. The requested setting. Default is null.
* @param array $controls Optional. The controls array. Default is null.
* @param array $all_settings Optional. All the settings. Default is null.
* @return array The settings with rendered dynamic tags.
public function parse_dynamic_settings( $settings, $controls = null, $all_settings = null ) {
if ( null === $all_settings ) {
$all_settings = $this->get_settings();
if ( null === $controls ) {
$controls = $this->get_controls();
$controls_objs = Plugin::$instance->controls_manager->get_controls();
foreach ( $controls as $control ) {
$control_name = $control['name'];
$control_obj = $controls_objs[ $control['type'] ] ?? null;
if ( ! $control_obj instanceof Base_Data_Control ) {
if ( $control_obj instanceof Control_Repeater ) {
if ( ! isset( $settings[ $control_name ] ) ) {
foreach ( $settings[ $control_name ] as & $field ) {
$field = $this->parse_dynamic_settings( $field, $control['fields'], $field );
$dynamic_settings = $control_obj->get_settings( 'dynamic' );
if ( ! $dynamic_settings ) {
if ( ! empty( $control['dynamic'] ) ) {
$dynamic_settings = array_merge( $dynamic_settings, $control['dynamic'] );
if ( empty( $dynamic_settings ) || ! isset( $all_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control_name ] ) ) {
if ( ! empty( $dynamic_settings['active'] ) && ! empty( $all_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control_name ] ) ) {
$parsed_value = $control_obj->parse_tags( $all_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control_name ], $dynamic_settings );
$dynamic_property = ! empty( $dynamic_settings['property'] ) ? $dynamic_settings['property'] : null;
if ( $dynamic_property ) {
$settings[ $control_name ][ $dynamic_property ] = $parsed_value;
$settings[ $control_name ] = $parsed_value;
* Retrieve the settings for all frontend controls.
* @return array Frontend settings.
public function get_frontend_settings() {
$frontend_settings = array_intersect_key( $this->get_settings_for_display(), array_flip( $this->get_frontend_settings_keys() ) );
foreach ( $frontend_settings as $key => $setting ) {
if ( in_array( $setting, [ null, '' ], true ) ) {
unset( $frontend_settings[ $key ] );
return $frontend_settings;
* Filter controls settings.
* Receives controls, settings and a callback function to filter the settings by
* and returns filtered settings.
* @param callable $callback The callback function.
* @param array $settings Optional. Control settings. Default is an empty
* @param array $controls Optional. Controls list. Default is an empty
* @return array Filtered settings.
public function filter_controls_settings( callable $callback, array $settings = [], array $controls = [] ) {
$settings = $this->get_settings();
$controls = $this->get_controls();
array_keys( $settings ), function( $filtered_settings, $setting_key ) use ( $controls, $settings, $callback ) {
if ( isset( $controls[ $setting_key ] ) ) {
$result = $callback( $settings[ $setting_key ], $controls[ $setting_key ] );
if ( null !== $result ) {
$filtered_settings[ $setting_key ] = $result;
return $filtered_settings;
* Get Responsive Control Device Suffix
* @deprecated 3.7.6 Use `Elementor\Controls_Manager::get_responsive_control_device_suffix()` instead.
* @return string $device suffix
protected function get_responsive_control_device_suffix( $control ) {
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.7.6', 'Elementor\Controls_Manager::get_responsive_control_device_suffix()' );
return Controls_Manager::get_responsive_control_device_suffix( $control );
* Whether the control is visible or not.
* Used to determine whether the control is visible or not.
* @param array $control The control.
* @param null $values Optional. Condition values. Default is null.
* @return bool Whether the control is visible.
public function is_control_visible( $control, $values = null, $controls = null ) {
if ( null === $values ) {
$values = $this->get_settings();
if ( ! empty( $control['conditions'] ) && ! Conditions::check( $control['conditions'], $values ) ) {
if ( empty( $control['condition'] ) ) {
$controls = $this->get_controls();
foreach ( $control['condition'] as $condition_key => $condition_value ) {
preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
$pure_condition_key = $condition_key_parts[1];
$condition_sub_key = $condition_key_parts[2];
$is_negative_condition = (bool) $condition_key_parts[3];
if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) {
$are_control_and_condition_responsive = isset( $control['responsive'] ) && ! empty( $controls[ $pure_condition_key ]['responsive'] );
$condition_name_to_check = $pure_condition_key;
if ( $are_control_and_condition_responsive ) {
$device_suffix = Controls_Manager::get_responsive_control_device_suffix( $control );
$condition_name_to_check = $pure_condition_key . $device_suffix;
// If the control is not desktop, and a conditioning control for the corresponding device exists, use it.
$instance_value = $values[ $pure_condition_key . $device_suffix ] ?? $values[ $pure_condition_key ];
$instance_value = $values[ $pure_condition_key ];
if ( $condition_sub_key && is_array( $instance_value ) ) {
if ( ! isset( $instance_value[ $condition_sub_key ] ) ) {
$instance_value = $instance_value[ $condition_sub_key ];
if ( ! $instance_value ) {
$parent = isset( $controls[ $condition_name_to_check ]['parent'] ) ? $controls[ $condition_name_to_check ]['parent'] : false;
$instance_value = $values[ $parent ];
if ( ! is_array( $instance_value ) ) {
if ( $condition_sub_key && isset( $instance_value[ $condition_sub_key ] ) ) {
$instance_value = $instance_value[ $condition_sub_key ];