Ticket #38342: 38342.2.diff
File 38342.2.diff, 3.9 KB (added by , 8 years ago) |
---|
-
src/wp-admin/admin-header.php
71 71 <script type="text/javascript"> 72 72 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; 73 73 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', 74 wpApi = wpApi || {}; 74 75 pagenow = '<?php echo $current_screen->id; ?>', 75 76 typenow = '<?php echo $current_screen->post_type; ?>', 76 77 adminpage = '<?php echo $admin_body_class; ?>', … … 77 78 thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', 78 79 decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', 79 80 isRtl = <?php echo (int) is_rtl(); ?>; 81 wpApi.url = '<?php echo esc_url_raw( get_rest_url() ); ?>', 82 wpApi.nonce = '<?php echo esc_attr( wp_create_nonce( 'wp_rest' ) ); ?>', 83 wpApi.success = '<?php echo __( 'Success' ); ?>' 84 wpApi.failure = '<?php echo __( 'Error' ); ?>' 80 85 </script> 81 86 <meta name="viewport" content="width=device-width,initial-scale=1.0"> 82 87 <?php -
src/wp-admin/includes/dashboard.php
518 518 <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" /> 519 519 <input type="hidden" name="post_type" value="post" /> 520 520 <?php wp_nonce_field( 'add-post' ); ?> 521 <span class="spinner"></span> 521 522 <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?> 522 523 <br class="clear" /> 523 524 </p> -
src/wp-admin/js/dashboard.js
63 63 64 64 /* QuickPress */ 65 65 quickPressLoad = function() { 66 var act = $('#quickpost-action'), t; 66 var act = $('#quickpost-action'), t, 67 $quickPress = $( '#dashboard_quick_press' ); 67 68 68 69 $( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false ); 69 70 70 71 t = $('#quick-press').submit( function( e ) { 71 72 e.preventDefault(); 72 $('#dashboard_quick_press #publishing-action .spinner').show(); 73 var title = $quickPress.find( '#title' ).val(), 74 content = $quickPress.find( '#content' ).val(), 75 status = 'draft', 76 data = { 77 title: title, 78 content: content, 79 }; 80 81 // Don't send if the fields are blank. 82 if ( '' === title && '' === content ) { 83 return false; 84 } 85 86 $quickPress.find( '.spinner' ).show(); 73 87 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true); 74 88 75 $.post( t.attr( 'action' ), t.serializeArray(), function( data ) { 76 // Replace the form, and prepend the published post. 77 $('#dashboard_quick_press .inside').html( data ); 78 $('#quick-press').removeClass('initial-form'); 79 quickPressLoad(); 80 highlightLatestPost(); 81 $('#title').focus(); 82 }); 89 $.ajax( { 90 method: "POST", 91 url: wpApi.url + 'wp/v2/posts', 92 data: data, 93 beforeSend: function ( xhr ) { 83 94 95 // Add a nonce to the request. 96 xhr.setRequestHeader( 'X-WP-Nonce', wpApi.nonce ); 97 }, 98 complete: function( response ) { 99 100 // After the form submission, reset everything. 101 $( '#quick-press' ).removeClass( 'initial-form' ); 102 quickPressLoad(); 103 highlightLatestPost(); 104 $( '#title' ).focus(); 105 $quickPress.find( '.spinner' ).hide(); 106 } 107 } ); 108 84 109 function highlightLatestPost () { 85 110 var latestPost = $('.drafts ul li').first(); 86 111 latestPost.css('background', '#fffbe5');