redirect_post

Definition:
function redirect_post($post_id = '') {}

Redirect to previous page.

Parameters

  • int $post_id: Optional. Post ID.

Defined filters

  • redirect_post_location
    apply_filters( 'redirect_post_location', $location, $post_id )

Source code

function redirect_post($post_id = '') {

	if ( isset($_POST['save']) || isset($_POST['publish']) ) {

		$status = get_post_status( $post_id );



		if ( isset( $_POST['publish'] ) ) {

			switch ( $status ) {

				case 'pending':

					$message = 8;

					break;

				case 'future':

					$message = 9;

					break;

				default:

					$message = 6;

			}

		} else {

				$message = 'draft' == $status ? 10 : 1;

		}



		$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );

	} elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {

		$location = add_query_arg( 'message', 2, wp_get_referer() );

		$location = explode('#', $location);

		$location = $location[0] . '#postcustom';

	} elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {

		$location = add_query_arg( 'message', 3, wp_get_referer() );

		$location = explode('#', $location);

		$location = $location[0] . '#postcustom';

	} elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {

		$location = "post.php?action=edit&post=$post_id&message=7";

	} else {

		$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );

	}



	wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );

	exit;

}

2645

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: