updated theme `Twenty Seventeen` version 2.4

This commit is contained in:
KawaiiPunk 2020-08-13 14:53:57 +00:00 committed by Gitium
parent f1c4277fcd
commit b3cd4e0a59
23 changed files with 2471 additions and 1529 deletions

View File

@ -130,6 +130,13 @@
<symbol id="icon-reddit-alien" viewBox="0 0 32 32">
<path class="path1" d="M32 15.107q0 1.036-0.527 1.884t-1.42 1.295q0.214 0.821 0.214 1.714 0 2.768-1.902 5.125t-5.188 3.723-7.143 1.366-7.134-1.366-5.179-3.723-1.902-5.125q0-0.839 0.196-1.679-0.911-0.446-1.464-1.313t-0.554-1.902q0-1.464 1.036-2.509t2.518-1.045q1.518 0 2.589 1.125 3.893-2.714 9.196-2.893l2.071-9.304q0.054-0.232 0.268-0.375t0.464-0.089l6.589 1.446q0.321-0.661 0.964-1.063t1.411-0.402q1.107 0 1.893 0.777t0.786 1.884-0.786 1.893-1.893 0.786-1.884-0.777-0.777-1.884l-5.964-1.321-1.857 8.429q5.357 0.161 9.268 2.857 1.036-1.089 2.554-1.089 1.482 0 2.518 1.045t1.036 2.509zM7.464 18.661q0 1.107 0.777 1.893t1.884 0.786 1.893-0.786 0.786-1.893-0.786-1.884-1.893-0.777q-1.089 0-1.875 0.786t-0.786 1.875zM21.929 25q0.196-0.196 0.196-0.464t-0.196-0.464q-0.179-0.179-0.446-0.179t-0.464 0.179q-0.732 0.75-2.161 1.107t-2.857 0.357-2.857-0.357-2.161-1.107q-0.196-0.179-0.464-0.179t-0.446 0.179q-0.196 0.179-0.196 0.455t0.196 0.473q0.768 0.768 2.116 1.214t2.188 0.527 1.625 0.080 1.625-0.080 2.188-0.527 2.116-1.214zM21.875 21.339q1.107 0 1.884-0.786t0.777-1.893q0-1.089-0.786-1.875t-1.875-0.786q-1.107 0-1.893 0.777t-0.786 1.884 0.786 1.893 1.893 0.786z"></path>
</symbol>
<symbol id="icon-whatsapp" viewBox="0 0 32 32">
<path d="M15.968 2.003a14.03 13.978 0 0 0-14.03 13.978 14.03 13.978 0 0 0 2.132 7.391L1.938 29.96l6.745-2.052a14.03 13.978 0 0 0 7.285 2.052 14.03 13.978 0 0 0 14.03-13.978 14.03 13.978 0 0 0-14.03-13.978z" stroke-width=".2000562"/>
<path d="M10.454 8.236a2.57 3.401 51.533 0 0-1.475 3.184v.015c.01 2.04 4.045 10.076 10.017 12.688l.017-.013a2.57 3.401 51.533 0 0 3.454-.706 2.57 3.401 51.533 0 0 1.064-4.129 2.57 3.401 51.533 0 0-4.262.103 2.57 3.401 51.533 0 0-.505.473c-1.346-.639-2.952-1.463-4.168-2.98-.771-.962-1.257-2.732-1.549-4.206a2.57 3.401 51.533 0 0 .605-.403 2.57 3.401 51.533 0 0 1.064-4.129 2.57 3.401 51.533 0 0-4.262.103z" stroke-width=".372"/>
</symbol>
<symbol id="icon-telegram" viewBox="0 0 32 32">
<path d="M30.8,2.2L0.6,13.9c-0.8,0.3-0.7,1.3,0,1.6l7.4,2.8l2.9,9.2c0.2,0.6,0.9,0.8,1.4,0.4l4.1-3.4 c0.4-0.4,1-0.4,1.5,0l7.4,5.4c0.5,0.4,1.2,0.1,1.4-0.5L32,3.2C32.1,2.5,31.4,1.9,30.8,2.2z M25,8.3l-11.9,11 c-0.4,0.4-0.7,0.9-0.8,1.5l-0.4,3c-0.1,0.4-0.6,0.4-0.7,0.1l-1.6-5.5c-0.2-0.6,0.1-1.3,0.6-1.6l14.4-8.9C25,7.7,25.3,8.1,25,8.3z"/>
</symbol>
<symbol id="icon-hashtag" viewBox="0 0 32 32">
<path class="path1" d="M17.696 18.286l1.143-4.571h-4.536l-1.143 4.571h4.536zM31.411 9.286l-1 4q-0.125 0.429-0.554 0.429h-5.839l-1.143 4.571h5.554q0.268 0 0.446 0.214 0.179 0.25 0.107 0.5l-1 4q-0.089 0.429-0.554 0.429h-5.839l-1.446 5.857q-0.125 0.429-0.554 0.429h-4q-0.286 0-0.464-0.214-0.161-0.214-0.107-0.5l1.393-5.571h-4.536l-1.446 5.857q-0.125 0.429-0.554 0.429h-4.018q-0.268 0-0.446-0.214-0.161-0.214-0.107-0.5l1.393-5.571h-5.554q-0.268 0-0.446-0.214-0.161-0.214-0.107-0.5l1-4q0.125-0.429 0.554-0.429h5.839l1.143-4.571h-5.554q-0.268 0-0.446-0.214-0.179-0.25-0.107-0.5l1-4q0.089-0.429 0.554-0.429h5.839l1.446-5.857q0.125-0.429 0.571-0.429h4q0.268 0 0.446 0.214 0.161 0.214 0.107 0.5l-1.393 5.571h4.536l1.446-5.857q0.125-0.429 0.571-0.429h4q0.268 0 0.446 0.214 0.161 0.214 0.107 0.5l-1.393 5.571h5.554q0.268 0 0.446 0.214 0.161 0.214 0.107 0.5z"></path>
</symbol>

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -34,7 +34,7 @@ get_header(); ?>
if ( 0 !== twentyseventeen_panel_count() || is_customize_preview() ) : // If we have pages to show.
/**
* Filter number of front page sections in Twenty Seventeen.
* Filters the number of front page sections in Twenty Seventeen.
*
* @since Twenty Seventeen 1.0
*

View File

@ -267,7 +267,7 @@ function twentyseventeen_content_width() {
}
/**
* Filter Twenty Seventeen content width of the theme.
* Filters Twenty Seventeen content width of the theme.
*
* @since Twenty Seventeen 1.0
*
@ -313,7 +313,7 @@ function twentyseventeen_fonts_url() {
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array $urls URLs to print for resource hints.
* @return array URLs to print for resource hints.
*/
function twentyseventeen_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'twentyseventeen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
@ -544,7 +544,7 @@ function twentyseventeen_content_image_sizes_attr( $sizes, $size ) {
add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 );
/**
* Filter the `sizes` value in the header image markup.
* Filters the `sizes` value in the header image markup.
*
* @since Twenty Seventeen 1.0
*
@ -589,8 +589,8 @@ add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnai
* @since Twenty Seventeen 1.0
*
* @param string $template front-page.php.
*
* @return string The template to be used: blank if is_home() is true (defaults to index.php), else $template.
* @return string The template to be used: blank if is_home() is true (defaults to index.php),
* otherwise $template.
*/
function twentyseventeen_front_page_template( $template ) {
return is_home() ? '' : $template;
@ -617,7 +617,7 @@ function twentyseventeen_widget_tag_cloud_args( $args ) {
add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' );
/**
* Get unique ID.
* Gets unique ID.
*
* This is a PHP implementation of Underscore's uniqueId method. A static variable
* contains an integer that is incremented with each call. This number is returned
@ -625,9 +625,8 @@ add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' );
* but it is unique across the life of the PHP process.
*
* @since Twenty Seventeen 2.0
* @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
*
* @staticvar int $id_counter
* @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
*
* @param string $prefix Prefix for the returned ID.
* @return string Unique ID.

View File

@ -0,0 +1,667 @@
<?php
/**
* Twenty Seventeen functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since Twenty Seventeen 1.0
*/
/**
* Twenty Seventeen only works in WordPress 4.7 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
return;
}
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function twentyseventeen_setup() {
/*
* Make theme available for translation.
* Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyseventeen
* If you're building a theme based on Twenty Seventeen, use a find and replace
* to change 'twentyseventeen' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'twentyseventeen' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
add_image_size( 'twentyseventeen-featured-image', 2000, 1200, true );
add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true );
// Set the default content width.
$GLOBALS['content_width'] = 525;
// This theme uses wp_nav_menu() in two locations.
register_nav_menus(
array(
'top' => __( 'Top Menu', 'twentyseventeen' ),
'social' => __( 'Social Links Menu', 'twentyseventeen' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'comment-form',
'comment-list',
'gallery',
'caption',
'script',
'style',
)
);
/*
* Enable support for Post Formats.
*
* See: https://wordpress.org/support/article/post-formats/
*/
add_theme_support(
'post-formats',
array(
'aside',
'image',
'video',
'quote',
'link',
'gallery',
'audio',
)
);
// Add theme support for Custom Logo.
add_theme_support(
'custom-logo',
array(
'width' => 250,
'height' => 250,
'flex-width' => true,
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, and column width.
*/
add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
// Load regular editor styles into the new block-based editor.
add_theme_support( 'editor-styles' );
// Load default block styles.
add_theme_support( 'wp-block-styles' );
// Add support for responsive embeds.
add_theme_support( 'responsive-embeds' );
// Define and register starter content to showcase the theme on new sites.
$starter_content = array(
'widgets' => array(
// Place three core-defined widgets in the sidebar area.
'sidebar-1' => array(
'text_business_info',
'search',
'text_about',
),
// Add the core-defined business info widget to the footer 1 area.
'sidebar-2' => array(
'text_business_info',
),
// Put two core-defined widgets in the footer 2 area.
'sidebar-3' => array(
'text_about',
'search',
),
),
// Specify the core-defined pages to create and add custom thumbnails to some of them.
'posts' => array(
'home',
'about' => array(
'thumbnail' => '{{image-sandwich}}',
),
'contact' => array(
'thumbnail' => '{{image-espresso}}',
),
'blog' => array(
'thumbnail' => '{{image-coffee}}',
),
'homepage-section' => array(
'thumbnail' => '{{image-espresso}}',
),
),
// Create the custom image attachments used as post thumbnails for pages.
'attachments' => array(
'image-espresso' => array(
'post_title' => _x( 'Espresso', 'Theme starter content', 'twentyseventeen' ),
'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
),
'image-sandwich' => array(
'post_title' => _x( 'Sandwich', 'Theme starter content', 'twentyseventeen' ),
'file' => 'assets/images/sandwich.jpg',
),
'image-coffee' => array(
'post_title' => _x( 'Coffee', 'Theme starter content', 'twentyseventeen' ),
'file' => 'assets/images/coffee.jpg',
),
),
// Default to a static front page and assign the front and posts pages.
'options' => array(
'show_on_front' => 'page',
'page_on_front' => '{{home}}',
'page_for_posts' => '{{blog}}',
),
// Set the front page section theme mods to the IDs of the core-registered pages.
'theme_mods' => array(
'panel_1' => '{{homepage-section}}',
'panel_2' => '{{about}}',
'panel_3' => '{{blog}}',
'panel_4' => '{{contact}}',
),
// Set up nav menus for each of the two areas registered in the theme.
'nav_menus' => array(
// Assign a menu to the "top" location.
'top' => array(
'name' => __( 'Top Menu', 'twentyseventeen' ),
'items' => array(
'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
'page_about',
'page_blog',
'page_contact',
),
),
// Assign a menu to the "social" location.
'social' => array(
'name' => __( 'Social Links Menu', 'twentyseventeen' ),
'items' => array(
'link_yelp',
'link_facebook',
'link_twitter',
'link_instagram',
'link_email',
),
),
),
);
/**
* Filters Twenty Seventeen array of starter content.
*
* @since Twenty Seventeen 1.1
*
* @param array $starter_content Array of starter content.
*/
$starter_content = apply_filters( 'twentyseventeen_starter_content', $starter_content );
add_theme_support( 'starter-content', $starter_content );
}
add_action( 'after_setup_theme', 'twentyseventeen_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function twentyseventeen_content_width() {
$content_width = $GLOBALS['content_width'];
// Get layout.
$page_layout = get_theme_mod( 'page_layout' );
// Check if layout is one column.
if ( 'one-column' === $page_layout ) {
if ( twentyseventeen_is_frontpage() ) {
$content_width = 644;
} elseif ( is_page() ) {
$content_width = 740;
}
}
// Check if is single post and there is no sidebar.
if ( is_single() && ! is_active_sidebar( 'sidebar-1' ) ) {
$content_width = 740;
}
/**
* Filter Twenty Seventeen content width of the theme.
*
* @since Twenty Seventeen 1.0
*
* @param int $content_width Content width in pixels.
*/
$GLOBALS['content_width'] = apply_filters( 'twentyseventeen_content_width', $content_width );
}
add_action( 'template_redirect', 'twentyseventeen_content_width', 0 );
/**
* Register custom fonts.
*/
function twentyseventeen_fonts_url() {
$fonts_url = '';
/*
* translators: If there are characters in your language that are not supported
* by Libre Franklin, translate this to 'off'. Do not translate into your own language.
*/
$libre_franklin = _x( 'on', 'Libre Franklin font: on or off', 'twentyseventeen' );
if ( 'off' !== $libre_franklin ) {
$font_families = array();
$font_families[] = 'Libre Franklin:300,300i,400,400i,600,600i,800,800i';
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
'display' => urlencode( 'fallback' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return esc_url_raw( $fonts_url );
}
/**
* Add preconnect for Google Fonts.
*
* @since Twenty Seventeen 1.0
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array $urls URLs to print for resource hints.
*/
function twentyseventeen_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'twentyseventeen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin',
);
}
return $urls;
}
add_filter( 'wp_resource_hints', 'twentyseventeen_resource_hints', 10, 2 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function twentyseventeen_widgets_init() {
register_sidebar(
array(
'name' => __( 'Blog Sidebar', 'twentyseventeen' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'twentyseventeen' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => __( 'Footer 1', 'twentyseventeen' ),
'id' => 'sidebar-2',
'description' => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => __( 'Footer 2', 'twentyseventeen' ),
'id' => 'sidebar-3',
'description' => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
}
add_action( 'widgets_init', 'twentyseventeen_widgets_init' );
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
* a 'Continue reading' link.
*
* @since Twenty Seventeen 1.0
*
* @param string $link Link to single post/page.
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function twentyseventeen_excerpt_more( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf(
'<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Post title. */
sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ), get_the_title( get_the_ID() ) )
);
return ' &hellip; ' . $link;
}
add_filter( 'excerpt_more', 'twentyseventeen_excerpt_more' );
/**
* Handles JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*
* @since Twenty Seventeen 1.0
*/
function twentyseventeen_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
}
add_action( 'wp_head', 'twentyseventeen_javascript_detection', 0 );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function twentyseventeen_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
add_action( 'wp_head', 'twentyseventeen_pingback_header' );
/**
* Display custom color CSS.
*/
function twentyseventeen_colors_css_wrap() {
if ( 'custom' !== get_theme_mod( 'colorscheme' ) && ! is_customize_preview() ) {
return;
}
require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
$hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
$customize_preview_data_hue = '';
if ( is_customize_preview() ) {
$customize_preview_data_hue = 'data-hue="' . $hue . '"';
}
?>
<style type="text/css" id="custom-theme-colors" <?php echo $customize_preview_data_hue; ?>>
<?php echo twentyseventeen_custom_colors_css(); ?>
</style>
<?php
}
add_action( 'wp_head', 'twentyseventeen_colors_css_wrap' );
/**
* Enqueues scripts and styles.
*/
function twentyseventeen_scripts() {
// Add custom fonts, used in the main stylesheet.
wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), null );
// Theme stylesheet.
wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri(), array(), '20190507' );
// Theme block stylesheet.
wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), '20190105' );
// Load the dark colorscheme.
if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) {
wp_enqueue_style( 'twentyseventeen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'twentyseventeen-style' ), '20190408' );
}
// Load the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer.
if ( is_customize_preview() ) {
wp_enqueue_style( 'twentyseventeen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'twentyseventeen-style' ), '20161202' );
wp_style_add_data( 'twentyseventeen-ie9', 'conditional', 'IE 9' );
}
// Load the Internet Explorer 8 specific stylesheet.
wp_enqueue_style( 'twentyseventeen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'twentyseventeen-style' ), '20161202' );
wp_style_add_data( 'twentyseventeen-ie8', 'conditional', 'lt IE 9' );
// Load the html5 shiv.
wp_enqueue_script( 'html5', get_theme_file_uri( '/assets/js/html5.js' ), array(), '20161020' );
wp_script_add_data( 'html5', 'conditional', 'lt IE 9' );
wp_enqueue_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', true );
$twentyseventeen_l10n = array(
'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
);
if ( has_nav_menu( 'top' ) ) {
wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '20161203', true );
$twentyseventeen_l10n['expand'] = __( 'Expand child menu', 'twentyseventeen' );
$twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
$twentyseventeen_l10n['icon'] = twentyseventeen_get_svg(
array(
'icon' => 'angle-down',
'fallback' => true,
)
);
}
wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20190121', true );
wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.2', true );
wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'twentyseventeen_scripts' );
/**
* Enqueues styles for the block-based editor.
*
* @since Twenty Seventeen 1.8
*/
function twentyseventeen_block_editor_styles() {
// Block styles.
wp_enqueue_style( 'twentyseventeen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ), array(), '20190328' );
// Add custom fonts.
wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), null );
}
add_action( 'enqueue_block_editor_assets', 'twentyseventeen_block_editor_styles' );
/**
* Add custom image sizes attribute to enhance responsive image functionality
* for content images.
*
* @since Twenty Seventeen 1.0
*
* @param string $sizes A source size value for use in a 'sizes' attribute.
* @param array $size Image size. Accepts an array of width and height
* values in pixels (in that order).
* @return string A source size value for use in a content image 'sizes' attribute.
*/
function twentyseventeen_content_image_sizes_attr( $sizes, $size ) {
$width = $size[0];
if ( 740 <= $width ) {
$sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px';
}
if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
$sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
}
}
return $sizes;
}
add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 );
/**
* Filter the `sizes` value in the header image markup.
*
* @since Twenty Seventeen 1.0
*
* @param string $html The HTML image tag markup being filtered.
* @param object $header The custom header object returned by 'get_custom_header()'.
* @param array $attr Array of the attributes for the image tag.
* @return string The filtered header image HTML.
*/
function twentyseventeen_header_image_tag( $html, $header, $attr ) {
if ( isset( $attr['sizes'] ) ) {
$html = str_replace( $attr['sizes'], '100vw', $html );
}
return $html;
}
add_filter( 'get_header_image_tag', 'twentyseventeen_header_image_tag', 10, 3 );
/**
* Add custom image sizes attribute to enhance responsive image functionality
* for post thumbnails.
*
* @since Twenty Seventeen 1.0
*
* @param array $attr Attributes for the image markup.
* @param int $attachment Image attachment ID.
* @param array $size Registered image size or flat array of height and width dimensions.
* @return array The filtered attributes for the image markup.
*/
function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
if ( is_archive() || is_search() || is_home() ) {
$attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
} else {
$attr['sizes'] = '100vw';
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 );
/**
* Use front-page.php when Front page displays is set to a static page.
*
* @since Twenty Seventeen 1.0
*
* @param string $template front-page.php.
*
* @return string The template to be used: blank if is_home() is true (defaults to index.php), else $template.
*/
function twentyseventeen_front_page_template( $template ) {
return is_home() ? '' : $template;
}
add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' );
/**
* Modifies tag cloud widget arguments to display all tags in the same font size
* and use list format for better accessibility.
*
* @since Twenty Seventeen 1.4
*
* @param array $args Arguments for tag cloud widget.
* @return array The filtered arguments for tag cloud widget.
*/
function twentyseventeen_widget_tag_cloud_args( $args ) {
$args['largest'] = 1;
$args['smallest'] = 1;
$args['unit'] = 'em';
$args['format'] = 'list';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'twentyseventeen_widget_tag_cloud_args' );
/**
* Get unique ID.
*
* This is a PHP implementation of Underscore's uniqueId method. A static variable
* contains an integer that is incremented with each call. This number is returned
* with the optional prefix. As such the returned value is not universally unique,
* but it is unique across the life of the PHP process.
*
* @since Twenty Seventeen 2.0
*
* @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
*
* @staticvar int $id_counter
*
* @param string $prefix Prefix for the returned ID.
* @return string Unique ID.
*/
function twentyseventeen_unique_id( $prefix = '' ) {
static $id_counter = 0;
if ( function_exists( 'wp_unique_id' ) ) {
return wp_unique_id( $prefix );
}
return $prefix . (string) ++$id_counter;
}
/**
* Implement the Custom Header feature.
*/
require get_parent_theme_file_path( '/inc/custom-header.php' );
/**
* Custom template tags for this theme.
*/
require get_parent_theme_file_path( '/inc/template-tags.php' );
/**
* Additional features to allow styling of the templates.
*/
require get_parent_theme_file_path( '/inc/template-functions.php' );
/**
* Customizer additions.
*/
require get_parent_theme_file_path( '/inc/customizer.php' );
/**
* SVG icons functions and filters.
*/
require get_parent_theme_file_path( '/inc/icon-functions.php' );

View File

@ -17,7 +17,7 @@
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>

View File

@ -14,7 +14,7 @@ function twentyseventeen_custom_colors_css() {
$hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
/**
* Filter Twenty Seventeen default saturation level.
* Filters Twenty Seventeen default saturation level.
*
* @since Twenty Seventeen 1.0
*

View File

@ -16,8 +16,10 @@
*/
function twentyseventeen_custom_header_setup() {
add_theme_support(
'custom-header',
/**
* Filter Twenty Seventeen custom-header support arguments.
* Filters Twenty Seventeen custom-header support arguments.
*
* @since Twenty Seventeen 1.0
*
@ -33,8 +35,6 @@ function twentyseventeen_custom_header_setup() {
* displayed on the blog.
* }
*/
add_theme_support(
'custom-header',
apply_filters(
'twentyseventeen_custom_header_args',
array(

View File

@ -116,7 +116,7 @@ function twentyseventeen_customize_register( $wp_customize ) {
);
/**
* Filter number of front page sections in Twenty Seventeen.
* Filters the number of front page sections in Twenty Seventeen.
*
* @since Twenty Seventeen 1.0
*
@ -197,6 +197,7 @@ function twentyseventeen_sanitize_colorscheme( $input ) {
* Render the site title for the selective refresh partial.
*
* @since Twenty Seventeen 1.0
*
* @see twentyseventeen_customize_register()
*
* @return void
@ -209,6 +210,7 @@ function twentyseventeen_customize_partial_blogname() {
* Render the site tagline for the selective refresh partial.
*
* @since Twenty Seventeen 1.0
*
* @see twentyseventeen_customize_register()
*
* @return void

View File

@ -0,0 +1,251 @@
<?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' );

View File

@ -117,11 +117,11 @@ function twentyseventeen_get_svg( $args = array() ) {
/**
* 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.
* @param string $item_output The menu item's starting HTML output.
* @param WP_Post $item Menu item data object.
* @param int $depth Depth of the menu. Used for padding.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @return string The menu item output with social icon.
*/
function twentyseventeen_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
// Get supported social icons.
@ -145,9 +145,9 @@ add_filter( 'walker_nav_menu_start_el', 'twentyseventeen_nav_menu_social_icons',
*
* @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 stdClass $args An object 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.
* @return string The menu item's title with dropdown icon.
*/
function twentyseventeen_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
if ( 'top' === $args->theme_location ) {
@ -165,7 +165,7 @@ add_filter( 'nav_menu_item_title', 'twentyseventeen_dropdown_icon_to_menu_link',
/**
* Returns an array of supported social links (URL and icon name).
*
* @return array $social_links_icons
* @return array Array of social links icons.
*/
function twentyseventeen_social_links_icons() {
// Supported social links icons.
@ -197,12 +197,15 @@ function twentyseventeen_social_links_icons() {
'soundcloud.com' => 'soundcloud',
'spotify.com' => 'spotify',
'stumbleupon.com' => 'stumbleupon',
't.me' => 'telegram',
'telegram.me' => 'telegram',
'tumblr.com' => 'tumblr',
'twitch.tv' => 'twitch',
'twitter.com' => 'twitter',
'vimeo.com' => 'vimeo',
'vine.co' => 'vine',
'vk.com' => 'vk',
'whatsapp.com' => 'whatsapp',
'wordpress.org' => 'wordpress',
'wordpress.com' => 'wordpress',
'yelp.com' => 'yelp',
@ -210,7 +213,7 @@ function twentyseventeen_social_links_icons() {
);
/**
* Filter Twenty Seventeen social links icons.
* Filters Twenty Seventeen social links icons.
*
* @since Twenty Seventeen 1.0
*

View File

@ -76,7 +76,7 @@ function twentyseventeen_panel_count() {
$panel_count = 0;
/**
* Filter number of front page sections in Twenty Seventeen.
* Filters the number of front page sections in Twenty Seventeen.
*
* @since Twenty Seventeen 1.0
*

View File

@ -131,7 +131,7 @@ endif;
*/
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.
// Find out the ID and set it up during a selective refresh.
global $twentyseventeencounter;
$id = str_replace( 'panel_', '', $partial->id );

View File

@ -1,7 +1,7 @@
=== Twenty Seventeen ===
Contributors: wordpressdotorg
Tested up to: 5.0
Version: 2.3
Tested up to: 5.5
Version: 2.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
@ -59,6 +59,11 @@ Source: https://unsplash.com/@englr?photo=bIhpiQA009k
== Changelog ==
= 2.4 =
* Released: August 11, 2020
https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_2.4
= 2.3 =
* Released: March 31, 2020

View File

@ -4,7 +4,7 @@ Theme URI: https://wordpress.org/themes/twentyseventeen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.
Version: 2.3
Version: 2.4
Requires at least: 4.7
Requires PHP: 5.2.4
License: GNU General Public License v2 or later
@ -1152,6 +1152,8 @@ td {
padding: 0.4em;
}
th,
td,
th:first-child,
td:first-child {
padding-left: 0;
@ -3527,7 +3529,7 @@ p > object:only-child {
right: 0;
top: 0;
width: 100%;
z-index: 7;
z-index: 1000;
}
.admin-bar .site-navigation-fixed.navigation-top {

View File

@ -43,6 +43,12 @@
get_the_title()
)
);
wp_link_pages(
array(
'before' => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->