Make WordPress Core

Changeset 24264


Ignore:
Timestamp:
05/15/2013 08:43:09 PM (13 years ago)
Author:
azaozz
Message:

Fix showing and hiding of UI elements when disabling the Post Formats UI, props kovshenin, see #24327

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r24243 r24264  
    9696
    9797    $admin_body_class .= ' wp-format-' . $post_format;
     98
     99    $show_post_format_ui = false;
     100
     101    if ( apply_filters( 'enable_post_format_ui', true, $post ) ) {
     102
     103        // If the user has explicitly set a screen option, use it, otherwise the UI is shown
     104        // when the theme supports formats, or if the site has formats assigned to posts.
     105        $post_format_user_option = get_user_option( 'post_formats_' . $post->post_type );
     106        if ( false !== $post_format_user_option )
     107            $show_post_format_ui = (bool) $post_format_user_option;
     108        else
     109            $show_post_format_ui = current_theme_supports( 'post-formats' ) || (bool) get_terms( 'post_format', array( 'number' => 1 ) );
     110    }
     111
     112    if ( $show_post_format_ui )
     113        $admin_body_class .= ' wp-post-format-show-ui';
    98114}
    99115
  • trunk/wp-admin/css/wp-admin.css

    r24258 r24264  
    39963996}
    39973997
    3998 .no-ui {
     3998.wp-post-format-ui {
    39993999    display: none;
     4000}
     4001
     4002.wp-post-format-show-ui .wp-post-format-ui {
     4003    display: block;
    40004004}
    40014005
     
    41124116}
    41134117
    4114 body.wp-format-image .attachment-display-settings,
    4115 body.wp-format-status #titlewrap,
    4116 body.wp-format-image .wp-media-buttons .insert-media,
    4117 body.wp-format-audio .wp-media-buttons .insert-media,
    4118 body.wp-format-video .wp-media-buttons .insert-media,
    4119 body.wp-format-aside .wp-media-buttons .insert-media,
    4120 body.wp-format-status .wp-media-buttons .insert-media {
     4118.wp-post-format-show-ui.wp-format-image .attachment-display-settings,
     4119.wp-post-format-show-ui.wp-format-status #titlewrap,
     4120.wp-post-format-show-ui.wp-format-image #insert-media-button,
     4121.wp-post-format-show-ui.wp-format-audio #insert-media-button,
     4122.wp-post-format-show-ui.wp-format-video #insert-media-button,
     4123.wp-post-format-show-ui.wp-format-aside #insert-media-button,
     4124.wp-post-format-show-ui.wp-format-status #insert-media-button {
    41214125    display: none;
    41224126}
  • trunk/wp-admin/edit-form-advanced.php

    r24184 r24264  
    131131$post_format = '';
    132132$post_format_options = '';
    133 $show_post_format_ui = false;
    134133if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'enable_post_format_ui', true, $post ) ) {
    135134    wp_enqueue_script( 'post-formats' );
     
    143142        if ( ! empty( $_REQUEST['format'] ) && in_array( $_REQUEST['format'], get_post_format_slugs() ) )
    144143            $post_format = $_REQUEST['format'];
    145     }
    146 
    147     $user_wants = get_user_option( 'post_formats_' . $post_type );
    148     if ( false !== $user_wants ) {
    149         // User wants what user gets.
    150         $show_post_format_ui = (bool) $user_wants;
    151     } else {
    152         // UI is shown when the theme supports formats, or if the site has formats assigned to posts.
    153         $show_post_format_ui = current_theme_supports( 'post-formats' ) || get_terms( 'post_format', array( 'number' => 1 ) );
    154144    }
    155145
     
    390380</div>
    391381<?php if ( ! empty( $post_format_options ) ) : ?>
    392 <div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>">
     382<div class="wp-post-format-ui">
    393383    <div class="post-format-options">
    394384        <?php echo $post_format_options; ?>
     
    423413<div id="post-body-content"<?php echo $format_class; ?>>
    424414<?php if ( ! empty( $all_post_formats ) ) : ?>
    425 <div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>">
     415<div class="wp-post-format-ui">
    426416    <div class="post-format-change"><span class="icon <?php echo esc_attr( 'wp-format-' . $post_format ); ?>"></span> <span class="post-format-description"><?php echo $all_post_formats[$post_format]['description']; ?></span></div>
    427417</div>
  • trunk/wp-admin/includes/post-formats.php

    r24258 r24264  
    1010
    1111?>
    12 <div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>">
     12<div class="wp-post-format-ui">
    1313    <div class="post-formats-fields">
    1414
  • trunk/wp-admin/js/post-formats.js

    r24236 r24264  
    211211
    212212        $( '#show_post_format_ui' ).on( 'change', function () {
    213             $( '.wp-post-format-ui' ).toggleClass( 'no-ui', ! this.checked );
     213            body.toggleClass( 'wp-post-format-show-ui', this.checked );
     214
     215            // Reset the display properties of possibly hidden items.
     216            insertMediaButton.css( 'display', '' );
     217            $( '#titlewrap' ).css( 'display', '' );
     218
    214219            $.post( ajaxurl, {
    215220                action: 'show-post-format-ui',
Note: See TracChangeset for help on using the changeset viewer.