[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Additional features to allow styling of the templates. 4 * 5 * @package WordPress 6 * @subpackage Twenty_Seventeen 7 * @since Twenty Seventeen 1.0 8 */ 9 10 /** 11 * Adds custom classes to the array of body classes. 12 * 13 * @param array $classes Classes for the body element. 14 * @return array 15 */ 16 function twentyseventeen_body_classes( $classes ) { 17 // Add class of group-blog to blogs with more than 1 published author. 18 if ( is_multi_author() ) { 19 $classes[] = 'group-blog'; 20 } 21 22 // Add class of hfeed to non-singular pages. 23 if ( ! is_singular() ) { 24 $classes[] = 'hfeed'; 25 } 26 27 // Add class if we're viewing the Customizer for easier styling of theme options. 28 if ( is_customize_preview() ) { 29 $classes[] = 'twentyseventeen-customizer'; 30 } 31 32 // Add class on front page. 33 if ( is_front_page() && 'posts' !== get_option( 'show_on_front' ) ) { 34 $classes[] = 'twentyseventeen-front-page'; 35 } 36 37 // Add a class if there is a custom header. 38 if ( has_header_image() ) { 39 $classes[] = 'has-header-image'; 40 } 41 42 // Add class if sidebar is used. 43 if ( is_active_sidebar( 'sidebar-1' ) && ! is_page() ) { 44 $classes[] = 'has-sidebar'; 45 } 46 47 // Add class for one or two column page layouts. 48 if ( is_page() || is_archive() ) { 49 if ( 'one-column' === get_theme_mod( 'page_layout' ) ) { 50 $classes[] = 'page-one-column'; 51 } else { 52 $classes[] = 'page-two-column'; 53 } 54 } 55 56 // Add class if the site title and tagline is hidden. 57 if ( 'blank' === get_header_textcolor() ) { 58 $classes[] = 'title-tagline-hidden'; 59 } 60 61 // Get the colorscheme or the default if there isn't one. 62 $colors = twentyseventeen_sanitize_colorscheme( get_theme_mod( 'colorscheme', 'light' ) ); 63 $classes[] = 'colors-' . $colors; 64 65 return $classes; 66 } 67 add_filter( 'body_class', 'twentyseventeen_body_classes' ); 68 69 /** 70 * Counts the number of our active panels. 71 * 72 * Primarily used to see if we have any panels active. 73 * 74 * @return int The number of active panels. 75 */ 76 function twentyseventeen_panel_count() { 77 78 $panel_count = 0; 79 80 /** 81 * Filters the number of front page sections in Twenty Seventeen. 82 * 83 * @since Twenty Seventeen 1.0 84 * 85 * @param int $num_sections Number of front page sections. 86 */ 87 $num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 ); 88 89 // Create a setting and control for each of the sections available in the theme. 90 for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) { 91 if ( get_theme_mod( 'panel_' . $i ) ) { 92 ++$panel_count; 93 } 94 } 95 96 return $panel_count; 97 } 98 99 /** 100 * Checks to see if we are on the front page or not. 101 * 102 * @return bool Whether we are on the front page or not. 103 */ 104 function twentyseventeen_is_frontpage() { 105 return ( is_front_page() && ! is_home() ); 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Nov 23 08:20:01 2024 | Cross-referenced by PHPXref |