Cart
1 year ago
PaymentGateways
10 months ago
AdminMenu.php
1 year ago
BillingController.php
1 year ago
CartController.php
1 year ago
CheckoutController.php
11 months ago
CouponController.php
11 months ago
Ecommerce.php
1 year ago
EmailController.php
11 months ago
HooksHandler.php
10 months ago
OptionKeys.php
1 year ago
OrderActivitiesController.php
1 year ago
OrderController.php
11 months ago
PaymentHandler.php
10 months ago
Settings.php
1 year ago
Tax.php
11 months ago
currency.php
1 year ago
AdminMenu.php
100 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_action( 'tutor_after_courses_admin_menu', array( $this, 'register_menu' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Register menu |
| 29 | * |
| 30 | * @return void |
| 31 | */ |
| 32 | public function register_menu() { |
| 33 | $order_menu_title = __( 'Orders', 'tutor' ); |
| 34 | $order_badge_count = get_transient( OrderModel::TRANSIENT_ORDER_BADGE_COUNT ); |
| 35 | |
| 36 | if ( false === $order_badge_count ) { |
| 37 | $order_badge_count = ( new OrderModel() )->get_order_count( |
| 38 | array( |
| 39 | 'payment_status' => OrderModel::PAYMENT_UNPAID, |
| 40 | 'order_type' => OrderModel::TYPE_SINGLE_ORDER, |
| 41 | ) |
| 42 | ); |
| 43 | set_transient( OrderModel::TRANSIENT_ORDER_BADGE_COUNT, $order_badge_count, HOUR_IN_SECONDS ); |
| 44 | } |
| 45 | |
| 46 | if ( $order_badge_count ) { |
| 47 | $order_menu_title .= ' <span class="update-plugins"><span class="plugin-count">' . $order_badge_count . '</span></span>'; |
| 48 | } |
| 49 | |
| 50 | add_submenu_page( 'tutor', __( 'Orders', 'tutor' ), $order_menu_title, 'manage_options', OrderController::PAGE_SLUG, array( $this, 'orders_view' ) ); |
| 51 | do_action( 'tutor_after_orders_admin_menu' ); |
| 52 | add_submenu_page( 'tutor', __( 'Coupons', 'tutor' ), __( 'Coupons', 'tutor' ), 'manage_options', CouponController::PAGE_SLUG, array( $this, 'coupons_view' ) ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Orders view page |
| 57 | * |
| 58 | * @since 3.0.0 |
| 59 | * |
| 60 | * @return void |
| 61 | */ |
| 62 | public function orders_view() { |
| 63 | $current_page = Input::get( 'page' ); |
| 64 | $action = Input::get( 'action' ); |
| 65 | |
| 66 | if ( OrderController::PAGE_SLUG === $current_page && 'edit' === $action ) { |
| 67 | ?> |
| 68 | <div class="tutor-admin-wrap tutor-order-details-wrapper"> |
| 69 | <div id="tutor-order-details-root"> |
| 70 | </div> |
| 71 | </div> |
| 72 | <?php |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | include apply_filters( 'tutor_order_list_page_template', tutor()->path . 'views/pages/ecommerce/order-list.php' ); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Coupons view page |
| 81 | * |
| 82 | * @since 3.0.0 |
| 83 | * |
| 84 | * @return void |
| 85 | */ |
| 86 | public function coupons_view() { |
| 87 | $action = Input::get( 'action' ); |
| 88 | if ( in_array( $action, array( 'add_new', 'edit' ) ) ) { |
| 89 | ?> |
| 90 | <div class="tutor-admin-wrap"> |
| 91 | <div id="tutor-coupon-root"> |
| 92 | </div> |
| 93 | </div> |
| 94 | <?php |
| 95 | return; |
| 96 | } |
| 97 | include tutor()->path . 'views/pages/ecommerce/coupon-list.php'; |
| 98 | } |
| 99 | } |
| 100 |