PluginProbe
Easy Bootstrap Shortcode / 4.4
Easy Bootstrap Shortcode v4.4
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 4.4, at osc_bootstrap_shortcode.php

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