Initial commit
This commit is contained in:
commit
28e6ddf404
1083 changed files with 191734 additions and 0 deletions
71
inc/back-compat.php
Normal file
71
inc/back-compat.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* Twenty Sixteen back compat functionality
|
||||
*
|
||||
* Prevents Twenty Sixteen from running on WordPress versions prior to 4.4,
|
||||
* since this theme is not meant to be backward compatible beyond that and
|
||||
* relies on many newer functions and markup changes introduced in 4.4.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Sixteen
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prevent switching to Twenty Sixteen on old versions of WordPress.
|
||||
*
|
||||
* Switches to the default theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
function twentysixteen_switch_theme() {
|
||||
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
|
||||
|
||||
unset( $_GET['activated'] );
|
||||
|
||||
add_action( 'admin_notices', 'twentysixteen_upgrade_notice' );
|
||||
}
|
||||
add_action( 'after_switch_theme', 'twentysixteen_switch_theme' );
|
||||
|
||||
/**
|
||||
* Adds a message for unsuccessful theme switch.
|
||||
*
|
||||
* Prints an update nag after an unsuccessful attempt to switch to
|
||||
* Twenty Sixteen on WordPress versions prior to 4.4.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @global string $wp_version WordPress version.
|
||||
*/
|
||||
function twentysixteen_upgrade_notice() {
|
||||
$message = sprintf( __( 'Twenty Sixteen requires at least WordPress version 4.4. You are running version %s. Please upgrade and try again.', 'twentysixteen' ), $GLOBALS['wp_version'] );
|
||||
printf( '<div class="error"><p>%s</p></div>', $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the Customizer from being loaded on WordPress versions prior to 4.4.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @global string $wp_version WordPress version.
|
||||
*/
|
||||
function twentysixteen_customize() {
|
||||
wp_die( sprintf( __( 'Twenty Sixteen requires at least WordPress version 4.4. You are running version %s. Please upgrade and try again.', 'twentysixteen' ), $GLOBALS['wp_version'] ), '', array(
|
||||
'back_link' => true,
|
||||
) );
|
||||
}
|
||||
add_action( 'load-customize.php', 'twentysixteen_customize' );
|
||||
|
||||
/**
|
||||
* Prevents the Theme Preview from being loaded on WordPress versions prior to 4.4.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @global string $wp_version WordPress version.
|
||||
*/
|
||||
function twentysixteen_preview() {
|
||||
if ( isset( $_GET['preview'] ) ) {
|
||||
wp_die( sprintf( __( 'Twenty Sixteen requires at least WordPress version 4.4. You are running version %s. Please upgrade and try again.', 'twentysixteen' ), $GLOBALS['wp_version'] ) );
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'twentysixteen_preview' );
|
1165
inc/customizer.php
Normal file
1165
inc/customizer.php
Normal file
File diff suppressed because it is too large
Load diff
262
inc/template-tags.php
Normal file
262
inc/template-tags.php
Normal file
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/**
|
||||
* Custom Twenty Sixteen template tags
|
||||
*
|
||||
* Eventually, some of the functionality here could be replaced by core features.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Sixteen
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_entry_meta' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the categories, tags.
|
||||
*
|
||||
* Create your own twentysixteen_entry_meta() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
function twentysixteen_entry_meta() {
|
||||
if ( 'post' === get_post_type() ) {
|
||||
$author_avatar_size = apply_filters( 'twentysixteen_author_avatar_size', 49 );
|
||||
printf( '<span class="byline"><span class="author">%1$s<a class="url fn n" href="%3$s">%4$s</a></span></span>',
|
||||
get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ),
|
||||
_x( 'Author', 'Used before post author name.', 'twentysixteen' ),
|
||||
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
||||
get_the_author()
|
||||
);
|
||||
}
|
||||
|
||||
if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
|
||||
twentysixteen_entry_date();
|
||||
}
|
||||
|
||||
$format = get_post_format();
|
||||
if ( current_theme_supports( 'post-formats', $format ) ) {
|
||||
printf( '<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
|
||||
sprintf( '<span class="screen-reader-text">%s </span></div>', _x( 'Format', 'Used before post format.', 'twentysixteen' ) ),
|
||||
esc_url( get_post_format_link( $format ) ),
|
||||
get_post_format_string( $format )
|
||||
);
|
||||
}
|
||||
|
||||
edit_post_link(
|
||||
sprintf(
|
||||
/* translators: %s: Name of current post */
|
||||
__( 'Edit', 'twentysixteen' ),
|
||||
get_the_title()
|
||||
),
|
||||
'<span class="edit-link">',
|
||||
'</span>'
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_entry_date' ) ) :
|
||||
/**
|
||||
* Prints HTML with date information for current post.
|
||||
*
|
||||
* Create your own twentysixteen_entry_date() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
function twentysixteen_entry_date() {
|
||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
|
||||
}
|
||||
|
||||
$time_string = sprintf( $time_string,
|
||||
esc_attr( get_the_date( 'c' ) ),
|
||||
get_the_date(),
|
||||
esc_attr( get_the_modified_date( 'c' ) ),
|
||||
get_the_modified_date()
|
||||
);
|
||||
|
||||
printf( '<span class="posted-on"><a href="%2$s" rel="bookmark">%3$s</a></span>',
|
||||
_x( 'Posted on', 'Used before publish date.', 'bengoldsworthy' ),
|
||||
esc_url( get_permalink() ),
|
||||
$time_string
|
||||
);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_entry_taxonomies' ) ) :
|
||||
/**
|
||||
* Prints HTML with category and tags for current post.
|
||||
*
|
||||
* Create your own twentysixteen_entry_taxonomies() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
function twentysixteen_entry_taxonomies() {
|
||||
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
|
||||
if ( $categories_list && twentysixteen_categorized_blog() ) {
|
||||
printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
|
||||
_x( 'Categories', 'Used before category names.', 'twentysixteen' ),
|
||||
$categories_list
|
||||
);
|
||||
}
|
||||
|
||||
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
|
||||
if ( $tags_list ) {
|
||||
printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
|
||||
_x( 'Tags', 'Used before tag names.', 'twentysixteen' ),
|
||||
$tags_list
|
||||
);
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_post_thumbnail' ) ) :
|
||||
/**
|
||||
* Displays an optional post thumbnail.
|
||||
*
|
||||
* Wraps the post thumbnail in an anchor element on index views, or a div
|
||||
* element when on single views.
|
||||
*
|
||||
* Create your own twentysixteen_post_thumbnail() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
function twentysixteen_post_thumbnail() {
|
||||
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_singular() ) :
|
||||
?>
|
||||
|
||||
<div class="post-header-image">
|
||||
<div class="post-title"><?php the_title( '<h2 class="title">', '</h2>' ); ?></div>
|
||||
<?php the_post_thumbnail(); ?>
|
||||
</div><!-- .post-thumbnail -->
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<!--<a class="post-thumbnail" href="<?php //the_permalink(); ?>" aria-hidden="true">
|
||||
<div class="read-div">Read</div>
|
||||
<?php //the_post_thumbnail( 'post-thumbnail', array( 'alt' => the_title_attribute( 'echo=0' ) ) ); ?>
|
||||
</a>-->
|
||||
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
|
||||
<div class="image-thumbnail" style="background-image: url('<?php the_post_thumbnail_url(); ?>');">
|
||||
<div class="read-div">Read</div>
|
||||
<?php //the_post_thumbnail( 'post-thumbnail', array( 'alt' => the_title_attribute( 'echo=0' ) ) ); ?>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<?php endif; // End is_singular()
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_excerpt' ) ) :
|
||||
/**
|
||||
* Displays the optional excerpt.
|
||||
*
|
||||
* Wraps the excerpt in a div element.
|
||||
*
|
||||
* Create your own twentysixteen_excerpt() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @param string $class Optional. Class string of the div element. Defaults to 'entry-summary'.
|
||||
*/
|
||||
function twentysixteen_excerpt( $class = 'entry-summary' ) {
|
||||
$class = esc_attr( $class );
|
||||
|
||||
if ( has_excerpt() || is_search() ) : ?>
|
||||
<div class="<?php echo $class; ?>">
|
||||
<?php the_excerpt(); ?>
|
||||
</div><!-- .<?php echo $class; ?> -->
|
||||
<?php endif;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_excerpt_more' ) && ! is_admin() ) :
|
||||
/**
|
||||
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
|
||||
* a 'Continue reading' link.
|
||||
*
|
||||
* Create your own twentysixteen_excerpt_more() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @return string 'Continue reading' link prepended with an ellipsis.
|
||||
*/
|
||||
function twentysixteen_excerpt_more() {
|
||||
$link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
|
||||
esc_url( get_permalink( get_the_ID() ) ),
|
||||
/* translators: %s: Name of current post */
|
||||
sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ), get_the_title( get_the_ID() ) )
|
||||
);
|
||||
return ' … ' . $link;
|
||||
}
|
||||
add_filter( 'excerpt_more', 'twentysixteen_excerpt_more' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Determines whether blog/site has more than one category.
|
||||
*
|
||||
* Create your own twentysixteen_categorized_blog() function to override in a child theme.
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @return bool True if there is more than one category, false otherwise.
|
||||
*/
|
||||
function twentysixteen_categorized_blog() {
|
||||
if ( false === ( $all_the_cool_cats = get_transient( 'twentysixteen_categories' ) ) ) {
|
||||
// Create an array of all the categories that are attached to posts.
|
||||
$all_the_cool_cats = get_categories( array(
|
||||
'fields' => 'ids',
|
||||
// We only need to know if there is more than one category.
|
||||
'number' => 2,
|
||||
) );
|
||||
|
||||
// Count the number of categories that are attached to the posts.
|
||||
$all_the_cool_cats = count( $all_the_cool_cats );
|
||||
|
||||
set_transient( 'twentysixteen_categories', $all_the_cool_cats );
|
||||
}
|
||||
|
||||
if ( $all_the_cool_cats > 1 ) {
|
||||
// This blog has more than 1 category so twentysixteen_categorized_blog should return true.
|
||||
return true;
|
||||
} else {
|
||||
// This blog has only 1 category so twentysixteen_categorized_blog should return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes out the transients used in twentysixteen_categorized_blog().
|
||||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*/
|
||||
function twentysixteen_category_transient_flusher() {
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
// Like, beat it. Dig?
|
||||
delete_transient( 'twentysixteen_categories' );
|
||||
}
|
||||
add_action( 'edit_category', 'twentysixteen_category_transient_flusher' );
|
||||
add_action( 'save_post', 'twentysixteen_category_transient_flusher' );
|
||||
|
||||
if ( ! function_exists( 'twentysixteen_the_custom_logo' ) ) :
|
||||
/**
|
||||
* Displays the optional custom logo.
|
||||
*
|
||||
* Does nothing if the custom logo is not available.
|
||||
*
|
||||
* @since Twenty Sixteen 1.2
|
||||
*/
|
||||
function twentysixteen_the_custom_logo() {
|
||||
if ( function_exists( 'the_custom_logo' ) ) {
|
||||
the_custom_logo();
|
||||
}
|
||||
}
|
||||
endif;
|
Reference in a new issue