updated theme GeneratePress
version 3.4.0
This commit is contained in:
@ -158,11 +158,14 @@ function generate_enqueue_backend_block_editor_assets() {
|
||||
$text_color = $color_settings['content_text_color'];
|
||||
}
|
||||
|
||||
$sidebar_layout = get_post_meta( get_the_ID(), '_generate_sidebar_layout', true );
|
||||
$content_area_type = get_post_meta( get_the_ID(), '_generate-full-width-content', true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-block-editor',
|
||||
'generatepressBlockEditor',
|
||||
array(
|
||||
'globalSidebarLayout' => generate_get_block_editor_sidebar_layout( false ),
|
||||
'sidebarLayout' => $sidebar_layout ? $sidebar_layout : generate_get_block_editor_sidebar_layout( false ),
|
||||
'containerWidth' => generate_get_option( 'container_width' ),
|
||||
'contentPaddingRight' => absint( $spacing_settings['content_right'] ) . 'px',
|
||||
'contentPaddingLeft' => absint( $spacing_settings['content_left'] ) . 'px',
|
||||
@ -170,7 +173,7 @@ function generate_enqueue_backend_block_editor_assets() {
|
||||
'leftSidebarWidth' => apply_filters( 'generate_left_sidebar_width', '25' ),
|
||||
'text_color' => $text_color,
|
||||
'show_editor_styles' => apply_filters( 'generate_show_block_editor_styles', true ),
|
||||
'contentAreaType' => apply_filters( 'generate_block_editor_content_area_type', '' ),
|
||||
'contentAreaType' => $content_area_type ? $content_area_type : apply_filters( 'generate_block_editor_content_area_type', '' ),
|
||||
'customContentWidth' => apply_filters( 'generate_block_editor_container_width', '' ),
|
||||
)
|
||||
);
|
||||
@ -360,16 +363,10 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( $color_settings['h1_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h1_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
$css->add_property( 'color', $color_settings['h1_color'] );
|
||||
|
||||
if ( $color_settings['content_title_color'] ) {
|
||||
$css->set_selector( '.editor-styles-wrapper .editor-post-title__input' );
|
||||
$css->set_selector( '.edit-post-visual-editor__post-title-wrapper h1' );
|
||||
$css->add_property( 'color', $color_settings['content_title_color'] );
|
||||
}
|
||||
|
||||
@ -385,13 +382,7 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( $color_settings['h2_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h2_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
$css->add_property( 'color', $color_settings['h2_color'] );
|
||||
|
||||
$css->set_selector( 'h3' );
|
||||
|
||||
@ -405,13 +396,7 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( $color_settings['h3_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h3_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
$css->add_property( 'color', $color_settings['h3_color'] );
|
||||
|
||||
$css->set_selector( 'h4' );
|
||||
|
||||
@ -433,13 +418,7 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $color_settings['h4_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h4_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
$css->add_property( 'color', $color_settings['h4_color'] );
|
||||
|
||||
$css->set_selector( 'h5' );
|
||||
|
||||
@ -461,13 +440,7 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $color_settings['h5_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h5_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
$css->add_property( 'color', $color_settings['h5_color'] );
|
||||
|
||||
$css->set_selector( 'h6' );
|
||||
|
||||
@ -489,13 +462,7 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $color_settings['h6_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h6_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
$css->add_property( 'color', $color_settings['h6_color'] );
|
||||
|
||||
$css->set_selector( 'a.button, .block-editor-block-list__layout .wp-block-button .wp-block-button__link' );
|
||||
|
||||
|
@ -103,7 +103,7 @@ if ( ! class_exists( 'GeneratePress_CSS' ) ) {
|
||||
}
|
||||
|
||||
// Add our unit to our value if it exists.
|
||||
if ( $unit && '' !== $unit ) {
|
||||
if ( $unit && '' !== $unit && is_numeric( $value ) ) {
|
||||
$value = $value . $unit;
|
||||
if ( '' !== $og_default ) {
|
||||
$og_default = $og_default . $unit;
|
||||
|
@ -287,7 +287,6 @@ class GeneratePress_HTML_Attributes {
|
||||
*/
|
||||
public function entry_header( $attributes ) {
|
||||
$attributes['class'] .= ' entry-header';
|
||||
$attributes['aria-label'] = esc_attr__( 'Content', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class GeneratePress_Typography {
|
||||
public function __construct() {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_google_fonts' ) );
|
||||
add_filter( 'generate_editor_styles', array( $this, 'add_editor_styles' ) );
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) );
|
||||
|
||||
// Load fonts the old way in versions before 5.8 as block_editor_settings_all didn't exist.
|
||||
if ( version_compare( $GLOBALS['wp_version'], '5.8', '<' ) ) {
|
||||
@ -118,9 +119,10 @@ class GeneratePress_Typography {
|
||||
/**
|
||||
* Build our typography CSS.
|
||||
*
|
||||
* @param string $module The name of the module we're generating CSS for.
|
||||
* @param string $module The name of the module we're generating CSS for.
|
||||
* @param string $specific_selector Target a specific selector to get the CSS for.
|
||||
*/
|
||||
public static function get_css( $module = 'core' ) {
|
||||
public static function get_css( $module = 'core', $specific_selector = '' ) {
|
||||
$typography = generate_get_option( 'typography' );
|
||||
|
||||
// Get data for a specific module so CSS can be compiled separately.
|
||||
@ -152,6 +154,14 @@ class GeneratePress_Typography {
|
||||
$selector = $options['customSelector'];
|
||||
}
|
||||
|
||||
if (
|
||||
$specific_selector &&
|
||||
$options['selector'] !== $specific_selector &&
|
||||
$options['customSelector'] !== $specific_selector
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$font_family = self::get_font_family( $options['fontFamily'] );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
@ -321,6 +331,7 @@ class GeneratePress_Typography {
|
||||
public static function get_defaults() {
|
||||
return array(
|
||||
'selector' => '',
|
||||
'customSelector' => '',
|
||||
'fontFamily' => '',
|
||||
'fontWeight' => '',
|
||||
'textTransform' => '',
|
||||
@ -357,6 +368,28 @@ class GeneratePress_Typography {
|
||||
|
||||
return $editor_styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add scripts to the block editor.
|
||||
*/
|
||||
public function enqueue_editor_scripts() {
|
||||
$html_typography = self::get_css( 'core', 'html' );
|
||||
|
||||
if ( $html_typography ) {
|
||||
wp_add_inline_style(
|
||||
/**
|
||||
* `wp-edit-blocks` is enqueued in the editor, including the iframes.
|
||||
* This is not ideal, as we should use the `block_editor_settings_all` filter to add editor CSS.
|
||||
* However, that filter prepends all selectors with `.editor-styles-wrapper`, which breaks the above
|
||||
* selector, as it appears above that element in the DOM.
|
||||
*
|
||||
* Related: https://github.com/tomusborne/generatepress/issues/472
|
||||
*/
|
||||
'wp-edit-blocks',
|
||||
$html_typography
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Typography::get_instance();
|
||||
|
@ -443,21 +443,21 @@ if ( ! function_exists( 'generate_customize_register' ) ) {
|
||||
'textTransform' => 'sanitize_text_field',
|
||||
'textDecoration' => 'sanitize_text_field',
|
||||
'fontStyle' => 'sanitize_text_field',
|
||||
'fontSize' => 'generate_sanitize_empty_decimal_integer',
|
||||
'fontSizeTablet' => 'generate_sanitize_empty_decimal_integer',
|
||||
'fontSizeMobile' => 'generate_sanitize_empty_decimal_integer',
|
||||
'fontSize' => 'sanitize_text_field',
|
||||
'fontSizeTablet' => 'sanitize_text_field',
|
||||
'fontSizeMobile' => 'sanitize_text_field',
|
||||
'fontSizeUnit' => 'sanitize_text_field',
|
||||
'lineHeight' => 'generate_sanitize_empty_decimal_integer',
|
||||
'lineHeightTablet' => 'generate_sanitize_empty_decimal_integer',
|
||||
'lineHeightMobile' => 'generate_sanitize_empty_decimal_integer',
|
||||
'lineHeight' => 'sanitize_text_field',
|
||||
'lineHeightTablet' => 'sanitize_text_field',
|
||||
'lineHeightMobile' => 'sanitize_text_field',
|
||||
'lineHeightUnit' => 'sanitize_text_field',
|
||||
'letterSpacing' => 'generate_sanitize_empty_negative_decimal_integer',
|
||||
'letterSpacingTablet' => 'generate_sanitize_empty_negative_decimal_integer',
|
||||
'letterSpacingMobile' => 'generate_sanitize_empty_negative_decimal_integer',
|
||||
'letterSpacing' => 'sanitize_text_field',
|
||||
'letterSpacingTablet' => 'sanitize_text_field',
|
||||
'letterSpacingMobile' => 'sanitize_text_field',
|
||||
'letterSpacingUnit' => 'sanitize_text_field',
|
||||
'marginBottom' => 'generate_sanitize_empty_decimal_integer',
|
||||
'marginBottomTablet' => 'generate_sanitize_empty_decimal_integer',
|
||||
'marginBottomMobile' => 'generate_sanitize_empty_decimal_integer',
|
||||
'marginBottom' => 'sanitize_text_field',
|
||||
'marginBottomTablet' => 'sanitize_text_field',
|
||||
'marginBottomMobile' => 'sanitize_text_field',
|
||||
'marginBottomUnit' => 'sanitize_text_field',
|
||||
'module' => 'sanitize_text_field',
|
||||
'group' => 'sanitize_text_field',
|
||||
@ -1011,7 +1011,7 @@ if ( ! function_exists( 'generate_customize_register' ) ) {
|
||||
'settings' => 'generate_settings[nav_search]',
|
||||
'priority' => 23,
|
||||
'active_callback' => function() {
|
||||
return 'enable' === generate_get_option( 'nav_search' );
|
||||
return 'enable' === generate_get_option( 'nav_search' ) || 'floats' === generate_get_option( 'structure' ) || 'font' === generate_get_option( 'icons' );
|
||||
},
|
||||
)
|
||||
);
|
||||
@ -1033,7 +1033,7 @@ if ( ! function_exists( 'generate_customize_register' ) ) {
|
||||
'section' => 'generate_layout_navigation',
|
||||
'priority' => 23,
|
||||
'active_callback' => function() {
|
||||
return 'disable' === generate_get_option( 'nav_search' );
|
||||
return 'disable' === generate_get_option( 'nav_search' ) && 'flexbox' === generate_get_option( 'structure' ) && 'svg' === generate_get_option( 'icons' );
|
||||
},
|
||||
)
|
||||
);
|
||||
|
@ -194,9 +194,7 @@ if ( ! function_exists( 'generate_construct_site_title' ) ) {
|
||||
'generate_site_title_output',
|
||||
sprintf(
|
||||
'<%1$s class="main-title"%4$s>
|
||||
<a href="%2$s" rel="home">
|
||||
%3$s
|
||||
</a>
|
||||
<a href="%2$s" rel="home">%3$s</a>
|
||||
</%1$s>',
|
||||
( is_front_page() && is_home() ) ? 'h1' : 'p',
|
||||
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
|
||||
@ -209,9 +207,7 @@ if ( ! function_exists( 'generate_construct_site_title' ) ) {
|
||||
$site_tagline = apply_filters(
|
||||
'generate_site_description_output',
|
||||
sprintf(
|
||||
'<p class="site-description"%2$s>
|
||||
%1$s
|
||||
</p>',
|
||||
'<p class="site-description"%2$s>%1$s</p>',
|
||||
html_entity_decode( get_bloginfo( 'description', 'display' ) ), // phpcs:ignore
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="description"' : ''
|
||||
)
|
||||
|
@ -490,6 +490,10 @@ function generate_add_menu_bar_items() {
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' );
|
||||
}
|
||||
|
||||
if ( generate_get_option( 'nav_search_modal' ) && 'flexbox' === generate_get_option( 'structure' ) && 'svg' === generate_get_option( 'icons' ) ) {
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_search_modal_trigger' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -453,12 +453,8 @@ if ( ! function_exists( 'generate_excerpt_more' ) ) {
|
||||
' ... <a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s">%3$s</a>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) ),
|
||||
__( 'Read more', 'generatepress' ),
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'generatepress' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
generate_get_read_more_text(),
|
||||
generate_get_read_more_aria_label()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -481,12 +477,8 @@ if ( ! function_exists( 'generate_content_more' ) ) {
|
||||
'<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s" aria-label="%4$s">%3$s</a></p>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ),
|
||||
__( 'Read more', 'generatepress' ),
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'generatepress' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
generate_get_read_more_text(),
|
||||
generate_get_read_more_aria_label()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -577,3 +569,31 @@ function generate_do_post_navigation( $template ) {
|
||||
generate_content_nav( 'nav-below' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the read more text for our posts.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
function generate_get_read_more_text() {
|
||||
return apply_filters(
|
||||
'generate_excerpt_more_text',
|
||||
__( 'Read more', 'generatepress' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the read more `aria-label` for our posts.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
function generate_get_read_more_aria_label() {
|
||||
return apply_filters(
|
||||
'generate_excerpt_more_aria_label',
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'Read more about %s', 'read more about post title', 'generatepress' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ function generate_do_search_modal() {
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_search_modal_trigger' );
|
||||
/**
|
||||
* Create the search modal trigger.
|
||||
*/
|
||||
@ -100,9 +99,9 @@ add_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
|
||||
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>
|
||||
<label for="search-modal-input" 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" />
|
||||
<input id="search-modal-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' ); ?>
|
||||
|
Reference in New Issue
Block a user