Making WordPress.org


Ignore:
Timestamp:
02/27/2018 11:31:19 PM (6 years ago)
Author:
obenland
Message:

WP.org: Update about pages with child nav

Also fixes a minor issue for toggled navigations on small screens for all themes.

Props mapk, obenland.
See #3046.

File:
1 edited

Legend:

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

    r6658 r6797  
    8585        ] );
    8686    }
     87
     88    if ( is_page() ) {
     89        $page = get_queried_object();
     90
     91        if ( $page->post_parent && 'about' === get_post( $page->post_parent )->post_name ) {
     92            wp_enqueue_script( 'wporg-navigation', get_theme_file_uri( '/js/navigation.js' ), [], '20151215', true );
     93        }
     94    }
    8795}
    8896add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\scripts' );
     
    98106    $cdn_handles = [
    99107        'wporg-page-stats',
     108        'wporg-navigation',
    100109    ];
    101110
     
    119128function body_class( $classes ) {
    120129    if ( is_page() ) {
    121         $classes[] = 'page-' . get_query_var( 'pagename' );
     130        $page = get_queried_object();
     131
     132        $classes[] = 'page-' . $page->post_name;
     133
     134        if ( $page->post_parent ) {
     135            $parent = get_post( $page->post_parent );
     136
     137            $classes[] = 'page-parent-' . $parent->post_name;
     138        }
    122139    }
    123140
Note: See TracChangeset for help on using the changeset viewer.