Enhanced Text Widget - Version 1.2

Version Description

This adds option to display bare text (no before/after widget/title elements are shown)

Download this release

Release Info

Developer bostondv
Plugin Icon wp plugin Enhanced Text Widget
Version 1.2
Comparing to
See all releases

Version 1.2

Files changed (3) hide show
  1. enhanced-text-widget.php +102 -0
  2. readme.txt +48 -0
  3. screenshot-1.png +0 -0
enhanced-text-widget.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Enhanced Text Widget
4
+ Plugin URI: http://pomelodesign.com/enhanced-text-widget
5
+ Description: This plugin provides a widget that supports Text, HTML, JavaScript, Flash and/or PHP as content with linkable widget titles.
6
+ Version: 1.2
7
+ Author: Pomelo Design Inc.
8
+ Author URI: http://pomelodesign.com/
9
+ */
10
+ /* This program is free software; you can redistribute it and/or modify
11
+ it under the terms of the GNU General Public License as published by
12
+ the Free Software Foundation; either version 2 of the License, or
13
+ (at your option) any later version.
14
+
15
+ This program is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ GNU General Public License for more details.
19
+
20
+ You should have received a copy of the GNU General Public License
21
+ along with this program; if not, write to the Free Software
22
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
+ */
24
+ class EnhancedTextWidget extends WP_Widget {
25
+
26
+ function EnhancedTextWidget() {
27
+ $widget_ops = array('classname' => 'widget_text', 'description' => __('Linkable titles with text, HTML PHP, Flash, Javascript'));
28
+ $control_ops = array('width' => 400, 'height' => 350);
29
+ $this->WP_Widget('EnhancedTextWidget', __('Enhanced Text'), $widget_ops, $control_ops);
30
+ }
31
+
32
+ function widget( $args, $instance ) {
33
+ extract($args);
34
+ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance);
35
+ $titleUrl = apply_filters('widget_title', empty($instance['titleUrl']) ? '' : $instance['titleUrl'], $instance);
36
+ $newWindow = $instance['newWindow'] ? '1' : '0';
37
+ $cssClass = apply_filters('widget_title', empty($instance['cssClass']) ? '' : $instance['cssClass'], $instance);
38
+ $bare = $instance['bare'] ? true : false;
39
+ $text = apply_filters( 'widget_text', $instance['text'], $instance );
40
+ if ( $cssClass ) {
41
+ if( strpos($before_widget, 'class') === false ) {
42
+ $before_widget = str_replace('>', 'class="'. $cssClass . '"', $before_widget);
43
+ } else {
44
+ $before_widget = str_replace('class="', 'class="'. $cssClass . ' ', $before_widget);
45
+ }
46
+ }
47
+ echo $bare ? '' : $before_widget;
48
+ if( $titleUrl && $title )
49
+ $title = '<a href="'.$titleUrl.'"'.($newWindow == '1'?' target="_blank"':'').' title="'.$title.'">'.$title.'</a>';
50
+ if ( !empty( $title ) ) { echo $bare ? $title : $before_title . $title . $after_title; } ?>
51
+ <div class="textwidget"><?php if($instance['filter']) { ob_start(); eval("?>$text<?php "); $output = ob_get_contents(); ob_end_clean(); echo wpautop($output); } else eval("?>".$text."<?php "); ?></div>
52
+ <?php
53
+ echo $bare ? '' : $after_widget;
54
+ }
55
+
56
+ function update( $new_instance, $old_instance ) {
57
+ $instance = $old_instance;
58
+ $instance['title'] = strip_tags($new_instance['title']);
59
+ $instance['titleUrl'] = strip_tags($new_instance['titleUrl']);
60
+ $instance['cssClass'] = strip_tags($new_instance['cssClass']);
61
+ $instance['bare'] = $new_instance['bare'] ? 1 : 0;
62
+ $instance['newWindow'] = $new_instance['newWindow'] ? 1 : 0;
63
+ if ( current_user_can('unfiltered_html') )
64
+ $instance['text'] = $new_instance['text'];
65
+ else
66
+ $instance['text'] = wp_filter_post_kses( $new_instance['text'] );
67
+ $instance['filter'] = isset($new_instance['filter']);
68
+ return $instance;
69
+ }
70
+
71
+ function form( $instance ) {
72
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'titleUrl' => '', 'text' => '' ) );
73
+ $title = strip_tags($instance['title']);
74
+ $titleUrl = strip_tags($instance['titleUrl']);
75
+ $newWindow = $instance['newWindow'] ? 'checked="checked"' : '';
76
+ $cssClass = strip_tags($instance['cssClass']);
77
+ $bare = $instance['bare'] ? 'checked="checked"' : '';
78
+ $text = format_to_edit($instance['text']);
79
+ ?>
80
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
81
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
82
+ <p><label for="<?php echo $this->get_field_id('titleUrl'); ?>"><?php _e('URL:'); ?></label>
83
+ <input class="widefat" id="<?php echo $this->get_field_id('titleUrl'); ?>" name="<?php echo $this->get_field_name('titleUrl'); ?>" type="text" value="<?php echo esc_attr($titleUrl); ?>" /></p>
84
+ <p><input class="checkbox" type="checkbox" <?php echo $newWindow; ?> id="<?php echo $this->get_field_id('newWindow'); ?>" name="<?php echo $this->get_field_name('newWindow'); ?>" />
85
+ <label for="<?php echo $this->get_field_id('newWindow'); ?>"><?php _e('Open the URL in a new window'); ?></label></p>
86
+ <p><label for="<?php echo $this->get_field_id('cssClass'); ?>"><?php _e('CSS Class:'); ?></label>
87
+ <input class="widefat" id="<?php echo $this->get_field_id('cssClass'); ?>" name="<?php echo $this->get_field_name('cssClass'); ?>" type="text" value="<?php echo esc_attr($cssClass); ?>" /></p>
88
+ <p><label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Content:'); ?></label>
89
+ <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
90
+
91
+ <p><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); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p>
92
+ <p><input class="checkbox" type="checkbox" <?php echo $bare; ?> id="<?php echo $this->get_field_id('bare'); ?>" name="<?php echo $this->get_field_name('bare'); ?>" />
93
+ <label for="<?php echo $this->get_field_id('bare'); ?>"><?php _e('Do not output before/after_widget/title'); ?></label></p>
94
+ <?php
95
+ }
96
+ }
97
+ function EnhancedTextWidgetInit() {
98
+ register_widget('EnhancedTextWidget');
99
+ }
100
+
101
+ add_action('widgets_init', 'EnhancedTextWidgetInit');
102
+ ?>
readme.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Enhanced Text Widget ===
2
+ Contributors: bostondv
3
+ 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
5
+ Requires at least: 2.8.0
6
+ Tested up to: 3.2.1
7
+ Stable tag: trunk
8
+
9
+ An enhanced version of the default text widget where you may have Text, HTML, JavaScript, Flash and/or PHP as content with linkable widget title.
10
+
11
+ == Description ==
12
+
13
+ An enhanced version of the default text widget where you may have Text, HTML, JavaScript, Flash and/or PHP as content with linkable widget title.
14
+
15
+ == Installation ==
16
+
17
+ 1. Download
18
+ 2. Extract all files from the zip archive
19
+ 3. Copy the enhanced-text-widget folder to wp-content/plugins/
20
+ 4. Activate the plugin through the "Plugins" menu in WordPress
21
+ 5. Add the widget to the sidebar and configure the options as desired
22
+
23
+ == Frequently Asked Questions ==
24
+
25
+ Nothing right now.
26
+
27
+ == Screenshots ==
28
+
29
+ 1. Widget editor.
30
+
31
+ == Upgrade Notice ==
32
+
33
+ = 1.2 =
34
+ This adds option to display bare text (no before/after widget/title elements are shown)
35
+
36
+ = 1.1 =
37
+ This adds a CSS class parameter to each widget.
38
+
39
+ = 1.0 =
40
+ This is the initial release.
41
+
42
+ == Changelog ==
43
+
44
+ = 1.1 =
45
+ * Adds css class parameter that wraps widget.
46
+
47
+ = 1.0 =
48
+ * First release.
screenshot-1.png ADDED
Binary file