Making WordPress.org


Ignore:
Timestamp:
09/06/2016 03:04:41 PM (10 years ago)
Author:
ocean90
Message:

Breathe: Clean up header.php and add welcome box via an action.

File:
1 edited

Legend:

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

    r3752 r3975  
    2525}
    2626add_action( 'wp_footer', __NAMESPACE__ . '\inline_scripts' );
     27
     28function welcome_box() {
     29        $welcome = get_page_by_path( 'welcome' );
     30        $cookie  = 'welcome-' . get_current_blog_id();
     31        $hash    = isset( $_COOKIE[ $cookie ] ) ? $_COOKIE[ $cookie ] : '';
     32        $content_hash = $welcome ? md5( $welcome->post_content ) : '';
     33
     34        if ( $welcome && ( empty( $hash ) || $content_hash !== $hash ) ) :
     35                $columns = preg_split( '|<hr\s*/?>|', $welcome->post_content );
     36                if ( count( $columns ) === 2 ) {
     37                        $welcome->post_content = "<div class='content-area'>\n\n{$columns[0]}</div><div class='widget-area'>\n\n{$columns[1]}</div>";
     38                }
     39                setup_postdata( $welcome );
     40
     41                // Disable Jetpack sharing buttons
     42                add_filter( 'sharing_show', '__return_false' );
     43        ?>
     44        <div class="make-welcome">
     45                <div class="entry-meta">
     46                        <?php edit_post_link( __( 'Edit', 'o2' ), '', '', $welcome->ID ); ?>
     47                        <button type="button" id="make-welcome-hide" class="toggle dashicons dashicons-no" data-hash="<?php echo $content_hash; ?>" data-cookie="<?php echo $cookie; ?>" title="<?php esc_attr_e( 'Hide this message', 'p2-breathe' ); ?>"></button>
     48                </div>
     49                <div class="entry-content clear">
     50                        <?php the_content(); ?>
     51                </div>
     52        </div>
     53        <?php
     54                remove_filter( 'sharing_show', '__return_false' );
     55                wp_reset_postdata();
     56        endif;
     57}
     58add_action( 'wporg_breathe_after_header', __NAMESPACE__ . '\welcome_box' );
Note: See TracChangeset for help on using the changeset viewer.