updated theme GeneratePress
version 3.0.2
This commit is contained in:
@ -20,10 +20,8 @@ if ( ! function_exists( 'generate_archive_title' ) ) {
|
||||
if ( ! function_exists( 'the_archive_title' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$clearfix = is_author() ? ' clearfix' : '';
|
||||
?>
|
||||
<header class="page-header<?php echo $clearfix; // WPCS: XSS ok, sanitization ok. ?>">
|
||||
<header class="page-header">
|
||||
<?php
|
||||
/**
|
||||
* generate_before_archive_title hook.
|
||||
@ -47,7 +45,7 @@ if ( ! function_exists( 'generate_archive_title' ) ) {
|
||||
*/
|
||||
do_action( 'generate_after_archive_title' );
|
||||
?>
|
||||
</header><!-- .page-header -->
|
||||
</header>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -59,7 +57,7 @@ if ( ! function_exists( 'generate_filter_the_archive_title' ) ) {
|
||||
*
|
||||
* @since 1.3.45
|
||||
*
|
||||
* @param string $title The archive title
|
||||
* @param string $title The archive title.
|
||||
* @return string The altered archive title
|
||||
*/
|
||||
function generate_filter_the_archive_title( $title ) {
|
||||
@ -73,10 +71,13 @@ if ( ! function_exists( 'generate_filter_the_archive_title' ) ) {
|
||||
* what author we're dealing with (if that is the case).
|
||||
*/
|
||||
the_post();
|
||||
$title = sprintf( '%1$s<span class="vcard">%2$s</span>',
|
||||
get_avatar( get_the_author_meta( 'ID' ), 75 ),
|
||||
|
||||
$title = sprintf(
|
||||
'%1$s<span class="vcard">%2$s</span>',
|
||||
get_avatar( get_the_author_meta( 'ID' ), 50 ),
|
||||
get_the_author()
|
||||
);
|
||||
|
||||
/*
|
||||
* Since we called the_post() above, we need to
|
||||
* rewind the loop back to the beginning that way
|
||||
@ -100,11 +101,11 @@ function generate_do_archive_description() {
|
||||
$term_description = term_description();
|
||||
|
||||
if ( ! empty( $term_description ) ) {
|
||||
printf( '<div class="taxonomy-description">%s</div>', $term_description ); // WPCS: XSS ok, sanitization ok.
|
||||
printf( '<div class="taxonomy-description">%s</div>', $term_description ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
if ( get_the_author_meta( 'description' ) && is_author() ) {
|
||||
echo '<div class="author-info">' . get_the_author_meta( 'description' ) . '</div>'; // WPCS: XSS ok, sanitization ok.
|
||||
echo '<div class="author-info">' . get_the_author_meta( 'description' ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,53 +12,58 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
if ( ! function_exists( 'generate_comment' ) ) {
|
||||
/**
|
||||
* Template for comments and pingbacks.
|
||||
*
|
||||
* Used as a callback by wp_list_comments() for displaying the comments.
|
||||
*
|
||||
* @param object $comment The comment object.
|
||||
* @param array $args The existing args.
|
||||
* @param int $depth The thread depth.
|
||||
*/
|
||||
function generate_comment( $comment, $args, $depth ) {
|
||||
$args['avatar_size'] = apply_filters( 'generate_comment_avatar_size', 50 );
|
||||
|
||||
if ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) : ?>
|
||||
if ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) : ?>
|
||||
|
||||
<li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
|
||||
<div class="comment-body">
|
||||
<?php _e( 'Pingback:', 'generatepress' ); // WPCS: XSS OK. ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">', '</span>' ); ?>
|
||||
<?php esc_html_e( 'Pingback:', 'generatepress' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">', '</span>' ); ?>
|
||||
</div>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
|
||||
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body" <?php generate_do_microdata( 'comment-body' ); ?>>
|
||||
<article id="div-comment-<?php comment_ID(); ?>" <?php generate_do_element_classes( 'comment-body', 'comment-body' ); ?>>
|
||||
<footer class="comment-meta">
|
||||
<?php
|
||||
if ( 0 != $args['avatar_size'] ) {
|
||||
if ( 0 != $args['avatar_size'] ) { // phpcs:ignore
|
||||
echo get_avatar( $comment, $args['avatar_size'] );
|
||||
}
|
||||
?>
|
||||
<div class="comment-author-info">
|
||||
<div class="comment-author vcard" <?php generate_do_microdata( 'comment-author' ); ?>>
|
||||
<div <?php generate_do_element_classes( 'comment-author' ); ?>>
|
||||
<?php printf( '<cite itemprop="name" class="fn">%s</cite>', get_comment_author_link() ); ?>
|
||||
</div><!-- .comment-author -->
|
||||
</div>
|
||||
|
||||
<div class="entry-meta comment-metadata">
|
||||
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
|
||||
<time datetime="<?php comment_time( 'c' ); ?>" itemprop="datePublished">
|
||||
<?php printf( // WPCS: XSS OK.
|
||||
/* translators: 1: date, 2: time */
|
||||
_x( '%1$s at %2$s', '1: date, 2: time', 'generatepress' ),
|
||||
get_comment_date(),
|
||||
get_comment_time()
|
||||
); ?>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: date, 2: time */
|
||||
_x( '%1$s at %2$s', '1: date, 2: time', 'generatepress' ), // phpcs:ignore
|
||||
get_comment_date(), // phpcs:ignore
|
||||
get_comment_time() // phpcs:ignore
|
||||
);
|
||||
?>
|
||||
</time>
|
||||
</a>
|
||||
<?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' ); ?>
|
||||
</div><!-- .comment-metadata -->
|
||||
</div><!-- .comment-author-info -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( '0' == $comment->comment_approved ) : ?>
|
||||
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'generatepress' ); // WPCS: XSS OK. ?></p>
|
||||
<?php if ( '0' == $comment->comment_approved ) : // phpcs:ignore ?>
|
||||
<p class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'generatepress' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</footer><!-- .comment-meta -->
|
||||
</footer>
|
||||
|
||||
<div class="comment-content" itemprop="text">
|
||||
<?php
|
||||
@ -66,7 +71,6 @@ if ( ! function_exists( 'generate_comment' ) ) {
|
||||
* generate_before_comment_content hook.
|
||||
*
|
||||
* @since 2.4
|
||||
*
|
||||
*/
|
||||
do_action( 'generate_before_comment_text', $comment, $args, $depth );
|
||||
|
||||
@ -76,13 +80,12 @@ if ( ! function_exists( 'generate_comment' ) ) {
|
||||
* generate_after_comment_content hook.
|
||||
*
|
||||
* @since 2.4
|
||||
*
|
||||
*/
|
||||
do_action( 'generate_after_comment_text', $comment, $args, $depth );
|
||||
?>
|
||||
</div><!-- .comment-content -->
|
||||
</article><!-- .comment-body -->
|
||||
<?php
|
||||
</div>
|
||||
</article>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
||||
@ -92,15 +95,23 @@ add_action( 'generate_after_comment_text', 'generate_do_comment_reply_link', 10,
|
||||
* Add our comment reply link after the comment text.
|
||||
*
|
||||
* @since 2.4
|
||||
* @param object $comment The comment object.
|
||||
* @param array $args The existing args.
|
||||
* @param int $depth The thread depth.
|
||||
*/
|
||||
function generate_do_comment_reply_link( $comment, $args, $depth ) {
|
||||
comment_reply_link( array_merge( $args, array(
|
||||
'add_below' => 'div-comment',
|
||||
'depth' => $depth,
|
||||
'max_depth' => $args['max_depth'],
|
||||
'before' => '<span class="reply">',
|
||||
'after' => '</span>',
|
||||
) ) );
|
||||
comment_reply_link(
|
||||
array_merge(
|
||||
$args,
|
||||
array(
|
||||
'add_below' => 'div-comment',
|
||||
'depth' => $depth,
|
||||
'max_depth' => $args['max_depth'],
|
||||
'before' => '<span class="reply">',
|
||||
'after' => '</span>',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_filter( 'comment_form_defaults', 'generate_set_comment_form_defaults' );
|
||||
@ -109,21 +120,21 @@ add_filter( 'comment_form_defaults', 'generate_set_comment_form_defaults' );
|
||||
*
|
||||
* @since 2.3
|
||||
*
|
||||
* @param array $defaults
|
||||
* @param array $defaults The existing defaults.
|
||||
* @return array
|
||||
*/
|
||||
function generate_set_comment_form_defaults( $defaults ) {
|
||||
$defaults['comment_field'] = sprintf(
|
||||
'<p class="comment-form-comment"><label for="comment" class="screen-reader-text">%1$s</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
|
||||
'<p class="comment-form-comment"><label for="comment" class="screen-reader-text">%1$s</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>',
|
||||
esc_html__( 'Comment', 'generatepress' )
|
||||
);
|
||||
|
||||
$defaults['comment_notes_before'] = null;
|
||||
$defaults['comment_notes_after'] = null;
|
||||
$defaults['id_form'] = 'commentform';
|
||||
$defaults['id_submit'] = 'submit';
|
||||
$defaults['title_reply'] = apply_filters( 'generate_leave_comment', __( 'Leave a Comment', 'generatepress' ) );
|
||||
$defaults['label_submit'] = apply_filters( 'generate_post_comment', __( 'Post Comment', 'generatepress' ) );
|
||||
$defaults['comment_notes_before'] = null;
|
||||
$defaults['comment_notes_after'] = null;
|
||||
$defaults['id_form'] = 'commentform';
|
||||
$defaults['id_submit'] = 'submit';
|
||||
$defaults['title_reply'] = apply_filters( 'generate_leave_comment', __( 'Leave a Comment', 'generatepress' ) );
|
||||
$defaults['label_submit'] = apply_filters( 'generate_post_comment', __( 'Post Comment', 'generatepress' ) );
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
@ -133,22 +144,25 @@ add_filter( 'comment_form_default_fields', 'generate_filter_comment_fields' );
|
||||
* Customizes the existing comment fields.
|
||||
*
|
||||
* @since 2.1.2
|
||||
* @param array $fields
|
||||
* @param array $fields The existing fields.
|
||||
* @return array
|
||||
*/
|
||||
function generate_filter_comment_fields( $fields ) {
|
||||
$commenter = wp_get_current_commenter();
|
||||
$required = get_option( 'require_name_email' );
|
||||
|
||||
$fields['author'] = sprintf(
|
||||
'<label for="author" class="screen-reader-text">%1$s</label><input placeholder="%1$s *" id="author" name="author" type="text" value="%2$s" size="30" />',
|
||||
'<label for="author" class="screen-reader-text">%1$s</label><input placeholder="%1$s%3$s" id="author" name="author" type="text" value="%2$s" size="30" />',
|
||||
esc_html__( 'Name', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author'] )
|
||||
esc_attr( $commenter['comment_author'] ),
|
||||
$required ? ' *' : ''
|
||||
);
|
||||
|
||||
$fields['email'] = sprintf(
|
||||
'<label for="email" class="screen-reader-text">%1$s</label><input placeholder="%1$s *" id="email" name="email" type="email" value="%2$s" size="30" />',
|
||||
'<label for="email" class="screen-reader-text">%1$s</label><input placeholder="%1$s%3$s" id="email" name="email" type="email" value="%2$s" size="30" />',
|
||||
esc_html__( 'Email', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author_email'] )
|
||||
esc_attr( $commenter['comment_author_email'] ),
|
||||
$required ? ' *' : ''
|
||||
);
|
||||
|
||||
$fields['url'] = sprintf(
|
||||
@ -159,3 +173,32 @@ function generate_filter_comment_fields( $fields ) {
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
add_action( 'generate_after_do_template_part', 'generate_do_comments_template', 15 );
|
||||
/**
|
||||
* Add the comments template to pages and single posts.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template we're targeting.
|
||||
*/
|
||||
function generate_do_comments_template( $template ) {
|
||||
if ( 'single' === $template || 'page' === $template ) {
|
||||
// If comments are open or we have at least one comment, load up the comment template.
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentionally loose.
|
||||
if ( comments_open() || '0' != get_comments_number() ) :
|
||||
/**
|
||||
* generate_before_comments_container hook.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
do_action( 'generate_before_comments_container' );
|
||||
?>
|
||||
|
||||
<div class="comments-area">
|
||||
<?php comments_template(); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
@ -22,23 +22,33 @@ if ( ! function_exists( 'generate_post_image' ) ) {
|
||||
|
||||
// If we're not on any single post/page or the 404 template, we must be showing excerpts.
|
||||
if ( ! is_singular() && ! is_404() ) {
|
||||
echo apply_filters( 'generate_featured_image_output', sprintf( // WPCS: XSS ok.
|
||||
'<div class="post-image">
|
||||
%3$s
|
||||
<a href="%1$s">
|
||||
%2$s
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( get_permalink() ),
|
||||
get_the_post_thumbnail(
|
||||
get_the_ID(),
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
array(
|
||||
'itemprop' => 'image',
|
||||
)
|
||||
),
|
||||
apply_filters( 'generate_inside_featured_image_output', '' )
|
||||
) );
|
||||
|
||||
$attrs = array();
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$attrs = array(
|
||||
'itemprop' => 'image',
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( // phpcs:ignore
|
||||
'generate_featured_image_output',
|
||||
sprintf(
|
||||
'<div class="post-image">
|
||||
%3$s
|
||||
<a href="%1$s">
|
||||
%2$s
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( get_permalink() ),
|
||||
get_the_post_thumbnail(
|
||||
get_the_ID(),
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
$attrs
|
||||
),
|
||||
apply_filters( 'generate_inside_featured_image_output', '' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,7 +59,7 @@ if ( ! function_exists( 'generate_featured_page_header_area' ) ) {
|
||||
*
|
||||
* @since 1.0.7
|
||||
*
|
||||
* @param string The featured image container class
|
||||
* @param string $class The featured image container class.
|
||||
*/
|
||||
function generate_featured_page_header_area( $class ) {
|
||||
// Don't run the function unless we're on a page it applies to.
|
||||
@ -61,14 +71,22 @@ if ( ! function_exists( 'generate_featured_page_header_area' ) ) {
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attrs = array();
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$attrs = array(
|
||||
'itemprop' => 'image',
|
||||
);
|
||||
}
|
||||
?>
|
||||
<div class="<?php echo esc_attr( $class ); ?> grid-container grid-parent">
|
||||
<?php the_post_thumbnail(
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
array(
|
||||
'itemprop' => 'image',
|
||||
)
|
||||
); ?>
|
||||
<div class="featured-image <?php echo esc_attr( $class ); ?> grid-container grid-parent">
|
||||
<?php
|
||||
the_post_thumbnail(
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
$attrs
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -17,9 +17,18 @@ if ( ! function_exists( 'generate_construct_footer' ) ) {
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_construct_footer() {
|
||||
$inside_site_info_class = '';
|
||||
|
||||
if ( 'full-width' !== generate_get_option( 'footer_inner_width' ) ) {
|
||||
$inside_site_info_class = ' grid-container grid-parent';
|
||||
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
$inside_site_info_class = ' grid-container';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<footer class="site-info" <?php generate_do_microdata( 'footer' ); ?>>
|
||||
<div class="inside-site-info <?php if ( 'full-width' !== generate_get_option( 'footer_inner_width' ) ) : ?>grid-container grid-parent<?php endif; ?>">
|
||||
<footer <?php generate_do_element_classes( 'site-info', 'site-info' ); ?>>
|
||||
<div class="inside-site-info<?php echo $inside_site_info_class; // phpcs:ignore ?>">
|
||||
<?php
|
||||
/**
|
||||
* generate_before_copyright hook.
|
||||
@ -43,7 +52,7 @@ if ( ! function_exists( 'generate_construct_footer' ) ) {
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</footer><!-- .site-info -->
|
||||
</footer>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -75,15 +84,17 @@ if ( ! function_exists( 'generate_add_footer_info' ) ) {
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_footer_info() {
|
||||
$copyright = sprintf( '<span class="copyright">© %1$s %2$s</span> • %4$s <a href="%3$s" itemprop="url">%5$s</a>',
|
||||
date( 'Y' ),
|
||||
$copyright = sprintf(
|
||||
'<span class="copyright">© %1$s %2$s</span> • %4$s <a href="%3$s"%6$s>%5$s</a>',
|
||||
date( 'Y' ), // phpcs:ignore
|
||||
get_bloginfo( 'name' ),
|
||||
esc_url( 'https://generatepress.com' ),
|
||||
_x( 'Powered by', 'GeneratePress', 'generatepress' ),
|
||||
__( 'GeneratePress', 'generatepress' )
|
||||
_x( 'Built with', 'GeneratePress', 'generatepress' ),
|
||||
__( 'GeneratePress', 'generatepress' ),
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="url"' : ''
|
||||
);
|
||||
|
||||
echo apply_filters( 'generate_copyright', $copyright ); // WPCS: XSS ok.
|
||||
echo apply_filters( 'generate_copyright', $copyright ); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,10 +108,24 @@ if ( ! function_exists( 'generate_add_footer_info' ) ) {
|
||||
* @param int $widget The ID of our widget.
|
||||
*/
|
||||
function generate_do_footer_widget( $widget_width, $widget ) {
|
||||
$widget_width = apply_filters( "generate_footer_widget_{$widget}_width", $widget_width );
|
||||
$tablet_widget_width = apply_filters( "generate_footer_widget_{$widget}_tablet_width", '50' );
|
||||
$widget_classes = sprintf(
|
||||
'footer-widget-%s',
|
||||
absint( $widget )
|
||||
);
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$widget_width = apply_filters( "generate_footer_widget_{$widget}_width", $widget_width );
|
||||
$tablet_widget_width = apply_filters( "generate_footer_widget_{$widget}_tablet_width", '50' );
|
||||
|
||||
$widget_classes = sprintf(
|
||||
'footer-widget-%1$s grid-parent grid-%2$s tablet-grid-%3$s mobile-grid-100',
|
||||
absint( $widget ),
|
||||
absint( $widget_width ),
|
||||
absint( $tablet_widget_width )
|
||||
);
|
||||
}
|
||||
?>
|
||||
<div class="footer-widget-<?php echo absint( $widget ); ?> grid-parent grid-<?php echo absint( $widget_width ); ?> tablet-grid-<?php echo absint( $tablet_widget_width ); ?> mobile-grid-100">
|
||||
<div class="<?php echo $widget_classes; // phpcs:ignore ?>">
|
||||
<?php dynamic_sidebar( 'footer-' . absint( $widget ) ); ?>
|
||||
</div>
|
||||
<?php
|
||||
@ -120,35 +145,30 @@ if ( ! function_exists( 'generate_construct_footer_widgets' ) ) {
|
||||
if ( ! empty( $widgets ) && 0 !== $widgets ) :
|
||||
|
||||
// If no footer widgets exist, we don't need to continue.
|
||||
if (
|
||||
! is_active_sidebar( 'footer-1' ) &&
|
||||
! is_active_sidebar( 'footer-2' ) &&
|
||||
! is_active_sidebar( 'footer-3' ) &&
|
||||
! is_active_sidebar( 'footer-4' ) &&
|
||||
! is_active_sidebar( 'footer-5' ) )
|
||||
{
|
||||
if ( ! is_active_sidebar( 'footer-1' ) && ! is_active_sidebar( 'footer-2' ) && ! is_active_sidebar( 'footer-3' ) && ! is_active_sidebar( 'footer-4' ) && ! is_active_sidebar( 'footer-5' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the widget width.
|
||||
$widget_width = '';
|
||||
if ( $widgets == 1 ) {
|
||||
|
||||
if ( 1 === (int) $widgets ) {
|
||||
$widget_width = '100';
|
||||
}
|
||||
|
||||
if ( $widgets == 2 ) {
|
||||
if ( 2 === (int) $widgets ) {
|
||||
$widget_width = '50';
|
||||
}
|
||||
|
||||
if ( $widgets == 3 ) {
|
||||
if ( 3 === (int) $widgets ) {
|
||||
$widget_width = '33';
|
||||
}
|
||||
|
||||
if ( $widgets == 4 ) {
|
||||
if ( 4 === (int) $widgets ) {
|
||||
$widget_width = '25';
|
||||
}
|
||||
|
||||
if ( $widgets == 5 ) {
|
||||
if ( 5 === (int) $widgets ) {
|
||||
$widget_width = '20';
|
||||
}
|
||||
?>
|
||||
@ -179,7 +199,7 @@ if ( ! function_exists( 'generate_construct_footer_widgets' ) ) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
endif;
|
||||
|
||||
/**
|
||||
@ -208,17 +228,18 @@ if ( ! function_exists( 'generate_back_to_top' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo apply_filters( 'generate_back_to_top_output', sprintf( // WPCS: XSS ok.
|
||||
'<a title="%1$s" rel="nofollow" href="#" class="generate-back-to-top" style="opacity:0;visibility:hidden;" data-scroll-speed="%2$s" data-start-scroll="%3$s">
|
||||
<span class="screen-reader-text">%5$s</span>
|
||||
%6$s
|
||||
</a>',
|
||||
esc_attr__( 'Scroll back to top', 'generatepress' ),
|
||||
absint( apply_filters( 'generate_back_to_top_scroll_speed', 400 ) ),
|
||||
absint( apply_filters( 'generate_back_to_top_start_scroll', 300 ) ),
|
||||
esc_attr( apply_filters( 'generate_back_to_top_icon', 'fa-angle-up' ) ),
|
||||
esc_html__( 'Scroll back to top', 'generatepress' ),
|
||||
generate_get_svg_icon( 'arrow' )
|
||||
) );
|
||||
echo apply_filters( // phpcs:ignore
|
||||
'generate_back_to_top_output',
|
||||
sprintf(
|
||||
'<a title="%1$s" aria-label="%1$s" rel="nofollow" href="#" class="generate-back-to-top" style="opacity:0;visibility:hidden;" data-scroll-speed="%2$s" data-start-scroll="%3$s">
|
||||
%5$s
|
||||
</a>',
|
||||
esc_attr__( 'Scroll back to top', 'generatepress' ),
|
||||
absint( apply_filters( 'generate_back_to_top_scroll_speed', 400 ) ),
|
||||
absint( apply_filters( 'generate_back_to_top_start_scroll', 300 ) ),
|
||||
esc_attr( apply_filters( 'generate_back_to_top_icon', 'fa-angle-up' ) ),
|
||||
generate_get_svg_icon( 'arrow-up' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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' )
|
||||
);
|
||||
|
@ -16,8 +16,14 @@ if ( ! function_exists( 'generate_navigation_position' ) ) {
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_navigation_position() {
|
||||
/**
|
||||
* generate_before_navigation hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_before_navigation' );
|
||||
?>
|
||||
<nav id="site-navigation" <?php generate_do_element_classes( 'navigation' ); ?> <?php generate_do_microdata( 'navigation' ); ?>>
|
||||
<nav id="site-navigation" <?php generate_do_element_classes( 'navigation' ); ?>>
|
||||
<div <?php generate_do_element_classes( 'inside_navigation' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
@ -46,17 +52,24 @@ if ( ! function_exists( 'generate_navigation_position' ) ) {
|
||||
if ( $mobile_menu_label ) {
|
||||
printf(
|
||||
'<span class="mobile-menu">%s</span>',
|
||||
$mobile_menu_label
|
||||
$mobile_menu_label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
__( 'Menu', 'generatepress' )
|
||||
esc_html__( 'Menu', 'generatepress' )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
<?php
|
||||
/**
|
||||
* generate_after_mobile_menu_button hook
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_after_mobile_menu_button' );
|
||||
|
||||
wp_nav_menu(
|
||||
array(
|
||||
'theme_location' => 'primary',
|
||||
@ -76,20 +89,85 @@ if ( ! function_exists( 'generate_navigation_position' ) ) {
|
||||
*/
|
||||
do_action( 'generate_after_primary_menu' );
|
||||
?>
|
||||
</div><!-- .inside-navigation -->
|
||||
</nav><!-- #site-navigation -->
|
||||
</div>
|
||||
</nav>
|
||||
<?php
|
||||
/**
|
||||
* generate_after_navigation hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_after_navigation' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_before_navigation', 'generate_do_header_mobile_menu_toggle' );
|
||||
/**
|
||||
* Build the mobile menu toggle in the header.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_header_mobile_menu_toggle() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! generate_has_inline_mobile_toggle() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<nav id="mobile-menu-control-wrapper" <?php generate_do_element_classes( 'mobile-navigation-toggle', array( 'main-navigation', 'mobile-menu-control-wrapper' ) ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_inside_mobile_menu_control_wrapper hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_inside_mobile_menu_control_wrapper' );
|
||||
?>
|
||||
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false" data-nav="site-navigation">
|
||||
<?php
|
||||
/**
|
||||
* generate_inside_mobile_menu hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_inside_mobile_menu' );
|
||||
|
||||
generate_do_svg_icon( 'menu-bars', true );
|
||||
|
||||
$mobile_menu_label = __( 'Menu', 'generatepress' );
|
||||
|
||||
if ( 'nav-float-right' === generate_get_navigation_location() || 'nav-float-left' === generate_get_navigation_location() ) {
|
||||
$mobile_menu_label = '';
|
||||
}
|
||||
|
||||
$mobile_menu_label = apply_filters( 'generate_mobile_menu_label', $mobile_menu_label );
|
||||
|
||||
if ( $mobile_menu_label ) {
|
||||
printf(
|
||||
'<span class="mobile-menu">%s</span>',
|
||||
$mobile_menu_label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
esc_html__( 'Menu', 'generatepress' )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
</nav>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_menu_fallback' ) ) {
|
||||
/**
|
||||
* Menu fallback.
|
||||
*
|
||||
* @since 1.1.4
|
||||
*
|
||||
* @param array $args
|
||||
* @return string
|
||||
* @param array $args Existing menu args.
|
||||
*/
|
||||
function generate_menu_fallback( $args ) {
|
||||
$generate_settings = wp_parse_args(
|
||||
@ -108,34 +186,38 @@ if ( ! function_exists( 'generate_menu_fallback' ) ) {
|
||||
|
||||
wp_list_pages( $args );
|
||||
|
||||
if ( 'enable' === $generate_settings['nav_search'] ) {
|
||||
printf(
|
||||
'<li class="search-item"><a aria-label="%1$s" href="#">%2$s</a></li>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true )
|
||||
if ( ! generate_is_using_flexbox() && 'enable' === $generate_settings['nav_search'] ) {
|
||||
$search_item = apply_filters(
|
||||
'generate_navigation_search_menu_item_output',
|
||||
sprintf(
|
||||
'<li class="search-item menu-item-align-right"><a aria-label="%1$s" href="#">%2$s</a></li>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
)
|
||||
);
|
||||
|
||||
echo $search_item; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Safe output.
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div><!-- .main-nav -->
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the navigation based on settings
|
||||
*
|
||||
* It would be better to have all of these inside one action, but these
|
||||
* are kept this way to maintain backward compatibility for people
|
||||
* un-hooking and moving the navigation/changing the priority.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'generate_add_navigation_after_header' ) ) {
|
||||
add_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
|
||||
/**
|
||||
* Generate the navigation based on settings
|
||||
*
|
||||
* It would be better to have all of these inside one action, but these
|
||||
* are kept this way to maintain backward compatibility for people
|
||||
* un-hooking and moving the navigation/changing the priority.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_navigation_after_header() {
|
||||
if ( 'nav-below-header' == generate_get_navigation_location() ) {
|
||||
if ( 'nav-below-header' === generate_get_navigation_location() ) {
|
||||
generate_navigation_position();
|
||||
}
|
||||
}
|
||||
@ -143,8 +225,17 @@ if ( ! function_exists( 'generate_add_navigation_after_header' ) ) {
|
||||
|
||||
if ( ! function_exists( 'generate_add_navigation_before_header' ) ) {
|
||||
add_action( 'generate_before_header', 'generate_add_navigation_before_header', 5 );
|
||||
/**
|
||||
* Generate the navigation based on settings
|
||||
*
|
||||
* It would be better to have all of these inside one action, but these
|
||||
* are kept this way to maintain backward compatibility for people
|
||||
* un-hooking and moving the navigation/changing the priority.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_navigation_before_header() {
|
||||
if ( 'nav-above-header' == generate_get_navigation_location() ) {
|
||||
if ( 'nav-above-header' === generate_get_navigation_location() ) {
|
||||
generate_navigation_position();
|
||||
}
|
||||
}
|
||||
@ -152,8 +243,17 @@ if ( ! function_exists( 'generate_add_navigation_before_header' ) ) {
|
||||
|
||||
if ( ! function_exists( 'generate_add_navigation_float_right' ) ) {
|
||||
add_action( 'generate_after_header_content', 'generate_add_navigation_float_right', 5 );
|
||||
/**
|
||||
* Generate the navigation based on settings
|
||||
*
|
||||
* It would be better to have all of these inside one action, but these
|
||||
* are kept this way to maintain backward compatibility for people
|
||||
* un-hooking and moving the navigation/changing the priority.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_navigation_float_right() {
|
||||
if ( 'nav-float-right' == generate_get_navigation_location() || 'nav-float-left' == generate_get_navigation_location() ) {
|
||||
if ( 'nav-float-right' === generate_get_navigation_location() || 'nav-float-left' === generate_get_navigation_location() ) {
|
||||
generate_navigation_position();
|
||||
}
|
||||
}
|
||||
@ -161,8 +261,17 @@ if ( ! function_exists( 'generate_add_navigation_float_right' ) ) {
|
||||
|
||||
if ( ! function_exists( 'generate_add_navigation_before_right_sidebar' ) ) {
|
||||
add_action( 'generate_before_right_sidebar_content', 'generate_add_navigation_before_right_sidebar', 5 );
|
||||
/**
|
||||
* Generate the navigation based on settings
|
||||
*
|
||||
* It would be better to have all of these inside one action, but these
|
||||
* are kept this way to maintain backward compatibility for people
|
||||
* un-hooking and moving the navigation/changing the priority.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_navigation_before_right_sidebar() {
|
||||
if ( 'nav-right-sidebar' == generate_get_navigation_location() ) {
|
||||
if ( 'nav-right-sidebar' === generate_get_navigation_location() ) {
|
||||
echo '<div class="gen-sidebar-nav">';
|
||||
generate_navigation_position();
|
||||
echo '</div>';
|
||||
@ -172,8 +281,17 @@ if ( ! function_exists( 'generate_add_navigation_before_right_sidebar' ) ) {
|
||||
|
||||
if ( ! function_exists( 'generate_add_navigation_before_left_sidebar' ) ) {
|
||||
add_action( 'generate_before_left_sidebar_content', 'generate_add_navigation_before_left_sidebar', 5 );
|
||||
/**
|
||||
* Generate the navigation based on settings
|
||||
*
|
||||
* It would be better to have all of these inside one action, but these
|
||||
* are kept this way to maintain backward compatibility for people
|
||||
* un-hooking and moving the navigation/changing the priority.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_navigation_before_left_sidebar() {
|
||||
if ( 'nav-left-sidebar' == generate_get_navigation_location() ) {
|
||||
if ( 'nav-left-sidebar' === generate_get_navigation_location() ) {
|
||||
echo '<div class="gen-sidebar-nav">';
|
||||
generate_navigation_position();
|
||||
echo '</div>';
|
||||
@ -189,7 +307,7 @@ if ( ! class_exists( 'Generate_Page_Walker' ) && class_exists( 'Walker_Page' ) )
|
||||
* @since 1.3.21
|
||||
*/
|
||||
class Generate_Page_Walker extends Walker_Page {
|
||||
function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
|
||||
function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { // phpcs:ignore
|
||||
$css_class = array( 'page_item', 'page-item-' . $page->ID );
|
||||
$button = '';
|
||||
|
||||
@ -204,15 +322,17 @@ if ( ! class_exists( 'Generate_Page_Walker' ) && class_exists( 'Walker_Page' ) )
|
||||
if ( $_current_page && in_array( $page->ID, $_current_page->ancestors ) ) {
|
||||
$css_class[] = 'current-menu-ancestor';
|
||||
}
|
||||
if ( $page->ID == $current_page ) {
|
||||
|
||||
if ( $page->ID == $current_page ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-item';
|
||||
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
|
||||
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
} elseif ( $page->ID == get_option( 'page_for_posts' ) ) {
|
||||
} elseif ( $page->ID == get_option( 'page_for_posts' ) ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name.
|
||||
$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
|
||||
|
||||
$args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before'];
|
||||
@ -223,7 +343,7 @@ if ( ! class_exists( 'Generate_Page_Walker' ) && class_exists( 'Walker_Page' ) )
|
||||
$css_classes,
|
||||
get_permalink( $page->ID ),
|
||||
$args['link_before'],
|
||||
apply_filters( 'the_title', $page->post_title, $page->ID ),
|
||||
apply_filters( 'the_title', $page->post_title, $page->ID ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name.
|
||||
$args['link_after'],
|
||||
$button
|
||||
);
|
||||
@ -238,10 +358,10 @@ if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
|
||||
*
|
||||
* @since 1.3.42
|
||||
*
|
||||
* @param string $title The menu item title.
|
||||
* @param WP_Post $item All of our menu item data.
|
||||
* @param string $title The menu item title.
|
||||
* @param WP_Post $item All of our menu item data.
|
||||
* @param stdClass $args All of our menu item args.
|
||||
* @param int $dept Depth of menu item.
|
||||
* @param int $depth Depth of menu item.
|
||||
* @return string The menu item.
|
||||
*/
|
||||
function generate_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
|
||||
@ -256,7 +376,47 @@ if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
|
||||
if ( isset( $args->container_class ) && 'main-nav' === $args->container_class ) {
|
||||
foreach ( $item->classes as $value ) {
|
||||
if ( 'menu-item-has-children' === $value ) {
|
||||
$icon = generate_get_svg_icon( 'arrow' );
|
||||
$arrow_direction = 'down';
|
||||
|
||||
if ( 'primary' === $args->theme_location ) {
|
||||
if ( 0 !== $depth ) {
|
||||
$arrow_direction = 'right';
|
||||
|
||||
if ( 'left' === generate_get_option( 'nav_dropdown_direction' ) ) {
|
||||
$arrow_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'nav-left-sidebar' === generate_get_navigation_location() ) {
|
||||
$arrow_direction = 'right';
|
||||
|
||||
if ( 'both-right' === generate_get_layout() ) {
|
||||
$arrow_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'nav-right-sidebar' === generate_get_navigation_location() ) {
|
||||
$arrow_direction = 'left';
|
||||
|
||||
if ( 'both-left' === generate_get_layout() ) {
|
||||
$arrow_direction = 'right';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'hover' !== generate_get_option( 'nav_dropdown_type' ) ) {
|
||||
$arrow_direction = 'down';
|
||||
}
|
||||
}
|
||||
|
||||
$arrow_direction = apply_filters( 'generate_menu_item_dropdown_arrow_direction', $arrow_direction, $args, $depth );
|
||||
|
||||
if ( 'down' === $arrow_direction ) {
|
||||
$arrow_direction = '';
|
||||
} else {
|
||||
$arrow_direction = '-' . $arrow_direction;
|
||||
}
|
||||
|
||||
$icon = generate_get_svg_icon( 'arrow' . $arrow_direction );
|
||||
$title = $title . '<span role="' . $role . '" class="dropdown-menu-toggle"' . $tabindex . '>' . $icon . '</span>';
|
||||
}
|
||||
}
|
||||
@ -283,25 +443,90 @@ if ( ! function_exists( 'generate_navigation_search' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo apply_filters( 'generate_navigation_search_output', sprintf( // WPCS: XSS ok, sanitization ok.
|
||||
'<form method="get" class="search-form navigation-search" action="%1$s">
|
||||
<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
|
||||
</form>',
|
||||
esc_url( home_url( '/' ) ),
|
||||
esc_attr( get_search_query() ),
|
||||
esc_attr_x( 'Search', 'label', 'generatepress' )
|
||||
));
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_navigation_search_output',
|
||||
sprintf(
|
||||
'<form method="get" class="search-form navigation-search" action="%1$s">
|
||||
<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
|
||||
</form>',
|
||||
esc_url( home_url( '/' ) ),
|
||||
esc_attr( get_search_query() ),
|
||||
esc_attr_x( 'Search', 'label', 'generatepress' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_after_primary_menu', 'generate_do_menu_bar_item_container' );
|
||||
add_action( 'generate_inside_mobile_menu_control_wrapper', 'generate_do_menu_bar_item_container' );
|
||||
/**
|
||||
* Add a container for menu bar items.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_menu_bar_item_container() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( generate_has_menu_bar_items() ) {
|
||||
echo '<div class="menu-bar-items">';
|
||||
do_action( 'generate_menu_bar_items' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp', 'generate_add_menu_bar_items' );
|
||||
/**
|
||||
* Add menu bar items to the primary navigation.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_add_menu_bar_items() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the navigation search button.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_navigation_search_button() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'enable' !== generate_get_option( 'nav_search' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$search_item = apply_filters(
|
||||
'generate_navigation_search_menu_item_output',
|
||||
sprintf(
|
||||
'<span class="menu-bar-item search-item"><a aria-label="%1$s" href="#">%2$s</a></span>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
)
|
||||
);
|
||||
|
||||
echo $search_item; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- No escaping needed.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_menu_search_icon' ) ) {
|
||||
add_filter( 'wp_nav_menu_items', 'generate_menu_search_icon', 10, 2 );
|
||||
/**
|
||||
* Add search icon to primary menu if set
|
||||
* Add search icon to primary menu if set.
|
||||
* Only used if using old float system.
|
||||
*
|
||||
* @since 1.2.9.7
|
||||
*
|
||||
* @param string $nav The HTML list content for the menu items.
|
||||
* @param string $nav The HTML list content for the menu items.
|
||||
* @param stdClass $args An object containing wp_nav_menu() arguments.
|
||||
* @return string The search icon menu item.
|
||||
*/
|
||||
@ -311,6 +536,10 @@ if ( ! function_exists( 'generate_menu_search_icon' ) ) {
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
return $nav;
|
||||
}
|
||||
|
||||
// If the search icon isn't enabled, return the regular nav.
|
||||
if ( 'enable' !== $generate_settings['nav_search'] ) {
|
||||
return $nav;
|
||||
@ -318,12 +547,16 @@ if ( ! function_exists( 'generate_menu_search_icon' ) ) {
|
||||
|
||||
// If our primary menu is set, add the search icon.
|
||||
if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) {
|
||||
return sprintf(
|
||||
'%1$s<li class="search-item"><a aria-label="%2$s" href="#">%3$s</a></li>',
|
||||
$nav,
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true )
|
||||
$search_item = apply_filters(
|
||||
'generate_navigation_search_menu_item_output',
|
||||
sprintf(
|
||||
'<li class="search-item menu-item-align-right"><a aria-label="%1$s" href="#">%2$s</a></li>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
)
|
||||
);
|
||||
|
||||
return $nav . $search_item;
|
||||
}
|
||||
|
||||
// Our primary menu isn't set, return the regular nav.
|
||||
@ -335,7 +568,8 @@ if ( ! function_exists( 'generate_menu_search_icon' ) ) {
|
||||
if ( ! function_exists( 'generate_mobile_menu_search_icon' ) ) {
|
||||
add_action( 'generate_inside_navigation', 'generate_mobile_menu_search_icon' );
|
||||
/**
|
||||
* Add search icon to mobile menu bar
|
||||
* Add search icon to mobile menu bar.
|
||||
* Only used if using old float system.
|
||||
*
|
||||
* @since 1.3.12
|
||||
*/
|
||||
@ -350,15 +584,19 @@ if ( ! function_exists( 'generate_mobile_menu_search_icon' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="mobile-bar-items">
|
||||
<?php do_action( 'generate_inside_mobile_menu_bar' ); ?>
|
||||
<span class="search-item">
|
||||
<a aria-label="<?php _e( 'Open Search Bar', 'generatepress' ); ?>" href="#">
|
||||
<a aria-label="<?php esc_attr_e( 'Open Search Bar', 'generatepress' ); ?>" href="#">
|
||||
<?php generate_do_svg_icon( 'search', true ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</div><!-- .mobile-bar-items -->
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ if ( ! function_exists( 'generate_content_nav' ) ) {
|
||||
* @param string $nav_id The id of our navigation.
|
||||
*/
|
||||
function generate_content_nav( $nav_id ) {
|
||||
if ( ! apply_filters( 'generate_show_post_navigation', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_query, $post;
|
||||
|
||||
// Don't print empty markup on single pages if there's nowhere to navigate.
|
||||
@ -44,16 +40,20 @@ if ( ! function_exists( 'generate_content_nav' ) ) {
|
||||
<nav id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo esc_attr( $nav_class ); ?>">
|
||||
<span class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'generatepress' ); ?></span>
|
||||
|
||||
<?php if ( is_single() ) : // navigation links for single posts.
|
||||
<?php
|
||||
if ( is_single() ) : // navigation links for single posts.
|
||||
|
||||
$post_navigation_args = apply_filters( 'generate_post_navigation_args', array(
|
||||
'previous_format' => '<div class="nav-previous">' . generate_get_svg_icon( 'arrow' ) . '<span class="prev" title="' . esc_attr__( 'Previous', 'generatepress' ) . '">%link</span></div>',
|
||||
'next_format' => '<div class="nav-next">' . generate_get_svg_icon( 'arrow' ) . '<span class="next" title="' . esc_attr__( 'Next', 'generatepress' ) . '">%link</span></div>',
|
||||
'link' => '%title',
|
||||
'in_same_term' => apply_filters( 'generate_category_post_navigation', false ),
|
||||
'excluded_terms' => '',
|
||||
'taxonomy' => 'category',
|
||||
) );
|
||||
$post_navigation_args = apply_filters(
|
||||
'generate_post_navigation_args',
|
||||
array(
|
||||
'previous_format' => '<div class="nav-previous">' . generate_get_svg_icon( 'arrow-left' ) . '<span class="prev" title="' . esc_attr__( 'Previous', 'generatepress' ) . '">%link</span></div>',
|
||||
'next_format' => '<div class="nav-next">' . generate_get_svg_icon( 'arrow-right' ) . '<span class="next" title="' . esc_attr__( 'Next', 'generatepress' ) . '">%link</span></div>',
|
||||
'link' => '%title',
|
||||
'in_same_term' => apply_filters( 'generate_category_post_navigation', false ),
|
||||
'excluded_terms' => '',
|
||||
'taxonomy' => 'category',
|
||||
)
|
||||
);
|
||||
|
||||
previous_post_link(
|
||||
$post_navigation_args['previous_format'],
|
||||
@ -73,26 +73,50 @@ if ( ! function_exists( 'generate_content_nav' ) ) {
|
||||
|
||||
elseif ( is_home() || is_archive() || is_search() ) : // navigation links for home, archive, and search pages.
|
||||
|
||||
if ( get_next_posts_link() ) : ?>
|
||||
if ( get_next_posts_link() ) :
|
||||
?>
|
||||
<div class="nav-previous">
|
||||
<?php generate_do_svg_icon( 'arrow' ); ?>
|
||||
<span class="prev" title="<?php esc_attr_e( 'Previous', 'generatepress' );?>"><?php next_posts_link( __( 'Older posts', 'generatepress' ) ); ?></span>
|
||||
<span class="prev" title="<?php esc_attr_e( 'Previous', 'generatepress' ); ?>"><?php next_posts_link( __( 'Older posts', 'generatepress' ) ); ?></span>
|
||||
</div>
|
||||
<?php endif;
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ( get_previous_posts_link() ) : ?>
|
||||
if ( get_previous_posts_link() ) :
|
||||
?>
|
||||
<div class="nav-next">
|
||||
<?php generate_do_svg_icon( 'arrow' ); ?>
|
||||
<span class="next" title="<?php esc_attr_e( 'Next', 'generatepress' );?>"><?php previous_posts_link( __( 'Newer posts', 'generatepress' ) ); ?></span>
|
||||
<span class="next" title="<?php esc_attr_e( 'Next', 'generatepress' ); ?>"><?php previous_posts_link( __( 'Newer posts', 'generatepress' ) ); ?></span>
|
||||
</div>
|
||||
<?php endif;
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ( function_exists( 'the_posts_pagination' ) ) {
|
||||
the_posts_pagination( array(
|
||||
'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ),
|
||||
'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ),
|
||||
'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ),
|
||||
) );
|
||||
the_posts_pagination(
|
||||
array(
|
||||
'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ),
|
||||
'prev_text' => apply_filters(
|
||||
'generate_previous_link_text',
|
||||
sprintf(
|
||||
/* translators: left arrow */
|
||||
__( '%s Previous', 'generatepress' ),
|
||||
'<span aria-hidden="true">←</span>'
|
||||
)
|
||||
),
|
||||
'next_text' => apply_filters(
|
||||
'generate_next_link_text',
|
||||
sprintf(
|
||||
/* translators: right arrow */
|
||||
__( 'Next %s', 'generatepress' ),
|
||||
'<span aria-hidden="true">→</span>'
|
||||
)
|
||||
),
|
||||
'before_page_number' => sprintf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
_x( 'Page', 'prepends the pagination page number for screen readers', 'generatepress' )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,8 +126,9 @@ if ( ! function_exists( 'generate_content_nav' ) ) {
|
||||
*/
|
||||
do_action( 'generate_paging_navigation' );
|
||||
|
||||
endif; ?>
|
||||
</nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
|
||||
endif;
|
||||
?>
|
||||
</nav>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -134,66 +159,89 @@ if ( ! function_exists( 'generate_modify_posts_pagination_template' ) ) {
|
||||
*
|
||||
* @since 2.3
|
||||
*
|
||||
* @param string $item The post meta item we're requesting
|
||||
* @return The requested HTML.
|
||||
* @param string $item The post meta item we're requesting.
|
||||
*/
|
||||
function generate_do_post_meta_item( $item ) {
|
||||
if ( 'date' === $item ) {
|
||||
$date = apply_filters( 'generate_post_date', true );
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s"%5$s>%2$s</time>';
|
||||
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
|
||||
$updated_time = get_the_modified_time( 'U' );
|
||||
$published_time = get_the_time( 'U' ) + 1800;
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
|
||||
if ( $updated_time > $published_time ) {
|
||||
if ( apply_filters( 'generate_post_date_show_updated_only', false ) ) {
|
||||
$time_string = '<time class="entry-date updated-date" datetime="%3$s"%6$s>%4$s</time>';
|
||||
} else {
|
||||
$time_string = '<time class="updated" datetime="%3$s"%6$s>%4$s</time>' . $time_string;
|
||||
}
|
||||
}
|
||||
|
||||
$time_string = sprintf( $time_string,
|
||||
$time_string = sprintf(
|
||||
$time_string,
|
||||
esc_attr( get_the_date( 'c' ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( 'c' ) ),
|
||||
esc_html( get_the_modified_date() )
|
||||
esc_html( get_the_modified_date() ),
|
||||
'microdata' === $schema_type ? ' itemprop="datePublished"' : '',
|
||||
'microdata' === $schema_type ? ' itemprop="dateModified"' : ''
|
||||
);
|
||||
|
||||
// If our date is enabled, show it.
|
||||
if ( $date ) {
|
||||
echo apply_filters( 'generate_post_date_output',
|
||||
sprintf( // WPCS: XSS ok, sanitization ok.
|
||||
'<span class="posted-on">%1$s<a href="%2$s" title="%3$s" rel="bookmark">%4$s</a></span> ',
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'date' ),
|
||||
esc_url( get_permalink() ),
|
||||
esc_attr( get_the_time() ),
|
||||
$time_string
|
||||
),
|
||||
$time_string );
|
||||
$posted_on = '<span class="posted-on">%1$s%4$s</span> ';
|
||||
|
||||
if ( apply_filters( 'generate_post_date_link', false ) ) {
|
||||
$posted_on = '<span class="posted-on">%1$s<a href="%2$s" title="%3$s" rel="bookmark">%4$s</a></span> ';
|
||||
}
|
||||
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_post_date_output',
|
||||
sprintf(
|
||||
$posted_on,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'date' ),
|
||||
esc_url( get_permalink() ),
|
||||
esc_attr( get_the_time() ),
|
||||
$time_string
|
||||
),
|
||||
$time_string,
|
||||
$posted_on
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'author' === $item ) {
|
||||
$author = apply_filters( 'generate_post_author', true );
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
if ( $author ) {
|
||||
echo apply_filters( 'generate_post_author_output',
|
||||
sprintf( '<span class="byline">%1$s<span class="author vcard" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span></span> ',
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ),
|
||||
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
||||
/* translators: 1: Author name */
|
||||
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
|
||||
esc_html( get_the_author() ),
|
||||
generate_get_microdata( 'post-author' )
|
||||
)
|
||||
);
|
||||
$byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author"%6$s><span class="author-name"%7$s>%4$s</span></a></span></span> ';
|
||||
|
||||
if ( ! apply_filters( 'generate_post_author_link', true ) ) {
|
||||
$byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><span class="author-name"%7$s>%4$s</span></span></span> ';
|
||||
}
|
||||
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_post_author_output',
|
||||
sprintf(
|
||||
$byline,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ),
|
||||
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
||||
/* translators: 1: Author name */
|
||||
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
|
||||
esc_html( get_the_author() ),
|
||||
generate_get_microdata( 'post-author' ),
|
||||
'microdata' === $schema_type ? ' itemprop="url"' : '',
|
||||
'microdata' === $schema_type ? ' itemprop="name"' : '',
|
||||
generate_is_using_hatom() ? ' vcard' : ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'categories' === $item ) {
|
||||
$categories = apply_filters( 'generate_show_categories', true );
|
||||
|
||||
$term_separator = apply_filters( 'generate_term_separator', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ), 'categories' );
|
||||
$categories_list = get_the_category_list( $term_separator );
|
||||
|
||||
if ( $categories_list && $categories ) {
|
||||
echo apply_filters( 'generate_category_list_output',
|
||||
sprintf( '<span class="cat-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ', // WPCS: XSS ok, sanitization ok.
|
||||
if ( $categories_list ) {
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_category_list_output',
|
||||
sprintf(
|
||||
'<span class="cat-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ',
|
||||
esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
|
||||
$categories_list,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' )
|
||||
@ -203,14 +251,14 @@ function generate_do_post_meta_item( $item ) {
|
||||
}
|
||||
|
||||
if ( 'tags' === $item ) {
|
||||
$tags = apply_filters( 'generate_show_tags', true );
|
||||
|
||||
$term_separator = apply_filters( 'generate_term_separator', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ), 'tags' );
|
||||
$tags_list = get_the_tag_list( '', $term_separator );
|
||||
|
||||
if ( $tags_list && $tags ) {
|
||||
echo apply_filters( 'generate_tag_list_output',
|
||||
sprintf( '<span class="tags-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ', // WPCS: XSS ok, sanitization ok.
|
||||
if ( $tags_list ) {
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_tag_list_output',
|
||||
sprintf(
|
||||
'<span class="tags-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ',
|
||||
esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
|
||||
$tags_list,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'tags' )
|
||||
@ -220,16 +268,22 @@ function generate_do_post_meta_item( $item ) {
|
||||
}
|
||||
|
||||
if ( 'comments-link' === $item ) {
|
||||
$comments = apply_filters( 'generate_show_comments', true );
|
||||
|
||||
if ( $comments && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||
echo '<span class="comments-link">';
|
||||
echo apply_filters( 'generate_inside_post_meta_item_output', '', 'comments-link' );
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_inside_post_meta_item_output',
|
||||
'',
|
||||
'comments-link'
|
||||
);
|
||||
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
|
||||
echo '</span> ';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'post-navigation' === $item && is_single() ) {
|
||||
generate_content_nav( 'nav-below' );
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_post_meta_items hook.
|
||||
*
|
||||
@ -243,6 +297,8 @@ add_filter( 'generate_inside_post_meta_item_output', 'generate_do_post_meta_pref
|
||||
* Add svg icons or text to our post meta output.
|
||||
*
|
||||
* @since 2.4
|
||||
* @param string $output The existing output.
|
||||
* @param string $item The item to target.
|
||||
*/
|
||||
function generate_do_post_meta_prefix( $output, $item ) {
|
||||
if ( 'author' === $item ) {
|
||||
@ -264,6 +320,92 @@ function generate_do_post_meta_prefix( $output, $item ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove post meta items from display if their individual filters are set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $items The post meta items.
|
||||
*/
|
||||
function generate_disable_post_meta_items( $items ) {
|
||||
$disable_filter_names = apply_filters(
|
||||
'generate_disable_post_meta_filter_names',
|
||||
array(
|
||||
'date' => 'generate_post_date',
|
||||
'author' => 'generate_post_author',
|
||||
'categories' => 'generate_show_categories',
|
||||
'tags' => 'generate_show_tags',
|
||||
'comments-link' => 'generate_show_comments',
|
||||
'post-navigation' => 'generate_show_post_navigation',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$default_display = true;
|
||||
|
||||
if ( 'comments-link' === $item && is_singular() ) {
|
||||
$default_display = false;
|
||||
}
|
||||
|
||||
// phpcs:ignore -- Hook name is coming from a variable.
|
||||
if ( isset( $disable_filter_names[ $item ] ) && ! apply_filters( $disable_filter_names[ $item ], $default_display ) ) {
|
||||
$items = array_diff( $items, array( $item ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post meta items in the header entry meta.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_get_header_entry_meta_items() {
|
||||
$items = apply_filters(
|
||||
'generate_header_entry_meta_items',
|
||||
array(
|
||||
'date',
|
||||
'author',
|
||||
)
|
||||
);
|
||||
|
||||
// Disable post meta items based on their individual filters.
|
||||
$items = generate_disable_post_meta_items( $items );
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post meta items in the footer entry meta.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_get_footer_entry_meta_items() {
|
||||
$items = apply_filters(
|
||||
'generate_footer_entry_meta_items',
|
||||
array(
|
||||
'categories',
|
||||
'tags',
|
||||
'comments-link',
|
||||
'post-navigation',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* This wasn't a "meta item" prior to 3.0.0 and some users may be using the filter above
|
||||
* without specifying that they want to include post-navigation. The below forces it to display
|
||||
* for users using the old float system to prevent it from disappearing on update.
|
||||
*/
|
||||
if ( ! generate_is_using_flexbox() && ! in_array( 'post-navigation', (array) $items ) ) {
|
||||
$items[] = 'post-navigation';
|
||||
}
|
||||
|
||||
// Disable post meta items based on their individual filters.
|
||||
$items = generate_disable_post_meta_items( $items );
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_posted_on' ) ) {
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time and author.
|
||||
@ -271,10 +413,7 @@ if ( ! function_exists( 'generate_posted_on' ) ) {
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_posted_on() {
|
||||
$items = apply_filters( 'generate_header_entry_meta_items', array(
|
||||
'date',
|
||||
'author',
|
||||
) );
|
||||
$items = generate_get_header_entry_meta_items();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
generate_do_post_meta_item( $item );
|
||||
@ -289,11 +428,7 @@ if ( ! function_exists( 'generate_entry_meta' ) ) {
|
||||
* @since 1.2.5
|
||||
*/
|
||||
function generate_entry_meta() {
|
||||
$items = apply_filters( 'generate_footer_entry_meta_items', array(
|
||||
'categories',
|
||||
'tags',
|
||||
'comments-link',
|
||||
) );
|
||||
$items = generate_get_footer_entry_meta_items();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
generate_do_post_meta_item( $item );
|
||||
@ -312,12 +447,20 @@ if ( ! function_exists( 'generate_excerpt_more' ) ) {
|
||||
* @return string The HTML for the more link.
|
||||
*/
|
||||
function generate_excerpt_more( $more ) {
|
||||
return apply_filters( 'generate_excerpt_more_output', sprintf( ' ... <a title="%1$s" class="read-more" href="%2$s">%3$s %4$s</a>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) ),
|
||||
__( 'Read more', 'generatepress' ),
|
||||
'<span class="screen-reader-text">' . get_the_title() . '</span>'
|
||||
) );
|
||||
return apply_filters(
|
||||
'generate_excerpt_more_output',
|
||||
sprintf(
|
||||
' ... <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' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,57 +475,105 @@ if ( ! function_exists( 'generate_content_more' ) ) {
|
||||
* @return string The HTML for the more link
|
||||
*/
|
||||
function generate_content_more( $more ) {
|
||||
return apply_filters( 'generate_content_more_link_output', sprintf( '<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s">%3$s%4$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' ),
|
||||
'<span class="screen-reader-text">' . get_the_title() . '</span>'
|
||||
) );
|
||||
return apply_filters(
|
||||
'generate_content_more_link_output',
|
||||
sprintf(
|
||||
'<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' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp', 'generate_add_post_meta', 5 );
|
||||
/**
|
||||
* Add our post meta items to the page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_add_post_meta() {
|
||||
$header_items = generate_get_header_entry_meta_items();
|
||||
|
||||
$header_post_types = apply_filters(
|
||||
'generate_entry_meta_post_types',
|
||||
array(
|
||||
'post',
|
||||
)
|
||||
);
|
||||
|
||||
if ( in_array( get_post_type(), $header_post_types ) && ! empty( $header_items ) ) {
|
||||
add_action( 'generate_after_entry_title', 'generate_post_meta' );
|
||||
}
|
||||
|
||||
$footer_items = generate_get_footer_entry_meta_items();
|
||||
|
||||
$footer_post_types = apply_filters(
|
||||
'generate_footer_meta_post_types',
|
||||
array(
|
||||
'post',
|
||||
)
|
||||
);
|
||||
|
||||
if ( in_array( get_post_type(), $footer_post_types ) && ! empty( $footer_items ) ) {
|
||||
add_action( 'generate_after_entry_content', 'generate_footer_meta' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_post_meta' ) ) {
|
||||
add_action( 'generate_after_entry_title', 'generate_post_meta' );
|
||||
/**
|
||||
* Build the post meta.
|
||||
*
|
||||
* @since 1.3.29
|
||||
*/
|
||||
function generate_post_meta() {
|
||||
$post_types = apply_filters( 'generate_entry_meta_post_types', array(
|
||||
'post',
|
||||
) );
|
||||
|
||||
if ( in_array( get_post_type(), $post_types ) ) : ?>
|
||||
<div class="entry-meta">
|
||||
<?php generate_posted_on(); ?>
|
||||
</div><!-- .entry-meta -->
|
||||
<?php endif;
|
||||
?>
|
||||
<div class="entry-meta">
|
||||
<?php generate_posted_on(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_footer_meta' ) ) {
|
||||
add_action( 'generate_after_entry_content', 'generate_footer_meta' );
|
||||
/**
|
||||
* Build the footer post meta.
|
||||
*
|
||||
* @since 1.3.30
|
||||
*/
|
||||
function generate_footer_meta() {
|
||||
$post_types = apply_filters( 'generate_footer_meta_post_types', array(
|
||||
'post',
|
||||
) );
|
||||
|
||||
if ( in_array( get_post_type(), $post_types ) ) : ?>
|
||||
<footer class="entry-meta">
|
||||
<?php
|
||||
generate_entry_meta();
|
||||
|
||||
if ( is_single() ) {
|
||||
generate_content_nav( 'nav-below' );
|
||||
}
|
||||
?>
|
||||
</footer><!-- .entry-meta -->
|
||||
<?php endif;
|
||||
?>
|
||||
<footer class="entry-meta">
|
||||
<?php generate_entry_meta(); ?>
|
||||
</footer>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_after_loop', 'generate_do_post_navigation' );
|
||||
/**
|
||||
* Add our post navigation after post loops.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template of the current action.
|
||||
*/
|
||||
function generate_do_post_navigation( $template ) {
|
||||
$templates = apply_filters(
|
||||
'generate_post_navigation_templates',
|
||||
array(
|
||||
'index',
|
||||
'archive',
|
||||
'search',
|
||||
)
|
||||
);
|
||||
|
||||
if ( in_array( $template, $templates ) && apply_filters( 'generate_show_post_navigation', true ) ) {
|
||||
generate_content_nav( 'nav-below' );
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ if ( ! function_exists( 'generate_construct_sidebars' ) ) {
|
||||
* The below hook was removed in 2.0, but we'll keep the call here so child themes
|
||||
* don't lose their sidebar when they update the theme.
|
||||
*/
|
||||
add_action( 'generate_sidebars', 'generate_construct_sidebars' );
|
||||
add_action( 'generate_sidebars', 'generate_construct_sidebars' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +50,7 @@ if ( ! function_exists( 'generate_construct_sidebars' ) ) {
|
||||
* @param string $area Left or right sidebar.
|
||||
*/
|
||||
function generate_do_default_sidebar_widgets( $area ) {
|
||||
if ( 'nav-' . $area === generate_get_navigation_location() ) {
|
||||
if ( 'nav-' . $area === generate_get_navigation_location() ) { // phpcs:ignore -- False positive.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ function generate_do_default_sidebar_widgets( $area ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'generate_show_default_sidebar_widgets', true ) ) {
|
||||
if ( ! apply_filters( 'generate_show_default_sidebar_widgets', true ) || generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user