Changeset 24021
- Timestamp:
- 04/17/2013 08:57:44 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post-formats.php
r24006 r24021 12 12 <div class="field wp-format-quote"> 13 13 <label for="wp_format_quote"><?php _e( 'Quote' ); ?></label> 14 <textarea id="wp_format_quote" name="_ wp_format_quote" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea>14 <textarea id="wp_format_quote" name="_format_quote" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 15 15 </div> 16 16 17 17 <div class="field wp-format-quote"> 18 18 <label for="wp_format_quote_source"><?php _e( 'Quote source' ); ?></label> 19 <input type="text" id="wp_format_quote_source" name="_ wp_format_quote_source" value="<?php echo esc_attr( $format_meta['quote_source'] ); ?>" class="widefat" />19 <input type="text" id="wp_format_quote_source" name="_format_quote_source_name" value="<?php echo esc_attr( $format_meta['quote_source_name'] ); ?>" class="widefat" /> 20 20 </div> 21 21 22 22 <div class="field wp-format-image"> 23 <?php if ( ! empty( $format_meta['image'] ) ) : ?> 23 <?php if ( ! empty( $format_meta['image'] ) ) : 24 $value = $format_meta['image']; 25 ?> 24 26 <div id="image-preview" class="wp-format-media-preview"> 25 27 <?php 26 if ( is_numeric( $ format_meta['image']) ) {27 $format_meta['image'] = absint( $ format_meta['image']);28 if ( is_numeric( $value ) ) { 29 $format_meta['image'] = absint( $value ); 28 30 $image = wp_get_attachment_url( $format_meta['image'] ); 29 31 printf( '<img src="%s" alt="%s" />', esc_url( $image ), get_the_title( $format_meta['image'] ) ); 30 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ format_meta['image']) ) {31 echo do_shortcode( $ format_meta['image']);32 } elseif ( ! preg_match( '#<[^>]+>#', $ format_meta['image']) ) {33 printf( '<img src="%s" alt="" />', esc_url( $ format_meta['image']) );32 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) ) { 33 echo do_shortcode( $value ); 34 } elseif ( ! preg_match( '#<[^>]+>#', $value ) ) { 35 printf( '<img src="%s" alt="" />', esc_url( $value ) ); 34 36 } else { 35 echo $ format_meta['image'];37 echo $value; 36 38 } 37 39 ?> … … 44 46 _e( 'Image URL' ); 45 47 ?></label> 46 <textarea id="wp_format_image" type="text" name="_ wp_format_image" class="widefat"><?php esc_html_e( $format_meta['image'] ); ?></textarea>48 <textarea id="wp_format_image" type="text" name="_format_image" class="widefat"><?php esc_html_e( $format_meta['image'] ); ?></textarea> 47 49 <div data-format="image" class="wp-format-media-holder hide-if-no-js"> 48 50 <a href="#" class="wp-format-media-select" … … 54 56 </div> 55 57 56 <div class="field wp-format-link wp-format-quote wp-format-image"> 57 <label for="wp_format_url"><?php _e( 'Link URL' ); ?></label> 58 <input type="text" id="wp_format_url" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" class="widefat" /> 58 <div class="field wp-format-link"> 59 <label for="wp_format_link_url"><?php _e( 'Link URL' ); ?></label> 60 <input type="text" id="wp_format_link_url" name="_format_link_url" value="<?php echo esc_url( $format_meta['link_url'] ); ?>" class="widefat" /> 61 </div> 62 63 <div class="field wp-format-quote"> 64 <label for="wp_format_quote_source_url"><?php _e( 'Link URL' ); ?></label> 65 <input type="text" id="wp_format_quote_source_url" name="_format_quote_source_url" value="<?php echo esc_url( $format_meta['quote_source_url'] ); ?>" class="widefat" /> 66 </div> 67 68 <div class="field wp-format-image"> 69 <label for="wp_format_image_url"><?php _e( 'Link URL' ); ?></label> 70 <input type="text" id="wp_format_image_url" name="_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" class="widefat" /> 59 71 </div> 60 72 61 73 <div class="field wp-format-video"> 62 <?php if ( ! empty( $format_meta['video'] ) ): ?> 74 <?php if ( ! empty( $format_meta['video_embed'] ) ): 75 $value = $format_meta['video_embed']; 76 ?> 63 77 <div id="video-preview" class="wp-format-media-preview"> 64 78 <?php 65 if ( is_numeric( $ format_meta['video']) ) {66 $url = wp_get_attachment_url( $ format_meta['video']);79 if ( is_numeric( $value ) ) { 80 $url = wp_get_attachment_url( $value ); 67 81 echo do_shortcode( sprintf( '[video src="%s"]', $url ) ); 68 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ format_meta['video']) ) {69 echo do_shortcode( $ format_meta['video']);70 } elseif ( ! preg_match( '#<[^>]+>#', $ format_meta['video']) ) {71 if ( strstr( $ format_meta['video'], home_url() ) )72 echo do_shortcode( sprintf( '[video src="%s"]', $ format_meta['video']) );82 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) ) { 83 echo do_shortcode( $value ); 84 } elseif ( ! preg_match( '#<[^>]+>#', $value ) ) { 85 if ( strstr( $value, home_url() ) ) 86 echo do_shortcode( sprintf( '[video src="%s"]', $value ) ); 73 87 else 74 echo $wp_embed->autoembed( $ format_meta['video']);88 echo $wp_embed->autoembed( $value ); 75 89 } else { 76 echo $ format_meta['video'];90 echo $value; 77 91 } 78 92 ?> … … 85 99 _e( 'Video URL' ); 86 100 ?></label> 87 <textarea id="wp_format_video" type="text" name="_ wp_format_video" class="widefat"><?php esc_html_e( $format_meta['video'] ); ?></textarea>101 <textarea id="wp_format_video" type="text" name="_format_video_embed" class="widefat"><?php esc_html_e( $format_meta['video_embed'] ); ?></textarea> 88 102 <div data-format="video" class="wp-format-media-holder hide-if-no-js"> 89 103 <a href="#" class="wp-format-media-select" … … 96 110 97 111 <div class="field wp-format-audio"> 98 <?php if ( ! empty( $format_meta['audio'] ) ): ?> 112 <?php if ( ! empty( $format_meta['audio_embed'] ) ): 113 $value = $format_meta['audio_embed']; 114 ?> 99 115 <div id="audio-preview" class="wp-format-media-preview"> 100 116 <?php 101 if ( is_numeric( $ format_meta['audio']) ) {102 $url = wp_get_attachment_url( $ format_meta['audio']);117 if ( is_numeric( $value ) ) { 118 $url = wp_get_attachment_url( $value ); 103 119 echo do_shortcode( sprintf( '[audio src="%s"]', $url ) ); 104 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ format_meta['audio']) ) {105 echo do_shortcode( $ format_meta['audio']);106 } elseif ( ! preg_match( '#<[^>]+>#', $ format_meta['audio']) ) {107 if ( strstr( $ format_meta['audio'], home_url() ) )108 echo do_shortcode( sprintf( '[audio src="%s"]', $ format_meta['audio']) );120 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) ) { 121 echo do_shortcode( $value ); 122 } elseif ( ! preg_match( '#<[^>]+>#', $value ) ) { 123 if ( strstr( $value, home_url() ) ) 124 echo do_shortcode( sprintf( '[audio src="%s"]', $value ) ); 109 125 else 110 echo $wp_embed->autoembed( $ format_meta['audio']);126 echo $wp_embed->autoembed( $value ); 111 127 } else { 112 echo $ format_meta['audio'];128 echo $value; 113 129 } 114 130 ?> … … 121 137 _e( 'Audio URL' ); 122 138 ?></label> 123 <textarea id="wp_format_audio" name="_ wp_format_audio" class="widefat"><?php esc_html_e( $format_meta['audio'] ); ?></textarea>139 <textarea id="wp_format_audio" name="_format_audio_embed" class="widefat"><?php esc_html_e( $format_meta['audio_embed'] ); ?></textarea> 124 140 <div data-format="audio" class="wp-format-media-holder hide-if-no-js"> 125 141 <a href="#" class="wp-format-media-select" data-choose="<?php esc_attr_e( 'Choose Audio' ); ?>" data-update="<?php esc_attr_e( 'Select Audio' ); ?>"> -
trunk/wp-admin/includes/post.php
r23985 r24021 193 193 194 194 // Post Formats 195 if ( isset( $post_data['post_format'] ) ) {195 if ( isset( $post_data['post_format'] ) ) 196 196 set_post_format( $post_ID, $post_data['post_format'] ); 197 } 198 199 if ( isset( $post_data[ '_wp_format_url' ] ) ) { 200 update_post_meta( $post_ID, '_wp_format_url', wp_slash( esc_url_raw( wp_unslash( $post_data['_wp_format_url'] ) ) ) ); 201 } 202 203 $format_keys = array( 'quote', 'quote_source', 'image', 'gallery', 'audio', 'video' ); 197 198 $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); 199 foreach ( $format_meta_urls as $format_meta_url ) { 200 $keyed = '_format_' . $format_meta_url; 201 if ( isset( $post_data[ $keyed ] ) ) 202 update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); 203 } 204 205 $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); 204 206 205 207 foreach ( $format_keys as $key ) { 206 if ( isset( $post_data[ '_wp_format_' . $key ] ) ) { 208 $keyed = '_format_' . $key; 209 if ( isset( $post_data[ $keyed ] ) ) { 207 210 if ( current_user_can( 'unfiltered_html' ) ) 208 update_post_meta( $post_ID, '_wp_format_' . $key, $post_data[ '_wp_format_' . $key] );211 update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); 209 212 else 210 update_post_meta( $post_ID, '_wp_format_' . $key, wp_filter_post_kses( $post_data[ '_wp_format_' . $key] ) );213 update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); 211 214 } 212 215 } -
trunk/wp-admin/js/post-formats.js
r24007 r24021 2 2 3 3 (function($) { 4 var container, mediaFrame, lastMimeType, lastMenu,mediaPreview,5 6 $container= $( '.post-formats-fields' );4 var container, mediaFrame, lastMimeType, mediaPreview, 5 noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'], 6 $container = $( '.post-formats-fields' ); 7 7 8 8 function switchFormatClass( format ) { … … 77 77 $('.wp-format-media-select').click(function(event) { 78 78 event.preventDefault(); 79 var $el = $(this), mime ,80 81 79 var $el = $(this), mime = 'image', 80 $holder = $el.closest('.wp-format-media-holder'), 81 $field = $( '#wp_format_' + $holder.data('format') ); 82 82 83 83 mime = $holder.data('format'); -
trunk/wp-includes/js/autosave.js
r23928 r24021 368 368 data['post_format'] = post_format == 'standard' ? '' : post_format; 369 369 370 $('.post-formats-fields').find('input[name^="_ wp_format_"], textarea[name^="_wp_format_"]').each( function(i, field) {370 $('.post-formats-fields').find('input[name^="_format_"], textarea[name^="_format_"]').each( function(i, field) { 371 371 data[ field.name ] = field.value || ''; 372 372 }); -
trunk/wp-includes/media.php
r24006 r24021 2075 2075 if ( has_post_format( $type, $post ) ) { 2076 2076 $meta = get_post_format_meta( $post->ID ); 2077 if ( ! empty( $meta[$type] ) ) { 2078 if ( is_integer( $meta[$type] ) ) { 2079 $url = wp_get_attachment_url( $meta[$type] ); 2077 if ( ! empty( $meta[$type . '_embed'] ) ) { 2078 $value = $meta[$type . '_embed']; 2079 if ( is_integer( $value ) ) { 2080 $url = wp_get_attachment_url( $value ); 2080 2081 $shortcode = sprintf( '[%s src="%s"]', $type, $url ); 2081 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ meta[$type]) ) {2082 $shortcode = $ meta[$type];2083 } elseif ( preg_match( '#<[^>]+>#', $ meta[$type]) ) {2084 $post->format_content = $ meta[$type];2082 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) ) { 2083 $shortcode = $value; 2084 } elseif ( preg_match( '#<[^>]+>#', $value ) ) { 2085 $post->format_content = $value; 2085 2086 return $post->format_content; 2086 } elseif ( 0 === strpos( $ meta[$type], 'http' ) ) {2087 $post->split_content = str_replace( $ meta[$type], '', $post->post_content, $count );2088 if ( strstr( $ meta[$type], home_url() ) ) {2089 $shortcode = sprintf( '[%s src="%s"]', $type, $ meta[$type]);2087 } elseif ( 0 === strpos( $value, 'http' ) ) { 2088 $post->split_content = str_replace( $value, '', $post->post_content, $count ); 2089 if ( strstr( $value, home_url() ) ) { 2090 $shortcode = sprintf( '[%s src="%s"]', $type, $value ); 2090 2091 } else { 2091 $post->format_content = $wp_embed->autoembed( $ meta[$type]);2092 $post->format_content = $wp_embed->autoembed( $value ); 2092 2093 return $post->format_content; 2093 2094 } -
trunk/wp-includes/post-formats.php
r23992 r24021 82 82 */ 83 83 function get_post_format_meta( $post_id = 0 ) { 84 $values = array( 85 'quote' => '', 86 'quote_source' => '', 87 'url' => '', 88 'image' => '', 89 'gallery' => '', 90 'audio' => '', 91 'video' => '', 84 $meta = get_post_meta( $post_id ); 85 $keys = array( 'quote', 'quote_source_name', 'quote_source_url', 'link_url', 'gallery', 'audio_embed', 'video_embed', 'url', 'image' ); 86 87 if ( empty( $meta ) ) 88 return array_fill_keys( $keys, '' ); 89 90 $upgrade = array( 91 '_wp_format_quote_source' => 'quote_source_name', 92 '_wp_format_audio' => 'audio_embed', 93 '_wp_format_video' => 'video_embed' 92 94 ); 93 95 94 foreach ( $values as $key => $value ) 95 $values[$key] = get_post_meta( $post_id, '_wp_format_' . $key, true ); 96 $format = get_post_format( $post_id ); 97 if ( ! empty( $format ) ) { 98 switch ( $format ) { 99 case 'link': 100 $upgrade['_wp_format_url'] = 'link_url'; 101 break; 102 case 'quote': 103 $upgrade['_wp_format_url'] = 'quote_source_url'; 104 break; 105 } 106 } 107 108 $upgrade_keys = array_keys( $upgrade ); 109 foreach ( $meta as $key => $values ) { 110 if ( ! in_array( $key, $upgrade_keys ) ) 111 continue; 112 update_post_meta( $post_id, '_format_' . $upgrade[$key], reset( $values ) ); 113 delete_post_meta( $post_id, $key ); 114 } 115 116 $values = array(); 117 118 foreach ( $keys as $key ) { 119 $value = get_post_meta( $post_id, '_format_' . $key, true ); 120 $values[$key] = empty( $value ) ? '' : $value; 121 } 96 122 97 123 return $values; … … 325 351 $compat['position'] = 'before'; 326 352 327 if ( ! empty( $meta[' url'] ) ) {328 $esc_url = preg_quote( $meta[' url'], '#' );353 if ( ! empty( $meta['link_url'] ) ) { 354 $esc_url = preg_quote( $meta['link_url'], '#' ); 329 355 // Make sure the same URL isn't in the post (modified/extended versions allowed) 330 356 if ( ! preg_match( '#' . $esc_url . '[^/&\?]?#', $content ) ) { 331 $url = $meta[' url'];357 $url = $meta['link_url']; 332 358 } else { 333 359 $url = get_content_url( $content, true ); … … 345 371 empty( $compat['link_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['link_class'] ) ), 346 372 esc_url( $url ), 347 empty( $post->post_title ) ? esc_url( $meta[' url'] ) : apply_filters( 'the_title', $post->post_title, $post->ID )373 empty( $post->post_title ) ? esc_url( $meta['link_url'] ) : apply_filters( 'the_title', $post->post_title, $post->ID ) 348 374 ); 349 375 } … … 376 402 if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) { 377 403 $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $meta['quote'] ) ); 378 if ( ! empty( $meta['quote_source '] ) ) {379 $source = ( empty( $meta[' url'] ) ) ? $meta['quote_source'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['url'] ), $meta['quote_source'] );404 if ( ! empty( $meta['quote_source_name'] ) ) { 405 $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] ); 380 406 $quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source ); 381 407 } … … 386 412 case 'video': 387 413 case 'audio': 388 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta[$format] ) ) { 414 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta[$format . '_embed'] ) ) { 415 $value = $meta[$format . '_embed']; 389 416 // the metadata is an attachment ID 390 if ( is_numeric( $ meta[$format]) ) {391 $url = wp_get_attachment_url( $ meta[$format]);417 if ( is_numeric( $value ) ) { 418 $url = wp_get_attachment_url( $value ); 392 419 $format_output .= sprintf( '[%s src="%s"]', $format, $url ); 393 420 // the metadata is a shortcode or an embed code 394 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ meta[$format] ) || preg_match( '#<[^>]+>#', $meta[$format]) ) {395 $format_output .= $ meta[$format];396 } elseif ( ! stristr( $content, $ meta[$format]) ) {421 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) || preg_match( '#<[^>]+>#', $value ) ) { 422 $format_output .= $value; 423 } elseif ( ! stristr( $content, $value ) ) { 397 424 // attempt to embed the URL 398 $format_output .= sprintf( '[embed]%s[/embed]', $ meta[$format]);425 $format_output .= sprintf( '[embed]%s[/embed]', $value ); 399 426 } 400 427 } … … 708 735 return ''; 709 736 710 if ( in_array( get_post_format( $post->ID ), array( 'image', 'link', 'quote' ) ) ) { 737 $format = get_post_format( $post->ID ); 738 if ( in_array( $format, array( 'image', 'link', 'quote' ) ) ) { 711 739 $meta = get_post_format_meta( $post->ID ); 712 if ( ! empty( $meta['url'] ) ) 713 return apply_filters( 'get_the_post_format_url', esc_url_raw( $meta['url'] ), $post ); 740 $meta_link = ''; 741 742 switch ( $format ) { 743 case 'link': 744 if ( ! empty( $meta['link_url'] ) ) 745 $meta_link = $meta['link_url']; 746 break; 747 case 'image': 748 if ( ! empty( $meta['url'] ) ) 749 $meta_link = $meta['url']; 750 break; 751 case 'quote': 752 if ( ! empty( $meta['quote_source_url'] ) ) 753 $meta_link = $meta['quote_source_url']; 754 break; 755 } 756 757 if ( ! empty( $meta_link ) ) 758 return apply_filters( 'get_the_post_format_url', esc_url_raw( $meta_link ), $post ); 714 759 } 715 760 -
trunk/wp-includes/revision.php
r23936 r24021 69 69 function _wp_post_revision_meta_keys() { 70 70 return array( 71 '_wp_format_url', 72 '_wp_format_quote', 73 '_wp_format_quote_source', 74 '_wp_format_image', 75 '_wp_format_gallery', 76 '_wp_format_audio', 77 '_wp_format_video', 71 '_format_url', 72 '_format_link_url', 73 '_format_quote_source_url', 74 '_format_quote_source_name', 75 '_format_quote', 76 '_format_image', 77 '_format_gallery', 78 '_format_audio_embed', 79 '_format_video_embed', 78 80 ); 79 81 }
Note: See TracChangeset
for help on using the changeset viewer.