Initial commit
This commit is contained in:
76
wp-content/themes/twentyseventeen/inc/back-compat.php
Normal file
76
wp-content/themes/twentyseventeen/inc/back-compat.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Twenty Seventeen back compat functionality
|
||||
*
|
||||
* Prevents Twenty Seventeen from running on WordPress versions prior to 4.7,
|
||||
* since this theme is not meant to be backward compatible beyond that and
|
||||
* relies on many newer functions and markup changes introduced in 4.7.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prevent switching to Twenty Seventeen on old versions of WordPress.
|
||||
*
|
||||
* Switches to the default theme.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
function twentyseventeen_switch_theme() {
|
||||
switch_theme( WP_DEFAULT_THEME );
|
||||
unset( $_GET['activated'] );
|
||||
add_action( 'admin_notices', 'twentyseventeen_upgrade_notice' );
|
||||
}
|
||||
add_action( 'after_switch_theme', 'twentyseventeen_switch_theme' );
|
||||
|
||||
/**
|
||||
* Adds a message for unsuccessful theme switch.
|
||||
*
|
||||
* Prints an update nag after an unsuccessful attempt to switch to
|
||||
* Twenty Seventeen on WordPress versions prior to 4.7.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @global string $wp_version WordPress version.
|
||||
*/
|
||||
function twentyseventeen_upgrade_notice() {
|
||||
/* translators: %s: The current WordPress version. */
|
||||
$message = sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] );
|
||||
printf( '<div class="error"><p>%s</p></div>', $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the Customizer from being loaded on WordPress versions prior to 4.7.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @global string $wp_version WordPress version.
|
||||
*/
|
||||
function twentyseventeen_customize() {
|
||||
wp_die(
|
||||
/* translators: %s: The current WordPress version. */
|
||||
sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ),
|
||||
'',
|
||||
array(
|
||||
'back_link' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'load-customize.php', 'twentyseventeen_customize' );
|
||||
|
||||
/**
|
||||
* Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @global string $wp_version WordPress version.
|
||||
*/
|
||||
function twentyseventeen_preview() {
|
||||
if ( isset( $_GET['preview'] ) ) {
|
||||
/* translators: %s: The current WordPress version. */
|
||||
wp_die( sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ) );
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'twentyseventeen_preview' );
|
||||
580
wp-content/themes/twentyseventeen/inc/color-patterns.php
Normal file
580
wp-content/themes/twentyseventeen/inc/color-patterns.php
Normal file
@ -0,0 +1,580 @@
|
||||
<?php
|
||||
/**
|
||||
* Twenty Seventeen: Color Patterns
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate the CSS for the current custom color scheme.
|
||||
*/
|
||||
function twentyseventeen_custom_colors_css() {
|
||||
$hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
|
||||
|
||||
/**
|
||||
* Filter Twenty Seventeen default saturation level.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @param int $saturation Color saturation level.
|
||||
*/
|
||||
$saturation = absint( apply_filters( 'twentyseventeen_custom_colors_saturation', 50 ) );
|
||||
$reduced_saturation = ( .8 * $saturation ) . '%';
|
||||
$saturation = $saturation . '%';
|
||||
$css = '
|
||||
/**
|
||||
* Twenty Seventeen: Color Patterns
|
||||
*
|
||||
* Colors are ordered from dark to light.
|
||||
*/
|
||||
|
||||
.colors-custom a:hover,
|
||||
.colors-custom a:active,
|
||||
.colors-custom .entry-content a:focus,
|
||||
.colors-custom .entry-content a:hover,
|
||||
.colors-custom .entry-summary a:focus,
|
||||
.colors-custom .entry-summary a:hover,
|
||||
.colors-custom .comment-content a:focus,
|
||||
.colors-custom .comment-content a:hover,
|
||||
.colors-custom .widget a:focus,
|
||||
.colors-custom .widget a:hover,
|
||||
.colors-custom .site-footer .widget-area a:focus,
|
||||
.colors-custom .site-footer .widget-area a:hover,
|
||||
.colors-custom .posts-navigation a:focus,
|
||||
.colors-custom .posts-navigation a:hover,
|
||||
.colors-custom .comment-metadata a:focus,
|
||||
.colors-custom .comment-metadata a:hover,
|
||||
.colors-custom .comment-metadata a.comment-edit-link:focus,
|
||||
.colors-custom .comment-metadata a.comment-edit-link:hover,
|
||||
.colors-custom .comment-reply-link:focus,
|
||||
.colors-custom .comment-reply-link:hover,
|
||||
.colors-custom .widget_authors a:focus strong,
|
||||
.colors-custom .widget_authors a:hover strong,
|
||||
.colors-custom .entry-title a:focus,
|
||||
.colors-custom .entry-title a:hover,
|
||||
.colors-custom .entry-meta a:focus,
|
||||
.colors-custom .entry-meta a:hover,
|
||||
.colors-custom.blog .entry-meta a.post-edit-link:focus,
|
||||
.colors-custom.blog .entry-meta a.post-edit-link:hover,
|
||||
.colors-custom.archive .entry-meta a.post-edit-link:focus,
|
||||
.colors-custom.archive .entry-meta a.post-edit-link:hover,
|
||||
.colors-custom.search .entry-meta a.post-edit-link:focus,
|
||||
.colors-custom.search .entry-meta a.post-edit-link:hover,
|
||||
.colors-custom .page-links a:focus .page-number,
|
||||
.colors-custom .page-links a:hover .page-number,
|
||||
.colors-custom .entry-footer a:focus,
|
||||
.colors-custom .entry-footer a:hover,
|
||||
.colors-custom .entry-footer .cat-links a:focus,
|
||||
.colors-custom .entry-footer .cat-links a:hover,
|
||||
.colors-custom .entry-footer .tags-links a:focus,
|
||||
.colors-custom .entry-footer .tags-links a:hover,
|
||||
.colors-custom .post-navigation a:focus,
|
||||
.colors-custom .post-navigation a:hover,
|
||||
.colors-custom .pagination a:not(.prev):not(.next):focus,
|
||||
.colors-custom .pagination a:not(.prev):not(.next):hover,
|
||||
.colors-custom .comments-pagination a:not(.prev):not(.next):focus,
|
||||
.colors-custom .comments-pagination a:not(.prev):not(.next):hover,
|
||||
.colors-custom .logged-in-as a:focus,
|
||||
.colors-custom .logged-in-as a:hover,
|
||||
.colors-custom a:focus .nav-title,
|
||||
.colors-custom a:hover .nav-title,
|
||||
.colors-custom .edit-link a:focus,
|
||||
.colors-custom .edit-link a:hover,
|
||||
.colors-custom .site-info a:focus,
|
||||
.colors-custom .site-info a:hover,
|
||||
.colors-custom .widget .widget-title a:focus,
|
||||
.colors-custom .widget .widget-title a:hover,
|
||||
.colors-custom .widget ul li a:focus,
|
||||
.colors-custom .widget ul li a:hover {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 0% ); /* base: #000; */
|
||||
}
|
||||
|
||||
.colors-custom .entry-content a,
|
||||
.colors-custom .entry-summary a,
|
||||
.colors-custom .comment-content a,
|
||||
.colors-custom .widget a,
|
||||
.colors-custom .site-footer .widget-area a,
|
||||
.colors-custom .posts-navigation a,
|
||||
.colors-custom .widget_authors a strong {
|
||||
-webkit-box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation . ', 6% ); /* base: rgba(15, 15, 15, 1); */
|
||||
box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation . ', 6% ); /* base: rgba(15, 15, 15, 1); */
|
||||
}
|
||||
|
||||
.colors-custom button,
|
||||
.colors-custom input[type="button"],
|
||||
.colors-custom input[type="submit"],
|
||||
.colors-custom .entry-footer .edit-link a.post-edit-link {
|
||||
background-color: hsl( ' . $hue . ', ' . $saturation . ', 13% ); /* base: #222; */
|
||||
}
|
||||
|
||||
.colors-custom input[type="text"]:focus,
|
||||
.colors-custom input[type="email"]:focus,
|
||||
.colors-custom input[type="url"]:focus,
|
||||
.colors-custom input[type="password"]:focus,
|
||||
.colors-custom input[type="search"]:focus,
|
||||
.colors-custom input[type="number"]:focus,
|
||||
.colors-custom input[type="tel"]:focus,
|
||||
.colors-custom input[type="range"]:focus,
|
||||
.colors-custom input[type="date"]:focus,
|
||||
.colors-custom input[type="month"]:focus,
|
||||
.colors-custom input[type="week"]:focus,
|
||||
.colors-custom input[type="time"]:focus,
|
||||
.colors-custom input[type="datetime"]:focus,
|
||||
.colors-custom .colors-custom input[type="datetime-local"]:focus,
|
||||
.colors-custom input[type="color"]:focus,
|
||||
.colors-custom textarea:focus,
|
||||
.colors-custom button.secondary,
|
||||
.colors-custom input[type="reset"],
|
||||
.colors-custom input[type="button"].secondary,
|
||||
.colors-custom input[type="reset"].secondary,
|
||||
.colors-custom input[type="submit"].secondary,
|
||||
.colors-custom a,
|
||||
.colors-custom .site-title,
|
||||
.colors-custom .site-title a,
|
||||
.colors-custom .navigation-top a,
|
||||
.colors-custom .dropdown-toggle,
|
||||
.colors-custom .menu-toggle,
|
||||
.colors-custom .page .panel-content .entry-title,
|
||||
.colors-custom .page-title,
|
||||
.colors-custom.page:not(.twentyseventeen-front-page) .entry-title,
|
||||
.colors-custom .page-links a .page-number,
|
||||
.colors-custom .comment-metadata a.comment-edit-link,
|
||||
.colors-custom .comment-reply-link .icon,
|
||||
.colors-custom h2.widget-title,
|
||||
.colors-custom mark,
|
||||
.colors-custom .post-navigation a:focus .icon,
|
||||
.colors-custom .post-navigation a:hover .icon,
|
||||
.colors-custom .site-content .site-content-light,
|
||||
.colors-custom .twentyseventeen-panel .recent-posts .entry-header .edit-link {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 13% ); /* base: #222; */
|
||||
}
|
||||
|
||||
.colors-custom .entry-content a:focus,
|
||||
.colors-custom .entry-content a:hover,
|
||||
.colors-custom .entry-summary a:focus,
|
||||
.colors-custom .entry-summary a:hover,
|
||||
.colors-custom .comment-content a:focus,
|
||||
.colors-custom .comment-content a:hover,
|
||||
.colors-custom .widget a:focus,
|
||||
.colors-custom .widget a:hover,
|
||||
.colors-custom .site-footer .widget-area a:focus,
|
||||
.colors-custom .site-footer .widget-area a:hover,
|
||||
.colors-custom .posts-navigation a:focus,
|
||||
.colors-custom .posts-navigation a:hover,
|
||||
.colors-custom .comment-metadata a:focus,
|
||||
.colors-custom .comment-metadata a:hover,
|
||||
.colors-custom .comment-metadata a.comment-edit-link:focus,
|
||||
.colors-custom .comment-metadata a.comment-edit-link:hover,
|
||||
.colors-custom .comment-reply-link:focus,
|
||||
.colors-custom .comment-reply-link:hover,
|
||||
.colors-custom .widget_authors a:focus strong,
|
||||
.colors-custom .widget_authors a:hover strong,
|
||||
.colors-custom .entry-title a:focus,
|
||||
.colors-custom .entry-title a:hover,
|
||||
.colors-custom .entry-meta a:focus,
|
||||
.colors-custom .entry-meta a:hover,
|
||||
.colors-custom.blog .entry-meta a.post-edit-link:focus,
|
||||
.colors-custom.blog .entry-meta a.post-edit-link:hover,
|
||||
.colors-custom.archive .entry-meta a.post-edit-link:focus,
|
||||
.colors-custom.archive .entry-meta a.post-edit-link:hover,
|
||||
.colors-custom.search .entry-meta a.post-edit-link:focus,
|
||||
.colors-custom.search .entry-meta a.post-edit-link:hover,
|
||||
.colors-custom .page-links a:focus .page-number,
|
||||
.colors-custom .page-links a:hover .page-number,
|
||||
.colors-custom .entry-footer .cat-links a:focus,
|
||||
.colors-custom .entry-footer .cat-links a:hover,
|
||||
.colors-custom .entry-footer .tags-links a:focus,
|
||||
.colors-custom .entry-footer .tags-links a:hover,
|
||||
.colors-custom .post-navigation a:focus,
|
||||
.colors-custom .post-navigation a:hover,
|
||||
.colors-custom .pagination a:not(.prev):not(.next):focus,
|
||||
.colors-custom .pagination a:not(.prev):not(.next):hover,
|
||||
.colors-custom .comments-pagination a:not(.prev):not(.next):focus,
|
||||
.colors-custom .comments-pagination a:not(.prev):not(.next):hover,
|
||||
.colors-custom .logged-in-as a:focus,
|
||||
.colors-custom .logged-in-as a:hover,
|
||||
.colors-custom a:focus .nav-title,
|
||||
.colors-custom a:hover .nav-title,
|
||||
.colors-custom .edit-link a:focus,
|
||||
.colors-custom .edit-link a:hover,
|
||||
.colors-custom .site-info a:focus,
|
||||
.colors-custom .site-info a:hover,
|
||||
.colors-custom .widget .widget-title a:focus,
|
||||
.colors-custom .widget .widget-title a:hover,
|
||||
.colors-custom .widget ul li a:focus,
|
||||
.colors-custom .widget ul li a:hover {
|
||||
-webkit-box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation . ', 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
|
||||
box-shadow: inset 0 0 0 hsl( ' . $hue . ', ' . $saturation . ' , 13% ), 0 3px 0 hsl( ' . $hue . ', ' . $saturation . ', 13% );
|
||||
}
|
||||
|
||||
body.colors-custom,
|
||||
.colors-custom button,
|
||||
.colors-custom input,
|
||||
.colors-custom select,
|
||||
.colors-custom textarea,
|
||||
.colors-custom h3,
|
||||
.colors-custom h4,
|
||||
.colors-custom h6,
|
||||
.colors-custom label,
|
||||
.colors-custom .entry-title a,
|
||||
.colors-custom.twentyseventeen-front-page .panel-content .recent-posts article,
|
||||
.colors-custom .entry-footer .cat-links a,
|
||||
.colors-custom .entry-footer .tags-links a,
|
||||
.colors-custom .format-quote blockquote,
|
||||
.colors-custom .nav-title,
|
||||
.colors-custom .comment-body,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-current-item .wp-playlist-item-album {
|
||||
color: hsl( ' . $hue . ', ' . $reduced_saturation . ', 20% ); /* base: #333; */
|
||||
}
|
||||
|
||||
.colors-custom .social-navigation a:hover,
|
||||
.colors-custom .social-navigation a:focus {
|
||||
background: hsl( ' . $hue . ', ' . $reduced_saturation . ', 20% ); /* base: #333; */
|
||||
}
|
||||
|
||||
.colors-custom input[type="text"]:focus,
|
||||
.colors-custom input[type="email"]:focus,
|
||||
.colors-custom input[type="url"]:focus,
|
||||
.colors-custom input[type="password"]:focus,
|
||||
.colors-custom input[type="search"]:focus,
|
||||
.colors-custom input[type="number"]:focus,
|
||||
.colors-custom input[type="tel"]:focus,
|
||||
.colors-custom input[type="range"]:focus,
|
||||
.colors-custom input[type="date"]:focus,
|
||||
.colors-custom input[type="month"]:focus,
|
||||
.colors-custom input[type="week"]:focus,
|
||||
.colors-custom input[type="time"]:focus,
|
||||
.colors-custom input[type="datetime"]:focus,
|
||||
.colors-custom input[type="datetime-local"]:focus,
|
||||
.colors-custom input[type="color"]:focus,
|
||||
.colors-custom textarea:focus,
|
||||
.bypostauthor > .comment-body > .comment-meta > .comment-author .avatar {
|
||||
border-color: hsl( ' . $hue . ', ' . $reduced_saturation . ', 20% ); /* base: #333; */
|
||||
}
|
||||
|
||||
.colors-custom h2,
|
||||
.colors-custom blockquote,
|
||||
.colors-custom input[type="text"],
|
||||
.colors-custom input[type="email"],
|
||||
.colors-custom input[type="url"],
|
||||
.colors-custom input[type="password"],
|
||||
.colors-custom input[type="search"],
|
||||
.colors-custom input[type="number"],
|
||||
.colors-custom input[type="tel"],
|
||||
.colors-custom input[type="range"],
|
||||
.colors-custom input[type="date"],
|
||||
.colors-custom input[type="month"],
|
||||
.colors-custom input[type="week"],
|
||||
.colors-custom input[type="time"],
|
||||
.colors-custom input[type="datetime"],
|
||||
.colors-custom input[type="datetime-local"],
|
||||
.colors-custom input[type="color"],
|
||||
.colors-custom textarea,
|
||||
.colors-custom .site-description,
|
||||
.colors-custom .entry-content blockquote.alignleft,
|
||||
.colors-custom .entry-content blockquote.alignright,
|
||||
.colors-custom .colors-custom .taxonomy-description,
|
||||
.colors-custom .site-info a,
|
||||
.colors-custom .wp-caption,
|
||||
.colors-custom .gallery-caption {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 40% ); /* base: #666; */
|
||||
}
|
||||
|
||||
.colors-custom abbr,
|
||||
.colors-custom acronym {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 40% ); /* base: #666; */
|
||||
}
|
||||
|
||||
.colors-custom h5,
|
||||
.colors-custom .entry-meta,
|
||||
.colors-custom .entry-meta a,
|
||||
.colors-custom.blog .entry-meta a.post-edit-link,
|
||||
.colors-custom.archive .entry-meta a.post-edit-link,
|
||||
.colors-custom.search .entry-meta a.post-edit-link,
|
||||
.colors-custom .nav-subtitle,
|
||||
.colors-custom .comment-metadata,
|
||||
.colors-custom .comment-metadata a,
|
||||
.colors-custom .no-comments,
|
||||
.colors-custom .comment-awaiting-moderation,
|
||||
.colors-custom .page-numbers.current,
|
||||
.colors-custom .page-links .page-number,
|
||||
.colors-custom .navigation-top .current-menu-item > a,
|
||||
.colors-custom .navigation-top .current_page_item > a,
|
||||
.colors-custom .main-navigation a:hover,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-current-item .wp-playlist-item-artist {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 46% ); /* base: #767676; */
|
||||
}
|
||||
|
||||
.colors-custom :not( .mejs-button ) > button:hover,
|
||||
.colors-custom :not( .mejs-button ) > button:focus,
|
||||
.colors-custom input[type="button"]:hover,
|
||||
.colors-custom input[type="button"]:focus,
|
||||
.colors-custom input[type="submit"]:hover,
|
||||
.colors-custom input[type="submit"]:focus,
|
||||
.colors-custom .entry-footer .edit-link a.post-edit-link:hover,
|
||||
.colors-custom .entry-footer .edit-link a.post-edit-link:focus,
|
||||
.colors-custom .social-navigation a,
|
||||
.colors-custom .prev.page-numbers:focus,
|
||||
.colors-custom .prev.page-numbers:hover,
|
||||
.colors-custom .next.page-numbers:focus,
|
||||
.colors-custom .next.page-numbers:hover,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item:hover,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item:focus {
|
||||
background: hsl( ' . esc_attr( $hue ) . ', ' . esc_attr( $saturation ) . ', 46% ); /* base: #767676; */
|
||||
}
|
||||
|
||||
.colors-custom button.secondary:hover,
|
||||
.colors-custom button.secondary:focus,
|
||||
.colors-custom input[type="reset"]:hover,
|
||||
.colors-custom input[type="reset"]:focus,
|
||||
.colors-custom input[type="button"].secondary:hover,
|
||||
.colors-custom input[type="button"].secondary:focus,
|
||||
.colors-custom input[type="reset"].secondary:hover,
|
||||
.colors-custom input[type="reset"].secondary:focus,
|
||||
.colors-custom input[type="submit"].secondary:hover,
|
||||
.colors-custom input[type="submit"].secondary:focus,
|
||||
.colors-custom hr {
|
||||
background: hsl( ' . $hue . ', ' . $saturation . ', 73% ); /* base: #bbb; */
|
||||
}
|
||||
|
||||
.colors-custom input[type="text"],
|
||||
.colors-custom input[type="email"],
|
||||
.colors-custom input[type="url"],
|
||||
.colors-custom input[type="password"],
|
||||
.colors-custom input[type="search"],
|
||||
.colors-custom input[type="number"],
|
||||
.colors-custom input[type="tel"],
|
||||
.colors-custom input[type="range"],
|
||||
.colors-custom input[type="date"],
|
||||
.colors-custom input[type="month"],
|
||||
.colors-custom input[type="week"],
|
||||
.colors-custom input[type="time"],
|
||||
.colors-custom input[type="datetime"],
|
||||
.colors-custom input[type="datetime-local"],
|
||||
.colors-custom input[type="color"],
|
||||
.colors-custom textarea,
|
||||
.colors-custom select,
|
||||
.colors-custom fieldset,
|
||||
.colors-custom .widget .tagcloud a:hover,
|
||||
.colors-custom .widget .tagcloud a:focus,
|
||||
.colors-custom .widget.widget_tag_cloud a:hover,
|
||||
.colors-custom .widget.widget_tag_cloud a:focus,
|
||||
.colors-custom .wp_widget_tag_cloud a:hover,
|
||||
.colors-custom .wp_widget_tag_cloud a:focus {
|
||||
border-color: hsl( ' . $hue . ', ' . $saturation . ', 73% ); /* base: #bbb; */
|
||||
}
|
||||
|
||||
.colors-custom thead th {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 73% ); /* base: #bbb; */
|
||||
}
|
||||
|
||||
.colors-custom .entry-footer .cat-links .icon,
|
||||
.colors-custom .entry-footer .tags-links .icon {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 73% ); /* base: #bbb; */
|
||||
}
|
||||
|
||||
.colors-custom button.secondary,
|
||||
.colors-custom input[type="reset"],
|
||||
.colors-custom input[type="button"].secondary,
|
||||
.colors-custom input[type="reset"].secondary,
|
||||
.colors-custom input[type="submit"].secondary,
|
||||
.colors-custom .prev.page-numbers,
|
||||
.colors-custom .next.page-numbers {
|
||||
background-color: hsl( ' . $hue . ', ' . $saturation . ', 87% ); /* base: #ddd; */
|
||||
}
|
||||
|
||||
.colors-custom .widget .tagcloud a,
|
||||
.colors-custom .widget.widget_tag_cloud a,
|
||||
.colors-custom .wp_widget_tag_cloud a {
|
||||
border-color: hsl( ' . $hue . ', ' . $saturation . ', 87% ); /* base: #ddd; */
|
||||
}
|
||||
|
||||
.colors-custom.twentyseventeen-front-page article:not(.has-post-thumbnail):not(:first-child),
|
||||
.colors-custom .widget ul li {
|
||||
border-top-color: hsl( ' . $hue . ', ' . $saturation . ', 87% ); /* base: #ddd; */
|
||||
}
|
||||
|
||||
.colors-custom .widget ul li {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 87% ); /* base: #ddd; */
|
||||
}
|
||||
|
||||
.colors-custom pre,
|
||||
.colors-custom mark,
|
||||
.colors-custom ins {
|
||||
background: hsl( ' . $hue . ', ' . $saturation . ', 93% ); /* base: #eee; */
|
||||
}
|
||||
|
||||
.colors-custom .navigation-top,
|
||||
.colors-custom .main-navigation > div > ul,
|
||||
.colors-custom .pagination,
|
||||
.colors-custom .comments-pagination,
|
||||
.colors-custom .entry-footer,
|
||||
.colors-custom .site-footer {
|
||||
border-top-color: hsl( ' . $hue . ', ' . $saturation . ', 93% ); /* base: #eee; */
|
||||
}
|
||||
|
||||
.colors-custom .navigation-top,
|
||||
.colors-custom .main-navigation li,
|
||||
.colors-custom .entry-footer,
|
||||
.colors-custom .single-featured-image-header,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item,
|
||||
.colors-custom tr {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 93% ); /* base: #eee; */
|
||||
}
|
||||
|
||||
.colors-custom .site-content .wp-playlist-light {
|
||||
border-color: hsl( ' . $hue . ', ' . $saturation . ', 93% ); /* base: #eee; */
|
||||
}
|
||||
|
||||
.colors-custom .site-header,
|
||||
.colors-custom .single-featured-image-header {
|
||||
background-color: hsl( ' . $hue . ', ' . $saturation . ', 98% ); /* base: #fafafa; */
|
||||
}
|
||||
|
||||
.colors-custom button,
|
||||
.colors-custom input[type="button"],
|
||||
.colors-custom input[type="submit"],
|
||||
.colors-custom .entry-footer .edit-link a.post-edit-link,
|
||||
.colors-custom .social-navigation a,
|
||||
.colors-custom .site-content .wp-playlist-light a.wp-playlist-caption:hover,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item:hover a,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item:focus a,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item:hover,
|
||||
.colors-custom .site-content .wp-playlist-light .wp-playlist-item:focus,
|
||||
.colors-custom .prev.page-numbers:focus,
|
||||
.colors-custom .prev.page-numbers:hover,
|
||||
.colors-custom .next.page-numbers:focus,
|
||||
.colors-custom .next.page-numbers:hover,
|
||||
.colors-custom.has-header-image .site-title,
|
||||
.colors-custom.has-header-video .site-title,
|
||||
.colors-custom.has-header-image .site-title a,
|
||||
.colors-custom.has-header-video .site-title a,
|
||||
.colors-custom.has-header-image .site-description,
|
||||
.colors-custom.has-header-video .site-description {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: #fff; */
|
||||
}
|
||||
|
||||
body.colors-custom,
|
||||
.colors-custom .navigation-top,
|
||||
.colors-custom .main-navigation ul {
|
||||
background: hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: #fff; */
|
||||
}
|
||||
|
||||
.colors-custom .widget ul li a,
|
||||
.colors-custom .site-footer .widget-area ul li a {
|
||||
-webkit-box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: rgba(255, 255, 255, 1); */
|
||||
box-shadow: inset 0 -1px 0 hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: rgba(255, 255, 255, 1); */
|
||||
}
|
||||
|
||||
.colors-custom .menu-toggle,
|
||||
.colors-custom .menu-toggle:hover,
|
||||
.colors-custom .menu-toggle:focus,
|
||||
.colors-custom .menu .dropdown-toggle,
|
||||
.colors-custom .menu-scroll-down,
|
||||
.colors-custom .menu-scroll-down:hover,
|
||||
.colors-custom .menu-scroll-down:focus {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.colors-custom .widget .tagcloud a,
|
||||
.colors-custom .widget .tagcloud a:focus,
|
||||
.colors-custom .widget .tagcloud a:hover,
|
||||
.colors-custom .widget.widget_tag_cloud a,
|
||||
.colors-custom .widget.widget_tag_cloud a:focus,
|
||||
.colors-custom .widget.widget_tag_cloud a:hover,
|
||||
.colors-custom .wp_widget_tag_cloud a,
|
||||
.colors-custom .wp_widget_tag_cloud a:focus,
|
||||
.colors-custom .wp_widget_tag_cloud a:hover,
|
||||
.colors-custom .entry-footer .edit-link a.post-edit-link:focus,
|
||||
.colors-custom .entry-footer .edit-link a.post-edit-link:hover {
|
||||
-webkit-box-shadow: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
/* Reset non-customizable hover styling for links */
|
||||
.colors-custom .entry-content a:hover,
|
||||
.colors-custom .entry-content a:focus,
|
||||
.colors-custom .entry-summary a:hover,
|
||||
.colors-custom .entry-summary a:focus,
|
||||
.colors-custom .comment-content a:focus,
|
||||
.colors-custom .comment-content a:hover,
|
||||
.colors-custom .widget a:hover,
|
||||
.colors-custom .widget a:focus,
|
||||
.colors-custom .site-footer .widget-area a:hover,
|
||||
.colors-custom .site-footer .widget-area a:focus,
|
||||
.colors-custom .posts-navigation a:hover,
|
||||
.colors-custom .posts-navigation a:focus,
|
||||
.colors-custom .widget_authors a:hover strong,
|
||||
.colors-custom .widget_authors a:focus strong {
|
||||
-webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 3px 0 rgba(0, 0, 0, 1);
|
||||
box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 3px 0 rgba(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
.colors-custom .gallery-item a,
|
||||
.colors-custom .gallery-item a:hover,
|
||||
.colors-custom .gallery-item a:focus {
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 48em) {
|
||||
|
||||
.colors-custom .nav-links .nav-previous .nav-title .icon,
|
||||
.colors-custom .nav-links .nav-next .nav-title .icon {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 20% ); /* base: #222; */
|
||||
}
|
||||
|
||||
.colors-custom .main-navigation li li:hover,
|
||||
.colors-custom .main-navigation li li.focus {
|
||||
background: hsl( ' . $hue . ', ' . $saturation . ', 46% ); /* base: #767676; */
|
||||
}
|
||||
|
||||
.colors-custom .navigation-top .menu-scroll-down {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 46% ); /* base: #767676; */;
|
||||
}
|
||||
|
||||
.colors-custom abbr[title] {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 46% ); /* base: #767676; */;
|
||||
}
|
||||
|
||||
.colors-custom .main-navigation ul ul {
|
||||
border-color: hsl( ' . $hue . ', ' . $saturation . ', 73% ); /* base: #bbb; */
|
||||
background: hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: #fff; */
|
||||
}
|
||||
|
||||
.colors-custom .main-navigation ul li.menu-item-has-children:before,
|
||||
.colors-custom .main-navigation ul li.page_item_has_children:before {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 73% ); /* base: #bbb; */
|
||||
}
|
||||
|
||||
.colors-custom .main-navigation ul li.menu-item-has-children:after,
|
||||
.colors-custom .main-navigation ul li.page_item_has_children:after {
|
||||
border-bottom-color: hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: #fff; */
|
||||
}
|
||||
|
||||
.colors-custom .main-navigation li li.focus > a,
|
||||
.colors-custom .main-navigation li li:focus > a,
|
||||
.colors-custom .main-navigation li li:hover > a,
|
||||
.colors-custom .main-navigation li li a:hover,
|
||||
.colors-custom .main-navigation li li a:focus,
|
||||
.colors-custom .main-navigation li li.current_page_item a:hover,
|
||||
.colors-custom .main-navigation li li.current-menu-item a:hover,
|
||||
.colors-custom .main-navigation li li.current_page_item a:focus,
|
||||
.colors-custom .main-navigation li li.current-menu-item a:focus {
|
||||
color: hsl( ' . $hue . ', ' . $saturation . ', 100% ); /* base: #fff; */
|
||||
}
|
||||
}';
|
||||
|
||||
/**
|
||||
* Filters Twenty Seventeen custom colors CSS.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @param string $css Base theme colors CSS.
|
||||
* @param int $hue The user's selected color hue.
|
||||
* @param string $saturation Filtered theme color saturation level.
|
||||
*/
|
||||
return apply_filters( 'twentyseventeen_custom_colors_css', $css, $hue, $saturation );
|
||||
}
|
||||
131
wp-content/themes/twentyseventeen/inc/custom-header.php
Normal file
131
wp-content/themes/twentyseventeen/inc/custom-header.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom header implementation
|
||||
*
|
||||
* @link https://codex.wordpress.org/Custom_Headers
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set up the WordPress core custom header feature.
|
||||
*
|
||||
* @uses twentyseventeen_header_style()
|
||||
*/
|
||||
function twentyseventeen_custom_header_setup() {
|
||||
|
||||
/**
|
||||
* Filter Twenty Seventeen custom-header support arguments.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @param array $args {
|
||||
* An array of custom-header support arguments.
|
||||
*
|
||||
* @type string $default-image Default image of the header.
|
||||
* @type int $width Width in pixels of the custom header image. Default 954.
|
||||
* @type int $height Height in pixels of the custom header image. Default 1300.
|
||||
* @type string $flex-height Flex support for height of header.
|
||||
* @type string $video Video support for header.
|
||||
* @type string $wp-head-callback Callback function used to styles the header image and text
|
||||
* displayed on the blog.
|
||||
* }
|
||||
*/
|
||||
add_theme_support(
|
||||
'custom-header',
|
||||
apply_filters(
|
||||
'twentyseventeen_custom_header_args',
|
||||
array(
|
||||
'default-image' => get_parent_theme_file_uri( '/assets/images/header.jpg' ),
|
||||
'width' => 2000,
|
||||
'height' => 1200,
|
||||
'flex-height' => true,
|
||||
'video' => true,
|
||||
'wp-head-callback' => 'twentyseventeen_header_style',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
register_default_headers(
|
||||
array(
|
||||
'default-image' => array(
|
||||
'url' => '%s/assets/images/header.jpg',
|
||||
'thumbnail_url' => '%s/assets/images/header.jpg',
|
||||
'description' => __( 'Default Header Image', 'twentyseventeen' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'after_setup_theme', 'twentyseventeen_custom_header_setup' );
|
||||
|
||||
if ( ! function_exists( 'twentyseventeen_header_style' ) ) :
|
||||
/**
|
||||
* Styles the header image and text displayed on the blog.
|
||||
*
|
||||
* @see twentyseventeen_custom_header_setup().
|
||||
*/
|
||||
function twentyseventeen_header_style() {
|
||||
$header_text_color = get_header_textcolor();
|
||||
|
||||
// If no custom options for text are set, let's bail.
|
||||
// get_header_textcolor() options: add_theme_support( 'custom-header' ) is default, hide text (returns 'blank') or any hex value.
|
||||
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get this far, we have custom styles. Let's do this.
|
||||
?>
|
||||
<style id="twentyseventeen-custom-header-styles" type="text/css">
|
||||
<?php
|
||||
// Has the text been hidden?
|
||||
if ( 'blank' === $header_text_color ) :
|
||||
?>
|
||||
.site-title,
|
||||
.site-description {
|
||||
position: absolute;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
}
|
||||
<?php
|
||||
// If the user has set a custom color for the text use that.
|
||||
else :
|
||||
?>
|
||||
.site-title a,
|
||||
.colors-dark .site-title a,
|
||||
.colors-custom .site-title a,
|
||||
body.has-header-image .site-title a,
|
||||
body.has-header-video .site-title a,
|
||||
body.has-header-image.colors-dark .site-title a,
|
||||
body.has-header-video.colors-dark .site-title a,
|
||||
body.has-header-image.colors-custom .site-title a,
|
||||
body.has-header-video.colors-custom .site-title a,
|
||||
.site-description,
|
||||
.colors-dark .site-description,
|
||||
.colors-custom .site-description,
|
||||
body.has-header-image .site-description,
|
||||
body.has-header-video .site-description,
|
||||
body.has-header-image.colors-dark .site-description,
|
||||
body.has-header-video.colors-dark .site-description,
|
||||
body.has-header-image.colors-custom .site-description,
|
||||
body.has-header-video.colors-custom .site-description {
|
||||
color: #<?php echo esc_attr( $header_text_color ); ?>;
|
||||
}
|
||||
<?php endif; ?>
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
endif; // End of twentyseventeen_header_style().
|
||||
|
||||
/**
|
||||
* Customize video play/pause button in the custom header.
|
||||
*
|
||||
* @param array $settings Video settings.
|
||||
* @return array The filtered video settings.
|
||||
*/
|
||||
function twentyseventeen_video_controls( $settings ) {
|
||||
$settings['l10n']['play'] = '<span class="screen-reader-text">' . __( 'Play background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'play' ) );
|
||||
$settings['l10n']['pause'] = '<span class="screen-reader-text">' . __( 'Pause background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'pause' ) );
|
||||
return $settings;
|
||||
}
|
||||
add_filter( 'header_video_settings', 'twentyseventeen_video_controls' );
|
||||
249
wp-content/themes/twentyseventeen/inc/customizer.php
Normal file
249
wp-content/themes/twentyseventeen/inc/customizer.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
/**
|
||||
* Twenty Seventeen: Customizer
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add postMessage support for site title and description for the Theme Customizer.
|
||||
*
|
||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||
*/
|
||||
function twentyseventeen_customize_register( $wp_customize ) {
|
||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'blogname',
|
||||
array(
|
||||
'selector' => '.site-title a',
|
||||
'render_callback' => 'twentyseventeen_customize_partial_blogname',
|
||||
)
|
||||
);
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'blogdescription',
|
||||
array(
|
||||
'selector' => '.site-description',
|
||||
'render_callback' => 'twentyseventeen_customize_partial_blogdescription',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Custom colors.
|
||||
*/
|
||||
$wp_customize->add_setting(
|
||||
'colorscheme',
|
||||
array(
|
||||
'default' => 'light',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'twentyseventeen_sanitize_colorscheme',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'colorscheme_hue',
|
||||
array(
|
||||
'default' => 250,
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint', // The hue is stored as a positive integer.
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'colorscheme',
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => __( 'Color Scheme', 'twentyseventeen' ),
|
||||
'choices' => array(
|
||||
'light' => __( 'Light', 'twentyseventeen' ),
|
||||
'dark' => __( 'Dark', 'twentyseventeen' ),
|
||||
'custom' => __( 'Custom', 'twentyseventeen' ),
|
||||
),
|
||||
'section' => 'colors',
|
||||
'priority' => 5,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'colorscheme_hue',
|
||||
array(
|
||||
'mode' => 'hue',
|
||||
'section' => 'colors',
|
||||
'priority' => 6,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Theme options.
|
||||
*/
|
||||
$wp_customize->add_section(
|
||||
'theme_options',
|
||||
array(
|
||||
'title' => __( 'Theme Options', 'twentyseventeen' ),
|
||||
'priority' => 130, // Before Additional CSS.
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'page_layout',
|
||||
array(
|
||||
'default' => 'two-column',
|
||||
'sanitize_callback' => 'twentyseventeen_sanitize_page_layout',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'page_layout',
|
||||
array(
|
||||
'label' => __( 'Page Layout', 'twentyseventeen' ),
|
||||
'section' => 'theme_options',
|
||||
'type' => 'radio',
|
||||
'description' => __( 'When the two-column layout is assigned, the page title is in one column and content is in the other.', 'twentyseventeen' ),
|
||||
'choices' => array(
|
||||
'one-column' => __( 'One Column', 'twentyseventeen' ),
|
||||
'two-column' => __( 'Two Column', 'twentyseventeen' ),
|
||||
),
|
||||
'active_callback' => 'twentyseventeen_is_view_with_layout_option',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter number of front page sections in Twenty Seventeen.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @param int $num_sections Number of front page sections.
|
||||
*/
|
||||
$num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 );
|
||||
|
||||
// Create a setting and control for each of the sections available in the theme.
|
||||
for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
|
||||
$wp_customize->add_setting(
|
||||
'panel_' . $i,
|
||||
array(
|
||||
'default' => false,
|
||||
'sanitize_callback' => 'absint',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'panel_' . $i,
|
||||
array(
|
||||
/* translators: %d: The front page section number. */
|
||||
'label' => sprintf( __( 'Front Page Section %d Content', 'twentyseventeen' ), $i ),
|
||||
'description' => ( 1 !== $i ? '' : __( 'Select pages to feature in each area from the dropdowns. Add an image to a section by setting a featured image in the page editor. Empty sections will not be displayed.', 'twentyseventeen' ) ),
|
||||
'section' => 'theme_options',
|
||||
'type' => 'dropdown-pages',
|
||||
'allow_addition' => true,
|
||||
'active_callback' => 'twentyseventeen_is_static_front_page',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'panel_' . $i,
|
||||
array(
|
||||
'selector' => '#panel' . $i,
|
||||
'render_callback' => 'twentyseventeen_front_page_section',
|
||||
'container_inclusive' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
add_action( 'customize_register', 'twentyseventeen_customize_register' );
|
||||
|
||||
/**
|
||||
* Sanitize the page layout options.
|
||||
*
|
||||
* @param string $input Page layout.
|
||||
*/
|
||||
function twentyseventeen_sanitize_page_layout( $input ) {
|
||||
$valid = array(
|
||||
'one-column' => __( 'One Column', 'twentyseventeen' ),
|
||||
'two-column' => __( 'Two Column', 'twentyseventeen' ),
|
||||
);
|
||||
|
||||
if ( array_key_exists( $input, $valid ) ) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize the colorscheme.
|
||||
*
|
||||
* @param string $input Color scheme.
|
||||
*/
|
||||
function twentyseventeen_sanitize_colorscheme( $input ) {
|
||||
$valid = array( 'light', 'dark', 'custom' );
|
||||
|
||||
if ( in_array( $input, $valid, true ) ) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
return 'light';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the site title for the selective refresh partial.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
* @see twentyseventeen_customize_register()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function twentyseventeen_customize_partial_blogname() {
|
||||
bloginfo( 'name' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the site tagline for the selective refresh partial.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
* @see twentyseventeen_customize_register()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function twentyseventeen_customize_partial_blogdescription() {
|
||||
bloginfo( 'description' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether we're previewing the front page and it's a static page.
|
||||
*/
|
||||
function twentyseventeen_is_static_front_page() {
|
||||
return ( is_front_page() && ! is_home() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether we're on a view that supports a one or two column layout.
|
||||
*/
|
||||
function twentyseventeen_is_view_with_layout_option() {
|
||||
// This option is available on all pages. It's also available on archives when there isn't a sidebar.
|
||||
return ( is_page() || ( is_archive() && ! is_active_sidebar( 'sidebar-1' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind JS handlers to instantly live-preview changes.
|
||||
*/
|
||||
function twentyseventeen_customize_preview_js() {
|
||||
wp_enqueue_script( 'twentyseventeen-customize-preview', get_theme_file_uri( '/assets/js/customize-preview.js' ), array( 'customize-preview' ), '20161002', true );
|
||||
}
|
||||
add_action( 'customize_preview_init', 'twentyseventeen_customize_preview_js' );
|
||||
|
||||
/**
|
||||
* Load dynamic logic for the customizer controls area.
|
||||
*/
|
||||
function twentyseventeen_panels_js() {
|
||||
wp_enqueue_script( 'twentyseventeen-customize-controls', get_theme_file_uri( '/assets/js/customize-controls.js' ), array(), '20161020', true );
|
||||
}
|
||||
add_action( 'customize_controls_enqueue_scripts', 'twentyseventeen_panels_js' );
|
||||
220
wp-content/themes/twentyseventeen/inc/icon-functions.php
Normal file
220
wp-content/themes/twentyseventeen/inc/icon-functions.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/**
|
||||
* SVG icons related functions and filters
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add SVG definitions to the footer.
|
||||
*/
|
||||
function twentyseventeen_include_svg_icons() {
|
||||
// Define SVG sprite file.
|
||||
$svg_icons = get_parent_theme_file_path( '/assets/images/svg-icons.svg' );
|
||||
|
||||
// If it exists, include it.
|
||||
if ( file_exists( $svg_icons ) ) {
|
||||
require_once $svg_icons;
|
||||
}
|
||||
}
|
||||
add_action( 'wp_footer', 'twentyseventeen_include_svg_icons', 9999 );
|
||||
|
||||
/**
|
||||
* Return SVG markup.
|
||||
*
|
||||
* @param array $args {
|
||||
* Parameters needed to display an SVG.
|
||||
*
|
||||
* @type string $icon Required SVG icon filename.
|
||||
* @type string $title Optional SVG title.
|
||||
* @type string $desc Optional SVG description.
|
||||
* }
|
||||
* @return string SVG markup.
|
||||
*/
|
||||
function twentyseventeen_get_svg( $args = array() ) {
|
||||
// Make sure $args are an array.
|
||||
if ( empty( $args ) ) {
|
||||
return __( 'Please define default parameters in the form of an array.', 'twentyseventeen' );
|
||||
}
|
||||
|
||||
// Define an icon.
|
||||
if ( false === array_key_exists( 'icon', $args ) ) {
|
||||
return __( 'Please define an SVG icon filename.', 'twentyseventeen' );
|
||||
}
|
||||
|
||||
// Set defaults.
|
||||
$defaults = array(
|
||||
'icon' => '',
|
||||
'title' => '',
|
||||
'desc' => '',
|
||||
'fallback' => false,
|
||||
);
|
||||
|
||||
// Parse args.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
// Set aria hidden.
|
||||
$aria_hidden = ' aria-hidden="true"';
|
||||
|
||||
// Set ARIA.
|
||||
$aria_labelledby = '';
|
||||
|
||||
/*
|
||||
* Twenty Seventeen doesn't use the SVG title or description attributes; non-decorative icons are described with .screen-reader-text.
|
||||
*
|
||||
* However, child themes can use the title and description to add information to non-decorative SVG icons to improve accessibility.
|
||||
*
|
||||
* Example 1 with title: <?php echo twentyseventeen_get_svg( array( 'icon' => 'arrow-right', 'title' => __( 'This is the title', 'textdomain' ) ) ); ?>
|
||||
*
|
||||
* Example 2 with title and description: <?php echo twentyseventeen_get_svg( array( 'icon' => 'arrow-right', 'title' => __( 'This is the title', 'textdomain' ), 'desc' => __( 'This is the description', 'textdomain' ) ) ); ?>
|
||||
*
|
||||
* See https://www.paciellogroup.com/blog/2013/12/using-aria-enhance-svg-accessibility/.
|
||||
*/
|
||||
if ( $args['title'] ) {
|
||||
$aria_hidden = '';
|
||||
$unique_id = twentyseventeen_unique_id();
|
||||
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . '"';
|
||||
|
||||
if ( $args['desc'] ) {
|
||||
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"';
|
||||
}
|
||||
}
|
||||
|
||||
// Begin SVG markup.
|
||||
$svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . $aria_labelledby . ' role="img">';
|
||||
|
||||
// Display the title.
|
||||
if ( $args['title'] ) {
|
||||
$svg .= '<title id="title-' . $unique_id . '">' . esc_html( $args['title'] ) . '</title>';
|
||||
|
||||
// Display the desc only if the title is already set.
|
||||
if ( $args['desc'] ) {
|
||||
$svg .= '<desc id="desc-' . $unique_id . '">' . esc_html( $args['desc'] ) . '</desc>';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the icon.
|
||||
*
|
||||
* The whitespace around `<use>` is intentional - it is a work around to a keyboard navigation bug in Safari 10.
|
||||
*
|
||||
* See https://core.trac.wordpress.org/ticket/38387.
|
||||
*/
|
||||
$svg .= ' <use href="#icon-' . esc_html( $args['icon'] ) . '" xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use> ';
|
||||
|
||||
// Add some markup to use as a fallback for browsers that do not support SVGs.
|
||||
if ( $args['fallback'] ) {
|
||||
$svg .= '<span class="svg-fallback icon-' . esc_attr( $args['icon'] ) . '"></span>';
|
||||
}
|
||||
|
||||
$svg .= '</svg>';
|
||||
|
||||
return $svg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display SVG icons in social links menu.
|
||||
*
|
||||
* @param string $item_output The menu item output.
|
||||
* @param WP_Post $item Menu item object.
|
||||
* @param int $depth Depth of the menu.
|
||||
* @param array $args wp_nav_menu() arguments.
|
||||
* @return string $item_output The menu item output with social icon.
|
||||
*/
|
||||
function twentyseventeen_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
|
||||
// Get supported social icons.
|
||||
$social_icons = twentyseventeen_social_links_icons();
|
||||
|
||||
// Change SVG icon inside social links menu if there is supported URL.
|
||||
if ( 'social' === $args->theme_location ) {
|
||||
foreach ( $social_icons as $attr => $value ) {
|
||||
if ( false !== strpos( $item_output, $attr ) ) {
|
||||
$item_output = str_replace( $args->link_after, '</span>' . twentyseventeen_get_svg( array( 'icon' => esc_attr( $value ) ) ), $item_output );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $item_output;
|
||||
}
|
||||
add_filter( 'walker_nav_menu_start_el', 'twentyseventeen_nav_menu_social_icons', 10, 4 );
|
||||
|
||||
/**
|
||||
* Add dropdown icon if menu item has children.
|
||||
*
|
||||
* @param string $title The menu item's title.
|
||||
* @param WP_Post $item The current menu item.
|
||||
* @param array $args An array of wp_nav_menu() arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @return string $title The menu item's title with dropdown icon.
|
||||
*/
|
||||
function twentyseventeen_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
|
||||
if ( 'top' === $args->theme_location ) {
|
||||
foreach ( $item->classes as $value ) {
|
||||
if ( 'menu-item-has-children' === $value || 'page_item_has_children' === $value ) {
|
||||
$title = $title . twentyseventeen_get_svg( array( 'icon' => 'angle-down' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
add_filter( 'nav_menu_item_title', 'twentyseventeen_dropdown_icon_to_menu_link', 10, 4 );
|
||||
|
||||
/**
|
||||
* Returns an array of supported social links (URL and icon name).
|
||||
*
|
||||
* @return array $social_links_icons
|
||||
*/
|
||||
function twentyseventeen_social_links_icons() {
|
||||
// Supported social links icons.
|
||||
$social_links_icons = array(
|
||||
'behance.net' => 'behance',
|
||||
'codepen.io' => 'codepen',
|
||||
'deviantart.com' => 'deviantart',
|
||||
'digg.com' => 'digg',
|
||||
'docker.com' => 'dockerhub',
|
||||
'dribbble.com' => 'dribbble',
|
||||
'dropbox.com' => 'dropbox',
|
||||
'facebook.com' => 'facebook',
|
||||
'flickr.com' => 'flickr',
|
||||
'foursquare.com' => 'foursquare',
|
||||
'plus.google.com' => 'google-plus',
|
||||
'github.com' => 'github',
|
||||
'instagram.com' => 'instagram',
|
||||
'linkedin.com' => 'linkedin',
|
||||
'mailto:' => 'envelope-o',
|
||||
'medium.com' => 'medium',
|
||||
'pinterest.com' => 'pinterest-p',
|
||||
'pscp.tv' => 'periscope',
|
||||
'getpocket.com' => 'get-pocket',
|
||||
'reddit.com' => 'reddit-alien',
|
||||
'skype.com' => 'skype',
|
||||
'skype:' => 'skype',
|
||||
'slideshare.net' => 'slideshare',
|
||||
'snapchat.com' => 'snapchat-ghost',
|
||||
'soundcloud.com' => 'soundcloud',
|
||||
'spotify.com' => 'spotify',
|
||||
'stumbleupon.com' => 'stumbleupon',
|
||||
'tumblr.com' => 'tumblr',
|
||||
'twitch.tv' => 'twitch',
|
||||
'twitter.com' => 'twitter',
|
||||
'vimeo.com' => 'vimeo',
|
||||
'vine.co' => 'vine',
|
||||
'vk.com' => 'vk',
|
||||
'wordpress.org' => 'wordpress',
|
||||
'wordpress.com' => 'wordpress',
|
||||
'yelp.com' => 'yelp',
|
||||
'youtube.com' => 'youtube',
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter Twenty Seventeen social links icons.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @param array $social_links_icons Array of social links icons.
|
||||
*/
|
||||
return apply_filters( 'twentyseventeen_social_links_icons', $social_links_icons );
|
||||
}
|
||||
102
wp-content/themes/twentyseventeen/inc/template-functions.php
Normal file
102
wp-content/themes/twentyseventeen/inc/template-functions.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Additional features to allow styling of the templates
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds custom classes to the array of body classes.
|
||||
*
|
||||
* @param array $classes Classes for the body element.
|
||||
* @return array
|
||||
*/
|
||||
function twentyseventeen_body_classes( $classes ) {
|
||||
// Add class of group-blog to blogs with more than 1 published author.
|
||||
if ( is_multi_author() ) {
|
||||
$classes[] = 'group-blog';
|
||||
}
|
||||
|
||||
// Add class of hfeed to non-singular pages.
|
||||
if ( ! is_singular() ) {
|
||||
$classes[] = 'hfeed';
|
||||
}
|
||||
|
||||
// Add class if we're viewing the Customizer for easier styling of theme options.
|
||||
if ( is_customize_preview() ) {
|
||||
$classes[] = 'twentyseventeen-customizer';
|
||||
}
|
||||
|
||||
// Add class on front page.
|
||||
if ( is_front_page() && 'posts' !== get_option( 'show_on_front' ) ) {
|
||||
$classes[] = 'twentyseventeen-front-page';
|
||||
}
|
||||
|
||||
// Add a class if there is a custom header.
|
||||
if ( has_header_image() ) {
|
||||
$classes[] = 'has-header-image';
|
||||
}
|
||||
|
||||
// Add class if sidebar is used.
|
||||
if ( is_active_sidebar( 'sidebar-1' ) && ! is_page() ) {
|
||||
$classes[] = 'has-sidebar';
|
||||
}
|
||||
|
||||
// Add class for one or two column page layouts.
|
||||
if ( is_page() || is_archive() ) {
|
||||
if ( 'one-column' === get_theme_mod( 'page_layout' ) ) {
|
||||
$classes[] = 'page-one-column';
|
||||
} else {
|
||||
$classes[] = 'page-two-column';
|
||||
}
|
||||
}
|
||||
|
||||
// Add class if the site title and tagline is hidden.
|
||||
if ( 'blank' === get_header_textcolor() ) {
|
||||
$classes[] = 'title-tagline-hidden';
|
||||
}
|
||||
|
||||
// Get the colorscheme or the default if there isn't one.
|
||||
$colors = twentyseventeen_sanitize_colorscheme( get_theme_mod( 'colorscheme', 'light' ) );
|
||||
$classes[] = 'colors-' . $colors;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
add_filter( 'body_class', 'twentyseventeen_body_classes' );
|
||||
|
||||
/**
|
||||
* Count our number of active panels.
|
||||
*
|
||||
* Primarily used to see if we have any panels active, duh.
|
||||
*/
|
||||
function twentyseventeen_panel_count() {
|
||||
|
||||
$panel_count = 0;
|
||||
|
||||
/**
|
||||
* Filter number of front page sections in Twenty Seventeen.
|
||||
*
|
||||
* @since Twenty Seventeen 1.0
|
||||
*
|
||||
* @param int $num_sections Number of front page sections.
|
||||
*/
|
||||
$num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 );
|
||||
|
||||
// Create a setting and control for each of the sections available in the theme.
|
||||
for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
|
||||
if ( get_theme_mod( 'panel_' . $i ) ) {
|
||||
$panel_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return $panel_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if we're on the front page or not.
|
||||
*/
|
||||
function twentyseventeen_is_frontpage() {
|
||||
return ( is_front_page() && ! is_home() );
|
||||
}
|
||||
226
wp-content/themes/twentyseventeen/inc/template-tags.php
Normal file
226
wp-content/themes/twentyseventeen/inc/template-tags.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom template tags for this theme
|
||||
*
|
||||
* Eventually, some of the functionality here could be replaced by core features.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Twenty_Seventeen
|
||||
* @since Twenty Seventeen 1.0
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'twentyseventeen_posted_on' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time and author.
|
||||
*/
|
||||
function twentyseventeen_posted_on() {
|
||||
|
||||
// Get the author name; wrap it in a link.
|
||||
$byline = sprintf(
|
||||
/* translators: %s: Post author. */
|
||||
__( 'by %s', 'twentyseventeen' ),
|
||||
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . get_the_author() . '</a></span>'
|
||||
);
|
||||
|
||||
// Finally, let's write all of this to the page.
|
||||
echo '<span class="posted-on">' . twentyseventeen_time_link() . '</span><span class="byline"> ' . $byline . '</span>';
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
if ( ! function_exists( 'twentyseventeen_time_link' ) ) :
|
||||
/**
|
||||
* Gets a nicely formatted string for the published date.
|
||||
*/
|
||||
function twentyseventeen_time_link() {
|
||||
$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 class="updated" datetime="%3$s">%4$s</time>';
|
||||
}
|
||||
|
||||
$time_string = sprintf(
|
||||
$time_string,
|
||||
get_the_date( DATE_W3C ),
|
||||
get_the_date(),
|
||||
get_the_modified_date( DATE_W3C ),
|
||||
get_the_modified_date()
|
||||
);
|
||||
|
||||
// Wrap the time string in a link, and preface it with 'Posted on'.
|
||||
return sprintf(
|
||||
/* translators: %s: Post date. */
|
||||
__( '<span class="screen-reader-text">Posted on</span> %s', 'twentyseventeen' ),
|
||||
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
|
||||
);
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the categories, tags and comments.
|
||||
*/
|
||||
function twentyseventeen_entry_footer() {
|
||||
|
||||
/* translators: Used between list items, there is a space after the comma. */
|
||||
$separate_meta = __( ', ', 'twentyseventeen' );
|
||||
|
||||
// Get Categories for posts.
|
||||
$categories_list = get_the_category_list( $separate_meta );
|
||||
|
||||
// Get Tags for posts.
|
||||
$tags_list = get_the_tag_list( '', $separate_meta );
|
||||
|
||||
// We don't want to output .entry-footer if it will be empty, so make sure its not.
|
||||
if ( ( ( twentyseventeen_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) {
|
||||
|
||||
echo '<footer class="entry-footer">';
|
||||
|
||||
if ( 'post' === get_post_type() ) {
|
||||
if ( ( $categories_list && twentyseventeen_categorized_blog() ) || $tags_list ) {
|
||||
echo '<span class="cat-tags-links">';
|
||||
|
||||
// Make sure there's more than one category before displaying.
|
||||
if ( $categories_list && twentyseventeen_categorized_blog() ) {
|
||||
echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
|
||||
}
|
||||
|
||||
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
|
||||
echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
|
||||
}
|
||||
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
twentyseventeen_edit_link();
|
||||
|
||||
echo '</footer> <!-- .entry-footer -->';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
if ( ! function_exists( 'twentyseventeen_edit_link' ) ) :
|
||||
/**
|
||||
* Returns an accessibility-friendly link to edit a post or page.
|
||||
*
|
||||
* This also gives us a little context about what exactly we're editing
|
||||
* (post or page?) so that users understand a bit more where they are in terms
|
||||
* of the template hierarchy and their content. Helpful when/if the single-page
|
||||
* layout with multiple posts/pages shown gets confusing.
|
||||
*/
|
||||
function twentyseventeen_edit_link() {
|
||||
edit_post_link(
|
||||
sprintf(
|
||||
/* translators: %s: Post title. */
|
||||
__( 'Edit<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
|
||||
get_the_title()
|
||||
),
|
||||
'<span class="edit-link">',
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Display a front page section.
|
||||
*
|
||||
* @param WP_Customize_Partial $partial Partial associated with a selective refresh request.
|
||||
* @param integer $id Front page section to display.
|
||||
*/
|
||||
function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
|
||||
if ( is_a( $partial, 'WP_Customize_Partial' ) ) {
|
||||
// Find out the id and set it up during a selective refresh.
|
||||
global $twentyseventeencounter;
|
||||
|
||||
$id = str_replace( 'panel_', '', $partial->id );
|
||||
|
||||
$twentyseventeencounter = $id;
|
||||
}
|
||||
|
||||
global $post; // Modify the global post object before setting up post data.
|
||||
if ( get_theme_mod( 'panel_' . $id ) ) {
|
||||
$post = get_post( get_theme_mod( 'panel_' . $id ) );
|
||||
setup_postdata( $post );
|
||||
set_query_var( 'panel', $id );
|
||||
|
||||
get_template_part( 'template-parts/page/content', 'front-page-panels' );
|
||||
|
||||
wp_reset_postdata();
|
||||
} elseif ( is_customize_preview() ) {
|
||||
// The output placeholder anchor.
|
||||
printf(
|
||||
'<article class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel%1$s" id="panel%1$s">' .
|
||||
'<span class="twentyseventeen-panel-title">%2$s</span></article>',
|
||||
$id,
|
||||
/* translators: %s: The section ID. */
|
||||
sprintf( __( 'Front Page Section %s Placeholder', 'twentyseventeen' ), $id )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a blog has more than 1 category.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function twentyseventeen_categorized_blog() {
|
||||
$category_count = get_transient( 'twentyseventeen_categories' );
|
||||
|
||||
if ( false === $category_count ) {
|
||||
// Create an array of all the categories that are attached to posts.
|
||||
$categories = get_categories(
|
||||
array(
|
||||
'fields' => 'ids',
|
||||
'hide_empty' => 1,
|
||||
// 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.
|
||||
$category_count = count( $categories );
|
||||
|
||||
set_transient( 'twentyseventeen_categories', $category_count );
|
||||
}
|
||||
|
||||
// Allow viewing case of 0 or 1 categories in post preview.
|
||||
if ( is_preview() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $category_count > 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush out the transients used in twentyseventeen_categorized_blog.
|
||||
*/
|
||||
function twentyseventeen_category_transient_flusher() {
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
// Like, beat it. Dig?
|
||||
delete_transient( 'twentyseventeen_categories' );
|
||||
}
|
||||
add_action( 'edit_category', 'twentyseventeen_category_transient_flusher' );
|
||||
add_action( 'save_post', 'twentyseventeen_category_transient_flusher' );
|
||||
|
||||
if ( ! function_exists( 'wp_body_open' ) ) :
|
||||
/**
|
||||
* Fire the wp_body_open action.
|
||||
*
|
||||
* Added for backward compatibility to support pre-5.2.0 WordPress versions.
|
||||
*
|
||||
* @since Twenty Seventeen 2.2
|
||||
*/
|
||||
function wp_body_open() {
|
||||
/**
|
||||
* Triggered after the opening <body> tag.
|
||||
*
|
||||
* @since Twenty Seventeen 2.2
|
||||
*/
|
||||
do_action( 'wp_body_open' );
|
||||
}
|
||||
endif;
|
||||
Reference in New Issue
Block a user