Changeset 785449 for dashboard/trunk/quickdraft.php
- Timestamp:
- 10/09/2013 05:49:27 PM (12 years ago)
- File:
-
- 1 edited
-
dashboard/trunk/quickdraft.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dashboard/trunk/quickdraft.php
r784283 r785449 9 9 } 10 10 11 add_action( 'admin_post_new-quickdraft-post', 'dashboard_plugin_quickdraft_admin_post' ); 12 function dashboard_plugin_quickdraft_admin_post() { 13 $post = get_post( $_REQUEST['post_ID'] ); 14 check_admin_referer( 'add-' . $post->post_type ); 15 edit_post(); 16 return wp_dashboard_quick_draft(); 17 } 18 11 19 // The QuickDraft widget display and creation of drafts 12 20 function wp_dashboard_quick_draft() { 13 21 global $post_ID; 14 15 if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {16 $view = get_permalink( $_POST['post_ID'] );17 $edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );18 if ( 'post-quickpress-publish' == $_POST['action'] ) {19 if ( current_user_can('publish_posts') )20 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 );21 else22 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 );23 } else {24 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 );25 }26 printf('<p class="easy-blogging">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );27 $_REQUEST = array(); // hack for get_default_post_to_edit()28 }29 22 30 23 /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ … … 47 40 48 41 $post_ID = (int) $post->ID; 49 50 $media_settings = array(51 'id' => $post->ID,52 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),53 );54 55 if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {56 $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );57 $media_settings['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;58 }59 42 ?> 60 43 61 <form name="post" action="<?php echo esc_url( admin_url( ' post.php' ) ); ?>" method="post" id="quick-press" class="initial-form">44 <form name="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="quick-press" class="initial-form"> 62 45 <div class="input-text-wrap" id="title-wrap"> 63 <label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php _e( 'Enter title here'); ?></label>64 <input type="text" name="post_title" id="title" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>"/>46 <label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php _e( "What's on your mind?" ); ?></label> 47 <input type="text" name="post_title" id="title" autocomplete="off" /> 65 48 </div> 66 49 67 <?php if ( current_user_can( 'upload_files' ) ) : ?> 68 <div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons"> 69 <?php do_action( 'media_buttons', 'content' ); ?> 70 </div> 71 <?php endif; ?> 72 73 <div class="textarea-wrap"> 74 <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( "What's on your mind?" ); ?></label> 75 <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"><?php echo esc_textarea( $post->post_content ); ?></textarea> 76 </div> 77 78 <script type="text/javascript"> 79 edCanvas = document.getElementById('content'); 80 edInsertContent = null; 81 <?php if ( $_POST ) : ?> 82 wp.media.editor.remove('content'); 83 wp.media.view.settings.post = <?php echo json_encode( $media_settings ); // big juicy hack. ?>; 84 wp.media.editor.add('content'); 85 <?php endif; ?> 86 </script> 87 88 <div class="input-text-wrap" id="tags-input-wrap"> 89 <label class="screen-reader-text prompt" for="tags-input" id="tags-input-prompt-text"><?php _e( 'Tags (separate with commas)' ); ?></label> 90 <input type="text" name="tags_input" id="tags-input" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /> 50 <div class="textarea-wrap" id="description-wrap"> 51 <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'Enter a description' ); ?></label> 52 <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"></textarea> 91 53 </div> 92 54 93 55 <p class="submit"> 94 <input type="hidden" name="action" id="quickpost-action" value=" post-quickpress-save" />56 <input type="hidden" name="action" id="quickpost-action" value="new-quickdraft-post" /> 95 57 <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" /> 96 58 <input type="hidden" name="post_type" value="post" /> … … 112 74 'post_status' => 'draft', 113 75 'author' => $GLOBALS['current_user']->ID, 114 'posts_per_page' => 5,76 'posts_per_page' => 4, 115 77 'orderby' => 'modified', 116 78 'order' => 'DESC' … … 121 83 if ( $drafts && is_array( $drafts ) ) { 122 84 $list = array(); 85 $draft_count = 0; 123 86 foreach ( $drafts as $draft ) { 87 if ( 3 == $draft_count ) 88 break; 89 90 $draft_count++; 91 124 92 $url = get_edit_post_link( $draft->ID ); 125 93 $title = _draft_or_post_title( $draft->ID ); … … 131 99 ?> 132 100 <div class="drafts"> 101 <?php if ( 3 < count($drafts) ) { ?> 133 102 <p class="view-all"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p> 103 <?php } ?> 134 104 <p class="title"><?php _e('Drafts'); ?></p> 135 105 <ul id="draft-list"> … … 138 108 </div> 139 109 <?php } else { ?> 140 <div class="drafts"><p><?php _e( 'There are no drafts at the moment'); ?></p></div>110 <div class="drafts"><p><?php _e("You have yet to add any drafts."); ?></p></div> 141 111 <?php } 142 112 }
Note: See TracChangeset
for help on using the changeset viewer.