Ticket #24010: 24010.diff
File 24010.diff, 17.5 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/post-formats.php
diff --git wp-admin/includes/post-formats.php wp-admin/includes/post-formats.php index 0364f5d..b851628 100644
$format_meta = get_post_format_meta( $post_ID ); 10 10 11 11 <div class="field wp-format-quote"> 12 12 <label for="wp_format_quote"><?php _e( 'Quote' ); ?></label> 13 <textarea id="wp_format_quote" name="_ wp_format_quote" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea>13 <textarea id="wp_format_quote" name="_format_quote" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea> 14 14 </div> 15 15 16 16 <div class="field wp-format-quote"> 17 17 <label for="wp_format_quote_source"><?php _e( 'Quote source' ); ?></label> 18 <input type="text" id="wp_format_quote_source" name="_ wp_format_quote_source" value="<?php echo esc_attr( $format_meta['quote_source'] ); ?>" class="widefat" />18 <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" /> 19 19 </div> 20 20 21 21 <?php … … $format_meta = get_post_format_meta( $post_ID ); 38 38 ?> 39 39 </a> 40 40 </div> 41 <input id="wp_format_image" type="hidden" name="_ wp_format_image" value="<?php echo esc_attr( $format_meta['image'] ); ?>" />41 <input id="wp_format_image" type="hidden" name="_format_image" value="<?php echo esc_attr( $format_meta['image'] ); ?>" /> 42 42 </div> 43 43 44 <div class="field wp-format-link wp-format-quote wp-format-image"> 45 <label for="wp_format_url"><?php _e( 'Link URL' ); ?></label> 46 <input type="text" id="wp_format_url" name="_wp_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" class="widefat" /> 44 <div class="field wp-format-link"> 45 <label for="wp_format_link_url"><?php _e( 'Link URL' ); ?></label> 46 <input type="text" id="wp_format_link_url" name="_format_link_url" value="<?php echo esc_url( $format_meta['link_url'] ); ?>" class="widefat" /> 47 </div> 48 49 <div class="field wp-format-quote"> 50 <label for="wp_format_quote_source_url"><?php _e( 'Link URL' ); ?></label> 51 <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" /> 52 </div> 53 54 <div class="field wp-format-image"> 55 <label for="wp_format_image_url"><?php _e( 'Link URL' ); ?></label> 56 <input type="text" id="wp_format_image_url" name="_format_url" value="<?php echo esc_url( $format_meta['url'] ); ?>" class="widefat" /> 47 57 </div> 48 58 49 59 <?php 50 $show_video_preview = ! empty( $format_meta['video '] );60 $show_video_preview = ! empty( $format_meta['video_embed'] ); 51 61 ?> 52 62 <div class="field wp-format-video<?php if ( $show_video_preview ) echo ' has-media-preview'; ?>"> 53 <?php if ( $show_video_preview ): ?> 63 <?php if ( $show_video_preview ): 64 $value = $format_meta['video_embed']; 65 ?> 54 66 <div id="video-preview" class="wp-format-media-preview"> 55 67 <?php 56 if ( is_numeric( $ format_meta['video']) ) {57 $url = wp_get_attachment_url( $ format_meta['video']);68 if ( is_numeric( $value ) ) { 69 $url = wp_get_attachment_url( $value ); 58 70 echo do_shortcode( sprintf( '[video src="%s"]', $url ) ); 59 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ format_meta['video']) ) {60 echo do_shortcode( $ format_meta['video']);61 } elseif ( ! preg_match( '#<[^>]+>#', $ format_meta['video']) ) {62 if ( strstr( $ format_meta['video'], home_url() ) )63 echo do_shortcode( sprintf( '[video src="%s"]', $ format_meta['video']) );71 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) ) { 72 echo do_shortcode( $value ); 73 } elseif ( ! preg_match( '#<[^>]+>#', $value ) ) { 74 if ( strstr( $value, home_url() ) ) 75 echo do_shortcode( sprintf( '[video src="%s"]', $value ) ); 64 76 else 65 echo $wp_embed->autoembed( $ format_meta['video']);77 echo $wp_embed->autoembed( $value ); 66 78 } else { 67 echo $ format_meta['video'];79 echo $value; 68 80 } 69 81 ?> 70 82 </div> … … $format_meta = get_post_format_meta( $post_ID ); 75 87 else 76 88 _e( 'Video URL' ); 77 89 ?></label> 78 <textarea id="wp_format_video" type="text" name="_ wp_format_video" class="widefat"><?php esc_html_e( $format_meta['video'] ); ?></textarea>90 <textarea id="wp_format_video" type="text" name="_format_video_embed" class="widefat"><?php esc_html_e( $format_meta['video_embed'] ); ?></textarea> 79 91 <div data-format="video" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>"> 80 92 <a href="#" class="wp-format-media-select" 81 93 data-choose="<?php esc_attr_e( 'Choose a Video' ); ?>" … … $format_meta = get_post_format_meta( $post_ID ); 86 98 </div> 87 99 88 100 <?php 89 $show_audio_preview = ! empty( $format_meta['audio '] );101 $show_audio_preview = ! empty( $format_meta['audio_embed'] ); 90 102 ?> 91 103 <div class="field wp-format-audio<?php if ( $show_audio_preview ) echo ' has-media-preview' ?>"> 92 <?php if ( $show_audio_preview ): ?> 104 <?php if ( $show_audio_preview ): 105 $value = $format_meta['audio_embed']; 106 ?> 93 107 <div id="audio-preview" class="wp-format-media-preview"> 94 108 <?php 95 if ( is_numeric( $ format_meta['audio']) ) {96 $url = wp_get_attachment_url( $ format_meta['audio']);109 if ( is_numeric( $value ) ) { 110 $url = wp_get_attachment_url( $value ); 97 111 echo do_shortcode( sprintf( '[audio src="%s"]', $url ) ); 98 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $ format_meta['audio']) ) {99 echo do_shortcode( $ format_meta['audio']);100 } elseif ( ! preg_match( '#<[^>]+>#', $ format_meta['audio']) ) {101 if ( strstr( $ format_meta['audio'], home_url() ) )102 echo do_shortcode( sprintf( '[audio src="%s"]', $ format_meta['audio']) );112 } elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $value ) ) { 113 echo do_shortcode( $value ); 114 } elseif ( ! preg_match( '#<[^>]+>#', $value ) ) { 115 if ( strstr( $value, home_url() ) ) 116 echo do_shortcode( sprintf( '[audio src="%s"]', $value ) ); 103 117 else 104 echo $wp_embed->autoembed( $ format_meta['audio']);118 echo $wp_embed->autoembed( $value ); 105 119 } else { 106 echo $ format_meta['audio'];120 echo $value; 107 121 } 108 122 ?> 109 123 </div> … … $format_meta = get_post_format_meta( $post_ID ); 114 128 else 115 129 _e( 'Audio URL' ); 116 130 ?></label> 117 <textarea id="wp_format_audio" name="_ wp_format_audio" class="widefat"><?php esc_html_e( $format_meta['audio'] );131 <textarea id="wp_format_audio" name="_format_audio_embed" class="widefat"><?php esc_html_e( $format_meta['audio_embed'] ); 118 132 ?></textarea> 119 <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( empty( $format_meta['audio '] ) ) echo ' empty'; ?>">133 <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( empty( $format_meta['audio_embed'] ) ) echo ' empty'; ?>"> 120 134 <a href="#" class="wp-format-media-select" data-choose="<?php esc_attr_e( 'Choose Audio' ); ?>" data-update="<?php esc_attr_e( 'Select Audio' ); ?>"> 121 135 <?php _e( 'Select Audio From Media Library' ) ?> 122 136 </a> -
wp-admin/includes/post.php
diff --git wp-admin/includes/post.php wp-admin/includes/post.php index 1b5ff0e..07509f9 100644
function edit_post( $post_data = null ) { 192 192 } 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 197 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'] ) ) ) ); 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 ] ) ) ) ); 201 203 } 202 204 203 $format_keys = array( 'quote', 'quote_source ', 'image', 'gallery', 'audio', 'video' );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 } 213 216 -
wp-includes/js/autosave.js
diff --git wp-includes/js/autosave.js wp-includes/js/autosave.js index 566da2d..fdc92f1 100644
wp.autosave.getPostData = function() { 367 367 post_format = $('#post_format').val() || ''; 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 }); 373 373 -
wp-includes/media.php
diff --git wp-includes/media.php wp-includes/media.php index 2231797..93f54be 100644
function get_the_post_format_media( $type, &$post = null, $limit = 0 ) { 2074 2074 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 } 2094 2095 } -
wp-includes/post-formats.php
diff --git wp-includes/post-formats.php wp-includes/post-formats.php index bd164af..6d75a73 100644
function set_post_format( $post, $format ) { 81 81 * @return array The array of post format metadata. 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 86 if ( empty( $meta ) ) 87 return array(); 88 89 $upgrade = array( 90 '_wp_format_quote_source' => 'quote_source_name', 91 '_wp_format_audio' => 'audio_embed', 92 '_wp_format_video' => 'video_embed' 92 93 ); 93 94 94 foreach ( $values as $key => $value ) 95 $values[$key] = get_post_meta( $post_id, '_wp_format_' . $key, true ); 95 $format = get_post_format( $post_id ); 96 if ( ! empty( $format ) ) { 97 switch ( $format ) { 98 case 'link': 99 $upgrade['_wp_format_url'] = 'link_url'; 100 break; 101 case 'quote': 102 $upgrade['_wp_format_url'] = 'quote_source_url'; 103 break; 104 } 105 } 106 107 $upgrade_keys = array_keys( $upgrade ); 108 foreach ( $meta as $key => $values ) { 109 if ( ! in_array( $key, $upgrade_keys ) ) 110 continue; 111 update_post_meta( $post_id, '_format_' . $upgrade[$key], reset( $values ) ); 112 delete_post_meta( $post_id, $key ); 113 } 114 115 $keys = array( 'quote', 'quote_source_name', 'quote_source_url', 'link_url', 'gallery', 'audio_embed', 'video_embed', 'url', 'image' ); 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; 98 124 } … … function post_formats_compat( $content, $id = 0 ) { 324 350 $compat['tag'] = ''; 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 ); 334 360 } … … function post_formats_compat( $content, $id = 0 ) { 344 370 '<a %shref="%s">%s</a>', 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 } 350 376 break; … … function post_formats_compat( $content, $id = 0 ) { 376 402 if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) { 377 403 $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $meta['quote'] ) ); 378 404 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'] );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 } 382 408 $format_output .= sprintf( '<figure class="quote">%s</figure>', $quote ); … … function post_formats_compat( $content, $id = 0 ) { 385 411 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 } 401 428 break; … … function get_the_post_format_url( $id = 0 ) { 707 734 if ( empty( $post ) ) 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 716 761 if ( ! empty( $post->post_content ) ) -
wp-includes/revision.php
diff --git wp-includes/revision.php wp-includes/revision.php index b0459b9..b28affa 100644
function _wp_post_revision_fields( $post = null, $autosave = false ) { 68 68 */ 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 } 80 82