PluginProbe
Easy Bootstrap Shortcode / trunk
Easy Bootstrap Shortcode vtrunk
trunk 2.4.0 2.5 3.4 3.5 3.6 3.7 4.0.0 4.4 4.5 4.5.4 5.0.0 5.0.1 5.0.2
easy-bootstrap-shortcodes / osc_bootstrap_shortcode.php

osc_bootstrap_shortcode.php in Easy Bootstrap Shortcode trunk, at osc_bootstrap_shortcode.php

442 lines 19.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Easy Bootstrap Shortcode
4 Plugin URI: http://www.oscitasthemes.in
5 Description: Add bootstrap 3.0.3 styles to your theme by wordpress editor shortcode buttons.
6 Version: 5.0.2
7 Requires at least: 6.5
8 Tested up to: 7.1
9 Requires PHP: 7.4
10 Author: oscitas
11 Author URI: http://www.oscitasthemes.in
12 License: GPLv2 or later
13 License URI: https://www.gnu.org/licenses/gpl-2.0.html
14 Text Domain: easy-bootstrap-shortcodes
15 Domain Path: /languages
16 */
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /*
23 * function used to check whether ebs activated this check included in EBS Pro
24 */
25 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Legacy global kept for extension compatibility.
26 $_EBS_SESSION_STARTED = false;
27 function osc_ebs_plugin_exists( $prevent ) {
28 return 'ebs';
29 }
30 $checkplugin=apply_filters('osc_ebs_pro_plugin_exists',false);
31 if(isset($checkplugin) && $checkplugin=='ebsp'):
32 add_action('admin_notices', 'ebs_showAdminMessages');
33
34 function ebs_showMessage($message, $errormsg = false)
35 {
36 if ($errormsg) {
37 echo '<div id="message" class="error ebs_notification">';
38 }
39 else {
40 echo '<div id="message" class="update-nag ebs_notification">';
41 }
42 echo '<p><strong>' . esc_html( $message ) . '</strong></p></div>';
43 }
44
45 /*
46 * Show message when EBS and EBS pro both activated
47 */
48 function ebs_showAdminMessages()
49 {
50 ebs_showMessage(__("Easy Bootstrap Shortcode Pro activated, deactivate Easy Bootstrap Shortcode free version", 'easy-bootstrap-shortcodes'), false);
51 }
52 else:
53 /*
54 Define Global variable and constants
55 */
56 add_filter( 'osc_ebs_plugin_exists', 'osc_ebs_plugin_exists' );
57 define('EBS_PLUGIN_URL',plugins_url('/',__FILE__));
58 define('EBS_JS_CDN','https://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js');
59 define('EBS_RESPOND_CDN','https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.min.js');
60 define('EBS_VERSION', '5.0.2');
61
62 require_once __DIR__ . '/includes/class-ebs-sanitizer.php';
63 require_once __DIR__ . '/includes/class-ebs-dynamic-css.php';
64 require_once __DIR__ . '/includes/class-ebs-gutenberg.php';
65
66 \EBS\Styles\Dynamic_Css::register();
67 \EBS\Editor\Gutenberg::register();
68 add_action('admin_init','check_ebsp_status');
69 function check_ebsp_status(){
70 $file = basename( __FILE__ );
71 $folder = basename( dirname( __FILE__ ) );
72 $hook = "after_plugin_row_{$folder}/{$file}";
73 add_action( $hook, 'ebsp_register_licence_key');
74 }
75 function ebsp_register_licence_key( $plugin_name )
76
77 {
78 $ebsprefix='ebsp';
79 $plugin_name='easy-bootstrap-shortcode-pro/osc_bootstrap_shortcode.php ';
80 echo '</tr><tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">' . wp_kses(
81 __( 'Easy Bootstrap Shortcode Pro also available, <a href="http://oscitasthemes.in/products/easy-bootstrap-shortcodes-pro/">click here</a> to purchase one now', 'easy-bootstrap-shortcodes' ),
82 array(
83 'a' => array( 'href' => true ),
84 )
85 ) . '</div></td>';
86 }
87
88 add_action('admin_enqueue_scripts', 'osc_add_admin_ebs_scripts');
89 add_action('admin_menu', 'osc_ebs_add_admin_menu');
90 add_filter('mce_external_plugins', 'osc_editor_enable_mce');
91 /*
92 * Include bootstrap js and css file if activated theme is not an oscitas product
93 */
94 if(!apply_filters('plugin_oscitas_theme_check',false)){
95 add_action('wp_enqueue_scripts', 'osc_add_frontend_ebs_scripts',-100);
96 }
97
98
99
100 register_activation_hook(__FILE__, 'osc_ebs_activate_plugin');
101 register_deactivation_hook(__FILE__, 'osc_ebs_deactivate_plugin');
102
103 /*
104 * Plugin activation hook set default plugin setting on activation
105 */
106 function osc_ebs_activate_plugin() {
107 $isSet=apply_filters('ebs_custom_option',false);
108 if (!$isSet) {
109
110 // EBS_BOOTSTRAP_JS_LOCATION '1' - for plugin file, '2' - don't user EBS files but use from other plugin or theme, '3' - to user CDN path
111 update_option( 'EBS_BOOTSTRAP_JS_LOCATION', 1 );
112 update_option( 'EBS_BOOTSTRAP_JS_CDN_PATH', EBS_JS_CDN );
113 update_option( 'EBS_BOOTSTRAP_RESPOND_CDN_PATH', EBS_RESPOND_CDN );
114 // EBS_BOOTSTRAP_RESPOND_LOCATION '1' - for plugin file, '2' - don't user EBS files but use from other plugin or theme, '3' - to user CDN path
115 update_option('EBS_BOOTSTRAP_RESPOND_LOCATION',2);
116
117 // EBS_BOOTSTRAP_CSS_LOCATION '1' - for plugin file, '2' - don't user EBS files but use from other plugin or theme
118 update_option( 'EBS_BOOTSTRAP_CSS_LOCATION', 1 );
119 update_option( 'EBS_EDITOR_OPT','icon');
120 update_option( 'EBS_EDITOR_OPT','icon');
121 if(get_option('EBS_SHORTCODE_PREFIX')==false){
122 update_option( 'EBS_SHORTCODE_PREFIX', '' );
123 }
124 update_option( 'EBS_INCLUDE_FA',1);
125 update_option( 'EBS_SESSION_CLOSE',0);
126 if(get_option('EBS_CUSTOM_CSS')==''){
127 update_option( 'EBS_CUSTOM_CSS','');
128 }
129 }
130
131 }
132
133 /*
134 * Plugin deactivation hook, delete option on deactivation
135 */
136 function osc_ebs_deactivate_plugin() {
137 $isSet=apply_filters('ebs_custom_option',false);
138 if (!$isSet) {
139 delete_option( 'EBS_BOOTSTRAP_JS_LOCATION' );
140 delete_option( 'EBS_BOOTSTRAP_JS_CDN_PATH' );
141 delete_option( 'EBS_BOOTSTRAP_CSS_LOCATION');
142 delete_option( 'EBS_BOOTSTRAP_RESPOND_LOCATION' );
143 delete_option( 'EBS_BOOTSTRAP_RESPOND_CDN_PATH' );
144 delete_option('EBS_EDITOR_OPT');
145 delete_option('EBS_INCLUDE_FA');
146 delete_option('EBS_SESSION_CLOSE');
147 }
148 }
149
150 /*
151 * Add plugin setting page on plugin listing page after activation
152 */
153 function osc_ebs_settings_link( $links ) {
154 $isSet=apply_filters('ebs_custom_option',false);
155 if (!$isSet) {
156 $settings_link = '<a href="admin.php?page=ebs/ebs-settings.php">'.__('Settings', 'easy-bootstrap-shortcodes').'</a>';
157 array_push( $links, $settings_link );
158 }
159 return $links;
160 }
161
162 add_filter( "plugin_action_links_".plugin_basename( __FILE__ ), 'osc_ebs_settings_link' );
163
164 /*
165 * Create EBS admin Menu
166 */
167 function osc_ebs_add_admin_menu() {
168 $isSet=apply_filters('ebs_custom_option',false);
169 if (!$isSet) {
170 add_menu_page(__('EBS Settings', 'easy-bootstrap-shortcodes'), __('EBS Settings', 'easy-bootstrap-shortcodes'), 'manage_options', 'ebs/ebs-settings.php', 'osc_ebs_setting_page', plugins_url('/images/icon.png', __FILE__));
171
172 $sub_page= add_submenu_page( 'ebs/ebs-settings.php',__('osCitas Offers', 'easy-bootstrap-shortcodes'), __('osCitas Offers', 'easy-bootstrap-shortcodes'), 'manage_options', 'ebs-pro-demo', 'osc_ebs_pro_demo_page' );
173 add_action('admin_print_styles-' . $sub_page, 'ebsProDemoPage_register_admin_styles');
174 }
175 }
176
177
178 /*
179 * Add EBS pto Demo page css
180 */
181 function ebsProDemoPage_register_admin_styles(){
182 wp_enqueue_style('ebs_pro_demo', EBS_PLUGIN_URL.'styles/ebs_pro_demo.css');
183 }
184 function osc_ebs_pro_demo_page(){
185 include 'lib/ebspro-demo.php';
186 }
187
188 /*
189 * Render EBS Setting Page & update EBS options
190 */
191 function osc_ebs_setting_page() {
192 if ( ! current_user_can( 'manage_options' ) ) {
193 wp_die( esc_html__( 'You do not have permission to access this page.', 'easy-bootstrap-shortcodes' ) );
194 }
195
196 if ( isset( $_POST['ebs_submit'] ) ) {
197 check_admin_referer( 'ebs_save_settings', 'ebs_settings_nonce' );
198
199 $js_location = isset( $_POST['b_js'] ) ? absint( $_POST['b_js'] ) : 1;
200 if ( $js_location < 1 || $js_location > 3 ) {
201 $js_location = 1;
202 }
203
204 $css_location = isset( $_POST['b_css'] ) ? absint( $_POST['b_css'] ) : 1;
205 if ( $css_location < 1 || $css_location > 3 ) {
206 $css_location = 1;
207 }
208
209 $respond_location = isset( $_POST['respond_js'] ) ? absint( $_POST['respond_js'] ) : 2;
210 if ( $respond_location < 1 || $respond_location > 3 ) {
211 $respond_location = 2;
212 }
213
214 $editor_opt = isset( $_POST['ebsp_editor_opt'] ) ? sanitize_key( $_POST['ebsp_editor_opt'] ) : 'icon';
215 if ( ! in_array( $editor_opt, array( 'icon', 'dropdown' ), true ) ) {
216 $editor_opt = 'icon';
217 }
218 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized via Sanitizer::custom_css().
219 $custom_css = isset( $_POST['ebs_custom_css'] ) ? \EBS\Security\Sanitizer::custom_css( wp_unslash( $_POST['ebs_custom_css'] ) ) : '';
220 $fa_icon = isset( $_POST['fa_icon'] ) ? 1 : 0;
221 $session_close = isset( $_POST['use_ebs_session_close'] ) ? 1 : 0;
222 $shortcode_prefix = isset( $_POST['shortcode_prefix'] ) ? sanitize_key( wp_unslash( $_POST['shortcode_prefix'] ) ) : '';
223 $cdn_path = isset( $_POST['cdn_path'] ) ? esc_url_raw( wp_unslash( $_POST['cdn_path'] ) ) : EBS_JS_CDN;
224 $respond_cdn_path = isset( $_POST['respond_cdn_path'] ) ? esc_url_raw( wp_unslash( $_POST['respond_cdn_path'] ) ) : EBS_RESPOND_CDN;
225
226 update_option( 'EBS_BOOTSTRAP_JS_LOCATION', $js_location );
227 update_option( 'EBS_BOOTSTRAP_JS_CDN_PATH', $cdn_path );
228 update_option( 'EBS_BOOTSTRAP_CSS_LOCATION', $css_location );
229 update_option( 'EBS_BOOTSTRAP_RESPOND_LOCATION', $respond_location );
230 update_option( 'EBS_BOOTSTRAP_RESPOND_CDN_PATH', $respond_cdn_path );
231 update_option( 'EBS_EDITOR_OPT', $editor_opt );
232 update_option( 'EBS_CUSTOM_CSS', $custom_css );
233 update_option( 'EBS_INCLUDE_FA', $fa_icon );
234 update_option( 'EBS_SESSION_CLOSE', $session_close );
235 update_option( 'EBS_SHORTCODE_PREFIX', $shortcode_prefix );
236
237 $js = $js_location;
238 $cdn = $cdn_path;
239 $css = $css_location;
240 $respond = $respond_location;
241 $respondcdn = $respond_cdn_path;
242 $ebsp_editor_opt = $editor_opt;
243 $ebs_custom_css = $custom_css;
244 $shortcode_prefix = $shortcode_prefix;
245 $use_ebs_session_close = $session_close;
246 } else {
247 $js = get_option( 'EBS_BOOTSTRAP_JS_LOCATION', 1 );
248 $cdn = get_option( 'EBS_BOOTSTRAP_JS_CDN_PATH', EBS_JS_CDN );
249 $css = get_option( 'EBS_BOOTSTRAP_CSS_LOCATION', 1 );
250 $respond = get_option( 'EBS_BOOTSTRAP_RESPOND_LOCATION', 2 );
251 $respondcdn = get_option( 'EBS_BOOTSTRAP_RESPOND_CDN_PATH', EBS_RESPOND_CDN );
252 $ebsp_editor_opt=get_option('EBS_EDITOR_OPT','icon');
253 $ebs_custom_css=get_option('EBS_CUSTOM_CSS','');
254 $shortcode_prefix=get_option('EBS_SHORTCODE_PREFIX','');
255 $fa_icon=get_option('EBS_INCLUDE_FA',1);
256 $use_ebs_session_close=get_option('EBS_SESSION_CLOSE',0);
257 }
258 include 'ebs_settings.php';
259 }
260
261 /*
262 * Define global JS variable for admin panel
263 */
264 add_action('admin_head', 'osc_ebs_ajax_ul');
265 function osc_ebs_ajax_ul(){
266 $ebsp_editor_opt=get_option('EBS_EDITOR_OPT','icon');
267
268 ?>
269 <script type="text/javascript">
270 var ebs_ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>';
271 var ebs_url='<?php echo esc_url( EBS_PLUGIN_URL ); ?>';
272 var ebs_editor_opt='<?php echo esc_js( $ebsp_editor_opt ); ?>';
273 var ebs_dropdown_obj=<?php echo wp_json_encode( ebs_shortcodes() ); ?>;
274 var ebs_dropdown_grp=<?php echo wp_json_encode( ebs_groups() ); ?>;
275
276 </script>
277 <?php
278 }
279
280 /*
281 * Add css and scripts to admin panel
282 */
283 function osc_add_admin_ebs_scripts() {
284 global $pagenow;
285 $fa_icon=get_option('EBS_INCLUDE_FA',1);
286 $use_ebs_session_close=get_option('EBS_SESSION_CLOSE',0);
287 $screen = get_current_screen();
288 if ($screen->id == 'toplevel_page_ebs/ebs-settings') {
289 wp_enqueue_style('ebs-setting', plugins_url('/styles/ebs-setting.min.css', __FILE__));
290 }
291 wp_enqueue_script('ebs-main', plugins_url('/js/ebs_main.js', __FILE__), array( 'jquery' ), EBS_VERSION, true );
292 $shortcode_prefix=get_option('EBS_SHORTCODE_PREFIX','');
293 wp_localize_script( 'ebs-main', 'ebs', array(
294 'font_awe'=>$fa_icon,
295 'ebs_prefix'=>$shortcode_prefix
296 ));
297
298 }
299
300 /*
301 * Add additional css to tinymce editor
302 */
303 add_action('admin_print_styles','ebsp_tinymce_button_css');
304 function ebsp_tinymce_button_css() {
305
306 wp_register_style('ebsp_tinymce_button_css', plugins_url('/styles/editor.css', __FILE__), array());
307
308 wp_enqueue_style('ebsp_tinymce_button_css');
309
310
311 wp_enqueue_style('dashicons');
312
313 }
314 /*
315 * Add css to tinymce editor
316 */
317 function osc_editor_enable_mce($plugin_array){
318 $fa_icon=get_option('EBS_INCLUDE_FA',1);
319 $use_ebs_session_close=get_option('EBS_SESSION_CLOSE',0);
320 wp_enqueue_script('jquery');
321 wp_enqueue_style('thickbox');
322 wp_enqueue_script('media-upload');
323 wp_enqueue_script('thickbox');
324 wp_enqueue_style('wp-color-picker');
325 wp_enqueue_script('wp-color-picker');
326 wp_enqueue_script('jquery-ui-slider');
327 // wp_enqueue_script('jquery-ui-dialog');
328 // wp_enqueue_style ( 'wp-jquery-ui-dialog');
329 wp_enqueue_style('ebs-magnific-popup', plugins_url('/styles/magnific-popup.css', __FILE__)); wp_enqueue_script('ebs-magnific-popup', plugins_url('/js/magnific-popup.js', __FILE__));
330 wp_enqueue_style('EBS_jquery-ui-slider-css', plugins_url('/styles/slider.css', __FILE__));
331 if (!apply_filters('ebs_bootstrap_icon_css_url',false)) {
332 wp_enqueue_style('bootstrap-icon', plugins_url('/styles/bootstrap-icon.min.css', __FILE__));
333 } else{
334 wp_enqueue_style('bootstrap-icon', apply_filters('ebs_bootstrap_icon_css_url',false));
335 }
336
337 if (!apply_filters('ebs_custom_bootstrap_admin_css',false)) {
338 wp_enqueue_style('ebs_bootstrap_admin', plugins_url('/styles/bootstrap_admin.min.css', __FILE__));
339 } if($fa_icon==1){
340 wp_enqueue_style('bootstrap-fa-icon', plugins_url('/styles/font-awesome.min.css', __FILE__));
341 }
342 return $plugin_array;
343 }
344
345 /*
346 * Add bootstrap css and js to frontend if current theme is not an oscitas theme
347 */
348 function osc_add_frontend_ebs_scripts() {
349 wp_enqueue_script('jquery');
350 $isSet=apply_filters('ebs_custom_option',false);
351 if (!$isSet) {
352 $js = get_option( 'EBS_BOOTSTRAP_JS_LOCATION', 1 );
353 $respond = get_option( 'EBS_BOOTSTRAP_RESPOND_LOCATION', 2 );
354 $cdn = get_option( 'EBS_BOOTSTRAP_JS_CDN_PATH', EBS_JS_CDN );
355 $respondcdn = get_option( 'EBS_BOOTSTRAP_RESPOND_CDN_PATH', EBS_RESPOND_CDN );
356 $css = get_option( 'EBS_BOOTSTRAP_CSS_LOCATION', 1 );
357 $fa_icon=get_option('EBS_INCLUDE_FA',1);
358 $use_ebs_session_close=get_option('EBS_SESSION_CLOSE',0);
359 // http://cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.min.js
360
361 if ($js == 1) {
362 if (!apply_filters('ebs_bootstrap_js_url',false)) {
363 wp_enqueue_script('bootstrap', plugins_url('/js/bootstrap.min.js', __FILE__));
364 } else{
365 wp_enqueue_script('bootstrap', apply_filters('ebs_bootstrap_js_url',false));
366 }
367 } elseif ($js == 3) {
368 if (!apply_filters('ebs_bootstrap_js_cdn',false)) {
369 wp_enqueue_script('bootstrap', $cdn);
370 } else{
371 wp_enqueue_script('bootstrap', apply_filters('ebs_bootstrap_js_cdn',false));
372 }
373 }
374 //$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
375 $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] )
376 ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) )
377 : '';
378 if ( $user_agent && preg_match( '/(?i)msie [1-8]/', $user_agent ) ) {
379 if ($respond == 1) {
380 if (!apply_filters('ebs_bootstrap_respond_url',false)) {
381 wp_enqueue_script('bootstrap_respond', plugins_url('/js/respond.min.js', __FILE__));
382 } else{
383 wp_enqueue_script('bootstrap_respond', apply_filters('ebs_bootstrap_respond_url',false));
384 }
385 } elseif ($respond == 3) {
386 if (!apply_filters('ebs_bootstrap_respond_cdn',false)) {
387 wp_enqueue_script('bootstrap_respond', $respondcdn);
388 } else{
389 wp_enqueue_script('bootstrap_respond', apply_filters('ebs_bootstrap_respond_cdn',false));
390 }
391 }
392 }
393 if ($css == 1) {
394 if (!apply_filters('ebs_bootstrap_css_url',false)) {
395 wp_enqueue_style('bootstrap', plugins_url('/styles/bootstrap.min.css', __FILE__));
396 } else {
397 wp_enqueue_style('bootstrap', apply_filters('ebs_bootstrap_css_url',false));
398 }
399 }
400 elseif($css==3){
401 if (!apply_filters('ebs_no_bootstrap_theme_css_url',false)) {
402 wp_enqueue_style('bootstrap', plugins_url('/styles/bootstrap-oscitas.css', __FILE__));
403 } else {
404 wp_enqueue_style('bootstrap', apply_filters('ebs_no_bootstrap_theme_css_url',false));
405 }
406
407 }
408 else {
409 if (!apply_filters('ebs_bootstrap_icon_css_url',false)) {
410 //wp_enqueue_style('bootstrap-icon', plugins_url('/styles/bootstrap-icon.min.css', __FILE__));
411 } else{
412 wp_enqueue_style('bootstrap-icon', apply_filters('ebs_bootstrap_icon_css_url',false));
413 }
414 }
415 if($fa_icon==1){
416 if(!apply_filters('ebs_bootstrap_fa_icon_include_from_theme_or_plugin',false)){
417 if (!apply_filters('ebs_bootstrap_fa_icon_frontend_css_url',false)) {
418 wp_enqueue_style('bootstrap-fa-icon', plugins_url('/styles/font-awesome.min.css', __FILE__));
419 } else{
420 wp_enqueue_style('bootstrap-fa-icon', apply_filters('ebs_bootstrap_fa_icon_frontend_css_url',false));
421 }
422 }
423 }
424 }
425 }
426
427 // Shortcodes
428
429 /**
430 * Legacy no-op kept for backward compatibility with extensions.
431 */
432 function ebs_session_start() {}
433
434 /**
435 * Legacy no-op kept for backward compatibility with extensions.
436 */
437 function ebs_session_end() {}
438
439 include('shortcode/functions.php');
440 include('lib/widget.php');
441 endif;
442