Widget Content Blocks - Version 2.0.1

Version Description

  • Added: meta box in WYSIWYG Widget editor screen.
  • Added: debug messages for logged in administrators on frontend when no WYSIWYG Widget OR an invalid WYSIWYG Widget is selected.
  • Added: title is now optional for even more control. If empty, it won't be shown. You are now longer required to use the heading tag which is set in the widget options since you can use a heading in your post.
Download this release

Release Info

Developer DvanKooten
Plugin Icon wp plugin Widget Content Blocks
Version 2.0.1
Comparing to
See all releases

Version 2.0.1

includes/class-wysiwyg-widgets-widget.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WYSIWYG_Widgets_Widget extends WP_Widget
4
+ {
5
+ public function __construct() {
6
+ parent::__construct(
7
+ 'wysiwyg_widgets_widget', // Base ID
8
+ 'WYSIWYG Widget', // Name
9
+ array( 'description' => 'Lets you select one of your "WYSIWYG Widgets" and show it in a widget area.' ) // Args
10
+ );
11
+ }
12
+
13
+ /**
14
+ * Front-end display of widget.
15
+ *
16
+ * @see WP_Widget::widget()
17
+ *
18
+ * @param array $args Widget arguments.
19
+ * @param array $instance Saved values from database.
20
+ */
21
+ public function widget( $args, $instance ) {
22
+ extract( $args );
23
+ $id = $instance['wysiwyg-widget-id'];
24
+
25
+ $title = apply_filters( 'widget_title', $instance['title'] );
26
+ $post = get_post($id);
27
+
28
+ echo $before_widget;
29
+ if(!empty($title)) { echo $before_title . $title . $after_title; }
30
+
31
+ if($post && !empty($id)) {
32
+ $content = apply_filters('the_content', $post->post_content);
33
+ echo $content;
34
+ } else {
35
+ if(current_user_can('manage_options')) { ?>
36
+ <p style="color:red;">
37
+ <strong>ADMINS ONLY NOTICE:</strong>
38
+ <?php if(empty($id)) { ?>
39
+ Please select a WYSIWYG Widget post to show in this area.
40
+ <?php } else { ?>
41
+ No post found with ID <?php echo $id; ?>, please select an existing WYSIWYG Widget post.
42
+ <?php } ?>
43
+ </p>
44
+ <?php }
45
+ }
46
+
47
+ echo $after_widget;
48
+
49
+ }
50
+
51
+ /**
52
+ * Sanitize widget form values as they are saved.
53
+ *
54
+ * @see WP_Widget::update()
55
+ *
56
+ * @param array $new_instance Values just sent to be saved.
57
+ * @param array $old_instance Previously saved values from database.
58
+ *
59
+ * @return array Updated safe values to be saved.
60
+ */
61
+ public function update( $new_instance, $old_instance ) {
62
+ $instance = array();
63
+ $instance['title'] = strip_tags( $new_instance['title'] );
64
+ $instance['wysiwyg-widget-id'] = $new_instance['wysiwyg-widget-id'];
65
+
66
+ return $instance;
67
+ }
68
+
69
+ /**
70
+ * Back-end widget form.
71
+ *
72
+ * @see WP_Widget::form()
73
+ *
74
+ * @param array $instance Previously saved values from database.
75
+ */
76
+ public function form( $instance ) {
77
+
78
+ $posts = get_posts(array(
79
+ 'post_type' => 'wysiwyg-widget',
80
+ 'numberposts' => -1
81
+ ));
82
+
83
+ $title = isset($instance['title']) ? $instance['title'] : 'Just another WYSIWYG Widget';
84
+ $selected_widget_id = (isset($instance['wysiwyg-widget-id'])) ? $instance['wysiwyg-widget-id'] : 0;
85
+
86
+ if(empty($posts)) { ?>
87
+
88
+ <p>You should first create at least 1 WYSIWYG Widget <a href="<?php echo admin_url('edit.php?post_type=wysiwyg-widget'); ?>">here</a>.</p>
89
+
90
+ <?php
91
+ } else { ?>
92
+ <p>
93
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
94
+ <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 ); ?>" />
95
+ </p>
96
+ <p>
97
+ <label for="<?php echo $this->get_field_id( 'wysiwyg-widget-id' ); ?>"><?php _e( 'Widget Content:' ); ?></label>
98
+ <select id="<?php echo $this->get_field_id('wysiwyg-widget-id'); ?>" name="<?php echo $this->get_field_name( 'wysiwyg-widget-id' ); ?>">
99
+ <option value="0">Select a WYSIWYG Widget..</option>
100
+ <?php foreach($posts as $p) { ?>
101
+ <option value="<?php echo $p->ID; ?>" <?php if($p->ID == $selected_widget_id) echo 'selected="selected"'; ?>><?php echo $p->post_title; ?></option>
102
+ <?php } ?>
103
+ </select>
104
+ </p>
105
+ <?php
106
+ }
107
+ ?>
108
+ <p style="border: 2px solid green; font-weight:bold; background: #CFC; padding:5px; ">I spent countless hours developing (and offering support) for this plugin for FREE. If you like it, consider <a href="http://dannyvankooten.com/donate/">donating $10, $20 or $50</a> as a token of your appreciation.</p>
109
+ <?php
110
+ }
111
+
112
+ }
includes/class-wysiwyg-widgets.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WYSIWYG_Widgets
4
+ {
5
+
6
+ public function init()
7
+ {
8
+ add_action('init', array($this, 'on_init_action'));
9
+ add_action( 'widgets_init', array($this, 'register_widget'));
10
+ add_action( 'add_meta_boxes', array($this, 'add_meta_box' ) );
11
+ }
12
+
13
+ public function on_init_action()
14
+ {
15
+ $labels = array(
16
+ 'name' => 'WYSIWYG Widget',
17
+ 'singular_name' => 'WYSIWYG Widget',
18
+ 'add_new' => 'Add New',
19
+ 'add_new_item' => 'Add New WYSIWYG Widget',
20
+ 'edit_item' => 'Edit Widget',
21
+ 'new_item' => 'New Widget',
22
+ 'all_items' => 'All Widgets',
23
+ 'view_item' => 'View Widget',
24
+ 'search_items' => 'Search Widgets',
25
+ 'not_found' => 'No widgets found',
26
+ 'not_found_in_trash' => 'No widgets found in Trash',
27
+ 'parent_item_colon' => '',
28
+ 'menu_name' => ' WYSIWYG Widgets'
29
+ );
30
+ $args = array(
31
+ 'public' => true,
32
+ 'publicly_queryable' => false,
33
+ 'show_in_nav_menus' => false,
34
+ 'exclude_from_search' => true,
35
+ 'labels' => $labels,
36
+ 'has_archive' => false,
37
+ 'supports' => array('title', 'editor')
38
+ );
39
+ register_post_type( 'wysiwyg-widget', $args );
40
+
41
+ }
42
+
43
+ public function add_meta_box()
44
+ {
45
+ add_meta_box(
46
+ 'wysiwyg-widget-donate-box',
47
+ 'Donate a token of your appreciation',
48
+ array($this, 'meta_donate_box'),
49
+ 'wysiwyg-widget',
50
+ 'side',
51
+ 'low'
52
+ );
53
+ }
54
+
55
+ public function register_widget()
56
+ {
57
+ register_widget('WYSIWYG_Widgets_Widget');
58
+ }
59
+
60
+ public function meta_donate_box($post)
61
+ {
62
+ ?>
63
+ <p style="border: 2px solid green; font-weight:bold; background: #CFC; padding:5px; ">I spent countless hours developing (and offering support) for this plugin for FREE. If you like it, consider <a href="http://dannyvankooten.com/donate/">donating $10, $20 or $50</a> as a token of your appreciation.</p>
64
+ <?php
65
+ }
66
+ }
readme.txt ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: DvanKooten
3
+ Donate link: http://dannyvankooten.com/donate/
4
+ Tags: widget,wysiwyg,wysiwyg widget,rich text,rich text widget,widget editor,text widget,visual widget,image widget,tinymce,fckeditor
5
+ Requires at least: 3.1
6
+ Tested up to: 3.5
7
+ Stable tag: 2.0.1
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Easily create advanced, good looking widgets with rich text editing and media upload functionality.
12
+
13
+ == Description ==
14
+
15
+ = WYSIWYG Widgets or rich text widgets =
16
+
17
+ Don't you just miss the visual editor in WordPress' default text widgets? This plugin helps by letting you create rich text widgets just like you would create a post. You can use the visual editor to create beautiful HTML and even use the WordPress media upload functionality.
18
+
19
+ **BACKWARDS COMPATIBILITY DROPPED IN VERSION 2, PLEASE BACK-UP YOUR WYSIWYG WIDGETS BEFORE UPGRADING**
20
+
21
+ **Features:**
22
+
23
+ * Create stunning widget content without having to know any HTML
24
+ * Insert media like images or video into your widgets the way you are used to
25
+ * Create easy lists in your widgets
26
+ * Use WP Links dialog to easily link to any of your pages or posts from a widget
27
+ * Use shortcodes inside your widget to benefit from other WP Plugins.
28
+
29
+ **More info:**
30
+
31
+ * [WYSIWYG Widgets](http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/)
32
+ * Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/) by the same author
33
+ * Follow Danny on Twitter for lightning fast support and updates: [@DannyvanKooten](http://twitter.com/dannyvankooten)
34
+ * [Thank Danny for this plugin by donating $10, $20 or $50.](http://dannyvankooten.com/donate/)
35
+
36
+ == Installation ==
37
+
38
+ 1. Upload the contents of wysiwyg-widgets.zip to your plugins directory.
39
+ 1. Activate the plugin
40
+ 1. Create a WYSIWYG Widget "post" through the new menu item "WYSIWYG Widgets".
41
+ 1. Go to your Widgets page, drag an instance of the WYSIWYG Widgets widget to one of your widget areas and select which WYSIWYG Widget to display.
42
+ 1. Go to the front end of your website and enjoy your beautiful widget.
43
+
44
+ == Frequently Asked Questions ==
45
+
46
+ = What does this plugin do? =
47
+ This plugin creates a custom post type "Widgets" where you can create widgets just like you would create posts. You can then show these "widget posts" by dragging a "WYSIWYG Widget" widget to one of your widget areas.
48
+
49
+ = What does WYSIWYG stand for? =
50
+ What You See Is What You Get
51
+
52
+ = Can I switch between 'Visual' and 'HTML' mode with this plugin? =
53
+ Yes, all the default options that you are used to from the post editor are available for the widget editor.
54
+
55
+ = Will this plugin help me create widgets with images and links =
56
+ Yes, you won't need to write a single line of HTML.
57
+
58
+ = Is this plugin free? =
59
+ Totally free, and it will always stay free. Donations are much appreciated though, I put a lot of time and effort in my plugins. Consider [donating $10, $20 or $50](http://dannyvankooten.com/donate/) as a token of your appreciation.
60
+
61
+ == Screenshots ==
62
+
63
+ 1. Overview of created WYSIWYG Widgets
64
+ 2. Edit the content of a WYSIWYG Widget just like you are used to edit posts.
65
+ 3. Drag the WYSIWYG Widget widget to one of your widget areas and select the WYSIWYG Widget to show.
66
+
67
+ == Changelog ==
68
+
69
+ = 2.0.1 =
70
+ * Added: meta box in WYSIWYG Widget editor screen.
71
+ * Added: debug messages for logged in administrators on frontend when no WYSIWYG Widget OR an invalid WYSIWYG Widget is selected.
72
+ * Added: title is now optional for even more control. If empty, it won't be shown. You are now longer required to use the heading tag which is set in the widget options since you can use a heading in your post.
73
+
74
+ = 2.0 =
75
+ * Total rewrite WITHOUT backwards compatibility. Please back-up your existing WYSIWYG Widgets' content before updating, you'll need to recreate them. Don't drag them to "deactivated widgets", just copy & paste the HTML content somewhere.
76
+
77
+ = 1.2 =
78
+ * Updated the plugin for WP 3.3. Broke backwards compatibility (on purpose), so when running WP 3.2.x and below: stick with [version 1.1.1](http://downloads.wordpress.org/plugin/wysiwyg-widgets.zip).
79
+
80
+ = 1.1.2 =
81
+ * Temporary fix for WP 3.3+
82
+
83
+ = 1.1.1 =
84
+ * Fixed problem with link dialog reloading page upon submit
85
+
86
+ = 1.1 =
87
+ * Changed the way WYSIWYG Widget works, no more overlay, just a WYSIWYG editor in your widget form.
88
+ * Fixed full-screen mode
89
+ * Fixed link dialog for WP versions below 3.2
90
+ * Fixed strange browser compatibility bug
91
+ * Fixed inconstistent working
92
+ * Added the ability to use shortcodes in WYSIWYG Widget's text
93
+
94
+ = 1.0.7 =
95
+ * Fixed small bug that broke the WP link dialog for WP versions older then 3.2
96
+ * Fixed issue with lists and weird non-breaking spaces
97
+ * Added compatibility with Dean's FCKEditor for Wordpress plugin
98
+ * Improved JS
99
+
100
+ **NOTE**: In this version some things were changed regarding the auto-paragraphing. This is now being handled by TinyMCE instead of WordPress, so when updating please run trough your widgets to correct this. :)
101
+
102
+ = 1.0.6 =
103
+ * Added backwards compatibility for WP installs below version 3.2 Sorry for the quick push!
104
+
105
+ = 1.0.5 =
106
+ * Fixed issue for WP3.2 installs, wp_tiny_mce_preload_dialogs is no valid callback. Function got renamed.
107
+
108
+ = 1.0.4 =
109
+ * Cleaned up code
110
+ * Improved loading of TinyMCE
111
+ * Fixed issue with RTL installs
112
+
113
+ = 1.0.3 =
114
+ * Bugfix: Hided the #wp-link block, was appearing in footer on widgets.php page.
115
+ * Improvement: Removed buttons added by external plugins, most likely causing issues. (eg Jetpack)
116
+ * Improvement: Increase textarea size after opening WYSIWYG overlay.
117
+ * Improvement: Use 'escape' key to close WYSIWYG editor overlay without saving changes.
118
+
119
+ = 1.0.2 =
120
+ * Bugfix: Fixed undefined index in dvk-plugin-admin.php
121
+ * Bugfix: Removed `esc_textarea` which caused TinyMCE to break
122
+ * Improvement: Minor CSS and JS improvements, 'Send to widget' button is now always visible
123
+ * Improvement: Added a widget description
124
+ * Improvement: Now using the correct way to set widget form width and height
125
+
126
+ = 1.0.1 =
127
+ * Bugfix: Fixed the default title, it's now an empty string. ('')
128
+
129
+ = 1.0 =
130
+ * Initial release
131
+
132
+ == Upgrade Notice ==
133
+
134
+ = 2.0 =
135
+ No backwards compatibility, please back-up your existing widgets before upgrading!
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
wysiwyg-widgets.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WYSIWYG Widgets
4
+ Plugin URI: http://DannyvanKooten.com/wordpress-plugins/wysiwyg-widgets/
5
+ Description: Adds a WYSIWYG Widget with a rich text editor and media upload functions.
6
+ Version: 2.0.1
7
+ Author: Danny van Kooten
8
+ Author URI: http://DannyvanKooten.com
9
+ License: GPL2
10
+ */
11
+
12
+ /* Copyright 2011 Danny van Kooten (email : danny@vkimedia.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
+ published by the Free Software Foundation.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ require_once 'includes/class-wysiwyg-widgets.php';
29
+ require_once 'includes/class-wysiwyg-widgets-widget.php';
30
+
31
+ $WYSIWYG_Widgets = new WYSIWYG_Widgets();
32
+ $WYSIWYG_Widgets->init();