Ticket #19570: 19570.6.diff
File 19570.6.diff, 11.5 KB (added by , 12 years ago) |
---|
-
wp-includes/post.php
1951 1951 } 1952 1952 1953 1953 /** 1954 * Retrieve post format metadata for a post 1955 * 1956 * @since 3.6.0 1957 * 1958 * @param int $post_id 1959 * @return null 1960 */ 1961 function get_post_format_meta( $post_id = 0 ) { 1962 $values = array( 1963 'quote' => '', 1964 'quote_source' => '', 1965 'image' => '', 1966 'url' => '', 1967 'gallery' => '', 1968 'media' => '', 1969 ); 1970 1971 foreach ( $values as $key => $value ) 1972 $values[$key] = get_post_meta( $post_id, '_wp_format_' . $key, true ); 1973 1974 return $values; 1975 } 1976 1977 /** 1954 1978 * Check if post is sticky. 1955 1979 * 1956 1980 * Sticky posts should remain at the top of The Loop. If the post ID is not -
wp-includes/script-loader.php
397 397 'comma' => _x( ',', 'tag delimiter' ), 398 398 ) ); 399 399 400 $scripts->add( 'post-formats', "/wp-admin/js/post-formats$suffix.js", array( 'media-models' ), false, 1 ); 401 400 402 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); 401 403 402 404 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) ); -
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/js/post-formats.js
1 window.wp = window.wp || {}; 2 3 (function($){ 4 var imageFrame, galleryFrame; 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 ( imageFrame ) { 26 imageFrame.open(); 27 return; 28 } 29 30 // Create the media frame. 31 imageFrame = 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 imageFrame.on( 'select', function() { 49 // Grab the selected attachment. 50 var attachment = imageFrame.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 imageFrame.open(); 62 }); 63 })(jQuery); -
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 <div class="post-formats-fields"> 397 398 <input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" /> 399 400 <div class="field wp-format-quote"> 401 <label for="_wp_format_quote" class="screen-reader-text"><?php _e( 'Quote' ); ?>:</label> 402 <textarea name="_wp_format_quote" placeholder="<?php esc_attr_e( 'Quote' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 403 </div> 404 405 <div class="field wp-format-quote"> 406 <label for="_wp_format_quote_source" class="screen-reader-text"><?php _e( 'Quote source' ); ?>:</label> 407 <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" /> 408 </div> 409 410 <div class="field wp-format-image"> 411 <div id="wp-format-image-holder" class="hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 412 <a href="#" id="wp-format-image-select" 413 data-choose="<?php esc_attr_e( 'Choose an Image' ); ?>" 414 data-update="<?php esc_attr_e( 'Select Image' ); ?>"> 415 <?php 416 if ( $image ) 417 echo '<img src="' . esc_url( $image ) . '" />'; 418 else 419 _e( 'Select Image' ); 420 ?> 421 </a> 422 </div> 423 <label for="_wp_format_image" class="screen-reader-text"><?php _e( 'Image ID or URL' ); ?>:</label> 424 <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" /> 425 </div> 426 427 <div class="field wp-format-link wp-format-quote wp-format-image"> 428 <label for="_wp_format_url" class="screen-reader-text"><?php _e( 'Link URL' ); ?>:</label> 429 <input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" placeholder="<?php esc_attr_e( 'Link URL' ); ?>" class="widefat" /> 430 </div> 431 432 <div class="field wp-format-gallery"> 433 <label for="_wp_format_gallery" class="screen-reader-text"><?php _e( 'Gallery shortcode' ); ?>:</label> 434 <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" /> 435 </div> 436 437 <div class="field wp-format-audio wp-format-video"> 438 <label for="_wp_format_media" class="screen-reader-text"><?php _e( 'Embed code or URL' ); ?>:</label> 439 <textarea name="_wp_format_media" placeholder="<?php esc_attr_e( 'Embed code or URL' ); ?>" class="widefat"><?php echo esc_textarea( $format_meta['media'] ); ?></textarea> 440 </div> 441 442 </div> 443 <?php 444 } 445 359 446 if ( post_type_supports($post_type, 'editor') ) { 360 447 ?> 361 448 <div id="postdivrich" class="postarea"> -
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-holder { 3128 overflow: hidden; 3129 width: 300px; 3130 height: 200px; 3131 border: 1px solid #dfdfdf; 3132 background: #f5f5f5; 3133 } 3134 3135 #wp-format-image-holder:hover { 3136 background-color: #eee; 3137 } 3138 3139 #wp-format-image-select { 3140 display: block; 3141 height: 200px; 3142 text-align: center; 3143 } 3144 3145 #wp-format-image-select img { 3146 max-width: 100%; 3147 max-height: 100%; 3148 } 3149 3150 .empty #wp-format-image-select { 3151 padding-top: 120px; 3152 height: 80px; 3153 background: url(../images/media-button-2x.png) no-repeat center; 3154 } 3155 3088 3156 /* Post Screen */ 3089 3157 #post-body #normal-sortables { 3090 3158 min-height: 50px;