Making WordPress.org

Changeset 3630


Ignore:
Timestamp:
07/07/2016 05:03:29 AM (8 years ago)
Author:
pento
Message:

Breathe: Make the Welcome message dismissable.

It will re-appear if the content is changed, so folks will see updates.

Fixes #1804.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe
Files:
3 edited

Legend:

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

    r3621 r3630  
    77
    88    // Cacheing hack
    9     wp_enqueue_style( 'wporg-breathe', get_stylesheet_uri(), array( 'p2-breathe' ), '20160704a' );
     9    wp_enqueue_style( 'wporg-breathe', get_stylesheet_uri(), array( 'p2-breathe' ), '20160707' );
    1010}
    1111add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\styles', 11 );
     12
     13function inline_scripts() {
     14    ?>
     15    <script type="text/javascript">
     16        var el = document.getElementById( 'make-welcome-hide' );
     17        if ( el ) {
     18            el.addEventListener( 'click', function( e ) {
     19                document.cookie = el.dataset.cookie + '=' + el.dataset.hash + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
     20                var wrapper = document.getElementsByClassName( 'make-welcome-wrapper' ).item( 0 );
     21                if ( wrapper ) {
     22                    jQuery( wrapper ).slideUp();
     23                }
     24            } );
     25        }
     26    </script>
     27    <?php
     28}
     29add_action( 'wp_footer', __NAMESPACE__ . '\inline_scripts' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/header.php

    r3599 r3630  
    1313
    1414        <nav id="site-navigation" class="navigation-main clear" role="navigation">
    15             <div class="screen-reader-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'p2-breathe' ); ?>"><?php _e( 'Skip to content', 'p2-breathe' ); ?></a></div>
     15            <div class="screen-reader-text skip-link"><a href="#content" title="<?php _e( 'Skip to content', 'p2-breathe' ); ?>"><?php _e( 'Skip to content', 'p2-breathe' ); ?></a></div>
    1616
    1717            <?php wp_nav_menu( array( 'theme_location' => 'primary', 'fallback_cb' => false ) ); ?>
     
    2323$welcome = get_page_by_path( 'welcome' );
    2424
    25 if ( $welcome ) {
     25$cookie = 'welcome-' . get_current_blog_id();
     26
     27$hash = isset( $_COOKIE[ $cookie ] ) ? $_COOKIE[ $cookie ] : '';
     28
     29if ( $welcome && md5( $welcome->post_content ) !== $hash ) {
    2630    setup_postdata( $welcome );
    2731?>
    28 <div class="make-welcome-wrapper"><div class="make-welcome">
    29     <?php
    30     the_content();
    31     edit_post_link( __( 'Edit', 'o2' ), '<p class="make-welcome-edit">', '</p>', $welcome->ID );
    32     ?>
    33 </div></div>
     32<div class="make-welcome-wrapper">
     33    <span id="make-welcome-hide" class="dashicons dashicons-no" data-hash="<?php echo md5( $welcome->post_content ); ?>" data-cookie="<?php echo $cookie; ?>" title="<?php _e( 'Hide this message', 'p2-breathe' ); ?>"></span>
     34    <div class="make-welcome">
     35        <?php
     36        the_content();
     37        edit_post_link( __( 'Edit', 'o2' ), '<p class="make-welcome-edit">', '</p>', $welcome->ID );
     38        ?>
     39    </div>
     40</div>
    3441<?php
    3542    wp_reset_postdata();
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/style.css

    r3621 r3630  
    308308    width:100%;
    309309    background: #eeeeee;
     310    /* jQuery slideUp overrides the margin, causing the animation to be a bit funky. !important stops that. */
     311    margin: -4em 0 4em 0 !important;
     312}
     313
     314#make-welcome-hide {
     315    float: right;
     316    margin: 30px;
     317    cursor: pointer;
    310318}
    311319
     
    316324    width: 100%;
    317325    max-width: 960px;
    318     margin: calc(-4em + 16px) auto 4em auto;
     326    margin: 0px auto;
    319327    padding-bottom: 14px;
    320328}
Note: See TracChangeset for help on using the changeset viewer.