PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.11
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.11
2.1.22 2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 All 56 releases
booking-manager / core / wpbm-js.php

wpbm-js.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.0.11, at core/wpbm-js.php

316 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @package Booking Manager
4 * @category JavaScript files and varibales
5 * @author wpdevelop
6 *
7 * @web-site https://oplugins.com/
8 * @email [email protected]
9 *
10 * @modified 19.10.2015
11 */
12
13 class WPBM_JS extends WPBM_JS_CSS {
14
15 public function define() {
16
17 $this->setType('js');
18
19 /*
20 $this->add( array(
21 'handle' => 'wpbm-datepick',
22 'src' => wpbm_plugin_url( '/js/datepick/jquery.datepick.js'),
23 'deps' => array( 'wpbm-global-vars' ),
24 'version' => '1.1',
25 'where_to_load' => array( 'admin', 'client' ), //Usage: array( 'admin', 'client' )
26 'condition' => false
27 ) );
28 */
29 }
30
31 /** Enqueue Files and Varibales.
32 * Useful in case, if we use get_options and current user functions...
33 *
34 * @param type $where_to_load
35 */
36 public function enqueue( $where_to_load ) {
37
38 wpbm_js_load_vars( $where_to_load );
39
40 // Define JavaScript varibales in all other files
41 do_action( 'wpbm_define_js_vars', $where_to_load );
42
43 wpbm_js_load_libs( $where_to_load );
44 wpbm_js_load_files( $where_to_load );
45
46 if ( wpbm_is_new_wpbm_page() )
47 $where_to_load = 'both';
48
49 // Load JavaScript files in all other versions
50 do_action( 'wpbm_enqueue_js_files', $where_to_load );
51 }
52
53 /** Deregister some conflict scripts from other plugins.
54 *
55 * @param type $where_to_load
56 */
57 public function remove_conflicts( $where_to_load ) {
58
59 if ( wpbm_is_master_page() ) {
60 if (function_exists('wp_dequeue_script')) {
61
62 //wp_dequeue_script( 'jquery.cookie' );
63 //wp_dequeue_script( 'jquery-interdependencies' );
64 wp_dequeue_script( 'chosen' );
65 wp_dequeue_script( 'cs-framework' );
66 wp_dequeue_script( 'cgmp-jquery-tools-tooltip' ); // Remove this script jquery.tools.tooltip.min.js, which is load by the "Comprehensive Google Map Plugin"
67 }
68 }
69
70 }
71 }
72
73
74
75 /** Define JavaScript Varibales */
76 function wpbm_js_load_vars( $where_to_load ) {
77
78 ////////////////////////////////////////////////////////////////////////////
79 // JavaScripts Variables
80 ////////////////////////////////////////////////////////////////////////////
81
82 wp_enqueue_script( 'wpbm-global-vars', wpbm_plugin_url( '/js/wpbm_vars.js' ), array( 'jquery' ), '1.1' ); // Blank JS File
83
84 wp_localize_script( 'wpbm-global-vars'
85 , 'wpbm_global1', array(
86 'wpbm_ajaxurl' => admin_url( 'admin-ajax.php' )
87 , 'wpbm_plugin_url' => plugins_url( '' , WPBM_FILE )
88 , 'wpbm_today' => '[' . intval(date_i18n('Y')) //FixIn:6.1
89 .','. intval(date_i18n('m'))
90 .','. intval(date_i18n('d'))
91 .','. intval(date_i18n('H'))
92 .','. intval(date_i18n('i'))
93 .']'
94 , 'wpbm_plugin_filename' => WPBM_PLUGIN_FILENAME
95 , 'message_verif_requred' => esc_js(__('This field is required' , 'booking-manager'))
96 , 'message_verif_requred_for_check_box' => esc_js(__('This checkbox must be checked' , 'booking-manager'))
97 , 'message_verif_requred_for_radio_box' => esc_js(__('At least one option must be selected' , 'booking-manager'))
98 , 'message_verif_emeil' => esc_js(__('Incorrect email field' , 'booking-manager'))
99 , 'message_verif_same_emeil' => esc_js(__('Your emails do not match' , 'booking-manager')) // Email Addresses Do Not Match
100
101 , 'wpbm_active_locale' => wpbm_get_locale()
102 , 'wpbm_message_processing' => esc_js( __('Processing' , 'booking-manager') )
103 , 'wpbm_message_deleting' => esc_js( __('Deleting' , 'booking-manager') )
104 , 'wpbm_message_updating' => esc_js( __('Updating' , 'booking-manager') )
105 , 'wpbm_message_saving' => esc_js( __('Saving' , 'booking-manager') )
106 ));
107
108 }
109
110
111 /** Default JavaScripts Libraries */
112 function wpbm_js_load_libs( $where_to_load ) {
113
114 // jQuery
115 wp_enqueue_script( 'jquery' );
116
117 //FixIn: 8.4.7.23
118 if ( false ) {
119
120 $version = wpbm_get_registered_jquery_version();
121
122 if ( $version !== false ) {
123
124 if ( version_compare( $version, '1.9.1', '<' ) ) { // load jQuery 1.7.1, if "Theme" load older jQuery //FixIn: 7.0.1.3
125 wp_deregister_script( 'jquery' );
126 wp_register_script( 'jquery', 'http://code.jquery.com/jquery-1.9.1.min.js', false, '1.9.1' ); //FixIn: 7.0.1.3
127 // wp_register_script('jquery', 'http://code.jquery.com/jquery-latest.min.js', false, false);
128 wp_enqueue_script( 'jquery' );
129
130 wp_register_script( 'jquery-migrate', 'http://code.jquery.com/jquery-migrate-1.0.0.js', false, '1.0.0' ); //FixIn: 7.0.1.3
131 wp_enqueue_script( 'jquery-migrate' ); //FixIn: 7.0.1.3
132 }
133
134 ////////////////////////////////////////////////////////////////////////
135 // jQuery Migrate
136 if ( version_compare( $version, '1.9', '>=' ) ) { // if the jQuery newer then 1.9
137 wp_register_script( 'jquery-migrate', 'http://code.jquery.com/jquery-migrate-1.0.0.js', false, '1.0.0' );
138 wp_enqueue_script( 'jquery-migrate' );
139 }
140 }
141 }
142
143 // Default Admin Libs
144 if ( ( $where_to_load == 'admin' )
145 // || ( is_admin() && ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) )
146 ) {
147
148 wp_enqueue_media();
149
150 wp_enqueue_script('thickbox');
151 // Load thickbox CSS
152 wp_enqueue_style('thickbox');
153
154 wp_enqueue_style( 'wp-color-picker' ); // Color Picker
155 wp_enqueue_script( 'wp-color-picker' );
156 wp_enqueue_script( 'jquery-ui-sortable' ); // UI Sortable
157 // if ( wpbm_is_master_page() )
158 // wp_enqueue_script( 'jquery-ui-dialog' ); // UI Dialog - for payment request dialog
159 }
160
161 }
162
163
164 /** Load JavaScript Files */
165 function wpbm_js_load_files( $where_to_load ) {
166
167 // Bootstrap
168 if ( ( ( is_admin() ) && ( get_wpbm_option( 'wpbm_is_not_load_bs_script_in_admin' ) !== 'On') )
169 // || ( ( ! is_admin() ) && ( get_wpbm_option( 'wpbm_is_not_load_bs_script_in_client' ) !== 'On' ) )
170 ) {
171 wp_enqueue_script( 'wpdevelop-bootstrap', wpbm_plugin_url( '/assets/libs/bootstrap/js/bootstrap.js' ), array( 'wpbm-global-vars' ), '3.3.5.1');
172 }
173
174 // Datepicker
175 // wp_enqueue_script( 'wpbm-datepick', wpbm_plugin_url( '/js/datepick/jquery.datepick.js'), array( 'wpbm-global-vars' ), '1.1');
176
177 // Localization
178 // $calendar_localization_url = wpbm_get_calendar_localization_url();
179 // if ( ! empty( $calendar_localization_url ) )
180 // wp_enqueue_script( 'wpbm-datepick-localize', $calendar_localization_url, array( 'wpbm-datepick' ), '1.1');
181 //wpbm_load_calendar_localization_file();
182
183 if ( ( $where_to_load == 'client' ) || ( wpbm_is_new_wpbm_page() ) ) {
184
185 // Client
186 // wp_enqueue_script( 'wpbm-main-client', wpbm_plugin_url( '/js/client.js'), array( 'wpbm-datepick' ), '1.1');
187 }
188
189 if ( $where_to_load == 'admin' ) {
190
191 // Admin
192 wp_enqueue_script( 'wpbm-admin-main', wpbm_plugin_url( '/js/admin.js'), array( 'wpbm-global-vars' ), '1.1');
193 wp_enqueue_script( 'wpbm-admin-support', wpbm_plugin_url( '/core/any/js/admin-support.js'), array( 'wpbm-global-vars' ), '1.1');
194
195 // Chosen Library
196 wp_enqueue_script( 'wpbm-chosen', wpbm_plugin_url( '/assets/libs/chosen/chosen.jquery.min.js'), array( 'wpbm-global-vars' ), '1.1' );
197 }
198
199 }
200
201
202
203 ////////////////////////////////////////////////////////////////////////////////
204 // Support JavaScript functions
205 ////////////////////////////////////////////////////////////////////////////////
206
207 /** Load Datepicker Localization JS File */
208 /*
209 function wpbm_load_calendar_localization_file() {
210
211 // Datepicker Localization - translation for calendar. Example: $locale = 'fr_FR';
212 $locale = wpbm_get_locale();
213 if ( ! empty( $locale ) ) {
214
215 $locale_lang = substr( $locale, 0, 2 );
216 $locale_country = substr( $locale, 3 );
217
218 if ( ( $locale_lang !== 'en') && ( wpbm_is_file_exist( '/js/datepick/jquery.datepick-' . $locale_lang . '.js' ) ) ) {
219
220 wp_enqueue_script( 'wpbm-datepick-localize', wpbm_plugin_url( '/js/datepick/jquery.datepick-'. $locale_lang . '.js' ), array( 'wpbm-datepick' ), '1.1');
221
222 } else if ( ( ! in_array( $locale, array( 'en_US', 'en_CA', 'en_GB', 'en_AU' ) ) ) // English Exceptions
223 && ( wpbm_is_file_exist( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ) )
224 ) {
225
226 wp_enqueue_script( 'wpbm-datepick-localize', wpbm_plugin_url( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ), array( 'wpbm-datepick' ), '1.1');
227 }
228 }
229 }*/
230
231
232 /** Get URL Datepicker Localization JS File
233 *
234 * @return string - URL to calendar skin
235 */
236 /*
237 function wpbm_get_calendar_localization_url() {
238 // Datepicker Localization - translation for calendar. Example: $locale = 'fr_FR';
239 $locale = wpbm_get_locale();
240
241 $calendar_localization_url = false;
242
243 if ( ! empty( $locale ) ) {
244
245 $locale_lang = substr( $locale, 0, 2 );
246 $locale_country = substr( $locale, 3 );
247
248 if ( ( $locale_lang !== 'en') && ( wpbm_is_file_exist( '/js/datepick/jquery.datepick-' . $locale_lang . '.js' ) ) ) {
249
250 $calendar_localization_url = wpbm_plugin_url( '/js/datepick/jquery.datepick-'. $locale_lang . '.js' );
251
252 } else if ( ( ! in_array( $locale, array( 'en_US', 'en_CA', 'en_GB', 'en_AU' ) ) ) // English Exceptions
253 && ( wpbm_is_file_exist( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ) )
254 ) {
255
256 $calendar_localization_url = wpbm_plugin_url( '/js/datepick/jquery.datepick-'. $locale_country . '.js' );
257 }
258 }
259
260 return $calendar_localization_url;
261 }
262 */
263
264 /** Get Registred jQuery version
265 *
266 * @global type $wp_scripts
267 * @return string - jQuery version
268 */
269 function wpbm_get_registered_jquery_version() {
270 global $wp_scripts;
271
272 $version = false;
273
274 if ( is_a( $wp_scripts, 'WP_Scripts' ) )
275 if (isset( $wp_scripts->registered['jquery'] ))
276 $version = $wp_scripts->registered['jquery']->ver;
277 return $version;
278 }
279
280
281 /** Check if we activated loading of JS/CSS only on specific pages and then load or no it
282 *
283 * @param boolean $is_load_scripts - Default: true
284 * @return boolean - true | false
285 */
286 function wpbm_is_load_css_js_on_client_page( $is_load_scripts ) {
287
288 return true;
289
290 if ( ! is_admin() ) { // Check on Client side only
291
292 $wpbm_is_load_js_css_on_specific_pages = get_wpbm_option( 'wpbm_is_load_js_css_on_specific_pages' );
293 if ( $wpbm_is_load_js_css_on_specific_pages == 'On' ) {
294
295 $wpbm_pages_for_load_js_css = get_wpbm_option( 'wpbm_pages_for_load_js_css' );
296
297 $wpbm_pages_for_load_js_css = preg_split('/[\r\n]+/', $wpbm_pages_for_load_js_css, -1, PREG_SPLIT_NO_EMPTY);
298
299 $request_uri = $_SERVER['REQUEST_URI']; // FixIn:5.4.1
300 if ( strpos( $request_uri, 'wpbm_hash=') !== false ) {
301 $request_uri = parse_url($request_uri);
302 if ( ( ! empty($request_uri ) ) && ( isset($request_uri['path'] ) ) ){
303 $request_uri = $request_uri['path'];
304 } else {
305 $request_uri = $_SERVER['REQUEST_URI'];
306 }
307 }
308
309 if ( ( ! empty($wpbm_pages_for_load_js_css ) ) && ( ! in_array( $request_uri, $wpbm_pages_for_load_js_css ) ) )
310 return false;
311 }
312 }
313 return true;
314 }
315 add_filter( 'wpbm_is_load_script_on_this_page', 'wpbm_is_load_css_js_on_client_page' );
316