Ticket #22673: 22673.diff
| File 22673.diff, 10.6 KB (added by , 13 years ago) |
|---|
-
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', … … 430 430 431 431 workflow.state('featured-image').on( 'select', function() { 432 432 var settings = wp.media.view.settings, 433 featuredImage = settings.featuredImage,434 433 selection = this.get('selection').single(); 435 434 436 if ( ! featuredImage)435 if ( ! settings.post.featuredImageId ) 437 436 return; 438 437 439 featuredImage.id = selection ? selection.id : -1;438 settings.post.featuredImageId = selection ? selection.id : -1; 440 439 wp.media.post( 'set-post-thumbnail', { 441 440 json: true, 442 post_id: settings.post Id,443 thumbnail_id: featuredImage.id,444 _wpnonce: featuredImage.nonce441 post_id: settings.post.id, 442 thumbnail_id: settings.post.featuredImageId, 443 _wpnonce: settings.post.nonce 445 444 }).done( function( html ) { 446 445 $( '.inside', '#postimagediv' ).html( html ); 447 446 }); … … 517 516 nonce: wp.media.view.settings.nonce.sendToEditor, 518 517 attachment: options, 519 518 html: html, 520 post_id: wp.media.view.settings.post Id519 post_id: wp.media.view.settings.post.id 521 520 }).done( function( resp ) { 522 521 wp.media.editor.insert( resp ); 523 522 }); … … 529 528 src: embed.linkUrl, 530 529 title: embed.title, 531 530 html: wp.media.string.link( embed ), 532 post_id: wp.media.view.settings.post Id531 post_id: wp.media.view.settings.post.id 533 532 }).done( function( resp ) { 534 533 wp.media.editor.insert( resp ); 535 534 }); … … 605 604 606 605 // Update the featured image id when the 'remove' link is clicked. 607 606 }).on( 'click', '#remove-post-thumbnail', function() { 608 wp.media.view.settings. featuredImage.id = -1;607 wp.media.view.settings.post.featuredImageId = -1; 609 608 }); 610 609 } 611 610 }; -
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/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(){ … … 572 571 573 572 activate: function() { 574 573 var selection = this.get('selection'), 575 id = media.view.settings. featuredImage.id,574 id = media.view.settings.post.featuredImageId, 576 575 attachment; 577 576 578 577 if ( '' !== id && -1 !== id ) { … … 1448 1447 ]); 1449 1448 1450 1449 1451 if ( media.view.settings. featuredImage) {1450 if ( media.view.settings.post.featuredImageId ) { 1452 1451 this.states.add( new media.controller.FeaturedImage({ 1453 1452 controller: this, 1454 1453 menu: 'main' … … 1500 1499 } 1501 1500 }); 1502 1501 1503 if ( media.view.settings. featuredImage) {1502 if ( media.view.settings.post.featuredImageId ) { 1504 1503 this.menu.view().set( 'featured-image', { 1505 1504 text: l10n.featuredImageTitle, 1506 1505 priority: 100 … … 1827 1826 }, 1828 1827 1829 1828 ready: function() { 1830 var postId = media.view.settings.post Id,1829 var postId = media.view.settings.post.id, 1831 1830 dropzone; 1832 1831 1833 1832 // If the uploader already exists, bail. … … 1878 1877 this.options.$browser = this.controller.uploader.$browser; 1879 1878 1880 1879 if ( _.isUndefined( this.options.postId ) ) 1881 this.options.postId = media.view.settings.post Id;1880 this.options.postId = media.view.settings.post.id; 1882 1881 1883 1882 this.views.set( '.upload-inline-status', new media.view.UploaderStatus({ 1884 1883 controller: this.controller … … 3032 3031 uploaded: { 3033 3032 text: l10n.uploadedToThisPost, 3034 3033 props: { 3035 uploadedTo: media.view.settings.post Id,3034 uploadedTo: media.view.settings.post.id, 3036 3035 orderby: 'menuOrder', 3037 3036 order: 'ASC' 3038 3037 }, … … 3072 3071 text: l10n.uploadedToThisPost, 3073 3072 props: { 3074 3073 type: null, 3075 uploadedTo: media.view.settings.post Id,3074 uploadedTo: media.view.settings.post.id, 3076 3075 orderby: 'menuOrder', 3077 3076 order: 'ASC' 3078 3077 }, -
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/media.php
1426 1426 'nonce' => array( 1427 1427 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ), 1428 1428 ), 1429 'postId' => 0, 1429 'post' => array( 1430 'id' => 0, 1431 ), 1430 1432 ); 1431 1433 1432 1434 $post = null; 1433 1435 if ( isset( $args['post'] ) ) { 1434 1436 $post = get_post( $args['post'] ); 1435 $settings['postId'] = $post->ID; 1436 $settings['nonce']['updatePost'] = wp_create_nonce( 'update-post_' . $post->ID ); 1437 $settings['post'] = array( 1438 'id' => $post->ID, 1439 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), 1440 ); 1437 1441 1438 1442 if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) { 1439 1440 $featuredImageId = get_post_meta( $post->ID, '_thumbnail_id', true ); 1441 1442 $settings['featuredImage'] = array( 1443 'id' => $featuredImageId ? $featuredImageId : -1, 1444 'nonce' => wp_create_nonce( 'set_post_thumbnail-' . $post->ID ), 1445 ); 1443 $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 1444 $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; 1446 1445 } 1447 1446 } 1448 1447 -
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 -
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>