Automattic\WooCommerce\Internal\Admin\Orders
COTRedirectionController::handle_hpos_admin_requests()
Listen for denied admin requests and, if they appear to relate to HPOS admin screens, potentially redirect the user to the equivalent CPT-driven screens.
Метод класса: COTRedirectionController{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$COTRedirectionController = new COTRedirectionController(); $COTRedirectionController->handle_hpos_admin_requests( $query_params );
- $query_params(массив|null)
- The query parameters to use when determining the redirect. If not provided, the $_GET superglobal will be used.
По умолчанию: null
Код COTRedirectionController::handle_hpos_admin_requests() COTRedirectionController::handle hpos admin requests WC 9.6.0
public function handle_hpos_admin_requests( $query_params = null ) { $query_params = is_array( $query_params ) ? $query_params : $_GET; if ( ! isset( $query_params['page'] ) || 'wc-orders' !== $query_params['page'] ) { return; } $params = wp_unslash( $query_params ); $action = $params['action'] ?? ''; unset( $params['page'] ); if ( 'edit' === $action && isset( $params['id'] ) ) { $params['post'] = $params['id']; unset( $params['id'] ); $new_url = add_query_arg( $params, get_admin_url( null, 'post.php' ) ); } elseif ( 'new' === $action ) { unset( $params['action'] ); $params['post_type'] = 'shop_order'; $new_url = add_query_arg( $params, get_admin_url( null, 'post-new.php' ) ); } else { // If nonce parameters are present and valid, rebuild them for the CPT admin list table. if ( isset( $params['_wpnonce'] ) && check_admin_referer( 'bulk-orders' ) ) { $params['_wp_http_referer'] = get_admin_url( null, 'edit.php?post_type=shop_order' ); $params['_wpnonce'] = wp_create_nonce( 'bulk-posts' ); } // If an `id` array parameter is present, rename as `post`. if ( isset( $params['id'] ) && is_array( $params['id'] ) ) { $params['post'] = $params['id']; unset( $params['id'] ); } $params['post_type'] = 'shop_order'; $new_url = add_query_arg( $params, get_admin_url( null, 'edit.php' ) ); } if ( ! empty( $new_url ) && wp_safe_redirect( $new_url, 301 ) ) { exit; } }