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

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