PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.7.2
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.7.2
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / includes / class-scripts.php

class-scripts.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.7.2, at includes/class-scripts.php

210 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WeDevs\ERP;
4
5 use WeDevs\ERP\Framework\Traits\Hooker;
6
7 /**
8 * Scripts and styles
9 */
10 class Scripts {
11
12 /*
13 * Hooks
14 */
15 use Hooker;
16
17 /**
18 * Script and style suffix
19 *
20 * @var string
21 */
22 protected $suffix;
23
24 /**
25 * Script version number
26 *
27 * @var int
28 */
29 protected $version;
30
31 /**
32 * Initialize the class
33 */
34 public function __construct() {
35 $this->suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
36 $this->version = WPERP_VERSION;
37
38 $this->action( 'admin_enqueue_scripts', 'scripts_handler' );
39 }
40
41 /**
42 * Register and enqueue scripts and styles
43 *
44 * @return void
45 */
46 public function scripts_handler() {
47 $this->register_scripts();
48 $this->register_styles();
49
50 $this->enqueue_scripts();
51 $this->enqueue_styles();
52 }
53
54 public function register_scripts() {
55
56 // wp_register_script( $handle, $src, $deps, $ver, $in_footer );
57 $vendor = WPERP_ASSETS . '/vendor';
58 $js = WPERP_ASSETS . '/js';
59
60 // register vendors first
61 wp_register_script( 'erp-select2', $vendor . '/select2/select2.full.min.js', [ 'jquery' ], $this->version, true );
62 wp_register_script( 'erp-tiptip', $vendor . '/tiptip/jquery.tipTip.min.js', [ 'jquery' ], $this->version, true );
63 wp_register_script( 'erp-momentjs', $vendor . '/moment/moment.min.js', false, $this->version, true );
64 wp_register_script( 'erp-fullcalendar', $vendor . '/fullcalendar/fullcalendar' . $this->suffix . '.js', [ 'jquery', 'erp-momentjs' ], $this->version, true );
65 wp_register_script( 'erp-timepicker', $vendor . '/timepicker/jquery.timepicker.min.js', [ 'jquery', 'erp-momentjs' ], $this->version, true );
66 wp_register_script( 'erp-vuejs', $vendor . '/vue/vue' . $this->suffix . '.js', [ 'jquery' ], $this->version, true );
67 wp_register_script( 'erp-trix-editor', $vendor . '/trix/trix.js', [ 'jquery' ], $this->version, true );
68 wp_register_script( 'erp-nprogress', $vendor . '/nprogress/nprogress.js', [ 'jquery' ], $this->version, true );
69 wp_register_script( 'erp-jvectormap', $vendor . '/jvectormap/jvectormap.min.js', [ 'jquery' ], $this->version, true );
70 wp_register_script( 'erp-jvectormap-world-mill', $vendor . '/jvectormap/jvectormap-world-mill.js', [ 'jquery' ], $this->version, true );
71
72 // sweet alert
73 wp_register_script( 'erp-sweetalert', $vendor . '/sweetalert/sweetalert.min.js', [ 'jquery' ], $this->version, true );
74
75 // Are you sure? JS
76 wp_register_script( 'erp-are-you-sure', $vendor . '/are-you-sure/jquery.are-you-sure.js', [ 'jquery' ], $this->version, true );
77
78 // flot chart
79 wp_register_script( 'erp-flotchart', $vendor . '/flot/jquery.flot.min.js', [ 'jquery' ], $this->version, true );
80 wp_register_script( 'erp-flotchart-time', $vendor . '/flot/jquery.flot.time.min.js', [ 'jquery' ], $this->version, true );
81 wp_register_script( 'erp-flotchart-orerbars', $vendor . '/flot/jquery.flot.orderBars.js', [ 'jquery' ], $this->version, true );
82 wp_register_script( 'erp-flotchart-pie', $vendor . '/flot/jquery.flot.pie.min.js', [ 'jquery' ], $this->version, true );
83 wp_register_script( 'erp-flotchart-axislables', $vendor . '/flot/jquery.flot.axislabels.js', [ 'jquery' ], $this->version, true );
84 wp_register_script( 'erp-flotchart-categories', $vendor . '/flot/jquery.flot.categories.js', [ 'jquery' ], $this->version, true );
85 wp_register_script( 'erp-flotchart-tooltip', $vendor . '/flot/jquery.flot.tooltip.min.js', [ 'jquery' ], $this->version, true );
86 wp_register_script( 'erp-flotchart-resize', $vendor . '/flot/jquery.flot.resize.min.js', [ 'jquery' ], $this->version, true );
87 wp_register_script( 'erp-flotchart-valuelabel', $vendor . '/flot/jquery.flot.valuelabels.js', [ 'jquery' ], $this->version, true );
88 wp_register_script( 'erp-flotchart-navigate', $vendor . '/flot/jquery.flot.navigate.js', [ 'jquery' ], $this->version, true );
89 wp_register_script( 'erp-flotchart-selection', $vendor . '/flot/jquery.flot.selection.js', [ 'jquery' ], $this->version, true );
90 wp_register_script( 'erp-flotchart-stack', $vendor . '/flot/jquery.flot.stack.js', [ 'jquery' ], $this->version, true );
91
92 // core js files
93 wp_register_script( 'erp-popup', $js . '/jquery-popup' . $this->suffix . '.js', [ 'jquery' ], $this->version, true );
94 wp_register_script( 'erp-script', $js . '/erp' . $this->suffix . '.js', [ 'jquery', 'backbone', 'underscore', 'wp-util', 'jquery-ui-datepicker' ], $this->version, true );
95 wp_register_script( 'erp-file-upload', $js . '/upload' . $this->suffix . '.js', [ 'jquery', 'plupload-handlers' ], $this->version, true );
96 wp_register_script( 'erp-admin-settings', $js . '/settings' . $this->suffix . '.js', [ 'jquery' ], $this->version, true );
97 wp_register_script( 'erp-system-status', $js . '/system-status' . $this->suffix . '.js', [ 'jquery' ], $this->version, true );
98
99 // tether.js
100 wp_register_script( 'erp-tether-main', $vendor . '/tether/tether.min.js', [ 'jquery' ], $this->version, true );
101 wp_register_script( 'erp-tether-drop', $vendor . '/tether/drop.min.js', [ 'jquery' ], $this->version, true );
102
103 // clipboard.js
104 wp_register_script( 'erp-clipboard', $vendor . '/clipboard/clipboard.min.js', [ 'jquery' ], $this->version, true );
105
106 // toastr.js
107 wp_register_script( 'erp-toastr', $vendor . '/toastr/toastr.min.js', [], $this->version, true );
108 }
109
110 /**
111 * Register all the styles
112 *
113 * @return void
114 */
115 public function register_styles() {
116 $vendor = WPERP_ASSETS . '/vendor';
117 $css = WPERP_ASSETS . '/css';
118
119 wp_register_style( 'erp-fontawesome', $vendor . '/fontawesome/font-awesome.min.css', false, $this->version );
120 wp_register_style( 'erp-select2', $vendor . '/select2/select2.min.css', false, $this->version );
121 wp_register_style( 'erp-tiptip', $vendor . '/tiptip/tipTip.css', false, $this->version );
122 wp_register_style( 'erp-fullcalendar', $vendor . '/fullcalendar/fullcalendar' . $this->suffix . '.css', false, $this->version );
123 wp_register_style( 'erp-timepicker', $vendor . '/timepicker/jquery.timepicker.css', false, $this->version );
124 wp_register_style( 'erp-trix-editor', $vendor . '/trix/trix.css', false, $this->version );
125 wp_register_style( 'erp-flotchart-valuelabel-css', $vendor . '/flot/plot.css', false, $this->version );
126 wp_register_style( 'erp-nprogress', $vendor . '/nprogress/nprogress.css', false, $this->version );
127 wp_register_style( 'erp-jvectormap', $vendor . '/jvectormap/jvectormap.css', false, $this->version );
128
129 // jquery UI
130 wp_register_style( 'jquery-ui', $vendor . '/jquery-ui/jquery-ui-1.9.1.custom.css' );
131
132 // sweet alert
133 wp_register_style( 'erp-sweetalert', $vendor . '/sweetalert/sweetalert.css', false, $this->version );
134
135 // tether drop theme
136 wp_register_style( 'erp-tether-drop-theme', $vendor . '/tether/drop-theme.min.css', false, $this->version );
137
138 // toastr.js
139 wp_register_style( 'erp-toastr', $vendor . '/toastr/toastr.min.css', false, $this->version );
140
141 // core css files
142 wp_register_style( 'erp-styles', $css . '/admin.css', false, $this->version );
143 }
144
145 /**
146 * Enqueue the scripts
147 *
148 * @return void
149 */
150 public function enqueue_scripts() {
151 $screen = get_current_screen();
152 $screen_base = isset( $screen->base ) ? $screen->base : false;
153 $hook = str_replace( sanitize_title( __( 'HR Management', 'erp' ) ), 'hr-management', $screen_base );
154
155 wp_enqueue_script( 'erp-select2' );
156 wp_enqueue_script( 'erp-popup' );
157 wp_enqueue_script( 'erp-script' );
158 wp_enqueue_script( 'erp-are-you-sure' );
159 wp_enqueue_media();
160
161 wp_localize_script( 'erp-script', 'wpErp', [
162 'nonce' => wp_create_nonce( 'erp-nonce' ),
163 'set_logo' => __( 'Set company logo', 'erp' ),
164 'upload_logo' => __( 'Upload company logo', 'erp' ),
165 'remove_logo' => __( 'Remove company logo', 'erp' ),
166 'update_location' => __( 'Update Location', 'erp' ),
167 'create' => __( 'Create', 'erp' ),
168 'update' => __( 'Update', 'erp' ),
169 'formUnsavedMsg' => __( 'You didn\'t save your changes!', 'erp' ),
170 'confirmMsg' => __( 'Are you sure?', 'erp' ),
171 'ajaxurl' => admin_url( 'admin-ajax.php' ),
172 'plupload' => [
173 'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'erp_featured_img' ),
174 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
175 'filters' => [['title' => __( 'Allowed Files' ), 'extensions' => '*']],
176 'multipart' => true,
177 'urlstream_upload' => true,
178 ],
179 ] );
180
181 wp_enqueue_script( 'erp-menu', WPERP_ASSETS . '/js/erp-menu.js', [], date( 'Ymd' ), true );
182
183 // load country/state JSON on new company page
184 if ( erp_is_contacts_page() ) {
185 wp_enqueue_script( 'post' );
186
187 $country = \WeDevs\ERP\Countries::instance();
188 wp_localize_script( 'erp-script', 'wpErpCountries', $country->load_country_states() );
189 }
190
191 if ( erp_is_current_page( 'erp-hr', 'employee' ) || erp_is_current_page( 'erp-hr', 'my-profile' ) || ( isset( $_GET['page'] ) && 'erp-company' === $_GET['page'] ) ) {
192 $country = \WeDevs\ERP\Countries::instance();
193 wp_localize_script( 'erp-script', 'wpErpCountries', $country->load_country_states() );
194 }
195 }
196
197 /**
198 * Enqueue the stylesheet
199 *
200 * @return void
201 */
202 public function enqueue_styles() {
203 wp_enqueue_style( 'erp-fontawesome' );
204 wp_enqueue_style( 'erp-select2' );
205 wp_enqueue_style( 'jquery-ui' );
206
207 wp_enqueue_style( 'erp-styles' );
208 }
209 }
210