updated theme GeneratePress
version 3.3.0
This commit is contained in:
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Search Modal.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_search_modal_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Search Modal', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'active_callback' => function() {
|
||||
if ( generate_get_option( 'nav_search_modal' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[search_modal_bg_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['search_modal_bg_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Field Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => ':root',
|
||||
'property' => '--gp-search-modal-bg-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[search_modal_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['search_modal_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Field Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => ':root',
|
||||
'property' => '--gp-search-modal-text-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[search_modal_overlay_bg_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['search_modal_overlay_bg_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Overlay Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => ':root',
|
||||
'property' => '--gp-search-modal-overlay-bg-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -208,10 +208,27 @@ if ( ! function_exists( 'generate_sanitize_hex_color' ) ) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
// Sanitize CSS variables.
|
||||
if ( strpos( $color, 'var(' ) !== false ) {
|
||||
return sanitize_text_field( $color );
|
||||
}
|
||||
|
||||
// Sanitize rgb() values.
|
||||
if ( strpos( $color, 'rgb(' ) !== false ) {
|
||||
$color = str_replace( ' ', '', $color );
|
||||
|
||||
sscanf( $color, 'rgb(%d,%d,%d)', $red, $green, $blue );
|
||||
return 'rgb(' . $red . ',' . $green . ',' . $blue . ')';
|
||||
}
|
||||
|
||||
// Sanitize rgba() values.
|
||||
if ( strpos( $color, 'rgba' ) !== false ) {
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
|
||||
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user