PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,67 @@
<?php
/**
* Twenty Fifteen back compat functionality
*
* Prevents Twenty Fifteen from running on WordPress versions prior to 4.1,
* since this theme is not meant to be backward compatible beyond that and
* relies on many newer functions and markup changes introduced in 4.1.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
/**
* Prevent switching to Twenty Fifteen on old versions of WordPress.
*
* Switches to the default theme.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_switch_theme() {
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
unset( $_GET['activated'] );
add_action( 'admin_notices', 'twentyfifteen_upgrade_notice' );
}
add_action( 'after_switch_theme', 'twentyfifteen_switch_theme' );
/**
* Add message for unsuccessful theme switch.
*
* Prints an update nag after an unsuccessful attempt to switch to
* Twenty Fifteen on WordPress versions prior to 4.1.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_upgrade_notice() {
$message = sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] );
printf( '<div class="error"><p>%s</p></div>', $message );
}
/**
* Prevent the Customizer from being loaded on WordPress versions prior to 4.1.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_customize() {
wp_die(
sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ),
'',
array(
'back_link' => true,
)
);
}
add_action( 'load-customize.php', 'twentyfifteen_customize' );
/**
* Prevent the Theme Preview from being loaded on WordPress versions prior to 4.1.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_preview() {
if ( isset( $_GET['preview'] ) ) {
wp_die( sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ) );
}
}
add_action( 'template_redirect', 'twentyfifteen_preview' );

View File

@ -0,0 +1,380 @@
<?php
/**
* Custom Header functionality for Twenty Fifteen
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
/**
* Set up the WordPress core custom header feature.
*
* @uses twentyfifteen_header_style()
*/
function twentyfifteen_custom_header_setup() {
$color_scheme = twentyfifteen_get_color_scheme();
$default_text_color = trim( $color_scheme[4], '#' );
/**
* Filter Twenty Fifteen custom-header support arguments.
*
* @since Twenty Fifteen 1.0
*
* @param array $args {
* An array of custom-header support arguments.
*
* @type string $default_text_color Default color of the header text.
* @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 $wp-head-callback Callback function used to styles the header image and text
* displayed on the blog.
* }
*/
add_theme_support(
'custom-header',
apply_filters(
'twentyfifteen_custom_header_args',
array(
'default-text-color' => $default_text_color,
'width' => 954,
'height' => 1300,
'wp-head-callback' => 'twentyfifteen_header_style',
)
)
);
}
add_action( 'after_setup_theme', 'twentyfifteen_custom_header_setup' );
/**
* Convert HEX to RGB.
*
* @since Twenty Fifteen 1.0
*
* @param string $color The original color, in 3- or 6-digit hexadecimal form.
* @return array Array containing RGB (red, green, and blue) values for the given
* HEX code, empty array otherwise.
*/
function twentyfifteen_hex2rgb( $color ) {
$color = trim( $color, '#' );
if ( strlen( $color ) == 3 ) {
$r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) );
$g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) );
$b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) );
} elseif ( strlen( $color ) == 6 ) {
$r = hexdec( substr( $color, 0, 2 ) );
$g = hexdec( substr( $color, 2, 2 ) );
$b = hexdec( substr( $color, 4, 2 ) );
} else {
return array();
}
return array(
'red' => $r,
'green' => $g,
'blue' => $b,
);
}
if ( ! function_exists( 'twentyfifteen_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog.
*
* @since Twenty Fifteen 1.0
*
* @see twentyfifteen_custom_header_setup()
*/
function twentyfifteen_header_style() {
$header_image = get_header_image();
// If no custom options for text are set, let's bail.
if ( empty( $header_image ) && display_header_text() ) {
return;
}
// If we get this far, we have custom styles. Let's do this.
?>
<style type="text/css" id="twentyfifteen-header-css">
<?php
// Short header for when there is no Custom Header and Header Text is hidden.
if ( empty( $header_image ) && ! display_header_text() ) :
?>
.site-header {
padding-top: 14px;
padding-bottom: 14px;
}
.site-branding {
min-height: 42px;
}
@media screen and (min-width: 46.25em) {
.site-header {
padding-top: 21px;
padding-bottom: 21px;
}
.site-branding {
min-height: 56px;
}
}
@media screen and (min-width: 55em) {
.site-header {
padding-top: 25px;
padding-bottom: 25px;
}
.site-branding {
min-height: 62px;
}
}
@media screen and (min-width: 59.6875em) {
.site-header {
padding-top: 0;
padding-bottom: 0;
}
.site-branding {
min-height: 0;
}
}
<?php
endif;
// Has a Custom Header been added?
if ( ! empty( $header_image ) ) :
?>
.site-header {
/*
* No shorthand so the Customizer can override individual properties.
* @see https://core.trac.wordpress.org/ticket/31460
*/
background-image: url(<?php header_image(); ?>);
background-repeat: no-repeat;
background-position: 50% 50%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@media screen and (min-width: 59.6875em) {
body:before {
/*
* No shorthand so the Customizer can override individual properties.
* @see https://core.trac.wordpress.org/ticket/31460
*/
background-image: url(<?php header_image(); ?>);
background-repeat: no-repeat;
background-position: 100% 50%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
border-right: 0;
}
.site-header {
background: transparent;
}
}
<?php
endif;
// Has the text been hidden?
if ( ! display_header_text() ) :
?>
.site-title,
.site-description {
clip: rect(1px, 1px, 1px, 1px);
position: absolute;
}
<?php endif; ?>
</style>
<?php
}
endif; // twentyfifteen_header_style
/**
* Enqueues front-end CSS for the header background color.
*
* @since Twenty Fifteen 1.0
*
* @see wp_add_inline_style()
*/
function twentyfifteen_header_background_color_css() {
$color_scheme = twentyfifteen_get_color_scheme();
$default_color = $color_scheme[1];
$header_background_color = get_theme_mod( 'header_background_color', $default_color );
// Don't do anything if the current color is the default.
if ( $header_background_color === $default_color ) {
return;
}
$css = '
/* Custom Header Background Color */
body:before,
.site-header {
background-color: %1$s;
}
@media screen and (min-width: 59.6875em) {
.site-header,
.secondary {
background-color: transparent;
}
.widget button,
.widget input[type="button"],
.widget input[type="reset"],
.widget input[type="submit"],
.widget_calendar tbody a,
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus {
color: %1$s;
}
}
';
wp_add_inline_style( 'twentyfifteen-style', sprintf( $css, $header_background_color ) );
}
add_action( 'wp_enqueue_scripts', 'twentyfifteen_header_background_color_css', 11 );
/**
* Enqueues front-end CSS for the sidebar text color.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_sidebar_text_color_css() {
$color_scheme = twentyfifteen_get_color_scheme();
$default_color = $color_scheme[4];
$sidebar_link_color = get_theme_mod( 'sidebar_textcolor', $default_color );
// Don't do anything if the current color is the default.
if ( $sidebar_link_color === $default_color ) {
return;
}
// If we get this far, we have custom styles. Let's do this.
$sidebar_link_color_rgb = twentyfifteen_hex2rgb( $sidebar_link_color );
$sidebar_text_color = vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $sidebar_link_color_rgb );
$sidebar_border_color = vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $sidebar_link_color_rgb );
$sidebar_border_focus_color = vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $sidebar_link_color_rgb );
$css = '
/* Custom Sidebar Text Color */
.site-title a,
.site-description,
.secondary-toggle:before {
color: %1$s;
}
.site-title a:hover,
.site-title a:focus {
color: %1$s; /* Fallback for IE7 and IE8 */
color: %2$s;
}
.secondary-toggle {
border-color: %1$s; /* Fallback for IE7 and IE8 */
border-color: %3$s;
}
.secondary-toggle:hover,
.secondary-toggle:focus {
border-color: %1$s; /* Fallback for IE7 and IE8 */
border-color: %4$s;
}
.site-title a {
outline-color: %1$s; /* Fallback for IE7 and IE8 */
outline-color: %4$s;
}
@media screen and (min-width: 59.6875em) {
.secondary a,
.dropdown-toggle:after,
.widget-title,
.widget blockquote cite,
.widget blockquote small {
color: %1$s;
}
.widget button,
.widget input[type="button"],
.widget input[type="reset"],
.widget input[type="submit"],
.widget_calendar tbody a {
background-color: %1$s;
}
.textwidget a {
border-color: %1$s;
}
.secondary a:hover,
.secondary a:focus,
.main-navigation .menu-item-description,
.widget,
.widget blockquote,
.widget .wp-caption-text,
.widget .gallery-caption {
color: %2$s;
}
.widget button:hover,
.widget button:focus,
.widget input[type="button"]:hover,
.widget input[type="button"]:focus,
.widget input[type="reset"]:hover,
.widget input[type="reset"]:focus,
.widget input[type="submit"]:hover,
.widget input[type="submit"]:focus,
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus {
background-color: %2$s;
}
.widget blockquote {
border-color: %2$s;
}
.main-navigation ul,
.main-navigation li,
.secondary-toggle,
.widget input,
.widget textarea,
.widget table,
.widget th,
.widget td,
.widget pre,
.widget li,
.widget_categories .children,
.widget_nav_menu .sub-menu,
.widget_pages .children,
.widget abbr[title] {
border-color: %3$s;
}
.dropdown-toggle:hover,
.dropdown-toggle:focus,
.widget hr {
background-color: %3$s;
}
.widget input:focus,
.widget textarea:focus {
border-color: %4$s;
}
.sidebar a:focus,
.dropdown-toggle:focus {
outline-color: %4$s;
}
}
';
wp_add_inline_style( 'twentyfifteen-style', sprintf( $css, $sidebar_link_color, $sidebar_text_color, $sidebar_border_color, $sidebar_border_focus_color ) );
}
add_action( 'wp_enqueue_scripts', 'twentyfifteen_sidebar_text_color_css', 11 );

View File

@ -0,0 +1,809 @@
<?php
/**
* Twenty Fifteen Customizer functionality
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
/**
* Add postMessage support for site title and description for the Customizer.
*
* @since Twenty Fifteen 1.0
*
* @param WP_Customize_Manager $wp_customize Customizer object.
*/
function twentyfifteen_customize_register( $wp_customize ) {
$color_scheme = twentyfifteen_get_color_scheme();
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'container_inclusive' => false,
'render_callback' => 'twentyfifteen_customize_partial_blogname',
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'container_inclusive' => false,
'render_callback' => 'twentyfifteen_customize_partial_blogdescription',
)
);
}
// Add color scheme setting and control.
$wp_customize->add_setting(
'color_scheme',
array(
'default' => 'default',
'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'color_scheme',
array(
'label' => __( 'Base Color Scheme', 'twentyfifteen' ),
'section' => 'colors',
'type' => 'select',
'choices' => twentyfifteen_get_color_scheme_choices(),
'priority' => 1,
)
);
// Add custom header and sidebar text color setting and control.
$wp_customize->add_setting(
'sidebar_textcolor',
array(
'default' => $color_scheme[4],
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'sidebar_textcolor',
array(
'label' => __( 'Header and Sidebar Text Color', 'twentyfifteen' ),
'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
'section' => 'colors',
)
)
);
// Remove the core header textcolor control, as it shares the sidebar text color.
$wp_customize->remove_control( 'header_textcolor' );
// Add custom header and sidebar background color setting and control.
$wp_customize->add_setting(
'header_background_color',
array(
'default' => $color_scheme[1],
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'header_background_color',
array(
'label' => __( 'Header and Sidebar Background Color', 'twentyfifteen' ),
'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
'section' => 'colors',
)
)
);
// Add an additional description to the header image section.
$wp_customize->get_section( 'header_image' )->description = __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' );
}
add_action( 'customize_register', 'twentyfifteen_customize_register', 11 );
/**
* Render the site title for the selective refresh partial.
*
* @since Twenty Fifteen 1.5
* @see twentyfifteen_customize_register()
*
* @return void
*/
function twentyfifteen_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @since Twenty Fifteen 1.5
* @see twentyfifteen_customize_register()
*
* @return void
*/
function twentyfifteen_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Register color schemes for Twenty Fifteen.
*
* Can be filtered with {@see 'twentyfifteen_color_schemes'}.
*
* The order of colors in a colors array:
* 1. Main Background Color.
* 2. Sidebar Background Color.
* 3. Box Background Color.
* 4. Main Text and Link Color.
* 5. Sidebar Text and Link Color.
* 6. Meta Box Background Color.
*
* @since Twenty Fifteen 1.0
*
* @return array An associative array of color scheme options.
*/
function twentyfifteen_get_color_schemes() {
/**
* Filter the color schemes registered for use with Twenty Fifteen.
*
* The default schemes include 'default', 'dark', 'yellow', 'pink', 'purple', and 'blue'.
*
* @since Twenty Fifteen 1.0
*
* @param array $schemes {
* Associative array of color schemes data.
*
* @type array $slug {
* Associative array of information for setting up the color scheme.
*
* @type string $label Color scheme label.
* @type array $colors HEX codes for default colors prepended with a hash symbol ('#').
* Colors are defined in the following order: Main background, sidebar
* background, box background, main text and link, sidebar text and link,
* meta box background.
* }
* }
*/
return apply_filters(
'twentyfifteen_color_schemes',
array(
'default' => array(
'label' => __( 'Default', 'twentyfifteen' ),
'colors' => array(
'#f1f1f1',
'#ffffff',
'#ffffff',
'#333333',
'#333333',
'#f7f7f7',
),
),
'dark' => array(
'label' => __( 'Dark', 'twentyfifteen' ),
'colors' => array(
'#111111',
'#202020',
'#202020',
'#bebebe',
'#bebebe',
'#1b1b1b',
),
),
'yellow' => array(
'label' => __( 'Yellow', 'twentyfifteen' ),
'colors' => array(
'#f4ca16',
'#ffdf00',
'#ffffff',
'#111111',
'#111111',
'#f1f1f1',
),
),
'pink' => array(
'label' => __( 'Pink', 'twentyfifteen' ),
'colors' => array(
'#ffe5d1',
'#e53b51',
'#ffffff',
'#352712',
'#ffffff',
'#f1f1f1',
),
),
'purple' => array(
'label' => __( 'Purple', 'twentyfifteen' ),
'colors' => array(
'#674970',
'#2e2256',
'#ffffff',
'#2e2256',
'#ffffff',
'#f1f1f1',
),
),
'blue' => array(
'label' => __( 'Blue', 'twentyfifteen' ),
'colors' => array(
'#e9f2f9',
'#55c3dc',
'#ffffff',
'#22313f',
'#ffffff',
'#f1f1f1',
),
),
)
);
}
if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) :
/**
* Get the current Twenty Fifteen color scheme.
*
* @since Twenty Fifteen 1.0
*
* @return array An associative array of either the current or default color scheme hex values.
*/
function twentyfifteen_get_color_scheme() {
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
$color_schemes = twentyfifteen_get_color_schemes();
if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
return $color_schemes[ $color_scheme_option ]['colors'];
}
return $color_schemes['default']['colors'];
}
endif; // twentyfifteen_get_color_scheme
if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) :
/**
* Returns an array of color scheme choices registered for Twenty Fifteen.
*
* @since Twenty Fifteen 1.0
*
* @return array Array of color schemes.
*/
function twentyfifteen_get_color_scheme_choices() {
$color_schemes = twentyfifteen_get_color_schemes();
$color_scheme_control_options = array();
foreach ( $color_schemes as $color_scheme => $value ) {
$color_scheme_control_options[ $color_scheme ] = $value['label'];
}
return $color_scheme_control_options;
}
endif; // twentyfifteen_get_color_scheme_choices
if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) :
/**
* Sanitization callback for color schemes.
*
* @since Twenty Fifteen 1.0
*
* @param string $value Color scheme name value.
* @return string Color scheme name.
*/
function twentyfifteen_sanitize_color_scheme( $value ) {
$color_schemes = twentyfifteen_get_color_scheme_choices();
if ( ! array_key_exists( $value, $color_schemes ) ) {
$value = 'default';
}
return $value;
}
endif; // twentyfifteen_sanitize_color_scheme
/**
* Enqueues front-end CSS for color scheme.
*
* @since Twenty Fifteen 1.0
*
* @see wp_add_inline_style()
*/
function twentyfifteen_color_scheme_css() {
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
// Don't do anything if the default color scheme is selected.
if ( 'default' === $color_scheme_option ) {
return;
}
$color_scheme = twentyfifteen_get_color_scheme();
// Convert main and sidebar text hex color to rgba.
$color_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[3] );
$color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[4] );
$colors = array(
'background_color' => $color_scheme[0],
'header_background_color' => $color_scheme[1],
'box_background_color' => $color_scheme[2],
'textcolor' => $color_scheme[3],
'secondary_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_textcolor_rgb ),
'border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_textcolor_rgb ),
'border_focus_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_textcolor_rgb ),
'sidebar_textcolor' => $color_scheme[4],
'sidebar_border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_textcolor_rgb ),
'sidebar_border_focus_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_textcolor_rgb ),
'secondary_sidebar_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_textcolor_rgb ),
'meta_box_background_color' => $color_scheme[5],
);
$color_scheme_css = twentyfifteen_get_color_scheme_css( $colors );
wp_add_inline_style( 'twentyfifteen-style', $color_scheme_css );
}
add_action( 'wp_enqueue_scripts', 'twentyfifteen_color_scheme_css' );
/**
* Binds JS listener to make Customizer color_scheme control.
*
* Passes color scheme data as colorScheme global.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_customize_control_js() {
wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', true );
wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );
}
add_action( 'customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js' );
/**
* Binds JS handlers to make the Customizer preview reload changes asynchronously.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_customize_preview_js() {
wp_enqueue_script( 'twentyfifteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20141216', true );
}
add_action( 'customize_preview_init', 'twentyfifteen_customize_preview_js' );
/**
* Returns CSS for the color schemes.
*
* @since Twenty Fifteen 1.0
*
* @param array $colors Color scheme colors.
* @return string Color scheme CSS.
*/
function twentyfifteen_get_color_scheme_css( $colors ) {
$colors = wp_parse_args(
$colors,
array(
'background_color' => '',
'header_background_color' => '',
'box_background_color' => '',
'textcolor' => '',
'secondary_textcolor' => '',
'border_color' => '',
'border_focus_color' => '',
'sidebar_textcolor' => '',
'sidebar_border_color' => '',
'sidebar_border_focus_color' => '',
'secondary_sidebar_textcolor' => '',
'meta_box_background_color' => '',
)
);
$css = <<<CSS
/* Color Scheme */
/* Background Color */
body {
background-color: {$colors['background_color']};
}
/* Sidebar Background Color */
body:before,
.site-header {
background-color: {$colors['header_background_color']};
}
/* Box Background Color */
.post-navigation,
.pagination,
.secondary,
.site-footer,
.hentry,
.page-header,
.page-content,
.comments-area,
.widecolumn {
background-color: {$colors['box_background_color']};
}
/* Box Background Color */
button,
input[type="button"],
input[type="reset"],
input[type="submit"],
.pagination .prev,
.pagination .next,
.widget_calendar tbody a,
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus,
.page-links a,
.page-links a:hover,
.page-links a:focus,
.sticky-post {
color: {$colors['box_background_color']};
}
/* Main Text Color */
button,
input[type="button"],
input[type="reset"],
input[type="submit"],
.pagination .prev,
.pagination .next,
.widget_calendar tbody a,
.page-links a,
.sticky-post {
background-color: {$colors['textcolor']};
}
/* Main Text Color */
body,
blockquote cite,
blockquote small,
a,
.dropdown-toggle:after,
.image-navigation a:hover,
.image-navigation a:focus,
.comment-navigation a:hover,
.comment-navigation a:focus,
.widget-title,
.entry-footer a:hover,
.entry-footer a:focus,
.comment-metadata a:hover,
.comment-metadata a:focus,
.pingback .edit-link a:hover,
.pingback .edit-link a:focus,
.comment-list .reply a:hover,
.comment-list .reply a:focus,
.site-info a:hover,
.site-info a:focus {
color: {$colors['textcolor']};
}
/* Main Text Color */
.entry-content a,
.entry-summary a,
.page-content a,
.comment-content a,
.pingback .comment-body > a,
.author-description a,
.taxonomy-description a,
.textwidget a,
.entry-footer a:hover,
.comment-metadata a:hover,
.pingback .edit-link a:hover,
.comment-list .reply a:hover,
.site-info a:hover {
border-color: {$colors['textcolor']};
}
/* Secondary Text Color */
button:hover,
button:focus,
input[type="button"]:hover,
input[type="button"]:focus,
input[type="reset"]:hover,
input[type="reset"]:focus,
input[type="submit"]:hover,
input[type="submit"]:focus,
.pagination .prev:hover,
.pagination .prev:focus,
.pagination .next:hover,
.pagination .next:focus,
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus,
.page-links a:hover,
.page-links a:focus {
background-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
background-color: {$colors['secondary_textcolor']};
}
/* Secondary Text Color */
blockquote,
a:hover,
a:focus,
.main-navigation .menu-item-description,
.post-navigation .meta-nav,
.post-navigation a:hover .post-title,
.post-navigation a:focus .post-title,
.image-navigation,
.image-navigation a,
.comment-navigation,
.comment-navigation a,
.widget,
.author-heading,
.entry-footer,
.entry-footer a,
.taxonomy-description,
.page-links > .page-links-title,
.entry-caption,
.comment-author,
.comment-metadata,
.comment-metadata a,
.pingback .edit-link,
.pingback .edit-link a,
.post-password-form label,
.comment-form label,
.comment-notes,
.comment-awaiting-moderation,
.logged-in-as,
.form-allowed-tags,
.no-comments,
.site-info,
.site-info a,
.wp-caption-text,
.gallery-caption,
.comment-list .reply a,
.widecolumn label,
.widecolumn .mu_register label {
color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
color: {$colors['secondary_textcolor']};
}
/* Secondary Text Color */
blockquote,
.logged-in-as a:hover,
.comment-author a:hover {
border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
border-color: {$colors['secondary_textcolor']};
}
/* Border Color */
hr,
.dropdown-toggle:hover,
.dropdown-toggle:focus {
background-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
background-color: {$colors['border_color']};
}
/* Border Color */
pre,
abbr[title],
table,
th,
td,
input,
textarea,
.main-navigation ul,
.main-navigation li,
.post-navigation,
.post-navigation div + div,
.pagination,
.comment-navigation,
.widget li,
.widget_categories .children,
.widget_nav_menu .sub-menu,
.widget_pages .children,
.site-header,
.site-footer,
.hentry + .hentry,
.author-info,
.entry-content .page-links a,
.page-links > span,
.page-header,
.comments-area,
.comment-list + .comment-respond,
.comment-list article,
.comment-list .pingback,
.comment-list .trackback,
.comment-list .reply a,
.no-comments {
border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
border-color: {$colors['border_color']};
}
/* Border Focus Color */
a:focus,
button:focus,
input:focus {
outline-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
outline-color: {$colors['border_focus_color']};
}
input:focus,
textarea:focus {
border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
border-color: {$colors['border_focus_color']};
}
/* Sidebar Link Color */
.secondary-toggle:before {
color: {$colors['sidebar_textcolor']};
}
.site-title a,
.site-description {
color: {$colors['sidebar_textcolor']};
}
/* Sidebar Text Color */
.site-title a:hover,
.site-title a:focus {
color: {$colors['secondary_sidebar_textcolor']};
}
/* Sidebar Border Color */
.secondary-toggle {
border-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */
border-color: {$colors['sidebar_border_color']};
}
/* Sidebar Border Focus Color */
.secondary-toggle:hover,
.secondary-toggle:focus {
border-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */
border-color: {$colors['sidebar_border_focus_color']};
}
.site-title a {
outline-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */
outline-color: {$colors['sidebar_border_focus_color']};
}
/* Meta Background Color */
.entry-footer {
background-color: {$colors['meta_box_background_color']};
}
@media screen and (min-width: 38.75em) {
/* Main Text Color */
.page-header {
border-color: {$colors['textcolor']};
}
}
@media screen and (min-width: 59.6875em) {
/* Make sure its transparent on desktop */
.site-header,
.secondary {
background-color: transparent;
}
/* Sidebar Background Color */
.widget button,
.widget input[type="button"],
.widget input[type="reset"],
.widget input[type="submit"],
.widget_calendar tbody a,
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus {
color: {$colors['header_background_color']};
}
/* Sidebar Link Color */
.secondary a,
.dropdown-toggle:after,
.widget-title,
.widget blockquote cite,
.widget blockquote small {
color: {$colors['sidebar_textcolor']};
}
.widget button,
.widget input[type="button"],
.widget input[type="reset"],
.widget input[type="submit"],
.widget_calendar tbody a {
background-color: {$colors['sidebar_textcolor']};
}
.textwidget a {
border-color: {$colors['sidebar_textcolor']};
}
/* Sidebar Text Color */
.secondary a:hover,
.secondary a:focus,
.main-navigation .menu-item-description,
.widget,
.widget blockquote,
.widget .wp-caption-text,
.widget .gallery-caption {
color: {$colors['secondary_sidebar_textcolor']};
}
.widget button:hover,
.widget button:focus,
.widget input[type="button"]:hover,
.widget input[type="button"]:focus,
.widget input[type="reset"]:hover,
.widget input[type="reset"]:focus,
.widget input[type="submit"]:hover,
.widget input[type="submit"]:focus,
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus {
background-color: {$colors['secondary_sidebar_textcolor']};
}
.widget blockquote {
border-color: {$colors['secondary_sidebar_textcolor']};
}
/* Sidebar Border Color */
.main-navigation ul,
.main-navigation li,
.widget input,
.widget textarea,
.widget table,
.widget th,
.widget td,
.widget pre,
.widget li,
.widget_categories .children,
.widget_nav_menu .sub-menu,
.widget_pages .children,
.widget abbr[title] {
border-color: {$colors['sidebar_border_color']};
}
.dropdown-toggle:hover,
.dropdown-toggle:focus,
.widget hr {
background-color: {$colors['sidebar_border_color']};
}
.widget input:focus,
.widget textarea:focus {
border-color: {$colors['sidebar_border_focus_color']};
}
.sidebar a:focus,
.dropdown-toggle:focus {
outline-color: {$colors['sidebar_border_focus_color']};
}
}
CSS;
return $css;
}
/**
* Output an Underscore template for generating CSS for the color scheme.
*
* The template generates the css dynamically for instant display in the Customizer
* preview.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_color_scheme_css_template() {
$colors = array(
'background_color' => '{{ data.background_color }}',
'header_background_color' => '{{ data.header_background_color }}',
'box_background_color' => '{{ data.box_background_color }}',
'textcolor' => '{{ data.textcolor }}',
'secondary_textcolor' => '{{ data.secondary_textcolor }}',
'border_color' => '{{ data.border_color }}',
'border_focus_color' => '{{ data.border_focus_color }}',
'sidebar_textcolor' => '{{ data.sidebar_textcolor }}',
'sidebar_border_color' => '{{ data.sidebar_border_color }}',
'sidebar_border_focus_color' => '{{ data.sidebar_border_focus_color }}',
'secondary_sidebar_textcolor' => '{{ data.secondary_sidebar_textcolor }}',
'meta_box_background_color' => '{{ data.meta_box_background_color }}',
);
?>
<script type="text/html" id="tmpl-twentyfifteen-color-scheme">
<?php echo twentyfifteen_get_color_scheme_css( $colors ); ?>
</script>
<?php
}
add_action( 'customize_controls_print_footer_scripts', 'twentyfifteen_color_scheme_css_template' );

View File

@ -0,0 +1,269 @@
<?php
/**
* Custom template tags for Twenty Fifteen
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
if ( ! function_exists( 'twentyfifteen_comment_nav' ) ) :
/**
* Display navigation to next/previous comments when applicable.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_comment_nav() {
// Are there comments to navigate through?
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
?>
<nav class="navigation comment-navigation" role="navigation">
<h2 class="screen-reader-text"><?php _e( 'Comment navigation', 'twentyfifteen' ); ?></h2>
<div class="nav-links">
<?php
if ( $prev_link = get_previous_comments_link( __( 'Older Comments', 'twentyfifteen' ) ) ) :
printf( '<div class="nav-previous">%s</div>', $prev_link );
endif;
if ( $next_link = get_next_comments_link( __( 'Newer Comments', 'twentyfifteen' ) ) ) :
printf( '<div class="nav-next">%s</div>', $next_link );
endif;
?>
</div><!-- .nav-links -->
</nav><!-- .comment-navigation -->
<?php
endif;
}
endif;
if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) :
/**
* Prints HTML with meta information for the categories, tags.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_entry_meta() {
if ( is_sticky() && is_home() && ! is_paged() ) {
printf( '<span class="sticky-post">%s</span>', __( 'Featured', 'twentyfifteen' ) );
}
$format = get_post_format();
if ( current_theme_supports( 'post-formats', $format ) ) {
printf(
'<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'twentyfifteen' ) ),
esc_url( get_post_format_link( $format ) ),
get_post_format_string( $format )
);
}
if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
$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,
esc_attr( get_the_date( 'c' ) ),
get_the_date(),
esc_attr( get_the_modified_date( 'c' ) ),
get_the_modified_date()
);
printf(
'<span class="posted-on"><span class="screen-reader-text">%1$s </span><a href="%2$s" rel="bookmark">%3$s</a></span>',
_x( 'Posted on', 'Used before publish date.', 'twentyfifteen' ),
esc_url( get_permalink() ),
$time_string
);
}
if ( 'post' == get_post_type() ) {
if ( is_singular() || is_multi_author() ) {
printf(
'<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>',
_x( 'Author', 'Used before post author name.', 'twentyfifteen' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
get_the_author()
);
}
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
if ( $categories_list && twentyfifteen_categorized_blog() ) {
printf(
'<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Categories', 'Used before category names.', 'twentyfifteen' ),
$categories_list
);
}
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
printf(
'<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Tags', 'Used before tag names.', 'twentyfifteen' ),
$tags_list
);
}
}
if ( is_attachment() && wp_attachment_is_image() ) {
// Retrieve attachment metadata.
$metadata = wp_get_attachment_metadata();
printf(
'<span class="full-size-link"><span class="screen-reader-text">%1$s </span><a href="%2$s">%3$s &times; %4$s</a></span>',
_x( 'Full size', 'Used before full size attachment link.', 'twentyfifteen' ),
esc_url( wp_get_attachment_url() ),
$metadata['width'],
$metadata['height']
);
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
/* translators: %s: post title */
comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentyfifteen' ), get_the_title() ) );
echo '</span>';
}
}
endif;
/**
* Determine whether blog/site has more than one category.
*
* @since Twenty Fifteen 1.0
*
* @return bool True of there is more than one category, false otherwise.
*/
function twentyfifteen_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'twentyfifteen_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = 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.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'twentyfifteen_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 || is_preview() ) {
// This blog has more than 1 category so twentyfifteen_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so twentyfifteen_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in {@see twentyfifteen_categorized_blog()}.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'twentyfifteen_categories' );
}
add_action( 'edit_category', 'twentyfifteen_category_transient_flusher' );
add_action( 'save_post', 'twentyfifteen_category_transient_flusher' );
if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) :
/**
* Display an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_post_thumbnail() {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
if ( is_singular() ) :
?>
<div class="post-thumbnail">
<?php the_post_thumbnail(); ?>
</div><!-- .post-thumbnail -->
<?php else : ?>
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
<?php
the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) );
?>
</a>
<?php
endif; // End is_singular()
}
endif;
if ( ! function_exists( 'twentyfifteen_get_link_url' ) ) :
/**
* Return the post URL.
*
* Falls back to the post permalink if no URL is found in the post.
*
* @since Twenty Fifteen 1.0
*
* @see get_url_in_content()
*
* @return string The Link format URL.
*/
function twentyfifteen_get_link_url() {
$has_url = get_url_in_content( get_the_content() );
return $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
endif;
if ( ! function_exists( 'twentyfifteen_excerpt_more' ) && ! is_admin() ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link.
*
* @since Twenty Fifteen 1.0
*
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function twentyfifteen_excerpt_more( $more ) {
$link = sprintf(
'<a href="%1$s" class="more-link">%2$s</a>',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading %s', 'twentyfifteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
);
return ' &hellip; ' . $link;
}
add_filter( 'excerpt_more', 'twentyfifteen_excerpt_more' );
endif;
if ( ! function_exists( 'twentyfifteen_the_custom_logo' ) ) :
/**
* Displays the optional custom logo.
*
* Does nothing if the custom logo is not available.
*
* @since Twenty Fifteen 1.5
*/
function twentyfifteen_the_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
endif;