1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace WC_POS\Admin;
13
14 use WC_POS\Template;
15
16 class Settings extends Page {
17
18
19 public $wc_pos_adminpage = 'admin_settings';
20
21 22 23
24 static public $handlers = array(
25 'general' => '\WC_POS\Admin\Settings\General',
26 'customers' => '\WC_POS\Admin\Settings\Customers',
27 'checkout' => '\WC_POS\Admin\Settings\Checkout',
28 'receipts' => '\WC_POS\Admin\Settings\Receipts',
29 'hotkeys' => '\WC_POS\Admin\Settings\HotKeys',
30 'access' => '\WC_POS\Admin\Settings\Access'
31 );
32
33 34 35
36 public function admin_menu() {
37 $this->screen_id = add_submenu_page(
38 \WC_POS\PLUGIN_NAME,
39
40 __( 'Settings' ),
41
42 __( 'Settings' ),
43 'manage_woocommerce_pos',
44 'wc_pos_settings',
45 array( $this, 'display_settings_page' )
46 );
47
48 parent::admin_menu();
49 }
50
51 52 53
54 public function display_settings_page() {
55 include 'views/settings.php';
56 }
57
58 59 60 61
62 static public function handlers(){
63 return apply_filters( 'woocommerce_pos_admin_settings_handlers', self::$handlers );
64 }
65
66 67 68
69 public function enqueue_admin_scripts() {
70 global $wp_scripts;
71 $wp_scripts->queue = array();
72
73
74 wp_deregister_script( 'jquery' );
75 wp_deregister_script( 'underscore' );
76 wp_deregister_script( 'select2' );
77 wp_deregister_script( 'backbone' );
78
79
80 $external_libs = Template::get_external_js_libraries();
81 wp_register_script( 'jquery', $external_libs[ 'jquery' ], false, null, true );
82 wp_register_script( 'lodash', $external_libs[ 'lodash' ], array( 'jquery' ), null, true );
83 wp_register_script( 'backbone', $external_libs[ 'backbone' ], array( 'jquery', 'lodash' ), null, true );
84 wp_register_script( 'backbone.radio', $external_libs[ 'radio' ], array( 'jquery', 'backbone', 'lodash' ), null, true );
85 wp_register_script( 'marionette', $external_libs[ 'marionette' ], array( 'jquery', 'backbone', 'lodash' ), null, true );
86 wp_register_script( 'handlebars', $external_libs[ 'handlebars' ], false, null, true );
87 wp_register_script( 'moment', $external_libs[ 'moment' ], false, null, true );
88 wp_register_script( 'accounting', $external_libs[ 'accounting' ], false, null, true );
89 wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.min.js', array( 'jquery' ), null, true );
90 wp_register_script( 'ace', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.2/ace.js', false, null, true );
91
92 $build = defined( '\SCRIPT_DEBUG' ) && \SCRIPT_DEBUG ? 'build' : 'min';
93
94 wp_enqueue_script(
95 \WC_POS\PLUGIN_NAME . '-admin-settings-app',
96 \WC_POS\PLUGIN_URL . 'assets/js/admin-settings.' . $build . '.js',
97 array( 'backbone', 'backbone.radio', 'marionette', 'handlebars', 'accounting', 'moment', 'select2', 'ace' ),
98 \WC_POS\VERSION,
99 true
100 );
101
102 $scripts = apply_filters( 'woocommerce_pos_admin_enqueue_scripts', array() );
103 if ( isset( $scripts[ 'locale' ] ) ) {
104 wp_enqueue_script(
105 \WC_POS\PLUGIN_NAME . '-js-locale',
106 $scripts[ 'locale' ],
107 array( \WC_POS\PLUGIN_NAME . '-admin-settings-app' ),
108 \WC_POS\VERSION,
109 true
110 );
111 }
112 }
113
114 }