Make WordPress Core

Changeset 34020


Ignore:
Timestamp:
09/10/2015 09:30:24 PM (10 years ago)
Author:
wonderboymusic
Message:

Move redirect_post() from wp-admin/post.php to wp-admin/includes/post.php.

See #33813.

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

Legend:

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

    r33970 r34020  
    17701770    }
    17711771}
     1772
     1773/**
     1774 * Redirect to previous page.
     1775 *
     1776 * @param int $post_id Optional. Post ID.
     1777 */
     1778function redirect_post($post_id = '') {
     1779    if ( isset($_POST['save']) || isset($_POST['publish']) ) {
     1780        $status = get_post_status( $post_id );
     1781
     1782        if ( isset( $_POST['publish'] ) ) {
     1783            switch ( $status ) {
     1784                case 'pending':
     1785                    $message = 8;
     1786                    break;
     1787                case 'future':
     1788                    $message = 9;
     1789                    break;
     1790                default:
     1791                    $message = 6;
     1792            }
     1793        } else {
     1794            $message = 'draft' == $status ? 10 : 1;
     1795        }
     1796
     1797        $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
     1798    } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
     1799        $location = add_query_arg( 'message', 2, wp_get_referer() );
     1800        $location = explode('#', $location);
     1801        $location = $location[0] . '#postcustom';
     1802    } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
     1803        $location = add_query_arg( 'message', 3, wp_get_referer() );
     1804        $location = explode('#', $location);
     1805        $location = $location[0] . '#postcustom';
     1806    } else {
     1807        $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
     1808    }
     1809
     1810    /**
     1811     * Filter the post redirect destination URL.
     1812     *
     1813     * @since 2.9.0
     1814     *
     1815     * @param string $location The destination URL.
     1816     * @param int    $post_id  The post ID.
     1817     */
     1818    wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
     1819    exit;
     1820}
  • trunk/src/wp-admin/post.php

    r33542 r34020  
    3939}
    4040
    41 /**
    42  * Redirect to previous page.
    43  *
    44  * @param int $post_id Optional. Post ID.
    45  */
    46 function redirect_post($post_id = '') {
    47     if ( isset($_POST['save']) || isset($_POST['publish']) ) {
    48         $status = get_post_status( $post_id );
    49 
    50         if ( isset( $_POST['publish'] ) ) {
    51             switch ( $status ) {
    52                 case 'pending':
    53                     $message = 8;
    54                     break;
    55                 case 'future':
    56                     $message = 9;
    57                     break;
    58                 default:
    59                     $message = 6;
    60             }
    61         } else {
    62             $message = 'draft' == $status ? 10 : 1;
    63         }
    64 
    65         $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
    66     } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
    67         $location = add_query_arg( 'message', 2, wp_get_referer() );
    68         $location = explode('#', $location);
    69         $location = $location[0] . '#postcustom';
    70     } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
    71         $location = add_query_arg( 'message', 3, wp_get_referer() );
    72         $location = explode('#', $location);
    73         $location = $location[0] . '#postcustom';
    74     } else {
    75         $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
    76     }
    77 
    78     /**
    79      * Filter the post redirect destination URL.
    80      *
    81      * @since 2.9.0
    82      *
    83      * @param string $location The destination URL.
    84      * @param int    $post_id  The post ID.
    85      */
    86     wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
    87     exit;
    88 }
    89 
    9041if ( isset( $_POST['deletepost'] ) )
    9142    $action = 'delete';
Note: See TracChangeset for help on using the changeset viewer.