Ticket #22673: 22673.2.diff
| File 22673.2.diff, 12.0 KB (added by , 13 years ago) |
|---|
-
wp-admin/includes/ajax-actions.php
1674 1674 } 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'] ); 1680 1680 if ( !current_user_can( 'edit_post', $post_ID ) ) { … … 1682 1682 } 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' ) { 1688 1691 if ( delete_post_thumbnail( $post_ID ) ) { -
wp-admin/includes/dashboard.php
505 505 } 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 510 520 <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press"> … … 524 534 <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"><?php echo esc_textarea( $post->post_content ); ?></textarea> 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"> 530 548 <label class="screen-reader-text prompt" for="tags-input" id="tags-input-prompt-text"><?php _e( 'Tags (separate with commas)' ); ?></label> -
wp-includes/js/media-editor.js
163 163 return { 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', 169 169 captiontag: 'dd', … … 439 439 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 ); 456 455 }); … … 526 525 nonce: wp.media.view.settings.nonce.sendToEditor, 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 ); 532 531 }); … … 538 537 src: embed.linkUrl, 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 ); 544 543 }); … … 614 613 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 } 620 619 }; -
wp-includes/js/media-models.js
244 244 action: 'save-attachment', 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 250 250 // Record the values of the changed attributes. … … 289 289 return media.post( 'save-attachment-compat', _.defaults({ 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 ); 295 295 }); … … 548 548 return; 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 }); 555 555 } … … 705 705 options.context = this; 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 711 711 // Clone the args so manipulation is non-destructive. -
wp-includes/js/media-views.js
12 12 media.view.settings = l10n.settings || {}; 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 20 19 $.support.transition = (function(){ … … 584 583 585 584 activate: function() { 586 585 var selection = this.get('selection'), 587 id = media.view.settings. featuredImage.id,586 id = media.view.settings.post.featuredImageId, 588 587 attachment; 589 588 590 589 if ( '' !== id && -1 !== id ) { … … 1460 1459 ]); 1461 1460 1462 1461 1463 if ( media.view.settings. featuredImage) {1462 if ( media.view.settings.post.featuredImageId ) { 1464 1463 this.states.add( new media.controller.FeaturedImage({ 1465 1464 controller: this, 1466 1465 menu: 'main' … … 1512 1511 } 1513 1512 }); 1514 1513 1515 if ( media.view.settings. featuredImage) {1514 if ( media.view.settings.post.featuredImageId ) { 1516 1515 this.menu.view().set( 'featured-image', { 1517 1516 text: l10n.featuredImageTitle, 1518 1517 priority: 100 … … 1839 1838 }, 1840 1839 1841 1840 ready: function() { 1842 var postId = media.view.settings.post Id,1841 var postId = media.view.settings.post.id, 1843 1842 dropzone; 1844 1843 1845 1844 // If the uploader already exists, bail. … … 1890 1889 this.options.$browser = this.controller.uploader.$browser; 1891 1890 1892 1891 if ( _.isUndefined( this.options.postId ) ) 1893 this.options.postId = media.view.settings.post Id;1892 this.options.postId = media.view.settings.post.id; 1894 1893 1895 1894 this.views.set( '.upload-inline-status', new media.view.UploaderStatus({ 1896 1895 controller: this.controller … … 3054 3053 change: 'change' 3055 3054 }, 3056 3055 3057 filters: {},3058 3056 keys: [], 3059 3057 3060 3058 initialize: function() { 3059 this.createFilters(); 3060 3061 3061 // Build `<option>` elements. 3062 3062 this.$el.html( _.chain( this.filters ).map( function( filter, value ) { 3063 3063 return { … … 3070 3070 this.select(); 3071 3071 }, 3072 3072 3073 createFilters: function() { 3074 this.filters = {}; 3075 }, 3076 3073 3077 change: function( event ) { 3074 3078 var filter = this.filters[ this.el.value ]; 3075 3079 … … 3096 3100 }); 3097 3101 3098 3102 media.view.AttachmentFilters.Uploaded = media.view.AttachmentFilters.extend({ 3099 filters: { 3100 all: { 3101 text: l10n.allMediaItems, 3102 props: { 3103 uploadedTo: null, 3104 orderby: 'date', 3105 order: 'DESC' 3103 createFilters: function() { 3104 this.filters = { 3105 all: { 3106 text: l10n.allMediaItems, 3107 props: { 3108 uploadedTo: null, 3109 orderby: 'date', 3110 order: 'DESC' 3111 }, 3112 priority: 10 3106 3113 }, 3107 priority: 103108 },3109 3114 3110 uploaded: { 3111 text: l10n.uploadedToThisPost, 3112 props: { 3113 uploadedTo: media.view.settings.postId, 3114 orderby: 'menuOrder', 3115 order: 'ASC' 3116 }, 3117 priority: 20 3118 } 3115 uploaded: { 3116 text: l10n.uploadedToThisPost, 3117 props: { 3118 uploadedTo: media.view.settings.post.id, 3119 orderby: 'menuOrder', 3120 order: 'ASC' 3121 }, 3122 priority: 20 3123 } 3124 }; 3119 3125 } 3120 3126 }); 3121 3127 3122 3128 media.view.AttachmentFilters.All = media.view.AttachmentFilters.extend({ 3123 filters: (function() {3129 createFilters: function() { 3124 3130 var filters = {}; 3125 3131 3126 3132 _.each( media.view.settings.mimeTypes || {}, function( text, key ) { … … 3150 3156 text: l10n.uploadedToThisPost, 3151 3157 props: { 3152 3158 type: null, 3153 uploadedTo: media.view.settings.post Id,3159 uploadedTo: media.view.settings.post.id, 3154 3160 orderby: 'menuOrder', 3155 3161 order: 'ASC' 3156 3162 }, 3157 3163 priority: 20 3158 3164 }; 3159 3165 3160 returnfilters;3161 } ())3166 this.filters = filters; 3167 } 3162 3168 }); 3163 3169 3164 3170 -
wp-includes/js/plupload/wp-plupload.js
157 157 date: new Date(), 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 163 163 // Handle early mime type scanning for images. -
wp-includes/media.php
1427 1427 'nonce' => array( 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 1433 1435 $post = null; 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 } 1449 1448 -
wp-includes/script-loader.php
323 323 did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array( 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 ) ); 329 329