Post locks:

- Show 'Saving revision...' while autosaving after a post has been taken over. Change to 'Your latest changes were saved as a revision.' when autosave completes.
- Make sure a user exists before using $user->display_name.
- Add 'post_lock_text' action for extending the message text.

git-svn-id: https://develop.svn.wordpress.org/trunk@24042 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2013-04-22 03:08:51 +00:00
parent db96892205
commit 008336ee9c
5 changed files with 37 additions and 13 deletions
+2 -5
View File
@@ -574,12 +574,11 @@ function wp_check_locked_posts( $response, $data, $screen_id ) {
$post_id = (int) substr( $key, 5 );
if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
$send = array();
$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
$send['avatar_src'] = $matches[1];
$send['text'] = sprintf( __( '%s is currently editing' ), $user->display_name );
$checked[$key] = $send;
}
}
@@ -608,9 +607,7 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
if ( !current_user_can('edit_post', $post_id) )
return $response;
if ( $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 ) ) ) {
$error = array(
'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name )
);
+8 -3
View File
@@ -1197,8 +1197,7 @@ function _admin_notice_post_locked() {
if ( ! $post = get_post() )
return;
if ( $user = wp_check_post_lock( $post->ID ) ) {
$user = get_userdata( $user );
if ( ( $user_id = wp_check_post_lock( $post->ID ) ) && ( $user = get_userdata( $user_id ) ) ) {
$locked = apply_filters( 'show_post_locked_dialog', true, $post, $user );
} else {
$locked = false;
@@ -1229,6 +1228,7 @@ function _admin_notice_post_locked() {
<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 esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user->display_name ) ); ?></p>
<?php do_action( 'post_lock_text', $post ); ?>
<p>
<a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a>
<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
@@ -1249,7 +1249,12 @@ function _admin_notice_post_locked() {
?>
<div class="post-taken-over">
<div class="post-locked-avatar"></div>
<p class="currently-editing wp-tab-first" tabindex="0"></p>
<p class="wp-tab-first" tabindex="0">
<span class="currently-editing"></span><br>
<span class="locked-saving hidden"><img src="images/wpspin_light-2x.gif" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
<span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
</p>
<?php do_action( 'post_lock_text', $post ); ?>
<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( admin_url('edit.php') ); ?>"><?php _e('Go to All Posts'); ?></a></p>
</div>
<?php