Make WordPress Core

Changeset 24408


Ignore:
Timestamp:
06/05/2013 03:01:59 AM (11 years ago)
Author:
azaozz
Message:

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.

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/misc.php

    r24406 r24408  
    570570    $checked = array();
    571571
    572     if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
     572    if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
    573573        foreach ( $data['wp-check-locked-posts'] as $key ) {
    574             $post_id = (int) substr( $key, 5 );
    575 
    576             if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
     574            if ( ! $post_id = absint( substr( $key, 5 ) ) )
     575                continue;
     576
     577            if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
    577578                $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
    578579
     
    598599 */
    599600function wp_refresh_post_lock( $response, $data, $screen_id ) {
    600     if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-lock', $data ) ) {
     601    if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
    601602        $received = $data['wp-refresh-post-lock'];
    602603        $send = array();
     
    637638 */
    638639function wp_refresh_post_nonces( $response, $data, $screen_id ) {
    639     if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
     640    if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
    640641        $received = $data['wp-refresh-post-nonces'];
    641642
  • trunk/wp-admin/includes/post.php

    r24388 r24408  
    12031203    }
    12041204
     1205    if ( $locked && ( $sendback = wp_get_referer() ) &&
     1206        false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
     1207
     1208        $sendback_text = __('Go back');
     1209    } else {
     1210        $sendback = admin_url( 'edit.php' );
     1211
     1212        if ( 'post' != $post->post_type && ( $post_type_object = get_post_type_object( $post->post_type ) ) ) {
     1213            $sendback .= '?post_type=' . $post->post_type;
     1214            $sendback_text = sprintf( _x('Go to All %s', 'post type general name: Posts, Pages, etc.'), $post_type_object->labels->name );
     1215        } else {
     1216            $sendback_text = __('Go to All Posts');
     1217        }
     1218    }
     1219
    12051220    $hidden = $locked ? '' : ' hidden';
    12061221
     
    12301245        <?php do_action( 'post_lock_text', $post ); ?>
    12311246        <p>
    1232         <a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a>
     1247        <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
    12331248        <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
    12341249        <?php
     
    12551270            </p>
    12561271            <?php do_action( 'post_lock_text', $post ); ?>
    1257             <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>
     1272            <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p>
    12581273        </div>
    12591274        <?php
Note: See TracChangeset for help on using the changeset viewer.