Changeset 6985 for sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php
- Timestamp:
- 03/30/2018 08:55:40 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php
r6984 r6985 7 7 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' ); 8 8 add_filter( 'get_custom_logo', __NAMESPACE__ . '\set_custom_logo' ); 9 add_filter( 'body_class', __NAMESPACE__ . '\add_body_classes' ); 9 10 10 11 /** … … 31 32 // Styles for locale switcher. 32 33 wp_enqueue_style( 'select2' ); 34 } 35 36 /** 37 * Add the post's slug to the body tag 38 * 39 * For CSS developers, this is better than relying on the post ID, because that often changes between their local 40 * development environment and production, and manually importing/exporting is inconvenient. 41 * 42 * @param array $body_classes 43 * 44 * @return array 45 */ 46 function add_body_classes( $body_classes ) { 47 global $wp_query; 48 $post = $wp_query->get_queried_object(); 49 50 if ( is_a( $post, 'WP_Post' ) ) { 51 $body_classes[] = $post->post_type . '-slug-' . sanitize_html_class( $post->post_name, $post->ID ); 52 } 53 54 return $body_classes; 33 55 } 34 56
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)