Black Studio TinyMCE Widget - Version 0.6.1

Version Description

  • Fixed Javascript issue preventing editor to show up in some cases
Download this release

Release Info

Developer marcochiesi
Plugin Icon 128x128 Black Studio TinyMCE Widget
Version 0.6.1
Comparing to
See all releases

Code changes from version 0.5 to 0.6.1

black-studio-tinymce-widget.css CHANGED
@@ -19,6 +19,7 @@
19
.editor_toggle_buttons {
20
height: 30px;
21
margin-right: 15px;
22
}
23
.editor_toggle_buttons a {
24
height: 18px;
@@ -43,4 +44,16 @@
43
border-color: #CCC #CCC #E9E9E9;
44
background-color: #E9E9E9;
45
color: #333;
46
}
19
.editor_toggle_buttons {
20
height: 30px;
21
margin-right: 15px;
22
+ float: right;
23
}
24
.editor_toggle_buttons a {
25
height: 18px;
44
border-color: #CCC #CCC #E9E9E9;
45
background-color: #E9E9E9;
46
color: #333;
47
+ }
48
+ .editor_media_buttons {
49
+ cursor: default;
50
+ padding: 8px 8px 0;
51
+ height: 22px;
52
+ }
53
+ .editor_media_buttons a {
54
+ cursor: pointer;
55
+ padding: 0 0 5px 10px;
56
+ }
57
+ .editor_media_buttons img {
58
+ vertical-align: middle;
59
}
black-studio-tinymce-widget.js CHANGED
@@ -15,19 +15,24 @@ function black_studio_deactivate_visual_editor(id) {
15
}
16
}
17
// Show editor (used upon opening the widget)
18
- function black_studio_show_visual_editor() {
19
- jQuery('input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
20
- txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
21
- if (!txt_area.is(':hidden')) {
22
jQuery('a[id^=widget-black-studio-tinymce][id$=visual]', jQuery(this).parents('div.widget')).click();
23
}
24
});
25
}
26
27
jQuery(document).ready(function(){
28
// Event handler for widget opening button
29
jQuery('div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action').live('click', function(){
30
- setTimeout(black_studio_show_visual_editor, 500); // This is delayed to let the animation be completed
31
return false;
32
});
33
// Event handler for widget saving button
15
}
16
}
17
// Show editor (used upon opening the widget)
18
+ function black_studio_deferred_show_visual_editor(id) {
19
+ jQuery('div.widget:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
20
+ // If textarea is visible and animation has completed then trigger a click to Visual button and enable the editor
21
+ if (typeof(tinyMCE.get(id)) != "object" && jQuery('div.widget:has(#' + id + ') :animated').size() == 0 && jQuery('#' + id).is(':visible')) {
22
jQuery('a[id^=widget-black-studio-tinymce][id$=visual]', jQuery(this).parents('div.widget')).click();
23
}
24
+ // Otherwise wait and retry later (animation ongoing)
25
+ else {
26
+ setTimeout(function(){black_studio_deferred_show_visual_editor(id);id=null;}, 100);
27
+ }
28
});
29
}
30
31
jQuery(document).ready(function(){
32
// Event handler for widget opening button
33
jQuery('div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action').live('click', function(){
34
+ txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
35
+ black_studio_deferred_show_visual_editor(txt_area.attr('id'));
36
return false;
37
});
38
// Event handler for widget saving button
black-studio-tinymce-widget.php CHANGED
@@ -1,15 +1,14 @@
1
<?php
2
/*
3
Plugin Name: Black Studio TinyMCE Widget
4
- Plugin URI: http://www.blackstudio.it
5
- Description: This plugins adds a new widget type, which allows you to insert html rich text using the visual TinyMCE editor in a WYSIWYG way.
6
- Version: 0.5
7
Author: Black Studio
8
Author URI: http://www.blackstudio.it
9
License: GPL2
10
*/
11
12
-
13
/* Widget class */
14
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
15
@@ -50,22 +49,25 @@ class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
50
<input id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>" type="hidden" value="<?php echo esc_attr($type); ?>" />
51
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
52
<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>
53
- <div class="editor_toggle_buttons">
54
<a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-html"<?php if ($type == 'html') {?> class="active"<?php }?>><?php _e('HTML'); ?></a>
55
<a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-visual"<?php if($type == 'visual') {?> class="active"<?php }?>><?php _e('Visual'); ?></a>
56
</div>
57
<div class="editor_container">
58
<textarea class="widefat" rows="16" cols="40" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
59
</div>
60
<?php
61
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && $type == 'visual') {
62
- ?>
63
- <script type="text/javascript" language="javascript">
64
- /* <![CDATA[ */
65
- black_studio_activate_visual_editor('<?php echo $this->get_field_id('text'); ?>');
66
- /* ]]> */
67
- </script>
68
- <?php
69
}
70
}
71
}
@@ -73,14 +75,14 @@ class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
73
/* Instantiate tinyMCE editor */
74
add_action('admin_head', 'black_studio_tinymce_load_tiny_mce');
75
function black_studio_tinymce_load_tiny_mce() {
76
- remove_all_filters('mce_external_plugins');
77
- wp_tiny_mce(false, array('height' => 350));
78
}
79
80
/* tinyMCE setup customization */
81
add_filter('tiny_mce_before_init', 'black_studio_tinymce_init_editor');
82
function black_studio_tinymce_init_editor($initArray) {
83
- // Remove WP fullscreen mode and set the native tinyMCE one
84
$plugins = explode(',', $initArray['plugins']);
85
if (isset($plugins['wpfullscreen'])) {
86
unset($plugins['wpfullscreen']);
@@ -89,9 +91,9 @@ function black_studio_tinymce_init_editor($initArray) {
89
$plugins[] = 'fullscreen';
90
}
91
$initArray['plugins'] = implode(',', $plugins);
92
- // add "image" button and remove "more"
93
- $initArray['theme_advanced_buttons1'] = str_replace("wp_more", "image", $initArray['theme_advanced_buttons1']);
94
- // return modified settings
95
return $initArray;
96
}
97
@@ -106,16 +108,24 @@ function black_studio_tinymce_init() {
106
/* Widget js loading */
107
add_action("admin_print_scripts", "black_studio_tinymce_scripts");
108
function black_studio_tinymce_scripts() {
109
- wp_enqueue_script('tiny_mce');
110
- wp_enqueue_script('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.js', __FILE__));
111
}
112
113
/* Widget css loading */
114
add_action("admin_print_styles", "black_studio_tinymce_styles");
115
function black_studio_tinymce_styles() {
116
wp_enqueue_style('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.css', __FILE__));
117
}
118
119
- /* Load translations */
120
load_plugin_textdomain('black-studio-tinymce-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
121
?>
1
<?php
2
/*
3
Plugin Name: Black Studio TinyMCE Widget
4
+ Plugin URI: http://wordpress.org/extend/plugins/black-studio-tinymce-widget/
5
+ Description: Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
6
+ Version: 0.6.1
7
Author: Black Studio
8
Author URI: http://www.blackstudio.it
9
License: GPL2
10
*/
11
12
/* Widget class */
13
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
14
49
<input id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>" type="hidden" value="<?php echo esc_attr($type); ?>" />
50
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
51
<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>
52
+ <div class="editor_toggle_buttons hide-if-no-js">
53
<a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-html"<?php if ($type == 'html') {?> class="active"<?php }?>><?php _e('HTML'); ?></a>
54
<a id="widget-<?php echo $this->id_base; ?>-<?php echo $this->number; ?>-visual"<?php if($type == 'visual') {?> class="active"<?php }?>><?php _e('Visual'); ?></a>
55
</div>
56
+ <div class="editor_media_buttons hide-if-no-js">
57
+ <?php do_action( 'media_buttons' ); ?>
58
+ </div>
59
<div class="editor_container">
60
<textarea class="widefat" rows="16" cols="40" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
61
</div>
62
<?php
63
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && $type == 'visual') {
64
+ ?>
65
+ <script type="text/javascript" language="javascript">
66
+ /* <![CDATA[ */
67
+ black_studio_activate_visual_editor('<?php echo $this->get_field_id('text'); ?>');
68
+ /* ]]> */
69
+ </script>
70
+ <?php
71
}
72
}
73
}
75
/* Instantiate tinyMCE editor */
76
add_action('admin_head', 'black_studio_tinymce_load_tiny_mce');
77
function black_studio_tinymce_load_tiny_mce() {
78
+ //remove_all_filters('mce_external_plugins');
79
+ wp_tiny_mce(false, array());
80
}
81
82
/* tinyMCE setup customization */
83
add_filter('tiny_mce_before_init', 'black_studio_tinymce_init_editor');
84
function black_studio_tinymce_init_editor($initArray) {
85
+ // Remove WP fullscreen mode and set the native tinyMCE fullscreen mode
86
$plugins = explode(',', $initArray['plugins']);
87
if (isset($plugins['wpfullscreen'])) {
88
unset($plugins['wpfullscreen']);
91
$plugins[] = 'fullscreen';
92
}
93
$initArray['plugins'] = implode(',', $plugins);
94
+ // Remove the "More" toolbar button
95
+ $initArray['theme_advanced_buttons1'] = str_replace(',wp_more', '', $initArray['theme_advanced_buttons1']);
96
+ // Return modified settings
97
return $initArray;
98
}
99
108
/* Widget js loading */
109
add_action("admin_print_scripts", "black_studio_tinymce_scripts");
110
function black_studio_tinymce_scripts() {
111
+ add_thickbox();
112
+ wp_enqueue_script('media-upload');
113
+ wp_enqueue_script('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.js', __FILE__), array('jquery', 'editor', 'thickbox', 'media-upload'));
114
}
115
116
/* Widget css loading */
117
add_action("admin_print_styles", "black_studio_tinymce_styles");
118
function black_studio_tinymce_styles() {
119
+ wp_enqueue_style('thickbox');
120
wp_enqueue_style('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.css', __FILE__));
121
}
122
123
+ /* Preload WP editor dialogs */
124
+ add_action( 'admin_print_footer_scripts', 'black_studio_tinymce_preload_dialogs');
125
+ function black_studio_tinymce_preload_dialogs() {
126
+ wp_preload_dialogs( array( 'plugins' => 'wpdialogs,wplink,wpfullscreen' ) );
127
+ }
128
+
129
+ /* Load localization */
130
load_plugin_textdomain('black-studio-tinymce-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
131
?>
languages/black-studio-tinymce-widget.pot CHANGED
@@ -4,7 +4,7 @@ msgstr ""
4
"Report-Msgid-Bugs-To: \n"
5
"POT-Creation-Date: 2011-11-10 17:15+0100\n"
6
"PO-Revision-Date: 2011-11-10 17:21+0100\n"
7
- "Last-Translator: Marco <marco@blackstudio.it>\n"
8
"Language-Team: Black Studio <info@blackstudio.it>\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=UTF-8\n"
4
"Report-Msgid-Bugs-To: \n"
5
"POT-Creation-Date: 2011-11-10 17:15+0100\n"
6
"PO-Revision-Date: 2011-11-10 17:21+0100\n"
7
+ "Last-Translator: Marco Chiesi <marco@blackstudio.it>\n"
8
"Language-Team: Black Studio <info@blackstudio.it>\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=UTF-8\n"
readme.txt CHANGED
@@ -1,27 +1,44 @@
1
=== Black Studio TinyMCE Widget ===
2
Contributors: marcochiesi, thedarkmist
3
Donate link: http://www.blackstudio.it/pagamento/
4
- Tags: wysiwyg widget, html widget, editor widget, rich text widget, enhanced text widget, tinymce widget, wysiwyg
5
Requires at least: 3.2.0
6
Tested up to: 3.2.1
7
- Stable tag: 0.5
8
9
- Adds a WYSIWYG widget based on the standard TinyMCE WordPress editor.
10
11
== Description ==
12
- This plugin adds a WYSIWYG widget based on the standard TinyMCE WordPress editor. This is intended to overcome the limitations of the standard WordPress text widget so you can visually write rich text contents, and also visually insert media from the Media Library.
13
14
== Installation ==
15
16
This section describes how to install the plugin and get it working.
17
18
- 1. Upload the entire black-studio-tinymce-widget folder to the /wp-content/plugins/ directory
19
2. Activate the plugin through the 'Plugins' menu in WordPress
20
- 3. Go Widget Screen
21
4. Drag Widget to desired sidebar
22
- 5. Fill in the widget
23
24
== Changelog ==
25
26
= 0.5 =
27
- * Beta Release
1
=== Black Studio TinyMCE Widget ===
2
Contributors: marcochiesi, thedarkmist
3
Donate link: http://www.blackstudio.it/pagamento/
4
+ Tags: wysiwyg, widget, tinymce, editor, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, visual editor widget
5
Requires at least: 3.2.0
6
Tested up to: 3.2.1
7
+ Stable tag: 0.6.1
8
9
+ Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
10
11
== Description ==
12
+ This plugin adds a WYSIWYG text widget based on the standard TinyMCE WordPress editor. This is intended to overcome the limitations of the default WordPress text widget, so that you can visually add rich text contents to your sidebars.
13
+
14
+ = Features =
15
+
16
+ * Add rich text widgets to your sidebar using visual editor
17
+ * Ability to switch between Visual mode and HTML mode
18
+ * Add items from Wordpress Media Library
19
+ * Fullscreen editing mode supported
20
21
== Installation ==
22
23
This section describes how to install the plugin and get it working.
24
25
+ 1. Upload the entire `black-studio-tinymce-widget` folder to the `/wp-content/plugins/` directory
26
2. Activate the plugin through the 'Plugins' menu in WordPress
27
+ 3. Go to Widgets Screen
28
4. Drag Widget to desired sidebar
29
+ 5. Fill in the widget title and text
30
+
31
+ == Screenshots ==
32
+
33
+ 1. A screenshot of the TinyMCE Widget
34
35
== Changelog ==
36
37
+ = 0.6.1 =
38
+ * Fixed Javascript issue preventing editor to show up in some cases
39
+
40
+ = 0.6 =
41
+ * Added support for Wordpress Media Library
42
+
43
= 0.5 =
44
+ * First Beta Release
screenshot-1.png ADDED
Binary file