protected function valid_post_id( $post_id ) {
		$key = papi_get_sanitized_post( 'action' ) === 'save-attachment-compat' ? 'id' : 'post_ID';
		$val = papi_get_sanitized_post( $key );

		// When autosave is in place the post id is located deeper in the post data array, the ids should not match.
		if ( isset( $_POST['data']['wp_autosave'], $_POST['data']['wp_autosave']['post_id'] ) ) {
			// But if it's a auto draft the ids should match.
			if ( isset( $_POST['data']['wp_autosave']['auto_draft'] ) && ! empty( $_POST['data']['wp_autosave']['auto_draft'] ) ) {
				return sanitize_text_field( $_POST['data']['wp_autosave']['post_id'] ) === strval( $post_id );
			}

			return sanitize_text_field( $_POST['data']['wp_autosave']['post_id'] ) !== strval( $post_id );
		}

		// Should not be the same id when `wp-preview` equals `dopreview`.
		if ( isset( $_POST['wp-preview'] ) && strtolower( $_POST['wp-preview'] ) === 'dopreview' ) {
			return $val !== strval( $post_id );
		}

		return $val === strval( $post_id );
	}
protected function valid_post_id( $post_id ) {
		$key = papi_get_sanitized_post( 'action' ) === 'save-attachment-compat' ? 'id' : 'post_ID';
		$val = papi_get_sanitized_post( $key );

		// When autosave is in place the post id is located deeper in the post data array, the ids should not match.
		if ( isset( $_POST['data']['wp_autosave'], $_POST['data']['wp_autosave']['post_id'] ) ) {
			// But if it's a auto draft the ids should match.
			if ( isset( $_POST['data']['wp_autosave']['auto_draft'] ) && ! empty( $_POST['data']['wp_autosave']['auto_draft'] ) ) {
				return sanitize_text_field( $_POST['data']['wp_autosave']['post_id'] ) === strval( $post_id );
			}

			return sanitize_text_field( $_POST['data']['wp_autosave']['post_id'] ) !== strval( $post_id );
		}

		// Should not be the same id when `wp-preview` equals `dopreview`.
		if ( isset( $_POST['wp-preview'] ) && strtolower( $_POST['wp-preview'] ) === 'dopreview' ) {
			return $val !== strval( $post_id );
		}

		return $val === strval( $post_id );
	}
protected function valid_post_id ( $ post_id ) { $ key = papi_get_sanitized_post ( 'action' ) === 'save-attachment-compat' ? 'id' : 'post_ID' ; $ val = papi_get_sanitized_post ( $ key ) ; // When autosave is in place the post id is located deeper in the post data array, the ids should not match. if ( isset ( $ _POST [ 'data' ] [ 'wp_autosave' ] , $ _POST [ 'data' ] [ 'wp_autosave' ] [ 'post_id' ] ) ) { // But if it's a auto draft the ids should match. if ( isset ( $ _POST [ 'data' ] [ 'wp_autosave' ] [ 'auto_draft' ] ) && ! empty ( $ _POST [ 'data' ] [ 'wp_autosave' ] [ 'auto_draft' ] ) ) { return sanitize_text_field ( $ _POST [ 'data' ] [ 'wp_autosave' ] [ 'post_id' ] ) === strval ( $ post_id ) ; } return sanitize_text_field ( $ _POST [ 'data' ] [ 'wp_autosave' ] [ 'post_id' ] ) !== strval ( $ post_id ) ; } // Should not be the same id when `wp-preview` equals `dopreview`. if ( isset ( $ _POST [ 'wp-preview' ] ) && strtolower ( $ _POST [ 'wp-preview' ] ) === 'dopreview' ) { return $ val !== strval ( $ post_id ) ; } return $ val === strval ( $ post_id ) ; }
Check if post id is valid or not.

@param  int $post_id

@return bool
Check if post id is valid or not .