PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.2.2
Order Tracking – WordPress Status Tracking Plugin v3.2.2
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / includes / AdminCustomers.class.php

AdminCustomers.class.php in Order Tracking – WordPress Status Tracking Plugin 3.2.2, at includes/AdminCustomers.class.php

149 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( !defined( 'ABSPATH' ) ) exit;
3
4 if ( !class_exists( 'ewdotpAdminCustomers' ) ) {
5 /**
6 * Class to handle the admin customers page for Order Tracking
7 *
8 * @since 3.0.0
9 */
10 class ewdotpAdminCustomers {
11
12 /**
13 * The customers table
14 *
15 * This is only instantiated on the customers admin page at the moment when
16 * it is generated.
17 *
18 * @see self::show_admin_customers_page()
19 * @see WP_List_table.BookingsTable.class.php
20 * @since 3.0.0
21 */
22 public $customers_table;
23
24 public function __construct() {
25
26 // Add the admin menu
27 add_action( 'admin_menu', array( $this, 'add_menu_page' ), 12 );
28
29 // Hide the 'Add New' item from the side menu
30 add_action( 'admin_head', array( $this, 'hide_add_new_menu_item' ), 12 );
31 }
32
33 /**
34 * Add the top-level admin menu page
35 * @since 3.0.0
36 */
37 public function add_menu_page() {
38 global $ewd_otp_controller;
39
40 add_submenu_page(
41 'ewd-otp-orders',
42 _x( 'Customers', 'Title of admin page that lets you view all customers', 'order-tracking' ),
43 _x( 'Customers', 'Title of the customers admin menu item', 'order-tracking' ),
44 $ewd_otp_controller->settings->get_setting( 'access-role' ),
45 'ewd-otp-customers',
46 array( $this, 'show_admin_customers_page' )
47 );
48
49 add_submenu_page(
50 'ewd-otp-orders',
51 _x( 'Add/Edit Customer', 'Title of admin page that lets you add or edit an customer', 'order-tracking' ),
52 _x( 'Add New', 'Title of the add/edit customer admin menu item', 'order-tracking' ),
53 $ewd_otp_controller->settings->get_setting( 'access-role' ),
54 'ewd-otp-add-edit-customer',
55 array( $this, 'add_edit_customer' )
56 );
57 }
58
59 /**
60 * Hide the 'Add New' admin page from the WordPress sidebar menu
61 * @since 3.0.0
62 */
63 public function hide_add_new_menu_item() {
64
65 remove_submenu_page( 'ewd-otp-orders', 'ewd-otp-add-edit-customer' );
66 }
67
68 /**
69 * Display the admin customers page
70 * @since 3.0.0
71 */
72 public function show_admin_customers_page() {
73 global $ewd_otp_controller;
74
75 require_once( EWD_OTP_PLUGIN_DIR . '/includes/WP_List_Table.CustomersTable.class.php' );
76 $this->customers_table = new ewdotpCustomersTable();
77 $this->customers_table->prepare_items();
78
79 $permission = ( $ewd_otp_controller->permissions->check_permission( 'customers' ) or get_option( 'ewd-otp-installation-time' ) < 1664742505 ) ? true : false;
80 ?>
81
82 <div class="wrap">
83 <h1>
84 <?php _e( 'Customers', 'order-tracking' ); ?>
85 <?php if ( $permission ) { ?><a href="admin.php?page=ewd-otp-add-edit-customer" class="add-new-h2 page-title-action add-customer"><?php _e( 'Add New', 'order-tracking' ); ?></a><?php } ?>
86 </h1>
87
88 <?php if ( $permission ) { ?>
89
90 <?php do_action( 'ewd_otp_customers_table_top' ); ?>
91 <form id="ewd-otp-customers-table" method="POST" action="">
92 <input type="hidden" name="page" value="ewd-otp-customers">
93
94 <div class="ewd-otp-primary-controls clearfix">
95 <div class="ewd-otp-views">
96 <?php $this->customers_table->views(); ?>
97 </div>
98 <?php $this->customers_table->advanced_filters(); ?>
99 </div>
100
101 <?php $this->customers_table->display(); ?>
102 </form>
103 <?php do_action( 'ewd_otp_customers_table_bottom' ); ?>
104
105 <?php } else { ?>
106
107 <div class='ewd-otp-premium-locked'>
108 <a href="https://www.etoilewebdesign.com/license-payment/?Selected=OTP&Quantity=1" target="_blank">Upgrade</a> to the premium version to use this feature
109 </div>
110 <?php } ?>
111 </div>
112
113 <?php
114 }
115
116 /**
117 * Display the admin customers page
118 * @since 3.0.0
119 */
120 public function add_edit_customer() {
121 global $ewd_otp_controller;
122
123 $customer_id = ! empty( $_GET['customer_id'] ) ? intval( $_GET['customer_id'] ) : 0;
124
125 $customer = new ewdotpCustomer();
126
127 if ( $customer_id ) {
128
129 $customer->load_customer_from_id( $customer_id );
130 }
131
132 if ( isset( $_POST['ewd_otp_admin_customer_submit'] ) ) {
133
134 $customer->process_admin_customer_submission();
135 }
136
137 ewd_otp_load_view_files();
138
139 $args = array(
140 'customer' => $customer
141 );
142
143 $admin_customer_view = new ewdotpAdminCustomerFormView( $args );
144
145 echo $admin_customer_view->render();
146 }
147 }
148 } // endif;
149