feat: merge promotion and earnings center
This commit is contained in:
+7
-21
@@ -55,6 +55,9 @@ class Center {
|
||||
*/
|
||||
public function rest_panel(\WP_REST_Request $request) {
|
||||
$tab = sanitize_key((string) $request->get_param('tab'));
|
||||
if ($tab === 'revenue') {
|
||||
$tab = 'promotion';
|
||||
}
|
||||
$tabs = $this->get_dashboard_tabs();
|
||||
if (!isset($tabs[$tab])) {
|
||||
return new \WP_Error('aksrt_user_center_panel', __('用户中心面板不存在', 'aksrt'), ['status' => 404]);
|
||||
@@ -76,7 +79,7 @@ class Center {
|
||||
$context['creator_income_request'] = $income_request;
|
||||
}
|
||||
$revenue_request = [];
|
||||
if ($tab === 'revenue') {
|
||||
if ($tab === 'promotion') {
|
||||
$reward_tab = sanitize_key((string) $request->get_param('reward_tab'));
|
||||
if (!in_array($reward_tab, ['detail', 'orders'], true)) {
|
||||
$reward_tab = 'detail';
|
||||
@@ -182,18 +185,12 @@ class Center {
|
||||
'priority' => 50,
|
||||
'type' => 'panel',
|
||||
],
|
||||
'revenue' => [
|
||||
'label' => __('收益中心', 'aksrt'),
|
||||
'promotion' => [
|
||||
'label' => __('推广收益', 'aksrt'),
|
||||
'icon' => 'chart-line',
|
||||
'priority' => 55,
|
||||
'type' => 'panel',
|
||||
],
|
||||
'promotion' => [
|
||||
'label' => __('推广中心', 'aksrt'),
|
||||
'icon' => 'share-alt',
|
||||
'priority' => 54,
|
||||
'type' => 'panel',
|
||||
],
|
||||
'notif' => [
|
||||
'label' => __('消息通知', 'aksrt'),
|
||||
'icon' => 'bell',
|
||||
@@ -226,8 +223,6 @@ class Center {
|
||||
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
|
||||
$promotion_tab_on = class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_affiliate_settings()['enabled']);
|
||||
$revenue_tab_on = $promotion_tab_on || (class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_payment_revenue_settings()['enabled']));
|
||||
$creator_tab_on = class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_payment_revenue_settings()['enabled']);
|
||||
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
||||
@@ -295,7 +290,7 @@ class Center {
|
||||
$order[] = 'credits';
|
||||
}
|
||||
|
||||
if ($revenue_tab_on && !in_array('revenue', $order, true)) {
|
||||
if ($promotion_tab_on && !in_array('promotion', $order, true)) {
|
||||
$insert_at = count($order);
|
||||
foreach (['credits', 'favorites'] as $anchor) {
|
||||
$idx = array_search($anchor, $order, true);
|
||||
@@ -304,12 +299,6 @@ class Center {
|
||||
break;
|
||||
}
|
||||
}
|
||||
array_splice($order, $insert_at, 0, ['revenue']);
|
||||
}
|
||||
if ($promotion_tab_on && !in_array('promotion', $order, true)) {
|
||||
$insert_at = count($order);
|
||||
$idx = array_search('revenue', $order, true);
|
||||
if ($idx !== false) { $insert_at = (int) $idx; }
|
||||
array_splice($order, $insert_at, 0, ['promotion']);
|
||||
}
|
||||
$auth_on = class_exists('\AKSRT\User\AuthApply')
|
||||
@@ -331,9 +320,6 @@ class Center {
|
||||
if ($key === 'credits' && !$credits_on && !$balance_on) {
|
||||
continue;
|
||||
}
|
||||
if ($key === 'revenue' && !$revenue_tab_on) {
|
||||
continue;
|
||||
}
|
||||
if ($key === 'promotion' && !$promotion_tab_on) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user