WordPress.org

Make WordPress Core

Changeset 12020


Ignore:
Timestamp:
10/11/2009 12:37:26 AM (9 years ago)
Author:
azaozz
Message:

Open View/Preview post in a new window from the link in the Saved/Updated message, cleanup messages code, add Draft updated for Pages.

Location:
trunk/wp-admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r12017 r12020  
    1919
    2020$action = isset($action) ? $action : '';
    21 if ( isset($_GET['message']) )
     21
     22$message = false;
     23if ( isset($_GET['message']) ) {
    2224    $_GET['message'] = absint( $_GET['message'] );
    23 $messages[1] = sprintf(__('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID));
    24 $messages[2] = __('Custom field updated.');
    25 $messages[3] = __('Custom field deleted.');
    26 $messages[4] = __('Post updated.');
    27 $messages[6] = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID));
    28 $messages[7] = __('Post saved.');
    29 $messages[8] = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
    30 // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php
    31 $messages[9] = sprintf(__('Post scheduled for: <b>%1$s</b>. <a href="%2$s">Preview post</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID));
    32 $messages[10] = sprintf(__('Draft updated. <a href="%s">Preview</a>'), get_permalink($post_ID));
    33 
    34 if ( isset($_GET['revision']) )
    35     $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
     25
     26    switch ( $_GET['message'] ) {
     27        case 1:
     28            $message = sprintf( __('Post updated. <a target="_blank" href="%s">View post</a>'), get_permalink($post_ID) );
     29            break;
     30        case 2:
     31            $message = __('Custom field updated.');
     32            break;
     33        case 3:
     34            $message = __('Custom field deleted.');
     35            break;
     36        case 4:
     37            $message = __('Post updated.');
     38            break;
     39        case 5:
     40            if ( isset($_GET['revision']) )
     41                $message = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
     42            break;
     43        case 6:
     44            $message = sprintf( __('Post published. <a target="_blank" href="%s">View post</a>'), get_permalink($post_ID) );
     45            break;
     46        case 7:
     47            $message = __('Post saved.');
     48            break;
     49        case 8:
     50            $message = sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
     51            break;
     52        case 9:
     53            // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php
     54            $message = sprintf( __('Post scheduled for: <b>%1$s</b>. <a target="_blank" href="%2$s">Preview post</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) );
     55            break;
     56        case 10:
     57            $message = sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
     58            break;
     59    }
     60}
    3661
    3762$notice = false;
    38 $notices[1] = __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>.' );
    39 
    4063if ( 0 == $post_ID ) {
    4164    $form_action = 'post';
     
    5275        foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
    5376            if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
    54                 $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
     77                $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>.' ), get_edit_post_link( $autosave->ID ) );
    5578                break;
    5679            }
     
    117140<div id="notice" class="error"><p><?php echo $notice ?></p></div>
    118141<?php endif; ?>
    119 <?php if (isset($_GET['message'])) : ?>
    120 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
     142<?php if ( $message ) : ?>
     143<div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
    121144<?php endif; ?>
    122145<form name="post" action="post.php" method="post" id="post">
  • trunk/wp-admin/edit-page-form.php

    r11897 r12020  
    2121    $temp_ID = 0;
    2222
    23 if ( isset($_GET['message']) )
     23$message = false;
     24if ( isset($_GET['message']) ) {
    2425    $_GET['message'] = absint( $_GET['message'] );
    25 $messages[1] = sprintf(__('Page updated. <a href="%s">View page</a>'), get_permalink($post_ID));
    26 $messages[2] = __('Custom field updated.');
    27 $messages[3] = __('Custom field deleted.');
    28 $messages[5] = sprintf(__('Page published. <a href="%s">View page</a>'), get_permalink($post_ID));
    29 $messages[6] = sprintf(__('Page submitted. <a href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
    30 // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php
    31 $messages[7] = sprintf(__('Page scheduled for: <b>%1$s</b>. <a href="%2$s">Preview post</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID));
    3226
    33 if ( isset($_GET['revision']) )
    34     $messages[5] = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
     27    switch ( $_GET['message'] ) {
     28        case 1:
     29            $message = sprintf( __('Page updated. <a target="_blank" href="%s">View page</a>'), get_permalink($post_ID) );
     30            break;
     31        case 2:
     32            $message = __('Custom field updated.');
     33            break;
     34        case 3:
     35            $message = __('Custom field deleted.');
     36            break;
     37        case 4:
     38            $message = sprintf( __('Page published. <a target="_blank" href="%s">View page</a>'), get_permalink($post_ID) );
     39            break;
     40        case 5:
     41            if ( isset($_GET['revision']) )
     42                $message = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
     43            break;
     44        case 6:
     45            $message = sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
     46            break;
     47        case 7:
     48            // translators: Publish box date formt, see http://php.net/date - Same as in meta-boxes.php
     49            $message = sprintf( __('Page scheduled for: <b>%1$s</b>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), get_permalink($post_ID) );
     50            break;
     51        case 8:
     52            $message = sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
     53            break;
     54    }
     55}
    3556
    3657$notice = false;
    37 $notices[1] = __( 'There is an autosave of this page that is more recent than the version below.  <a href="%s">View the autosave</a>.' );
    38 
    3958if ( 0 == $post_ID) {
    4059    $form_action = 'post';
     
    4968    $autosave = wp_get_post_autosave( $post_ID );
    5069    if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) )
    51         $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
     70        $notice = sprintf( __( 'There is an autosave of this page that is more recent than the version below.  <a href="%s">View the autosave</a>.' ), get_edit_post_link( $autosave->ID ) );
    5271}
    5372
     
    88107<div id="notice" class="error"><p><?php echo $notice ?></p></div>
    89108<?php endif; ?>
    90 <?php if (isset($_GET['message'])) : ?>
    91 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
     109<?php if ( $message ) : ?>
     110<div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
    92111<?php endif; ?>
    93112
  • trunk/wp-admin/page.php

    r11986 r12020  
    3636    } elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) {
    3737        $location = 'sidebar.php?a=b';
    38     } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) ) {
     38    } elseif ( isset($_POST['save']) || isset($_POST['publish']) ) {
     39        $status = get_post_status( $page_ID );
     40
    3941        if ( isset( $_POST['publish'] ) ) {
    40             switch ( get_post_status( $page_ID ) ) {
     42            switch ( $status ) {
    4143                case 'pending':
    42                     $location = add_query_arg( 'message', 6, get_edit_post_link( $page_ID, 'url' ) );
     44                    $message = 6;
    4345                    break;
    4446                case 'future':
    45                     $location = add_query_arg( 'message', 7, get_edit_post_link( $page_ID, 'url' ) );
     47                    $message = 7;
    4648                    break;
    4749                default:
    48                     $location = add_query_arg( 'message', 5, get_edit_post_link( $page_ID, 'url' ) );
     50                    $message = 4;
    4951            }
    5052        } else {
    51             $location = add_query_arg( 'message', 1, get_edit_post_link( $page_ID, 'url' ) );
     53                $message = 'draft' == $status ? 8 : 1;
    5254        }
     55
     56        $location = add_query_arg( 'message', $message, get_edit_post_link( $page_ID, 'url' ) );
    5357    } elseif ( isset($_POST['addmeta']) ) {
    5458        $location = add_query_arg( 'message', 2, wp_get_referer() );
  • trunk/wp-admin/post.php

    r12017 r12020  
    4141    } elseif ( isset($_POST['save']) || isset($_POST['publish']) ) {
    4242        $status = get_post_status( $post_ID );
    43         $link = get_edit_post_link( $post_ID, 'url' );
    4443
    4544        if ( isset( $_POST['publish'] ) ) {
     
    5857        }
    5958
    60         $location = add_query_arg( 'message', $message, $link );
     59        $location = add_query_arg( 'message', $message, get_edit_post_link( $post_ID, 'url' ) );
    6160    } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
    6261        $location = add_query_arg( 'message', 2, wp_get_referer() );
Note: See TracChangeset for help on using the changeset viewer.