Automattic\WooCommerce\Internal\Admin\Orders

PostsRedirectionController::maybe_redirect_to_orders_page()privateWC 1.0

If needed, performs a redirection to the main orders page.

Метод класса: PostsRedirectionController{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->maybe_redirect_to_orders_page(): void;

Код PostsRedirectionController::maybe_redirect_to_orders_page() WC 8.9.3

private function maybe_redirect_to_orders_page(): void {
	$post_type = $_GET['post_type'] ?? ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

	if ( ! $post_type || ! in_array( $post_type, wc_get_order_types( 'admin-menu' ), true ) ) {
		return;
	}

	// Respect query args, except for 'post_type'.
	$query_args = wp_unslash( $_GET );
	$action     = $query_args['action'] ?? '';
	$posts      = $query_args['post'] ?? array();
	unset( $query_args['post_type'], $query_args['post'], $query_args['_wpnonce'], $query_args['_wp_http_referer'], $query_args['action'] );

	// Remap 'post_status' arg.
	if ( isset( $query_args['post_status'] ) ) {
		$query_args['status'] = $query_args['post_status'];
		unset( $query_args['post_status'] );
	}

	$new_url = $this->page_controller->get_base_page_url( $post_type );
	$new_url = add_query_arg( $query_args, $new_url );

	// Handle bulk actions.
	if ( $action && in_array( $action, array( 'trash', 'untrash', 'delete', 'mark_processing', 'mark_on-hold', 'mark_completed', 'mark_cancelled' ), true ) ) {
		check_admin_referer( 'bulk-posts' );

		$new_url = add_query_arg(
			array(
				'action'           => $action,
				'id'               => $posts,
				'_wp_http_referer' => $this->page_controller->get_orders_url(),
				'_wpnonce'         => wp_create_nonce( 'bulk-orders' ),
			),
			$new_url
		);
	}

	wp_safe_redirect( $new_url, 301 );
	exit;
}