WordPress.org

Make WordPress Core

Changeset 7438


Ignore:
Timestamp:
03/21/2008 03:31:12 AM (10 years ago)
Author:
markjaquith
Message:

"Go back" link for admin-initiated post/page edits. e.g. do a search, edit a post, click the link to go back to the search.

Location:
trunk
Files:
5 edited

Legend:

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

    r7409 r7438  
    22$action = isset($action)? $action : '';
    33if ( isset($_GET['message']) )
    4     $_GET['message'] = (int) $_GET['message'];
    5 $messages[1] = __('Post updated');
    6 $messages[2] = __('Custom field updated');
     4    $_GET['message'] = absint( $_GET['message'] );
     5$messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
     6$messages[2] = __('Custom field updated.');
    77$messages[3] = __('Custom field deleted.');
    88?>
    99<?php if (isset($_GET['message'])) : ?>
    10 <div id="message" class="updated fade"><p><?php echo wp_specialchars($messages[$_GET['message']]); ?></p></div>
     10<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    1111<?php endif; ?>
    1212
     
    6060if ( !empty($_REQUEST['popupurl']) )
    6161    echo clean_url(stripslashes($_REQUEST['popupurl']));
    62 else if ( url_to_postid(wp_get_referer()) == $post_ID )
     62else if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false )
    6363    echo 'redo';
    6464else
    6565    echo clean_url(stripslashes(wp_get_referer()));
    6666?>" />
     67<?php wp_original_referer_field(true, 'previous'); ?>
    6768
    6869<?php echo $form_extra ?>
  • trunk/wp-admin/edit-page-form.php

    r7350 r7438  
    11<?php
     2if ( isset($_GET['message']) )
     3    $_GET['message'] = absint( $_GET['message'] );
     4$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
     5?>
     6<?php if (isset($_GET['message'])) : ?>
     7<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
     8<?php endif;
    29
    310if (!isset($post_ID) || 0 == $post_ID) {
     
    3946<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
    4047<input name="referredby" type="hidden" id="referredby" value="<?php
    41 if ( url_to_postid(wp_get_referer()) == $post_ID )
     48if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false )
    4249    echo 'redo';
    4350else
    4451    echo clean_url(stripslashes(wp_get_referer()));
    4552?>" />
     53<?php wp_original_referer_field(true, 'previous'); ?>
    4654
    4755<div id="poststuff">
  • trunk/wp-admin/page.php

    r7426 r7438  
    124124
    125125        if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
    126             $location = "page.php?action=edit&post=$page_ID";
     126            if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false )
     127                $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "page.php?action=edit&post=$page_ID&message=1" );
     128            else
     129                $location = "page.php?action=edit&post=$page_ID";
    127130        } elseif ($_POST['addmeta']) {
    128131            $location = add_query_arg( 'message', 2, wp_get_referer() );
  • trunk/wp-admin/post.php

    r7426 r7438  
    137137
    138138        if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
    139             $location = "post.php?action=edit&post=$post_ID";
     139            if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false )
     140                $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" );
     141            else
     142                $location = "post.php?action=edit&post=$post_ID";
    140143        } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
    141144            $location = add_query_arg( 'message', 2, wp_get_referer() );
  • trunk/wp-includes/functions.php

    r7406 r7438  
    982982   
    983983    if ( $referer )
    984         wp_referer_field( $echo );
     984        wp_referer_field( $echo, 'previous' );
    985985   
    986986    return $nonce_field;
     
    988988
    989989
    990 function wp_referer_field( $echo = true ) {
     990function wp_referer_field( $echo = true) {
    991991    $ref = attribute_escape( $_SERVER['REQUEST_URI'] );
    992992    $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
    993    
    994     if ( wp_get_original_referer() ) {
    995         $original_ref = attribute_escape( stripslashes( wp_get_original_referer() ) );
    996         $referer_field .= "\n".'<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />';
    997     }
    998993
    999994    if ( $echo )
    1000995        echo $referer_field;
    1001    
    1002996    return $referer_field;
    1003997}
    1004998
    1005 
    1006 function wp_original_referer_field( $echo = true ) {
    1007     $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $_SERVER['REQUEST_URI'] ) ) . '" />';
     999function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
     1000    $jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     1001    $ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;
     1002    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $ref ) ) . '" />';
    10081003    if ( $echo )
    10091004        echo $orig_referer_field;
    1010    
    10111005    return $orig_referer_field;
    10121006}
     
    10151009function wp_get_referer() {
    10161010    if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
    1017         return $_REQUEST['_wp_http_referer'];
     1011        $ref = $_REQUEST['_wp_http_referer'];
    10181012    else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
    1019         return $_SERVER['HTTP_REFERER'];
     1013        $ref = $_SERVER['HTTP_REFERER'];
     1014
     1015    if ( $ref !== $_SERVER['REQUEST_URI'] )
     1016        return $ref;
    10201017    return false;
    10211018}
Note: See TracChangeset for help on using the changeset viewer.