Making WordPress.org

Changeset 14185


Ignore:
Timestamp:
11/20/2024 09:52:33 PM (13 months ago)
Author:
adamwood
Message:

Breathe 2024: Hide welcome box on other pages

This change hides the welcome box by default on pages other than the home page.
The welcome box usually contains heading tags, and when displayed breaks the heading hierarchy on pages where there is no h1 in the local nav bar.
Visibility can still be toggled via the button.

Closes https://github.com/WordPress/wordpress.org/issues/382

File:
1 edited

Legend:

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

    r14158 r14185  
    344344    $welcome      = get_page_by_path( 'welcome' );
    345345    $cookie       = 'welcome-' . get_current_blog_id();
     346    $path         = get_blog_details()->path;
    346347    $hash         = isset( $_COOKIE[ $cookie ] ) ? $_COOKIE[ $cookie ] : '';
    347348    $content_hash = $welcome ? md5( $welcome->post_content ) : '';
     
    377378        <div class="entry-content clear" id="make-welcome-content" data-cookie="<?php echo $cookie; ?>" data-hash="<?php echo $content_hash; ?>">
    378379            <script type="text/javascript">
    379                 var elContent = document.getElementById( 'make-welcome-content' );
     380                const elContent = document.getElementById( 'make-welcome-content' );
     381
    380382                if ( elContent ) {
    381                     if ( -1 !== document.cookie.indexOf( elContent.dataset.cookie + '=' + elContent.dataset.hash ) ) {
    382                         var elToggle = document.getElementById( 'make-welcome-toggle' ),
    383                             elEditLink = document.getElementsByClassName( 'make-welcome-edit-post-link' ),
    384                             elContainer = document.querySelector( '.make-welcome' );
     383                    const hasCookieSetToHidden = -1 !== document.cookie.indexOf( elContent.dataset.cookie + '=' + elContent.dataset.hash );
     384                    const isHome = window.location.pathname === '<?php echo esc_js( $path ); ?>';
     385
     386                    if ( hasCookieSetToHidden || ! isHome ) {
     387                        const elToggle = document.getElementById( 'make-welcome-toggle' );
     388                        const elEditLink = document.getElementsByClassName( 'make-welcome-edit-post-link' );
     389                        const elContainer = document.querySelector( '.make-welcome' );
    385390
    386391                        // It's hidden, hide it ASAP.
Note: See TracChangeset for help on using the changeset viewer.