Initial commit
This commit is contained in:
116
wp-content/themes/generatepress/inc/structure/archives.php
Normal file
116
wp-content/themes/generatepress/inc/structure/archives.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$clearfix = is_author() ? ' clearfix' : '';
|
||||
?>
|
||||
<header class="page-header<?php echo $clearfix; // WPCS: XSS ok, sanitization ok. ?>">
|
||||
<?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><!-- .page-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' ), 75 ),
|
||||
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 = term_description();
|
||||
|
||||
if ( ! empty( $term_description ) ) {
|
||||
printf( '<div class="taxonomy-description">%s</div>', $term_description ); // WPCS: XSS ok, sanitization ok.
|
||||
}
|
||||
|
||||
if ( get_the_author_meta( 'description' ) && is_author() ) {
|
||||
echo '<div class="author-info">' . get_the_author_meta( 'description' ) . '</div>'; // WPCS: XSS ok, sanitization ok.
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_after_archive_description hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_archive_description' );
|
||||
}
|
161
wp-content/themes/generatepress/inc/structure/comments.php
Normal file
161
wp-content/themes/generatepress/inc/structure/comments.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?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.
|
||||
*/
|
||||
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 _e( 'Pingback:', 'generatepress' ); // WPCS: XSS OK. ?> <?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' ); ?>>
|
||||
<footer class="comment-meta">
|
||||
<?php
|
||||
if ( 0 != $args['avatar_size'] ) {
|
||||
echo get_avatar( $comment, $args['avatar_size'] );
|
||||
}
|
||||
?>
|
||||
<div class="comment-author-info">
|
||||
<div class="comment-author vcard" <?php generate_do_microdata( 'comment-author' ); ?>>
|
||||
<?php printf( '<cite itemprop="name" class="fn">%s</cite>', get_comment_author_link() ); ?>
|
||||
</div><!-- .comment-author -->
|
||||
|
||||
<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()
|
||||
); ?>
|
||||
</time>
|
||||
</a>
|
||||
<?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' ); ?>
|
||||
</div><!-- .comment-metadata -->
|
||||
</div><!-- .comment-author-info -->
|
||||
|
||||
<?php if ( '0' == $comment->comment_approved ) : ?>
|
||||
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'generatepress' ); // WPCS: XSS OK. ?></p>
|
||||
<?php endif; ?>
|
||||
</footer><!-- .comment-meta -->
|
||||
|
||||
<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><!-- .comment-content -->
|
||||
</article><!-- .comment-body -->
|
||||
<?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
|
||||
*/
|
||||
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
|
||||
* @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>',
|
||||
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' ) );
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
add_filter( 'comment_form_default_fields', 'generate_filter_comment_fields' );
|
||||
/**
|
||||
* Customizes the existing comment fields.
|
||||
*
|
||||
* @since 2.1.2
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*/
|
||||
function generate_filter_comment_fields( $fields ) {
|
||||
$commenter = wp_get_current_commenter();
|
||||
|
||||
$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" />',
|
||||
esc_html__( 'Name', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author'] )
|
||||
);
|
||||
|
||||
$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" />',
|
||||
esc_html__( 'Email', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author_email'] )
|
||||
);
|
||||
|
||||
$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;
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
<?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() ) {
|
||||
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', '' )
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_featured_page_header_area' ) ) {
|
||||
/**
|
||||
* Build the page header.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*
|
||||
* @param string 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;
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
<?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' );
|
||||
}
|
||||
}
|
||||
}
|
224
wp-content/themes/generatepress/inc/structure/footer.php
Normal file
224
wp-content/themes/generatepress/inc/structure/footer.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?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 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; ?>">
|
||||
<?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><!-- .site-info -->
|
||||
<?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" itemprop="url">%5$s</a>',
|
||||
date( 'Y' ),
|
||||
get_bloginfo( 'name' ),
|
||||
esc_url( 'https://generatepress.com' ),
|
||||
_x( 'Powered by', 'GeneratePress', 'generatepress' ),
|
||||
__( 'GeneratePress', 'generatepress' )
|
||||
);
|
||||
|
||||
echo apply_filters( 'generate_copyright', $copyright ); // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_width = apply_filters( "generate_footer_widget_{$widget}_width", $widget_width );
|
||||
$tablet_widget_width = apply_filters( "generate_footer_widget_{$widget}_tablet_width", '50' );
|
||||
?>
|
||||
<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">
|
||||
<?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 ( $widgets == 1 ) {
|
||||
$widget_width = '100';
|
||||
}
|
||||
|
||||
if ( $widgets == 2 ) {
|
||||
$widget_width = '50';
|
||||
}
|
||||
|
||||
if ( $widgets == 3 ) {
|
||||
$widget_width = '33';
|
||||
}
|
||||
|
||||
if ( $widgets == 4 ) {
|
||||
$widget_width = '25';
|
||||
}
|
||||
|
||||
if ( $widgets == 5 ) {
|
||||
$widget_width = '20';
|
||||
}
|
||||
?>
|
||||
<div id="footer-widgets" class="site footer-widgets">
|
||||
<div <?php generate_do_element_classes( 'inside_footer' ); ?>>
|
||||
<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( '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' )
|
||||
) );
|
||||
}
|
||||
}
|
310
wp-content/themes/generatepress/inc/structure/header.php
Normal file
310
wp-content/themes/generatepress/inc/structure/header.php
Normal file
@ -0,0 +1,310 @@
|
||||
<?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 id="masthead" <?php generate_do_element_classes( 'header' ); ?> <?php generate_do_microdata( 'header' ); ?>>
|
||||
<div <?php generate_do_element_classes( 'inside_header' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_before_header_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_before_header_content' );
|
||||
|
||||
// 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><!-- .inside-header -->
|
||||
</header><!-- #masthead -->
|
||||
<?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',
|
||||
'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';
|
||||
|
||||
// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
|
||||
if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
|
||||
$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
$attr['height'] = $data['height'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$attr = array_map( 'esc_attr', $attr );
|
||||
|
||||
$html_attr = '';
|
||||
foreach ( $attr as $name => $value ) {
|
||||
$html_attr .= " $name=" . '"' . $value . '"';
|
||||
}
|
||||
|
||||
// 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' ) ) ),
|
||||
$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;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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' )
|
||||
) );
|
||||
|
||||
// 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 title and tagline.
|
||||
if ( false == $disable_title || false == $disable_tagline ) {
|
||||
if ( generate_get_option( 'inline_logo_site_branding' ) && generate_has_logo_site_branding() ) {
|
||||
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 : ''
|
||||
) );
|
||||
|
||||
if ( generate_get_option( 'inline_logo_site_branding' ) && generate_has_logo_site_branding() ) {
|
||||
echo '</div><!-- .site-branding-container -->';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_header_items_order', 'generate_reorder_inline_site_branding' );
|
||||
/**
|
||||
* Remove the logo from it's usual position.
|
||||
*
|
||||
* @since 2.3
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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_element_classes( 'top_bar' ); ?>>
|
||||
<div class="inside-top-bar<?php if ( 'contained' == generate_get_option( 'top_bar_inner_width' ) ) echo ' grid-container grid-parent'; ?>">
|
||||
<?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' );
|
||||
/**
|
||||
* 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">' ); // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
|
||||
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' )
|
||||
);
|
||||
}
|
397
wp-content/themes/generatepress/inc/structure/navigation.php
Normal file
397
wp-content/themes/generatepress/inc/structure/navigation.php
Normal file
@ -0,0 +1,397 @@
|
||||
<?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() {
|
||||
?>
|
||||
<nav id="site-navigation" <?php generate_do_element_classes( 'navigation' ); ?> <?php generate_do_microdata( 'navigation' ); ?>>
|
||||
<div <?php generate_do_element_classes( '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 class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
|
||||
<?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
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
__( 'Menu', 'generatepress' )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
<?php
|
||||
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><!-- .inside-navigation -->
|
||||
</nav><!-- #site-navigation -->
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_menu_fallback' ) ) {
|
||||
/**
|
||||
* Menu fallback.
|
||||
*
|
||||
* @since 1.1.4
|
||||
*
|
||||
* @param array $args
|
||||
* @return string
|
||||
*/
|
||||
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 ( '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 )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div><!-- .main-nav -->
|
||||
<?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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 ) {
|
||||
$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 ) {
|
||||
$css_class[] = 'current-menu-item';
|
||||
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
} elseif ( $page->ID == get_option( 'page_for_posts' ) ) {
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
|
||||
$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 ),
|
||||
$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 $dept 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 ) {
|
||||
$icon = generate_get_svg_icon( 'arrow' );
|
||||
$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( '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' )
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
* @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 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 ) {
|
||||
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 )
|
||||
);
|
||||
}
|
||||
|
||||
// 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
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
?>
|
||||
<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="#">
|
||||
<?php generate_do_svg_icon( 'search', true ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</div><!-- .mobile-bar-items -->
|
||||
<?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
|
||||
}
|
388
wp-content/themes/generatepress/inc/structure/post-meta.php
Normal file
388
wp-content/themes/generatepress/inc/structure/post-meta.php
Normal file
@ -0,0 +1,388 @@
|
||||
<?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 ) {
|
||||
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.
|
||||
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_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation';
|
||||
?>
|
||||
<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.
|
||||
|
||||
$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',
|
||||
) );
|
||||
|
||||
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', __( '← Previous', 'generatepress' ) ),
|
||||
'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_paging_navigation hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_paging_navigation' );
|
||||
|
||||
endif; ?>
|
||||
</nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
|
||||
<?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
|
||||
* @return The requested HTML.
|
||||
*/
|
||||
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" itemprop="datePublished">%2$s</time>';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$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() )
|
||||
);
|
||||
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'author' === $item ) {
|
||||
$author = apply_filters( 'generate_post_author', true );
|
||||
|
||||
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' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
|
||||
$categories_list,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
|
||||
$tags_list,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'tags' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'comments-link' === $item ) {
|
||||
$comments = apply_filters( 'generate_show_comments', true );
|
||||
|
||||
if ( $comments && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||
echo '<span class="comments-link">';
|
||||
echo apply_filters( 'generate_inside_post_meta_item_output', '', 'comments-link' );
|
||||
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
|
||||
echo '</span> ';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
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 = apply_filters( 'generate_header_entry_meta_items', array(
|
||||
'date',
|
||||
'author',
|
||||
) );
|
||||
|
||||
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 = apply_filters( 'generate_footer_entry_meta_items', array(
|
||||
'categories',
|
||||
'tags',
|
||||
'comments-link',
|
||||
) );
|
||||
|
||||
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">%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>'
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
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">%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>'
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
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() ) {
|
||||
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 ) ) {
|
||||
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