Astra_Builder_Base_Configuration::prepare_widget_options( string $type = 'header' )
Prepare common options for the widgets by type.
Description
Parameters
- $type
-
(string) (Optional) type.
Default value: 'header'
Return
(array)
Source
File: inc/customizer/configurations/builder/class-astra-builder-base-configuration.php
public static function prepare_widget_options( $type = 'header' ) {
$html_config = array();
if ( 'footer' === $type ) {
$component_limit = defined( 'ASTRA_EXT_VER' ) ?
Astra_Builder_Helper::$component_limit : Astra_Builder_Helper::$num_of_footer_widgets;
} else {
$component_limit = defined( 'ASTRA_EXT_VER' ) ?
Astra_Builder_Helper::$component_limit : Astra_Builder_Helper::$num_of_header_widgets;
}
$astra_has_widgets_block_editor = astra_has_widgets_block_editor();
for ( $index = 1; $index <= $component_limit; $index++ ) {
$_section = ( ! $astra_has_widgets_block_editor ) ? 'sidebar-widgets-' . $type . '-widget-' . $index : 'astra-sidebar-widgets-' . $type . '-widget-' . $index;
$html_config[] = array(
array(
'name' => $_section,
'type' => 'section',
'priority' => 5,
'title' => __( 'Widget ', 'astra' ) . $index,
'panel' => 'panel-' . $type . '-builder-group',
'clone_index' => $index,
'clone_type' => $type . '-widget',
'divider' => array( 'ast_class' => 'ast-bottom-divider' ),
),
/**
* Option: Margin
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $_section . '-margin]',
'default' => astra_get_option( $_section . '-margin' ),
'type' => 'control',
'transport' => 'postMessage',
'control' => 'ast-responsive-spacing',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_spacing' ),
'section' => $_section,
'priority' => 220,
'title' => __( 'Margin', 'astra' ),
'linked_choices' => true,
'unit_choices' => array( 'px', 'em', '%' ),
'choices' => array(
'top' => __( 'Top', 'astra' ),
'right' => __( 'Right', 'astra' ),
'bottom' => __( 'Bottom', 'astra' ),
'left' => __( 'Left', 'astra' ),
),
),
);
if ( 'footer' === $type ) {
$html_config [] = array(
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-alignment-' . $index . ']',
'default' => astra_get_option( $type . '-widget-alignment-' . $index ),
'type' => 'control',
'control' => 'ast-selector',
'section' => $_section,
'priority' => 5,
'title' => __( 'Alignment', 'astra' ),
'transport' => 'postMessage',
'choices' => array(
'left' => 'align-left',
'center' => 'align-center',
'right' => 'align-right',
),
'divider' => ( ! $astra_has_widgets_block_editor ) ? array( 'ast_class' => 'ast-top-divider' ) : '',
),
);
}
if ( ! astra_remove_widget_design_options() ) {
$html_config[] = array(
/**
* Option: Widget title color.
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-title-color]',
'default' => astra_get_option( $type . '-widget-' . $index . '-title-color' ),
'title' => __( 'Title Color', 'astra' ),
'type' => 'control',
'section' => $_section,
'priority' => 7,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'divider' => ( ! $astra_has_widgets_block_editor ) ? array( 'ast_class' => 'ast-top-divider' ) : '',
'rgba' => true,
),
/**
* Option: Widget Color.
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-color]',
'default' => astra_get_option( $type . '-widget-' . $index . '-color' ),
'title' => __( 'Content Color', 'astra' ),
'type' => 'control',
'section' => $_section,
'priority' => 7,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'rgba' => true,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-link-color-group]',
'default' => astra_get_option( $type . '-widget-' . $index . '-color-group' ),
'type' => 'control',
'control' => 'ast-color-group',
'title' => __( 'Link Color', 'astra' ),
'section' => $_section,
'transport' => 'postMessage',
'priority' => 7,
'responsive' => true,
'divider' => array( 'ast_class' => 'ast-bottom-divider' ),
),
/**
* Option: Widget link color.
*/
array(
'name' => $type . '-widget-' . $index . '-link-color',
'default' => astra_get_option( $type . '-widget-' . $index . '-link-color' ),
'parent' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-link-color-group]',
'type' => 'sub-control',
'section' => $_section,
'priority' => 3,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'rgba' => true,
'title' => __( 'Normal', 'astra' ),
),
/**
* Option: Widget link color.
*/
array(
'name' => $type . '-widget-' . $index . '-link-h-color',
'default' => astra_get_option( $type . '-widget-' . $index . '-link-h-color' ),
'parent' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-link-color-group]',
'type' => 'sub-control',
'section' => $_section,
'priority' => 1,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'rgba' => true,
'title' => __( 'Hover', 'astra' ),
),
);
if ( defined( 'ASTRA_EXT_VER' ) && Astra_Ext_Extension::is_active( 'typography' ) ) {
$html_config[] = array(
/**
* Option: Widget Title Typography
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-text-typography]',
'default' => astra_get_option( $type . '-widget-' . $index . '-text-typography' ),
'type' => 'control',
'control' => 'ast-settings-group',
'title' => __( 'Title Font', 'astra' ),
'section' => $_section,
'transport' => 'postMessage',
'priority' => 90,
'divider' => array( 'ast_class' => 'ast-bottom-divider' ),
),
/**
* Option: Widget Title Font Size
*/
array(
'name' => $type . '-widget-' . $index . '-font-size',
'default' => astra_get_option( $type . '-widget-' . $index . '-font-size' ),
'parent' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-text-typography]',
'transport' => 'postMessage',
'title' => __( 'Size', 'astra' ),
'type' => 'sub-control',
'section' => $_section,
'control' => 'ast-responsive',
'input_attrs' => array(
'min' => 0,
),
'priority' => 2,
'units' => array(
'px' => 'px',
'em' => 'em',
),
),
/**
* Option: Widget Content Typography
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-content-typography]',
'default' => astra_get_option( $type . '-widget-' . $index . '-content-typography' ),
'type' => 'control',
'control' => 'ast-settings-group',
'title' => __( 'Content Font', 'astra' ),
'section' => $_section,
'transport' => 'postMessage',
'priority' => 91,
),
/**
* Option: Widget Content Font Size
*/
array(
'name' => $type . '-widget-' . $index . '-content-font-size',
'default' => astra_get_option( $type . '-widget-' . $index . '-content-font-size' ),
'parent' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-content-typography]',
'transport' => 'postMessage',
'title' => __( 'Size', 'astra' ),
'type' => 'sub-control',
'section' => $_section,
'control' => 'ast-responsive',
'input_attrs' => array(
'min' => 0,
),
'priority' => 2,
'units' => array(
'px' => 'px',
'em' => 'em',
),
),
);
} else {
$html_config[] = array(
/**
* Option: Widget Title Font Size
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-font-size]',
'default' => astra_get_option( $type . '-widget-' . $index . '-font-size' ),
'transport' => 'postMessage',
'title' => __( 'Title Font Size', 'astra' ),
'type' => 'control',
'section' => $_section,
'control' => 'ast-responsive',
'input_attrs' => array(
'min' => 0,
),
'priority' => 90,
'units' => array(
'px' => 'px',
'em' => 'em',
),
),
/**
* Option: Widget Content Font Size
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $type . '-widget-' . $index . '-content-font-size]',
'default' => astra_get_option( $type . '-widget-' . $index . '-content-font-size' ),
'transport' => 'postMessage',
'title' => __( 'Content Font Size', 'astra' ),
'type' => 'control',
'section' => $_section,
'control' => 'ast-responsive',
'input_attrs' => array(
'min' => 0,
),
'priority' => 91,
'units' => array(
'px' => 'px',
'em' => 'em',
),
),
);
}
}
$html_config[] = self::prepare_visibility_tab( $_section, $type );
}
return call_user_func_array( 'array_merge', $html_config + array( array() ) );
}
Expand full source code Collapse full source code View on Trac