Advertisements

wp_dashboard_quick_press

Definition:
function wp_dashboard_quick_press() {}

Defined actions

  • media_buttons
    do_action( 'media_buttons' );

Source code

function wp_dashboard_quick_press() {

	global $post_ID;



	$drafts = false;

	if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {

		$view = get_permalink( $_POST['post_ID'] );

		$edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );

		if ( 'post-quickpress-publish' == $_POST['action'] ) {

			if ( current_user_can('publish_posts') )

				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 );

			else

				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 );

		} else {

			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 );

			$drafts_query = new WP_Query( array(

				'post_type' => 'post',

				'post_status' => 'draft',

				'author' => $GLOBALS['current_user']->ID,

				'posts_per_page' => 1,

				'orderby' => 'modified',

				'order' => 'DESC'

			) );



			if ( $drafts_query->posts )

				$drafts =& $drafts_query->posts;

		}

		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>' );

		$_REQUEST = array(); // hack for get_default_post_to_edit()

	}



	/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */

	$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID

	if ( $last_post_id ) {

		$post = get_post( $last_post_id );

		if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore

			$post = get_default_post_to_edit('post', true);

			update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID

		} else {

			$post->post_title = ''; // Remove the auto draft title

		}

	} else {

		$post = get_default_post_to_edit('post', true);

		update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID

	}



	$post_ID = (int) $post->ID;

?>



	<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">

		<h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>

		<div class="input-text-wrap">

			<input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />

		</div>



		<?php if ( current_user_can( 'upload_files' ) ) : ?>

		<div id="media-buttons" class="hide-if-no-js">

			<?php do_action( 'media_buttons' ); ?>

		</div>

		<?php endif; ?>



		<h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>

		<div class="textarea-wrap">

			<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo esc_textarea( $post->post_content ); ?></textarea>

		</div>



		<script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>



		<h4><label for="tags-input"><?php _e('Tags') ?></label></h4>

		<div class="input-text-wrap">

			<input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />

		</div>



		<p class="submit">

			<input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />

			<input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />

			<input type="hidden" name="post_type" value="post" />

			<?php wp_nonce_field('add-post'); ?>

			<?php submit_button( __( 'Save Draft' ), 'button', 'save', false, array( 'id' => 'save-post', 'tabindex'=> 4 ) ); ?>

			<input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />

			<span id="publishing-action">

				<input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />

				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />

			</span>

			<br class="clear" />

		</p>



	</form>



<?php

	if ( $drafts )

		wp_dashboard_recent_drafts( $drafts );

}

3547

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: