updated theme GeneratePress
version 3.3.0
This commit is contained in:
@ -131,87 +131,89 @@ class GeneratePress_Typography {
|
||||
}
|
||||
);
|
||||
|
||||
if ( ! empty( $typography ) ) {
|
||||
$css = new GeneratePress_CSS();
|
||||
if ( empty( $typography ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$body_selector = 'body';
|
||||
$paragraph_selector = 'p';
|
||||
$css = new GeneratePress_CSS();
|
||||
|
||||
foreach ( $typography as $key => $data ) {
|
||||
$options = wp_parse_args(
|
||||
$data,
|
||||
self::get_defaults()
|
||||
);
|
||||
$body_selector = 'body';
|
||||
$paragraph_selector = 'p';
|
||||
|
||||
$selector = self::get_css_selector( $options['selector'] );
|
||||
foreach ( $typography as $key => $data ) {
|
||||
$options = wp_parse_args(
|
||||
$data,
|
||||
self::get_defaults()
|
||||
);
|
||||
|
||||
if ( 'custom' === $selector ) {
|
||||
$selector = $options['customSelector'];
|
||||
}
|
||||
$selector = self::get_css_selector( $options['selector'] );
|
||||
|
||||
$font_family = self::get_font_family( $options['fontFamily'] );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-family', $font_family );
|
||||
$css->add_property( 'font-weight', $options['fontWeight'] );
|
||||
$css->add_property( 'text-transform', $options['textTransform'] );
|
||||
$css->add_property( 'font-style', $options['fontStyle'] );
|
||||
$css->add_property( 'text-decoration', $options['textDecoration'] );
|
||||
$css->add_property( 'font-size', $options['fontSize'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacing'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeight'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottom'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeight'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottom'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'tablet' ) );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-size', $options['fontSizeTablet'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacingTablet'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeightTablet'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomTablet'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeightTablet'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomTablet'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'mobile' ) );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-size', $options['fontSizeMobile'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacingMobile'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeightMobile'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomMobile'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeightMobile'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomMobile'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
if ( 'custom' === $selector ) {
|
||||
$selector = $options['customSelector'];
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
$font_family = self::get_font_family( $options['fontFamily'] );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-family', $font_family );
|
||||
$css->add_property( 'font-weight', $options['fontWeight'] );
|
||||
$css->add_property( 'text-transform', $options['textTransform'] );
|
||||
$css->add_property( 'font-style', $options['fontStyle'] );
|
||||
$css->add_property( 'text-decoration', $options['textDecoration'] );
|
||||
$css->add_property( 'font-size', $options['fontSize'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacing'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeight'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottom'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeight'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottom'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'tablet' ) );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-size', $options['fontSizeTablet'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacingTablet'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeightTablet'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomTablet'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeightTablet'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomTablet'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'mobile' ) );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-size', $options['fontSizeMobile'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacingMobile'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeightMobile'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomMobile'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeightMobile'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomMobile'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,10 +260,10 @@ if ( ! function_exists( 'generate_base_css' ) ) {
|
||||
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
if ( ! empty( $data['slug'] ) && ! empty( $data['color'] ) ) {
|
||||
$css->set_selector( '.has-' . $data['slug'] . '-color' );
|
||||
$css->set_selector( ':root .has-' . $data['slug'] . '-color' );
|
||||
$css->add_property( 'color', 'var(--' . $data['slug'] . ')' );
|
||||
|
||||
$css->set_selector( '.has-' . $data['slug'] . '-background-color' );
|
||||
$css->set_selector( ':root .has-' . $data['slug'] . '-background-color' );
|
||||
$css->add_property( 'background-color', 'var(--' . $data['slug'] . ')' );
|
||||
}
|
||||
}
|
||||
@ -486,6 +486,11 @@ if ( ! function_exists( 'generate_advanced_css' ) ) {
|
||||
$css->add_property( 'background-color', $settings['back_to_top_background_color_hover'] );
|
||||
$css->add_property( 'color', $settings['back_to_top_text_color_hover'] );
|
||||
|
||||
$css->set_selector( ':root' );
|
||||
$css->add_property( '--gp-search-modal-bg-color', $settings['search_modal_bg_color'] );
|
||||
$css->add_property( '--gp-search-modal-text-color', $settings['search_modal_text_color'] );
|
||||
$css->add_property( '--gp-search-modal-overlay-bg-color', $settings['search_modal_overlay_bg_color'] );
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'mobile-menu' ) );
|
||||
$css->set_selector( '.main-navigation .menu-bar-item:hover > a, .main-navigation .menu-bar-item.sfHover > a' );
|
||||
$css->add_property( 'background', 'none' );
|
||||
@ -543,7 +548,7 @@ if ( ! function_exists( 'generate_font_css' ) ) {
|
||||
$css->add_property( 'margin-bottom', floatval( $settings['paragraph_margin'] ), $defaults['paragraph_margin'], 'em' );
|
||||
|
||||
if ( apply_filters( 'generate_do_wp_block_margin_bottom', true ) ) {
|
||||
$css->set_selector( '.entry-content > [class*="wp-block-"]:not(:last-child)' );
|
||||
$css->set_selector( '.entry-content > [class*="wp-block-"]:not(:last-child):not(.wp-block-heading)' );
|
||||
$css->add_property( 'margin-bottom', floatval( $settings['paragraph_margin'] ), false, 'em' );
|
||||
}
|
||||
|
||||
@ -1276,3 +1281,55 @@ function generate_update_dynamic_css_cache() {
|
||||
$css = generate_get_dynamic_css();
|
||||
update_option( 'generate_dynamic_css_output', wp_strip_all_tags( $css ) );
|
||||
}
|
||||
|
||||
add_action( 'generate_base_css', 'generate_do_modal_css' );
|
||||
/**
|
||||
* Do the modal CSS.
|
||||
*
|
||||
* @param Object $css The existing CSS object.
|
||||
*/
|
||||
function generate_do_modal_css( $css ) {
|
||||
if ( ! apply_filters( 'generate_enable_modal_script', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css->set_selector( '.gp-modal:not(.gp-modal--open):not(.gp-modal--transition)' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
|
||||
$css->set_selector( '.gp-modal--transition:not(.gp-modal--open)' );
|
||||
$css->add_property( 'pointer-events', 'none' );
|
||||
|
||||
$css->set_selector( '.gp-modal-overlay:not(.gp-modal-overlay--open):not(.gp-modal--transition)' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
|
||||
$css->set_selector( '.gp-modal__overlay' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
$css->add_property( 'position', 'fixed' );
|
||||
$css->add_property( 'top', '0' );
|
||||
$css->add_property( 'left', '0' );
|
||||
$css->add_property( 'right', '0' );
|
||||
$css->add_property( 'bottom', '0' );
|
||||
$css->add_property( 'background', 'rgba(0,0,0,0.2)' );
|
||||
$css->add_property( 'display', 'flex' );
|
||||
$css->add_property( 'justify-content', 'center' );
|
||||
$css->add_property( 'align-items', 'center' );
|
||||
$css->add_property( 'z-index', '10000' );
|
||||
$css->add_property( 'backdrop-filter', 'blur(3px)' );
|
||||
$css->add_property( 'transition', 'opacity 500ms ease' );
|
||||
$css->add_property( 'opacity', 0 );
|
||||
|
||||
$css->set_selector( '.gp-modal--open:not(.gp-modal--transition) .gp-modal__overlay' );
|
||||
$css->add_property( 'opacity', 1 );
|
||||
|
||||
$css->set_selector( '.gp-modal__container' );
|
||||
$css->add_property( 'max-width', '100%' );
|
||||
$css->add_property( 'max-height', '100vh' );
|
||||
$css->add_property( 'transform', 'scale(0.9)' );
|
||||
$css->add_property( 'transition', 'transform 500ms ease' );
|
||||
$css->add_property( 'padding', '0 10px' );
|
||||
|
||||
$css->set_selector( '.gp-modal--open:not(.gp-modal--transition) .gp-modal__container' );
|
||||
$css->add_property( 'transform', 'scale(1)' );
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
@ -304,6 +304,7 @@ if ( ! function_exists( 'generate_customize_register' ) ) {
|
||||
require_once $fields_dir . '/footer-widgets.php';
|
||||
require_once $fields_dir . '/footer-bar.php';
|
||||
require_once $fields_dir . '/back-to-top.php';
|
||||
require_once $fields_dir . '/search-modal.php';
|
||||
|
||||
do_action( 'generate_customize_after_controls', $wp_customize );
|
||||
|
||||
@ -1009,6 +1010,31 @@ if ( ! function_exists( 'generate_customize_register' ) ) {
|
||||
),
|
||||
'settings' => 'generate_settings[nav_search]',
|
||||
'priority' => 23,
|
||||
'active_callback' => function() {
|
||||
return 'enable' === generate_get_option( 'nav_search' );
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[nav_search_modal]',
|
||||
array(
|
||||
'default' => $defaults['nav_search_modal'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_sanitize_checkbox',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_settings[nav_search_modal]',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'label' => esc_html__( 'Enable navigation search modal', 'generatepress' ),
|
||||
'section' => 'generate_layout_navigation',
|
||||
'priority' => 23,
|
||||
'active_callback' => function() {
|
||||
return 'disable' === generate_get_option( 'nav_search' );
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -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 '';
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
'nav_dropdown_type' => 'hover',
|
||||
'nav_dropdown_direction' => is_rtl() ? 'left' : 'right',
|
||||
'nav_search' => 'disable',
|
||||
'nav_search_modal' => false,
|
||||
'content_layout_setting' => 'separate-containers',
|
||||
'layout_setting' => 'right-sidebar',
|
||||
'blog_layout_setting' => 'right-sidebar',
|
||||
@ -188,6 +189,9 @@ if ( ! function_exists( 'generate_get_color_defaults' ) ) {
|
||||
'back_to_top_background_color_hover' => 'rgba( 0,0,0,0.6 )',
|
||||
'back_to_top_text_color' => '#ffffff',
|
||||
'back_to_top_text_color_hover' => '#ffffff',
|
||||
'search_modal_bg_color' => 'var(--base-3)',
|
||||
'search_modal_text_color' => 'var(--contrast)',
|
||||
'search_modal_overlay_bg_color' => 'rgba(0,0,0,0.2)',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -93,6 +93,10 @@ if ( ! function_exists( 'generate_scripts' ) ) {
|
||||
wp_enqueue_script( 'generate-dropdown-click', $dir_uri . "/assets/js/dropdown-click{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
if ( apply_filters( 'generate_enable_modal_script', false ) ) {
|
||||
wp_enqueue_script( 'generate-modal', $dir_uri . '/assets/dist/modal.js', array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
wp_enqueue_script( 'generate-navigation-search', $dir_uri . "/assets/js/navigation-search{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
|
||||
|
@ -228,7 +228,9 @@ function generate_save_layout_meta_data( $post_id ) {
|
||||
}
|
||||
|
||||
$sidebar_layout_key = '_generate-sidebar-layout-meta';
|
||||
$sidebar_layout_value = filter_input( INPUT_POST, $sidebar_layout_key, FILTER_SANITIZE_STRING );
|
||||
$sidebar_layout_value = isset( $_POST[ $sidebar_layout_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $sidebar_layout_key ] ) )
|
||||
: '';
|
||||
|
||||
if ( $sidebar_layout_value ) {
|
||||
update_post_meta( $post_id, $sidebar_layout_key, $sidebar_layout_value );
|
||||
@ -237,7 +239,9 @@ function generate_save_layout_meta_data( $post_id ) {
|
||||
}
|
||||
|
||||
$footer_widget_key = '_generate-footer-widget-meta';
|
||||
$footer_widget_value = filter_input( INPUT_POST, $footer_widget_key, FILTER_SANITIZE_STRING );
|
||||
$footer_widget_value = isset( $_POST[ $footer_widget_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $footer_widget_key ] ) )
|
||||
: '';
|
||||
|
||||
// Check for empty string to allow 0 as a value.
|
||||
if ( '' !== $footer_widget_value ) {
|
||||
@ -247,7 +251,9 @@ function generate_save_layout_meta_data( $post_id ) {
|
||||
}
|
||||
|
||||
$page_builder_container_key = '_generate-full-width-content';
|
||||
$page_builder_container_value = filter_input( INPUT_POST, $page_builder_container_key, FILTER_SANITIZE_STRING );
|
||||
$page_builder_container_value = isset( $_POST[ $page_builder_container_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $page_builder_container_key ] ) )
|
||||
: '';
|
||||
|
||||
if ( $page_builder_container_value ) {
|
||||
update_post_meta( $post_id, $page_builder_container_key, $page_builder_container_value );
|
||||
@ -258,7 +264,9 @@ function generate_save_layout_meta_data( $post_id ) {
|
||||
// We only need this if the Disable Elements module doesn't exist.
|
||||
if ( ! defined( 'GENERATE_DE_VERSION' ) ) {
|
||||
$disable_content_title_key = '_generate-disable-headline';
|
||||
$disable_content_title_value = filter_input( INPUT_POST, $disable_content_title_key, FILTER_SANITIZE_STRING );
|
||||
$disable_content_title_value = isset( $_POST[ $disable_content_title_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $disable_content_title_key ] ) )
|
||||
: '';
|
||||
|
||||
if ( $disable_content_title_value ) {
|
||||
update_post_meta( $post_id, $disable_content_title_key, $disable_content_title_value );
|
||||
|
@ -156,8 +156,8 @@ function generate_set_comment_form_defaults( $defaults ) {
|
||||
esc_html__( 'Comment', 'generatepress' )
|
||||
);
|
||||
|
||||
$defaults['comment_notes_before'] = null;
|
||||
$defaults['comment_notes_after'] = null;
|
||||
$defaults['comment_notes_before'] = '';
|
||||
$defaults['comment_notes_after'] = '';
|
||||
$defaults['id_form'] = 'commentform';
|
||||
$defaults['id_submit'] = 'submit';
|
||||
$defaults['title_reply'] = apply_filters( 'generate_leave_comment', __( 'Leave a Comment', 'generatepress' ) );
|
||||
|
@ -115,32 +115,21 @@ if ( ! function_exists( 'generate_construct_logo' ) ) {
|
||||
)
|
||||
);
|
||||
|
||||
$data = get_theme_mod( 'custom_logo' ) && ( '' !== $retina_logo_url || generate_is_using_flexbox() )
|
||||
? wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) )
|
||||
: false;
|
||||
|
||||
if ( '' !== $retina_logo_url ) {
|
||||
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
|
||||
}
|
||||
|
||||
// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
|
||||
if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
|
||||
$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
$attr['height'] = $data['height'];
|
||||
}
|
||||
if ( $data ) {
|
||||
if ( isset( $data['width'] ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
}
|
||||
} elseif ( generate_is_using_flexbox() ) {
|
||||
// Add this to flexbox version only until we can verify it won't conflict with existing installs.
|
||||
if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
|
||||
$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
if ( isset( $data['width'] ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
}
|
||||
|
||||
if ( isset( $data['height'] ) ) {
|
||||
$attr['height'] = $data['height'];
|
||||
}
|
||||
}
|
||||
if ( isset( $data['height'] ) ) {
|
||||
$attr['height'] = $data['height'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,6 +396,10 @@ function generate_get_footer_entry_meta_items() {
|
||||
$items[] = 'post-navigation';
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
$items = array_diff( (array) $items, array( 'post-navigation' ) );
|
||||
}
|
||||
|
||||
// Disable post meta items based on their individual filters.
|
||||
$items = generate_disable_post_meta_items( $items );
|
||||
|
||||
|
111
wp-content/themes/generatepress/inc/structure/search-modal.php
Normal file
111
wp-content/themes/generatepress/inc/structure/search-modal.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Post meta elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action( 'wp_footer', 'generate_do_search_modal' );
|
||||
/**
|
||||
* Create the search modal HTML.
|
||||
*/
|
||||
function generate_do_search_modal() {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="gp-modal gp-search-modal" id="gp-search">
|
||||
<div class="gp-modal__overlay" tabindex="-1" data-gpmodal-close>
|
||||
<div class="gp-modal__container">
|
||||
<?php do_action( 'generate_inside_search_modal' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_search_modal_trigger' );
|
||||
/**
|
||||
* Create the search modal trigger.
|
||||
*/
|
||||
function generate_do_search_modal_trigger() {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<span class="menu-bar-item">
|
||||
<a href="#" role="button" aria-label="<?php _e( 'Open search', 'generatepress' ); ?>" data-gpmodal-trigger="gp-search"><?php echo generate_get_svg_icon( 'search', true ); // phpcs:ignore -- Escaped in function. ?></a>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_filter( 'generate_enable_modal_script', 'generate_enable_search_modal' );
|
||||
/**
|
||||
* Enable the search modal.
|
||||
*/
|
||||
function generate_enable_search_modal() {
|
||||
return generate_get_option( 'nav_search_modal' );
|
||||
}
|
||||
|
||||
add_action( 'generate_base_css', 'generate_do_search_modal_css' );
|
||||
/**
|
||||
* Do the modal CSS.
|
||||
*
|
||||
* @param Object $css The existing CSS object.
|
||||
*/
|
||||
function generate_do_search_modal_css( $css ) {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css->set_selector( '.search-modal-fields' );
|
||||
$css->add_property( 'display', 'flex' );
|
||||
|
||||
$css->set_selector( '.gp-search-modal .gp-modal__overlay' );
|
||||
$css->add_property( 'align-items', 'flex-start' );
|
||||
$css->add_property( 'padding-top', '25vh' );
|
||||
$css->add_property( 'background', 'var(--gp-search-modal-overlay-bg-color)' );
|
||||
|
||||
$css->set_selector( '.search-modal-form' );
|
||||
$css->add_property( 'width', '500px' );
|
||||
$css->add_property( 'max-width', '100%' );
|
||||
$css->add_property( 'background-color', 'var(--gp-search-modal-bg-color)' );
|
||||
$css->add_property( 'color', 'var(--gp-search-modal-text-color)' );
|
||||
|
||||
$css->set_selector( '.search-modal-form .search-field, .search-modal-form .search-field:focus' );
|
||||
$css->add_property( 'width', '100%' );
|
||||
$css->add_property( 'height', '60px' );
|
||||
$css->add_property( 'background-color', 'transparent' );
|
||||
$css->add_property( 'border', 0 );
|
||||
$css->add_property( 'appearance', 'none' );
|
||||
$css->add_property( 'color', 'currentColor' );
|
||||
|
||||
$css->set_selector( '.search-modal-fields button, .search-modal-fields button:active, .search-modal-fields button:focus, .search-modal-fields button:hover' );
|
||||
$css->add_property( 'background-color', 'transparent' );
|
||||
$css->add_property( 'border', 0 );
|
||||
$css->add_property( 'color', 'currentColor' );
|
||||
$css->add_property( 'width', '60px' );
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
add_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
|
||||
/**
|
||||
* Add our search fields to the modal.
|
||||
*/
|
||||
function generate_do_search_fields() {
|
||||
?>
|
||||
<form role="search" method="get" class="search-modal-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
||||
<label class="screen-reader-text"><?php echo apply_filters( 'generate_search_label', _x( 'Search for:', 'label', 'generatepress' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||
<div class="search-modal-fields">
|
||||
<input type="search" class="search-field" placeholder="<?php echo esc_attr( apply_filters( 'generate_search_placeholder', _x( 'Search …', 'placeholder', 'generatepress' ) ) ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
|
||||
<button aria-label="<?php echo esc_attr( apply_filters( 'generate_search_button', _x( 'Search', 'submit button', 'generatepress' ) ) ); ?>"><?php echo generate_get_svg_icon( 'search' ); // phpcs:ignore -- Escaped in function. ?></button>
|
||||
</div>
|
||||
<?php do_action( 'generate_inside_search_modal_form' ); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
Reference in New Issue
Block a user