Changeset 6841
- Timestamp:
- 03/08/2018 02:51:43 AM (7 years ago)
- 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
r6563 r6841 47 47 48 48 // Cacheing hack 49 wp_enqueue_style( 'wporg-breathe', get_stylesheet_uri(), array( 'p2-breathe' ), '2018020 7a' );49 wp_enqueue_style( 'wporg-breathe', get_stylesheet_uri(), array( 'p2-breathe' ), '20180208a' ); 50 50 } 51 51 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\styles', 11 ); … … 60 60 ?> 61 61 <script type="text/javascript"> 62 var el = document.getElementById( 'make-welcome- hide' );62 var el = document.getElementById( 'make-welcome-toggle' ); 63 63 if ( el ) { 64 64 el.addEventListener( 'click', function( e ) { 65 document.cookie = el.dataset.cookie + '=' + el.dataset.hash + 66 '; expires=Fri, 31 Dec 9999 23:59:59 GMT' + 67 '; domain=<?php echo esc_js( $current_site->domain ); ?>' + 68 '; path=<?php echo esc_js( $current_site->path ); ?>'; 69 jQuery( '.make-welcome' ).slideUp(); 65 if ( jQuery( '.make-welcome .entry-content' ).is( ':hidden' ) ) { 66 document.cookie = el.dataset.cookie + '=' + 67 '; expires=Thu, 01 Jan 1970 00:00:00 GMT' + 68 '; domain=<?php echo esc_js( $current_site->domain ); ?>' + 69 '; path=<?php echo esc_js( $current_site->path ); ?>'; 70 jQuery( '#make-welcome-toggle' ).text( '<?php esc_attr_e( 'Hide welcome box', 'wporg' ); ?>' ); 71 } else { 72 document.cookie = el.dataset.cookie + '=' + el.dataset.hash + 73 '; expires=Fri, 31 Dec 9999 23:59:59 GMT' + 74 '; domain=<?php echo esc_js( $current_site->domain ); ?>' + 75 '; path=<?php echo esc_js( $current_site->path ); ?>'; 76 jQuery( '#make-welcome-toggle' ).text( '<?php esc_attr_e( 'Show welcome box', 'wporg' ); ?>' ); 77 } 78 79 jQuery( '.make-welcome .entry-content' ).slideToggle(); 80 jQuery( '.make-welcome .post-edit-link' ).toggle(); 70 81 } ); 71 82 } … … 76 87 77 88 function welcome_box() { 78 $welcome = get_page_by_path( 'welcome' );79 $cookie = 'welcome-' . get_current_blog_id();80 $hash = isset( $_COOKIE[ $cookie ] ) ? $_COOKIE[ $cookie ] : '';89 $welcome = get_page_by_path( 'welcome' ); 90 $cookie = 'welcome-' . get_current_blog_id(); 91 $hash = isset( $_COOKIE[ $cookie ] ) ? $_COOKIE[ $cookie ] : ''; 81 92 $content_hash = $welcome ? md5( $welcome->post_content ) : ''; 82 93 83 if ( $welcome && ( empty( $hash ) || $content_hash !== $hash ) ) : 84 $columns = preg_split( '|<hr\s*/?>|', $welcome->post_content ); 85 if ( count( $columns ) === 2 ) { 86 $welcome->post_content = "<div class='content-area'>\n\n{$columns[0]}</div><div class='widget-area'>\n\n{$columns[1]}</div>"; 87 } 88 89 setup_postdata( $welcome ); 90 91 // Disable Jetpack sharing buttons 92 add_filter( 'sharing_show', '__return_false' ); 94 if ( ! $welcome ) { 95 return; 96 } 97 98 if ( ! $hash || $content_hash !== $hash ) { 99 $class = ''; 100 $label = __( 'Hide welcome box', 'wporg' ); 101 } else { 102 $class = 'hidden'; 103 $label = __( 'Show welcome box', 'wporg' ); 104 } 105 106 $columns = preg_split( '|<hr\s*/?>|', $welcome->post_content ); 107 if ( count( $columns ) === 2 ) { 108 $welcome->post_content = "<div class='content-area'>\n\n{$columns[0]}</div><div class='widget-area'>\n\n{$columns[1]}</div>"; 109 } 110 111 setup_postdata( $welcome ); 112 113 // Disable Jetpack sharing buttons 114 add_filter( 'sharing_show', '__return_false' ); 93 115 ?> 94 116 <div class="make-welcome"> 95 117 <div class="entry-meta"> 96 <?php edit_post_link( __( 'Edit', 'wporg' ), '', '', $welcome->ID ); ?>97 <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', 'wporg' ); ?>"></button>118 <?php edit_post_link( __( 'Edit', 'wporg' ), '', '', $welcome->ID, 'post-edit-link ' . $class ); ?> 119 <button type="button" id="make-welcome-toggle" data-hash="<?php echo $content_hash; ?>" data-cookie="<?php echo $cookie; ?>"><?php echo $label; ?></button> 98 120 </div> 99 <div class="entry-content clear ">121 <div class="entry-content clear <?php echo $class; ?>""> 100 122 <?php the_content(); ?> 101 123 </div> 102 124 </div> 103 125 <?php 104 remove_filter( 'sharing_show', '__return_false' ); 105 wp_reset_postdata(); 106 endif; 126 remove_filter( 'sharing_show', '__return_false' ); 127 wp_reset_postdata(); 107 128 } 108 129 add_action( 'wporg_breathe_after_header', __NAMESPACE__ . '\welcome_box' ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/style.css
r6562 r6841 787 787 788 788 .make-welcome .entry-meta { 789 margin: 1 5px;789 margin: 1em; 790 790 position: absolute; 791 791 right: 0; … … 812 812 .make-welcome .entry-meta [type="button"]:focus { 813 813 outline: thin dotted; 814 } 815 816 .make-welcome .hidden { 817 display: none; 814 818 } 815 819
Note: See TracChangeset
for help on using the changeset viewer.