From 2860f4769e704f677923214a56ada54ee69a9683 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 5 Jun 2013 03:01:59 +0000 Subject: [PATCH] Post locks: - When a post is locked, ensure the 'Go back' button doesn't reload the same screen. If no referrer, change the button from 'Go back' to 'Go to All Posts'/'Go to All Pages' etc. - Remove restriction on checking locks only for posts. See #23697. git-svn-id: https://develop.svn.wordpress.org/trunk@24408 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/misc.php | 11 ++++++----- wp-admin/includes/post.php | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 266b89cb08..ecaf717721 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -569,11 +569,12 @@ add_action('admin_head', '_ipad_meta'); function wp_check_locked_posts( $response, $data, $screen_id ) { $checked = array(); - if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { + if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { foreach ( $data['wp-check-locked-posts'] as $key ) { - $post_id = (int) substr( $key, 5 ); + if ( ! $post_id = absint( substr( $key, 5 ) ) ) + continue; - if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { + if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) { $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) ); if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) @@ -597,7 +598,7 @@ add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); * @since 3.6 */ function wp_refresh_post_lock( $response, $data, $screen_id ) { - if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-lock', $data ) ) { + if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) { $received = $data['wp-refresh-post-lock']; $send = array(); @@ -636,7 +637,7 @@ add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); * @since 3.6 */ function wp_refresh_post_nonces( $response, $data, $screen_id ) { - if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-nonces', $data ) ) { + if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) { $received = $data['wp-refresh-post-nonces']; if ( ! $post_id = absint( $received['post_id'] ) ) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 519c71b351..1dd9b3b2ae 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1202,6 +1202,21 @@ function _admin_notice_post_locked() { $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 && ( $post_type_object = get_post_type_object( $post->post_type ) ) ) { + $sendback .= '?post_type=' . $post->post_type; + $sendback_text = sprintf( _x('Go to All %s', 'post type general name: Posts, Pages, etc.'), $post_type_object->labels->name ); + } else { + $sendback_text = __('Go to All Posts'); + } + } + $hidden = $locked ? '' : ' hidden'; ?> @@ -1229,7 +1244,7 @@ function _admin_notice_post_locked() {

display_name ) ); ?>

- +

-

+