Register UC panel tab=orders with full order list/actions UI; route aksrt_get_orders_page_url and /orders template to profile?tab=orders; enqueue order assets when the UC orders tab is active.
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: AKSRT - Orders
|
|
* Template Post Type: page
|
|
*
|
|
* Legacy standalone orders URL — redirects into user center tab (zibll-style).
|
|
* Kept as template slug so old page assignments resolve; content lives in UC.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (!is_user_logged_in()) {
|
|
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(home_url('/profile/'));
|
|
wp_safe_redirect($login_url);
|
|
exit;
|
|
}
|
|
|
|
$target = function_exists('aksrt_get_user_center_url')
|
|
? aksrt_get_user_center_url('orders')
|
|
: home_url('/profile/?tab=orders');
|
|
|
|
// Preserve filter/query from standalone page.
|
|
$keep = [];
|
|
foreach (['order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section'] as $key) {
|
|
if (isset($_GET[$key]) && (string) wp_unslash($_GET[$key]) !== '') {
|
|
$keep[$key] = sanitize_text_field(wp_unslash((string) $_GET[$key]));
|
|
}
|
|
}
|
|
// Legacy ?tab=pending on standalone page → order_tab.
|
|
if (isset($_GET['tab'])) {
|
|
$legacy_tab = sanitize_key((string) wp_unslash($_GET['tab']));
|
|
if ($legacy_tab !== '' && $legacy_tab !== 'orders' && !isset($keep['order_tab'])) {
|
|
$keep['order_tab'] = $legacy_tab;
|
|
}
|
|
}
|
|
if ($keep !== []) {
|
|
$target = add_query_arg($keep, $target);
|
|
}
|
|
|
|
wp_safe_redirect($target, 302);
|
|
exit;
|