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

git-svn-id: http://core.svn.wordpress.org/trunk@24264 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-05-15 20:43:09 +00:00
parent cf47737813
commit 7255abb66c
5 changed files with 37 additions and 22 deletions

View File

@ -95,6 +95,22 @@ if ( isset( $post ) && is_a( $post, 'WP_Post' ) && post_type_supports( get_post_
}
$admin_body_class .= ' wp-format-' . $post_format;
$show_post_format_ui = false;
if ( apply_filters( 'enable_post_format_ui', true, $post ) ) {
// If the user has explicitly set a screen option, use it, otherwise the UI is shown
// when the theme supports formats, or if the site has formats assigned to posts.
$post_format_user_option = get_user_option( 'post_formats_' . $post->post_type );
if ( false !== $post_format_user_option )
$show_post_format_ui = (bool) $post_format_user_option;
else
$show_post_format_ui = current_theme_supports( 'post-formats' ) || (bool) get_terms( 'post_format', array( 'number' => 1 ) );
}
if ( $show_post_format_ui )
$admin_body_class .= ' wp-post-format-show-ui';
}
if ( wp_is_mobile() )

View File

@ -3995,10 +3995,14 @@ body .ui-slider-tooltip {
padding-bottom: 0;
}
.no-ui {
.wp-post-format-ui {
display: none;
}
.wp-post-format-show-ui .wp-post-format-ui {
display: block;
}
.post-formats-fields {
display: none;
margin-bottom: 15px;
@ -4111,13 +4115,13 @@ body .ui-slider-tooltip {
text-align: center;
}
body.wp-format-image .attachment-display-settings,
body.wp-format-status #titlewrap,
body.wp-format-image .wp-media-buttons .insert-media,
body.wp-format-audio .wp-media-buttons .insert-media,
body.wp-format-video .wp-media-buttons .insert-media,
body.wp-format-aside .wp-media-buttons .insert-media,
body.wp-format-status .wp-media-buttons .insert-media {
.wp-post-format-show-ui.wp-format-image .attachment-display-settings,
.wp-post-format-show-ui.wp-format-status #titlewrap,
.wp-post-format-show-ui.wp-format-image #insert-media-button,
.wp-post-format-show-ui.wp-format-audio #insert-media-button,
.wp-post-format-show-ui.wp-format-video #insert-media-button,
.wp-post-format-show-ui.wp-format-aside #insert-media-button,
.wp-post-format-show-ui.wp-format-status #insert-media-button {
display: none;
}

View File

@ -130,7 +130,6 @@ foreach ( get_object_taxonomies( $post ) as $tax_name ) {
$format_class = '';
$post_format = '';
$post_format_options = '';
$show_post_format_ui = false;
if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'enable_post_format_ui', true, $post ) ) {
wp_enqueue_script( 'post-formats' );
wp_enqueue_script( 'wp-mediaelement' );
@ -144,15 +143,6 @@ if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'enable_
$post_format = $_REQUEST['format'];
}
$user_wants = get_user_option( 'post_formats_' . $post_type );
if ( false !== $user_wants ) {
// User wants what user gets.
$show_post_format_ui = (bool) $user_wants;
} else {
// UI is shown when the theme supports formats, or if the site has formats assigned to posts.
$show_post_format_ui = current_theme_supports( 'post-formats' ) || get_terms( 'post_format', array( 'number' => 1 ) );
}
$format_class = " class='wp-format-{$post_format}'";
$all_post_formats = array(
@ -389,7 +379,7 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create
<p><?php _e("You have lost your connection with the server, and saving has been disabled. This message will vanish once you've reconnected."); ?></p>
</div>
<?php if ( ! empty( $post_format_options ) ) : ?>
<div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>">
<div class="wp-post-format-ui">
<div class="post-format-options">
<?php echo $post_format_options; ?>
</div>
@ -422,7 +412,7 @@ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
<div id="post-body-content"<?php echo $format_class; ?>>
<?php if ( ! empty( $all_post_formats ) ) : ?>
<div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>">
<div class="wp-post-format-ui">
<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>
</div>
<?php endif; ?>

View File

@ -9,7 +9,7 @@ $format_meta = get_post_format_meta( $post_ID );
wp_nonce_field( 'show-post-format-ui_' . $post_type, 'show_post_format_ui_nonce', false );
?>
<div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>">
<div class="wp-post-format-ui">
<div class="post-formats-fields">
<input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" />

View File

@ -210,7 +210,12 @@ window.wp = window.wp || {};
}
$( '#show_post_format_ui' ).on( 'change', function () {
$( '.wp-post-format-ui' ).toggleClass( 'no-ui', ! this.checked );
body.toggleClass( 'wp-post-format-show-ui', this.checked );
// Reset the display properties of possibly hidden items.
insertMediaButton.css( 'display', '' );
$( '#titlewrap' ).css( 'display', '' );
$.post( ajaxurl, {
action: 'show-post-format-ui',
post_type: $( '#post_type' ).val(),