PluginProbe
Orderable – Restaurant & Food Ordering System / 1.20.1
Orderable – Restaurant & Food Ordering System v1.20.1
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
orderable / inc / class-settings.php

class-settings.php in Orderable – Restaurant & Food Ordering System 1.20.1, at inc/class-settings.php

1,138 lines 40.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Settings methods.
4 *
5 * @package Orderable/Classes
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 /**
11 * Settings class.
12 */
13 class Orderable_Settings {
14 /**
15 * Settings framework instance.
16 *
17 * @var null|Orderable_Settings_Framework
18 */
19 public static $settings_framework = null;
20
21 /**
22 * Settings.
23 *
24 * @var array
25 */
26 public static $settings = array();
27
28 /**
29 * Option group.
30 *
31 * @var string
32 */
33 protected static $option_group = 'orderable';
34
35 /**
36 * Run.
37 */
38 public static function run() {
39 add_action( 'admin_init', array( __CLASS__, 'maybe_opt_in' ) );
40 add_action( 'init', array( __CLASS__, 'init_settings' ) );
41 add_filter( 'plugin_action_links_' . ORDERABLE_BASENAME, array( __CLASS__, 'plugin_settings_link' ) );
42 add_action( 'init', array( __CLASS__, 'init_onboarding' ) );
43 add_action( 'admin_menu', array( __CLASS__, 'add_settings_page' ), 1 );
44 add_filter( 'orderable_default_settings', array( __CLASS__, 'default_settings' ) );
45 add_filter( 'wpsf_register_settings_orderable', array( __CLASS__, 'register_settings' ) );
46 add_filter( 'wpsf_register_settings_orderable', array( __CLASS__, 'reorder_settings_tabs' ), 200 );
47 add_filter( 'iconic_onboard_save_orderable_result', array( __CLASS__, 'save_onboard_settings' ), 10, 2 );
48 add_filter( 'wpsf_title_orderable', array( __CLASS__, 'settings_logo' ) );
49 add_action( 'wpsf_after_title_orderable', array( __CLASS__, 'settings_header' ) );
50 add_action( 'wpsf_after_tab_links_orderable', array( __CLASS__, 'add_sidebar' ) );
51 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
52
53 // Add category fields.
54 add_action( 'product_cat_add_form_fields', array( __CLASS__, 'add_category_fields' ), 20 );
55 add_action( 'product_cat_edit_form_fields', array( __CLASS__, 'edit_category_fields' ), 20 );
56 add_action( 'created_term', array( __CLASS__, 'save_category_fields' ), 10, 3 );
57 add_action( 'edit_term', array( __CLASS__, 'save_category_fields' ), 10, 3 );
58
59 // Admin Pointers.
60 add_action( 'orderable_admin_assets_enqueued', array( __CLASS__, 'admin_pointers' ) );
61 add_filter( 'orderable_admin_script_deps', array( __CLASS__, 'admin_script_deps' ) );
62 }
63
64 /**
65 * Init settings.
66 */
67 public static function init_settings() {
68 require_once ORDERABLE_VENDOR_PATH . 'wp-settings-framework/wp-settings-framework.php';
69 require_once ORDERABLE_VENDOR_PATH . 'iconic-core/class-core-settings.php';
70 require_once ORDERABLE_VENDOR_PATH . 'iconic-core/class-core-cross-sells.php';
71
72 self::$settings_framework = new Orderable_Settings_Framework( null, self::$option_group );
73 self::$settings = self::$settings_framework->get_settings();
74 }
75
76 /**
77 * Add settings page link to plugin listing.
78 *
79 * @param array $links
80 *
81 * @return array
82 */
83 public static function plugin_settings_link( $links = array() ) {
84 $settings_url = admin_url( 'admin.php?page=orderable-settings' );
85 $links[] = sprintf( '<a href="%s">%s</a>', esc_url( $settings_url ), esc_html( __( 'Settings', 'orderable' ) ) );
86
87 return $links;
88 }
89
90 /**
91 * Add settings page.
92 */
93 public static function add_settings_page() {
94 $icon = self::get_orderable_svg_icon();
95
96 add_menu_page( 'Orderable', 'Orderable', 'manage_options', 'orderable', null, $icon, 54 );
97
98 self::$settings_framework->add_settings_page(
99 array(
100 'parent_slug' => 'orderable',
101 'page_title' => __( 'Orderable Settings', 'orderable' ),
102 'menu_title' => __( 'Settings', 'orderable' ),
103 'capability' => 'manage_options',
104 )
105 );
106
107 remove_submenu_page( 'orderable', 'orderable' );
108 }
109
110 /**
111 * Add default settings.
112 *
113 * @param array $default_settings
114 *
115 * @return array
116 */
117 public static function default_settings( $default_settings = array() ) {
118 $default_settings['style_style_color'] = '#000000';
119 $default_settings['style_style_buttons'] = 'rounded';
120 $default_settings['style_products_title_size'] = 20;
121 $default_settings['style_products_price_size'] = 18;
122
123 return $default_settings;
124 }
125
126 /**
127 * Register settings.
128 *
129 * @param array $settings
130 *
131 * @return array
132 */
133 public static function register_settings( $settings = array() ) {
134 $settings = array(
135 'tabs' => array(),
136 'sections' => array(),
137 );
138
139 $settings['tabs'] = array(
140 array(
141 'id' => 'dashboard',
142 'title' => __( 'Dashboard', 'orderable' ),
143 'priority' => 0,
144 ),
145 array(
146 'id' => 'style',
147 'title' => __( 'Style', 'orderable' ),
148 'priority' => 100,
149 ),
150 );
151
152 $settings['sections']['dashboard_getting_started'] = array(
153 'tab_id' => 'dashboard',
154 'section_id' => 'getting_started',
155 'section_title' => __( 'Getting Started', 'orderable' ),
156 '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' ),
157 'section_order' => 0,
158 'fields' => array(
159 'playlist' => array(
160 'id' => 'playlist',
161 'title' => '',
162 'type' => 'custom',
163 'output' => wp_oembed_get( 'https://youtube.com/playlist?list=PLUUdHDDAkhAV8-k86JRjB34Xtbp1y6kXh' ),
164 ),
165 ),
166 );
167
168 $settings['sections']['style'] = array(
169 'tab_id' => 'style',
170 'section_id' => 'style',
171 'section_title' => __( 'General', 'orderable' ),
172 'section_description' => '',
173 'section_order' => 10,
174 'fields' => array(
175 'color' => array(
176 'id' => 'color',
177 'title' => __( 'Brand Color', 'orderable' ),
178 'subtitle' => __( 'Select an accent color to be used for buttons and other elements.', 'orderable' ),
179 'type' => 'color',
180 'default' => self::get_setting_default( 'style_style_color' ),
181 ),
182 'buttons' => array(
183 'id' => 'buttons',
184 'title' => __( 'Button Style', 'orderable' ),
185 'subtitle' => __( 'Choose a button style which suits your theme.', 'orderable' ),
186 'type' => 'select',
187 'default' => self::get_setting_default( 'style_style_buttons' ),
188 'choices' => array(
189 'rounded' => __( 'Rounded', 'orderable' ),
190 'square' => __( 'Square', 'orderable' ),
191 ),
192 ),
193 ),
194 );
195
196 $settings['sections']['products_style'] = array(
197 'tab_id' => 'style',
198 'section_id' => 'products',
199 'section_title' => __( 'Product Cards', 'orderable' ),
200 'section_description' => '',
201 'section_order' => 15,
202 'fields' => array(
203 'title_size' => array(
204 'id' => 'title_size',
205 'title' => __( 'Product Title Size (px)', 'orderable' ),
206 'subtitle' => __( 'Set the product title font size in pixels.', 'orderable' ),
207 'type' => 'number',
208 'default' => self::get_setting_default( 'style_products_title_size' ),
209 ),
210 'price_size' => array(
211 'id' => 'price_size',
212 'title' => __( 'Product Price Size (px)', 'orderable' ),
213 'subtitle' => __( 'Set the product price font size in pixels.', 'orderable' ),
214 'type' => 'number',
215 'default' => self::get_setting_default( 'style_products_price_size' ),
216 ),
217 ),
218 );
219
220 return $settings;
221 }
222
223 /**
224 * Reorder settings tabs.
225 *
226 * @param array $settings
227 *
228 * @return array
229 */
230 public static function reorder_settings_tabs( $settings = array() ) {
231 usort(
232 $settings['tabs'],
233 function ( $a, $b ) {
234 $a['priority'] = empty( $a['priority'] ) ? 0 : absint( $a['priority'] );
235 $b['priority'] = empty( $b['priority'] ) ? 0 : absint( $b['priority'] );
236
237 return $a['priority'] - $b['priority'];
238 }
239 );
240
241 return $settings;
242 }
243
244 /**
245 * Get setting default.
246 *
247 * @param string $setting_name
248 *
249 * @return bool|mixed
250 */
251 public static function get_setting_default( $setting_name = '' ) {
252 if ( empty( $setting_name ) ) {
253 return false;
254 }
255
256 $defaults = apply_filters( 'orderable_default_settings', array() );
257
258 if ( ! isset( $defaults[ $setting_name ] ) ) {
259 return false;
260 }
261
262 return $defaults[ $setting_name ];
263 }
264
265 /**
266 * Get setting.
267 *
268 * This method is accessible before the settings are assign to self::$settings.
269 *
270 * @param string $setting_name
271 *
272 * @return bool|mixed
273 */
274 public static function get_setting( $setting_name = '' ) {
275 if ( empty( $setting_name ) ) {
276 return false;
277 }
278
279 /**
280 * Filter the orderable settings.
281 *
282 * @since 1.8.0
283 * @hook orderable_settings
284 * @param false|array $settings The orderable settings.
285 * @param string $setting_name The setting name to be retrieved.
286 * @return false|array New value
287 */
288 $settings = apply_filters( 'orderable_settings', false, $setting_name );
289
290 if ( isset( $settings[ $setting_name ] ) ) {
291 return $settings[ $setting_name ];
292 }
293
294 $settings = get_option( self::$option_group . '_settings' );
295
296 if ( isset( $settings[ $setting_name ] ) ) {
297 return $settings[ $setting_name ];
298 }
299
300 return self::get_setting_default( $setting_name );
301 }
302
303 /**
304 * @param string $suffix
305 *
306 * @return bool
307 */
308 public static function is_settings_page( $suffix = '' ) {
309 if ( ! is_admin() ) {
310 return false;
311 }
312
313 // Allow bypass from other modules.
314 if ( apply_filters( 'orderable_is_settings_page', false ) ) {
315 return true;
316 }
317
318 $valid_pages = apply_filters(
319 'orderable_valid_admin_pages',
320 array(
321 self::$option_group . '-settings' . $suffix,
322 )
323 );
324 $page = empty( $_GET['page'] ) ? '' : sanitize_text_field( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
325
326 if ( ! in_array( $page, $valid_pages, true ) ) {
327 return false;
328 }
329
330 return true;
331 }
332
333 /**
334 * Init onboarding.
335 */
336 public static function init_onboarding() {
337 if ( ! self::is_settings_page() || defined( 'WC_DOING_AJAX' ) ) {
338 if ( empty( $_REQUEST['plugin_slug'] ) || 'orderable' !== $_REQUEST['plugin_slug'] ) {
339 return;
340 }
341 }
342
343 include_once ORDERABLE_INC_PATH . 'vendor/iconic-onboard/class-iconic-onboard.php';
344
345 $slides = apply_filters(
346 'orderable_onboarding_slides',
347 array(
348 'welcome' => array(
349 'header_image' => ORDERABLE_URL . '/assets/img/onboarding/orderable-onboarding-header.jpg',
350 'title' => 'Welcome',
351 'description' => 'Thank you for choosing Orderable to add local ordering to your website. This short setup wizard will guide you though configuring Orderable.',
352 'button_text' => 'Begin <span class="dashicons dashicons-arrow-right-alt2"></span>',
353 'button_icon' => '',
354 ),
355 'requirements' => array(
356 'title' => 'Requirements',
357 '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.',
358 'button_text' => 'Install &amp; Activate WooCommerce',
359 'wait' => 'install_plugin',
360 'json_data' => array(
361 'wait_text' => __( 'Installing...', 'orderable' ),
362 'plugin_data' => array(
363 'name' => __( 'WooCommerce', 'orderable' ),
364 'repo-slug' => 'woocommerce',
365 'file' => 'woocommerce.php',
366 ),
367 ),
368 ),
369 'business' => array(
370 'title' => 'Business Info',
371 'description' => 'Orderable needs some basic business information that will be used when orders are placed.',
372 'button_text' => 'Continue <span class="dashicons dashicons-arrow-right-alt2"></span>',
373 'fields' => array(
374 'name' => array(
375 'id' => 'business_name',
376 'title' => __( 'Business Name', 'orderable' ),
377 'desc' => '',
378 'type' => 'text',
379 'default' => get_bloginfo( 'name' ),
380 ),
381 'address' => array(
382 'id' => 'business_address',
383 'title' => __( 'Address line 1', 'orderable' ),
384 'desc' => '',
385 'type' => 'text',
386 ),
387 'address_2' => array(
388 'id' => 'business_address_2',
389 'title' => __( 'Address line 2', 'orderable' ),
390 'desc' => '',
391 'type' => 'text',
392 ),
393 'city' => array(
394 'id' => 'business_city',
395 'title' => __( 'City', 'orderable' ),
396 'desc' => '',
397 'type' => 'text',
398 ),
399 'default_country' => array(
400 'id' => 'default_country',
401 'title' => __( 'Country / State', 'orderable' ),
402 'desc' => '',
403 'type' => 'select',
404 'choices' => array(),
405 ),
406 'postcode' => array(
407 'id' => 'business_postcode',
408 'title' => __( 'Postcode / ZIP', 'orderable' ),
409 'desc' => '',
410 'type' => 'text',
411 ),
412 'email' => array(
413 'id' => 'business_email',
414 'title' => __( 'Business Email', 'orderable' ),
415 'desc' => '',
416 'type' => 'text',
417 'default' => get_option( 'admin_email' ),
418 ),
419 array(
420 'id' => 'opt_in',
421 'title' => '',
422 'desc' => __( 'Please keep me up to date via email on new Orderable training and features', 'orderable' ),
423 'type' => 'checkbox',
424 'default' => 1,
425 ),
426 ),
427 ),
428 'location' => array(
429 'title' => 'Location Info',
430 'description' => 'Help us set up your ordering system. You can refine these details further after completing the onboarding process.',
431 'button_text' => "Continue <span class='dashicons dashicons-arrow-right-alt2'></span>",
432 'fields' => array(
433 array(
434 'id' => 'services',
435 'title' => __( 'Which services do you offer?', 'orderable' ),
436 'desc' => '',
437 'type' => 'checkboxes',
438 'choices' => array(
439 'flat_rate' => __( 'Delivery', 'orderable' ),
440 'local_pickup' => __( 'Pickup', 'orderable' ),
441 ),
442 ),
443 array(
444 'id' => 'days',
445 'title' => __( 'Which days of the week are you open?', 'orderable' ),
446 'desc' => '',
447 'type' => 'checkboxes',
448 'choices' => array(
449 1 => __( 'Monday', 'orderable' ),
450 2 => __( 'Tuesday', 'orderable' ),
451 3 => __( 'Wednesday', 'orderable' ),
452 4 => __( 'Thursday', 'orderable' ),
453 5 => __( 'Friday', 'orderable' ),
454 6 => __( 'Saturday', 'orderable' ),
455 0 => __( 'Sunday', 'orderable' ),
456 ),
457 ),
458 array(
459 'id' => 'open_hours',
460 'title' => __( 'What are your normal opening hours?', 'orderable' ),
461 'desc' => '',
462 'type' => 'custom',
463 'default' => self::get_open_hours_fields(),
464 ),
465 ),
466 ),
467 'done' => array(
468 'title' => 'All Done',
469 '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.",
470 'button_text' => "Save and Finish <span class='dashicons dashicons-yes'></span>",
471 ),
472 )
473 );
474
475 if ( function_exists( 'WC' ) ) {
476 unset( $slides['requirements'] );
477
478 $base = wc_get_base_location();
479 $countries_states = self::get_countries_states();
480 $default = '';
481
482 if ( isset( $base['country'] ) && isset( $countries_states[ 'country:' . $base['country'] ] ) ) {
483 $default = 'country:' . $base['country'];
484 }
485
486 if ( isset( $base['country'] ) && isset( $base['state'] ) && isset( $countries_states[ $base['country'] ] ) ) {
487 $state = 'state:' . $base['country'] . ':' . $base['state'];
488 if ( isset( $countries_states[ $base['country'] ]['values'][ $state ] ) ) {
489 $default = $state;
490 }
491 }
492
493 $slides['business']['fields']['default_country']['choices'] = $countries_states;
494 $slides['business']['fields']['default_country']['default'] = $default;
495 $slides['business']['fields']['address']['default'] = WC()->countries->get_base_address();
496 $slides['business']['fields']['address_2']['default'] = WC()->countries->get_base_address_2();
497 $slides['business']['fields']['city']['default'] = WC()->countries->get_base_city();
498 $slides['business']['fields']['postcode']['default'] = WC()->countries->get_base_postcode();
499 }
500
501 Orderable_Onboard::run(
502 array(
503 'version' => ORDERABLE_VERSION,
504 'plugin_slug' => 'orderable',
505 'plugin_url' => ORDERABLE_URL,
506 'plugin_path' => ORDERABLE_PATH,
507 'slides' => $slides,
508 )
509 );
510 }
511
512 /**
513 * Save the onboarding data in database.
514 *
515 * @param array $result Was the submission a success?
516 * @param array $fields Submitted fields.
517 *
518 * @return bool|array $result
519 */
520 public static function save_onboard_settings( $result, $fields ) {
521 if ( empty( $fields['orderable_settings'] ) ) {
522 return false;
523 }
524
525 // Get existing/default settings.
526 $settings = get_option( 'orderable_settings', array() );
527
528 // Assign opening hours.
529 $from = array(
530 'hour' => sanitize_text_field( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['hour'] ),
531 'minute' => sanitize_text_field( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['minute'] ),
532 'period' => sanitize_text_field( $fields['orderable_settings']['iconic_onboard_open_hours']['from']['period'] ),
533 );
534 $to = array(
535 'hour' => sanitize_text_field( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['hour'] ),
536 'minute' => sanitize_text_field( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['minute'] ),
537 'period' => sanitize_text_field( $fields['orderable_settings']['iconic_onboard_open_hours']['to']['period'] ),
538 );
539
540 $settings['store_general_open_hours'] = array();
541
542 $days = is_array( $fields['orderable_settings']['iconic_onboard_days'] ) ? $fields['orderable_settings']['iconic_onboard_days'] : array();
543
544 for ( $day = 0; $day <= 6; $day ++ ) {
545 $settings['store_general_open_hours'][ $day ] = array(
546 'enabled' => in_array( (string) $day, $days, true ),
547 'from' => $from,
548 'to' => $to,
549 'max_orders' => '',
550 );
551 }
552
553 // Save Business details.
554 $name = isset( $fields['orderable_settings']['iconic_onboard_business_name'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_name'] ) ) : '';
555 $address = isset( $fields['orderable_settings']['iconic_onboard_business_address'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_address'] ) ) : '';
556 $address_2 = isset( $fields['orderable_settings']['iconic_onboard_business_address_2'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_address_2'] ) ) : '';
557 $city = isset( $fields['orderable_settings']['iconic_onboard_business_city'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_city'] ) ) : '';
558 $country_state = isset( $fields['orderable_settings']['iconic_onboard_default_country'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_default_country'] ) ) : '';
559 $stripped_country_state = $country_state ? str_replace( array( 'country:', 'state:' ), '', $country_state ) : '';
560 $stripped_country_state = explode( ':', $stripped_country_state )[0];
561 $postcode = isset( $fields['orderable_settings']['iconic_onboard_business_postcode'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_postcode'] ) ) : '';
562 $email = isset( $fields['orderable_settings']['iconic_onboard_business_email'] ) ? wc_clean( wp_unslash( $fields['orderable_settings']['iconic_onboard_business_email'] ) ) : '';
563 $opt_in = ! empty( $fields['orderable_settings']['iconic_onboard_opt_in'] );
564
565 if ( ! empty( $name ) ) {
566 update_option( 'blogname', $name );
567 }
568
569 update_option( 'woocommerce_store_address', $address );
570 update_option( 'woocommerce_store_address_2', $address_2 );
571 update_option( 'woocommerce_store_city', $city );
572 update_option( 'woocommerce_default_country', $stripped_country_state );
573 update_option( 'woocommerce_store_postcode', $postcode );
574 update_option( 'admin_email', $email );
575
576 // Process opt in
577 if ( $opt_in ) {
578 Orderable_Webhooks::subscribe( $email );
579 }
580
581 // Restrict delivery area to country/state.
582 if ( ! empty( $stripped_country_state ) ) {
583 update_option( 'woocommerce_allowed_countries', 'specific' );
584 update_option( 'woocommerce_specific_allowed_countries', array( $stripped_country_state ) );
585 }
586
587 // Save store services.
588 if ( ! empty( $fields['orderable_settings']['iconic_onboard_services'] ) ) {
589 $settings['store_general_services'] = array();
590
591 $existing_zone_id = null;
592 $zone_name = __( 'Local', 'orderable' );
593 $zones = WC_Shipping_Zones::get_zones();
594
595 if ( ! empty( $zones ) ) {
596 foreach ( $zones as $zone ) {
597 if ( $zone_name !== $zone['zone_name'] ) {
598 continue;
599 }
600
601 $existing_zone_id = $zone['id'];
602 $shipping_method_instances = ! empty( $zone['shipping_methods'] ) ? array_keys( $zone['shipping_methods'] ) : false;
603 break;
604 }
605 }
606
607 $zone = new WC_Shipping_Zone( $existing_zone_id );
608 $zone->set_zone_name( $zone_name );
609
610 if ( ! empty( $country_state ) ) {
611 $zone->clear_locations();
612 $location_parts = explode( ':', $country_state );
613
614 switch ( $location_parts[0] ) {
615 case 'state':
616 $zone->add_location( $location_parts[1] . ':' . $location_parts[2], 'state' );
617 break;
618 case 'country':
619 $zone->add_location( $location_parts[1], 'country' );
620 break;
621 case 'continent':
622 $zone->add_location( $location_parts[1], 'continent' );
623 break;
624 }
625 }
626
627 if ( ! empty( $shipping_method_instances ) ) {
628 foreach ( $shipping_method_instances as $shipping_method_instance_id ) {
629 $zone->delete_shipping_method( $shipping_method_instance_id );
630 }
631 }
632
633 $service_types = array(
634 'flat_rate' => 'delivery',
635 'local_pickup' => 'pickup',
636 );
637
638 foreach ( $fields['orderable_settings']['iconic_onboard_services'] as $service ) {
639 $service = wc_clean( $service );
640 $zone->add_shipping_method( $service );
641
642 $settings['store_general_services'][] = $service_types[ $service ];
643 }
644
645 $zone->save();
646 }
647
648 // Misc.
649 $settings['store_general_service_hours_pickup_same'] = 1;
650
651 // Save settings.
652 update_option( 'orderable_settings', $settings );
653
654 /**
655 * Action hook for when the onboard settings are saved.
656 *
657 * @param array $fields The settings.
658 */
659 do_action( 'orderable_onboard_settings_saved', $fields );
660
661 // Return success.
662 return $result;
663 }
664
665 /**
666 * Get countries and states for select field.
667 *
668 * @return array
669 */
670 public static function get_countries_states() {
671 $countries_states = array();
672
673 if ( ! function_exists( 'WC' ) ) {
674 return $countries_states;
675 }
676
677 $countries = WC()->countries->get_countries();
678
679 if ( empty( $countries ) ) {
680 return $countries_states;
681 }
682
683 foreach ( $countries as $key => $value ) {
684 $countries_states[ 'country:' . $key ] = $value;
685 $states = WC()->countries->get_states( $key );
686
687 if ( empty( $states ) ) {
688 continue;
689 }
690
691 $countries_states[ $key ] = array(
692 'group_label' => $value,
693 'values' => array(),
694 );
695
696 foreach ( $states as $state_key => $state_value ) {
697 $state_key = sprintf( 'state:%s:%s', $key, $state_key );
698 $countries_states[ $key ]['values'][ $state_key ] = sprintf( '%s &mdash; %s', $value, $state_value );
699 }
700 }
701
702 return $countries_states;
703 }
704
705 /**
706 * Get open hours fields.
707 *
708 * @return string
709 */
710 public static function get_open_hours_fields() {
711 ob_start();
712 ?>
713 <div class="iconic-onboard-modal-setting__field-section">
714 <div style="margin: 0 0 8px;"><?php _e( 'From:', 'orderable' ); ?></div>
715 <?php
716 echo Orderable_Timings_Settings::get_time_field(
717 'orderable_settings[iconic_onboard_open_hours][from]',
718 array(
719 'hour' => 9,
720 'minute' => '00',
721 'period' => 'AM',
722 )
723 );
724 ?>
725 </div>
726 <div class="iconic-onboard-modal-setting__field-section">
727 <div style="margin: 0 0 8px;"><?php _e( 'To:', 'orderable' ); ?></div>
728 <?php
729 echo Orderable_Timings_Settings::get_time_field(
730 'orderable_settings[iconic_onboard_open_hours][to]',
731 array(
732 'hour' => 5,
733 'minute' => '00',
734 'period' => 'PM',
735 )
736 );
737 ?>
738 </div>
739 <?php
740
741 return ob_get_clean();
742 }
743
744 /**
745 * Category fields.
746 */
747 public static function add_category_fields() {
748 ?>
749 <div class="form-field term-display-type-wrap">
750 <label for="visibility"><?php esc_html_e( 'Visibility', 'orderable' ); ?></label>
751 <select id="visibility" name="visibility" class="postform">
752 <option value=""><?php esc_html_e( 'Default', 'orderable' ); ?></option>
753 <option value="hidden"><?php esc_html_e( 'Hidden', 'orderable' ); ?></option>
754 </select>
755 <p><?php _e( 'Choose whether to hide (on the frontend) this category archive and all single product pages within this category. Hiding them is recommended if using this category in the Orderable menu shortcode.', 'orderable' ); ?></p>
756 </div>
757 <?php
758 }
759
760 /**
761 * Edit category fields.
762 *
763 * @param mixed $term Term (category) being edited.
764 */
765 public static function edit_category_fields( $term ) {
766 $visibility = get_term_meta( $term->term_id, 'visibility', true );
767 ?>
768 <tr class="form-field term-display-type-wrap">
769 <th scope="row" valign="top">
770 <label for="visibility"><?php esc_html_e( 'Visibility', 'orderable' ); ?></label>
771 </th>
772 <td>
773 <select id="visibility" name="visibility" class="postform">
774 <option value="" <?php selected( '', $visibility ); ?>><?php esc_html_e( 'Default', 'orderable' ); ?></option>
775 <option value="hidden" <?php selected( 'hidden', $visibility ); ?>><?php esc_html_e( 'Hidden', 'orderable' ); ?></option>
776 </select>
777 <p><?php _e( 'Choose whether to hide (on the frontend) this category archive and all single product pages within this category. Hiding them is recommended if using this category in the Orderable menu shortcode.', 'orderable' ); ?></p>
778 </td>
779 </tr>
780 <?php
781 }
782
783 /**
784 * Save category fields.
785 *
786 * @param mixed $term_id Term ID being saved.
787 * @param mixed $tt_id Term taxonomy ID.
788 * @param string $taxonomy Taxonomy slug.
789 */
790 public static function save_category_fields( $term_id, $tt_id = '', $taxonomy = '' ) {
791 if ( 'product_cat' !== $taxonomy ) {
792 return;
793 }
794
795 $visibility = isset( $_POST['visibility'] ) ? sanitize_text_field( wp_unslash( $_POST['visibility'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
796
797 update_term_meta( $term_id, 'visibility', $visibility );
798 }
799
800 /**
801 * Get hidden category IDs.
802 *
803 * @return array
804 */
805 public static function get_hidden_categories() {
806 global $wpdb;
807
808 static $hidden_categories = null;
809
810 if ( ! is_null( $hidden_categories ) ) {
811 return apply_filters( 'orderable_hidden_categories', $hidden_categories );
812 }
813
814 $hidden_categories = array();
815
816 $results = $wpdb->get_results(
817 "SELECT DISTINCT tm.term_id
818 FROM $wpdb->term_taxonomy AS tt
819 INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id
820 INNER JOIN $wpdb->termmeta AS tm ON t.term_id = tm.term_id
821 WHERE tt.taxonomy = 'product_cat'
822 AND tm.meta_key = 'visibility'
823 AND tm.meta_value IN ( 'hidden' )
824
825 UNION DISTINCT
826
827 SELECT DISTINCT term_id
828 FROM $wpdb->term_taxonomy
829 WHERE parent IN (
830 SELECT DISTINCT tm.term_id
831 FROM $wpdb->term_taxonomy AS tt
832 INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id
833 INNER JOIN $wpdb->termmeta AS tm ON t.term_id = tm.term_id
834 WHERE tt.taxonomy = 'product_cat'
835 AND tm.meta_key = 'visibility'
836 AND tm.meta_value IN ( 'hidden' )
837 )",
838 ARRAY_A
839 );
840
841 if ( is_wp_error( $results ) || empty( $results ) ) {
842 return apply_filters( 'orderable_hidden_categories', $hidden_categories );
843 }
844
845 $hidden_categories = array_map( 'absint', wp_list_pluck( $results, 'term_id' ) );
846
847 return apply_filters( 'orderable_hidden_categories', $hidden_categories );
848 }
849
850 /**
851 * Add logo to settings page.
852 */
853 public static function settings_logo( $title = '' ) {
854 return sprintf( '<img src="%s" width="164" height="36" />', esc_url( ORDERABLE_ASSETS_URL . 'img/orderable-logo.svg' ) );
855 }
856
857 /**
858 * Help buttons and version number
859 */
860 public static function settings_header() {
861 ?>
862 <style>
863 .wpsf-settings__header {
864 justify-content: space-between;
865 }
866
867 .orderable-settings-header {
868 display: flex;
869 align-items: center;
870 }
871
872 .orderable-settings-header__links {
873 margin: 0 10px 0 0;
874 padding: 0;
875 list-style: none none outside;
876 height: 20px;
877 }
878
879 .orderable-settings-header__links li {
880 margin: 0 10px 0 0;
881 padding: 0;
882 display: inline-block;
883 }
884
885 .orderable-settings-header__links a {
886 text-decoration: none;
887 color: #64707B !important;
888 white-space: nowrap;
889 display: flex;
890 align-items: center;
891 }
892
893 .orderable-settings-header__links a:hover {
894 color: #7031F5 !important;
895 }
896
897 .orderable-settings-header__links a svg {
898 fill: #7031F5;
899 margin-right: 4px;
900 }
901
902 @media screen and (max-width: 648px) {
903 .orderable-settings-header__links {
904 display: none;
905 }
906 }
907 </style>
908 <div class="orderable-settings-header">
909 <ul class="orderable-settings-header__links">
910 <li><a href="https://my.orderable.com/support/?utm_source=orderable&utm_medium=plugin&utm_campaign=settings-header" target="_blank">
911 <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20px" height="20px">
912 <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" />
913 </svg> <?php _e( 'Get Help', 'orderable' ); ?></a></li>
914 <li><a href="https://my.orderable.com/roadmap/?utm_source=orderable&utm_medium=plugin&utm_campaign=settings-header" target="_blank">
915 <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20px" height="20px">
916 <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" />
917 </svg> <?php _e( 'Request Feature', 'orderable' ); ?></a></li>
918 <li><a href="https://orderable.com/documentation/?utm_source=orderable&utm_medium=plugin&utm_campaign=settings-header" target="_blank">
919 <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20px" height="20px">
920 <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" />
921 </svg> <?php _e( 'View Docs', 'orderable' ); ?></a></li>
922 </ul>
923 <?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 ); ?>
924 </div>
925 <?php
926 }
927
928 /**
929 * Add pointers.
930 */
931 public static function admin_pointers() {
932 $screen_id = self::screen_has_pointers();
933
934 if ( ! $screen_id ) {
935 return;
936 }
937
938 $pointers = array();
939
940 if ( $screen_id === 'orderable_page_orderable-settings' ) {
941 $pointers['orderable-store-settings'] = array(
942 'target' => '#toplevel_page_orderable a[href="admin.php?page=orderable-location"]',
943 'next' => 'orderable-layout-builder',
944 'options' => array(
945 'content' => '<h3>' . esc_html__( 'Set Up Your Location', 'orderable' ) . '</h3>' .
946 '<p>' .
947 esc_html__( "Configure your location's opening hours, delivery/pickup schedule, and holidays.", 'orderable' ) .
948 ' <a href="https://orderable.com/getting-started?utm_source=orderable&utm_medium=plugin&utm_campaign=pointer" target="_blank">' . esc_html__( 'Learn more' ) . '</a>.' .
949 '</p>',
950 'position' => array(
951 'edge' => 'left',
952 'align' => 'left',
953 ),
954 ),
955 );
956
957 $pointers['orderable-layout-builder'] = array(
958 'target' => '#toplevel_page_orderable a[href="edit.php?post_type=orderable_layouts"]',
959 'next' => 'orderable-order-view',
960 'options' => array(
961 'content' => '<h3>' . esc_html__( 'Product Layouts', 'orderable' ) . '</h3>' .
962 '<p>' .
963 esc_html__( 'Use the Layout Builder to create a product list based on category. Embed your layout using the shortcode or block.', 'orderable' ) .
964 ' <a href="https://orderable.com/layout-builder?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 $pointers['orderable-order-view'] = array(
974 'target' => '#toplevel_page_orderable a[href="edit.php?post_type=shop_order&orderable_live_view"]',
975 'options' => array(
976 'content' => '<h3>' . esc_html__( 'Live Order View', 'orderable' ) . '</h3>' .
977 '<p>' .
978 esc_html__( 'Use the Live Order View to get notified and manage orders in real time.', 'orderable' ) .
979 ' <a href="https://orderable.com/process-orders?utm_source=orderable&utm_medium=plugin&utm_campaign=pointer" target="_blank">' . esc_html__( 'Learn more' ) . '</a>.' .
980 '</p>',
981 'position' => array(
982 'edge' => 'left',
983 'align' => 'left',
984 ),
985 ),
986 );
987 }
988
989 $pointers = apply_filters( 'orderable_pointers', $pointers );
990
991 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
992 $valid_pointers = array();
993
994 if ( in_array( 'orderable-tour-dismissed', $dismissed ) ) {
995 return;
996 }
997
998 // Check pointers and remove dismissed ones.
999 foreach ( $pointers as $pointer_id => $pointer ) {
1000 // Sanity check
1001 if ( in_array( $pointer_id, $dismissed ) ) {
1002 continue;
1003 }
1004
1005 // Add the pointer to $valid_pointers array
1006 $valid_pointers[ $pointer_id ] = $pointer;
1007 }
1008
1009 if ( empty( $valid_pointers ) ) {
1010 return;
1011 }
1012
1013 // Add pointers style to queue.
1014 wp_enqueue_style( 'wp-pointer' );
1015
1016 // Add pointer options to script.
1017 wp_localize_script(
1018 'orderable',
1019 'orderable_pointers',
1020 array(
1021 'pointers' => $valid_pointers,
1022 'ajax_url' => admin_url( 'admin-ajax.php' ),
1023 'i18n' => array(
1024 'close' => esc_html__( 'Close', 'orderable' ),
1025 'next' => esc_html__( 'Next', 'orderable' ),
1026 'skip' => esc_html__( 'Skip', 'orderable' ),
1027 ),
1028 )
1029 );
1030 }
1031
1032 /**
1033 * Add script deps for admin scripts.
1034 *
1035 * @param array $deps
1036 *
1037 * @return array
1038 */
1039 public static function admin_script_deps( $deps = array() ) {
1040 if ( ! self::screen_has_pointers() ) {
1041 return $deps;
1042 }
1043
1044 $deps[] = 'wp-pointer';
1045
1046 return $deps;
1047 }
1048
1049 /**
1050 * Does this screen have pointers?
1051 *
1052 * If screen has pointers, return the screen ID. Otherwise false.
1053 *
1054 * @return bool|string
1055 */
1056 public static function screen_has_pointers() {
1057 $screen = get_current_screen();
1058 $screen_id = $screen->id;
1059
1060 $pointers = array( 'orderable_page_orderable-settings' );
1061
1062 return in_array( $screen_id, $pointers, true ) ? $screen_id : false;
1063 }
1064
1065 /**
1066 * Maybe opt in based on previous setting.
1067 */
1068 public static function maybe_opt_in() {
1069 $opt_in = get_option( 'orderable_opt_in' );
1070
1071 // Opt in is only stored in the database if opting in failed.
1072 if ( ! $opt_in ) {
1073 return;
1074 }
1075
1076 Orderable_Webhooks::subscribe();
1077 }
1078
1079 /**
1080 * Universal upgrade page content.
1081 *
1082 * @param string $feature Feature name.
1083 */
1084 public static function upgrade_page_content( $feature = '' ) {
1085 $utm_campaign = str_replace( ' ', '-', strtolower( $feature ) );
1086 include ORDERABLE_TEMPLATES_PATH . 'admin/orderable-pro-page.php';
1087 }
1088
1089 /**
1090 * Get SVG icon of the Orderable logo.
1091 *
1092 * @return string
1093 */
1094 public static function get_orderable_svg_icon() {
1095 return 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQ0IiBoZWlnaHQ9IjE4MyIgdmlld0JveD0iMCAwIDI0NCAxODMiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+DQo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTE5MC40NzggMTY2LjdDMjI3LjM2MiAxNDIuNzEgMjUzLjI3MSA5MS44NDM4IDI0MC44NTYgNTYuMzA5NUMyMjguNDQyIDIwLjk1NTcgMTc3LjUyMyAwLjkzMzgzNSAxMjMuNzI3IDAuMDMxOTUxNEM3MC4xMDk3IC0wLjg2OTkzMyAxMy42MTQgMTcuMzQ4MSAyLjI3ODkxIDUxLjI1OUMtOS4yMzYxMyA4NS4xNjk4IDI0LjU4OTMgMTM0Ljk1NCA2NS40MzE3IDE2MS4yODlDMTA2LjA5NCAxODcuNjI0IDE1My43NzQgMTkwLjY5IDE5MC40NzggMTY2LjdaTTE4My4yMzQgNzguNzIwNkMxODMuMjM0IDgzLjkyNDEgMTc4LjEwOCA5MS42Mjg3IDE2Ny4zNDggOTEuNjI4N0MxNTYuNTg4IDkxLjYyODcgMTUxLjQ2MyA4My45MjQxIDE1MS40NjMgNzguNzIwNkMxNTEuNDYzIDczLjUxNzIgMTU2LjU4OCA2NS44MTI2IDE2Ny4zNDggNjUuODEyNkMxNzguMTA4IDY1LjgxMjYgMTgzLjIzNCA3My41MTcyIDE4My4yMzQgNzguNzIwNlpNMTY5LjExOCAxMjQuNjk3QzE5NS4zNDkgMTIzLjgyMiAyMTYuMzI4IDEwMy41NzIgMjE2LjMyOCA3OC43MjA2QzIxNi4zMjggNTMuMzEyNCAxOTQuMzk5IDMyLjcxNSAxNjcuMzQ4IDMyLjcxNUMxNjcuMjU3IDMyLjcxNSAxNjcuMTY3IDMyLjcxNTMgMTY3LjA3NiAzMi43MTU3SDg2LjczNUM4MS42NjMgMzIuNzE1NyA3Ny41NTEyIDM2LjgzNTIgNzcuNTUxMiA0MS45MTY4Qzc3LjU1MTIgNDYuOTk4NSA4MS42NjMgNTEuMTE4IDg2LjczNSA1MS4xMThIMTI4LjE2TDEyOC4xNDQgNTEuMTM3MUMxMzIuOTQyIDUxLjQ1MTEgMTM2LjczNiA1NS40NDE3IDEzNi43MzYgNjAuMzE4M0MxMzYuNzM2IDY1LjQgMTMyLjYxNiA2OS41MTk1IDEyNy41MzQgNjkuNTE5NUgxMTkuMzQ4TDExOS4zNDggNjkuNTIwMkg1My4wNjExQzQ3Ljk4OTEgNjkuNTIwMiA0My44NzczIDczLjYzOTcgNDMuODc3MyA3OC43MjEzQzQzLjg3NzMgODMuODAyOSA0Ny45ODkxIDg3LjkyMjQgNTMuMDYxMSA4Ny45MjI0SDEyNy42NTJDMTMyLjY4IDg3Ljk4NTQgMTM2LjczNiA5Mi4wODA0IDEzNi43MzYgOTcuMTIyOEMxMzYuNzM2IDEwMiAxMzIuOTQyIDEwNS45OSAxMjguMTQ0IDEwNi4zMDRMMTI4LjE2MSAxMDYuMzI1SDc0LjQ5QzY5LjQxNzkgMTA2LjMyNSA2NS4zMDYyIDExMC40NDQgNjUuMzA2MiAxMTUuNTI2QzY1LjMwNjIgMTIwLjYwNyA2OS40MTc5IDEyNC43MjcgNzQuNDkgMTI0LjcyN0gxNjguMzY5QzE2OC42MjEgMTI0LjcyNyAxNjguODcxIDEyNC43MTcgMTY5LjExOCAxMjQuNjk3Wk0xNTAuODY0IDEzNy41NDVDMTUyLjA2NSAxNDEuMTE4IDE0OS41NTggMTQ2LjIzMyAxNDUuOTg4IDE0OC42NDZDMTQyLjQzNSAxNTEuMDU4IDEzNy44MjEgMTUwLjc1IDEzMy44ODUgMTQ4LjEwMkMxMjkuOTMyIDE0NS40NTQgMTI2LjY1OSAxNDAuNDQ3IDEyNy43NzMgMTM3LjAzN0MxMjguODcgMTMzLjYyNyAxMzQuMzM4IDEzMS43OTUgMTM5LjUyNyAxMzEuODg2QzE0NC43MzQgMTMxLjk3NyAxNDkuNjYyIDEzMy45OSAxNTAuODY0IDEzNy41NDVaTTE2MS42NzYgMTM3LjU0NUMxNjAuNDc0IDE0MS4xMTggMTYyLjk4MiAxNDYuMjMzIDE2Ni41NTIgMTQ4LjY0NkMxNzAuMTA0IDE1MS4wNTggMTc0LjcxOSAxNTAuNzUgMTc4LjY1NCAxNDguMTAyQzE4Mi42MDcgMTQ1LjQ1NCAxODUuODgxIDE0MC40NDcgMTg0Ljc2NiAxMzcuMDM3QzE4My42NjkgMTMzLjYyNyAxNzguMjAyIDEzMS43OTUgMTczLjAxMiAxMzEuODg2QzE2Ny44MDYgMTMxLjk3NyAxNjIuODc3IDEzMy45OSAxNjEuNjc2IDEzNy41NDVaIiBmaWxsPSIjOUNBMUE4Ii8+DQo8L3N2Zz4=';
1096 }
1097
1098 /**
1099 * Add sidebar
1100 *
1101 * @return void
1102 */
1103 public static function add_sidebar() {
1104 if ( self::is_orderable_pro_activated() || ! self::is_settings_page() ) {
1105 return;
1106 }
1107
1108 Orderable_Core_Settings::$args['account_link'] = 'https://my.orderable.com';
1109 Orderable_Core_Settings::$args['utm_source'] = 'Orderable';
1110
1111 add_filter( 'orderable_skip_core_cross_sells_selected_plugins', '__return_true' );
1112
1113 Orderable_Core_Settings::add_sidebar();
1114 }
1115
1116 /**
1117 * Enqueue scripts
1118 *
1119 * @return void
1120 */
1121 public static function enqueue_scripts() {
1122 if ( self::is_orderable_pro_activated() || ! self::is_settings_page() ) {
1123 return;
1124 }
1125
1126 wp_enqueue_style( 'wp-block-library' );
1127 }
1128
1129 /**
1130 * Check if Orderable Pro is activated
1131 *
1132 * @return boolean
1133 */
1134 protected static function is_orderable_pro_activated() {
1135 return defined( 'ORDERABLE_PRO_VERSION' );
1136 }
1137 }
1138