Astra_Customizer::bypass_control_configs( array $configuration )
Bypass JS configs for Controls.
Description
Parameters
- $configuration
-
(array) (Required) configuration.
Source
File: inc/customizer/class-astra-customizer.php
public static function bypass_control_configs( $configuration ) { $val = ''; if ( isset( $configuration['name'] ) ) { $data = explode( '[', rtrim( $configuration['name'], ']' ) ); if ( isset( $data[1] ) ) { $val = astra_get_option( $data[1] ); } } if ( isset( $val ) && ! empty( $val ) ) { $configuration['value'] = $val; } switch ( $configuration['type'] ) { case 'ast-builder': if ( is_array( $configuration['default'] ) && ! isset( $configuration['default']['popup'] ) ) { $configuration['default']['popup'] = array( 'popup_content' => array() ); } break; case 'ast-responsive-spacing': if ( ! is_array( $val ) || is_numeric( $val ) ) { $configuration['value'] = array( 'desktop' => array( 'top' => $val, 'right' => '', 'bottom' => $val, 'left' => '', ), 'tablet' => array( 'top' => $val, 'right' => '', 'bottom' => $val, 'left' => '', ), 'mobile' => array( 'top' => $val, 'right' => '', 'bottom' => $val, 'left' => '', ), 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ); } break; case 'ast-radio-image': $configuration['value'] = $val; if ( isset( $configuration['choices'] ) && is_array( $configuration['choices'] ) ) { foreach ( $configuration['choices'] as $key => $value ) { $configuration['choices'][ $key ] = $value['path']; $configuration['choices_titles'][ $key ] = $value['label']; } } if ( isset( $configuration['input_attrs'] ) ) { $configuration['inputAttrs'] = ''; $configuration['labelStyle'] = ''; foreach ( $configuration['input_attrs'] as $attr => $value ) { if ( 'style' !== $attr ) { $configuration['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; } else { $configuration['labelStyle'] = 'style="' . esc_attr( $value ) . '" '; } } } break; case 'ast-border': $configuration['value'] = $val; break; case 'ast-responsive-slider': if ( ! is_array( $val ) || is_numeric( $val ) ) { $configuration['value'] = array( 'desktop' => $val, 'tablet' => '', 'mobile' => '', ); } break; case 'ast-responsive-background': $configuration['value'] = $val; break; case 'ast-responsive': if ( ! is_array( $val ) || is_numeric( $val ) ) { $configuration['value'] = array( 'desktop' => $val, 'tablet' => '', 'mobile' => '', 'desktop-unit' => '', 'tablet-unit' => '', 'mobile-unit' => '', ); } break; case 'ast-link': $configuration['value'] = $val; break; case 'ast-hidden': $configuration['value'] = $val; break; case 'ast-settings-group': $config = array(); if ( isset( self::$group_configs[ $configuration['name'] ]['tabs'] ) ) { $tab = array_keys( self::$group_configs[ $configuration['name'] ]['tabs'] ); rsort( $tab ); foreach ( $tab as $key => $value ) { $config['tabs'][ $value ] = wp_list_sort( self::$group_configs[ $configuration['name'] ]['tabs'][ $value ], 'priority' ); } } else { if ( isset( self::$group_configs[ $configuration['name'] ] ) ) { $config = wp_list_sort( self::$group_configs[ $configuration['name'] ], 'priority' ); } } $configuration['ast_fields'] = $config; break; case 'ast-font-weight': $configuration['ast_all_font_weight'] = array( '100' => __( 'Thin 100', 'astra' ), '100italic' => __( '100 Italic', 'astra' ), '200' => __( 'Extra-Light 200', 'astra' ), '200italic' => __( '200 Italic', 'astra' ), '300' => __( 'Light 300', 'astra' ), '300italic' => __( '300 Italic', 'astra' ), '400' => __( 'Normal 400', 'astra' ), 'italic' => __( '400 Italic', 'astra' ), '500' => __( 'Medium 500', 'astra' ), '500italic' => __( '500 Italic', 'astra' ), '600' => __( 'Semi-Bold 600', 'astra' ), '600italic' => __( '600 Italic', 'astra' ), '700' => __( 'Bold 700', 'astra' ), '700italic' => __( '700 Italic', 'astra' ), '800' => __( 'Extra-Bold 800', 'astra' ), '800italic' => __( '800 Italic', 'astra' ), '900' => __( 'Ultra-Bold 900', 'astra' ), '900italic' => __( '900 Italic', 'astra' ), ); break; case 'ast-sortable': $configuration['value'] = $val; break; } // Switch End. if ( isset( $configuration['id'] ) ) { $configuration['link'] = self::get_control_link( $configuration['id'] ); } $exclude_controls = array( 'ast-builder', 'ast-radio-image' ); if ( isset( $configuration['type'] ) && ! in_array( $configuration['type'], $exclude_controls ) && isset( $configuration['input_attrs'] ) && is_array( $configuration['input_attrs'] ) ) { $configuration['inputAttrs'] = ''; foreach ( $configuration['input_attrs'] as $attr => $value ) { if ( ! is_array( $value ) ) { $configuration['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; } } } return $configuration; }
Expand full source code Collapse full source code View on Trac