Ticket #21776: 21776.3.diff
| File 21776.3.diff, 4.2 KB (added by nacin, 6 months ago) |
|---|
-
wp-admin/includes/ajax-actions.php
1693 1693 wp_die( 0 ); 1694 1694 } 1695 1695 1696 function 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 1696 1707 function wp_ajax_date_format() { 1697 1708 wp_die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) ); 1698 1709 } -
wp-admin/includes/post.php
1120 1120 $post = get_post( $post ); 1121 1121 1122 1122 $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' ) ); 1125 1125 1126 1126 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { 1127 1127 $old_content_width = $content_width; … … 1131 1131 else 1132 1132 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); 1133 1133 if ( !empty( $thumbnail_html ) ) { 1134 $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );1135 1134 $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>'; 1137 1136 } 1138 1137 $content_width = $old_content_width; 1139 1138 } -
wp-admin/includes/meta-boxes.php
1001 1001 * @since 2.9.0 1002 1002 */ 1003 1003 function post_thumbnail_meta_box( $post ) { 1004 global $_wp_additional_image_sizes;1005 1006 1004 ?><script type="text/javascript"> 1007 1005 jQuery( function($) { 1008 1006 var $element = $('#select-featured-image'), … … 1101 1099 </script> 1102 1100 1103 1101 <?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 ); 1119 1104 } 1105 No newline at end of file -
wp-admin/admin-ajax.php
56 56 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post', 57 57 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 58 58 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 59 'send-attachment-to-editor', 59 'send-attachment-to-editor', 'preview-post-thumbnail', 60 60 ); 61 61 62 62 // Register core Ajax calls.
