Ticket #21776: 21776.7-refresh.diff

File 21776.7-refresh.diff, 21.2 KB (added by DrewAPicture, 6 months ago)

refresh at r22973

Line 
1Index: wp-includes/js/media-editor.js
2===================================================================
3--- wp-includes/js/media-editor.js      (revision 22973)
4+++ wp-includes/js/media-editor.js      (working copy)
5@@ -375,6 +375,7 @@
6 
7                        workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
8                                frame:    'post',
9+                               state:    'upload',
10                                title:    wp.media.view.l10n.addMedia,
11                                multiple: true
12                        } ) );
13@@ -427,14 +428,52 @@
14                                }
15                        }, this );
16 
17+                       workflow.state('featured-image').on( 'select', function() {
18+                               var settings = wp.media.view.settings,
19+                                       featuredImage = settings.featuredImage,
20+                                       selection = this.get('selection').single();
21+
22+                               if ( ! featuredImage )
23+                                       return;
24+
25+                               featuredImage.id = selection ? selection.id : -1;
26+                               wp.media.post( 'set-post-thumbnail', {
27+                                       json:         true,
28+                                       post_id:      settings.postId,
29+                                       thumbnail_id: featuredImage.id,
30+                                       _wpnonce:     featuredImage.nonce
31+                               }).done( function( html ) {
32+                                       $( '.inside', '#postimagediv' ).html( html );
33+                               });
34+                       });
35+
36+                       workflow.setState( workflow.options.state );
37                        return workflow;
38                },
39 
40+               id: function( id ) {
41+                       if ( id )
42+                               return id;
43+
44+                       // If an empty `id` is provided, default to `wpActiveEditor`.
45+                       id = wpActiveEditor;
46+
47+                       // If that doesn't work, fall back to `tinymce.activeEditor.id`.
48+                       if ( ! id && typeof tinymce !== 'undefined' && tinymce.activeEditor )
49+                               id = tinymce.activeEditor.id;
50+
51+                       // Last but not least, fall back to the empty string.
52+                       id = id || '';
53+                       return id;
54+               },
55+
56                get: function( id ) {
57+                       id = this.id( id );
58                        return workflows[ id ];
59                },
60 
61                remove: function( id ) {
62+                       id = this.id( id );
63                        delete workflows[ id ];
64                },
65 
66@@ -497,6 +536,30 @@
67                        }
68                },
69 
70+               open: function( id ) {
71+                       var workflow, editor;
72+
73+                       id = this.id( id );
74+
75+                       // Save a bookmark of the caret position in IE.
76+                       if ( typeof tinymce !== 'undefined' ) {
77+                               editor = tinymce.get( id );
78+
79+                               if ( tinymce.isIE && editor && ! editor.isHidden() ) {
80+                                       editor.focus();
81+                                       editor.windowManager.insertimagebookmark = editor.selection.getBookmark();
82+                               }
83+                       }
84+
85+                       workflow = this.get( id );
86+
87+                       // Initialize the editor's workflow if we haven't yet.
88+                       if ( ! workflow )
89+                               workflow = this.add( id );
90+
91+                       return workflow.open();
92+               },
93+
94                init: function() {
95                        $(document.body).on( 'click', '.insert-media', function( event ) {
96                                var $this = $(this),
97@@ -513,45 +576,40 @@
98 
99                                wp.media.editor.open( editor );
100                        });
101-               },
102 
103-               open: function( id ) {
104-                       var workflow, editor;
105+                       // Open the content media manager to the 'featured image' tab when
106+                       // the post thumbnail is clicked.
107+                       $('#postimagediv').on( 'click', '#set-post-thumbnail', function( event ) {
108+                               event.preventDefault();
109+                               // Stop propagation to prevent thickbox from activating.
110+                               event.stopPropagation();
111 
112-                       // If an empty `id` is provided, default to `wpActiveEditor`.
113-                       id = id || wpActiveEditor;
114+                               // Always get the 'content' frame, since this is tailored to post.php.
115+                               var frame = wp.media.editor.add('content'),
116+                                       initialState = frame.state().id,
117+                                       escape;
118 
119-                       if ( typeof tinymce !== 'undefined' && tinymce.activeEditor ) {
120-                               // If that doesn't work, fall back to `tinymce.activeEditor`.
121-                               if ( ! id ) {
122-                                       editor = tinymce.activeEditor;
123-                                       id = id || editor.id;
124-                               } else {
125-                                       editor = tinymce.get( id );
126-                               }
127+                               escape = function() {
128+                                       // Only run this event once.
129+                                       this.off( 'escape', escape );
130 
131-                               // Save a bookmark of the caret position, needed for IE
132-                               if ( tinymce.isIE && editor && ! editor.isHidden() ) {
133-                                       editor.focus();
134-                                       editor.windowManager.insertimagebookmark = editor.selection.getBookmark();
135-                               }
136-                       }
137+                                       // If we're still on the 'featured-image' state, restore
138+                                       // the initial state.
139+                                       if ( 'featured-image' === this.state().id )
140+                                               this.setState( initialState );
141+                               };
142 
143-                       // Last but not least, fall back to the empty string.
144-                       id = id || '';
145+                               frame.on( 'escape', escape, frame );
146 
147-                       workflow = wp.media.editor.get( id );
148+                               frame.setState('featured-image').open();
149 
150-                       // If the workflow exists, open it.
151-                       // Initialize the editor's workflow if we haven't yet.
152-                       if ( workflow )
153-                               workflow.open();
154-                       else
155-                               workflow = wp.media.editor.add( id );
156-
157-                       return workflow;
158+                       // Update the featured image id when the 'remove' link is clicked.
159+                       }).on( 'click', '#remove-post-thumbnail', function() {
160+                               wp.media.view.settings.featuredImage.id = -1;
161+                       });
162                }
163        };
164 
165+       _.bindAll( wp.media.editor, 'open' );
166        $( wp.media.editor.init );
167 }(jQuery));
168Index: wp-includes/js/media-views.js
169===================================================================
170--- wp-includes/js/media-views.js       (revision 22973)
171+++ wp-includes/js/media-views.js       (working copy)
172@@ -170,7 +170,7 @@
173                        // created the `states` collection, or are trying to select a state
174                        // that does not exist.
175                        if ( ( previous && id === previous.id ) || ! this.states || ! this.states.get( id ) )
176-                               return;
177+                               return this;
178 
179                        if ( previous ) {
180                                previous.trigger('deactivate');
181@@ -179,6 +179,8 @@
182 
183                        this._state = id;
184                        this.state().trigger('activate');
185+
186+                       return this;
187                },
188 
189                // Returns the previous active state.
190@@ -549,7 +551,40 @@
191                }
192        });
193 
194+       // wp.media.controller.FeaturedImage
195+       // ---------------------------------
196+       media.controller.FeaturedImage = media.controller.Library.extend({
197+               defaults: _.defaults({
198+                       id:         'featured-image',
199+                       filterable: 'uploaded',
200+                       multiple:   false,
201+                       menu:       'main',
202+                       toolbar:    'featured-image'
203+               }, media.controller.Library.prototype.defaults ),
204 
205+               initialize: function() {
206+                       // If we haven't been provided a `library`, create a `Selection`.
207+                       if ( ! this.get('library') )
208+                               this.set( 'library', media.query({ type: 'image' }) );
209+
210+                       media.controller.Library.prototype.initialize.apply( this, arguments );
211+               },
212+
213+               activate: function() {
214+                       var selection = this.get('selection'),
215+                               id = media.view.settings.featuredImage.id;
216+
217+                       if ( '' !== id && -1 !== id ) {
218+                               attachment = Attachment.get( id );
219+                               attachment.fetch();
220+                       }
221+
222+                       selection.reset( attachment ? [ attachment ] : [] );
223+                       media.controller.Library.prototype.activate.apply( this, arguments );
224+               }
225+       });
226+
227+
228        // wp.media.controller.Embed
229        // -------------------------
230        media.controller.Embed = media.controller.State.extend({
231@@ -605,7 +640,9 @@
232                        }, this );
233 
234                        this.set( 'url', '' );
235-                       this.frame.toolbar.view().refresh();
236+
237+                       if ( this.id === this.frame.state().id )
238+                               this.frame.toolbar.view().refresh();
239                }
240        });
241 
242@@ -1077,9 +1114,10 @@
243                        if ( this.options.modal ) {
244                                this.modal = new media.view.Modal({
245                                        controller: this,
246-                                       $content:   this.$el,
247                                        title:      this.options.title
248                                });
249+
250+                               this.modal.content( this );
251                        }
252 
253                        // Force the uploader off if the upload limit has been exceeded or
254@@ -1102,14 +1140,6 @@
255                        this.on( 'attach', _.bind( this.views.ready, this.views ), this );
256                },
257 
258-               render: function() {
259-                       if ( this.modal )
260-                               this.modal.render();
261-
262-                       media.view.Frame.prototype.render.apply( this, arguments );
263-                       return this;
264-               },
265-
266                createIframeStates: function( options ) {
267                        var settings = media.view.settings,
268                                tabs = settings.tabs,
269@@ -1186,7 +1216,7 @@
270        });
271 
272        // Map some of the modal's methods to the frame.
273-       _.each(['open','close','attach','detach'], function( method ) {
274+       _.each(['open','close','attach','detach','escape'], function( method ) {
275                media.view.MediaFrame.prototype[ method ] = function( view ) {
276                        if ( this.modal )
277                                this.modal[ method ].apply( this.modal, arguments );
278@@ -1202,7 +1232,6 @@
279                        media.view.MediaFrame.prototype.initialize.apply( this, arguments );
280 
281                        _.defaults( this.options, {
282-                               state:     'upload',
283                                selection: [],
284                                library:   {},
285                                multiple:  false
286@@ -1349,7 +1378,6 @@
287        media.view.MediaFrame.Post = media.view.MediaFrame.Select.extend({
288                initialize: function() {
289                        _.defaults( this.options, {
290-                               state:     'upload',
291                                multiple:  true,
292                                editing:   false
293                        });
294@@ -1409,6 +1437,14 @@
295                                        libraryState: 'gallery-edit'
296                                })
297                        ]);
298+
299+
300+                       if ( media.view.settings.featuredImage ) {
301+                               this.states.add( new media.controller.FeaturedImage({
302+                                       controller: this,
303+                                       menu:       'main'
304+                               }) );
305+                       }
306                },
307 
308                bindHandlers: function() {
309@@ -1427,6 +1463,7 @@
310                                        toolbar: {
311                                                'main-attachments': 'mainAttachmentsToolbar',
312                                                'main-embed':       'mainEmbedToolbar',
313+                                               'featured-image':   'featuredImageToolbar',
314                                                'gallery-edit':     'galleryEditToolbar',
315                                                'gallery-add':      'galleryAddToolbar'
316                                        }
317@@ -1444,15 +1481,22 @@
318                        media.view.MediaFrame.Select.prototype.mainMenu.call( this, { silent: true });
319 
320                        this.menu.view().set({
321-                               separateLibrary: new media.View({
322+                               'library-separator': new media.View({
323                                        className: 'separator',
324                                        priority: 60
325                                }),
326-                               embed: {
327+                               'embed': {
328                                        text: l10n.fromUrlTitle,
329                                        priority: 80
330                                }
331                        });
332+
333+                       if ( media.view.settings.featuredImage ) {
334+                               this.menu.view().set( 'featured-image', {
335+                                       text: l10n.featuredImageTitle,
336+                                       priority: 100
337+                               });
338+                       }
339                },
340 
341                galleryMenu: function() {
342@@ -1559,6 +1603,14 @@
343                        }) );
344                },
345 
346+               featuredImageToolbar: function() {
347+                       this.toolbar.view( new media.view.Toolbar.Select({
348+                               controller: this,
349+                               text:       l10n.setFeaturedImage,
350+                               state:      this.options.state || 'upload'
351+                       }) );
352+               },
353+
354                mainEmbedToolbar: function() {
355                        this.toolbar.view( new media.view.Toolbar.Embed({
356                                controller: this
357@@ -1629,7 +1681,7 @@
358                },
359 
360                events: {
361-                       'click .media-modal-backdrop, .media-modal-close': 'closeHandler',
362+                       'click .media-modal-backdrop, .media-modal-close': 'escapeHandler',
363                        'keydown': 'keydown'
364                },
365 
366@@ -1643,56 +1695,73 @@
367                        });
368                },
369 
370-               render: function() {
371-                       // Ensure content div exists.
372-                       this.options.$content = this.options.$content || $('<div />');
373-
374-                       // Detach the content element from the DOM to prevent
375-                       // `this.$el.html()` from garbage collecting its events.
376-                       this.options.$content.detach();
377-
378-                       this.$el.html( this.template({
379+               prepare: function() {
380+                       return {
381                                title: this.options.title
382-                       }) );
383-
384-                       this.options.$content.addClass('media-modal-content');
385-                       this.$('.media-modal').append( this.options.$content );
386-                       return this;
387+                       };
388                },
389 
390                attach: function() {
391+                       if ( this.views.attached )
392+                               return this;
393+
394+                       if ( ! this.views.rendered )
395+                               this.render();
396+
397                        this.$el.appendTo( this.options.container );
398+
399+                       // Manually mark the view as attached and trigger ready.
400+                       this.views.attached = true;
401+                       this.views.ready();
402+
403                        return this.propagate('attach');
404                },
405 
406                detach: function() {
407+                       if ( this.$el.is(':visible') )
408+                               this.close();
409+
410                        this.$el.detach();
411+                       this.views.attached = false;
412                        return this.propagate('detach');
413                },
414 
415                open: function() {
416+                       if ( this.$el.is(':visible') )
417+                               return this;
418+
419+                       if ( ! this.views.attached )
420+                               this.attach();
421+
422                        this.$el.show().focus();
423                        return this.propagate('open');
424                },
425 
426-               close: function() {
427+               close: function( options ) {
428+                       if ( ! this.views.attached || ! this.$el.is(':visible') )
429+                               return this;
430+
431                        this.$el.hide();
432-                       return this.propagate('close');
433+                       this.propagate('close');
434+
435+                       if ( options && options.escape )
436+                               this.propagate('escape');
437+
438+                       return this;
439                },
440 
441-               closeHandler: function( event ) {
442+               escape: function() {
443+                       return this.close({ escape: true });
444+               },
445+
446+               escapeHandler: function( event ) {
447                        event.preventDefault();
448-                       this.close();
449+                       this.escape();
450                },
451 
452-               content: function( $content ) {
453-                       // Detach any existing content to prevent events from being lost.
454-                       if ( this.options.$content )
455-                               this.options.$content.detach();
456-
457-                       // Set and render the content.
458-                       this.options.$content = ( $content instanceof Backbone.View ) ? $content.$el : $content;
459-                       return this.render();
460+               content: function( content ) {
461+                       this.views.set( '.media-modal-content', content );
462+                       return this;
463                },
464 
465                // Triggers a modal event and if the `propagate` option is set,
466@@ -1710,7 +1779,7 @@
467                        // Close the modal when escape is pressed.
468                        if ( 27 === event.which ) {
469                                event.preventDefault();
470-                               this.close();
471+                               this.escape();
472                                return;
473                        }
474                }
475Index: wp-includes/js/media-models.js
476===================================================================
477--- wp-includes/js/media-models.js      (revision 22973)
478+++ wp-includes/js/media-models.js      (working copy)
479@@ -30,10 +30,8 @@
480                        frame = new MediaFrame.Post( attributes );
481 
482                delete attributes.frame;
483-               // Set the default state.
484-               frame.setState( frame.options.state );
485-               // Render, attach, and open the frame.
486-               return frame.render().attach().open();
487+
488+               return frame;
489        };
490 
491        _.extend( media, { model: {}, view: {}, controller: {} });
492@@ -235,6 +233,9 @@
493 
494                        // Overload the `update` request so properties can be saved.
495                        } else if ( 'update' === method ) {
496+                               if ( ! this.get('nonces') )
497+                                       return $.Deferred().resolveWith( this ).promise();
498+
499                                options = options || {};
500                                options.context = this;
501 
502Index: wp-includes/media.php
503===================================================================
504--- wp-includes/media.php       (revision 22973)
505+++ wp-includes/media.php       (working copy)
506@@ -1434,6 +1434,16 @@
507                $post = get_post( $args['post'] );
508                $settings['postId'] = $post->ID;
509                $settings['nonce']['updatePost'] = wp_create_nonce( 'update-post_' . $post->ID );
510+
511+               if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
512+
513+                       $featuredImageId = get_post_meta( $post->ID, '_thumbnail_id', true );
514+
515+                       $settings['featuredImage'] = array(
516+                               'id'    => $featuredImageId ? $featuredImageId : -1,
517+                               'nonce' => wp_create_nonce( 'set_post_thumbnail-' . $post->ID ),
518+                       );
519+               }
520        }
521 
522        $hier = $post && is_post_type_hierarchical( $post->post_type );
523@@ -1467,6 +1477,10 @@
524                // From URL
525                'fromUrlTitle'       => __( 'From URL' ),
526 
527+               // Featured Images
528+               'featuredImageTitle'  => __( 'Featured Image' ),
529+               'setFeaturedImage'    => __( 'Set featured image' ),
530+
531                // Gallery
532                'createGalleryTitle' => __( 'Create Gallery' ),
533                'editGalleryTitle'   => __( 'Edit Gallery' ),
534@@ -1511,6 +1525,7 @@
535                <div class="media-modal wp-core-ui">
536                        <h3 class="media-modal-title">{{ data.title }}</h3>
537                        <a class="media-modal-close media-modal-icon" href="#" title="<?php esc_attr_e('Close'); ?>"></a>
538+                       <div class="media-modal-content"></div>
539                </div>
540                <div class="media-modal-backdrop">
541                        <div></div>
542Index: wp-includes/css/media-views.css
543===================================================================
544--- wp-includes/css/media-views.css     (revision 22973)
545+++ wp-includes/css/media-views.css     (working copy)
546@@ -403,6 +403,11 @@
547  */
548 .media-frame {
549        overflow: hidden;
550+       position: absolute;
551+       top: 0;
552+       left: 0;
553+       right: 0;
554+       bottom: 0;
555 }
556 
557 .media-frame .region-content {
558Index: wp-admin/includes/ajax-actions.php
559===================================================================
560--- wp-admin/includes/ajax-actions.php  (revision 22973)
561+++ wp-admin/includes/ajax-actions.php  (working copy)
562@@ -1674,23 +1674,31 @@
563 }
564 
565 function wp_ajax_set_post_thumbnail() {
566+       $json = ! empty( $_REQUEST['json'] );
567+
568        $post_ID = intval( $_POST['post_id'] );
569-       if ( !current_user_can( 'edit_post', $post_ID ) )
570-               wp_die( -1 );
571+       if ( !current_user_can( 'edit_post', $post_ID ) ) {
572+               $json ? wp_send_json_error() : wp_die( -1 );
573+       }
574        $thumbnail_id = intval( $_POST['thumbnail_id'] );
575 
576        check_ajax_referer( "set_post_thumbnail-$post_ID" );
577 
578        if ( $thumbnail_id == '-1' ) {
579-               if ( delete_post_thumbnail( $post_ID ) )
580-                       wp_die( _wp_post_thumbnail_html( null, $post_ID ) );
581-               else
582-                       wp_die( 0 );
583+               if ( delete_post_thumbnail( $post_ID ) ) {
584+                       $return = _wp_post_thumbnail_html( null, $post_ID );
585+                       $json ? wp_send_json_success( $return ) : wp_die( $return );
586+               } else {
587+                       $json ? wp_send_json_error() : wp_die( 0 );
588+               }
589        }
590 
591-       if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
592-               wp_die( _wp_post_thumbnail_html( $thumbnail_id, $post_ID ) );
593-       wp_die( 0 );
594+       if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) {
595+               $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
596+               $json ? wp_send_json_success( $return ) : wp_die( $return );
597+       }
598+
599+       $json ? wp_send_json_error() : wp_die( 0 );
600 }
601 
602 function wp_ajax_date_format() {
603Index: wp-admin/includes/post.php
604===================================================================
605--- wp-admin/includes/post.php  (revision 22973)
606+++ wp-admin/includes/post.php  (working copy)
607@@ -199,14 +199,6 @@
608                        set_post_format( $post_ID, false );
609        }
610 
611-       // Featured Images
612-       if ( isset( $post_data['thumbnail_id'] ) ) {
613-               if ( '-1' == $post_data['thumbnail_id'] )
614-                       delete_post_thumbnail( $post_ID );
615-               else
616-                       set_post_thumbnail( $post_ID, $post_data['thumbnail_id'] );
617-       }
618-
619        // Meta Stuff
620        if ( isset($post_data['meta']) && $post_data['meta'] ) {
621                foreach ( $post_data['meta'] as $key => $value ) {
622Index: wp-admin/includes/meta-boxes.php
623===================================================================
624--- wp-admin/includes/meta-boxes.php    (revision 22973)
625+++ wp-admin/includes/meta-boxes.php    (working copy)
626@@ -1001,119 +1001,6 @@
627  * @since 2.9.0
628  */
629 function post_thumbnail_meta_box( $post ) {
630-       global $_wp_additional_image_sizes;
631-
632-       ?><script type="text/javascript">
633-       jQuery( function($) {
634-               var $element     = $('#select-featured-image'),
635-                       $thumbnailId = $element.find('input[name="thumbnail_id"]'),
636-                       title        = '<?php _e( "Choose a Featured Image" ); ?>',
637-                       update       = '<?php _e( "Update Featured Image" ); ?>',
638-                       Attachment   = wp.media.model.Attachment,
639-                       frame, setFeaturedImage;
640-
641-               setFeaturedImage = function( thumbnailId ) {
642-                       var selection;
643-
644-                       $element.find('img').remove();
645-                       $element.toggleClass( 'has-featured-image', -1 != thumbnailId );
646-                       $thumbnailId.val( thumbnailId );
647-
648-                       if ( frame ) {
649-                               selection = frame.state('library').get('selection');
650-
651-                               if ( -1 === thumbnailId )
652-                                       selection.clear();
653-                               else
654-                                       selection.add( Attachment.get( thumbnailId ) );
655-                       }
656-               };
657-
658-               $element.on( 'click', '.choose, img', function( event ) {
659-                       var options, thumbnailId, attachment;
660-
661-                       event.preventDefault();
662-
663-                       if ( frame ) {
664-                               frame.open();
665-                               return;
666-                       }
667-
668-                       options = {
669-                               title:   title,
670-                               library: {
671-                                       type: 'image'
672-                               }
673-                       };
674-
675-                       thumbnailId = $thumbnailId.val();
676-                       if ( '' !== thumbnailId && -1 !== thumbnailId ) {
677-                               attachment = Attachment.get( thumbnailId );
678-                               attachment.fetch();
679-                               options.selection = [ attachment ];
680-                       }
681-
682-                       frame = wp.media( options );
683-
684-                       frame.state('library').set( 'filterable', 'uploaded' );
685-
686-                       frame.toolbar.on( 'activate:select', function() {
687-                               frame.toolbar.view().set({
688-                                       select: {
689-                                               style: 'primary',
690-                                               text:  update,
691-
692-                                               click: function() {
693-                                                       var selection = frame.state().get('selection'),
694-                                                               model = selection.first(),
695-                                                               sizes = model.get('sizes'),
696-                                                               size;
697-
698-                                                       setFeaturedImage( model.id );
699-
700-                                                       // @todo: might need a size hierarchy equivalent.
701-                                                       if ( sizes )
702-                                                               size = sizes['post-thumbnail'] || sizes.medium;
703-
704-                                                       // @todo: Need a better way of accessing full size
705-                                                       // data besides just calling toJSON().
706-                                                       size = size || model.toJSON();
707-
708-                                                       frame.close();
709-
710-                                                       $( '<img />', {
711-                                                               src:    size.url,
712-                                                               width:  size.width
713-                                                       }).prependTo( $element );
714-                                               }
715-                                       }
716-                               });
717-                       });
718-
719-                       frame.toolbar.mode('select');
720-               });
721-
722-               $element.on( 'click', '.remove', function( event ) {
723-                       event.preventDefault();
724-                       setFeaturedImage( -1 );
725-               });
726-       });
727-       </script>
728-
729-       <?php
730-       $thumbnail_id   = get_post_meta( $post->ID, '_thumbnail_id', true );
731-       $thumbnail_size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : 'medium';
732-       $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $thumbnail_size );
733-
734-       $classes = empty( $thumbnail_id ) ? '' : 'has-featured-image';
735-
736-       ?><div id="select-featured-image"
737-               class="<?php echo esc_attr( $classes ); ?>"
738-               data-post-id="<?php echo esc_attr( $post->ID ); ?>">
739-               <?php echo $thumbnail_html; ?>
740-               <input type="hidden" name="thumbnail_id" value="<?php echo esc_attr( $thumbnail_id ); ?>" />
741-               <a href="#" class="choose button-secondary"><?php _e( 'Choose a Featured Image' ); ?></a>
742-               <a href="#" class="remove"><?php _e( 'Remove Featured Image' ); ?></a>
743-       </div>
744-       <?php
745+       $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
746+       echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
747 }
748\ No newline at end of file
749Index: wp-admin/js/custom-background.js
750===================================================================
751--- wp-admin/js/custom-background.js    (revision 22973)
752+++ wp-admin/js/custom-background.js    (working copy)
753@@ -57,7 +57,7 @@
754                                });
755                        });
756 
757-                       frame.setState('library');
758+                       frame.setState('library').open();
759                });
760        });
761 })(jQuery);
762\ No newline at end of file
763Index: wp-admin/js/custom-header.js
764===================================================================
765--- wp-admin/js/custom-header.js        (revision 22973)
766+++ wp-admin/js/custom-header.js        (working copy)
767@@ -40,7 +40,7 @@
768                                });
769                        });
770 
771-                       frame.setState('library');
772+                       frame.setState('library').open();
773                });
774        });
775 }(jQuery));