Making WordPress.org


Ignore:
Timestamp:
03/30/2018 08:55:40 PM (9 years ago)
Author:
iandunn
Message:

WP15: Add the template for the About page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php

    r6984 r6985  
    77add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
    88add_filter( 'get_custom_logo',    __NAMESPACE__ . '\set_custom_logo' );
     9add_filter( 'body_class',         __NAMESPACE__ . '\add_body_classes' );
    910
    1011/**
    … …  
    3132        // Styles for locale switcher.
    3233        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 */
     46function 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;
    3355}
    3456
Note: See TracChangeset for help on using the changeset viewer.