WordPress.org

Make WordPress Core

Changeset 23725


Ignore:
Timestamp:
03/15/2013 09:09:20 PM (8 years ago)
Author:
azaozz
Message:

Post locks: add Preview button when post is locked, fix the suggested places, see #23312

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/wp-admin.css

    r23707 r23725  
    34313431}
    34323432
    3433 #notification-dialog .post-locked-message a.button-primary {
    3434     margin: 0 10px;
     3433#notification-dialog .post-locked-message a.button {
     3434    margin-right: 10px;
    34353435}
    34363436
  • trunk/wp-admin/includes/post.php

    r23661 r23725  
    11991199 */
    12001200function _admin_notice_post_locked() {
    1201     global $post_ID;
    1202 
    1203     if ( !empty( $post_ID ) && ( $user = wp_check_post_lock( $post_ID ) ) ) {
     1201    if ( ! $post = get_post() )
     1202        return;
     1203
     1204    if ( $user = wp_check_post_lock( $post->ID ) ) {
    12041205        $user = get_userdata( $user );
    1205         $locked = apply_filters( 'show_post_locked_dialog', true, $post_ID, $user );
     1206        $locked = apply_filters( 'show_post_locked_dialog', true, $post, $user );
    12061207    } else {
    12071208        $locked = false;
    12081209    }
    12091210
     1211    $class = $locked ? '' : ' class="hidden"';
     1212
    12101213    ?>
    1211     <div id="notification-dialog-wrap"<?php if ( ! $locked ) echo ' style="display:none"'; ?>>
     1214    <div id="notification-dialog-wrap"<?php echo $class; ?>>
    12121215    <div id="notification-dialog-background"></div>
    12131216    <div id="notification-dialog">
     
    12151218
    12161219    if ( $locked ) {
     1220        $preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) );
     1221
     1222        if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
     1223            // Latest content is in autosave
     1224            $nonce = wp_create_nonce( 'post_preview_' . $post->ID );
     1225            $preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
     1226        }
     1227
     1228        $preview_link = apply_filters( 'preview_post_link', $preview_link );
     1229
    12171230        ?>
    12181231        <div class="post-locked-message">
     
    12211234        <p>
    12221235        <a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a>
     1236        <a class="button" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
    12231237        <?php
    12241238
    1225         // Allow plugins to prevent some users taking over
    1226         if ( apply_filters( 'post_lock_take_over', true, $post_ID, $user ) ) {
     1239        // Allow plugins to prevent some users overriding the post lock
     1240        if ( apply_filters( 'override_post_lock', true, $post, $user ) ) {
    12271241            ?>
    1228             <a class="button button-primary" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', get_edit_post_link( $post_ID, 'url' ) ) ); ?>"><?php _e('Take over'); ?></a>
     1242            <a class="button button-primary" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', get_edit_post_link( $post->ID, 'url' ) ) ); ?>"><?php _e('Take over'); ?></a>
    12291243            <?php
    12301244        }
  • trunk/wp-admin/js/post.js

    r23661 r23725  
    280280                wrap.find('p.currently-editing').text( received.lock_error.text );
    281281               
    282                 if ( received.lock_error.avatar_src && /^https?:\/\/[a-z0-9]+?\.gravatar\.com\/avatar/.test( received.lock_error.avatar_src ) ) {
     282                if ( received.lock_error.avatar_src ) {
    283283                    avatar = $('<img class="avatar avatar-64 photo" width="64" height="64" />').attr( 'src', received.lock_error.avatar_src.replace(/&amp;/g, '&') );
    284284                    wrap.find('div.post-locked-avatar').empty().append( avatar );
Note: See TracChangeset for help on using the changeset viewer.