wppaste
WordPress

wp_dashboard_quick_press( string|false $message = false, string $notice_type = 'error' )

Since
3.8.0, 7.1.0
Source
wp-admin/includes/dashboard.php:551
Displays the Quick Draft widget.

Compatibility

WordPress
since 7.1.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$messagestring|falseoptional
Error or success message. Default false.Default: false
$notice_typestringoptional
Admin notice type. Default 'error'.Default: 'error'

Performance profile

How much work a call to wp_dashboard_quick_press() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
8–96

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 124.

Plugin surface
1 hook

Third-party callbacks on 'enter_title_here' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • querycontent queryget_post()called directly
  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()one call below wp_dashboard_quick_press()

Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 9 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_dashboard_quick_press() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!current_user_can()8current_user_can()
current_user_can() && !empty($post)76current_user_can(), get_user_option(), get_post(), admin_url(), esc_url(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can() && !empty($post)82current_user_can(), get_user_option(), get_post(), admin_url(), esc_url(), type(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can()83current_user_can(), get_user_option(), get_default_post_to_edit(), get_current_user_id(), get_current_blog_id(), get_blogs_of_user(), array_keys(), admin_url(), esc_url(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can()85–88current_user_can(), get_user_option(), get_post(), get_default_post_to_edit(), get_current_user_id(), update_user_option(), admin_url(), esc_url(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can()89current_user_can(), get_user_option(), get_default_post_to_edit(), get_current_user_id(), get_current_blog_id(), get_blogs_of_user(), array_keys(), admin_url(), esc_url(), type(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can()90current_user_can(), get_user_option(), get_default_post_to_edit(), get_current_user_id(), get_current_blog_id(), get_blogs_of_user(), array_keys(), update_user_option(), admin_url(), esc_url(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can()91–94current_user_can(), get_user_option(), get_post(), get_default_post_to_edit(), get_current_user_id(), update_user_option(), admin_url(), esc_url(), type(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()
current_user_can()96current_user_can(), get_user_option(), get_default_post_to_edit(), get_current_user_id(), get_current_blog_id(), get_blogs_of_user(), array_keys(), update_user_option(), admin_url(), esc_url(), type(), __(), apply_filters(), _e(), esc_attr_e(), wp_nonce_field(), __(), submit_button(), wp_dashboard_recent_drafts()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1248–966
8.51248–966
8.41248–9663 fewer instructions than PHP 8.3
8.31278–996
8.21278–996
8.11278–996
7.41278–996

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while wp_dashboard_quick_press() runs, in this order:

  1. apply_filters( enter_title_here )filterline 603 (+52 into the body)

    Filters the title field placeholder text.

Uses · 18

Show all 18

Used by · 1

Source code

function wp_dashboard_quick_press( $message = false, $notice_type = 'error' ) {	global $post_ID; 	if ( ! current_user_can( 'edit_posts' ) ) {		return;	} 	// 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 ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore.			$post = get_default_post_to_edit( 'post', true );			update_user_option( get_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 );		$user_id = get_current_user_id(); 		// Don't create an option if this is a super admin who does not belong to this site.		if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) {			update_user_option( $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" class="hide-if-no-js"> 		<?php		if ( $message ) {			wp_admin_notice(				$message,				array(					'type'       => $notice_type,					'attributes' => array(						'role' => 'alert',					),				)			);		}		?> 		<div class="input-text-wrap" id="title-wrap">			<label for="title">				<?php				/** This filter is documented in wp-admin/edit-form-advanced.php */				echo apply_filters( 'enter_title_here', __( 'Title' ), $post );				?>			</label>			<input type="text" name="post_title" id="title" autocomplete="off" />		</div> 		<div class="textarea-wrap" id="description-wrap">			<label for="content"><?php _e( 'Content' ); ?></label>			<textarea name="content" id="content" placeholder="<?php esc_attr_e( 'What&#8217;s on your mind?' ); ?>" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>		</div> 		<p class="submit">			<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />			<input type="hidden" name="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' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>			<br class="clear" />		</p> 	</form>	<?php	wp_dashboard_recent_drafts();}

Changelog

Introduced in 3.8.0. 3 changes between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.1.0
Parameter $message added.verified against source
7.1.0
Parameter $notice_type added.verified against source
7.1.0
Parameter $error_msg removed.verified against source
7.1.0
Added $notice_type parameter.from the docblock
3.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/dashboard.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.