Ticket #10917: 10917-ajax+useroption.patch
File 10917-ajax+useroption.patch, 6.6 KB (added by , 15 years ago) |
---|
-
wp-admin/includes/dashboard.php
383 383 do_action( 'activity_box_end' ); 384 384 } 385 385 386 function wp_dashboard_quick_press() { 386 function wp_dashboard_quick_press_output() { 387 global $post_ID; 388 387 389 $drafts = false; 388 390 if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) { 389 391 $view = get_permalink( $_POST['post_ID'] ); 390 392 $edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) ); 391 393 if ( 'post-quickpress-publish' == $_POST['action'] ) { 392 394 if ( current_user_can('publish_posts') ) 393 printf( '<div class=" message"><p>' . __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );395 printf( '<div class="updated"><p>' . __( 'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit ); 394 396 else 395 printf( '<div class=" message"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );397 printf( '<div class="updated"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit ); 396 398 } else { 397 printf( '<div class=" message"><p>' . __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );399 printf( '<div class="updated"><p>' . __( 'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit ); 398 400 $drafts_query = new WP_Query( array( 399 401 'post_type' => 'post', 400 402 'post_status' => 'draft', … … 407 409 if ( $drafts_query->posts ) 408 410 $drafts =& $drafts_query->posts; 409 411 } 410 printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href=" tools.php">' . __('Press This') . '</a>' );412 printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' ); 411 413 $_REQUEST = array(); // hack for get_default_post_to_edit() 412 414 } 413 415 414 $post = get_default_post_to_edit(); 416 /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ 417 $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID 418 if ( $last_post_id ) { 419 $post = get_post( $last_post_id ); 420 if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore 421 $post = get_default_post_to_edit('post', true); 422 update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID 423 } else { 424 $post->post_title = ''; // Remove the auto draft title 425 } 426 } else { 427 $post = get_default_post_to_edit('post', true); 428 update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID 429 } 430 431 $post_ID = (int) $post->ID; 415 432 ?> 416 433 417 434 <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press"> … … 440 457 441 458 <p class="submit"> 442 459 <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" /> 443 <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" />460 <input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" /> 444 461 <input type="hidden" name="post_type" value="post" /> 445 462 <?php wp_nonce_field('add-post'); ?> 446 463 <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php esc_attr_e('Save Draft'); ?>" /> … … 459 476 wp_dashboard_recent_drafts( $drafts ); 460 477 } 461 478 479 function wp_dashboard_quick_press() { 480 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 481 } 482 462 483 function wp_dashboard_recent_drafts( $drafts = false ) { 463 484 if ( !$drafts ) { 464 485 $drafts_query = new WP_Query( array( -
wp-admin/index-extra.php
32 32 case 'dashboard_plugins' : 33 33 wp_dashboard_plugins_output(); 34 34 break; 35 36 case 'dashboard_quick_press' : 37 wp_dashboard_quick_press_output(); 38 break; 35 39 36 40 } 37 41 -
wp-admin/js/dashboard.dev.js
6 6 'dashboard_incoming_links', 7 7 'dashboard_primary', 8 8 'dashboard_secondary', 9 'dashboard_plugins' 9 'dashboard_plugins', 10 'dashboard_quick_press' 10 11 ]; 11 12 12 13 ajaxPopulateWidgets = function(el) { … … 20 21 $(this).css('display', ''); 21 22 if ( 'dashboard_plugins' == id && $.isFunction(tb_init) ) 22 23 tb_init('#dashboard_plugins a.thickbox'); 24 if ( 'dashboard_quick_press' == id && $.isFunction(tb_init) ) { 25 tb_init('#dashboard_quick_press a.thickbox'); 26 quickPressLoad(); 27 } 23 28 }); 24 29 }); 25 30 }, i * 500 ); … … 53 58 $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() { 54 59 $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'hidden'); 55 60 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled',''); 61 $('#dashboard_quick_press ul').next('p').remove(); 56 62 $('#dashboard_quick_press ul').find('li').each( function() { 57 63 $('#dashboard_recent_drafts ul').prepend( this ); 58 64 } ).end().remove(); … … 65 71 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); 66 72 67 73 }; 68 quickPressLoad();69 74 70 75 } ); -
wp-admin/post.php
131 131 $_POST['post_ID'] = $post_id; 132 132 // output the quickpress dashboard widget 133 133 require_once(ABSPATH . 'wp-admin/includes/dashboard.php'); 134 wp_dashboard_quick_press ();134 wp_dashboard_quick_press_output(); 135 135 exit; 136 136 } 137 137