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 / lib / widget.php

widget.php in Easy Bootstrap Shortcode 4.5, at lib/widget.php

81 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Create EBS widgets to to parse EBS shortcodes in sidebar
4 */
5 add_action('widgets_init', 'osc_ebsp_content_widget');
6
7 function osc_ebsp_content_widget() {
8 register_widget('Ebs_Custom_Widget');
9 }
10
11
12
13 class Ebs_Custom_Widget extends WP_Widget {
14
15 function __construct() {
16 global $wp_version;
17 $widget_ops = array('classname' => 'ebs_custom_widget', 'description' => __('EBS widget to show EBS/other shortcodes in sidebar.','ebs'));
18 $control_ops = array('id_base' => 'ebsp-widget');
19 parent::__construct('ebsp-widget', __('EBS Shortcode Compiler', 'ebs'), $widget_ops, $control_ops);
20 }
21
22 function widget($args, $instance) {
23 extract($args);
24
25 $title = apply_filters('widget_title', $instance['title']);
26 $ebs_content = $instance['ebs_content'];
27
28
29 echo $before_widget;
30
31 if ($title) {
32 echo $before_title . $title . $after_title;
33 }
34
35 if ($ebs_content) {
36
37 ?>
38 <div class="ebs_widget_content">
39 <?php echo do_shortcode($ebs_content);?>
40 </div>
41 <div class="clear"></div>
42 <?php
43 }
44
45
46
47 echo $after_widget;
48 }
49
50 function update($new_instance, $old_instance) {
51 $instance = $old_instance;
52
53 $instance['title'] = strip_tags($new_instance['title']);
54 $instance['ebs_content'] = $new_instance['ebs_content'];
55
56
57 return $instance;
58 }
59
60 function form($instance) {
61 $defaults = array('title' => 'EBS Shortcode', 'ebs_content' => '');
62 $instance = wp_parse_args((array) $instance, $defaults);
63 ?>
64
65 <p>
66 <label for="<?php echo $this->get_field_id('title'); ?>"><?php echo __('Title', 'easy-bootstrap-shoercodes'); ?>:</label>
67 <input class="osc_ebs_input" style=" width: 100%; display: block;" id="<?php echo $this->get_field_id('title'); ?>" type="text" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
68 </p>
69
70 <p>
71 <label for="<?php echo $this->get_field_id('ebs_content'); ?>"><?php echo __('Shortcode', 'easy-bootstrap-shoercodes'); ?>:</label>
72 <textarea class="osc_ebs_input" style=" height: 250px;
73 width: 100%; display: block;" id="<?php echo $this->get_field_id('ebs_content'); ?>" name="<?php echo $this->get_field_name('ebs_content'); ?>" ><?php echo $instance['ebs_content']; ?></textarea>
74 </p>
75
76
77 <?php
78 }
79
80 }
81 ?>