Automattic\WooCommerce\Admin\Features\ProductBlockEditor
RedirectionController::get_parsed_route
Get the parsed WooCommerce Admin path.
Method of the class: RedirectionController{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->get_parsed_route(): array;
RedirectionController::get_parsed_route() RedirectionController::get parsed route code WC 10.5.0
protected function get_parsed_route(): array {
if ( ! \Automattic\WooCommerce\Admin\PageController::is_admin_page() || ! isset( $_GET['path'] ) ) {
return array(
'page' => null,
'product_id' => null,
);
}
$path = esc_url_raw( wp_unslash( $_GET['path'] ) );
$path_pieces = explode( '/', wp_parse_url( $path, PHP_URL_PATH ) );
return array(
'page' => $path_pieces[1] ?? '',
'product_id' => 'product' === ( $path_pieces[1] ?? '' ) ? absint( $path_pieces[2] ?? 0 ) : null,
);
}