Making WordPress.org


Ignore:
Timestamp:
04/30/2015 11:31:29 PM (10 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Prevent brief display of search bar on page load before it gets hidden (while maintaining no-JS support). Fixes #763.

File:
1 edited

Legend:

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

    r1505 r1527  
    8787    add_action( 'pre_get_posts', __NAMESPACE__ . '\\pre_get_posts' );
    8888    add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' );
     89    add_action( 'wp_head', __NAMESPACE__ . '\\header_js' );
    8990    add_action( 'add_meta_boxes', __NAMESPACE__ . '\\rename_comments_meta_box', 10, 2 );
    9091
     
    103104    add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_items', 10, 2 );
    104105
    105     add_filter( 'wp_parser_skip_duplicate_hooks', '__return_true' ); 
     106    add_filter( 'wp_parser_skip_duplicate_hooks', '__return_true' );
    106107
    107108}
     
    244245}
    245246
     247/**
     248 * Outputs JavaScript intended to appear in the head of the page.
     249 */
     250function header_js() {
     251    // Output CSS to hide markup with the class 'hide-if-js'. Ensures the markup is visible if JS is not present.
     252    echo "<script type=\"text/javascript\">jQuery( '<style>.hide-if-js { display: none; }</style>' ).appendTo( 'head' );</script>\n";
     253}
     254
    246255function theme_scripts_styles() {
    247256    wp_enqueue_style( 'dashicons' );
Note: See TracChangeset for help on using the changeset viewer.