Cart
10 months ago
PaymentGateways
3 months ago
AdminMenu.php
9 months ago
BillingController.php
1 year ago
CartController.php
1 year ago
CheckoutController.php
3 months ago
CouponController.php
5 months ago
Ecommerce.php
1 year ago
EmailController.php
11 months ago
HooksHandler.php
4 months ago
OptionKeys.php
1 year ago
OrderActivitiesController.php
1 year ago
OrderController.php
6 months ago
PaymentHandler.php
9 months ago
Settings.php
9 months ago
Tax.php
9 months ago
currency.php
5 months ago
AdminMenu.php
121 lines
| 1 | <?php |
| 2 | /** |
| 3 | * AdminMenu class for registering menu |
| 4 | * |
| 5 | * @package Tutor\Ecommerce |
| 6 | * @author Themeum |
| 7 | * @link https://themeum.com |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | |
| 11 | namespace Tutor\Ecommerce; |
| 12 | |
| 13 | use TUTOR\Input; |
| 14 | use Tutor\Models\OrderModel; |
| 15 | |
| 16 | /** |
| 17 | * Register ecommerce menu |
| 18 | */ |
| 19 | class AdminMenu { |
| 20 | /** |
| 21 | * Constructor |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | add_filter( 'tutor_admin_menu', array( $this, 'register_menu' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Register menu |
| 29 | * |
| 30 | * @since 3.0.0 |
| 31 | * @since 3.8.0 param menu added. |
| 32 | * |
| 33 | * @param array $menu menu. |
| 34 | * |
| 35 | * @return array |
| 36 | */ |
| 37 | public function register_menu( $menu ) { |
| 38 | $order_menu_title = __( 'Orders', 'tutor' ); |
| 39 | $order_badge_count = get_transient( OrderModel::TRANSIENT_ORDER_BADGE_COUNT ); |
| 40 | |
| 41 | if ( false === $order_badge_count ) { |
| 42 | $order_badge_count = ( new OrderModel() )->get_order_count( |
| 43 | array( |
| 44 | 'payment_status' => OrderModel::PAYMENT_UNPAID, |
| 45 | 'order_type' => OrderModel::TYPE_SINGLE_ORDER, |
| 46 | ) |
| 47 | ); |
| 48 | set_transient( OrderModel::TRANSIENT_ORDER_BADGE_COUNT, $order_badge_count, HOUR_IN_SECONDS ); |
| 49 | } |
| 50 | |
| 51 | if ( $order_badge_count ) { |
| 52 | $order_menu_title .= ' <span class="update-plugins"><span class="plugin-count">' . $order_badge_count . '</span></span>'; |
| 53 | } |
| 54 | |
| 55 | $menu['group_two']['orders'] = array( |
| 56 | 'parent_slug' => 'tutor', |
| 57 | 'page_title' => __( 'Orders', 'tutor' ), |
| 58 | 'menu_title' => $order_menu_title, |
| 59 | 'capability' => 'manage_options', |
| 60 | 'menu_slug' => OrderController::PAGE_SLUG, |
| 61 | 'callback' => array( $this, 'orders_view' ), |
| 62 | ); |
| 63 | |
| 64 | $menu['group_two']['coupons'] = array( |
| 65 | 'parent_slug' => 'tutor', |
| 66 | 'page_title' => __( 'Coupons', 'tutor' ), |
| 67 | 'menu_title' => __( 'Coupons', 'tutor' ), |
| 68 | 'capability' => 'manage_options', |
| 69 | 'menu_slug' => CouponController::PAGE_SLUG, |
| 70 | 'callback' => array( $this, 'coupons_view' ), |
| 71 | ); |
| 72 | |
| 73 | return $menu; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Orders view page |
| 78 | * |
| 79 | * @since 3.0.0 |
| 80 | * |
| 81 | * @return void |
| 82 | */ |
| 83 | public function orders_view() { |
| 84 | $current_page = Input::get( 'page' ); |
| 85 | $action = Input::get( 'action' ); |
| 86 | |
| 87 | if ( OrderController::PAGE_SLUG === $current_page && 'edit' === $action ) { |
| 88 | ?> |
| 89 | <div class="tutor-admin-wrap tutor-order-details-wrapper"> |
| 90 | <div id="tutor-order-details-root"> |
| 91 | </div> |
| 92 | </div> |
| 93 | <?php |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | include apply_filters( 'tutor_order_list_page_template', tutor()->path . 'views/pages/ecommerce/order-list.php' ); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Coupons view page |
| 102 | * |
| 103 | * @since 3.0.0 |
| 104 | * |
| 105 | * @return void |
| 106 | */ |
| 107 | public function coupons_view() { |
| 108 | $action = Input::get( 'action' ); |
| 109 | if ( in_array( $action, array( 'add_new', 'edit' ) ) ) { |
| 110 | ?> |
| 111 | <div class="tutor-admin-wrap"> |
| 112 | <div id="tutor-coupon-root"> |
| 113 | </div> |
| 114 | </div> |
| 115 | <?php |
| 116 | return; |
| 117 | } |
| 118 | include tutor()->path . 'views/pages/ecommerce/coupon-list.php'; |
| 119 | } |
| 120 | } |
| 121 |