PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 4.17.1
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v4.17.1
4.17.1 4.17.0 4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / Membership / CustomersPage / SettingsPage.php
wp-user-avatar / src / Admin / SettingsPages / Membership / CustomersPage Last commit date
CustomerWPListTable.php 1 year ago SettingsPage.php 1 week ago index.php 4 years ago
SettingsPage.php
622 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages\Membership\CustomersPage;
4
5 use ProfilePress\Core\Admin\SettingsPages\AbstractSettingsPage;
6 use ProfilePress\Core\Classes\RegistrationAuth;
7 use ProfilePress\Core\Admin\SettingsPages\Membership\ContextualStateChangeHelper;
8 use ProfilePress\Core\Membership\CheckoutFields;
9 use ProfilePress\Core\Membership\Models\Customer\CustomerEntity;
10 use ProfilePress\Core\Membership\Models\Customer\CustomerFactory;
11 use ProfilePress\Core\Membership\Models\Order\OrderStatus;
12 use ProfilePress\Core\Membership\PaymentMethods\PaymentMethods;
13 use ProfilePress\Core\Membership\Repositories\PlanRepository;
14 use ProfilePress\Core\Membership\Services\Calculator;
15 use ProfilePress\Custom_Settings_Page_Api;
16 use ProfilePressVendor\Carbon\CarbonImmutable;
17
18 class SettingsPage extends AbstractSettingsPage
19 {
20 public $error_bucket;
21
22 /** @var CustomerWPListTable */
23 private $customerListTable;
24
25 function __construct()
26 {
27 add_action('ppress_register_menu_page', [$this, 'register_cpf_settings_page']);
28 add_action('ppress_admin_settings_page_customers', [$this, 'settings_page_function']);
29
30 add_action('wp_ajax_ppress_mb_search_wp_users', [$this, 'search_wp_users']);
31
32 if (ppressGET_var('page') == PPRESS_MEMBERSHIP_CUSTOMERS_SETTINGS_SLUG) {
33
34 add_filter('set-screen-option', [__CLASS__, 'set_screen'], 10, 3);
35 add_filter('set_screen_option_rules_per_page', [__CLASS__, 'set_screen'], 10, 3);
36
37 add_action('admin_init', function () {
38 $this->save_customer();
39 $this->add_customer();
40 });
41 }
42 }
43
44 public function default_header_menu()
45 {
46 return 'customers';
47 }
48
49 public function register_cpf_settings_page()
50 {
51 global $ppress_customer_page;
52
53 $hook = $ppress_customer_page = add_submenu_page(
54 PPRESS_DASHBOARD_SETTINGS_SLUG,
55 $this->admin_page_title() . ' - ProfilePress',
56 esc_html__('Customers', 'wp-user-avatar'),
57 'manage_options',
58 PPRESS_MEMBERSHIP_CUSTOMERS_SETTINGS_SLUG,
59 [$this, 'admin_page_callback']
60 );
61
62 add_action("load-$hook", [$this, 'add_options']);
63
64 do_action('ppress_membership_customers_settings_page_register', $hook);
65 }
66
67 /**
68 * @return void
69 * @throws \Exception
70 */
71 public function save_customer()
72 {
73 if ( ! isset($_POST['ppress_save_customer'])) return;
74
75 ppress_verify_nonce();
76
77 if ( ! current_user_can('manage_options')) return;
78
79 $user_id = absint($_POST['customer_wp_user']);
80
81 $customer_id = absint($_GET['id']);
82 $customer = CustomerFactory::fromId($customer_id);
83 $customer->user_id = $user_id;
84 $customer->private_note = sanitize_textarea_field(stripslashes($_POST['private_note']));
85 $customer->save();
86
87 $billing_fields = array_keys(CheckoutFields::billing_fields());
88
89 foreach ($_POST as $key => $value) {
90 if (in_array($key, $billing_fields)) {
91 update_user_meta($user_id, $key, sanitize_textarea_field($value));
92 }
93 }
94
95 do_action('ppress_customer_updated', $customer_id);
96
97 wp_safe_redirect(add_query_arg([
98 'ppress_customer_action' => 'view',
99 'id' => $customer_id,
100 'saved' => 'true'
101 ], PPRESS_MEMBERSHIP_CUSTOMERS_SETTINGS_PAGE));
102 exit;
103 }
104
105 /**
106 * @return void|string
107 * @throws \Exception
108 */
109 public function add_customer()
110 {
111 if ( ! isset($_POST['save_ppress_customers'])) return;
112
113 if ( ! current_user_can('create_users')) {
114 wp_die(__('You do not have permission to perform this action.', 'wp-user-avatar'), __('Error', 'wp-user-avatar'), array('response' => 403));
115 }
116
117 check_admin_referer('wp-csa-nonce', 'wp_csa_nonce');
118
119 $type = ! empty($_POST['user_account_type']) ? $_POST['user_account_type'] : 'new';
120
121 $customer_data = ppressPOST_var('ppress_customers', [], true);
122
123 $customer_email = ppress_var($customer_data, 'email', '');
124 $customer_user_id = ppress_var($customer_data, 'search_user', '');
125
126 if ($type == 'new' && empty($customer_email)) {
127 wp_die(__('Please enter a valid customer email.', 'wp-user-avatar'), __('Error', 'wp-user-avatar'), array('response' => 400));
128 }
129
130 if ('new' == $type) {
131
132 $user_login = ! empty($customer_data['username']) ? $customer_data['username'] : $customer_email;
133
134 $existing_user = get_user_by('login', $user_login);
135
136 if ($existing_user && $existing_user->exists()) {
137 wp_die(sprintf(__('A user account already exists with the login %s.', 'wp-user-avatar'), esc_html($user_login)), __('Error', 'wp-user-avatar'), array('response' => 500));
138 }
139
140 $user_args = array(
141 'user_login' => sanitize_text_field($user_login),
142 'user_email' => sanitize_text_field($customer_email),
143 'user_pass' => ! empty($_POST['pass1']) ? $_POST['pass1'] : wp_generate_password(24),
144 'first_name' => ! empty($customer_data['first_name']) ? sanitize_text_field($customer_data['first_name']) : '',
145 'last_name' => ! empty($customer_data['last_name']) ? sanitize_text_field($customer_data['last_name']) : ''
146 );
147
148 $user_args['display_name'] = trim($user_args['first_name'] . ' ' . $user_args['last_name']);
149
150 if (empty($user_args['display_name'])) {
151 $user_args['display_name'] = $user_args['user_login'];
152 }
153
154 $user_id = wp_insert_user($user_args);
155
156 if (empty($user_id)) {
157 wp_die(__('Error creating customer account.', 'wp-user-avatar'), __('Error', 'wp-user-avatar'), array('response' => 500));
158 }
159
160 // Send welcome email to the user
161 RegistrationAuth::send_welcome_email($user_id, $user_args['user_pass']);
162
163 $user = get_userdata($user_id);
164
165 } else {
166
167 $user = get_user_by('id', $customer_user_id);
168
169 if ( ! is_a($user, 'WP_User')) {
170 wp_die(sprintf(__('Unable to locate existing account with the email %s.', 'wp-user-avatar'), esc_html($customer_email)), __('Error', 'wp-user-avatar'), array('response' => 500));
171 }
172 }
173
174 $customer = CustomerFactory::fromUserId($user->ID);
175
176 if ($customer->exists()) {
177 wp_die(sprintf(__('A customer with the ID %d already exists with this account.', 'wp-user-avatar'), $customer->get_id()), __('Error', 'wp-user-avatar'), array('response' => 500));
178 }
179
180 $new_customer = new CustomerEntity();
181 $new_customer->user_id = $user->ID;
182 $customer_id = $new_customer->save();
183
184 if (empty($customer_id)) {
185 wp_die(__('Error creating customer record.', 'wp-user-avatar'), __('Error', 'wp-user-avatar'), array('response' => 500));
186 }
187
188 if (ppress_var($customer_data, 'billing_address') == 'true') {
189 foreach (array_keys(CheckoutFields::billing_fields()) as $billing_key) {
190 if (isset($_POST[$billing_key])) {
191 update_user_meta($user->ID, $billing_key, sanitize_textarea_field($_POST[$billing_key]));
192 }
193 }
194 }
195
196 do_action('ppress_customer_updated', $customer_id);
197
198 if (ppress_var($customer_data, 'create_order') == 'true') {
199 $this->create_customer_order($customer_id, $customer_data);
200 }
201
202 wp_safe_redirect(esc_url_raw(CustomerWPListTable::view_customer_url($customer_id)));
203 exit;
204 }
205
206 /**
207 * Create a membership order for the customer.
208 *
209 * @param int $customer_id
210 * @param array $customer_data
211 *
212 * @return void
213 */
214 protected function create_customer_order($customer_id, $customer_data)
215 {
216 $plan_id = absint(ppress_var($customer_data, 'order_plan'));
217
218 if (empty($plan_id)) {
219 wp_die(__('No plan was selected. Please try again.', 'wp-user-avatar'), __('Error', 'wp-user-avatar'), array('response' => 400));
220 }
221
222 $date_created = current_time('mysql');
223
224 if ( ! empty($customer_data['order_date'])) {
225 $date_created = CarbonImmutable::parse(sanitize_text_field($customer_data['order_date']), wp_timezone())
226 ->setTimeFromTimeString(CarbonImmutable::now(wp_timezone())->toTimeString())
227 ->utc()->toDateTimeString();
228 }
229
230 $amount = ppress_sanitize_amount(ppress_var($customer_data, 'order_amount', ''));
231
232 if (empty($amount) || Calculator::init($amount)->isNegativeOrZero()) {
233 $amount = ppress_get_plan($plan_id)->get_price();
234 }
235
236 $response = ppress_subscribe_user_to_plan(
237 $plan_id,
238 $customer_id,
239 [
240 'amount' => $amount,
241 'order_status' => ppress_var($customer_data, 'order_status', OrderStatus::COMPLETED),
242 'payment_method' => ppress_var($customer_data, 'order_payment_method', ''),
243 'transaction_id' => ppress_var($customer_data, 'order_transaction_id', ''),
244 'date_created' => $date_created
245 ],
246 ppress_var($customer_data, 'order_send_receipt') == 'true'
247 );
248
249 if (is_wp_error($response)) {
250 wp_die($response->get_error_message(), __('Error', 'wp-user-avatar'), array('response' => 400));
251 }
252 }
253
254 public function search_wp_users()
255 {
256 if ( ! current_user_can('manage_options')) return;
257
258 check_ajax_referer('ppress-admin-nonce', 'nonce');
259
260 $search = sanitize_text_field($_GET['search']);
261
262 $results['results'] = [];
263
264 $users = get_users([
265 'search' => '*' . $search . '*',
266 'search_columns' => ['user_email', 'user_login', 'user_nicename', 'display_name'],
267 'fields' => ['ID', 'user_email', 'user_login'],
268 'number' => 1000
269 ]);
270
271 if (is_array($users) && ! empty($users)) {
272
273 foreach ($users as $user) {
274
275 $results['results'][$user->ID] = array(
276 'id' => $user->ID,
277 'text' => sprintf('%s (%s)', $user->user_login, $user->user_email),
278 );
279 }
280 }
281
282 $results['results'] = array_values($results['results']);
283
284 wp_send_json($results, 200);
285 }
286
287 public function admin_page_title()
288 {
289 $title = esc_html__('Customers', 'wp-user-avatar');
290
291 if (ppressGET_var('ppress_customer_action') == 'new') {
292 $title = esc_html__('Add New Customer', 'wp-user-avatar');
293 }
294
295 if (ppressGET_var('ppress_customer_action') == 'view') {
296 $title = esc_html__('Customer Details', 'wp-user-avatar');
297 }
298
299 return $title;
300 }
301
302 public static function set_screen($status, $option, $value)
303 {
304 return $value;
305 }
306
307 public function add_options()
308 {
309 $args = [
310 'label' => esc_html__('Customers', 'wp-user-avatar'),
311 'default' => 10,
312 'option' => 'customers_per_page'
313 ];
314
315 add_screen_option('per_page', $args);
316
317 $this->customerListTable = new CustomerWPListTable();
318 }
319
320 public function admin_notices()
321 {
322 if ( ! isset($_GET['saved']) && ! isset($this->error_bucket)) return;
323
324 $status = 'updated';
325 $message = '';
326
327 if ( ! empty($this->error_bucket)) {
328 $message = $this->error_bucket;
329 $status = 'error';
330 }
331
332 if (isset($_GET['saved'])) {
333 $message = esc_html__('Changes saved.', 'wp-user-avatar');
334 }
335
336 printf('<div id="message" class="%s notice is-dismissible"><p>%s</strong></p></div>', $status, $message);
337 }
338
339 public function settings_page_function()
340 {
341 add_action('admin_footer', [$this, 'js_script']);
342 add_filter('wp_cspa_main_content_area', [$this, 'admin_settings_page_callback'], 10, 2);
343 add_action('wp_cspa_before_closing_header', [$this, 'add_new_button']);
344
345 add_action('wp_cspa_form_tag', function ($option_name) {
346 if ($option_name == 'ppress_customers') {
347 printf(' action="%s"', ppress_get_current_url_query_string());
348 }
349 });
350
351 $instance = Custom_Settings_Page_Api::instance();
352 if ( ! isset($_GET['ppress_customer_action'])) {
353 $instance->form_method('get');
354 $instance->remove_nonce_field();
355 }
356
357 if (ppressGET_var('ppress_customer_action') == 'new') {
358
359 $form_fields = [
360 'account_type' => [
361 'label' => __('User Account', 'wp-user-avatar'),
362 'type' => 'custom_field_block',
363 'data' => self::user_account_type_settings()
364 ],
365 'search_user' => [
366 'label' => __('Search User', 'wp-user-avatar'),
367 'type' => 'select',
368 'options' => [],
369 'attributes' => ['class' => 'ppress-select2-field customer_wp_user']
370 ],
371 'first_name' => [
372 'label' => __('First Name', 'wp-user-avatar'),
373 'type' => 'text'
374 ],
375 'last_name' => [
376 'label' => __('Last Name', 'wp-user-avatar'),
377 'type' => 'text'
378 ],
379 'email' => [
380 'label' => __('Email Address', 'wp-user-avatar'),
381 'type' => 'text'
382 ],
383 'username' => [
384 'label' => __('Username', 'wp-user-avatar'),
385 'type' => 'text'
386 ],
387 'password' => [
388 'label' => __('Password', 'wp-user-avatar'),
389 'type' => 'custom_field_block',
390 'data' => self::password_field()
391 ],
392 'billing_address' => [
393 'label' => __('Billing Address', 'wp-user-avatar'),
394 'checkbox_label' => __('Add a billing address for this customer.', 'wp-user-avatar'),
395 'type' => 'checkbox'
396 ]
397 ];
398
399 $form_fields = array_merge($form_fields, self::billing_field_blocks());
400
401 $form_fields = array_merge($form_fields, [
402 'create_order' => [
403 'label' => __('Create Order', 'wp-user-avatar'),
404 'checkbox_label' => __('Create a membership order for this customer.', 'wp-user-avatar'),
405 'type' => 'checkbox'
406 ],
407 'order_plan' => [
408 'label' => __('Membership Plan', 'wp-user-avatar'),
409 'type' => 'select',
410 'options' => array_reduce(PlanRepository::init()->retrieveAll(), function ($carry, $item) {
411 $carry[$item->id] = $item->name;
412
413 return $carry;
414 }, ['' => '&mdash;&mdash;&mdash;&mdash;'])
415 ],
416 'order_amount' => [
417 'label' => __('Amount', 'wp-user-avatar'),
418 'type' => 'text',
419 'placeholder' => ppress_display_amount('0.00'),
420 'description' => esc_html__('Enter the total order amount, or leave blank to use the price of the selected plan.', 'wp-user-avatar')
421 ],
422 'order_status' => [
423 'label' => __('Order Status', 'wp-user-avatar'),
424 'type' => 'select',
425 'options' => OrderStatus::get_all()
426 ],
427 'order_payment_method' => [
428 'label' => __('Payment Method', 'wp-user-avatar'),
429 'type' => 'select',
430 'options' => array_reduce(PaymentMethods::get_instance()->get_all(), function ($carry, $item) {
431 $carry[$item->id] = $item->method_title;
432
433 return $carry;
434 }, ['' => '&mdash;&mdash;&mdash;&mdash;'])
435 ],
436 'order_transaction_id' => [
437 'label' => __('Transaction ID', 'wp-user-avatar'),
438 'type' => 'text',
439 'description' => esc_html__('Enter the transaction ID, if any.', 'wp-user-avatar')
440 ],
441 'order_date' => [
442 'label' => __('Date', 'wp-user-avatar'),
443 'type' => 'text',
444 'class' => 'ppress_datepicker',
445 'description' => esc_html__("Enter the purchase date, or leave blank for today's date.", 'wp-user-avatar')
446 ],
447 'order_send_receipt' => [
448 'label' => __('Send Receipt', 'wp-user-avatar'),
449 'checkbox_label' => __('Check to send the order receipt to the customer.', 'wp-user-avatar'),
450 'type' => 'checkbox',
451 'default_value' => 'true'
452 ]
453 ]);
454
455 ContextualStateChangeHelper::init();
456
457 $instance->main_content([
458 apply_filters('ppress_admin_new_customer_form_fields', $form_fields)
459 ]);
460
461 $instance->remove_white_design();
462
463 $instance->sidebar(self::sidebar_args());
464 }
465
466 $instance->add_view_classes('ppview');
467 $instance->option_name('ppress_customers');
468 $instance->page_header($this->admin_page_title());
469 $instance->build(ppressGET_var('ppress_customer_action') != 'new');
470 }
471
472
473 protected static function user_account_type_settings()
474 {
475 $html = sprintf(
476 '<label><input checked class="user-account-type" type="radio" name="user_account_type" value="new">%s</label>&nbsp;&nbsp;',
477 __('New Account', 'wp-user-avatar')
478 );
479
480 $html .= sprintf(
481 '<label><input class="user-account-type" type="radio" name="user_account_type" value="existing">%s</label>&nbsp;&nbsp;',
482 __('Existing Account', 'wp-user-avatar')
483 );
484
485 return $html;
486 }
487
488 protected static function password_field()
489 {
490 ob_start();
491 ?>
492 <div id="password" class="user-pass1-wrap">
493 <input class="hidden" value=" "/><!-- #24364 workaround -->
494 <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e('Show password', 'wp-user-avatar'); ?></button>
495 <div class="wp-pwd hide-if-js">
496 <span class="password-input-wrapper">
497 <input style="width:25em!important;" type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="new-password" data-pw="<?php echo esc_attr(wp_generate_password(24)); ?>"/>
498 </span>
499 <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Hide password', 'wp-user-avatar'); ?>">
500 <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
501 <span class="text"><?php _e('Hide', 'wp-user-avatar'); ?></span>
502 </button>
503 <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0">
504 <span class="dashicons dashicons-no" aria-hidden="true"></span>
505 <span class="text"><?php _e('Cancel', 'wp-user-avatar'); ?></span>
506 </button>
507 <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
508 </div>
509 </div>
510 <?php
511 return ob_get_clean();
512 }
513
514 /**
515 * Billing field blocks for the new customer form.
516 *
517 * @return array
518 */
519 protected static function billing_field_blocks()
520 {
521 $billing_fields = CheckoutFields::billing_fields();
522 $standard = CheckoutFields::standard_billing_fields();
523
524 $blocks = [];
525
526 foreach ($billing_fields as $field_id => $field) {
527
528 $label = ppress_var($field, 'label', ppress_var($standard, $field_id, ['label' => $field_id])['label']);
529
530 $blocks['billing_field_' . $field_id] = [
531 'label' => $label,
532 'type' => 'custom_field_block',
533 'data' => do_shortcode(sprintf('[edit-profile-cpf id="%1$s" key="%1$s" value="" class="regular-text widefat"]', esc_attr($field_id)))
534 ];
535 }
536
537 return $blocks;
538 }
539
540 public function add_new_button()
541 {
542 if ( ! isset($_GET['ppress_customer_action'])) {
543 $url = esc_url_raw(add_query_arg('ppress_customer_action', 'new', PPRESS_MEMBERSHIP_CUSTOMERS_SETTINGS_PAGE));
544 echo "<a class=\"add-new-h2\" href=\"$url\">" . esc_html__('Add New', 'wp-user-avatar') . '</a>';
545 }
546 }
547
548 public function admin_settings_page_callback($content)
549 {
550 if (ppressGET_var('ppress_customer_action') == 'view') {
551 $this->admin_notices();
552 ContextualStateChangeHelper::init();
553 require_once dirname(dirname(__FILE__)) . '/views/customers/view-customer.php';
554
555 return;
556 }
557
558 if (ppressGET_var('ppress_customer_action') == 'new') return $content;
559
560 $this->customerListTable->prepare_items();
561
562 echo '<input type="hidden" name="page" value="' . PPRESS_MEMBERSHIP_CUSTOMERS_SETTINGS_SLUG . '" />';
563 echo '<input type="hidden" name="view" value="customers" />';
564 if (isset($_GET['status'])) {
565 echo '<input type="hidden" name="status" value="' . esc_attr($_GET['status']) . '" />';
566 }
567 $this->customerListTable->views();
568 $this->customerListTable->filter_bar();
569 $this->customerListTable->display();
570
571 do_action('ppress_customer_wp_list_table_bottom');
572 }
573
574 public function js_script()
575 {
576 ?>
577 <script type="text/javascript">
578 jQuery(function ($) {
579 $("input.user-account-type").on("change", function () {
580 if ($("input[name=\'user_account_type\']:checked").val() === "new") {
581 $("#search_user_row").hide();
582 $("#first_name_row").show();
583 $("#last_name_row").show();
584 $("#email_row").show();
585 $("#username_row").show();
586 $("#password_row").show();
587 } else {
588 $("#search_user_row").show();
589 $("#first_name_row").hide();
590 $("#last_name_row").hide();
591 $("#email_row").hide();
592 $("#username_row").hide();
593 $("#password_row").hide();
594 }
595 }).trigger('change');
596
597 var orderRows = "#order_plan_row, #order_amount_row, #order_status_row, #order_payment_method_row, #order_transaction_id_row, #order_date_row, #order_send_receipt_row";
598 $("#create_order").on("change", function () {
599 $(this).is(":checked") ? $(orderRows).show() : $(orderRows).hide();
600 }).trigger('change');
601
602 var billingRows = $("tr[id^='billing_field_']");
603 $("#billing_address").on("change", function () {
604 $(this).is(":checked") ? billingRows.show() : billingRows.hide();
605 }).trigger('change');
606 });
607 </script>
608 <?php
609 }
610
611 public static function get_instance()
612 {
613 static $instance = null;
614
615 if (is_null($instance)) {
616 $instance = new self();
617 }
618
619 return $instance;
620 }
621 }
622