updated theme GeneratePress version 3.0.2

This commit is contained in:
2020-10-20 15:16:18 +00:00
committed by Gitium
parent dcc1a6ca18
commit 1047e0b29f
129 changed files with 16624 additions and 8924 deletions

View File

@ -18,7 +18,7 @@ if ( ! function_exists( 'generate_construct_header' ) ) {
*/
function generate_construct_header() {
?>
<header id="masthead" <?php generate_do_element_classes( 'header' ); ?> <?php generate_do_microdata( 'header' ); ?>>
<header id="masthead" <?php generate_do_element_classes( 'header' ); ?>>
<div <?php generate_do_element_classes( 'inside_header' ); ?>>
<?php
/**
@ -28,8 +28,10 @@ if ( ! function_exists( 'generate_construct_header' ) ) {
*/
do_action( 'generate_before_header_content' );
// Add our main header items.
generate_header_items();
if ( ! generate_is_using_flexbox() ) {
// Add our main header items.
generate_header_items();
}
/**
* generate_after_header_content hook.
@ -40,8 +42,8 @@ if ( ! function_exists( 'generate_construct_header' ) ) {
*/
do_action( 'generate_after_header_content' );
?>
</div><!-- .inside-header -->
</header><!-- #masthead -->
</div>
</header>
<?php
}
}
@ -54,7 +56,8 @@ if ( ! function_exists( 'generate_header_items' ) ) {
* @since 1.2.9.7
*/
function generate_header_items() {
$order = apply_filters( 'generate_header_items_order',
$order = apply_filters(
'generate_header_items_order',
array(
'header-widget',
'site-branding',
@ -103,12 +106,15 @@ if ( ! function_exists( 'generate_construct_logo' ) ) {
*/
do_action( 'generate_before_logo' );
$attr = apply_filters( 'generate_logo_attributes', array(
'class' => 'header-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
) );
$attr = apply_filters(
'generate_logo_attributes',
array(
'class' => 'header-image is-logo-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
)
);
if ( '' !== $retina_logo_url ) {
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
@ -117,6 +123,16 @@ if ( ! function_exists( 'generate_construct_logo' ) ) {
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'];
}
}
} 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 ) ) {
$attr['width'] = $data['width'];
$attr['height'] = $data['height'];
@ -132,16 +148,21 @@ if ( ! function_exists( 'generate_construct_logo' ) ) {
}
// Print our HTML.
echo apply_filters( 'generate_logo_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-logo">
<a href="%1$s" title="%2$s" rel="home">
<img %3$s />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'generate_logo_output',
sprintf(
'<div class="site-logo">
<a href="%1$s" title="%2$s" rel="home">
<img %3$s />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
),
$logo_url,
$html_attr
), $logo_url, $html_attr );
);
/**
* generate_after_logo hook.
@ -169,49 +190,63 @@ if ( ! function_exists( 'generate_construct_site_title' ) ) {
$tagline = get_bloginfo( 'description' );
// If the disable title checkbox is checked, or the title field is empty, return true.
$disable_title = ( '1' == $generate_settings['hide_title'] || '' == $title ) ? true : false;
$disable_title = ( '1' == $generate_settings['hide_title'] || '' == $title ) ? true : false; // phpcs:ignore
// If the disable tagline checkbox is checked, or the tagline field is empty, return true.
$disable_tagline = ( '1' == $generate_settings['hide_tagline'] || '' == $tagline ) ? true : false;
$disable_tagline = ( '1' == $generate_settings['hide_tagline'] || '' == $tagline ) ? true : false; // phpcs:ignore
$schema_type = generate_get_schema_type();
// Build our site title.
$site_title = apply_filters( 'generate_site_title_output', sprintf(
'<%1$s class="main-title" itemprop="headline">
<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( '/' ) ) ),
get_bloginfo( 'name' )
) );
$site_title = apply_filters(
'generate_site_title_output',
sprintf(
'<%1$s class="main-title"%4$s>
<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( '/' ) ) ),
get_bloginfo( 'name' ),
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
)
);
// Build our tagline.
$site_tagline = apply_filters( 'generate_site_description_output', sprintf(
'<p class="site-description" itemprop="description">
%1$s
</p>',
html_entity_decode( get_bloginfo( 'description', 'display' ) )
) );
$site_tagline = apply_filters(
'generate_site_description_output',
sprintf(
'<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"' : ''
)
);
// Site title and tagline.
if ( false == $disable_title || false == $disable_tagline ) {
if ( generate_get_option( 'inline_logo_site_branding' ) && generate_has_logo_site_branding() ) {
if ( false === $disable_title || false === $disable_tagline ) {
if ( generate_needs_site_branding_container() ) {
echo '<div class="site-branding-container">';
generate_construct_logo();
}
echo apply_filters( 'generate_site_branding_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-branding">
%1$s
%2$s
</div>',
( ! $disable_title ) ? $site_title : '',
( ! $disable_tagline ) ? $site_tagline : ''
) );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- outputting site title and tagline. False positive.
echo apply_filters(
'generate_site_branding_output',
sprintf(
'<div class="site-branding">
%1$s
%2$s
</div>',
( ! $disable_title ) ? $site_title : '',
( ! $disable_tagline ) ? $site_tagline : ''
)
);
if ( generate_get_option( 'inline_logo_site_branding' ) && generate_has_logo_site_branding() ) {
echo '</div><!-- .site-branding-container -->';
if ( generate_needs_site_branding_container() ) {
echo '</div>';
}
}
}
@ -222,6 +257,7 @@ add_filter( 'generate_header_items_order', 'generate_reorder_inline_site_brandin
* Remove the logo from it's usual position.
*
* @since 2.3
* @param array $order Order of the header items.
*/
function generate_reorder_inline_site_branding( $order ) {
if ( ! generate_get_option( 'inline_logo_site_branding' ) || ! generate_has_logo_site_branding() ) {
@ -241,14 +277,61 @@ if ( ! function_exists( 'generate_construct_header_widget' ) ) {
* @since 1.3.28
*/
function generate_construct_header_widget() {
if ( is_active_sidebar( 'header' ) ) : ?>
if ( is_active_sidebar( 'header' ) ) :
?>
<div class="header-widget">
<?php dynamic_sidebar( 'header' ); ?>
</div>
<?php endif;
<?php
endif;
}
}
add_action( 'generate_before_header_content', 'generate_do_site_logo', 5 );
/**
* Add the site logo to our header.
* Only added if we aren't using floats to preserve backwards compatibility.
*
* @since 3.0.0
*/
function generate_do_site_logo() {
if ( ! generate_is_using_flexbox() || generate_needs_site_branding_container() ) {
return;
}
generate_construct_logo();
}
add_action( 'generate_before_header_content', 'generate_do_site_branding' );
/**
* Add the site branding to our header.
* Only added if we aren't using floats to preserve backwards compatibility.
*
* @since 3.0.0
*/
function generate_do_site_branding() {
if ( ! generate_is_using_flexbox() ) {
return;
}
generate_construct_site_title();
}
add_action( 'generate_after_header_content', 'generate_do_header_widget' );
/**
* Add the header widget to our header.
* Only used when grid isn't using floats to preserve backwards compatibility.
*
* @since 3.0.0
*/
function generate_do_header_widget() {
if ( ! generate_is_using_flexbox() ) {
return;
}
generate_construct_header_widget();
}
if ( ! function_exists( 'generate_top_bar' ) ) {
add_action( 'generate_before_header', 'generate_top_bar', 5 );
/**
@ -260,9 +343,19 @@ if ( ! function_exists( 'generate_top_bar' ) ) {
if ( ! is_active_sidebar( 'top-bar' ) ) {
return;
}
$inside_top_bar_class = '';
if ( 'contained' === generate_get_option( 'top_bar_inner_width' ) ) {
$inside_top_bar_class = ' grid-container grid-parent';
if ( generate_is_using_flexbox() ) {
$inside_top_bar_class = ' grid-container';
}
}
?>
<div <?php generate_do_element_classes( 'top_bar' ); ?>>
<div class="inside-top-bar<?php if ( 'contained' == generate_get_option( 'top_bar_inner_width' ) ) echo ' grid-container grid-parent'; ?>">
<div class="inside-top-bar<?php echo $inside_top_bar_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- False positive. ?>">
<?php dynamic_sidebar( 'top-bar' ); ?>
</div>
</div>
@ -292,7 +385,7 @@ if ( ! function_exists( 'generate_add_viewport' ) ) {
* @since 1.1.0
*/
function generate_add_viewport() {
echo apply_filters( 'generate_meta_viewport', '<meta name="viewport" content="width=device-width, initial-scale=1">' ); // WPCS: XSS ok.
echo apply_filters( 'generate_meta_viewport', '<meta name="viewport" content="width=device-width, initial-scale=1">' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
@ -303,7 +396,8 @@ add_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 );
* @since 2.0
*/
function generate_do_skip_to_content_link() {
printf( '<a class="screen-reader-text skip-link" href="#content" title="%1$s">%2$s</a>',
printf(
'<a class="screen-reader-text skip-link" href="#content" title="%1$s">%2$s</a>',
esc_attr__( 'Skip to content', 'generatepress' ),
esc_html__( 'Skip to content', 'generatepress' )
);