PluginProbe
Orderable – Restaurant & Food Ordering System / 0.2.0
Orderable – Restaurant & Food Ordering System v0.2.0
0.1.4 0.1.5 0.2.0 1.0.0 1.1.0 1.1.1 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.19.1 1.19.2 1.2.0 1.20.0 1.20.1 All 44 releases
← All changes | inc/class-settings.php +71 -349 1.2.0 → 0.2.0 View file →
@@ -35,9 +35,8 @@
35 35 /**
36 36 * Run.
37 37 */
38 38 public static function run() {
39 - add_action( 'admin_init', array( __CLASS__, 'maybe_opt_in' ) );
40 39 add_action( 'init', array( __CLASS__, 'init_settings' ) );
41 40 add_filter( 'plugin_action_links_' . ORDERABLE_BASENAME, array( __CLASS__, 'plugin_settings_link' ) );
42 41 add_action( 'init', array( __CLASS__, 'init_onboarding' ) );
43 42 add_action( 'admin_menu', array( __CLASS__, 'add_settings_page' ), 1 );
@@ -45,9 +44,9 @@
45 44 add_filter( 'wpsf_register_settings_orderable', array( __CLASS__, 'register_settings' ) );
46 45 add_filter( 'wpsf_register_settings_orderable', array( __CLASS__, 'reorder_settings_tabs' ), 200 );
47 46 add_filter( 'iconic_onboard_save_orderable_result', array( __CLASS__, 'save_onboard_settings' ), 10, 2 );
48 47 add_filter( 'wpsf_title_orderable', array( __CLASS__, 'settings_logo' ) );
49 - add_action( 'wpsf_after_title_orderable', array( __CLASS__, 'settings_header' ) );
48 + add_action( 'wpsf_after_title_orderable', array( __CLASS__, 'version_number' ) );
50 49
51 50 // Add category fields.
52 51 add_action( 'product_cat_add_form_fields', array( __CLASS__, 'add_category_fields' ), 20 );
53 52 add_action( 'product_cat_edit_form_fields', array( __CLASS__, 'edit_category_fields' ), 20 );
@@ -52,12 +51,8 @@
52 51 add_action( 'product_cat_add_form_fields', array( __CLASS__, 'add_category_fields' ), 20 );
53 52 add_action( 'product_cat_edit_form_fields', array( __CLASS__, 'edit_category_fields' ), 20 );
54 53 add_action( 'created_term', array( __CLASS__, 'save_category_fields' ), 10, 3 );
55 54 add_action( 'edit_term', array( __CLASS__, 'save_category_fields' ), 10, 3 );
56 -
57 - // Admin Pointers.
58 - add_action( 'orderable_admin_assets_enqueued', array( __CLASS__, 'admin_pointers' ) );
59 - add_filter( 'orderable_admin_script_deps', array( __CLASS__, 'admin_script_deps' ) );
60 55 }
61 56
62 57 /**
63 58 * Init settings.
@@ -144,24 +139,8 @@
144 139 'priority' => 100,
145 140 ),
146 141 );
147 142
148 - $settings['sections']['dashboard_getting_started'] = array(
149 - 'tab_id' => 'dashboard',
150 - 'section_id' => 'getting_started',
151 - 'section_title' => __( 'Getting Started', 'orderable' ),
152 - 'section_description' => sprintf( __( 'Below you will find a playlist of useful "getting started" videos for Orderable. If you need any help getting things set up, please <a href="%s" target="_blank">reach out to our support team</a>.', 'orderable' ), 'https://my.orderable.com/support/?utm_source=orderable&utm_medium=plugin&utm_campaign=getting-started' ),
153 - 'section_order' => 0,
154 - 'fields' => array(
155 - 'playlist' => array(
156 - 'id' => 'playlist',
157 - 'title' => '',
158 - 'type' => 'custom',
159 - 'output' => wp_oembed_get( 'https://youtube.com/playlist?list=PLUUdHDDAkhAV8-k86JRjB34Xtbp1y6kXh' ),
160 - ),
161 - ),
162 - );
163 -
164 143 $settings['sections']['style'] = array(
165 144 'tab_id' => 'style',
166 145 'section_id' => 'style',
167 146 'section_title' => __( 'General', 'orderable' ),
@@ -167,9 +146,9 @@
167 146 'section_title' => __( 'General', 'orderable' ),
168 147 'section_description' => '',
169 148 'section_order' => 10,
170 149 'fields' => array(
171 - 'color' => array(
150 + 'color' => array(
172 151 'id' => 'color',
173 152 'title' => __( 'Brand Color', 'orderable' ),
174 153 'subtitle' => __( 'Select an accent color to be used for buttons and other elements.', 'orderable' ),
175 154 'type' => 'color',
@@ -195,21 +174,21 @@
195 174 'section_title' => __( 'Product Cards', 'orderable' ),
196 175 'section_description' => '',
197 176 'section_order' => 15,
198 177 'fields' => array(
199 - 'title_size' => array(
178 + 'title_size' => array(
200 179 'id' => 'title_size',
201 180 'title' => __( 'Product Title Size (px)', 'orderable' ),
202 181 'subtitle' => __( 'Set the product title font size in pixels.', 'orderable' ),
203 182 'type' => 'number',
204 - 'default' => self::get_setting_default( 'style_products_title_size' ),
183 + 'default' => Orderable_Settings::get_setting_default( 'style_products_title_size' ),
205 184 ),
206 - 'price_size' => array(
185 + 'price_size' => array(
207 186 'id' => 'price_size',
208 187 'title' => __( 'Product Price Size (px)', 'orderable' ),
209 188 'subtitle' => __( 'Set the product price font size in pixels.', 'orderable' ),
210 189 'type' => 'number',
211 - 'default' => self::get_setting_default( 'style_products_price_size' ),
190 + 'default' => Orderable_Settings::get_setting_default( 'style_products_price_size' ),
212 191 ),
213 192 ),
214 193 );
215 194
@@ -223,17 +202,14 @@
223 202 *
224 203 * @return array
225 204 */
226 205 public static function reorder_settings_tabs( $settings = array() ) {
227 - usort(
228 - $settings['tabs'],
229 - function ( $a, $b ) {
230 - $a['priority'] = empty( $a['priority'] ) ? 0 : absint( $a['priority'] );
231 - $b['priority'] = empty( $b['priority'] ) ? 0 : absint( $b['priority'] );
206 + usort( $settings['tabs'], function ( $a, $b ) {
207 + $a['priority'] = empty( $a['priority'] ) ? 0 : absint( $a['priority'] );
208 + $b['priority'] = empty( $b['priority'] ) ? 0 : absint( $b['priority'] );
232 209
233 - return $a['priority'] - $b['priority'];
234 - }
235 - );
210 + return $a['priority'] - $b['priority'];
211 + } );
236 212
237 213 return $settings;
238 214 }
239 215
@@ -295,14 +271,11 @@
295 271 if ( apply_filters( 'orderable_is_settings_page', false ) ) {
296 272 return true;
297 273 }
298 274
299 - $valid_pages = apply_filters(
300 - 'orderable_valid_admin_pages',
301 - array(
302 - self::$option_group . '-settings' . $suffix,
303 - )
304 - );
275 + $valid_pages = apply_filters( 'orderable_valid_admin_pages', array(
276 + self::$option_group . '-settings' . $suffix,
277 + ) );
305 278 $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
306 279
307 280 if ( ! in_array( $page, $valid_pages, true ) ) {
308 281 return false;
@@ -331,15 +304,15 @@
331 304 'button_text' => 'Begin <span class="dashicons dashicons-arrow-right-alt2"></span>',
332 305 'button_icon' => '',
333 306 ),
334 307 'requirements' => array(
335 - 'title' => 'Requirements',
336 - 'description' => 'Orderable requires WooCommerce for the order checkout, management, and reporting. In this step we will install WooCommerce for you. This might take a couple of minutes.',
337 - 'button_text' => 'Install &amp; Activate WooCommerce',
338 - 'wait' => 'install_plugin',
339 - 'json_data' => array(
340 - 'wait_text' => __( 'Installing...', 'orderable' ),
341 - 'plugin_data' => array(
308 + 'title' => 'Requirements',
309 + 'description' => 'Orderable requires WooCommerce for the order checkout, management, and reporting. In this step we will install WooCommerce for you. This might take a couple of minutes.',
310 + 'button_text' => 'Install &amp; Activate WooCommerce',
311 + 'wait' => 'install_plugin',
312 + 'json_data' => array(
313 + 'wait_text' => __( 'Installing...', 'orderable' ),
314 + 'plugin_data' => array(
342 315 'name' => __( 'WooCommerce', 'orderable' ),
343 316 'repo-slug' => 'woocommerce',
344 317 'file' => 'woocommerce.php',
345 318 ),
@@ -404,12 +377,12 @@
404 377 ),
405 378 ),
406 379 ),
407 380 'location' => array(
408 - "title" => "Location Info",
409 - "description" => 'Help us set up your ordering system. You can refine these details further after completing the onboarding process.',
410 - "button_text" => "Continue <span class='dashicons dashicons-arrow-right-alt2'></span>",
411 - 'fields' => array(
381 + "title" => "Location Info",
382 + "description" => 'Help us set up your ordering system. You can refine these details further after completing the onboarding process.',
383 + "button_text" => "Continue <span class='dashicons dashicons-arrow-right-alt2'></span>",
384 + 'fields' => array(
412 385 array(
413 386 'id' => 'services',
414 387 'title' => __( 'Which services do you offer?', 'orderable' ),
415 388 'desc' => '',
@@ -443,11 +416,11 @@
443 416 ),
444 417 ),
445 418 ),
446 419 'done' => array(
447 - "title" => "All Done",
448 - "description" => "Congratulations, You Did It! Orderable is ready to use on your website. You've successfully completed the setup process and all that is left for you to do is create/customize your products.",
449 - "button_text" => "Save and Finish <span class='dashicons dashicons-yes'></span>",
420 + "title" => "All Done",
421 + "description" => "Congratulations, You Did It! Orderable is ready to use on your website. You've successfully completed the setup process and all that is left for you to do is create/customize your products.",
422 + "button_text" => "Save and Finish <span class='dashicons dashicons-yes'></span>",
450 423 ),
451 424 ) );
452 425
453 426 if ( function_exists( 'WC' ) ) {
@@ -452,25 +425,12 @@
452 425
453 426 if ( function_exists( 'WC' ) ) {
454 427 unset( $slides['requirements'] );
455 428
456 - $base = wc_get_base_location();
457 - $countries_states = self::get_countries_states();
458 - $default = '';
429 + $base = wc_get_base_location();
459 430
460 - if ( isset( $base['country'] ) && isset( $countries_states[ 'country:' . $base['country'] ] ) ) {
461 - $default = 'country:' . $base['country'];
462 - }
463 -
464 - if ( isset( $base['country'] ) && isset( $base['state'] ) && isset( $countries_states[ $base['country'] ] ) ) {
465 - $state = 'state:' . $base['country'] . ':' . $base['state'];
466 - if ( isset( $countries_states[ $base['country'] ]['values'][ $state ] ) ) {
467 - $default = $state;
468 - }
469 - }
470 -
471 - $slides['business']['fields']['default_country']['choices'] = $countries_states;
472 - $slides['business']['fields']['default_country']['default'] = $default;
431 + $slides['business']['fields']['default_country']['choices'] = self::get_countries_states();
432 + $slides['business']['fields']['default_country']['default'] = implode( ':', array_filter( $base ) );
473 433 $slides['business']['fields']['address']['default'] = WC()->countries->get_base_address();
474 434 $slides['business']['fields']['address_2']['default'] = WC()->countries->get_base_address_2();
475 435 $slides['business']['fields']['city']['default'] = WC()->countries->get_base_city();
476 436 $slides['business']['fields']['postcode']['default'] = WC()->countries->get_base_postcode();
@@ -503,30 +463,36 @@
503 463 // Get existing/default settings.
504 464 $settings = get_option( 'orderable_settings', array() );
505 465
506 466 // Assign opening hours.
507 - $from = array(
508 - 'hour' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['hour'], FILTER_SANITIZE_STRING ),
509 - 'minute' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['minute'], FILTER_SANITIZE_STRING ),
510 - 'period' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['period'], FILTER_SANITIZE_STRING ),
511 - );
512 - $to = array(
513 - 'hour' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['hour'], FILTER_SANITIZE_STRING ),
514 - 'minute' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['minute'], FILTER_SANITIZE_STRING ),
515 - 'period' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['period'], FILTER_SANITIZE_STRING ),
516 - );
467 + if ( ! empty( $fields['orderable_settings']['iconic_onboard_days'] ) && is_array( $fields['orderable_settings']['iconic_onboard_days'] ) ) {
468 + $from = array(
469 + 'hour' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['hour'], FILTER_SANITIZE_STRING ),
470 + 'minute' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['minute'], FILTER_SANITIZE_STRING ),
471 + 'period' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['period'], FILTER_SANITIZE_STRING ),
472 + );
473 + $to = array(
474 + 'hour' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['hour'], FILTER_SANITIZE_STRING ),
475 + 'minute' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['minute'], FILTER_SANITIZE_STRING ),
476 + 'period' => filter_var( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['period'], FILTER_SANITIZE_STRING ),
477 + );
517 478
518 - $settings['store_general_open_hours'] = array();
479 + $settings['store_general_open_hours'] = array();
519 480
520 - $days = is_array( $fields['orderable_settings']['iconic_onboard_days'] ) ? $fields['orderable_settings']['iconic_onboard_days'] : array();
481 + foreach ( $fields['orderable_settings']['iconic_onboard_days'] as $day ) {
482 + $day = absint( $day );
521 483
522 - for ( $day = 0; $day <= 6; $day ++ ) {
523 - $settings['store_general_open_hours'][ $day ] = array(
524 - 'enabled' => in_array( (string) $day, $days, true ),
525 - 'from' => $from,
526 - 'to' => $to,
527 - 'max_orders' => '',
528 - );
484 + if ( $day < 0 || $day > 6 ) {
485 + continue;
486 + }
487 +
488 + $settings['store_general_open_hours'][ $day ] = array(
489 + 'enabled' => '1',
490 + 'from' => $from,
491 + 'to' => $to,
492 + 'max_orders' => '',
493 + );
494 + }
529 495 }
530 496
531 497 // Save Business details.
532 498 $name = isset( $fields['orderable_settings']['iconic_onboard_business_name'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_name'] ) ) : '';
@@ -534,12 +500,11 @@
534 500 $address_2 = isset( $fields['orderable_settings']['iconic_onboard_business_address_2'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_address_2'] ) ) : '';
535 501 $city = isset( $fields['orderable_settings']['iconic_onboard_business_city'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_city'] ) ) : '';
536 502 $country_state = isset( $fields['orderable_settings']['iconic_onboard_default_country'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_default_country'] ) ) : '';
537 503 $stripped_country_state = $country_state ? str_replace( array( 'country:', 'state:' ), '', $country_state ) : '';
538 - $stripped_country_state = explode( ':', $stripped_country_state )[0];
539 504 $postcode = isset( $fields['orderable_settings']['iconic_onboard_business_postcode'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_postcode'] ) ) : '';
540 505 $email = isset( $fields['orderable_settings']['iconic_onboard_business_email'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_email'] ) ) : '';
541 - $opt_in = ! empty( $fields['orderable_settings']['iconic_onboard_opt_in'] );
506 + $opt_in = isset( $fields['orderable_settings']['iconic_onboard_opt_in'] );
542 507
543 508 if ( ! empty( $name ) ) {
544 509 update_option( 'blogname', $name );
545 510 }
@@ -549,14 +514,10 @@
549 514 update_option( 'woocommerce_store_city', $city );
550 515 update_option( 'woocommerce_default_country', $stripped_country_state );
551 516 update_option( 'woocommerce_store_postcode', $postcode );
552 517 update_option( 'admin_email', $email );
518 + update_option( 'orderable_opt_in', $opt_in );
553 519
554 - // Process opt in
555 - if ( $opt_in ) {
556 - Orderable_Webhooks::subscribe( $email );
557 - }
558 -
559 520 // Restrict delivery area to country/state.
560 521 if ( ! empty( $stripped_country_state ) ) {
561 522 update_option( 'woocommerce_allowed_countries', 'specific' );
562 523 update_option( 'woocommerce_specific_allowed_countries', array( $stripped_country_state ) );
@@ -682,31 +643,21 @@
682 643 ob_start();
683 644 ?>
684 645 <div class="iconic-onboard-modal-setting__field-section">
685 646 <div style="margin: 0 0 8px;"><?php _e( 'From:', 'orderable' ); ?></div>
686 - <?php
687 - echo Orderable_Timings_Settings::get_time_field(
688 - 'orderable_settings[iconic_onboard_open_hours][from]',
689 - array(
690 - 'hour' => 9,
691 - 'minute' => '00',
692 - 'period' => 'AM',
693 - )
694 - );
695 - ?>
647 + <?php echo Orderable_Timings_Settings::get_time_field( 'orderable_settings[iconic_onboard_open_hours][from]', array(
648 + 'hour' => 9,
649 + 'minute' => '00',
650 + 'period' => 'AM',
651 + ) ); ?>
696 652 </div>
697 653 <div class="iconic-onboard-modal-setting__field-section">
698 654 <div style="margin: 0 0 8px;"><?php _e( 'To:', 'orderable' ); ?></div>
699 - <?php
700 - echo Orderable_Timings_Settings::get_time_field(
701 - 'orderable_settings[iconic_onboard_open_hours][to]',
702 - array(
703 - 'hour' => 5,
704 - 'minute' => '00',
705 - 'period' => 'PM',
706 - )
707 - );
708 - ?>
655 + <?php echo Orderable_Timings_Settings::get_time_field( 'orderable_settings[iconic_onboard_open_hours][to]', array(
656 + 'hour' => 5,
657 + 'minute' => '00',
658 + 'period' => 'PM',
659 + ) ); ?>
709 660 </div>
710 661 <?php
711 662
712 663 return ob_get_clean();
@@ -823,239 +774,10 @@
823 774 return sprintf( '<img src="%s" width="164" height="36" />', esc_url( ORDERABLE_ASSETS_URL . 'img/orderable-logo.svg' ) );
824 775 }
825 776
826 777 /**
827 - * Help buttons and version number
778 + * Add version number to settings page.
828 779 */
829 - public static function settings_header() {
830 - ?>
831 - <style>
832 - .wpsf-settings__header {
833 - justify-content: space-between;
834 - }
835 -
836 - .orderable-settings-header {
837 - display: flex;
838 - align-items: center;
839 - }
840 -
841 - .orderable-settings-header__links {
842 - margin: 0 10px 0 0;
843 - padding: 0;
844 - list-style: none none outside;
845 - height: 20px;
846 - }
847 -
848 - .orderable-settings-header__links li {
849 - margin: 0 10px 0 0;
850 - padding: 0;
851 - display: inline-block;
852 - }
853 -
854 - .orderable-settings-header__links a {
855 - text-decoration: none;
856 - color: #64707B !important;
857 - white-space: nowrap;
858 - display: flex;
859 - align-items: center;
860 - }
861 -
862 - .orderable-settings-header__links a:hover {
863 - color: #7031F5 !important;
864 - }
865 -
866 - .orderable-settings-header__links a svg {
867 - fill: #7031F5;
868 - margin-right: 4px;
869 - }
870 -
871 - @media screen and (max-width: 648px) {
872 - .orderable-settings-header__links {
873 - display: none;
874 - }
875 - }
876 - </style>
877 - <div class="orderable-settings-header">
878 - <ul class="orderable-settings-header__links">
879 - <li><a href="https://my.orderable.com/support/?utm_source=orderable&utm_medium=plugin&utm_campaign=settings-header" target="_blank">
880 - <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20px" height="20px">
881 - <path d="M 12 2 C 6.4889971 2 2 6.4889971 2 12 C 2 17.511003 6.4889971 22 12 22 C 17.511003 22 22 17.511003 22 12 C 22 6.4889971 17.511003 2 12 2 z M 12 4 C 16.430123 4 20 7.5698774 20 12 C 20 16.430123 16.430123 20 12 20 C 7.5698774 20 4 16.430123 4 12 C 4 7.5698774 7.5698774 4 12 4 z M 12 6 C 9.79 6 8 7.79 8 10 L 10 10 C 10 8.9 10.9 8 12 8 C 13.1 8 14 8.9 14 10 C 14 12 11 12.367 11 15 L 13 15 C 13 13.349 16 12.5 16 10 C 16 7.79 14.21 6 12 6 z M 11 16 L 11 18 L 13 18 L 13 16 L 11 16 z" />
882 - </svg> <?php _e( 'Get Help', 'orderable' ); ?></a></li>
883 - <li><a href="https://my.orderable.com/roadmap/?utm_source=orderable&utm_medium=plugin&utm_campaign=settings-header" target="_blank">
884 - <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20px" height="20px">
885 - <path d="M 11 0 L 11 3 L 13 3 L 13 0 L 11 0 z M 4.2226562 2.8085938 L 2.8085938 4.2226562 L 4.9296875 6.34375 L 6.34375 4.9296875 L 4.2226562 2.8085938 z M 19.777344 2.8085938 L 17.65625 4.9296875 L 19.070312 6.34375 L 21.191406 4.2226562 L 19.777344 2.8085938 z M 12 5 C 8.1456661 5 5 8.1456661 5 12 C 5 14.767788 6.6561188 17.102239 9 18.234375 L 9 21 C 9 22.093063 9.9069372 23 11 23 L 13 23 C 14.093063 23 15 22.093063 15 21 L 15 18.234375 C 17.343881 17.102239 19 14.767788 19 12 C 19 8.1456661 15.854334 5 12 5 z M 12 7 C 14.773666 7 17 9.2263339 17 12 C 17 14.184344 15.605334 16.022854 13.666016 16.708984 L 13 16.943359 L 13 21 L 11 21 L 11 16.943359 L 10.333984 16.708984 C 8.3946664 16.022854 7 14.184344 7 12 C 7 9.2263339 9.2263339 7 12 7 z M 0 11 L 0 13 L 3 13 L 3 11 L 0 11 z M 21 11 L 21 13 L 24 13 L 24 11 L 21 11 z M 4.9296875 17.65625 L 2.8085938 19.777344 L 4.2226562 21.191406 L 6.34375 19.070312 L 4.9296875 17.65625 z M 19.070312 17.65625 L 17.65625 19.070312 L 19.777344 21.191406 L 21.191406 19.777344 L 19.070312 17.65625 z" />
886 - </svg> <?php _e( 'Request Feature', 'orderable' ); ?></a></li>
887 - <li><a href="https://orderable.com/documentation/?utm_source=orderable&utm_medium=plugin&utm_campaign=settings-header" target="_blank">
888 - <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20px" height="20px">
889 - <path d="M 6 2 C 4.895 2 4 2.895 4 4 L 4 20 C 4 21.105 4.895 22 6 22 L 18 22 C 19.105 22 20 21.105 20 20 L 20 4 C 20 2.895 19.105 2 18 2 L 14 2 L 8 2 L 6 2 z M 6 4 L 8 4 L 8 12 L 11 10.5 L 14 12 L 14 4 L 18 4 L 18 20 L 6 20 L 6 4 z M 10 4 L 12 4 L 12 8.7636719 L 11.894531 8.7109375 L 11 8.2636719 L 10.105469 8.7109375 L 10 8.7636719 L 10 4 z" />
890 - </svg> <?php _e( 'View Docs', 'orderable' ); ?></a></li>
891 - </ul>
892 - <?php printf( '<span class="orderable-settings-header__version" style="margin: 0 0 0 auto; background: #f4f5f6; display: inline-block; padding: 0 10px; border-radius: 13px; height: 26px; line-height: 26px; white-space: nowrap; box-sizing: border-box; color: #65707b;">v%s</span>', ORDERABLE_VERSION ); ?>
893 - </div>
894 - <?php
895 - }
896 -
897 - /**
898 - * Add pointers.
899 - */
900 - public static function admin_pointers() {
901 - $screen_id = self::screen_has_pointers();
902 -
903 - if ( ! $screen_id ) {
904 - return;
905 - }
906 -
907 - $pointers = array();
908 -
909 - if ( $screen_id === 'orderable_page_orderable-settings' ) {
910 - $pointers['orderable-store-settings'] = array(
911 - 'target' => '.wpsf-nav a[href="#tab-store"]',
912 - 'next' => 'orderable-layout-builder',
913 - 'options' => array(
914 - 'content' => '<h3>' . esc_html__( 'Set Up Your Store', 'orderable' ) . '</h3>' .
915 - '<p>' .
916 - esc_html__( "Use the Store Settings tab to configure your store's opening hours, delivery/pickup schedule, and holidays.", 'orderable' ) .
917 - ' <a href="https://orderable.com/getting-started?utm_source=orderable&utm_medium=plugin&utm_campaign=pointer" target="_blank">' . esc_html__( 'Learn more' ) . '</a>.' .
918 - '</p>',
919 - 'position' => array(
920 - 'edge' => 'top',
921 - 'align' => 'left',
922 - ),
923 - ),
924 - );
925 -
926 - $pointers['orderable-layout-builder'] = array(
927 - 'target' => '#toplevel_page_orderable a[href="edit.php?post_type=orderable_layouts"]',
928 - 'next' => 'orderable-order-view',
929 - 'options' => array(
930 - 'content' => '<h3>' . esc_html__( 'Layout Builder', 'orderable' ) . '</h3>' .
931 - '<p>' .
932 - esc_html__( 'Use the Layout Builder to create a product list based on category. Embed your layout using the shortcode or block.', 'orderable' ) .
933 - ' <a href="https://orderable.com/layout-builder?utm_source=orderable&utm_medium=plugin&utm_campaign=pointer" target="_blank">' . esc_html__( 'Learn more' ) . '</a>.' .
934 - '</p>',
935 - 'position' => array(
936 - 'edge' => 'left',
937 - 'align' => 'left',
938 - ),
939 - ),
940 - );
941 -
942 - $pointers['orderable-order-view'] = array(
943 - 'target' => '#toplevel_page_orderable a[href="edit.php?post_type=shop_order&orderable_live_view"]',
944 - 'next' => 'orderable-addons',
945 - 'options' => array(
946 - 'content' => '<h3>' . esc_html__( 'Live Order View', 'orderable' ) . '</h3>' .
947 - '<p>' .
948 - esc_html__( 'Use the Live Order View to get notified and manage orders in real time.', 'orderable' ) .
949 - ' <a href="https://orderable.com/process-orders?utm_source=orderable&utm_medium=plugin&utm_campaign=pointer" target="_blank">' . esc_html__( 'Learn more' ) . '</a>.' .
950 - '</p>',
951 - 'position' => array(
952 - 'edge' => 'left',
953 - 'align' => 'left',
954 - ),
955 - ),
956 - );
957 -
958 - $pointers['orderable-addons'] = array(
959 - 'target' => '#toplevel_page_orderable a[href="admin.php?page=orderable-product-addons"]',
960 - 'options' => array(
961 - 'content' => '<h3>' . esc_html__( 'Product Addons', 'orderable' ) . '</h3>' .
962 - '<p>' .
963 - esc_html__( 'Create product options which can be conditionally applied to the products in your store.', 'orderable' ) .
964 - ' <a href="https://orderable.com/product-addons?utm_source=orderable&utm_medium=plugin&utm_campaign=pointer" target="_blank">' . esc_html__( 'Learn more' ) . '</a>.' .
965 - '</p>',
966 - 'position' => array(
967 - 'edge' => 'left',
968 - 'align' => 'left',
969 - ),
970 - ),
971 - );
972 - }
973 -
974 - $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
975 - $valid_pointers = array();
976 -
977 - if ( in_array( 'orderable-tour-dismissed', $dismissed ) ) {
978 - return;
979 - }
980 -
981 - // Check pointers and remove dismissed ones.
982 - foreach ( $pointers as $pointer_id => $pointer ) {
983 - // Sanity check
984 - if ( in_array( $pointer_id, $dismissed ) ) {
985 - continue;
986 - }
987 -
988 - // Add the pointer to $valid_pointers array
989 - $valid_pointers[ $pointer_id ] = $pointer;
990 - }
991 -
992 - if ( empty( $valid_pointers ) ) {
993 - return;
994 - }
995 -
996 - // Add pointers style to queue.
997 - wp_enqueue_style( 'wp-pointer' );
998 -
999 - // Add pointer options to script.
1000 - wp_localize_script(
1001 - 'orderable',
1002 - 'orderable_pointers',
1003 - array(
1004 - 'pointers' => $valid_pointers,
1005 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
1006 - 'i18n' => array(
1007 - 'close' => esc_html__( 'Close', 'orderable' ),
1008 - 'next' => esc_html__( 'Next', 'orderable' ),
1009 - 'skip' => esc_html__( 'Skip', 'orderable' ),
1010 - ),
1011 - )
1012 - );
1013 - }
1014 -
1015 - /**
1016 - * Add script deps for admin scripts.
1017 - *
1018 - * @param array $deps
1019 - *
1020 - * @return array
1021 - */
1022 - public static function admin_script_deps( $deps = array() ) {
1023 - if ( ! self::screen_has_pointers() ) {
1024 - return $deps;
1025 - }
1026 -
1027 - $deps[] = 'wp-pointer';
1028 -
1029 - return $deps;
1030 - }
1031 -
1032 - /**
1033 - * Does this screen have pointers?
1034 - *
1035 - * If screen has pointers, return the screen ID. Otherwise false.
1036 - *
1037 - * @return bool|string
1038 - */
1039 - public static function screen_has_pointers() {
1040 - $screen = get_current_screen();
1041 - $screen_id = $screen->id;
1042 -
1043 - $pointers = array( 'orderable_page_orderable-settings' );
1044 -
1045 - return in_array( $screen_id, $pointers, true ) ? $screen_id : false;
1046 - }
1047 -
1048 - /**
1049 - * Maybe opt in based on previous setting.
1050 - */
1051 - public static function maybe_opt_in() {
1052 - $opt_in = get_option( 'orderable_opt_in' );
1053 -
1054 - // Opt in is only stored in the database if opting in failed.
1055 - if ( ! $opt_in ) {
1056 - return;
1057 - }
1058 -
1059 - Orderable_Webhooks::subscribe();
780 + public static function version_number() {
781 + printf( '<span style="margin: 0 0 0 auto; background: #f4f5f6; display: inline-block; padding: 0 10px; border-radius: 13px; height: 26px; line-height: 26px; white-space: nowrap; box-sizing: border-box; color: #65707b;">v%s</span>', ORDERABLE_VERSION );
1060 782 }
1061 783 }