first
This commit is contained in:
142
wp-content/themes/generatepress/inc/structure/archives.php
Normal file
142
wp-content/themes/generatepress/inc/structure/archives.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Archive elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_archive_title' ) ) {
|
||||
add_action( 'generate_archive_title', 'generate_archive_title' );
|
||||
/**
|
||||
* Build the archive title
|
||||
*
|
||||
* @since 1.3.24
|
||||
*/
|
||||
function generate_archive_title() {
|
||||
if ( ! function_exists( 'the_archive_title' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<header <?php generate_do_attr( 'page-header' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_before_archive_title hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_before_archive_title' );
|
||||
?>
|
||||
|
||||
<h1 class="page-title">
|
||||
<?php the_archive_title(); ?>
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* generate_after_archive_title hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @hooked generate_do_archive_description - 10
|
||||
*/
|
||||
do_action( 'generate_after_archive_title' );
|
||||
?>
|
||||
</header>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_filter_the_archive_title' ) ) {
|
||||
add_filter( 'get_the_archive_title', 'generate_filter_the_archive_title' );
|
||||
/**
|
||||
* Alter the_archive_title() function to match our original archive title function
|
||||
*
|
||||
* @since 1.3.45
|
||||
*
|
||||
* @param string $title The archive title.
|
||||
* @return string The altered archive title
|
||||
*/
|
||||
function generate_filter_the_archive_title( $title ) {
|
||||
if ( is_category() ) {
|
||||
$title = single_cat_title( '', false );
|
||||
} elseif ( is_tag() ) {
|
||||
$title = single_tag_title( '', false );
|
||||
} elseif ( is_author() ) {
|
||||
/*
|
||||
* Queue the first post, that way we know
|
||||
* 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' ), 50 ),
|
||||
get_the_author()
|
||||
);
|
||||
|
||||
/*
|
||||
* Since we called the_post() above, we need to
|
||||
* rewind the loop back to the beginning that way
|
||||
* we can run the loop properly, in full.
|
||||
*/
|
||||
rewind_posts();
|
||||
}
|
||||
|
||||
return $title;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_after_archive_title', 'generate_do_archive_description' );
|
||||
/**
|
||||
* Output the archive description.
|
||||
*
|
||||
* @since 2.3
|
||||
*/
|
||||
function generate_do_archive_description() {
|
||||
$term_description = get_the_archive_description();
|
||||
|
||||
if ( ! empty( $term_description ) ) {
|
||||
if ( is_author() ) {
|
||||
printf( '<div class="author-info">%s</div>', $term_description ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
printf( '<div class="taxonomy-description">%s</div>', $term_description ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_after_archive_description hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_archive_description' );
|
||||
}
|
||||
|
||||
add_action( 'generate_before_loop', 'generate_do_search_results_title' );
|
||||
/**
|
||||
* Add the search results title to the search results page.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $template The template we're targeting.
|
||||
*/
|
||||
function generate_do_search_results_title( $template ) {
|
||||
if ( 'search' === $template ) {
|
||||
// phpcs:ignore -- No escaping needed.
|
||||
echo apply_filters(
|
||||
'generate_search_title_output',
|
||||
sprintf(
|
||||
'<header %s><h1 class="page-title">%s</h1></header>',
|
||||
generate_get_attr( 'page-header' ),
|
||||
sprintf(
|
||||
/* translators: 1: Search query name */
|
||||
__( 'Search Results for: %s', 'generatepress' ),
|
||||
'<span>' . get_search_query() . '</span>'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
233
wp-content/themes/generatepress/inc/structure/comments.php
Normal file
233
wp-content/themes/generatepress/inc/structure/comments.php
Normal file
@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* Comment structure.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
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 ) : ?>
|
||||
|
||||
<li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
|
||||
<div class="comment-body">
|
||||
<?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 <?php generate_do_attr( 'comment-body', array(), array( 'comment-id' => get_comment_ID() ) ); ?>>
|
||||
<footer <?php generate_do_attr( 'comment-meta' ); ?>>
|
||||
<?php
|
||||
if ( 0 != $args['avatar_size'] ) { // phpcs:ignore
|
||||
echo get_avatar( $comment, $args['avatar_size'] );
|
||||
}
|
||||
?>
|
||||
<div class="comment-author-info">
|
||||
<div <?php generate_do_element_classes( 'comment-author' ); ?>>
|
||||
<?php printf( '<cite itemprop="name" class="fn">%s</cite>', get_comment_author_link() ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* generate_after_comment_author_name hook.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
do_action( 'generate_after_comment_author_name' );
|
||||
|
||||
if ( apply_filters( 'generate_show_comment_entry_meta', true ) ) :
|
||||
$has_comment_date_link = apply_filters( 'generate_add_comment_date_link', true );
|
||||
|
||||
?>
|
||||
<div class="entry-meta comment-metadata">
|
||||
<?php
|
||||
if ( $has_comment_date_link ) {
|
||||
printf(
|
||||
'<a href="%s">',
|
||||
esc_url( get_comment_link( $comment->comment_ID ) )
|
||||
);
|
||||
}
|
||||
?>
|
||||
<time datetime="<?php comment_time( 'c' ); ?>" itemprop="datePublished">
|
||||
<?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>
|
||||
<?php
|
||||
if ( $has_comment_date_link ) {
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?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>
|
||||
|
||||
<div class="comment-content" itemprop="text">
|
||||
<?php
|
||||
/**
|
||||
* generate_before_comment_content hook.
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
do_action( 'generate_before_comment_text', $comment, $args, $depth );
|
||||
|
||||
comment_text();
|
||||
|
||||
/**
|
||||
* generate_after_comment_content hook.
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
do_action( 'generate_after_comment_text', $comment, $args, $depth );
|
||||
?>
|
||||
</div>
|
||||
</article>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_after_comment_text', 'generate_do_comment_reply_link', 10, 3 );
|
||||
/**
|
||||
* 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>',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_filter( 'comment_form_defaults', 'generate_set_comment_form_defaults' );
|
||||
/**
|
||||
* Set the default settings for our comments.
|
||||
*
|
||||
* @since 2.3
|
||||
*
|
||||
* @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" required></textarea></p>',
|
||||
esc_html__( 'Comment', 'generatepress' )
|
||||
);
|
||||
|
||||
$defaults['comment_notes_before'] = '';
|
||||
$defaults['comment_notes_after'] = '';
|
||||
$defaults['id_form'] = 'commentform';
|
||||
$defaults['id_submit'] = 'submit';
|
||||
$defaults['title_reply'] = apply_filters( 'generate_leave_comment', __( 'Leave a Comment', 'generatepress' ) );
|
||||
$defaults['label_submit'] = apply_filters( 'generate_post_comment', __( 'Post Comment', 'generatepress' ) );
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
add_filter( 'comment_form_default_fields', 'generate_filter_comment_fields' );
|
||||
/**
|
||||
* Customizes the existing comment fields.
|
||||
*
|
||||
* @since 2.1.2
|
||||
* @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%3$s" id="author" name="author" type="text" value="%2$s" size="30"%4$s />',
|
||||
esc_html__( 'Name', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author'] ),
|
||||
$required ? ' *' : '',
|
||||
$required ? ' required' : ''
|
||||
);
|
||||
|
||||
$fields['email'] = sprintf(
|
||||
'<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"%4$s />',
|
||||
esc_html__( 'Email', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author_email'] ),
|
||||
$required ? ' *' : '',
|
||||
$required ? ' required' : ''
|
||||
);
|
||||
|
||||
$fields['url'] = sprintf(
|
||||
'<label for="url" class="screen-reader-text">%1$s</label><input placeholder="%1$s" id="url" name="url" type="url" value="%2$s" size="30" />',
|
||||
esc_html__( 'Website', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author_url'] )
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* Featured image elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_post_image' ) ) {
|
||||
add_action( 'generate_after_entry_header', 'generate_post_image' );
|
||||
/**
|
||||
* Prints the Post Image to post excerpts
|
||||
*/
|
||||
function generate_post_image() {
|
||||
// If there's no featured image, return.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're not on any single post/page or the 404 template, we must be showing excerpts.
|
||||
if ( ! is_singular() && ! is_404() ) {
|
||||
|
||||
$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', '' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_featured_page_header_area' ) ) {
|
||||
/**
|
||||
* Build the page header.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*
|
||||
* @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.
|
||||
if ( ! is_singular() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't run the function unless we have a post thumbnail.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attrs = array();
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$attrs = 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
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_featured_page_header' ) ) {
|
||||
add_action( 'generate_after_header', 'generate_featured_page_header', 10 );
|
||||
/**
|
||||
* Add page header above content.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
function generate_featured_page_header() {
|
||||
if ( function_exists( 'generate_page_header' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_page() ) {
|
||||
generate_featured_page_header_area( 'page-header-image' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_featured_page_header_inside_single' ) ) {
|
||||
add_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
|
||||
/**
|
||||
* Add post header inside content.
|
||||
* Only add to single post.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
function generate_featured_page_header_inside_single() {
|
||||
if ( function_exists( 'generate_page_header' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_single() ) {
|
||||
generate_featured_page_header_area( 'page-header-image-single' );
|
||||
}
|
||||
}
|
||||
}
|
236
wp-content/themes/generatepress/inc/structure/footer.php
Normal file
236
wp-content/themes/generatepress/inc/structure/footer.php
Normal file
@ -0,0 +1,236 @@
|
||||
<?php
|
||||
/**
|
||||
* Footer elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_footer' ) ) {
|
||||
add_action( 'generate_footer', 'generate_construct_footer' );
|
||||
/**
|
||||
* Build our footer.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_construct_footer() {
|
||||
?>
|
||||
<footer <?php generate_do_attr( 'site-info' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-site-info' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_before_copyright hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @hooked generate_footer_bar - 15
|
||||
*/
|
||||
do_action( 'generate_before_copyright' );
|
||||
?>
|
||||
<div class="copyright-bar">
|
||||
<?php
|
||||
/**
|
||||
* generate_credits hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @hooked generate_add_footer_info - 10
|
||||
*/
|
||||
do_action( 'generate_credits' );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_footer_bar' ) ) {
|
||||
add_action( 'generate_before_copyright', 'generate_footer_bar', 15 );
|
||||
/**
|
||||
* Build our footer bar
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_footer_bar() {
|
||||
if ( ! is_active_sidebar( 'footer-bar' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="footer-bar">
|
||||
<?php dynamic_sidebar( 'footer-bar' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_footer_info' ) ) {
|
||||
add_action( 'generate_credits', 'generate_add_footer_info' );
|
||||
/**
|
||||
* Add the copyright to the footer
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_footer_info() {
|
||||
$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( 'Built with', 'GeneratePress', 'generatepress' ),
|
||||
__( 'GeneratePress', 'generatepress' ),
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="url"' : ''
|
||||
);
|
||||
|
||||
echo apply_filters( 'generate_copyright', $copyright ); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our individual footer widgets.
|
||||
* Displays a sample widget if no widget is found in the area.
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @param int $widget_width The width class of our widget.
|
||||
* @param int $widget The ID of our widget.
|
||||
*/
|
||||
function generate_do_footer_widget( $widget_width, $widget ) {
|
||||
$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="<?php echo $widget_classes; // phpcs:ignore ?>">
|
||||
<?php dynamic_sidebar( 'footer-' . absint( $widget ) ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_footer_widgets' ) ) {
|
||||
add_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
|
||||
/**
|
||||
* Build our footer widgets.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_construct_footer_widgets() {
|
||||
// Get how many widgets to show.
|
||||
$widgets = generate_get_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' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the widget width.
|
||||
$widget_width = '';
|
||||
|
||||
if ( 1 === (int) $widgets ) {
|
||||
$widget_width = '100';
|
||||
}
|
||||
|
||||
if ( 2 === (int) $widgets ) {
|
||||
$widget_width = '50';
|
||||
}
|
||||
|
||||
if ( 3 === (int) $widgets ) {
|
||||
$widget_width = '33';
|
||||
}
|
||||
|
||||
if ( 4 === (int) $widgets ) {
|
||||
$widget_width = '25';
|
||||
}
|
||||
|
||||
if ( 5 === (int) $widgets ) {
|
||||
$widget_width = '20';
|
||||
}
|
||||
?>
|
||||
<div id="footer-widgets" class="site footer-widgets">
|
||||
<div <?php generate_do_attr( 'footer-widgets-container' ); ?>>
|
||||
<div class="inside-footer-widgets">
|
||||
<?php
|
||||
if ( $widgets >= 1 ) {
|
||||
generate_do_footer_widget( $widget_width, 1 );
|
||||
}
|
||||
|
||||
if ( $widgets >= 2 ) {
|
||||
generate_do_footer_widget( $widget_width, 2 );
|
||||
}
|
||||
|
||||
if ( $widgets >= 3 ) {
|
||||
generate_do_footer_widget( $widget_width, 3 );
|
||||
}
|
||||
|
||||
if ( $widgets >= 4 ) {
|
||||
generate_do_footer_widget( $widget_width, 4 );
|
||||
}
|
||||
|
||||
if ( $widgets >= 5 ) {
|
||||
generate_do_footer_widget( $widget_width, 5 );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
/**
|
||||
* generate_after_footer_widgets hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_footer_widgets' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_back_to_top' ) ) {
|
||||
add_action( 'generate_after_footer', 'generate_back_to_top' );
|
||||
/**
|
||||
* Build the back to top button
|
||||
*
|
||||
* @since 1.3.24
|
||||
*/
|
||||
function generate_back_to_top() {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'enable' !== $generate_settings['back_to_top'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
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" 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' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
386
wp-content/themes/generatepress/inc/structure/header.php
Normal file
386
wp-content/themes/generatepress/inc/structure/header.php
Normal file
@ -0,0 +1,386 @@
|
||||
<?php
|
||||
/**
|
||||
* Header elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_header' ) ) {
|
||||
add_action( 'generate_header', 'generate_construct_header' );
|
||||
/**
|
||||
* Build the header.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_construct_header() {
|
||||
?>
|
||||
<header <?php generate_do_attr( 'header' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-header' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_before_header_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_before_header_content' );
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
// Add our main header items.
|
||||
generate_header_items();
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_after_header_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @hooked generate_add_navigation_float_right - 5
|
||||
*/
|
||||
do_action( 'generate_after_header_content' );
|
||||
?>
|
||||
</div>
|
||||
</header>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_header_items' ) ) {
|
||||
/**
|
||||
* Build the header contents.
|
||||
* Wrapping this into a function allows us to customize the order.
|
||||
*
|
||||
* @since 1.2.9.7
|
||||
*/
|
||||
function generate_header_items() {
|
||||
$order = apply_filters(
|
||||
'generate_header_items_order',
|
||||
array(
|
||||
'header-widget',
|
||||
'site-branding',
|
||||
'logo',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $order as $item ) {
|
||||
if ( 'header-widget' === $item ) {
|
||||
generate_construct_header_widget();
|
||||
}
|
||||
|
||||
if ( 'site-branding' === $item ) {
|
||||
generate_construct_site_title();
|
||||
}
|
||||
|
||||
if ( 'logo' === $item ) {
|
||||
generate_construct_logo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_logo' ) ) {
|
||||
/**
|
||||
* Build the logo
|
||||
*
|
||||
* @since 1.3.28
|
||||
*/
|
||||
function generate_construct_logo() {
|
||||
$logo_url = ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) ? wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ) : false;
|
||||
$logo_url = ( $logo_url ) ? $logo_url[0] : generate_get_option( 'logo' );
|
||||
|
||||
$logo_url = esc_url( apply_filters( 'generate_logo', $logo_url ) );
|
||||
$retina_logo_url = esc_url( apply_filters( 'generate_retina_logo', generate_get_option( 'retina_logo' ) ) );
|
||||
|
||||
// If we don't have a logo, bail.
|
||||
if ( empty( $logo_url ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_before_logo hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_before_logo' );
|
||||
|
||||
$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,
|
||||
)
|
||||
);
|
||||
|
||||
$data = get_theme_mod( 'custom_logo' ) && ( '' !== $retina_logo_url || generate_is_using_flexbox() )
|
||||
? wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) )
|
||||
: false;
|
||||
|
||||
if ( '' !== $retina_logo_url ) {
|
||||
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
|
||||
}
|
||||
|
||||
if ( $data ) {
|
||||
if ( isset( $data['width'] ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
}
|
||||
|
||||
if ( isset( $data['height'] ) ) {
|
||||
$attr['height'] = $data['height'];
|
||||
}
|
||||
}
|
||||
|
||||
$attr = array_map( 'esc_attr', $attr );
|
||||
|
||||
$html_attr = '';
|
||||
foreach ( $attr as $name => $value ) {
|
||||
$html_attr .= " $name=" . '"' . $value . '"';
|
||||
}
|
||||
|
||||
// Print our HTML.
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_logo_output',
|
||||
sprintf(
|
||||
'<div class="site-logo">
|
||||
<a href="%1$s" rel="home">
|
||||
<img %2$s />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
|
||||
$html_attr
|
||||
),
|
||||
$logo_url,
|
||||
$html_attr
|
||||
);
|
||||
|
||||
/**
|
||||
* generate_after_logo hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_logo' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_site_title' ) ) {
|
||||
/**
|
||||
* Build the site title and tagline.
|
||||
*
|
||||
* @since 1.3.28
|
||||
*/
|
||||
function generate_construct_site_title() {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
// Get the title and tagline.
|
||||
$title = get_bloginfo( '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; // 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; // 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"%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"%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_needs_site_branding_container() ) {
|
||||
echo '<div class="site-branding-container">';
|
||||
generate_construct_logo();
|
||||
}
|
||||
|
||||
// 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_needs_site_branding_container() ) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_header_items_order', 'generate_reorder_inline_site_branding' );
|
||||
/**
|
||||
* 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() ) {
|
||||
return $order;
|
||||
}
|
||||
|
||||
return array(
|
||||
'header-widget',
|
||||
'site-branding',
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_header_widget' ) ) {
|
||||
/**
|
||||
* Build the header widget.
|
||||
*
|
||||
* @since 1.3.28
|
||||
*/
|
||||
function generate_construct_header_widget() {
|
||||
if ( is_active_sidebar( 'header' ) ) :
|
||||
?>
|
||||
<div class="header-widget">
|
||||
<?php dynamic_sidebar( 'header' ); ?>
|
||||
</div>
|
||||
<?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 );
|
||||
/**
|
||||
* Build our top bar.
|
||||
*
|
||||
* @since 1.3.45
|
||||
*/
|
||||
function generate_top_bar() {
|
||||
if ( ! is_active_sidebar( 'top-bar' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div <?php generate_do_attr( 'top-bar' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-top-bar' ); ?>>
|
||||
<?php dynamic_sidebar( 'top-bar' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_pingback_header' ) ) {
|
||||
add_action( 'wp_head', 'generate_pingback_header' );
|
||||
/**
|
||||
* Add a pingback url auto-discovery header for singularly identifiable articles.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_pingback_header() {
|
||||
if ( is_singular() && pings_open() ) {
|
||||
printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_viewport' ) ) {
|
||||
add_action( 'wp_head', 'generate_add_viewport', 1 );
|
||||
/**
|
||||
* Add viewport to wp_head.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
function generate_add_viewport() {
|
||||
echo apply_filters( 'generate_meta_viewport', '<meta name="viewport" content="width=device-width, initial-scale=1">' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 );
|
||||
/**
|
||||
* Add skip to content link before the header.
|
||||
*
|
||||
* @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>',
|
||||
esc_attr__( 'Skip to content', 'generatepress' ),
|
||||
esc_html__( 'Skip to content', 'generatepress' )
|
||||
);
|
||||
}
|
635
wp-content/themes/generatepress/inc/structure/navigation.php
Normal file
635
wp-content/themes/generatepress/inc/structure/navigation.php
Normal file
@ -0,0 +1,635 @@
|
||||
<?php
|
||||
/**
|
||||
* Navigation elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_navigation_position' ) ) {
|
||||
/**
|
||||
* Build the navigation.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_navigation_position() {
|
||||
/**
|
||||
* generate_before_navigation hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_before_navigation' );
|
||||
?>
|
||||
<nav <?php generate_do_attr( 'navigation' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-navigation' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_inside_navigation hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @hooked generate_navigation_search - 10
|
||||
* @hooked generate_mobile_menu_search_icon - 10
|
||||
*/
|
||||
do_action( 'generate_inside_navigation' );
|
||||
?>
|
||||
<button <?php generate_do_attr( 'menu-toggle' ); ?>>
|
||||
<?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 = apply_filters( 'generate_mobile_menu_label', __( 'Menu', 'generatepress' ) );
|
||||
|
||||
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>
|
||||
<?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',
|
||||
'container' => 'div',
|
||||
'container_class' => 'main-nav',
|
||||
'container_id' => 'primary-menu',
|
||||
'menu_class' => '',
|
||||
'fallback_cb' => 'generate_menu_fallback',
|
||||
'items_wrap' => '<ul id="%1$s" class="%2$s ' . join( ' ', generate_get_element_classes( 'menu' ) ) . '">%3$s</ul>',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* generate_after_primary_menu hook.
|
||||
*
|
||||
* @since 2.3
|
||||
*/
|
||||
do_action( 'generate_after_primary_menu' );
|
||||
?>
|
||||
</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 <?php generate_do_attr( '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 <?php generate_do_attr( 'menu-toggle', array( '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 Existing menu args.
|
||||
*/
|
||||
function generate_menu_fallback( $args ) {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
?>
|
||||
<div id="primary-menu" class="main-nav">
|
||||
<ul <?php generate_do_element_classes( 'menu' ); ?>>
|
||||
<?php
|
||||
$args = array(
|
||||
'sort_column' => 'menu_order',
|
||||
'title_li' => '',
|
||||
'walker' => new Generate_Page_Walker(),
|
||||
);
|
||||
|
||||
wp_list_pages( $args );
|
||||
|
||||
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>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
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() ) {
|
||||
generate_navigation_position();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() ) {
|
||||
generate_navigation_position();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() ) {
|
||||
generate_navigation_position();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() ) {
|
||||
echo '<div class="gen-sidebar-nav">';
|
||||
generate_navigation_position();
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() ) {
|
||||
echo '<div class="gen-sidebar-nav">';
|
||||
generate_navigation_position();
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Generate_Page_Walker' ) && class_exists( 'Walker_Page' ) ) {
|
||||
/**
|
||||
* Add current-menu-item to the current item if no theme location is set
|
||||
* This means we don't have to duplicate CSS properties for current_page_item and current-menu-item
|
||||
*
|
||||
* @since 1.3.21
|
||||
*/
|
||||
class Generate_Page_Walker extends Walker_Page {
|
||||
function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { // phpcs:ignore
|
||||
$css_class = array( 'page_item', 'page-item-' . $page->ID );
|
||||
$button = '';
|
||||
|
||||
if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
|
||||
$css_class[] = 'menu-item-has-children';
|
||||
$icon = generate_get_svg_icon( 'arrow' );
|
||||
$button = '<span role="presentation" class="dropdown-menu-toggle">' . $icon . '</span>';
|
||||
}
|
||||
|
||||
if ( ! empty( $current_page ) ) {
|
||||
$_current_page = get_post( $current_page );
|
||||
if ( $_current_page && in_array( $page->ID, $_current_page->ancestors ) ) {
|
||||
$css_class[] = 'current-menu-ancestor';
|
||||
}
|
||||
|
||||
if ( $page->ID == $current_page ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-item';
|
||||
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
} 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'];
|
||||
$args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after'];
|
||||
|
||||
$output .= sprintf(
|
||||
'<li class="%s"><a href="%s">%s%s%s%s</a>',
|
||||
$css_classes,
|
||||
get_permalink( $page->ID ),
|
||||
$args['link_before'],
|
||||
apply_filters( 'the_title', $page->post_title, $page->ID ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name.
|
||||
$args['link_after'],
|
||||
$button
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
|
||||
add_filter( 'nav_menu_item_title', 'generate_dropdown_icon_to_menu_link', 10, 4 );
|
||||
/**
|
||||
* Add dropdown icon if menu item has children.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*
|
||||
* @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 $depth Depth of menu item.
|
||||
* @return string The menu item.
|
||||
*/
|
||||
function generate_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
|
||||
$role = 'presentation';
|
||||
$tabindex = '';
|
||||
|
||||
if ( 'click-arrow' === generate_get_option( 'nav_dropdown_type' ) ) {
|
||||
$role = 'button';
|
||||
$tabindex = ' tabindex="0"';
|
||||
}
|
||||
|
||||
if ( isset( $args->container_class ) && 'main-nav' === $args->container_class ) {
|
||||
foreach ( $item->classes as $value ) {
|
||||
if ( 'menu-item-has-children' === $value ) {
|
||||
$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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_navigation_search' ) ) {
|
||||
add_action( 'generate_inside_navigation', 'generate_navigation_search' );
|
||||
/**
|
||||
* Add the search bar to the navigation.
|
||||
*
|
||||
* @since 1.1.4
|
||||
*/
|
||||
function generate_navigation_search() {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'enable' !== $generate_settings['nav_search'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
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.
|
||||
* Only used if using old float system.
|
||||
*
|
||||
* @since 1.2.9.7
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
function generate_menu_search_icon( $nav, $args ) {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
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;
|
||||
}
|
||||
|
||||
// If our primary menu is set, add the search icon.
|
||||
if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) {
|
||||
$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.
|
||||
// In this case, the search icon is added to the generate_menu_fallback() function in navigation.php.
|
||||
return $nav;
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
* Only used if using old float system.
|
||||
*
|
||||
* @since 1.3.12
|
||||
*/
|
||||
function generate_mobile_menu_search_icon() {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
// If the search icon isn't enabled, return the regular nav.
|
||||
if ( 'enable' !== $generate_settings['nav_search'] ) {
|
||||
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 esc_attr_e( 'Open Search Bar', 'generatepress' ); ?>" href="#">
|
||||
<?php generate_do_svg_icon( 'search', true ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_footer', 'generate_clone_sidebar_navigation' );
|
||||
/**
|
||||
* Clone our sidebar navigation and place it below the header.
|
||||
* This places our mobile menu in a more user-friendly location.
|
||||
*
|
||||
* We're not using wp_add_inline_script() as this needs to happens
|
||||
* before menu.js is enqueued.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
function generate_clone_sidebar_navigation() {
|
||||
if ( 'nav-left-sidebar' !== generate_get_navigation_location() && 'nav-right-sidebar' !== generate_get_navigation_location() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
var target, nav, clone;
|
||||
nav = document.getElementById( 'site-navigation' );
|
||||
if ( nav ) {
|
||||
clone = nav.cloneNode( true );
|
||||
clone.className += ' sidebar-nav-mobile';
|
||||
clone.setAttribute( 'aria-label', '<?php esc_attr_e( 'Mobile Menu', 'generatepress' ); ?>' );
|
||||
target = document.getElementById( 'masthead' );
|
||||
if ( target ) {
|
||||
target.insertAdjacentHTML( 'afterend', clone.outerHTML );
|
||||
} else {
|
||||
document.body.insertAdjacentHTML( 'afterbegin', clone.outerHTML )
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
579
wp-content/themes/generatepress/inc/structure/post-meta.php
Normal file
579
wp-content/themes/generatepress/inc/structure/post-meta.php
Normal file
@ -0,0 +1,579 @@
|
||||
<?php
|
||||
/**
|
||||
* Post meta elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_content_nav' ) ) {
|
||||
/**
|
||||
* Display navigation to next/previous pages when applicable.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param string $nav_id The id of our navigation.
|
||||
*/
|
||||
function generate_content_nav( $nav_id ) {
|
||||
global $wp_query, $post;
|
||||
|
||||
// Don't print empty markup on single pages if there's nowhere to navigate.
|
||||
if ( is_single() ) {
|
||||
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
|
||||
$next = get_adjacent_post( false, '', false );
|
||||
|
||||
if ( ! $next && ! $previous ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't print empty markup in archives if there's only one page.
|
||||
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<nav <?php generate_do_attr( 'post-navigation', array( 'id' => esc_attr( $nav_id ) ) ); ?>>
|
||||
<?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-left' ) . '<span class="prev">%link</span></div>',
|
||||
'next_format' => '<div class="nav-next">' . generate_get_svg_icon( 'arrow-right' ) . '<span class="next">%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'],
|
||||
$post_navigation_args['link'],
|
||||
$post_navigation_args['in_same_term'],
|
||||
$post_navigation_args['excluded_terms'],
|
||||
$post_navigation_args['taxonomy']
|
||||
);
|
||||
|
||||
next_post_link(
|
||||
$post_navigation_args['next_format'],
|
||||
$post_navigation_args['link'],
|
||||
$post_navigation_args['in_same_term'],
|
||||
$post_navigation_args['excluded_terms'],
|
||||
$post_navigation_args['taxonomy']
|
||||
);
|
||||
|
||||
elseif ( is_home() || is_archive() || is_search() ) : // navigation links for home, archive, and search pages.
|
||||
|
||||
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>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
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>
|
||||
</div>
|
||||
<?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',
|
||||
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' )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_paging_navigation hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_paging_navigation' );
|
||||
|
||||
endif;
|
||||
?>
|
||||
</nav>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_modify_posts_pagination_template' ) ) {
|
||||
add_filter( 'navigation_markup_template', 'generate_modify_posts_pagination_template', 10, 2 );
|
||||
/**
|
||||
* Remove the container and screen reader text from the_posts_pagination()
|
||||
* We add this in ourselves in generate_content_nav()
|
||||
*
|
||||
* @since 1.3.45
|
||||
*
|
||||
* @param string $template The default template.
|
||||
* @param string $class The class passed by the calling function.
|
||||
* @return string The HTML for the post navigation.
|
||||
*/
|
||||
function generate_modify_posts_pagination_template( $template, $class ) {
|
||||
if ( ! empty( $class ) && false !== strpos( $class, 'pagination' ) ) {
|
||||
$template = '<div class="nav-links">%3$s</div>';
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output requested post meta.
|
||||
*
|
||||
* @since 2.3
|
||||
*
|
||||
* @param string $item The post meta item we're requesting.
|
||||
*/
|
||||
function generate_do_post_meta_item( $item ) {
|
||||
if ( 'date' === $item ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s"%5$s>%2$s</time>';
|
||||
|
||||
$updated_time = get_the_modified_time( 'U' );
|
||||
$published_time = get_the_time( 'U' ) + 1800;
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
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,
|
||||
esc_attr( get_the_date( 'c' ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( 'c' ) ),
|
||||
esc_html( get_the_modified_date() ),
|
||||
'microdata' === $schema_type ? ' itemprop="datePublished"' : '',
|
||||
'microdata' === $schema_type ? ' itemprop="dateModified"' : ''
|
||||
);
|
||||
|
||||
$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 ) {
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
$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 ) {
|
||||
$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 ) {
|
||||
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' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'tags' === $item ) {
|
||||
$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 ) {
|
||||
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' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'comments-link' === $item ) {
|
||||
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||
echo '<span class="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.
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
do_action( 'generate_post_meta_items', $item );
|
||||
}
|
||||
|
||||
add_filter( 'generate_inside_post_meta_item_output', 'generate_do_post_meta_prefix', 10, 2 );
|
||||
/**
|
||||
* 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 ) {
|
||||
$output = __( 'by', 'generatepress' ) . ' ';
|
||||
}
|
||||
|
||||
if ( 'categories' === $item ) {
|
||||
$output = generate_get_svg_icon( 'categories' );
|
||||
}
|
||||
|
||||
if ( 'tags' === $item ) {
|
||||
$output = generate_get_svg_icon( 'tags' );
|
||||
}
|
||||
|
||||
if ( 'comments-link' === $item ) {
|
||||
$output = generate_get_svg_icon( 'comments' );
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
$items = array_diff( (array) $items, array( 'post-navigation' ) );
|
||||
}
|
||||
|
||||
// Disable post meta items based on their individual filters.
|
||||
$items = generate_disable_post_meta_items( $items );
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_posted_on' ) ) {
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time and author.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_posted_on() {
|
||||
$items = generate_get_header_entry_meta_items();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
generate_do_post_meta_item( $item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_entry_meta' ) ) {
|
||||
/**
|
||||
* Prints HTML with meta information for the categories, tags.
|
||||
*
|
||||
* @since 1.2.5
|
||||
*/
|
||||
function generate_entry_meta() {
|
||||
$items = generate_get_footer_entry_meta_items();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
generate_do_post_meta_item( $item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_excerpt_more' ) ) {
|
||||
add_filter( 'excerpt_more', 'generate_excerpt_more' );
|
||||
/**
|
||||
* Prints the read more HTML to post excerpts.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param string $more The string shown within the more link.
|
||||
* @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" 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' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_content_more' ) ) {
|
||||
add_filter( 'the_content_more_link', 'generate_content_more' );
|
||||
/**
|
||||
* Prints the read more HTML to post content using the more tag.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param string $more The string shown within the more link.
|
||||
* @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" 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' ) ) {
|
||||
/**
|
||||
* Build the post meta.
|
||||
*
|
||||
* @since 1.3.29
|
||||
*/
|
||||
function generate_post_meta() {
|
||||
?>
|
||||
<div class="entry-meta">
|
||||
<?php generate_posted_on(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_footer_meta' ) ) {
|
||||
/**
|
||||
* Build the footer post meta.
|
||||
*
|
||||
* @since 1.3.30
|
||||
*/
|
||||
function generate_footer_meta() {
|
||||
?>
|
||||
<footer <?php generate_do_attr( 'footer-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' );
|
||||
}
|
||||
}
|
111
wp-content/themes/generatepress/inc/structure/search-modal.php
Normal file
111
wp-content/themes/generatepress/inc/structure/search-modal.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Post meta elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action( 'wp_footer', 'generate_do_search_modal' );
|
||||
/**
|
||||
* Create the search modal HTML.
|
||||
*/
|
||||
function generate_do_search_modal() {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="gp-modal gp-search-modal" id="gp-search">
|
||||
<div class="gp-modal__overlay" tabindex="-1" data-gpmodal-close>
|
||||
<div class="gp-modal__container">
|
||||
<?php do_action( 'generate_inside_search_modal' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_search_modal_trigger' );
|
||||
/**
|
||||
* Create the search modal trigger.
|
||||
*/
|
||||
function generate_do_search_modal_trigger() {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<span class="menu-bar-item">
|
||||
<a href="#" role="button" aria-label="<?php _e( 'Open search', 'generatepress' ); ?>" data-gpmodal-trigger="gp-search"><?php echo generate_get_svg_icon( 'search', true ); // phpcs:ignore -- Escaped in function. ?></a>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_filter( 'generate_enable_modal_script', 'generate_enable_search_modal' );
|
||||
/**
|
||||
* Enable the search modal.
|
||||
*/
|
||||
function generate_enable_search_modal() {
|
||||
return generate_get_option( 'nav_search_modal' );
|
||||
}
|
||||
|
||||
add_action( 'generate_base_css', 'generate_do_search_modal_css' );
|
||||
/**
|
||||
* Do the modal CSS.
|
||||
*
|
||||
* @param Object $css The existing CSS object.
|
||||
*/
|
||||
function generate_do_search_modal_css( $css ) {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css->set_selector( '.search-modal-fields' );
|
||||
$css->add_property( 'display', 'flex' );
|
||||
|
||||
$css->set_selector( '.gp-search-modal .gp-modal__overlay' );
|
||||
$css->add_property( 'align-items', 'flex-start' );
|
||||
$css->add_property( 'padding-top', '25vh' );
|
||||
$css->add_property( 'background', 'var(--gp-search-modal-overlay-bg-color)' );
|
||||
|
||||
$css->set_selector( '.search-modal-form' );
|
||||
$css->add_property( 'width', '500px' );
|
||||
$css->add_property( 'max-width', '100%' );
|
||||
$css->add_property( 'background-color', 'var(--gp-search-modal-bg-color)' );
|
||||
$css->add_property( 'color', 'var(--gp-search-modal-text-color)' );
|
||||
|
||||
$css->set_selector( '.search-modal-form .search-field, .search-modal-form .search-field:focus' );
|
||||
$css->add_property( 'width', '100%' );
|
||||
$css->add_property( 'height', '60px' );
|
||||
$css->add_property( 'background-color', 'transparent' );
|
||||
$css->add_property( 'border', 0 );
|
||||
$css->add_property( 'appearance', 'none' );
|
||||
$css->add_property( 'color', 'currentColor' );
|
||||
|
||||
$css->set_selector( '.search-modal-fields button, .search-modal-fields button:active, .search-modal-fields button:focus, .search-modal-fields button:hover' );
|
||||
$css->add_property( 'background-color', 'transparent' );
|
||||
$css->add_property( 'border', 0 );
|
||||
$css->add_property( 'color', 'currentColor' );
|
||||
$css->add_property( 'width', '60px' );
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
add_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
|
||||
/**
|
||||
* Add our search fields to the modal.
|
||||
*/
|
||||
function generate_do_search_fields() {
|
||||
?>
|
||||
<form role="search" method="get" class="search-modal-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
||||
<label class="screen-reader-text"><?php echo apply_filters( 'generate_search_label', _x( 'Search for:', 'label', 'generatepress' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||
<div class="search-modal-fields">
|
||||
<input type="search" class="search-field" placeholder="<?php echo esc_attr( apply_filters( 'generate_search_placeholder', _x( 'Search …', 'placeholder', 'generatepress' ) ) ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
|
||||
<button aria-label="<?php echo esc_attr( apply_filters( 'generate_search_button', _x( 'Search', 'submit button', 'generatepress' ) ) ); ?>"><?php echo generate_get_svg_icon( 'search' ); // phpcs:ignore -- Escaped in function. ?></button>
|
||||
</div>
|
||||
<?php do_action( 'generate_inside_search_modal_form' ); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
83
wp-content/themes/generatepress/inc/structure/sidebars.php
Normal file
83
wp-content/themes/generatepress/inc/structure/sidebars.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Build the sidebars.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_construct_sidebars' ) ) {
|
||||
/**
|
||||
* Construct the sidebars.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_construct_sidebars() {
|
||||
$layout = generate_get_layout();
|
||||
|
||||
// When to show the right sidebar.
|
||||
$rs = array( 'right-sidebar', 'both-sidebars', 'both-right', 'both-left' );
|
||||
|
||||
// When to show the left sidebar.
|
||||
$ls = array( 'left-sidebar', 'both-sidebars', 'both-right', 'both-left' );
|
||||
|
||||
// If left sidebar, show it.
|
||||
if ( in_array( $layout, $ls ) ) {
|
||||
get_sidebar( 'left' );
|
||||
}
|
||||
|
||||
// If right sidebar, show it.
|
||||
if ( in_array( $layout, $rs ) ) {
|
||||
get_sidebar();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show sidebar widgets if no widgets are added to the sidebar area.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @param string $area Left or right sidebar.
|
||||
*/
|
||||
function generate_do_default_sidebar_widgets( $area ) {
|
||||
if ( 'nav-' . $area === generate_get_navigation_location() ) { // phpcs:ignore -- False positive.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
$secondary_nav = wp_parse_args(
|
||||
get_option( 'generate_secondary_nav_settings', array() ),
|
||||
generate_secondary_nav_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'secondary-nav-' . $area === $secondary_nav['secondary_nav_position_setting'] ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'generate_show_default_sidebar_widgets', true ) || generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<aside id="search" class="widget widget_search">
|
||||
<?php get_search_form(); ?>
|
||||
</aside>
|
||||
|
||||
<aside id="archives" class="widget">
|
||||
<h2 class="widget-title"><?php esc_html_e( 'Archives', 'generatepress' ); ?></h2>
|
||||
<ul>
|
||||
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
|
||||
</ul>
|
||||
</aside>
|
||||
<?php
|
||||
}
|
Reference in New Issue
Block a user