Making WordPress.org

Changeset 3975


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.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe
Files:
2 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' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/header.php

    r3974 r3975  
    11<?php
    2 $welcome = get_page_by_path( 'welcome' );
    3 $cookie  = 'welcome-' . get_current_blog_id();
    4 $hash    = isset( $_COOKIE[ $cookie ] ) ? $_COOKIE[ $cookie ] : '';
    5 $content_hash = $welcome ? md5( $welcome->post_content ) : '';
    6 
    72$GLOBALS['pagetitle'] = get_bloginfo( 'name', 'display' );
    83require WPORGPATH . 'header.php';
     
    2419</header><!-- .site-header -->
    2520
    26 <?php
    27 
    28 if ( $welcome && ( empty( $hash ) || $content_hash !== $hash ) ) :
    29         $columns = preg_split( '|<hr\s*/?>|', $welcome->post_content );
    30         if ( count( $columns ) === 2 ) {
    31                 $welcome->post_content = "<div class='content-area'>\n\n{$columns[0]}</div><div class='widget-area'>\n\n{$columns[1]}</div>";
    32         }
    33         setup_postdata( $welcome );
    34 
    35         // Disable Jetpack sharing buttons.
    36         add_filter( 'sharing_show', '__return_false' );
    37 ?>
    38 <div class="make-welcome">
    39         <div class="entry-meta">
    40                 <?php edit_post_link( __( 'Edit', 'o2' ), '', '', $welcome->ID ); ?>
    41                 <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>
    42         </div>
    43         <div class="entry-content clear">
    44                 <?php the_content(); ?>
    45         </div>
    46 </div>
    47 <?php
    48         remove_filter( 'sharing_show', '__return_false' );
    49         wp_reset_postdata();
    50 endif;
    51 ?>
     21<?php do_action( 'wporg_breathe_after_header' ); ?>
    5222
    5323<div id="page" class="hfeed site">
Note: See TracChangeset for help on using the changeset viewer.