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 / Settings.class.php

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

1,000 lines 30.8 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( 'ewdotpSettings' ) ) {
5 /**
6 * Class to handle configurable settings for Order Tracking
7 * @since 3.0.0
8 */
9 class ewdotpSettings {
10
11 public $order_information_options = array();
12
13 public $sales_rep_options = array();
14
15 public $status_options = array();
16
17 public $currency_options = array();
18
19 public $email_options = array();
20
21 /**
22 * Default values for settings
23 * @since 3.0.0
24 */
25 public $defaults = array();
26
27 /**
28 * Stored values for settings
29 * @since 3.0.0
30 */
31 public $settings = array();
32
33 public function __construct() {
34
35 add_action( 'init', array( $this, 'set_defaults' ) );
36
37 add_action( 'init', array( $this, 'set_field_options' ), 11 );
38
39 add_action( 'init', array( $this, 'load_settings_panel' ), 12 );
40 }
41
42 /**
43 * Load the plugin's default settings
44 * @since 3.0.0
45 */
46 public function set_defaults() {
47
48 $order_information_defaults = array(
49 'order_number',
50 'order_name',
51 'order_status',
52 'order_updated',
53 'order_notes',
54 );
55
56 $this->defaults = array(
57
58 'order-information' => $order_information_defaults,
59
60 'date-format' => _x( 'd-m-Y H:i:s', 'Default date format for display. Available options here https://www.php.net/manual/en/datetime.format.php', 'order-tracking' ),
61 'form-instructions' => __( 'Enter the order number you would like to track in the form below.', 'order-tracking' ),
62
63 'access-role' => 'manage_options',
64 'tracking-graphic' => 'default',
65
66 'google-maps-api-key' => 'AIzaSyBFLmQU4VaX-T67EnKFtos7S7m_laWn6L4',
67
68 'email-messages' => array(),
69
70 'label-retrieving-results' => __( 'Retrieving Results...', 'order-tracking' ),
71 'label-customer-order-thank-you' => __( 'Thank you. Your order number is:', 'order-tracking' ),
72 );
73
74 $this->defaults = apply_filters( 'ewd_otp_defaults', $this->defaults, $this );
75 }
76
77 /**
78 * Put all of the available possible select options into key => value arrays
79 * @since 3.0.0
80 */
81 public function set_field_options() {
82 global $ewd_otp_controller;
83
84 $this->currency_options = array(
85 'AUD' => __( 'Australian Dollar', 'order-tracking'),
86 'BRL' => __( 'Brazilian Real', 'order-tracking'),
87 'CAD' => __( 'Canadian Dollar', 'order-tracking'),
88 'CZK' => __( 'Czech Koruna', 'order-tracking'),
89 'DKK' => __( 'Danish Krone', 'order-tracking'),
90 'EUR' => __( 'Euro', 'order-tracking'),
91 'HKD' => __( 'Hong Kong Dollar', 'order-tracking'),
92 'HUF' => __( 'Hungarian Forint', 'order-tracking'),
93 'ILS' => __( 'Israeli New Sheqel', 'order-tracking'),
94 'JPY' => __( 'Japanese Yen', 'order-tracking'),
95 'MYR' => __( 'Malaysian Ringgit', 'order-tracking'),
96 'MXN' => __( 'Mexican Peso', 'order-tracking'),
97 'NOK' => __( 'Norwegian Krone', 'order-tracking'),
98 'NZD' => __( 'New Zealand Dollar', 'order-tracking'),
99 'PHP' => __( 'Philippine Peso', 'order-tracking'),
100 'PLN' => __( 'Polish Zloty', 'order-tracking'),
101 'GBP' => __( 'Pound Sterling', 'order-tracking'),
102 'RUB' => __( 'Russian Ruble', 'order-tracking'),
103 'SGD' => __( 'Singapore Dollar', 'order-tracking'),
104 'SEK' => __( 'Swedish Krona', 'order-tracking'),
105 'CHF' => __( 'Swiss Franc', 'order-tracking'),
106 'TWD' => __( 'Taiwan New Dollar', 'order-tracking'),
107 'THB' => __( 'Thai Baht', 'order-tracking'),
108 'TRY' => __( 'Turkish Lira', 'order-tracking'),
109 'USD' => __( 'U.S. Dollar', 'order-tracking'),
110 );
111
112 $this->order_information_options = array(
113 'order_number' => __( 'Order Number', 'order-tracking' ),
114 'order_name' => __( 'Name', 'order-tracking' ),
115 'order_status' => __( 'Status', 'order-tracking' ),
116 'order_location' => __( 'Location', 'order-tracking' ),
117 'order_updated' => __( 'Updated Date', 'order-tracking' ),
118 'order_notes' => __( 'Notes', 'order-tracking' ),
119 'customer_notes' => __( 'Customer Notes', 'order-tracking' ),
120 'order_graphic' => __( 'Status Graphic', 'order-tracking' ),
121 'order_map' => __( 'Tracking Map', 'order-tracking' ),
122 'customer_name' => __( 'Customer Name', 'order-tracking' ),
123 'customer_email' => __( 'Customer Email', 'order-tracking' ),
124 'sales_rep_first_name' => __( 'Sales Rep First Name', 'order-tracking' ),
125 'sales_rep_last_name' => __( 'Sales Rep Last Name', 'order-tracking' ),
126 'sales_rep_email' => __( 'Sales Rep Email', 'order-tracking' ),
127 );
128
129 $statuses = ewd_otp_decode_infinite_table_setting( $this->get_setting( 'statuses' ) );
130
131 foreach ( $statuses as $status ) {
132
133 $this->status_options[ $status->status ] = $status->status;
134 }
135
136 $emails = ewd_otp_decode_infinite_table_setting( $this->get_setting( 'email-messages' ) );
137
138 foreach ( $emails as $email ) {
139
140 $this->email_options[ $email->id ] = $email->name;
141 }
142
143 if ( post_type_exists( 'uwpm_mail_template' ) ) {
144
145 $this->email_options[-1] = '';
146
147 $args = array(
148 'post_type' => 'uwpm_mail_template',
149 'numberposts' => -1
150 );
151
152 $uwpm_emails = get_posts( $args );
153
154 foreach ( $uwpm_emails as $uwpm_email ) {
155
156 $email_id = $uwpm_email->ID * -1;
157
158 $this->email_options[ $email_id ] = $uwpm_email->post_title;
159 }
160 }
161
162 $args = array(
163 'sales_reps_per_page' => -1
164 );
165
166 $sales_reps = $ewd_otp_controller->sales_rep_manager->get_matching_sales_reps( $args );
167
168 foreach ( $sales_reps as $sales_rep ) {
169
170 $this->sales_rep_options[ $sales_rep->id ] = $sales_rep->first_name . ' ' . $sales_rep->last_name;
171 }
172 }
173
174 /**
175 * Get a setting's value or fallback to a default if one exists
176 * @since 3.0.0
177 */
178 public function get_setting( $setting ) {
179
180 if ( empty( $this->settings ) ) {
181 $this->settings = get_option( 'ewd-otp-settings' );
182 }
183
184 if ( ! empty( $this->settings[ $setting ] ) ) {
185 return apply_filters( 'ewd-otp-settings-' . $setting, $this->settings[ $setting ] );
186 }
187
188 if ( ! empty( $this->defaults[ $setting ] ) ) {
189 return apply_filters( 'ewd-otp-settings-' . $setting, $this->defaults[ $setting ] );
190 }
191
192 return apply_filters( 'ewd-otp-settings-' . $setting, null );
193 }
194
195 /**
196 * Set a setting to a particular value
197 * @since 3.0.0
198 */
199 public function set_setting( $setting, $value ) {
200
201 $this->settings[ $setting ] = $value;
202 }
203
204 /**
205 * Save all settings, to be used with set_setting
206 * @since 3.0.0
207 */
208 public function save_settings() {
209
210 update_option( 'ewd-otp-settings', $this->settings );
211 }
212
213 /**
214 * Load the admin settings page
215 * @since 3.0.0
216 * @sa https://github.com/NateWr/simple-admin-pages
217 */
218 public function load_settings_panel() {
219
220 global $ewd_otp_controller;
221
222 require_once( EWD_OTP_PLUGIN_DIR . '/lib/simple-admin-pages/simple-admin-pages.php' );
223 $sap = sap_initialize_library(
224 $args = array(
225 'version' => '2.6.12',
226 'lib_url' => EWD_OTP_PLUGIN_URL . '/lib/simple-admin-pages/',
227 'theme' => 'purple',
228 )
229 );
230
231 $sap->add_page(
232 'submenu',
233 array(
234 'id' => 'ewd-otp-settings',
235 'title' => __( 'Settings', 'order-tracking' ),
236 'menu_title' => __( 'Settings', 'order-tracking' ),
237 'parent_menu' => 'ewd-otp-orders',
238 'description' => '',
239 'capability' => $this->get_setting( 'access-role' ),
240 'default_tab' => 'ewd-otp-basic-tab',
241 )
242 );
243
244 $sap->add_section(
245 'ewd-otp-settings',
246 array(
247 'id' => 'ewd-otp-basic-tab',
248 'title' => __( 'Basic', 'order-tracking' ),
249 'is_tab' => true,
250 'rank' => 1,
251 'tutorial_yt_id' => 'v8t0Z06Y_XY',
252 )
253 );
254
255 $sap->add_section(
256 'ewd-otp-settings',
257 array(
258 'id' => 'ewd-otp-general',
259 'title' => __( 'General', 'order-tracking' ),
260 'tab' => 'ewd-otp-basic-tab',
261 )
262 );
263
264 $sap->add_setting(
265 'ewd-otp-settings',
266 'ewd-otp-general',
267 'textarea',
268 array(
269 'id' => 'custom-css',
270 'title' => __( 'Custom CSS', 'order-tracking' ),
271 'description' => __( 'You can add custom CSS styles to your appointment booking page in the box above.', 'order-tracking' ),
272 )
273 );
274
275 $sap->add_setting(
276 'ewd-otp-settings',
277 'ewd-otp-general',
278 'checkbox',
279 array(
280 'id' => 'order-information',
281 'title' => __( 'Order Information Displayed', 'order-tracking' ),
282 'description' => __( 'What information should be displayed for your orders?', 'order-tracking' ),
283 'options' => $this->order_information_options
284 )
285 );
286
287 $sap->add_setting(
288 'ewd-otp-settings',
289 'ewd-otp-general',
290 'toggle',
291 array(
292 'id' => 'hide-blank-fields',
293 'title' => __( 'Hide Blank Fields', 'order-tracking' ),
294 'description' => __( 'Should fields which don\'t have a value (ex. customer name, custom fields) be hidden if they\'re empty?', 'order-tracking' )
295 )
296 );
297
298 $sap->add_setting(
299 'ewd-otp-settings',
300 'ewd-otp-general',
301 'textarea',
302 array(
303 'id' => 'form-instructions',
304 'title' => __( 'Form Instructions', 'order-tracking' ),
305 'description' => __( 'The instructions that will display above the order form.', 'order-tracking' ),
306 )
307 );
308
309 $sap->add_setting(
310 'ewd-otp-settings',
311 'ewd-otp-general',
312 'text',
313 array(
314 'id' => 'date-format',
315 'title' => __( 'Date/Time Format', 'order-tracking' ),
316 'description' => __( 'The format to use when displaying dates. Possible options can be: <a href="https://www.php.net/manual/en/datetime.format.php">found here</a>', 'order-tracking' )
317 )
318 );
319
320 $sap->add_setting(
321 'ewd-otp-settings',
322 'ewd-otp-general',
323 'radio',
324 array(
325 'id' => 'email-frequency',
326 'title' => __( 'Order Email Frequency', 'order-tracking' ),
327 'description' => __( 'How often should emails be sent to customers about the status of their orders?', 'order-tracking' ),
328 'options' => array(
329 'change' => __( 'On Change', 'order-tracking' ),
330 'creation' => __( 'On Creation', 'order-tracking' ),
331 'never' => __( 'Never', 'order-tracking' ),
332 )
333 )
334 );
335
336 $sap->add_setting(
337 'ewd-otp-settings',
338 'ewd-otp-general',
339 'toggle',
340 array(
341 'id' => 'disable-ajax-loading',
342 'title' => __( 'Disable AJAX Reloads', 'order-tracking' ),
343 'description' => __( 'Should the use of AJAX to display search results without reloading the page be disabled?', 'order-tracking' )
344 )
345 );
346
347 $sap->add_setting(
348 'ewd-otp-settings',
349 'ewd-otp-general',
350 'toggle',
351 array(
352 'id' => 'new-window',
353 'title' => __( 'New Window', 'order-tracking' ),
354 'description' => __( 'Should search results open in a new window? (Doesn\'t work with AJAX reloads)', 'order-tracking' )
355 )
356 );
357
358 $sap->add_setting(
359 'ewd-otp-settings',
360 'ewd-otp-general',
361 'toggle',
362 array(
363 'id' => 'display-print-button',
364 'title' => __( 'Display "Print" Button', 'order-tracking' ),
365 'description' => __( 'Should a "Print" button be added to tracking form results, so that visitors can print their order information more easily?', 'order-tracking' )
366 )
367 );
368
369 $sap->add_setting(
370 'ewd-otp-settings',
371 'ewd-otp-general',
372 'toggle',
373 array(
374 'id' => 'email-verification',
375 'title' => __( 'Email Verification', 'order-tracking' ),
376 'description' => __( 'Do visitors need to also enter the email address associated with an order to be able to view order information?', 'order-tracking' )
377 )
378 );
379
380 $sap->add_setting(
381 'ewd-otp-settings',
382 'ewd-otp-general',
383 'text',
384 array(
385 'id' => 'google-maps-api-key',
386 'title' => __( 'Google Maps API Key', 'order-tracking' ),
387 'description' => sprintf(
388 __( 'If you\'re displaying a map with a map of your order locations ( using the "Tracking Map" checkbox of the "Order Information" setting above), Google requires an API key to use their maps. %sGet an API key%s.', 'order-tracking' ),
389 '<a href="https://developers.google.com/maps/documentation/javascript/get-api-key">',
390 '</a>'
391 ),
392 'conditional_on' => 'order-information',
393 'conditional_on_value' => 'order_map'
394 )
395 );
396
397 $sap->add_setting(
398 'ewd-otp-settings',
399 'ewd-otp-general',
400 'text',
401 array(
402 'id' => 'tracking-page-url',
403 'title' => __( 'Status Tracking URL', 'order-tracking' ),
404 'description' => __( 'The URL of your tracking page, required if you want to include a tracking link in your message body, on the WooCommerce order page, etc..', 'order-tracking' )
405 )
406 );
407
408 $sap->add_setting(
409 'ewd-otp-settings',
410 'ewd-otp-general',
411 'toggle',
412 array(
413 'id' => 'use-wp-timezone',
414 'title' => __( 'Use WP Timezone', 'order-tracking' ),
415 'description' => __( 'By default, the timestamp on status updates uses your server\'s timezone. Enabling this will make it display (in the admin and on the front-end tracking page) using the timezone you have set in your WordPress General Settings instead. ', 'order-tracking' )
416 )
417 );
418
419 $sap->add_section(
420 'ewd-otp-settings',
421 array(
422 'id' => 'ewd-otp-statuses-tab',
423 'title' => __( 'Statuses', 'order-tracking' ),
424 'is_tab' => true,
425 'rank' => 3,
426 'tutorial_yt_id' => 'ih7qJEuOgPY',
427 )
428 );
429
430 $sap->add_section(
431 'ewd-otp-settings',
432 array(
433 'id' => 'ewd-otp-statuses',
434 'title' => __( 'Statuses', 'order-tracking' ),
435 'tab' => 'ewd-otp-statuses-tab',
436 )
437 );
438
439 $statuses_description = __( 'Statuses let your customers know the current status of their order.', 'order-tracking' ) . '<br />';
440
441 $sap->add_setting(
442 'ewd-otp-settings',
443 'ewd-otp-statuses',
444 'infinite_table',
445 array(
446 'id' => 'statuses',
447 'title' => __( 'Statuses', 'order-tracking' ),
448 'add_label' => __( '+ ADD', 'order-tracking' ),
449 'del_label' => __( 'Delete', 'order-tracking' ),
450 'description' => $statuses_description,
451 'fields' => array(
452 'status' => array(
453 'type' => 'text',
454 'label' => 'Status',
455 'required' => true
456 ),
457 'percentage' => array(
458 'type' => 'text',
459 'label' => '&#37; Complete',
460 'required' => false
461 ),
462 'email' => array(
463 'type' => 'select',
464 'label' => __( 'Email', 'order-tracking' ),
465 'options' => $this->email_options
466 ),
467 'internal' => array(
468 'type' => 'select',
469 'label' => __( 'Internal Status', 'order-tracking' ),
470 'options' => array(
471 'no' => __( 'No', 'order-tracking' ),
472 'yes' => __( 'Yes', 'order-tracking' ),
473 )
474 )
475 )
476 )
477 );
478
479 $sap->add_section(
480 'ewd-otp-settings',
481 array(
482 'id' => 'ewd-otp-emails-tab',
483 'title' => __( 'Emails', 'order-tracking' ),
484 'is_tab' => true,
485 'rank' => 5,
486 'tutorial_yt_id' => 'IDi__KeytMQ',
487 )
488 );
489
490 $sap->add_section(
491 'ewd-otp-settings',
492 array(
493 'id' => 'ewd-otp-emails',
494 'title' => __( 'Emails', 'order-tracking' ),
495 'tab' => 'ewd-otp-emails-tab',
496 )
497 );
498
499 $emails_description = __( 'What should be in the messages sent to users? You can put [order-name], [order-number], [order-status], [order-notes], [customer-notes] and [order-time] into the message, to include current order name, order number, order status, public order notes or the time the order was updated.', 'order-tracking' ) . '<br />';
500 $emails_description .= __( 'You can also use [tracking-link], [customer-name], [customer-number], [customer-id], [sales-rep], [sales-rep-number] or the slug of a custom field enclosed in square brackets to include those fields in the email.', 'order-tracking' );
501
502 $sap->add_setting(
503 'ewd-otp-settings',
504 'ewd-otp-emails',
505 'infinite_table',
506 array(
507 'id' => 'email-messages',
508 'title' => __( 'Email Messages', 'order-tracking' ),
509 'add_label' => __( '+ ADD', 'order-tracking' ),
510 'del_label' => __( 'Delete', 'order-tracking' ),
511 'description' => $emails_description,
512 'fields' => array(
513 'id' => array(
514 'type' => 'hidden',
515 'label' => 'ID',
516 'required' => true
517 ),
518 'name' => array(
519 'type' => 'text',
520 'label' => 'Name',
521 'required' => true
522 ),
523 'subject' => array(
524 'type' => 'text',
525 'label' => 'Subject',
526 'required' => true
527 ),
528 'message' => array(
529 'type' => 'textarea',
530 'label' => 'Message',
531 'required' => true
532 )
533 )
534 )
535 );
536
537 $sap->add_setting(
538 'ewd-otp-settings',
539 'ewd-otp-emails',
540 'text',
541 array(
542 'id' => 'admin-email',
543 'title' => __( 'Admin Email', 'order-tracking' ),
544 'description' => __( 'What email should customer note and customer order notifications be sent to, if they\'ve been set in the "Premium" area of the "Options" tab? Leave blank to use the WordPress admin email address.', 'order-tracking' ),
545 'small' => true
546 )
547 );
548
549 /**
550 * Premium options preview only
551 */
552 // "Premium" Tab
553 $sap->add_section(
554 'ewd-otp-settings',
555 array(
556 'id' => 'ewd-otp-premium-tab',
557 'title' => __( 'Premium', 'order-tracking' ),
558 'is_tab' => true,
559 'rank' => 2,
560 'tutorial_yt_id' => 'DDQO1Wkahf0',
561 'show_submit_button' => $this->show_submit_button( 'premium' )
562 )
563 );
564 $sap->add_section(
565 'ewd-otp-settings',
566 array(
567 'id' => 'ewd-otp-premium-tab-body',
568 'tab' => 'ewd-otp-premium-tab',
569 'callback' => $this->premium_info( 'premium' )
570 )
571 );
572
573 // "Locations" Tab
574 $sap->add_section(
575 'ewd-otp-settings',
576 array(
577 'id' => 'ewd-otp-locations-tab',
578 'title' => __( 'Locations', 'order-tracking' ),
579 'is_tab' => true,
580 'rank' => 4,
581 'tutorial_yt_id' => 'hptAmlqQ4G0',
582 'show_submit_button' => $this->show_submit_button( 'locations' )
583 )
584 );
585 $sap->add_section(
586 'ewd-otp-settings',
587 array(
588 'id' => 'ewd-otp-locations-tab-body',
589 'tab' => 'ewd-otp-locations-tab',
590 'callback' => $this->premium_info( 'locations' )
591 )
592 );
593
594 // "Payments" Tab
595 $sap->add_section(
596 'ewd-otp-settings',
597 array(
598 'id' => 'ewd-otp-payments-tab',
599 'title' => __( 'Payments', 'order-tracking' ),
600 'is_tab' => true,
601 'rank' => 7,
602 'tutorial_yt_id' => 'oDt9BGvVdtQ',
603 'show_submit_button' => $this->show_submit_button( 'payments' )
604 )
605 );
606 $sap->add_section(
607 'ewd-otp-settings',
608 array(
609 'id' => 'ewd-otp-payments-tab-body',
610 'tab' => 'ewd-otp-payments-tab',
611 'callback' => $this->premium_info( 'payments' )
612 )
613 );
614
615 // "WooCommerce" Tab
616 $sap->add_section(
617 'ewd-otp-settings',
618 array(
619 'id' => 'ewd-otp-woocommerce-tab',
620 'title' => __( 'WooCommerce', 'order-tracking' ),
621 'is_tab' => true,
622 'rank' => 6,
623 'tutorial_yt_id' => 'zWTGldvnnc8',
624 'show_submit_button' => $this->show_submit_button( 'woocommerce' )
625 )
626 );
627 $sap->add_section(
628 'ewd-otp-settings',
629 array(
630 'id' => 'ewd-otp-woocommerce-tab-body',
631 'tab' => 'ewd-otp-woocommerce-tab',
632 'callback' => $this->premium_info( 'woocommerce' )
633 )
634 );
635
636 // "Zendesk" Tab
637 $sap->add_section(
638 'ewd-otp-settings',
639 array(
640 'id' => 'ewd-otp-zendesk-tab',
641 'title' => __( 'Zendesk', 'order-tracking' ),
642 'is_tab' => true,
643 'rank' => 10,
644 'tutorial_yt_id' => 'r00ewZ8l0z8',
645 'show_submit_button' => $this->show_submit_button( 'zendesk' )
646 )
647 );
648 $sap->add_section(
649 'ewd-otp-settings',
650 array(
651 'id' => 'ewd-otp-zendesk-tab-body',
652 'tab' => 'ewd-otp-zendesk-tab',
653 'callback' => $this->premium_info( 'zendesk' )
654 )
655 );
656
657 // "Labelling" Tab
658 $sap->add_section(
659 'ewd-otp-settings',
660 array(
661 'id' => 'ewd-otp-labelling-tab',
662 'title' => __( 'Labelling', 'order-tracking' ),
663 'is_tab' => true,
664 'rank' => 9,
665 'tutorial_yt_id' => 'oGimPjCPTdU',
666 'show_submit_button' => $this->show_submit_button( 'labelling' )
667 )
668 );
669 $sap->add_section(
670 'ewd-otp-settings',
671 array(
672 'id' => 'ewd-otp-labelling-tab-body',
673 'tab' => 'ewd-otp-labelling-tab',
674 'callback' => $this->premium_info( 'labelling' )
675 )
676 );
677
678 // "Styling" Tab
679 $sap->add_section(
680 'ewd-otp-settings',
681 array(
682 'id' => 'ewd-otp-styling-tab',
683 'title' => __( 'Styling', 'order-tracking' ),
684 'is_tab' => true,
685 'rank' => 8,
686 'tutorial_yt_id' => 'c75VcMG11a8',
687 'show_submit_button' => $this->show_submit_button( 'styling' )
688 )
689 );
690 $sap->add_section(
691 'ewd-otp-settings',
692 array(
693 'id' => 'ewd-otp-styling-tab-body',
694 'tab' => 'ewd-otp-styling-tab',
695 'callback' => $this->premium_info( 'styling' )
696 )
697 );
698
699 $sap = apply_filters( 'ewd_otp_settings_page', $sap, $this );
700
701 $sap->add_admin_menus();
702
703 }
704
705 public function show_submit_button( $permission_type = '' ) {
706 global $ewd_otp_controller;
707
708 if ( $ewd_otp_controller->permissions->check_permission( $permission_type ) ) {
709 return true;
710 }
711
712 return false;
713 }
714
715 public function premium_info( $section_and_perm_type ) {
716 global $ewd_otp_controller;
717
718 $is_premium_user = $ewd_otp_controller->permissions->check_permission( $section_and_perm_type );
719 $is_helper_installed = defined( 'EWDPH_PLUGIN_FNAME' ) && is_plugin_active( EWDPH_PLUGIN_FNAME );
720
721 if ( $is_premium_user || $is_helper_installed ) {
722 return false;
723 }
724
725 $content = '';
726
727 $premium_features = '
728 <p><strong>' . __( 'The premium version also gives you access to the following features:', 'order-tracking' ) . '</strong></p>
729 <ul class="ewd-otp-dashboard-new-footer-one-benefits">
730 <li>' . __( 'Create & Assign Orders to Sales Reps', 'order-tracking' ) . '</li>
731 <li>' . __( 'Create & Tie Orders to Customers', 'order-tracking' ) . '</li>
732 <li>' . __( 'Custom Fields', 'order-tracking' ) . '</li>
733 <li>' . __( 'WooCommerce Order Integration', 'order-tracking' ) . '</li>
734 <li>' . __( 'Advanced Display & Styling Options', 'order-tracking' ) . '</li>
735 <li>' . __( 'Front-End Customer Order Form', 'order-tracking' ) . '</li>
736 <li>' . __( 'Import/Export Orders', 'order-tracking' ) . '</li>
737 <li>' . __( 'Set Up Status Locations', 'order-tracking' ) . '</li>
738 <li>' . __( 'Email Support', 'order-tracking' ) . '</li>
739 </ul>
740 <div class="ewd-otp-dashboard-new-footer-one-buttons">
741 <a class="ewd-otp-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=OTP&Quantity=1&utm_source=otp_settings&utm_content=' . $section_and_perm_type . '" target="_blank">' . __( 'UPGRADE NOW', 'order-tracking' ) . '</a>
742 </div>
743 ';
744
745 switch ( $section_and_perm_type ) {
746
747 case 'premium':
748
749 $content = '
750 <div class="ewd-otp-settings-preview">
751 <h2>' . __( 'Premium', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
752 <p>' . __( 'The premium options let you change the tracking graphic, configure notification emails, customize the order form and more.', 'order-tracking' ) . '</p>
753 <div class="ewd-otp-settings-preview-images">
754 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/premium1.png" alt="OTP premium screenshot one">
755 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/premium2.png" alt="OTP premium screenshot two">
756 </div>
757 ' . $premium_features . '
758 </div>
759 ';
760
761 break;
762
763 case 'locations':
764
765 $content = '
766 <div class="ewd-otp-settings-preview">
767 <h2>' . __( 'Locations', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
768 <p>' . __( 'You can create locations, which can be assigned to orders, so your customers know exactly where their orders are. You can also specify latitude and longitude coordinates for each location, allowing it to display on a map on the tracking page.', 'order-tracking' ) . '</p>
769 <div class="ewd-otp-settings-preview-images">
770 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/locations.png" alt="OTP locations screenshot">
771 </div>
772 ' . $premium_features . '
773 </div>
774 ';
775
776 break;
777
778 case 'payments':
779
780 $content = '
781 <div class="ewd-otp-settings-preview">
782 <h2>' . __( 'Payments', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
783 <p>' . __( 'The payment options let you enable and configure the ability to accept payment for orders via PayPal.', 'order-tracking' ) . '</p>
784 <div class="ewd-otp-settings-preview-images">
785 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/payments.png" alt="OTP payments screenshot">
786 </div>
787 ' . $premium_features . '
788 </div>
789 ';
790
791 break;
792
793 case 'woocommerce':
794
795 $content = '
796 <div class="ewd-otp-settings-preview">
797 <h2>' . __( 'WooCommerce', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
798 <p>' . __( 'The WooCommerce options let you enable and configure the ability to have the plugin automatically create a corresponding order every time a new order is placed on your site via WooCommerce.', 'order-tracking' ) . '</p>
799 <div class="ewd-otp-settings-preview-images">
800 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/woocommerce1.png" alt="OTP woocommerce screenshot one">
801 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/woocommerce2.png" alt="OTP woocommerce screenshot two">
802 </div>
803 ' . $premium_features . '
804 </div>
805 ';
806
807 break;
808
809 case 'zendesk':
810
811 $content = '
812 <div class="ewd-otp-settings-preview">
813 <h2>' . __( 'Sendesk', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
814 <p>' . __( 'This lets you enable Zendesk integration, so, every time you get a new ticket in Zendesk, it creates an order in the plugin.', 'order-tracking' ) . '</p>
815 <div class="ewd-otp-settings-preview-images">
816 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/zendesk.png" alt="OTP zendesk screenshot">
817 </div>
818 ' . $premium_features . '
819 </div>
820 ';
821
822 break;
823
824 case 'labelling':
825
826 $content = '
827 <div class="ewd-otp-settings-preview">
828 <h2>' . __( 'Labelling', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
829 <p>' . __( 'The labelling options let you change the wording of the different labels that appear on the front end of the plugin. You can use this to translate them, customize the wording for your purpose, etc.', 'order-tracking' ) . '</p>
830 <div class="ewd-otp-settings-preview-images">
831 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/labelling1.png" alt="OTP labelling screenshot one">
832 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/labelling2.png" alt="OTP labelling screenshot two">
833 </div>
834 ' . $premium_features . '
835 </div>
836 ';
837
838 break;
839
840 case 'styling':
841
842 $content = '
843 <div class="ewd-otp-settings-preview">
844 <h2>' . __( 'Styling', 'order-tracking' ) . '<span>' . __( 'Premium', 'order-tracking' ) . '</span></h2>
845 <p>' . __( 'The styling options let you modify the color, font size, font family, border, margin and padding of the various elements found in your tracking forms and orders.', 'order-tracking' ) . '</p>
846 <div class="ewd-otp-settings-preview-images">
847 <img src="' . EWD_OTP_PLUGIN_URL . '/assets/img/premium-screenshots/styling.png" alt="OTP styling screenshot">
848 </div>
849 ' . $premium_features . '
850 </div>
851 ';
852
853 break;
854 }
855
856 return function() use ( $content ) {
857
858 echo wp_kses_post( $content );
859 };
860 }
861
862 /**
863 * Create a set of default statuses and emails if none exist
864 * @since 3.0.0
865 */
866 public function create_default_statuses_and_emails() {
867
868 $statuses = ewd_otp_decode_infinite_table_setting( $this->get_setting( 'statuses' ) );
869
870 if ( ! empty( $statuses ) ) { return; }
871
872 $emails = array(
873 array(
874 'id' => 1,
875 'name' => __( 'Default', 'order-tracking' ),
876 'subject' => __( 'Order Status Update', 'order-tracking' ),
877 'message' => __( 'Hello [order-name], You have an update for your order [order-number]!', 'order-tracking' )
878 )
879 );
880
881 $this->set_setting( 'email-messages', json_encode( $emails ) );
882
883 $statuses = array(
884 array(
885 'status' => __( 'Pending Payment', 'order-tracking' ),
886 'percentage' => '25',
887 'email' => 1,
888 'internal' => 'no',
889 ),
890 array(
891 'status' => __( 'Processing', 'order-tracking' ),
892 'percentage' => '50',
893 'email' => 1,
894 'internal' => 'no',
895 ),
896 array(
897 'status' => __( 'On Hold', 'order-tracking' ),
898 'percentage' => '50',
899 'email' => 1,
900 'internal' => 'no',
901 ),
902 array(
903 'status' => __( 'Completed', 'order-tracking' ),
904 'percentage' => '100',
905 'email' => 1,
906 'internal' => 'no',
907 ),
908 array(
909 'status' => __( 'Cancelled', 'order-tracking' ),
910 'percentage' => '0',
911 'email' => 1,
912 'internal' => 'no',
913 ),
914 array(
915 'status' => __( 'Refunded', 'order-tracking' ),
916 'percentage' => '0',
917 'email' => 1,
918 'internal' => 'no',
919 ),
920 array(
921 'status' => __( 'Failed', 'order-tracking' ),
922 'percentage' => '0',
923 'email' => 1,
924 'internal' => 'no',
925 ),
926 );
927
928
929 $this->set_setting( 'statuses', json_encode( $statuses ) );
930
931 $this->save_settings();
932 }
933
934 /**
935 * Load all custom fields
936 * @since 3.0.0
937 */
938 public function get_custom_fields() {
939
940 $custom_fields = is_array( get_option( 'ewd-otp-custom-fields' ) ) ? get_option( 'ewd-otp-custom-fields' ) : array();
941
942 return $custom_fields;
943 }
944
945 /**
946 * Load the custom fields related to orders
947 * @since 3.0.0
948 */
949 public function get_order_custom_fields() {
950
951 $custom_fields = is_array( get_option( 'ewd-otp-custom-fields' ) ) ? get_option( 'ewd-otp-custom-fields' ) : array();
952
953 $return_fields = array();
954
955 foreach ( $custom_fields as $custom_field ){
956
957 if ( $custom_field->function == 'orders' ) { $return_fields[] = $custom_field; }
958 }
959
960 return $return_fields;
961 }
962
963 /**
964 * Load the custom fields related to customers
965 * @since 3.0.0
966 */
967 public function get_customer_custom_fields() {
968
969 $custom_fields = is_array( get_option( 'ewd-otp-custom-fields' ) ) ? get_option( 'ewd-otp-custom-fields' ) : array();
970
971 $return_fields = array();
972
973 foreach ( $custom_fields as $custom_field ){
974
975 if ( $custom_field->function == 'customers' ) { $return_fields[] = $custom_field; }
976 }
977
978 return $return_fields;
979 }
980
981 /**
982 * Load the custom fields related to sales reps
983 * @since 3.0.0
984 */
985 public function get_sales_rep_custom_fields() {
986
987 $custom_fields = is_array( get_option( 'ewd-otp-custom-fields' ) ) ? get_option( 'ewd-otp-custom-fields' ) : array();
988
989 $return_fields = array();
990
991 foreach ( $custom_fields as $custom_field ){
992
993 if ( $custom_field->function == 'sales_reps' ) { $return_fields[] = $custom_field; }
994 }
995
996 return $return_fields;
997 }
998 }
999 } // endif;
1000