Home / APIs / _admin_notice_post_locked() – Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post.

You appear to be a bot. Output may be restricted

Description

Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post.

Usage

$none = _admin_notice_post_locked();

Parameters

Returns

none

Source

File name: wordpress/wp-admin/includes/post.php
Lines: 1 to 100 of 149

function _admin_notice_post_locked() {
  if ( ! $post = get_post() )
    return;

  $user = null;
  if (  $user_id = wp_check_post_lock( $post->ID ) )
    $user = get_userdata( $user_id );

  if ( $user ) {

    
/**
 * Filters whether to show the post locked dialog.
 *
 * Returning a falsey value to the filter will short-circuit displaying the dialog.
 *
 * @since 3.6.0
 *
 * @param bool         $display Whether to display the dialog. Default true.
 * @param WP_Post      $post    Post object.
 * @param WP_User|bool $user    WP_User object on success, false otherwise.
 */
    if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
      return;

    $locked = true;
  } else {
    $locked = false;
  }

  if ( $locked && ( $sendback = wp_get_referer() ) &&
    false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {

    $sendback_text = __('Go back');
  } else {
    $sendback = admin_url( 'edit.php' );

    if ( 'post' != $post->post_type )
      $sendback = add_query_arg( 'post_type', $post->post_type, $sendback );

    $sendback_text = get_post_type_object( $post->post_type )->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 != $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 a falsey value to the filter will disable the ability
 * to override the post lock.
 *
 * @since 3.6.0
 *
 * @param bool    $override Whether to allow overriding post locks. Default true.
 * @param WP_Post $post     Post object.
 * @param WP_User $user     User object.
 */
    $override = apply_filters( 'override_post_lock', true, $post, $user );
    $tab_last = $override ? '' : ' wp-tab-last';

    ?>
		<div class="post-locked-message">
		<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
		<p class="currently-editing wp-tab-first" tabindex="0">
		<?php
      if ( $override ) {
        /* translators: %s: user's display name */
        printf( __( '%s is already editing this post. Do you want to take over?' ), esc_html( $user->display_name ) );
      } else {
        /* translators: %s: user's display name */
        printf( __( '%s is already editing this post.' ), esc_html( $user->display_name ) );
      }
    ?>
		</p>
		<?php
    
/**
 * Fires inside the post locked dialog before the buttons are displayed.
 *
 * @since 3.6.0
 *
 * @param WP_Post $post Post object.
 */
 

[1] [2] Next » View on GitHub View on Trac

Related

Published: 13 March 2017 | Last updated: 17 November 2017

Information

Function name: _admin_notice_post_locked
Plugin ref: WordPress
Version: 5.0.3
Sourcefile: wp-admin/includes/post.php
File ref: wp-admin/includes/post.php
API type: private
Deprecated?: No
API Letters: _,A,L,N,P

  • Plugins
  • Themes
  • Blocks
  • Shortcodes
  • APIs
  • Files
  • Hooks
  • Classes
  • Sites
  • Sitemap
  • Blog
oik-plugins Jetpack a2z
Jetpack a2z

Site:  jetpack.wp-a2z.org
© Copyright oik-plugins 2014-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins