Changeset 22994
- Timestamp:
- 12/03/2012 07:17:10 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
wp-admin/includes/ajax-actions.php (modified) (2 diffs)
-
wp-admin/includes/dashboard.php (modified) (2 diffs)
-
wp-includes/js/media-editor.js (modified) (5 diffs)
-
wp-includes/js/media-models.js (modified) (4 diffs)
-
wp-includes/js/media-views.js (modified) (11 diffs)
-
wp-includes/js/plupload/wp-plupload.js (modified) (1 diff)
-
wp-includes/media.php (modified) (2 diffs)
-
wp-includes/script-loader.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r22979 r22994 1675 1675 1676 1676 function wp_ajax_set_post_thumbnail() { 1677 $json = ! empty( $_REQUEST['json'] ); 1677 $json = ! empty( $_REQUEST['json'] ); // New-style request 1678 1678 1679 1679 $post_ID = intval( $_POST['post_id'] ); … … 1683 1683 $thumbnail_id = intval( $_POST['thumbnail_id'] ); 1684 1684 1685 check_ajax_referer( "set_post_thumbnail-$post_ID" ); 1685 if ( $json ) 1686 check_ajax_referer( "update-post_$post_ID" ); 1687 else 1688 check_ajax_referer( "set_post_thumbnail-$post_ID" ); 1686 1689 1687 1690 if ( $thumbnail_id == '-1' ) { -
trunk/wp-admin/includes/dashboard.php
r22964 r22994 506 506 507 507 $post_ID = (int) $post->ID; 508 509 $media_settings = array( 510 'id' => $post->ID, 511 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), 512 ); 513 514 if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) { 515 $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 516 $media_settings['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; 517 } 508 518 ?> 509 519 … … 525 535 </div> 526 536 527 <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script> 537 <script type="text/javascript"> 538 edCanvas = document.getElementById('content'); 539 edInsertContent = null; 540 <?php if ( $_POST ) : ?> 541 wp.media.editor.remove('content'); 542 wp.media.view.settings.post = <?php echo json_encode( $media_settings ); // big juicy hack. ?>; 543 wp.media.editor.add('content'); 544 <?php endif; ?> 545 </script> 528 546 529 547 <div class="input-text-wrap" id="tags-input-wrap"> -
trunk/wp-includes/js/media-editor.js
r22987 r22994 164 164 defaults: { 165 165 order: 'ASC', 166 id: wp.media.view.settings.post Id,166 id: wp.media.view.settings.post.id, 167 167 itemtag: 'dl', 168 168 icontag: 'dt', … … 440 440 workflow.state('featured-image').on( 'select', function() { 441 441 var settings = wp.media.view.settings, 442 featuredImage = settings.featuredImage,443 442 selection = this.get('selection').single(); 444 443 445 if ( ! featuredImage)444 if ( ! settings.post.featuredImageId ) 446 445 return; 447 446 448 featuredImage.id = selection ? selection.id : -1;447 settings.post.featuredImageId = selection ? selection.id : -1; 449 448 wp.media.post( 'set-post-thumbnail', { 450 449 json: true, 451 post_id: settings.post Id,452 thumbnail_id: featuredImage.id,453 _wpnonce: featuredImage.nonce450 post_id: settings.post.id, 451 thumbnail_id: settings.post.featuredImageId, 452 _wpnonce: settings.post.nonce 454 453 }).done( function( html ) { 455 454 $( '.inside', '#postimagediv' ).html( html ); … … 527 526 attachment: options, 528 527 html: html, 529 post_id: wp.media.view.settings.post Id528 post_id: wp.media.view.settings.post.id 530 529 }).done( function( resp ) { 531 530 wp.media.editor.insert( resp ); … … 539 538 title: embed.title, 540 539 html: wp.media.string.link( embed ), 541 post_id: wp.media.view.settings.post Id540 post_id: wp.media.view.settings.post.id 542 541 }).done( function( resp ) { 543 542 wp.media.editor.insert( resp ); … … 615 614 // Update the featured image id when the 'remove' link is clicked. 616 615 }).on( 'click', '#remove-post-thumbnail', function() { 617 wp.media.view.settings. featuredImage.id = -1;616 wp.media.view.settings.post.featuredImageId = -1; 618 617 }); 619 618 } -
trunk/wp-includes/js/media-models.js
r22987 r22994 245 245 id: this.id, 246 246 nonce: this.get('nonces').update, 247 post_id: media.model.settings.post Id247 post_id: media.model.settings.post.id 248 248 }); 249 249 … … 290 290 id: this.id, 291 291 nonce: this.get('nonces').update, 292 post_id: media.model.settings.post Id292 post_id: media.model.settings.post.id 293 293 }, data ) ).done( function( resp, status, xhr ) { 294 294 model.set( model.parse( resp, xhr ), options ); … … 549 549 550 550 return media.post( 'save-attachment-order', { 551 nonce: media.model.settings. updatePostNonce,552 post_id: media.model.settings.post Id,551 nonce: media.model.settings.post.nonce, 552 post_id: media.model.settings.post.id, 553 553 attachments: attachments 554 554 }); … … 706 706 options.data = _.extend( options.data || {}, { 707 707 action: 'query-attachments', 708 post_id: media.model.settings.post Id708 post_id: media.model.settings.post.id 709 709 }); 710 710 -
trunk/wp-includes/js/media-views.js
r22993 r22994 13 13 delete l10n.settings; 14 14 15 // Copy the `postId` setting over to the model settings. 16 media.model.settings.postId = media.view.settings.postId; 17 media.model.settings.updatePostNonce = media.view.settings.nonce.updatePost; 15 // Copy the `post` setting over to the model settings. 16 media.model.settings.post = media.view.settings.post; 18 17 19 18 // Check if the browser supports CSS 3.0 transitions … … 608 607 activate: function() { 609 608 var selection = this.get('selection'), 610 id = media.view.settings. featuredImage.id,609 id = media.view.settings.post.featuredImageId, 611 610 attachment; 612 611 … … 1484 1483 1485 1484 1486 if ( media.view.settings. featuredImage) {1485 if ( media.view.settings.post.featuredImageId ) { 1487 1486 this.states.add( new media.controller.FeaturedImage({ 1488 1487 controller: this, … … 1536 1535 }); 1537 1536 1538 if ( media.view.settings. featuredImage) {1537 if ( media.view.settings.post.featuredImageId ) { 1539 1538 this.menu.view().set( 'featured-image', { 1540 1539 text: l10n.featuredImageTitle, … … 1863 1862 1864 1863 ready: function() { 1865 var postId = media.view.settings.post Id,1864 var postId = media.view.settings.post.id, 1866 1865 dropzone; 1867 1866 … … 1914 1913 1915 1914 if ( _.isUndefined( this.options.postId ) ) 1916 this.options.postId = media.view.settings.post Id;1915 this.options.postId = media.view.settings.post.id; 1917 1916 1918 1917 this.views.set( '.upload-inline-status', new media.view.UploaderStatus({ … … 3078 3077 }, 3079 3078 3080 filters: {},3081 3079 keys: [], 3082 3080 3083 3081 initialize: function() { 3082 this.createFilters(); 3083 3084 3084 // Build `<option>` elements. 3085 3085 this.$el.html( _.chain( this.filters ).map( function( filter, value ) { … … 3094 3094 }, 3095 3095 3096 createFilters: function() { 3097 this.filters = {}; 3098 }, 3099 3096 3100 change: function( event ) { 3097 3101 var filter = this.filters[ this.el.value ]; … … 3120 3124 3121 3125 media.view.AttachmentFilters.Uploaded = media.view.AttachmentFilters.extend({ 3122 filters: { 3123 all: { 3124 text: l10n.allMediaItems, 3125 props: { 3126 uploadedTo: null, 3127 orderby: 'date', 3128 order: 'DESC' 3126 createFilters: function() { 3127 this.filters = { 3128 all: { 3129 text: l10n.allMediaItems, 3130 props: { 3131 uploadedTo: null, 3132 orderby: 'date', 3133 order: 'DESC' 3134 }, 3135 priority: 10 3129 3136 }, 3130 priority: 10 3131 }, 3132 3133 uploaded: { 3134 text: l10n.uploadedToThisPost, 3135 props: { 3136 uploadedTo: media.view.settings.postId, 3137 orderby: 'menuOrder', 3138 order: 'ASC' 3139 }, 3140 priority: 20 3141 } 3137 3138 uploaded: { 3139 text: l10n.uploadedToThisPost, 3140 props: { 3141 uploadedTo: media.view.settings.post.id, 3142 orderby: 'menuOrder', 3143 order: 'ASC' 3144 }, 3145 priority: 20 3146 } 3147 }; 3142 3148 } 3143 3149 }); 3144 3150 3145 3151 media.view.AttachmentFilters.All = media.view.AttachmentFilters.extend({ 3146 filters: (function() {3152 createFilters: function() { 3147 3153 var filters = {}; 3148 3154 … … 3174 3180 props: { 3175 3181 type: null, 3176 uploadedTo: media.view.settings.post Id,3182 uploadedTo: media.view.settings.post.id, 3177 3183 orderby: 'menuOrder', 3178 3184 order: 'ASC' … … 3181 3187 }; 3182 3188 3183 returnfilters;3184 } ())3189 this.filters = filters; 3190 } 3185 3191 }); 3186 3192 -
trunk/wp-includes/js/plupload/wp-plupload.js
r22974 r22994 158 158 filename: file.name, 159 159 menuOrder: 0, 160 uploadedTo: wp.media.model.settings.post Id160 uploadedTo: wp.media.model.settings.post.id 161 161 }, _.pick( file, 'loaded', 'size', 'percent' ) ); 162 162 -
trunk/wp-includes/media.php
r22991 r22994 1428 1428 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ), 1429 1429 ), 1430 'postId' => 0, 1430 'post' => array( 1431 'id' => 0, 1432 ), 1431 1433 ); 1432 1434 … … 1434 1436 if ( isset( $args['post'] ) ) { 1435 1437 $post = get_post( $args['post'] ); 1436 $settings['postId'] = $post->ID; 1437 $settings['nonce']['updatePost'] = wp_create_nonce( 'update-post_' . $post->ID ); 1438 $settings['post'] = array( 1439 'id' => $post->ID, 1440 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), 1441 ); 1438 1442 1439 1443 if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) { 1440 1441 $featuredImageId = get_post_meta( $post->ID, '_thumbnail_id', true ); 1442 1443 $settings['featuredImage'] = array( 1444 'id' => $featuredImageId ? $featuredImageId : -1, 1445 'nonce' => wp_create_nonce( 'set_post_thumbnail-' . $post->ID ), 1446 ); 1444 $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 1445 $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; 1447 1446 } 1448 1447 } -
trunk/wp-includes/script-loader.php
r22947 r22994 324 324 'settings' => array( 325 325 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), 326 'post Id' => 0,326 'post' => array( 'id' => 0 ), 327 327 ), 328 328 ) );
Note: See TracChangeset
for help on using the changeset viewer.