Ticket #19570: 19570.23.diff
File 19570.23.diff, 29.4 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin-rtl.css
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 … … 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
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 … … 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, … … 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, … … 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 .mejs-audio audio, 3205 .mejs-video video { 3206 display: block; 3207 } 3208 3209 .wp-format-media-select { 3210 display: block; 3211 height: 200px; 3212 text-align: center; 3213 } 3214 3215 .wp-format-media-select img { 3216 max-width: 100%; 3217 max-height: 100%; 3218 } 3219 3220 .empty .wp-format-media-select { 3221 height: 20px; 3222 } 3223 3224 .empty .wp-format-media-metaedit { 3225 height: 20px; 3226 display: block; 3227 text-align: center; 3228 } 3229 3230 .edit-format-preview { 3231 display: block; 3232 margin: 5px 0; 3233 } 3234 3235 #wp_format_audio, #wp_format_video { 3236 float: left; 3237 margin-right: 23px; 3238 max-width: 50%; 3239 min-height: 97px; 3240 } 3241 3176 3242 /* Post Screen */ 3177 3243 #post-body #normal-sortables { 3178 3244 min-height: 50px; … … 4066 4132 } 4067 4133 4068 4134 /*------------------------------------------------------------------------------ 4135 11.4 - Post format selection 4136 ------------------------------------------------------------------------------*/ 4137 4138 #icon-edit.standard { 4139 background: url(../images/post-formats32.png) no-repeat -3px -4px; 4140 } 4141 4142 #icon-edit.image { 4143 background: url(../images/post-formats32.png) no-repeat -43px -4px; 4144 } 4145 4146 #icon-edit.gallery { 4147 background: url(../images/post-formats32.png) no-repeat -83px -4px; 4148 } 4149 4150 #icon-edit.audio { 4151 background: url(../images/post-formats32.png) no-repeat -123px -4px; 4152 } 4153 4154 #icon-edit.video { 4155 background: url(../images/post-formats32.png) no-repeat -163px -4px; 4156 } 4157 4158 #icon-edit.chat { 4159 background: url(../images/post-formats32.png) no-repeat -202px -4px; 4160 } 4161 4162 #icon-edit.status { 4163 background: url(../images/post-formats32.png) no-repeat -242px -4px; 4164 } 4165 4166 #icon-edit.aside { 4167 background: url(../images/post-formats32.png) no-repeat -282px -4px; 4168 } 4169 4170 #icon-edit.quote { 4171 background: url(../images/post-formats32.png) no-repeat -322px -4px; 4172 } 4173 4174 #icon-edit.link { 4175 background: url(../images/post-formats32.png) no-repeat -362px -4px; 4176 } 4177 4178 .post-format-description { 4179 color: #666; 4180 display: none; 4181 margin: 10px 0; 4182 } 4183 4184 .post-format-options { 4185 height: 29px; 4186 background: #f9f9f9; 4187 border: 1px solid #dfdfdf; 4188 -webkit-border-radius: 3px; 4189 border-radius: 3px; 4190 margin: 0 0 9px 1px; 4191 padding: 0; 4192 } 4193 4194 .post-format-options a { 4195 border-right: 1px solid #ebebeb; 4196 display: inline-block; 4197 height: 16px; 4198 width: 16px; 4199 padding: 6px; 4200 position: relative; 4201 text-decoration: none; 4202 } 4203 4204 .post-format-options a:first-child { 4205 -webkit-border-bottom-left-radius: 3px; 4206 -webkit-border-top-left-radius: 3px; 4207 border-bottom-left-radius: 3px; 4208 border-top-left-radius: 3px; 4209 } 4210 4211 .post-format-options a.active, 4212 .post-format-options a:focus, 4213 .post-format-options a:hover { 4214 background: #fff; 4215 outline: none; 4216 opacity: 1; 4217 } 4218 4219 .post-format-options a div { 4220 height: 16px; 4221 width: 16px; 4222 opacity: 0.4; 4223 } 4224 4225 .post-format-options a.active div, 4226 .post-format-options a:focus div, 4227 .post-format-options a:hover div { 4228 opacity: 1; 4229 } 4230 4231 .post-format-options .standard { 4232 background: url(../images/post-formats.png) no-repeat -8px -8px; 4233 } 4234 4235 .post-format-options .image { 4236 background: url(../images/post-formats.png) no-repeat -40px -8px; 4237 } 4238 4239 .post-format-options .gallery { 4240 background: url(../images/post-formats.png) no-repeat -72px -8px; 4241 } 4242 4243 .post-format-options .audio { 4244 background: url(../images/post-formats.png) no-repeat -104px -8px; 4245 } 4246 4247 .post-format-options .video { 4248 background: url(../images/post-formats.png) no-repeat -136px -8px; 4249 } 4250 4251 .post-format-options .chat { 4252 background: url(../images/post-formats.png) no-repeat -168px -8px; 4253 } 4254 4255 .post-format-options .status { 4256 background: url(../images/post-formats.png) no-repeat -200px -8px; 4257 } 4258 4259 .post-format-options .aside { 4260 background: url(../images/post-formats.png) no-repeat -232px -8px; 4261 } 4262 4263 .post-format-options .quote { 4264 background: url(../images/post-formats.png) no-repeat -264px -8px; 4265 } 4266 4267 .post-format-options .link { 4268 background: url(../images/post-formats.png) no-repeat -296px -8px; 4269 } 4270 4271 .post-format-tip { 4272 color: #999; 4273 font-size: 14px; 4274 float: right; 4275 padding: 6px 10px; 4276 text-transform: capitalize; 4277 } 4278 4279 /*------------------------------------------------------------------------------ 4069 4280 12.0 - Categories 4070 4281 ------------------------------------------------------------------------------*/ 4071 4282 -
wp-admin/edit-form-advanced.php
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 ) … … 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 use the editor to compose your post.' ) 147 ), 148 'image' => array ( 149 'description' => __( 'Select or upload an image to use for your post.' ) 150 ), 151 'gallery' => array ( 152 'description' => __( 'Use the Add Media button to select or upload 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 into the box, upload a video file, or choose one from your Media Library.' ) 159 ), 160 'audio' => array ( 161 'description' => __( 'Paste an audio embed into the box, upload an audio file, or choose one from your Media Library.' ) 162 ), 163 'chat' => array ( 164 'description' => __( 'Copy a chat or Q&A transcript into the editor.' ) 165 ), 166 'status' => array ( 167 'description' => __( 'Use the editor to compose a status update. What’s new?' ) 168 ), 169 'quote' => array ( 170 'description' => __( 'Copy a quotation into the box. Also add the source and URL if you have them.' ) 171 ), 172 'aside' => array ( 173 'description' => __( 'An aside is a quick thought or side topic. Use the editor to compose one.' ) 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 … … 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 <?php endif; ?> 402 363 403 <?php if ( post_type_supports($post_type, 'title') ) { ?> 364 404 <div id="titlediv"> 365 405 <div id="titlewrap"> … … 373 413 if ( !empty($shortlink) ) 374 414 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 375 415 376 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 377 <div id="edit-slug-box" class="hide-if-no-js"> 416 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { 417 $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status; 418 ?> 419 <div id="edit-slug-box" class="hide-if-no-js<?php if ( ! $has_sample_permalink ) echo ' hidden' ?>"> 378 420 <?php 379 if ( $ sample_permalink_html && 'auto-draft' != $post->post_status)421 if ( $has_sample_permalink ) 380 422 echo $sample_permalink_html; 381 423 ?> 382 424 </div> … … 398 440 } 399 441 400 442 // 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"> 443 if ( post_type_supports( $post_type, 'post-formats' ) ) 444 require_once( './includes/post-formats.php' ); 405 445 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 <?php430 }431 432 446 if ( post_type_supports($post_type, 'editor') ) { 433 447 ?> 434 448 <div id="postdivrich" class="postarea edit-form-section"> -
wp-admin/includes/post-formats.php
1 <?php 2 global $wp_embed; 3 $format_meta = get_post_format_meta( $post_ID ); 4 5 ?> 6 <div class="post-format-description"></div> 7 <div class="post-formats-fields edit-form-section"> 8 9 <input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" /> 10 11 <div class="field wp-format-quote"> 12 <label for="_wp_format_quote" class="screen-reader-text"><?php _e( 'Quote' ); ?>:</label> 13 <textarea name="_wp_format_quote" placeholder="<?php esc_attr_e( 'Quote' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 14 </div> 15 16 <div class="field wp-format-quote"> 17 <label for="_wp_format_quote_source" class="screen-reader-text"><?php _e( 'Quote source' ); ?>:</label> 18 <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" /> 19 </div> 20 21 <?php 22 $image = false; 23 if ( isset( $format_meta['image'] ) ) 24 $image = is_numeric( $format_meta['image'] ) ? wp_get_attachment_url( $format_meta['image'] ) : $format_meta['image']; 25 ?> 26 <div class="field wp-format-image"> 27 <div data-format="image" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 28 <a href="#" class="wp-format-media-select" 29 data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>" 30 data-update="<?php esc_attr_e( 'Select Image' ); ?>"> 31 <?php 32 if ( $image ) 33 echo '<img src="' . esc_url( $image ) . '" />'; 34 else 35 _e( 'Select / Upload Image' ); 36 ?> 37 </a> 38 </div> 39 <label for="_wp_format_image" class="screen-reader-text"><?php _e( 'Image URL' ); ?>:</label> 40 <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" /> 41 </div> 42 43 <div class="field wp-format-link wp-format-quote wp-format-image"> 44 <label for="_wp_format_url" class="screen-reader-text"><?php _e( 'Link URL' ); ?>:</label> 45 <input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" placeholder="<?php esc_attr_e( 'Link URL' ); ?>" class="widefat" /> 46 </div> 47 48 <?php 49 $show_video_preview = ! empty( $format_meta['video'] ); 50 ?> 51 <div class="field wp-format-video<?php if ( $show_video_preview ) echo ' has-media-preview' ?>"> 52 <?php if ( $show_video_preview ): ?> 53 <div id="video-preview" class="wp-format-media-preview"> 54 <?php 55 if ( is_numeric( $format_meta['video'] ) ) { 56 $url = wp_get_attachment_url( $format_meta['video'] ); 57 echo do_shortcode( sprintf( '[video src="%s"]', $url ) ); 58 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $format_meta['video'] ) ) { 59 echo do_shortcode( $format_meta['video'] ); 60 } elseif ( ! preg_match( '#<[^>]+>#', $format_meta['video'] ) ) { 61 if ( strstr( $format_meta['video'], home_url() ) ) 62 echo do_shortcode( sprintf( '[video src="%s"]', $format_meta['video'] ) ); 63 else 64 echo $wp_embed->autoembed( $format_meta['video'] ); 65 } else { 66 echo $format_meta['video']; 67 } 68 ?> 69 </div> 70 <?php endif ?> 71 <label for="_wp_format_video" class="screen-reader-text"><?php _e( 'Video embed code or URL' ); ?>:</label> 72 <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> 73 <div data-format="video" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 74 <a href="#" class="wp-format-media-select" 75 data-choose="<?php esc_attr_e( 'Choose a Video' ); ?>" 76 data-update="<?php esc_attr_e( 'Select Video' ); ?>"> 77 <?php _e( 'Select Video From Media Library' ) ?> 78 </a> 79 </div> 80 </div> 81 82 <?php 83 $show_audio_preview = ! empty( $format_meta['audio'] ); 84 ?> 85 <div class="field wp-format-audio<?php if ( $show_audio_preview ) echo ' has-media-preview' ?>"> 86 <?php if ( $show_audio_preview ): ?> 87 <div id="audio-preview" class="wp-format-media-preview"> 88 <?php 89 if ( is_numeric( $format_meta['audio'] ) ) { 90 $url = wp_get_attachment_url( $format_meta['audio'] ); 91 echo do_shortcode( sprintf( '[audio src="%s"]', $url ) ); 92 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $format_meta['audio'] ) ) { 93 echo do_shortcode( $format_meta['audio'] ); 94 } elseif ( ! preg_match( '#<[^>]+>#', $format_meta['audio'] ) ) { 95 if ( strstr( $format_meta['audio'], home_url() ) ) 96 echo do_shortcode( sprintf( '[audio src="%s"]', $format_meta['audio'] ) ); 97 else 98 echo $wp_embed->autoembed( $format_meta['audio'] ); 99 } else { 100 echo $format_meta['audio']; 101 } 102 ?> 103 </div> 104 <?php endif ?> 105 <label for="_wp_format_audio" class="screen-reader-text"><?php _e( 'Audio embed code or URL' ); ?>:</label> 106 <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'] ); 107 ?></textarea> 108 <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( empty( $format_meta['audio'] ) ) echo ' empty'; ?>"> 109 <a href="#" class="wp-format-media-select" data-choose="<?php esc_attr_e( 'Choose Audio' ); ?>" data-update="<?php esc_attr_e( 'Select Audio' ); ?>"> 110 <?php _e( 'Select Audio From Media Library' ) ?> 111 </a> 112 </div> 113 </div> 114 </div> 115 No newline at end of file -
wp-admin/includes/post.php
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/includes/screen.php
142 142 * 143 143 * @since 3.2.0 144 144 * 145 * @global $post_ID 145 146 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) 146 147 * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. 147 148 * @return string HTML for the screen icon. 148 149 */ 149 150 function get_screen_icon( $screen = '' ) { 151 global $post_ID; 150 152 if ( empty( $screen ) ) 151 153 $screen = get_current_screen(); 152 154 elseif ( is_string( $screen ) ) … … 165 167 166 168 if ( $screen->post_type ) 167 169 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type ); 170 171 if ( $post_ID ) { 172 $format = get_post_format( $post_ID ); 173 if ( $format ) 174 $class .= ' ' . $format; 175 } 168 176 } 169 177 170 178 return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>'; -
wp-admin/js/post-formats.js
1 (function($){ 1 window.wp = window.wp || {}; 2 2 3 (function($) { 4 var mediaFrame, lastMimeType, lastMenu, mediaPreview; 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(); 17 22 23 // Update description line 24 description.html($this.data('description')); 25 26 if (description.not(':visible')) 27 description.slideDown('fast'); 28 18 29 if ( typeof tinymce != 'undefined' ) { 19 30 editor = tinymce.get('content'); 20 31 … … 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') ); 29 46 }); 30 47 31 })(jQuery); 48 // Media selection 49 $('.wp-format-media-select').click(function (event) { 50 event.preventDefault(); 51 var $el = $(this), $holder, $field, mime = 'image', menu = '', 52 $holder = $el.closest('.wp-format-media-holder'), 53 $field = $( '#wp_format_' + $holder.data('format') ); 54 55 switch ( $holder.data('format') ) { 56 case 'audio': 57 mime = 'audio'; 58 break; 59 case 'video': 60 mime = 'video'; 61 break; 62 } 63 64 // If the media frame already exists, reopen it. 65 if ( mediaFrame && lastMimeType === mime && lastMenu === menu ) { 66 mediaFrame.open(); 67 return; 68 } 69 70 lastMimeType = mime; 71 lastMenu = menu; 72 73 // Create the media frame. 74 mediaFrame = wp.media.frames.formatMedia = wp.media({ 75 // Set the title of the modal. 76 title: $el.data('choose'), 77 78 // Set the menu sidebar of the modal, if applicable 79 toolbar: menu, 80 81 // Tell the modal to show only items matching the current mime type. 82 library: { 83 type: mime 84 }, 85 86 // Customize the submit button. 87 button: { 88 // Set the text of the button. 89 text: $el.data('update') 90 } 91 }); 92 93 mediaPreview = function (format, url, mime) { 94 $('#' + format + '-preview').remove(); 95 $holder.parent().prepend( '<div id="' + format + '-preview" class="wp-format-media-preview">' + 96 '<' + format + ' class="wp-' + format + '-shortcode" controls="controls" preload="none">' + 97 '<source type="' + mime + '" src="' + url + '" />' + 98 '</' + format + '></div>' ); 99 $('.wp-' + format + '-shortcode').mediaelementplayer(); 100 }; 101 102 // When an image is selected, run a callback. 103 mediaFrame.on( 'select', function () { 104 // Grab the selected attachment. 105 var attachment = mediaFrame.state().get('selection').first(), mime, url, id; 106 107 id = attachment.get('id'); 108 url = attachment.get('url'); 109 mime = attachment.get('mime'); 110 111 if ( 0 === mime.indexOf('audio') ) { 112 $field.val(url); 113 // show one preview at a time 114 mediaPreview('audio', url, mime); 115 } else if ( 0 === mime.indexOf('video') ) { 116 $field.val(url); 117 // show one preview at a time 118 mediaPreview('video', url, mime); 119 } else { 120 // set the hidden input's value 121 $field.val(url); 122 // Show the image in the placeholder 123 $el.html('<img src="' + url + '" />'); 124 $holder.removeClass('empty').show(); 125 } 126 }); 127 128 mediaFrame.open(); 129 }); 130 })(jQuery); 131 No newline at end of file -
wp-admin/js/post.js
641 641 new_title: $('#title').val(), 642 642 samplepermalinknonce: $('#samplepermalinknonce').val() 643 643 }, function(data) { 644 $('#edit-slug-box').html(data); 644 var box = $('#edit-slug-box'); 645 box.html(data); 646 if (box.hasClass('hidden')) { 647 box.fadeIn('fast', function () { 648 box.removeClass('hidden'); 649 }); 650 } 645 651 b.html(revert_b); 646 652 real_slug.val(new_slug); 647 653 makeSlugeditClickable(); -
wp-includes/js/autosave.js
199 199 }, 200 200 function(data) { 201 201 if ( data !== '-1' ) { 202 jQuery('#edit-slug-box').html(data); 202 var box = jQuery('#edit-slug-box'); 203 box.html(data); 204 if (box.hasClass('hidden')) { 205 box.fadeIn('fast', function () { 206 box.removeClass('hidden'); 207 }); 208 } 203 209 makeSlugeditClickable(); 204 210 } 205 211 } -
wp-includes/media.php
2043 2043 2044 2044 if ( has_post_format( $type ) ) { 2045 2045 $meta = get_post_format_meta( $post->ID ); 2046 if ( ! empty( $meta[ 'media'] ) ) {2047 if ( is_ numeric( $meta['media'] ) ) {2048 $url = wp_get_attachment_url( $meta[ 'media'] );2046 if ( ! empty( $meta[$type] ) ) { 2047 if ( is_integer( $meta[$type] ) ) { 2048 $url = wp_get_attachment_url( $meta[$type] ); 2049 2049 $shortcode = sprintf( '[%s src="%s"]', $type, $url ); 2050 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $meta[ 'media'] ) ) {2051 $shortcode = $meta[ 'media'];2052 } elseif ( preg_match( '#<[^>]+>#', $meta[ 'media'] ) ) {2053 $post->format_content = $meta[ 'media'];2050 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $meta[$type] ) ) { 2051 $shortcode = $meta[$type]; 2052 } elseif ( preg_match( '#<[^>]+>#', $meta[$type] ) ) { 2053 $post->format_content = $meta[$type]; 2054 2054 return $post->format_content; 2055 } elseif ( 0 === strpos( $meta[ 'media'], 'http' ) ) {2056 $post->split_content = str_replace( $meta[ 'media'], '', $post->post_content, $count );2057 if ( strstr( $meta[ 'media'], home_url() ) ) {2058 $shortcode = sprintf( '[%s src="%s"]', $type, $meta[ 'media'] );2055 } elseif ( 0 === strpos( $meta[$type], 'http' ) ) { 2056 $post->split_content = str_replace( $meta[$type], '', $post->post_content, $count ); 2057 if ( strstr( $meta[$type], home_url() ) ) { 2058 $shortcode = sprintf( '[%s src="%s"]', $type, $meta[$type] ); 2059 2059 } else { 2060 $post->format_content = $wp_embed->autoembed( $meta[ 'media'] );2060 $post->format_content = $wp_embed->autoembed( $meta[$type] ); 2061 2061 return $post->format_content; 2062 2062 } 2063 2063 } -
wp-includes/post-formats.php
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 ) … … 351 354 352 355 case 'video': 353 356 case 'audio': 354 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['media'] ) ) { 357 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta[$format] ) ) { 358 // the metadata is an attachment ID 359 if ( is_numeric( $meta[$format] ) ) { 360 $url = wp_get_attachment_url( $meta[$format] ); 361 $format_output .= sprintf( '[%s src="%s"]', $format, $url ); 355 362 // the metadata is a shortcode or an embed code 356 if ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) {357 $format_output .= $meta[ 'media'];358 } elseif ( ! stristr( $content, $meta[ 'media'] ) ) {363 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $meta[$format] ) || preg_match( '#<[^>]+>#', $meta[$format] ) ) { 364 $format_output .= $meta[$format]; 365 } elseif ( ! stristr( $content, $meta[$format] ) ) { 359 366 // attempt to embed the URL 360 $format_output .= sprintf( '[embed]%s[/embed]', $meta[ 'media'] );367 $format_output .= sprintf( '[embed]%s[/embed]', $meta[$format] ); 361 368 } 362 369 } 363 370 break;