WordPress.org

Make WordPress Core

Ticket #21776: 21776.3.diff

File 21776.3.diff, 4.2 KB (added by nacin, 17 months ago)
  • wp-admin/includes/ajax-actions.php

     
    16931693        wp_die( 0 ); 
    16941694} 
    16951695 
     1696function wp_ajax_preview_post_thumbnail() { 
     1697        $post_id = intval( $_POST['post_id'] ); 
     1698        if ( ! current_user_can( 'edit_post', $post_id ) ) 
     1699                wp_send_json_error(); 
     1700 
     1701        check_ajax_referer( 'preview_post_thumbnail-' . $post_id ); 
     1702 
     1703        $thumbnail_id = intval( $_POST['thumbnail_id'] ); 
     1704        wp_send_json_success( _wp_post_thumbnail_html( $thumbnail_id, $post_id ) ); 
     1705} 
     1706 
    16961707function wp_ajax_date_format() { 
    16971708        wp_die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) ); 
    16981709} 
  • wp-admin/includes/post.php

     
    11201120        $post = get_post( $post ); 
    11211121 
    11221122        $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) ); 
    1123         $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>'; 
    1124         $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) ); 
     1123        $set_thumbnail_link = '<a class="choose button-secondary thickbox" href="%s">%s</a>'; 
     1124        $content = sprintf( $set_thumbnail_link, $upload_iframe_src, __( 'Choose a Featured Image' ) ); 
    11251125 
    11261126        if ( $thumbnail_id && get_post( $thumbnail_id ) ) { 
    11271127                $old_content_width = $content_width; 
     
    11311131                else 
    11321132                        $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); 
    11331133                if ( !empty( $thumbnail_html ) ) { 
    1134                         $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); 
    11351134                        $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); 
    1136                         $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>'; 
     1135                        $content .= '<a href="#" class="remove">' . esc_html__( 'Remove featured image' ) . '</a>'; 
    11371136                } 
    11381137                $content_width = $old_content_width; 
    11391138        } 
  • wp-admin/includes/meta-boxes.php

     
    10011001 * @since 2.9.0 
    10021002 */ 
    10031003function post_thumbnail_meta_box( $post ) { 
    1004         global $_wp_additional_image_sizes; 
    1005  
    10061004        ?><script type="text/javascript"> 
    10071005        jQuery( function($) { 
    10081006                var $element     = $('#select-featured-image'), 
     
    11011099        </script> 
    11021100 
    11031101        <?php 
    1104         $thumbnail_id   = get_post_meta( $post->ID, '_thumbnail_id', true ); 
    1105         $thumbnail_size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : 'medium'; 
    1106         $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $thumbnail_size ); 
    1107  
    1108         $classes = empty( $thumbnail_id ) ? '' : 'has-featured-image'; 
    1109  
    1110         ?><div id="select-featured-image" 
    1111                 class="<?php echo esc_attr( $classes ); ?>" 
    1112                 data-post-id="<?php echo esc_attr( $post->ID ); ?>"> 
    1113                 <?php echo $thumbnail_html; ?> 
    1114                 <input type="hidden" name="thumbnail_id" value="<?php echo esc_attr( $thumbnail_id ); ?>" /> 
    1115                 <a href="#" class="choose button-secondary"><?php _e( 'Choose a Featured Image' ); ?></a> 
    1116                 <a href="#" class="remove"><?php _e( 'Remove Featured Image' ); ?></a> 
    1117         </div> 
    1118         <?php 
     1102        $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 
     1103        echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); 
    11191104} 
     1105 No newline at end of file 
  • wp-admin/admin-ajax.php

     
    5656        'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post', 
    5757        'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 
    5858        'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 
    59         'send-attachment-to-editor', 
     59        'send-attachment-to-editor', 'preview-post-thumbnail', 
    6060); 
    6161 
    6262// Register core Ajax calls.