Remove separate meta fields for image and gallery post formats. These are proving to be more confusing and labor-intensive from both a user and dev perspective than entering into the regular content editor. We will rely on good content parsing instead. See #19570, #23347.
git-svn-id: http://core.svn.wordpress.org/trunk@23753 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
57b2fc1c04
commit
25c272856b
|
@ -3097,13 +3097,22 @@ input#link_url {
|
|||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.wp-format-standard .post-formats-fields,
|
||||
.wp-format-aside .post-formats-fields,
|
||||
.wp-format-chat .post-formats-fields,
|
||||
.wp-format-status .post-formats-fields {
|
||||
.post-formats-fields {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wp-format-link .post-formats-fields,
|
||||
.wp-format-quote .post-formats-fields,
|
||||
.wp-format-video .post-formats-fields,
|
||||
.wp-format-audio .post-formats-fields,
|
||||
.wp-format-chat .field.wp-format-chat,
|
||||
.wp-format-link .field.wp-format-link,
|
||||
.wp-format-quote .field.wp-format-quote,
|
||||
.wp-format-video .field.wp-format-video,
|
||||
.wp-format-audio .field.wp-format-audio {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.post-formats-fields .field {
|
||||
display: none;
|
||||
margin-bottom: 10px;
|
||||
|
@ -3115,45 +3124,6 @@ input#link_url {
|
|||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.wp-format-chat .field.wp-format-chat,
|
||||
.wp-format-gallery .field.wp-format-gallery,
|
||||
.wp-format-link .field.wp-format-link,
|
||||
.wp-format-image .field.wp-format-image,
|
||||
.wp-format-quote .field.wp-format-quote,
|
||||
.wp-format-video .field.wp-format-video,
|
||||
.wp-format-audio .field.wp-format-audio {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#wp-format-image-holder {
|
||||
overflow: hidden;
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
border: 1px solid #dfdfdf;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
#wp-format-image-holder:hover {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#wp-format-image-select {
|
||||
display: block;
|
||||
height: 200px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#wp-format-image-select img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.empty #wp-format-image-select {
|
||||
padding-top: 120px;
|
||||
height: 80px;
|
||||
background: url(../images/media-button-2x.png) no-repeat center;
|
||||
}
|
||||
|
||||
/* Post Screen */
|
||||
#post-body #normal-sortables {
|
||||
min-height: 50px;
|
||||
|
|
|
@ -393,11 +393,6 @@ if ( has_action( 'edit_form_after_title' ) ) {
|
|||
// post format fields
|
||||
if ( post_type_supports( $post_type, 'post-formats' ) ) {
|
||||
$format_meta = get_post_format_meta( $post_ID );
|
||||
|
||||
if ( isset( $format_meta['image'] ) )
|
||||
$image = is_numeric( $format_meta['image'] ) ? wp_get_attachment_url( $format_meta['image'] ) : $format_meta['image'];
|
||||
else
|
||||
$image = false;
|
||||
?>
|
||||
<div class="post-formats-fields edit-form-section">
|
||||
|
||||
|
@ -413,33 +408,11 @@ else
|
|||
<input type="text" name="_wp_format_quote_source" value="<?php echo esc_attr( $format_meta['quote_source'] ); ?>" placeholder="<?php esc_attr_e( 'Quote source' ); ?>" class="widefat" />
|
||||
</div>
|
||||
|
||||
<div class="field wp-format-image">
|
||||
<div id="wp-format-image-holder" class="hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>">
|
||||
<a href="#" id="wp-format-image-select"
|
||||
data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>"
|
||||
data-update="<?php esc_attr_e( 'Select Image' ); ?>">
|
||||
<?php
|
||||
if ( $image )
|
||||
echo '<img src="' . esc_url( $image ) . '" />';
|
||||
else
|
||||
_e( 'Select Image' );
|
||||
?>
|
||||
</a>
|
||||
</div>
|
||||
<label for="_wp_format_image" class="screen-reader-text"><?php _e( 'Image ID or URL' ); ?>:</label>
|
||||
<input type="text" name="_wp_format_image" id="wp_format_image" value="<?php echo esc_attr( $format_meta['image'] ); ?>" placeholder="<?php esc_attr_e( 'Image ID or URL' ); ?>" class="widefat hide-if-js" />
|
||||
</div>
|
||||
|
||||
<div class="field wp-format-link wp-format-quote wp-format-image">
|
||||
<div class="field wp-format-link wp-format-quote">
|
||||
<label for="_wp_format_url" class="screen-reader-text"><?php _e( 'Link URL' ); ?>:</label>
|
||||
<input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" placeholder="<?php esc_attr_e( 'Link URL' ); ?>" class="widefat" />
|
||||
</div>
|
||||
|
||||
<div class="field wp-format-gallery">
|
||||
<label for="_wp_format_gallery" class="screen-reader-text"><?php _e( 'Gallery shortcode' ); ?>:</label>
|
||||
<input type="text" name="_wp_format_gallery" id="wp_format_gallery" value="<?php echo esc_attr( $format_meta['gallery'] ); ?>" placeholder="<?php esc_attr_e( 'Gallery shortcode' ); ?>" class="widefat" />
|
||||
</div>
|
||||
|
||||
<div class="field wp-format-audio wp-format-video">
|
||||
<label for="_wp_format_media" class="screen-reader-text"><?php _e( 'Embed code or URL' ); ?>:</label>
|
||||
<textarea name="_wp_format_media" placeholder="<?php esc_attr_e( 'Embed code or URL' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['media'] ); ?></textarea>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
window.wp = window.wp || {};
|
||||
|
||||
(function($){
|
||||
var imageFrame;
|
||||
|
||||
// Post formats selection
|
||||
$('.post-format-select a').on( 'click.post-format', function(e) {
|
||||
var $this = $(this), editor, body,
|
||||
format = $this.data('wp-format'), container = $('#post-body-content');
|
||||
var $this = $(this),
|
||||
editor,
|
||||
body,
|
||||
format = $this.data('wp-format'),
|
||||
container = $('#post-body-content');
|
||||
|
||||
$('.post-format-select a.nav-tab-active').removeClass('nav-tab-active');
|
||||
$this.addClass('nav-tab-active').blur();
|
||||
|
@ -28,50 +28,4 @@ window.wp = window.wp || {};
|
|||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Image selection
|
||||
$('#wp-format-image-select').click( function( event ) {
|
||||
var $el = $(this),
|
||||
$holder = $('#wp-format-image-holder'),
|
||||
$field = $('#wp_format_image');
|
||||
event.preventDefault();
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( imageFrame ) {
|
||||
imageFrame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the media frame.
|
||||
imageFrame = wp.media.frames.formatImage = wp.media({
|
||||
// Set the title of the modal.
|
||||
title: $el.data('choose'),
|
||||
|
||||
// Tell the modal to show only images.
|
||||
library: {
|
||||
type: 'image'
|
||||
},
|
||||
|
||||
// Customize the submit button.
|
||||
button: {
|
||||
// Set the text of the button.
|
||||
text: $el.data('update')
|
||||
}
|
||||
});
|
||||
|
||||
// When an image is selected, run a callback.
|
||||
imageFrame.on( 'select', function() {
|
||||
// Grab the selected attachment.
|
||||
var attachment = imageFrame.state().get('selection').first(),
|
||||
imageUrl = attachment.get('url');
|
||||
|
||||
// set the hidden input's value
|
||||
$field.attr('value', attachment.id);
|
||||
|
||||
// Show the image in the placeholder
|
||||
$el.html('<img src="' + imageUrl + '" />');
|
||||
$holder.removeClass('empty');
|
||||
});
|
||||
|
||||
imageFrame.open();
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
@ -83,9 +83,7 @@ function get_post_format_meta( $post_id = 0 ) {
|
|||
$values = array(
|
||||
'quote' => '',
|
||||
'quote_source' => '',
|
||||
'image' => '',
|
||||
'url' => '',
|
||||
'gallery' => '',
|
||||
'media' => '',
|
||||
);
|
||||
|
||||
|
@ -299,7 +297,6 @@ function post_formats_compat( $content, $id = 0 ) {
|
|||
'tag' => 'div',
|
||||
'class' => get_post_format_content_class( $format ),
|
||||
'link_class' => '',
|
||||
'image_class' => '',
|
||||
);
|
||||
|
||||
$args = apply_filters( 'post_format_compat', array() );
|
||||
|
@ -343,34 +340,6 @@ function post_formats_compat( $content, $id = 0 ) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
if ( ! empty( $meta['image'] ) ) {
|
||||
$image = is_numeric( $meta['image'] ) ? wp_get_attachment_url( $meta['image'] ) : $meta['image'];
|
||||
|
||||
if ( ! empty( $image ) && ! stristr( $content, $image ) ) {
|
||||
$image_html = sprintf(
|
||||
'<img %ssrc="%s" alt="" />',
|
||||
empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
|
||||
$image
|
||||
);
|
||||
if ( empty( $meta['url'] ) ) {
|
||||
$format_output .= $image_html;
|
||||
} else {
|
||||
$format_output .= sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( $meta['url'] ),
|
||||
$image_html
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'gallery':
|
||||
if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['gallery'] ) )
|
||||
$format_output .= $meta['gallery'];
|
||||
break;
|
||||
|
||||
case 'video':
|
||||
case 'audio':
|
||||
if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['media'] ) ) {
|
||||
|
|
Loading…
Reference in New Issue