[ Index ] |
PHP Cross Reference of WordPress |
[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 * Count our number of active panels. 71 * 72 * Primarily used to see if we have any panels active, duh. 73 */ 74 function twentyseventeen_panel_count() { 75 76 $panel_count = 0; 77 78 /** 79 * Filters the number of front page sections in Twenty Seventeen. 80 * 81 * @since Twenty Seventeen 1.0 82 * 83 * @param int $num_sections Number of front page sections. 84 */ 85 $num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 ); 86 87 // Create a setting and control for each of the sections available in the theme. 88 for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) { 89 if ( get_theme_mod( 'panel_' . $i ) ) { 90 $panel_count++; 91 } 92 } 93 94 return $panel_count; 95 } 96 97 /** 98 * Checks to see if we're on the front page or not. 99 */ 100 function twentyseventeen_is_frontpage() { 101 return ( is_front_page() && ! is_home() ); 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Nov 23 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |