Ticket #19570: 19570.5.diff
File 19570.5.diff, 11.7 KB (added by , 12 years ago) |
---|
-
wp-includes/post.php
1899 1899 } 1900 1900 1901 1901 /** 1902 * Retrieve metadata for current post format 1903 * 1904 * @since 3.6.0 1905 * 1906 * @param int $post_id 1907 * @return null 1908 */ 1909 function get_post_format_meta( $post_id = 0 ) { 1910 $keys = get_post_meta( $post_id ); 1911 if ( empty( $keys ) ) 1912 return null; 1913 1914 $values = array( 1915 'quote' => '', 1916 'quote_source' => '', 1917 'image' => '', 1918 'url' => '', 1919 'gallery' => '', 1920 'media' => '', 1921 ); 1922 foreach ( $keys as $key => $value ) { 1923 if ( 0 === strpos( $key, '_wp_format_' ) ) 1924 $values[str_replace( '_wp_format_', '', $key )] = $value[0]; 1925 } 1926 1927 return $values; 1928 } 1929 1930 /** 1902 1931 * Check if post is sticky. 1903 1932 * 1904 1933 * Sticky posts should remain at the top of The Loop. If the post ID is not -
wp-includes/script-loader.php
399 399 'comma' => _x( ',', 'tag delimiter' ), 400 400 ) ); 401 401 402 $scripts->add( 'post-formats', "/wp-admin/js/post-formats$suffix.js", array( 'media-models' ), false, 1 ); 403 402 404 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); 403 405 404 406 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) ); -
wp-admin/edit-form-advanced.php
112 112 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' ); 113 113 } 114 114 115 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )116 add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );117 118 115 // all taxonomies 119 116 foreach ( get_object_taxonomies( $post ) as $tax_name ) { 120 117 $taxonomy = get_taxonomy($tax_name); … … 129 126 add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name )); 130 127 } 131 128 129 // post format 130 if ( post_type_supports( $post_type, 'post-formats' ) ) { 131 wp_enqueue_script( 'post-formats' ); 132 $post_format = get_post_format(); 133 $format_class = ''; 134 if ( ! $post_format ) 135 $post_format = 'standard'; 136 137 $format_class = " class='wp-format-{$post_format}'"; 138 } 139 132 140 if ( post_type_supports($post_type, 'page-attributes') ) 133 141 add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core'); 134 142 … … 321 329 322 330 <div id="poststuff"> 323 331 332 <?php 333 if ( post_type_supports( $post_type, 'post-formats' ) ) { 334 $all_post_formats = get_post_format_strings(); 335 336 echo '<h2 class="nav-tab-wrapper post-format-select">'; 337 338 foreach ( $all_post_formats as $slug => $label ) { 339 if ( $post_format == $slug ) 340 $class = 'nav-tab nav-tab-active'; 341 else 342 $class = 'nav-tab'; 343 344 echo '<a class="' . $class . '" href="?format=' . $slug . '" data-wp-format="' . $slug . '">' . $label . '</a>'; 345 } 346 347 echo '</h2>'; 348 } 349 ?> 350 324 351 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 325 <div id="post-body-content"> 352 <div id="post-body-content"<?php echo $format_class; ?>> 353 326 354 <?php if ( post_type_supports($post_type, 'title') ) { ?> 327 355 <div id="titlediv"> 328 356 <div id="titlewrap"> … … 356 384 357 385 do_action( 'edit_form_after_title' ); 358 386 387 // post format fields 388 if ( post_type_supports( $post_type, 'post-formats' ) ) { 389 $format_meta = get_post_format_meta( $post_ID ); 390 391 if ( isset( $format_meta['image'] ) ) 392 $image = is_numeric( $format_meta['image'] ) ? wp_get_attachment_url( $format_meta['image'] ) : $format_meta['image']; 393 else 394 $image = false; 395 396 ?> 397 <div class="post-formats-fields"> 398 399 <input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" /> 400 401 <div class="field wp-format-quote"> 402 <label for="_wp_format_quote" class="screen-reader-text"><?php _e( 'Quote' ); ?>:</label> 403 <textarea name="_wp_format_quote" placeholder="<?php _e( 'Quote' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 404 </div> 405 406 <div class="field wp-format-quote"> 407 <label for="_wp_format_quote_source" class="screen-reader-text"><?php _e( 'Quote source' ); ?>:</label> 408 <input type="text" name="_wp_format_quote_source" value="<?php echo esc_attr( $format_meta['quote_source'] ); ?>" placeholder="<?php _e( 'Quote source' ); ?>" class="widefat" /> 409 </div> 410 411 <div class="field wp-format-image"> 412 <div id="wp-format-image-holder" class="hide-if-no-js<?php if ( empty( $image ) ) echo ' empty'; ?>"> 413 <a href="#" id="wp-format-image-select" 414 data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>" 415 data-update="<?php esc_attr_e( 'Select Image' ); ?>"> 416 <?php 417 if ( empty( $image ) ) 418 echo "<img src='{$image}' />"; 419 else 420 _e( 'Select Image' ); 421 ?> 422 </a> 423 </div> 424 <label for="_wp_format_image" class="screen-reader-text"><?php _e( 'Image ID or URL' ); ?>:</label> 425 <input type="text" name="_wp_format_image" id="wp_format_image" value="<?php echo esc_attr( $format_meta['image'] ); ?>" placeholder="<?php _e( 'Image ID or URL' ); ?>" class="widefat hide-if-js" /> 426 </div> 427 428 <div class="field wp-format-link wp-format-quote wp-format-image"> 429 <label for="_wp_format_url" class="screen-reader-text"><?php _e( 'Link URL' ); ?>:</label> 430 <input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" placeholder="<?php _e( 'Link URL' ); ?>" class="widefat" /> 431 </div> 432 433 <div class="field wp-format-gallery"> 434 <label for="_wp_format_gallery" class="screen-reader-text"><?php _e( 'Gallery shortcode' ); ?>:</label> 435 <input type="text" name="_wp_format_gallery" value="<?php echo esc_attr( $format_meta['gallery'] ); ?>" placeholder="<?php _e( 'Gallery shortcode' ); ?>" class="widefat" /> 436 </div> 437 438 <div class="field wp-format-audio wp-format-video"> 439 <label for="_wp_format_media" class="screen-reader-text"><?php _e( 'Embed code or URL' ); ?>:</label> 440 <textarea name="_wp_format_media" placeholder="<?php _e( 'Embed code or URL' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['media'] ); ?></textarea> 441 </div> 442 443 </div> 444 <?php 445 } 446 359 447 if ( post_type_supports($post_type, 'editor') ) { 360 448 ?> 361 449 <div id="postdivrich" class="postarea"> -
wp-admin/includes/post.php
192 192 } 193 193 194 194 // Post Formats 195 // @TODO: be able to delete 195 196 if ( isset( $post_data['post_format'] ) ) { 196 if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) ) 197 set_post_format( $post_ID, $post_data['post_format'] ); 198 elseif ( '0' == $post_data['post_format'] ) 199 set_post_format( $post_ID, false ); 197 set_post_format( $post_ID, $post_data['post_format'] ); 200 198 } 201 199 200 if ( isset( $post_data[ '_wp_format_url' ] ) ) { 201 update_post_meta( $post_ID, '_wp_format_url', addslashes( esc_url_raw( stripslashes( $post_data['_wp_format_url'] ) ) ) ); 202 } 203 204 $format_keys = array( 'quote', 'quote_source', 'image', 'gallery', 'media' ); 205 206 foreach ( $format_keys as $key ) { 207 if ( isset( $post_data[ '_wp_format_' . $key ] ) ) 208 update_post_meta( $post_ID, '_wp_format_' . $key, wp_filter_post_kses( $post_data[ '_wp_format_' . $key ] ) ); 209 } 210 202 211 // Meta Stuff 203 212 if ( isset($post_data['meta']) && $post_data['meta'] ) { 204 213 foreach ( $post_data['meta'] as $key => $value ) { -
wp-admin/css/wp-admin.css
747 747 background-color: #eee; 748 748 } 749 749 750 :-moz-placeholder { 750 :-moz-placeholder, 751 .wp-core-ui :-moz-placeholder { 751 752 color: #a9a9a9; 752 753 } 753 754 … … 3080 3081 margin: 2px 0 2px -2px; 3081 3082 } 3082 3083 3083 #post-status-select , #post-format{3084 #post-status-select { 3084 3085 line-height: 2.5em; 3085 3086 margin-top: 3px; 3086 3087 } 3087 3088 3089 /* Post formats form */ 3090 #poststuff .post-format-select { 3091 margin-top: 0; 3092 padding-bottom: 0; 3093 } 3094 3095 .post-formats-fields { 3096 margin-bottom: 20px; 3097 } 3098 3099 .wp-format-standard .post-formats-fields, 3100 .wp-format-aside .post-formats-fields, 3101 .wp-format-chat .post-formats-fields, 3102 .wp-format-status .post-formats-fields { 3103 display: none; 3104 } 3105 3106 .post-formats-fields .field { 3107 display: none; 3108 margin-bottom: 10px; 3109 } 3110 3111 .post-formats-fields input, 3112 .post-formats-fields textarea { 3113 padding: 5px; 3114 font-size: 1.2em; 3115 } 3116 3117 .wp-format-chat .field.wp-format-chat, 3118 .wp-format-gallery .field.wp-format-gallery, 3119 .wp-format-link .field.wp-format-link, 3120 .wp-format-image .field.wp-format-image, 3121 .wp-format-quote .field.wp-format-quote, 3122 .wp-format-video .field.wp-format-video, 3123 .wp-format-audio .field.wp-format-audio { 3124 display: block; 3125 } 3126 3127 /*.wp-format-image .post-formats-fields, 3128 .wp-format-video .post-formats-fields, 3129 .wp-format-audio .post-formats-fields { 3130 width: 30%; 3131 float: left; 3132 } 3133 3134 .wp-format-image #postdivrich, 3135 .wp-format-video #postdivrich, 3136 .wp-format-audio #postdivrich { 3137 width: 69%; 3138 float: right; 3139 }*/ 3140 3141 #wp-format-image-holder { 3142 overflow: hidden; 3143 width: 300px; 3144 height: 200px; 3145 background: #f5f5f5; 3146 box-shadow: 3147 inset 0 0 15px rgba( 0, 0, 0, 0.1 ), 3148 inset 0 0 0 1px rgba( 0, 0, 0, 0.05 ); 3149 } 3150 3151 #wp-format-image-holder:hover { 3152 background-color: #eee; 3153 } 3154 3155 #wp-format-image-select { 3156 display: block; 3157 height: 200px; 3158 text-align: center; 3159 } 3160 3161 #wp-format-image-select img { 3162 max-width: 100%; 3163 max-height: 100%; 3164 } 3165 3166 .empty #wp-format-image-select { 3167 padding-top: 120px; 3168 height: 80px; 3169 background: url(../images/media-button-2x.png) no-repeat center; 3170 } 3171 3088 3172 /* Post Screen */ 3089 3173 #post-body #normal-sortables { 3090 3174 min-height: 50px; -
wp-admin/js/post-formats.js
1 window.wp = window.wp || {}; 2 3 (function($){ 4 var frame; 5 6 // Post formats selection 7 $('.post-format-select a').on( 'click', function(e){ 8 e.preventDefault(); 9 var $this = $(this), 10 format = $this.data('wpFormat'); 11 $('.post-format-select a.nav-tab-active').removeClass('nav-tab-active'); 12 $this.addClass('nav-tab-active').blur(); 13 $('#post_format').val(format); 14 $('#post-body-content').attr('class', 'wp-format-' + format ); 15 }); 16 17 // Image selection 18 $('#wp-format-image-select').click( function( event ) { 19 var $el = $(this), 20 $holder = $('#wp-format-image-holder'), 21 $field = $('#wp_format_image'); 22 event.preventDefault(); 23 24 // If the media frame already exists, reopen it. 25 if ( frame ) { 26 frame.open(); 27 return; 28 } 29 30 // Create the media frame. 31 frame = wp.media.frames.formatImage = wp.media({ 32 // Set the title of the modal. 33 title: $el.data('choose'), 34 35 // Tell the modal to show only images. 36 library: { 37 type: 'image' 38 }, 39 40 // Customize the submit button. 41 button: { 42 // Set the text of the button. 43 text: $el.data('update') 44 } 45 }); 46 47 // When an image is selected, run a callback. 48 frame.on( 'select', function() { 49 // Grab the selected attachment. 50 var attachment = frame.state().get('selection').first(), 51 imageUrl = attachment.get('url'); 52 53 // set the hidden input's value 54 $field.attr('value', attachment.id); 55 56 // Show the image in the placeholder 57 $el.html('<img src="' + imageUrl + '" />'); 58 $holder.removeClass('empty'); 59 }); 60 61 frame.open(); 62 }); 63 })(jQuery);