updated theme GeneratePress
version 3.0.2
This commit is contained in:
@ -43,25 +43,6 @@ if ( ! function_exists( 'generate_is_top_bar_active' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_hidden_navigation' ) && function_exists( 'is_customize_preview' ) ) {
|
||||
add_action( 'wp_footer', 'generate_hidden_navigation' );
|
||||
/**
|
||||
* Adds a hidden navigation if no navigation is set
|
||||
* This allows us to use postMessage to position the navigation when it doesn't exist
|
||||
*
|
||||
* @since 1.3.40
|
||||
*/
|
||||
function generate_hidden_navigation() {
|
||||
if ( is_customize_preview() && function_exists( 'generate_navigation_position' ) ) {
|
||||
?>
|
||||
<div style="display:none;">
|
||||
<?php generate_navigation_position(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customize_partial_blogname' ) ) {
|
||||
/**
|
||||
* Render the site title for the selective refresh partial.
|
||||
@ -92,16 +73,16 @@ if ( ! function_exists( 'generate_enqueue_color_palettes' ) ) {
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_enqueue_color_palettes() {
|
||||
// Old versions of WP don't get nice things
|
||||
// Old versions of WP don't get nice things.
|
||||
if ( ! function_exists( 'wp_add_inline_script' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab our palette array and turn it into JS
|
||||
$palettes = json_encode( generate_get_default_color_palettes() );
|
||||
// Grab our palette array and turn it into JS.
|
||||
$palettes = wp_json_encode( generate_get_default_color_palettes() );
|
||||
|
||||
// Add our custom palettes
|
||||
// json_encode takes care of escaping
|
||||
// Add our custom palettes.
|
||||
// json_encode takes care of escaping.
|
||||
wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $palettes . ';' );
|
||||
}
|
||||
}
|
||||
@ -111,6 +92,7 @@ if ( ! function_exists( 'generate_sanitize_integer' ) ) {
|
||||
* Sanitize integers.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_integer( $input ) {
|
||||
return absint( $input );
|
||||
@ -122,6 +104,7 @@ if ( ! function_exists( 'generate_sanitize_decimal_integer' ) ) {
|
||||
* Sanitize integers that can use decimals.
|
||||
*
|
||||
* @since 1.3.41
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_decimal_integer( $input ) {
|
||||
return abs( floatval( $input ) );
|
||||
@ -132,8 +115,10 @@ if ( ! function_exists( 'generate_sanitize_decimal_integer' ) ) {
|
||||
* Sanitize a positive number, but allow an empty value.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_absint( $input ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' == $input ) {
|
||||
return '';
|
||||
}
|
||||
@ -146,8 +131,10 @@ if ( ! function_exists( 'generate_sanitize_checkbox' ) ) {
|
||||
* Sanitize checkbox values.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $checked The value to check.
|
||||
*/
|
||||
function generate_sanitize_checkbox( $checked ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
return ( ( isset( $checked ) && true == $checked ) ? true : false );
|
||||
}
|
||||
}
|
||||
@ -158,19 +145,20 @@ if ( ! function_exists( 'generate_sanitize_blog_excerpt' ) ) {
|
||||
* Needed because GP Premium calls the control ID which is different from the settings ID.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_blog_excerpt( $input ) {
|
||||
$valid = array(
|
||||
'full',
|
||||
'excerpt'
|
||||
);
|
||||
function generate_sanitize_blog_excerpt( $input ) {
|
||||
$valid = array(
|
||||
'full',
|
||||
'excerpt',
|
||||
);
|
||||
|
||||
if ( in_array( $input, $valid ) ) {
|
||||
return $input;
|
||||
} else {
|
||||
return 'full';
|
||||
}
|
||||
}
|
||||
if ( in_array( $input, $valid ) ) {
|
||||
return $input;
|
||||
} else {
|
||||
return 'full';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_hex_color' ) ) {
|
||||
@ -179,25 +167,28 @@ if ( ! function_exists( 'generate_sanitize_hex_color' ) ) {
|
||||
* Allow blank value.
|
||||
*
|
||||
* @since 1.2.9.6
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_hex_color( $color ) {
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
function generate_sanitize_hex_color( $color ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
||||
return $color;
|
||||
}
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize RGBA colors.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_rgba_color( $color ) {
|
||||
if ( '' === $color ) {
|
||||
@ -211,7 +202,7 @@ function generate_sanitize_rgba_color( $color ) {
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
|
||||
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';
|
||||
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_choices' ) ) {
|
||||
@ -219,17 +210,19 @@ if ( ! function_exists( 'generate_sanitize_choices' ) ) {
|
||||
* Sanitize choices.
|
||||
*
|
||||
* @since 1.3.24
|
||||
* @param string $input The value to check.
|
||||
* @param object $setting The setting object.
|
||||
*/
|
||||
function generate_sanitize_choices( $input, $setting ) {
|
||||
// Ensure input is a slug
|
||||
// Ensure input is a slug.
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
// Get list of choices from the control.
|
||||
// associated with the setting.
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
// If the input is a valid key, return it.
|
||||
// otherwise, return the default.
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
}
|
||||
@ -238,6 +231,7 @@ if ( ! function_exists( 'generate_sanitize_choices' ) ) {
|
||||
* Sanitize our Google Font variants
|
||||
*
|
||||
* @since 2.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_variants( $input ) {
|
||||
if ( is_array( $input ) ) {
|
||||
@ -256,9 +250,11 @@ add_action( 'customize_controls_enqueue_scripts', 'generate_do_control_inline_sc
|
||||
* @since 2.0
|
||||
*/
|
||||
function generate_do_control_inline_scripts() {
|
||||
wp_localize_script( 'generatepress-typography-customizer', 'gp_customize',
|
||||
wp_localize_script(
|
||||
'generatepress-typography-customizer',
|
||||
'gp_customize',
|
||||
array(
|
||||
'nonce' => wp_create_nonce( 'gp_customize_nonce' )
|
||||
'nonce' => wp_create_nonce( 'gp_customize_nonce' ),
|
||||
)
|
||||
);
|
||||
|
||||
@ -268,7 +264,7 @@ function generate_do_control_inline_scripts() {
|
||||
'generatepress-typography-customizer',
|
||||
'generatePressTypography',
|
||||
array(
|
||||
'googleFonts' => apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) )
|
||||
'googleFonts' => apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) ),
|
||||
)
|
||||
);
|
||||
|
||||
@ -277,6 +273,8 @@ function generate_do_control_inline_scripts() {
|
||||
wp_enqueue_script( 'generatepress-customizer-controls', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-controls.js', array( 'customize-controls', 'jquery' ), GENERATE_VERSION, true );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_defaults', generate_get_defaults() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_color_defaults', generate_get_color_defaults() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_typography_defaults', generate_get_default_fonts() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_spacing_defaults', generate_spacing_get_defaults() );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customizer_live_preview' ) ) {
|
||||
@ -294,13 +292,19 @@ if ( ! function_exists( 'generate_customizer_live_preview' ) ) {
|
||||
|
||||
wp_enqueue_script( 'generate-themecustomizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-live-preview.js', array( 'customize-preview' ), GENERATE_VERSION, true );
|
||||
|
||||
wp_localize_script( 'generate-themecustomizer', 'generatepress_live_preview', array(
|
||||
'mobile' => generate_get_media_query( 'mobile' ),
|
||||
'tablet' => generate_get_media_query( 'tablet' ),
|
||||
'desktop' => generate_get_media_query( 'desktop' ),
|
||||
'contentLeft' => absint( $spacing_settings['content_left'] ),
|
||||
'contentRight' => absint( $spacing_settings['content_right'] ),
|
||||
) );
|
||||
wp_localize_script(
|
||||
'generate-themecustomizer',
|
||||
'generatepress_live_preview',
|
||||
array(
|
||||
'mobile' => generate_get_media_query( 'mobile' ),
|
||||
'tablet' => generate_get_media_query( 'tablet' ),
|
||||
'desktop' => generate_get_media_query( 'desktop' ),
|
||||
'contentLeft' => absint( $spacing_settings['content_left'] ),
|
||||
'contentRight' => absint( $spacing_settings['content_right'] ),
|
||||
'isFlex' => generate_is_using_flexbox(),
|
||||
'isRTL' => is_rtl(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,6 +329,20 @@ function generate_has_custom_logo_callback() {
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
function generate_sanitize_preset_layout( $input ) {
|
||||
function generate_sanitize_preset_layout() {
|
||||
return 'current';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display options if we're using the Floats structure.
|
||||
*/
|
||||
function generate_is_using_floats_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine whether to show the inline logo option.
|
||||
*/
|
||||
function generate_show_inline_logo_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' ) && generate_has_logo_site_branding();
|
||||
}
|
||||
|
Reference in New Issue
Block a user