Version Description
- Display text field in monospace font
- Code refactoring
Download this release
Release Info
Developer | bostondv |
Plugin | Enhanced Text Widget |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.4
- enhanced-text-widget.php +143 -71
- readme.txt +7 -1
- screenshot-1.png +0 -0
enhanced-text-widget.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Enhanced Text Widget
|
4 |
Plugin URI: http://pomelodesign.com/enhanced-text-widget
|
5 |
Description: An enhanced version of the default text widget where you may have Text, HTML, CSS, JavaScript, Flash, and/or PHP as content with linkable widget title.
|
6 |
-
Version: 1.
|
7 |
Author: Pomelo Design
|
8 |
Author URI: http://pomelodesign.com/
|
9 |
License: GPL2
|
@@ -25,21 +25,47 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25 |
|
26 |
class EnhancedTextWidget extends WP_Widget {
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
$control_ops = array('width' => 400, 'height' => 350);
|
31 |
-
|
|
|
32 |
}
|
33 |
|
|
|
|
|
|
|
34 |
function widget( $args, $instance ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
extract($args);
|
|
|
36 |
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance);
|
37 |
-
$
|
38 |
-
$
|
39 |
-
$
|
40 |
-
$
|
41 |
-
$
|
42 |
-
$
|
|
|
|
|
43 |
if ( $cssClass ) {
|
44 |
if( strpos($before_widget, 'class') === false ) {
|
45 |
$before_widget = str_replace('>', 'class="'. $cssClass . '"', $before_widget);
|
@@ -47,87 +73,133 @@ class EnhancedTextWidget extends WP_Widget {
|
|
47 |
$before_widget = str_replace('class="', 'class="'. $cssClass . ' ', $before_widget);
|
48 |
}
|
49 |
}
|
|
|
50 |
echo $bare ? '' : $before_widget;
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
if
|
56 |
-
|
57 |
-
}
|
58 |
}
|
59 |
-
|
60 |
-
<div class="textwidget">
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
echo $bare ? '' : $after_widget;
|
73 |
}
|
74 |
|
|
|
|
|
|
|
75 |
function update( $new_instance, $old_instance ) {
|
76 |
$instance = $old_instance;
|
77 |
$instance['title'] = strip_tags($new_instance['title']);
|
78 |
-
$instance['hideTitle'] = isset($new_instance['hideTitle']);
|
79 |
-
$instance['titleUrl'] = strip_tags($new_instance['titleUrl']);
|
80 |
-
$instance['cssClass'] = strip_tags($new_instance['cssClass']);
|
81 |
-
$instance['newWindow'] = isset($new_instance['newWindow']);
|
82 |
if ( current_user_can('unfiltered_html') )
|
83 |
$instance['text'] = $new_instance['text'];
|
84 |
else
|
85 |
-
$instance['text'] = wp_filter_post_kses(
|
|
|
|
|
|
|
|
|
86 |
$instance['filter'] = isset($new_instance['filter']);
|
87 |
$instance['bare'] = isset($new_instance['bare']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
return $instance;
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
function form( $instance ) {
|
92 |
-
$instance = wp_parse_args( (array) $instance, array(
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
$
|
102 |
-
if(isset($instance['cssClass'])){
|
103 |
-
$cssClass = strip_tags($instance['cssClass']);
|
104 |
-
}
|
105 |
-
$text = "";
|
106 |
-
if(isset($instance['text'])){
|
107 |
-
$text = format_to_edit($instance['text']);
|
108 |
-
}
|
109 |
?>
|
110 |
-
|
111 |
-
<
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
<p
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
<p
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
<?php
|
126 |
}
|
127 |
}
|
128 |
-
|
|
|
|
|
|
|
|
|
129 |
register_widget('EnhancedTextWidget');
|
130 |
}
|
131 |
|
132 |
-
add_action('widgets_init', '
|
133 |
-
?>
|
3 |
Plugin Name: Enhanced Text Widget
|
4 |
Plugin URI: http://pomelodesign.com/enhanced-text-widget
|
5 |
Description: An enhanced version of the default text widget where you may have Text, HTML, CSS, JavaScript, Flash, and/or PHP as content with linkable widget title.
|
6 |
+
Version: 1.4
|
7 |
Author: Pomelo Design
|
8 |
Author URI: http://pomelodesign.com/
|
9 |
License: GPL2
|
25 |
|
26 |
class EnhancedTextWidget extends WP_Widget {
|
27 |
|
28 |
+
/**
|
29 |
+
* Widget construction
|
30 |
+
*/
|
31 |
+
function __construct() {
|
32 |
+
$widget_ops = array('classname' => 'widget_text enhanced-text-widget', 'description' => __('Text, HTML, CSS, PHP, Flash, JavaScript, Shortcodes', 'enhancedtext'));
|
33 |
$control_ops = array('width' => 400, 'height' => 350);
|
34 |
+
parent::__construct('EnhancedTextWidget', __('Enhanced Text', 'enhancedtext'), $widget_ops, $control_ops);
|
35 |
+
load_plugin_textdomain('enhancedtext', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Setup the widget output
|
40 |
+
*/
|
41 |
function widget( $args, $instance ) {
|
42 |
+
$cache = wp_cache_get('EnhancedTextWidget', 'widget');
|
43 |
+
|
44 |
+
if (!is_array($cache)) {
|
45 |
+
$cache = array();
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!isset($args['widget_id'])) {
|
49 |
+
$args['widget_id'] = null;
|
50 |
+
}
|
51 |
+
|
52 |
+
if (isset($cache[$args['widget_id']])) {
|
53 |
+
echo $cache[$args['widget_id']];
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
ob_start();
|
58 |
extract($args);
|
59 |
+
|
60 |
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance);
|
61 |
+
$titleUrl = empty($instance['titleUrl']) ? '' : $instance['titleUrl'];
|
62 |
+
$cssClass = empty($instance['cssClass']) ? '' : $instance['cssClass'];
|
63 |
+
$text = apply_filters('widget_text', $instance['text'], $instance);
|
64 |
+
$hideTitle = !empty($instance['hideTitle']) ? true : false;
|
65 |
+
$newWindow = !empty($instance['newWindow']) ? true : false;
|
66 |
+
$filterText = !empty($instance['filter']) ? true : false;
|
67 |
+
$bare = !empty($instance['bare']) ? true : false;
|
68 |
+
|
69 |
if ( $cssClass ) {
|
70 |
if( strpos($before_widget, 'class') === false ) {
|
71 |
$before_widget = str_replace('>', 'class="'. $cssClass . '"', $before_widget);
|
73 |
$before_widget = str_replace('class="', 'class="'. $cssClass . ' ', $before_widget);
|
74 |
}
|
75 |
}
|
76 |
+
|
77 |
echo $bare ? '' : $before_widget;
|
78 |
+
|
79 |
+
if ($newWindow) $newWindow = "target='_blank'";
|
80 |
+
|
81 |
+
if(!$hideTitle && $title) {
|
82 |
+
if($titleUrl) $title = "<a href='$titleUrl' $newWindow>$title</a>";
|
83 |
+
echo $bare ? $title : $before_title . $title . $after_title;
|
|
|
84 |
}
|
85 |
+
|
86 |
+
echo $bare ? '' : '<div class="textwidget widget-text">';
|
87 |
+
|
88 |
+
ob_start();
|
89 |
+
eval('?>' . $text);
|
90 |
+
$text = ob_get_contents();
|
91 |
+
ob_end_clean();
|
92 |
+
echo $filterText ? wpautop($text) : $text;
|
93 |
+
|
94 |
+
echo $bare ? '' : '</div>' . $after_widget;
|
95 |
+
|
96 |
+
$cache[$args['widget_id']] = ob_get_flush();
|
97 |
+
wp_cache_set('EnhancedTextWidget', $cache, 'widget');
|
|
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
+
* Run on widget update
|
102 |
+
*/
|
103 |
function update( $new_instance, $old_instance ) {
|
104 |
$instance = $old_instance;
|
105 |
$instance['title'] = strip_tags($new_instance['title']);
|
|
|
|
|
|
|
|
|
106 |
if ( current_user_can('unfiltered_html') )
|
107 |
$instance['text'] = $new_instance['text'];
|
108 |
else
|
109 |
+
$instance['text'] = wp_filter_post_kses($new_instance['text']);
|
110 |
+
$instance['titleUrl'] = strip_tags($new_instance['titleUrl']);
|
111 |
+
$instance['cssClass'] = strip_tags($new_instance['cssClass']);
|
112 |
+
$instance['hideTitle'] = isset($new_instance['hideTitle']);
|
113 |
+
$instance['newWindow'] = isset($new_instance['newWindow']);
|
114 |
$instance['filter'] = isset($new_instance['filter']);
|
115 |
$instance['bare'] = isset($new_instance['bare']);
|
116 |
+
|
117 |
+
$this->flush_widget_cache();
|
118 |
+
|
119 |
+
$alloptions = wp_cache_get('alloptions', 'options');
|
120 |
+
|
121 |
+
if (isset($alloptions['EnhancedTextWidget'])) {
|
122 |
+
delete_option('EnhancedTextWidget');
|
123 |
+
}
|
124 |
+
|
125 |
return $instance;
|
126 |
}
|
127 |
|
128 |
+
/**
|
129 |
+
* Flush widget cache
|
130 |
+
*/
|
131 |
+
function flush_widget_cache() {
|
132 |
+
wp_cache_delete('EnhancedTextWidget', 'widget');
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Setup the widget admin form
|
137 |
+
*/
|
138 |
function form( $instance ) {
|
139 |
+
$instance = wp_parse_args( (array) $instance, array(
|
140 |
+
'title' => '',
|
141 |
+
'titleUrl' => '',
|
142 |
+
'cssClass' => '',
|
143 |
+
'text' => ''
|
144 |
+
));
|
145 |
+
$title = $instance['title'];
|
146 |
+
$titleUrl = $instance['titleUrl'];
|
147 |
+
$cssClass = $instance['cssClass'];
|
148 |
+
$text = format_to_edit($instance['text']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
?>
|
150 |
+
|
151 |
+
<style>
|
152 |
+
.monospace { font-family: Consolas, Lucida Console, monospace; }
|
153 |
+
</style>
|
154 |
+
|
155 |
+
<p>
|
156 |
+
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'enhancedtext'); ?>:</label>
|
157 |
+
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
|
158 |
+
</p>
|
159 |
+
|
160 |
+
<p>
|
161 |
+
<label for="<?php echo $this->get_field_id('titleUrl'); ?>"><?php _e('URL', 'enhancedtext'); ?>:</label>
|
162 |
+
<input class="widefat" id="<?php echo $this->get_field_id('titleUrl'); ?>" name="<?php echo $this->get_field_name('titleUrl'); ?>" type="text" value="<?php echo $titleUrl; ?>" />
|
163 |
+
</p>
|
164 |
+
|
165 |
+
<p>
|
166 |
+
<label for="<?php echo $this->get_field_id('cssClass'); ?>"><?php _e('CSS Classes', 'enhancedtext'); ?>:</label>
|
167 |
+
<input class="widefat" id="<?php echo $this->get_field_id('cssClass'); ?>" name="<?php echo $this->get_field_name('cssClass'); ?>" type="text" value="<?php echo $cssClass; ?>" />
|
168 |
+
</p>
|
169 |
+
|
170 |
+
<p>
|
171 |
+
<label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Content', 'enhancedtext'); ?>:</label>
|
172 |
+
<textarea class="widefat monospace" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
|
173 |
+
</p>
|
174 |
+
|
175 |
+
<p>
|
176 |
+
<input id="<?php echo $this->get_field_id('hideTitle'); ?>" name="<?php echo $this->get_field_name('hideTitle'); ?>" type="checkbox" <?php checked(isset($instance['hideTitle']) ? $instance['hideTitle'] : 0); ?> /> <label for="<?php echo $this->get_field_id('hideTitle'); ?>"><?php _e('Do not display the title', 'enhancedtext'); ?></label>
|
177 |
+
</p>
|
178 |
+
|
179 |
+
<p>
|
180 |
+
<input type="checkbox" id="<?php echo $this->get_field_id('newWindow'); ?>" name="<?php echo $this->get_field_name('newWindow'); ?>" <?php checked(isset($instance['newWindow']) ? $instance['newWindow'] : 0); ?> />
|
181 |
+
<label for="<?php echo $this->get_field_id('newWindow'); ?>"><?php _e('Open the URL in a new window', 'enhancedtext'); ?></label>
|
182 |
+
</p>
|
183 |
+
|
184 |
+
<p>
|
185 |
+
<input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs to the content', 'enhancedtext'); ?></label>
|
186 |
+
</p>
|
187 |
+
|
188 |
+
<p>
|
189 |
+
<input id="<?php echo $this->get_field_id('bare'); ?>" name="<?php echo $this->get_field_name('bare'); ?>" type="checkbox" <?php checked(isset($instance['bare']) ? $instance['bare'] : 0); ?> /> <label for="<?php echo $this->get_field_id('bare'); ?>"><?php _e('Do not output before/after_widget/title', 'enhancedtext'); ?></label>
|
190 |
+
</p>
|
191 |
+
|
192 |
+
<p class="credits"><small><?php _e('Developed by', 'enhancedtext'); ?> <a href="http://pomelodesign.com">Pomelo Design</a></small></p>
|
193 |
+
|
194 |
<?php
|
195 |
}
|
196 |
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Register the widget
|
200 |
+
*/
|
201 |
+
function enhanced_text_widget_init() {
|
202 |
register_widget('EnhancedTextWidget');
|
203 |
}
|
204 |
|
205 |
+
add_action('widgets_init', 'enhanced_text_widget_init');
|
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://pomelodesign.com/donate/
|
|
4 |
Tags: widget, clickable, linkable, linked title, text, php, javascript, flash, linked title text, linked, text widget, php widget, link widget title, bare widget, widget shortcodes
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 1.
|
8 |
License: GPL2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -27,6 +27,8 @@ Options:
|
|
27 |
|
28 |
For support please [wordpress.org](http://wordpress.org/support/plugin/enhanced-text-widget). Visit [our website](http://pomelodesign.com), follow [@pomelod](http://twitter.com/pomelod/) or like [on facebook](http://www.facebook.com/pomelodesign/) for updates.
|
29 |
|
|
|
|
|
30 |
== Installation ==
|
31 |
|
32 |
1. Download and extract the zip archive
|
@@ -58,6 +60,10 @@ This is the initial release.
|
|
58 |
|
59 |
== Changelog ==
|
60 |
|
|
|
|
|
|
|
|
|
61 |
= 1.3.4 =
|
62 |
* This adds option to hide the title
|
63 |
* Tested up to 3.5.1
|
4 |
Tags: widget, clickable, linkable, linked title, text, php, javascript, flash, linked title text, linked, text widget, php widget, link widget title, bare widget, widget shortcodes
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 1.4
|
8 |
License: GPL2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
27 |
|
28 |
For support please [wordpress.org](http://wordpress.org/support/plugin/enhanced-text-widget). Visit [our website](http://pomelodesign.com), follow [@pomelod](http://twitter.com/pomelod/) or like [on facebook](http://www.facebook.com/pomelodesign/) for updates.
|
29 |
|
30 |
+
Fork or contribute on [Github](https://github.com/bostondv/enhanced-text-widget)
|
31 |
+
|
32 |
== Installation ==
|
33 |
|
34 |
1. Download and extract the zip archive
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
= 1.4 =
|
64 |
+
* Display text field in monospace font
|
65 |
+
* Code refactoring
|
66 |
+
|
67 |
= 1.3.4 =
|
68 |
* This adds option to hide the title
|
69 |
* Tested up to 3.5.1
|
screenshot-1.png
CHANGED
Binary file
|