Ticket #19570: 19570.17.diff
File 19570.17.diff, 24.4 KB (added by , 11 years ago) |
---|
-
wp-admin/css/wp-admin-rtl.css
diff --git wp-admin/css/wp-admin-rtl.css wp-admin/css/wp-admin-rtl.css index ba157f5..e04fafd 100644
TABLE OF CONTENTS: 23 23 11.1 - Custom Fields 24 24 11.2 - Post Revisions 25 25 11.3 - Featured Images 26 11.4 - Post Format Selection 26 27 12.0 - Categories 27 28 13.0 - Tags 28 29 14.0 - Media Screen … … table.diff td, table.diff th { 967 968 } 968 969 969 970 /*------------------------------------------------------------------------------ 971 11.4 - Post format selection 972 ------------------------------------------------------------------------------*/ 973 974 .post-format-options a { 975 border-left: 1px solid #ebebeb; 976 border-right: none; 977 } 978 979 .post-format-options a:first-child { 980 -webkit-border-bottom-left-radius: 0; 981 -webkit-border-top-left-radius: 0; 982 border-bottom-left-radius: 0; 983 border-top-left-radius: 0; 984 } 985 986 .post-format-options a:last-child { 987 -webkit-border-bottom-right-radius: 3px; 988 -webkit-border-top-right-radius: 3px; 989 border-bottom-right-radius: 3px; 990 border-top-right-radius: 3px; 991 } 992 993 .post-format-tip { 994 float: left; 995 } 996 997 /*------------------------------------------------------------------------------ 970 998 12.0 - Categories 971 999 ------------------------------------------------------------------------------*/ 972 1000 -
wp-admin/css/wp-admin.css
diff --git wp-admin/css/wp-admin.css wp-admin/css/wp-admin.css index 7fb44bc..e5535fe 100644
TABLE OF CONTENTS: 24 24 11.1 - Custom Fields 25 25 11.2 - Post Revisions 26 26 11.3 - Featured Images 27 11.4 - Post Format Selection 27 28 12.0 - Categories 28 29 13.0 - Tags 29 30 14.0 - Media Screen … … input#link_url { 3150 3151 display: none; 3151 3152 } 3152 3153 3154 .wp-format-gallery .post-formats-fields, 3155 .wp-format-image .post-formats-fields, 3153 3156 .wp-format-link .post-formats-fields, 3154 3157 .wp-format-quote .post-formats-fields, 3155 3158 .wp-format-video .post-formats-fields, 3156 3159 .wp-format-audio .post-formats-fields, 3160 .wp-format-gallery .field.wp-format-gallery, 3161 .wp-format-image .field.wp-format-image, 3157 3162 .wp-format-chat .field.wp-format-chat, 3158 3163 .wp-format-link .field.wp-format-link, 3159 3164 .wp-format-quote .field.wp-format-quote, … … input#link_url { 3165 3170 .post-formats-fields .field { 3166 3171 display: none; 3167 3172 margin-bottom: 10px; 3173 overflow: hidden; 3168 3174 } 3169 3175 3170 3176 .post-formats-fields input, … … input#link_url { 3173 3179 font-size: 1.2em; 3174 3180 } 3175 3181 3182 .wp-format-media-holder { 3183 float: left; 3184 overflow: hidden; 3185 width: 40%; 3186 height: 200px; 3187 border: 1px dashed #dfdfdf; 3188 background: #f5f5f5 url(../images/media-button-2x.png) no-repeat 50% 25%; 3189 } 3190 3191 .wp-format-media-holder.empty { 3192 height: auto; 3193 padding: 55px 0 20px; 3194 } 3195 3196 .wp-format-media-holder:hover { 3197 background-color: #eee; 3198 } 3199 3200 .wp-format-media-preview { 3201 margin-bottom: 20px; 3202 } 3203 3204 .has-media-preview .wp-format-media-holder, 3205 .has-media-preview audio, 3206 .has-media-preview video { 3207 display: none; 3208 } 3209 3210 .mejs-audio audio, 3211 .mejs-video video { 3212 display: block; 3213 } 3214 3215 .wp-format-media-select { 3216 display: block; 3217 height: 200px; 3218 text-align: center; 3219 } 3220 3221 .wp-format-media-select img { 3222 max-width: 100%; 3223 max-height: 100%; 3224 } 3225 3226 .empty .wp-format-media-select { 3227 height: 20px; 3228 } 3229 3230 .empty .wp-format-media-metaedit { 3231 height: 20px; 3232 display: block; 3233 text-align: center; 3234 } 3235 3236 .edit-format-preview { 3237 display: block; 3238 margin: 5px 0; 3239 } 3240 3241 #wp_format_audio, #wp_format_video { 3242 float: left; 3243 margin-right: 23px; 3244 max-width: 50%; 3245 min-height: 97px; 3246 } 3247 3176 3248 /* Post Screen */ 3177 3249 #post-body #normal-sortables { 3178 3250 min-height: 50px; … … body .ui-tooltip { 4066 4138 } 4067 4139 4068 4140 /*------------------------------------------------------------------------------ 4141 11.4 - Post format selection 4142 ------------------------------------------------------------------------------*/ 4143 4144 #icon-edit.standard { 4145 background: url(../images/post-formats32.png) no-repeat -3px -4px; 4146 } 4147 4148 #icon-edit.image { 4149 background: url(../images/post-formats32.png) no-repeat -43px -4px; 4150 } 4151 4152 #icon-edit.gallery { 4153 background: url(../images/post-formats32.png) no-repeat -83px -4px; 4154 } 4155 4156 #icon-edit.audio { 4157 background: url(../images/post-formats32.png) no-repeat -123px -4px; 4158 } 4159 4160 #icon-edit.video { 4161 background: url(../images/post-formats32.png) no-repeat -163px -4px; 4162 } 4163 4164 #icon-edit.chat { 4165 background: url(../images/post-formats32.png) no-repeat -202px -4px; 4166 } 4167 4168 #icon-edit.status { 4169 background: url(../images/post-formats32.png) no-repeat -242px -4px; 4170 } 4171 4172 #icon-edit.aside { 4173 background: url(../images/post-formats32.png) no-repeat -282px -4px; 4174 } 4175 4176 #icon-edit.quote { 4177 background: url(../images/post-formats32.png) no-repeat -322px -4px; 4178 } 4179 4180 #icon-edit.link { 4181 background: url(../images/post-formats32.png) no-repeat -362px -4px; 4182 } 4183 4184 .post-format-description { 4185 color: #666; 4186 display: none; 4187 margin: 10px 0; 4188 } 4189 4190 .post-format-options { 4191 height: 29px; 4192 background: #f9f9f9; 4193 border: 1px solid #dfdfdf; 4194 -webkit-border-radius: 3px; 4195 border-radius: 3px; 4196 margin: 0 0 9px 1px; 4197 padding: 0; 4198 } 4199 4200 .post-format-options a { 4201 border-right: 1px solid #ebebeb; 4202 display: inline-block; 4203 height: 16px; 4204 width: 16px; 4205 padding: 6px; 4206 position: relative; 4207 text-decoration: none; 4208 } 4209 4210 .post-format-options a:first-child { 4211 -webkit-border-bottom-left-radius: 3px; 4212 -webkit-border-top-left-radius: 3px; 4213 border-bottom-left-radius: 3px; 4214 border-top-left-radius: 3px; 4215 } 4216 4217 .post-format-options a.active, 4218 .post-format-options a:focus, 4219 .post-format-options a:hover { 4220 background: #fff; 4221 outline: none; 4222 opacity: 1; 4223 } 4224 4225 .post-format-options a div { 4226 height: 16px; 4227 width: 16px; 4228 opacity: 0.4; 4229 } 4230 4231 .post-format-options a.active div, 4232 .post-format-options a:focus div, 4233 .post-format-options a:hover div { 4234 opacity: 1; 4235 } 4236 4237 .post-format-options .standard { 4238 background: url(../images/post-formats.png) no-repeat -8px -8px; 4239 } 4240 4241 .post-format-options .image { 4242 background: url(../images/post-formats.png) no-repeat -40px -8px; 4243 } 4244 4245 .post-format-options .gallery { 4246 background: url(../images/post-formats.png) no-repeat -72px -8px; 4247 } 4248 4249 .post-format-options .audio { 4250 background: url(../images/post-formats.png) no-repeat -104px -8px; 4251 } 4252 4253 .post-format-options .video { 4254 background: url(../images/post-formats.png) no-repeat -136px -8px; 4255 } 4256 4257 .post-format-options .chat { 4258 background: url(../images/post-formats.png) no-repeat -168px -8px; 4259 } 4260 4261 .post-format-options .status { 4262 background: url(../images/post-formats.png) no-repeat -200px -8px; 4263 } 4264 4265 .post-format-options .aside { 4266 background: url(../images/post-formats.png) no-repeat -232px -8px; 4267 } 4268 4269 .post-format-options .quote { 4270 background: url(../images/post-formats.png) no-repeat -264px -8px; 4271 } 4272 4273 .post-format-options .link { 4274 background: url(../images/post-formats.png) no-repeat -296px -8px; 4275 } 4276 4277 .post-format-tip { 4278 color: #999; 4279 font-size: 14px; 4280 float: right; 4281 padding: 6px 10px; 4282 text-transform: capitalize; 4283 } 4284 4285 /*------------------------------------------------------------------------------ 4069 4286 12.0 - Categories 4070 4287 ------------------------------------------------------------------------------*/ 4071 4288 -
wp-admin/edit-form-advanced.php
diff --git wp-admin/edit-form-advanced.php wp-admin/edit-form-advanced.php index c7e8dc6..b8d90ce 100644
foreach ( get_object_taxonomies( $post ) as $tax_name ) { 130 130 $format_class = ''; 131 131 if ( post_type_supports( $post_type, 'post-formats' ) ) { 132 132 wp_enqueue_script( 'post-formats' ); 133 wp_enqueue_script( 'wp-mediaelement' ); 134 wp_enqueue_style( 'wp-mediaelement' ); 133 135 $post_format = get_post_format(); 134 136 135 137 if ( ! $post_format ) … … if ( post_type_supports( $post_type, 'post-formats' ) ) { 138 140 $format_class = " class='wp-format-{$post_format}'"; 139 141 } 140 142 143 if ( post_type_supports( $post_type, 'post-formats' ) ) { 144 $all_post_formats = array( 145 'standard' => array ( 146 'description' => __('Add a title and description for your post below.') 147 ), 148 'image' => array ( 149 'description' => __('Select an image for your post below.') 150 ), 151 'gallery' => array ( 152 'description' => __('Use the Add Media button below to select images for your gallery.') 153 ), 154 'link' => array ( 155 'description' => __('Add a link URL below.') 156 ), 157 'video' => array ( 158 'description' => __('Paste a video embed URL below, or upload a new video.') 159 ), 160 'audio' => array ( 161 'description' => __('Paste an audio embed URL below, or upload a new audio file.') 162 ), 163 'chat' => array ( 164 'description' => __('Paste a chat transcript below.') 165 ), 166 'status' => array ( 167 'description' => __('What are you up to? Enter your status message below.') 168 ), 169 'quote' => array ( 170 'description' => __('Enter a quote below.') 171 ), 172 'aside' => array ( 173 'description' => __('Enter a quick thought or side topic below.') 174 ) 175 ); 176 $post_format_options = ''; 177 178 foreach ( $all_post_formats as $slug => $attr ) { 179 $class = ''; 180 if ( $post_format == $slug ) { 181 $class = 'class="active"'; 182 $active_post_type_slug = $slug; 183 $active_post_type_label = ucfirst( $slug ); 184 $active_post_format_description = $attr['description']; 185 } 186 187 $post_format_options .= '<a ' . $class . ' href="?format=' . $slug . '" data-description="' . $attr['description'] . '" data-wp-format="' . $slug . '" title="' . ucfirst( sprintf( __( '%s Post' ), $slug ) ) . '"><div class="' . $slug . '"></div></a>'; 188 } 189 } 190 191 $current_post_format = array( 'currentPostFormat' => esc_html( $active_post_type_slug ) ); 192 wp_localize_script( 'post', 'postFormats', $current_post_format ); 193 141 194 if ( post_type_supports($post_type, 'page-attributes') ) 142 195 add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core'); 143 196 … … wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 337 390 ?> 338 391 339 392 <div id="poststuff"> 340 341 <?php342 if ( post_type_supports( $post_type, 'post-formats' ) ) {343 $all_post_formats = get_post_format_strings();344 345 echo '<h2 class="nav-tab-wrapper post-format-select">';346 347 foreach ( $all_post_formats as $slug => $label ) {348 if ( $post_format == $slug )349 $class = 'nav-tab nav-tab-active';350 else351 $class = 'nav-tab';352 353 echo '<a class="' . $class . '" href="?format=' . $slug . '" data-wp-format="' . $slug . '">' . $label . '</a>';354 }355 356 echo '</h2>';357 }358 ?>359 360 393 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 361 394 <div id="post-body-content"<?php echo $format_class; ?>> 362 395 396 <?php if ( ! empty( $post_format_options ) ) : ?> 397 <div class="post-format-options"> 398 <span class="post-format-tip">Standard Post</span> 399 <?php echo $post_format_options; ?> 400 </div> 401 <div class="post-format-description"></div> 402 <?php endif; ?> 403 363 404 <?php if ( post_type_supports($post_type, 'title') ) { ?> 364 405 <div id="titlediv"> 365 406 <div id="titlewrap"> … … if ( has_action( 'edit_form_after_title' ) ) { 398 439 } 399 440 400 441 // post format fields 401 if ( post_type_supports( $post_type, 'post-formats' ) ) { 402 $format_meta = get_post_format_meta( $post_ID ); 403 ?> 404 <div class="post-formats-fields edit-form-section"> 405 406 <input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" /> 407 408 <div class="field wp-format-quote"> 409 <label for="_wp_format_quote" class="screen-reader-text"><?php _e( 'Quote' ); ?>:</label> 410 <textarea name="_wp_format_quote" placeholder="<?php esc_attr_e( 'Quote' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 411 </div> 412 413 <div class="field wp-format-quote"> 414 <label for="_wp_format_quote_source" class="screen-reader-text"><?php _e( 'Quote source' ); ?>:</label> 415 <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" /> 416 </div> 417 418 <div class="field wp-format-link wp-format-quote"> 419 <label for="_wp_format_url" class="screen-reader-text"><?php _e( 'Link URL' ); ?>:</label> 420 <input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" placeholder="<?php esc_attr_e( 'Link URL' ); ?>" class="widefat" /> 421 </div> 422 423 <div class="field wp-format-audio wp-format-video"> 424 <label for="_wp_format_media" class="screen-reader-text"><?php _e( 'Embed code or URL' ); ?>:</label> 425 <textarea name="_wp_format_media" placeholder="<?php esc_attr_e( 'Embed code or URL' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['media'] ); ?></textarea> 426 </div> 427 428 </div> 429 <?php 430 } 442 if ( post_type_supports( $post_type, 'post-formats' ) ) 443 require_once( './includes/post-formats.php' ); 431 444 432 445 if ( post_type_supports($post_type, 'editor') ) { 433 446 ?> -
new file wp-admin/includes/post-formats.php
diff --git wp-admin/includes/post-formats.php wp-admin/includes/post-formats.php new file mode 100644 index 0000000..1c74990
- + 1 <?php 2 $format_meta = get_post_format_meta( $post_ID ); 3 4 ?> 5 <div class="post-formats-fields edit-form-section"> 6 7 <input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" /> 8 9 <div class="field wp-format-quote"> 10 <label for="_wp_format_quote" class="screen-reader-text"><?php _e( 'Quote' ); ?>:</label> 11 <textarea name="_wp_format_quote" placeholder="<?php esc_attr_e( 'Quote' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 12 </div> 13 14 <div class="field wp-format-quote"> 15 <label for="_wp_format_quote_source" class="screen-reader-text"><?php _e( 'Quote source' ); ?>:</label> 16 <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" /> 17 </div> 18 19 <?php 20 $image = false; 21 if ( isset( $format_meta['image'] ) ) 22 $image = is_numeric( $format_meta['image'] ) ? wp_get_attachment_url( $format_meta['image'] ) : $format_meta['image']; 23 ?> 24 <div class="field wp-format-image"> 25 <div data-format="image" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 26 <a href="#" class="wp-format-media-select" 27 data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>" 28 data-update="<?php esc_attr_e( 'Select Image' ); ?>"> 29 <?php 30 if ( $image ) 31 echo '<img src="' . esc_url( $image ) . '" />'; 32 else 33 _e( 'Select Image' ); 34 ?> 35 </a> 36 </div> 37 <label for="_wp_format_image" class="screen-reader-text"><?php _e( 'Image URL' ); ?>:</label> 38 <input id="wp_format_image" type="hidden" name="_wp_format_image" value="<?php echo esc_url( $format_meta['image'] ); ?>" placeholder="<?php esc_attr_e( 'Image URL' ); ?>" class="widefat" /> 39 </div> 40 41 <div class="field wp-format-link wp-format-quote wp-format-image"> 42 <label for="_wp_format_url" class="screen-reader-text"><?php _e( 'Link URL' ); ?>:</label> 43 <input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" placeholder="<?php esc_attr_e( 'Link URL' ); ?>" class="widefat" /> 44 </div> 45 46 <?php 47 $show_video_preview = ! empty( $format_meta['video'] ); 48 ?> 49 <div class="field wp-format-video<?php if ( $show_video_preview ) echo ' has-media-preview' ?>"> 50 <?php if ( $show_video_preview ): ?> 51 <div id="video-preview"> 52 <?php 53 if ( is_numeric( $format_meta['video'] ) ) { 54 $url = wp_get_attachment_url( $format_meta['video'] ); 55 echo do_shortcode( sprintf( '[video src="%s"]', $url ) ); 56 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $format_meta['video'] ) ) { 57 echo do_shortcode( $format_meta['video'] ); 58 } elseif ( ! preg_match( '#<[^>]+>#', $format_meta['video'] ) ) { 59 echo do_shortcode( sprintf( '[video src="%s"]', $format_meta['video'] ) ); 60 } else { 61 echo $format_meta['video']; 62 } 63 ?> 64 <a class="edit-format-preview" data-format="video" href="#">Update Media</a> 65 </div> 66 <?php endif ?> 67 <label for="_wp_format_video" class="screen-reader-text"><?php _e( 'Video Embed Code or URL' ); ?>:</label> 68 <textarea id="wp_format_video" type="text" name="_wp_format_video" placeholder="<?php esc_attr_e( 'Video Embed Code or URL' ); ?>" class="widefat"><?php esc_html_e( $format_meta['video'] ); ?></textarea> 69 <div data-format="video" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 70 <a href="#" class="wp-format-media-select" 71 data-choose="<?php esc_attr_e( 'Choose a Video' ); ?>" 72 data-update="<?php esc_attr_e( 'Select Video' ); ?>"> 73 <?php _e( 'Select Video From Media Library' ) ?> 74 </a> 75 </div> 76 </div> 77 78 <?php 79 $show_audio_preview = ! empty( $format_meta['audio'] ); 80 ?> 81 <div class="field wp-format-audio<?php if ( $show_audio_preview ) echo ' has-media-preview' ?>"> 82 <?php if ( $show_audio_preview ): ?> 83 <div id="audio-preview"> 84 <?php 85 if ( is_numeric( $format_meta['audio'] ) ) { 86 $url = wp_get_attachment_url( $format_meta['audio'] ); 87 echo do_shortcode( sprintf( '[audio src="%s"]', $url ) ); 88 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $format_meta['audio'] ) ) { 89 echo do_shortcode( $format_meta['audio'] ); 90 } elseif ( ! preg_match( '#<[^>]+>#', $format_meta['audio'] ) ) { 91 echo do_shortcode( sprintf( '[audio src="%s"]', $format_meta['audio'] ) ); 92 } else { 93 echo $format_meta['audio']; 94 } 95 ?> 96 <a class="edit-format-preview" data-format="audio" href="#">Update Media</a> 97 </div> 98 <?php endif ?> 99 <label for="_wp_format_audio" class="screen-reader-text"><?php _e( 'Audio Embed Code or URL' ); ?>:</label> 100 <textarea id="wp_format_audio" name="_wp_format_audio" placeholder="<?php esc_attr_e( 'Audio Embed Code or URL' ); ?>" class="widefat"><?php esc_html_e( $format_meta['audio'] ); ?></textarea> 101 <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( empty( $format_meta['audio'] ) ) echo ' empty'; ?>"> 102 <a href="#" class="wp-format-media-select" data-choose="<?php esc_attr_e( 'Choose Audio' ); ?>" data-update="<?php esc_attr_e( 'Select Audio' ); ?>"> 103 <?php _e( 'Select Audio From Media Library' ) ?> 104 </a> 105 </div> 106 </div> 107 </div> 108 No newline at end of file -
wp-admin/includes/post.php
diff --git wp-admin/includes/post.php wp-admin/includes/post.php index 6167b3e..2bf7b2b 100644
function edit_post( $post_data = null ) { 200 200 update_post_meta( $post_ID, '_wp_format_url', wp_slash( esc_url_raw( wp_unslash( $post_data['_wp_format_url'] ) ) ) ); 201 201 } 202 202 203 $format_keys = array( 'quote', 'quote_source', 'image', 'gallery', ' media' );203 $format_keys = array( 'quote', 'quote_source', 'image', 'gallery', 'image', 'gallery', 'audio', 'video' ); 204 204 205 205 foreach ( $format_keys as $key ) { 206 206 if ( isset( $post_data[ '_wp_format_' . $key ] ) ) -
wp-admin/js/post-formats.js
diff --git wp-admin/js/post-formats.js wp-admin/js/post-formats.js index 75f7f90..3cf5aa6 100644
1 (function($){ 1 window.wp = window.wp || {}; 2 3 (function($) { 4 var mediaFrame, lastMimeType, lastMenu, mediaPreview; 2 5 3 6 // Post formats selection 4 $('.post-format-select a').on( 'click.post-format', function(e) { 5 var $this = $(this), 6 editor, 7 body, 7 $('.post-format-options a').on( 'click', function(e){ 8 var $this = $(this), editor, body, 9 parent = $this.parent(), 8 10 format = $this.data('wp-format'), 9 container = $('#post-body-content'); 11 container = $('#post-body-content'), 12 description = $('.post-format-description'); 10 13 11 $('.post-format-select a.nav-tab-active').removeClass('nav-tab-active'); 12 $this.addClass('nav-tab-active').blur(); 14 parent.find('a.active').removeClass('active'); 15 $this.addClass('active'); 16 $('#icon-edit').removeClass(postFormats.currentPostFormat).addClass(format); 13 17 $('#post_format').val(format); 14 18 15 19 container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' ); 16 20 container.addClass('wp-format-' + format); 21 $('#title').focus(); 22 23 // Update description line 24 description.html($this.data('description')); 25 26 if (description.not(':visible')) 27 description.slideDown('fast'); 17 28 18 29 if ( typeof tinymce != 'undefined' ) { 19 30 editor = tinymce.get('content'); … … 25 36 } 26 37 } 27 38 39 postFormats.currentPostFormat = format; 40 28 41 e.preventDefault(); 42 }).on('mouseenter focusin', function () { 43 $('.post-format-tip').html( $(this).prop('title') ); 44 }).on('mouseleave focusout', function () { 45 $('.post-format-tip').html( $('.post-format-options a.active').prop('title') ); 46 }); 47 48 $('.post-formats-fields').on( 'click', '.edit-format-preview', function (e) { 49 e.preventDefault(); 50 var elem = $(e.currentTarget); 51 52 if ( elem.data('format') ) 53 $( '.wp-format-' + elem.data('format') + ' .wp-format-media-holder' ).addClass('empty').show(); 29 54 }); 30 55 31 })(jQuery); 56 // Media selection 57 $('.wp-format-media-select').click(function (event) { 58 event.preventDefault(); 59 var $el = $(this), $holder, $field, mime = 'image', menu = '', 60 $holder = $el.closest('.wp-format-media-holder'), 61 $field = $( '#wp_format_' + $holder.data('format') ); 62 63 switch ( $holder.data('format') ) { 64 case 'audio': 65 mime = 'audio'; 66 break; 67 case 'video': 68 mime = 'video'; 69 break; 70 } 71 72 if ( $('.wp-format-' + $holder.data('format') + ' .edit-format-preview').length ) 73 $holder.hide(); 74 75 // If the media frame already exists, reopen it. 76 if ( mediaFrame && lastMimeType === mime && lastMenu === menu ) { 77 mediaFrame.open(); 78 return; 79 } 80 81 lastMimeType = mime; 82 lastMenu = menu; 83 84 // Create the media frame. 85 mediaFrame = wp.media.frames.formatMedia = wp.media({ 86 // Set the title of the modal. 87 title: $el.data('choose'), 88 89 // Set the menu sidebar of the modal, if applicable 90 toolbar: menu, 91 92 // Tell the modal to show only items matching the current mime type. 93 library: { 94 type: mime 95 }, 96 97 // Customize the submit button. 98 button: { 99 // Set the text of the button. 100 text: $el.data('update') 101 } 102 }); 103 104 mediaPreview = function (format, url, mime) { 105 $('#' + format + '-preview').remove(); 106 $holder.parent().prepend( '<div id="' + format + '-preview" class="wp-format-media-preview">' + 107 '<' + format + ' class="wp-' + format + '-shortcode" controls="controls" preload="none">' + 108 '<source type="' + mime + '" src="' + url + '" />' + 109 '</' + format + '></div>' ); 110 $('.wp-' + format + '-shortcode').mediaelementplayer(); 111 }; 112 113 // When an image is selected, run a callback. 114 mediaFrame.on( 'select', function () { 115 // Grab the selected attachment. 116 var attachment = mediaFrame.state().get('selection').first(), mime, url, id; 117 118 id = attachment.get('id'); 119 url = attachment.get('url'); 120 mime = attachment.get('mime'); 121 122 if ( 0 === mime.indexOf('audio') ) { 123 $field.val(url); 124 // show one preview at a time 125 mediaPreview('audio', url, mime); 126 } else if ( 0 === mime.indexOf('video') ) { 127 $field.val(url); 128 // show one preview at a time 129 mediaPreview('video', url, mime); 130 } else { 131 // set the hidden input's value 132 $field.val(url); 133 // Show the image in the placeholder 134 $el.html('<img src="' + url + '" />'); 135 $holder.removeClass('empty').show(); 136 } 137 }); 138 139 mediaFrame.open(); 140 }); 141 })(jQuery); 142 No newline at end of file -
wp-includes/post-formats.php
diff --git wp-includes/post-formats.php wp-includes/post-formats.php index f83e08a..d4e99b6 100644
function get_post_format_meta( $post_id = 0 ) { 84 84 'quote' => '', 85 85 'quote_source' => '', 86 86 'url' => '', 87 'media' => '', 87 'image' => '', 88 'gallery' => '', 89 'audio' => '', 90 'video' => '', 88 91 ); 89 92 90 93 foreach ( $values as $key => $value ) … … function post_formats_compat( $content, $id = 0 ) { 355 358 case 'video': 356 359 case 'audio': 357 360 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['media'] ) ) { 361 // the metadata is an attachment ID 362 if ( is_numeric( $meta['media'] ) ) { 363 $url = wp_get_attachment_url( $meta['media'] ); 364 $format_output .= sprintf( '[%s src="%s"]', $format, $url ); 358 365 // the metadata is a shortcode or an embed code 359 if ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) {366 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) { 360 367 $format_output .= $meta['media']; 361 368 } elseif ( ! stristr( $content, $meta['media'] ) ) { 362 369 // attempt to embed the URL