wppaste
WordPress

_admin_notice_post_locked()

Since
2.8.5
Source
wp-admin/includes/post.php:1786
Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post.

Hooks fired · 4

4 hooks fire while _admin_notice_post_locked() runs, in this order:

  1. apply_filters( show_post_locked_dialog )filterline 1812 (+26 into the body)

    Filters whether to show the post locked dialog.

  2. apply_filters( override_post_lock )filterline 1871 (+85 into the body)

    Filters whether to allow the post lock to be overridden.

  3. do_action( post_locked_dialog )actionline 1898 (+112 into the body)

    Fires inside the post locked dialog before the buttons are displayed.

  4. do_action( post_lock_lost_dialog )actionline 1935 (+149 into the body)

    Fires inside the dialog displayed when a user has lost the post lock.

Uses · 20

Show all 20
  • get_avatar()Retrieves the avatar `` tag for a user, email address, MD5 hash, comment, or post.
  • esc_html()Escaping for HTML blocks.
  • do_action()Calls the callback functions that have been added to an action hook.
  • esc_url()Checks and cleans a URL.
  • esc_html_x()Translates string with gettext context, and escapes it for safe use in HTML output.
  • wp_nonce_url()Retrieves URL with nonce added to URL query.
  • get_edit_post_link()Retrieves the edit post link for post.
  • _e()Displays translated text.

Source

function _admin_notice_post_locked() {	$post = get_post(); 	if ( ! $post ) {		return;	} 	$user    = null;	$user_id = wp_check_post_lock( $post->ID ); 	if ( $user_id ) {		$user = get_userdata( $user_id );	} 	if ( $user ) {		/**		 * Filters whether to show the post locked dialog.		 *		 * Returning false from the filter will prevent the dialog from being displayed.		 *		 * @since 3.6.0		 *		 * @param bool    $display Whether to display the dialog. Default true.		 * @param WP_Post $post    Post object.		 * @param WP_User $user    The user with the lock for the post.		 */		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) {			return;		} 		$locked = true;	} else {		$locked = false;	} 	$sendback      = wp_get_referer();	$sendback_text = __( 'Go back' ); 	if ( ! $locked || ! $sendback || str_contains( $sendback, 'post.php' ) || str_contains( $sendback, 'post-new.php' ) ) {		$sendback = admin_url( 'edit.php' ); 		if ( 'post' !== $post->post_type ) {			$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );		} 		$post_type_object = get_post_type_object( $post->post_type ); 		if ( $post_type_object ) {			$sendback_text = $post_type_object->labels->all_items;		}	} 	$hidden = $locked ? '' : ' hidden'; 	?>	<div id="post-lock-dialog" class="notification-dialog-wrap<?php echo $hidden; ?>">	<div class="notification-dialog-background"></div>	<div class="notification-dialog">	<?php 	if ( $locked ) {		$query_args = array();		if ( get_post_type_object( $post->post_type )->public ) {			if ( 'publish' === $post->post_status || $user->ID !== (int) $post->post_author ) {				// Latest content is in autosave.				$nonce                       = wp_create_nonce( 'post_preview_' . $post->ID );				$query_args['preview_id']    = $post->ID;				$query_args['preview_nonce'] = $nonce;			}		} 		$preview_link = get_preview_post_link( $post->ID, $query_args ); 		/**		 * Filters whether to allow the post lock to be overridden.		 *		 * Returning false from the filter will disable the ability		 * to override the post lock.		 *		 * @since 3.6.0

History

Introduced in 2.8.5. Unchanged from 6.7.7 through 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.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/post.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.