wp/wp-admin/post.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    12 require_once __DIR__ . '/admin.php';
    12 require_once __DIR__ . '/admin.php';
    13 
    13 
    14 $parent_file  = 'edit.php';
    14 $parent_file  = 'edit.php';
    15 $submenu_file = 'edit.php';
    15 $submenu_file = 'edit.php';
    16 
    16 
    17 wp_reset_vars( array( 'action' ) );
    17 $action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
    18 
    18 
    19 if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
    19 if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
    20 	wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 );
    20 	wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 );
    21 } elseif ( isset( $_GET['post'] ) ) {
    21 } elseif ( isset( $_GET['post'] ) ) {
    22 	$post_id = (int) $_GET['post'];
    22 	$post_id = (int) $_GET['post'];
    26 	$post_id = 0;
    26 	$post_id = 0;
    27 }
    27 }
    28 $post_ID = $post_id;
    28 $post_ID = $post_id;
    29 
    29 
    30 /**
    30 /**
    31  * @global string  $post_type
    31  * @global string       $post_type        Global post type.
    32  * @global object  $post_type_object
    32  * @global WP_Post_Type $post_type_object Global post type object.
    33  * @global WP_Post $post             Global post object.
    33  * @global WP_Post      $post             Global post object.
    34  */
    34  */
    35 global $post_type, $post_type_object, $post;
    35 global $post_type, $post_type_object, $post;
    36 
    36 
    37 if ( $post_id ) {
    37 if ( $post_id ) {
    38 	$post = get_post( $post_id );
    38 	$post = get_post( $post_id );
    53 	$action = 'preview';
    53 	$action = 'preview';
    54 }
    54 }
    55 
    55 
    56 $sendback = wp_get_referer();
    56 $sendback = wp_get_referer();
    57 if ( ! $sendback ||
    57 if ( ! $sendback ||
    58 	false !== strpos( $sendback, 'post.php' ) ||
    58 	str_contains( $sendback, 'post.php' ) ||
    59 	false !== strpos( $sendback, 'post-new.php' ) ) {
    59 	str_contains( $sendback, 'post-new.php' ) ) {
    60 	if ( 'attachment' === $post_type ) {
    60 	if ( 'attachment' === $post_type ) {
    61 		$sendback = admin_url( 'upload.php' );
    61 		$sendback = admin_url( 'upload.php' );
    62 	} else {
    62 	} else {
    63 		$sendback = admin_url( 'edit.php' );
    63 		$sendback = admin_url( 'edit.php' );
    64 		if ( ! empty( $post_type ) ) {
    64 		if ( ! empty( $post_type ) ) {
    95 
    95 
    96 		$_POST['comment_status'] = get_default_comment_status( $post->post_type );
    96 		$_POST['comment_status'] = get_default_comment_status( $post->post_type );
    97 		$_POST['ping_status']    = get_default_comment_status( $post->post_type, 'pingback' );
    97 		$_POST['ping_status']    = get_default_comment_status( $post->post_type, 'pingback' );
    98 
    98 
    99 		// Wrap Quick Draft content in the Paragraph block.
    99 		// Wrap Quick Draft content in the Paragraph block.
   100 		if ( false === strpos( $_POST['content'], '<!-- wp:paragraph -->' ) ) {
   100 		if ( ! str_contains( $_POST['content'], '<!-- wp:paragraph -->' ) ) {
   101 			$_POST['content'] = sprintf(
   101 			$_POST['content'] = sprintf(
   102 				'<!-- wp:paragraph -->%s<!-- /wp:paragraph -->',
   102 				'<!-- wp:paragraph -->%s<!-- /wp:paragraph -->',
   103 				str_replace( array( "\r\n", "\r", "\n" ), '<br />', $_POST['content'] )
   103 				str_replace( array( "\r\n", "\r", "\n" ), '<br />', $_POST['content'] )
   104 			);
   104 			);
   105 		}
   105 		}