Making WordPress.org

Changeset 6577


Ignore:
Timestamp:
02/09/2018 05:42:07 PM (7 years ago)
Author:
obenland
Message:

Main: Add body class to target specific pages

See #3046.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/functions.php

    r6507 r6577  
    6666
    6767/**
     68 * Extend the default WordPress body classes.
     69 *
     70 * Adds classes to make it easier to target specific pages.
     71 *
     72 * @param array $classes Body classes.
     73 * @return array
     74 */
     75function body_class( $classes ) {
     76    if ( is_page() ) {
     77        $classes[] = 'page-' . get_query_var( 'pagename' );
     78    }
     79
     80    return array_unique( $classes );
     81}
     82add_filter( 'body_class', __NAMESPACE__ . '\body_class' );
     83
     84/**
    6885 * Custom template tags.
    6986 */
Note: See TracChangeset for help on using the changeset viewer.