redirect_post
函数
redirect_post ( $post_id = '' )
- 参数
-
-
(int)
$post_id
Optional. Post ID.- Required: 否
- Default: (empty)
-
(int)
- 定义位置
-
-
wp-admin/includes/post.php
, line 2053
-
wp-admin/includes/post.php
- 引入
- 2.7.0
- 弃用
- –
重定向到前一页。
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'; } else { $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); } /** * Filters the post redirect destination URL. * * @since 2.9.0 * * @param string $location The destination URL. * @param int $post_id The post ID. */ wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); exit; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。