Black Studio TinyMCE Widget - Version 0.6

Version Description

  • Added support for Wordpress Media Library
Download this release

Release Info

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

Version 0.6

black-studio-tinymce-widget.css ADDED
@@ -0,0 +1,59 @@
1
+ /* CSS Document */
2
+
3
+ #mce_fullscreen_container {
4
+ background-color: white;
5
+ }
6
+ .editor_container {
7
+ border-color: #CCC #CCC #DFDFDF;
8
+ border-style: solid;
9
+ border-width: 1px;
10
+ border-collapse: separate;
11
+ -moz-border-radius: 3px 3px 0 0;
12
+ -webkit-border-top-right-radius: 3px;
13
+ -webkit-border-top-left-radius: 3px;
14
+ -khtml-border-top-right-radius: 3px;
15
+ -khtml-border-top-left-radius: 3px;
16
+ border-top-right-radius: 3px;
17
+ border-top-left-radius: 3px;
18
+ }
19
+ .editor_toggle_buttons {
20
+ height: 30px;
21
+ margin-right: 15px;
22
+ float: right;
23
+ }
24
+ .editor_toggle_buttons a {
25
+ height: 18px;
26
+ margin: 5px 5px 0 0;
27
+ padding: 4px 5px 2px;
28
+ float: right;
29
+ cursor: pointer;
30
+ border-width: 1px;
31
+ border-style: solid;
32
+ -moz-border-radius: 3px 3px 0 0;
33
+ -webkit-border-top-right-radius: 3px;
34
+ -webkit-border-top-left-radius: 3px;
35
+ -khtml-border-top-right-radius: 3px;
36
+ -khtml-border-top-left-radius: 3px;
37
+ border-top-right-radius: 3px;
38
+ border-top-left-radius: 3px;
39
+ background-color: #F1F1F1;
40
+ border-color: #DFDFDF #DFDFDF #CCC;
41
+ color: #999;
42
+ }
43
+ .editor_toggle_buttons a.active {
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 ADDED
@@ -0,0 +1,59 @@
1
+ // Activate visual editor
2
+ function black_studio_activate_visual_editor(id) {
3
+ jQuery('#'+id).addClass("mceEditor");
4
+ if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
5
+ black_studio_deactivate_visual_editor(id);
6
+ tinyMCE.execCommand("mceAddControl", false, id);
7
+ }
8
+ }
9
+ // Deactivate visual editor
10
+ function black_studio_deactivate_visual_editor(id) {
11
+ if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
12
+ if (typeof(tinyMCE.get(id)) == "object") {
13
+ tinyMCE.execCommand("mceRemoveControl", false, id);
14
+ }
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
34
+ jQuery('input[id^=widget-black-studio-tinymce][id$=savewidget]').live('click', function(){
35
+ txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
36
+ editor = tinyMCE.get(txt_area.attr('id'));
37
+ if (typeof(editor) == "object") {
38
+ content = editor.getContent()
39
+ txt_area.val(content);
40
+ }
41
+ return true;
42
+ });
43
+ // Event handler for visual switch button
44
+ jQuery('a[id^=widget-black-studio-tinymce][id$=visual]').live('click', function(){
45
+ jQuery(this).addClass('active');
46
+ jQuery('a[id^=widget-black-studio-tinymce][id$=html]', jQuery(this).parents('div.widget')).removeClass('active');
47
+ jQuery('input[id^=widget-black-studio-tinymce][id$=type]', jQuery(this).parents('div.widget')).val('visual');
48
+ black_studio_activate_visual_editor(jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget')).attr('id'));
49
+ return false;
50
+ });
51
+ // Event handler for html switch button
52
+ jQuery('a[id^=widget-black-studio-tinymce][id$=html]').live('click', function(){
53
+ jQuery(this).addClass('active');
54
+ jQuery('a[id^=widget-black-studio-tinymce][id$=visual]', jQuery(this).parents('div.widget')).removeClass('active');
55
+ jQuery('input[id^=widget-black-studio-tinymce][id$=type]', jQuery(this).parents('div.widget')).val('html');
56
+ black_studio_deactivate_visual_editor(jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget')).attr('id'));
57
+ return false;
58
+ });
59
+ });
black-studio-tinymce-widget.php ADDED
@@ -0,0 +1,131 @@
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
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
+
15
+ function __construct() {
16
+ $widget_ops = array('classname' => 'widget_black_studio_tinymce', 'description' => __('Arbitrary text or HTML with visual editor', 'black-studio-tinymce-widget'));
17
+ $control_ops = array('width' => 600, 'height' => 500);
18
+ parent::__construct('black-studio-tinymce', __('Black Studio TinyMCE', 'black-studio-tinymce-widget'), $widget_ops, $control_ops);
19
+ }
20
+
21
+ function widget( $args, $instance ) {
22
+ extract($args);
23
+ $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
24
+ $text = apply_filters( 'widget_text', $instance['text'], $instance );
25
+ echo $before_widget;
26
+ if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
27
+ <div class="textwidget"><?php echo $text; ?></div>
28
+ <?php
29
+ echo $after_widget;
30
+ }
31
+
32
+ function update( $new_instance, $old_instance ) {
33
+ $instance = $old_instance;
34
+ $instance['title'] = strip_tags($new_instance['title']);
35
+ if ( current_user_can('unfiltered_html') )
36
+ $instance['text'] = $new_instance['text'];
37
+ else
38
+ $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
39
+ $instance['type'] = strip_tags($new_instance['type']);
40
+ return $instance;
41
+ }
42
+
43
+ function form( $instance ) {
44
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'type' => 'visual' ) );
45
+ $title = strip_tags($instance['title']);
46
+ $text = esc_textarea($instance['text']);
47
+ $type = esc_textarea($instance['type']);
48
+ ?>
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
+ }
74
+
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']);
89
+ }
90
+ if (!isset($plugins['fullscreen'])) {
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
+
100
+ /* Widget initialization */
101
+ add_action('widgets_init', 'black_studio_tinymce_init');
102
+ function black_studio_tinymce_init() {
103
+ if ( !is_blog_installed() )
104
+ return;
105
+ register_widget('WP_Widget_Black_Studio_TinyMCE');
106
+ }
107
+
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-it_IT.mo ADDED
Binary file
languages/black-studio-tinymce-widget-it_IT.po ADDED
@@ -0,0 +1,26 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Black Studio TinyMCE Widget\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:15+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"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-Language: Italian\n"
15
+ "X-Poedit-Country: ITALY\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: black-studio-tinymce-widget.php:17
20
+ msgid "Arbitrary text or HTML with visual editor"
21
+ msgstr "Testo o HTML libero con editor visuale"
22
+
23
+ #: black-studio-tinymce-widget.php:19
24
+ msgid "Black Studio TinyMCE"
25
+ msgstr "Black Studio TinyMCE"
26
+
languages/black-studio-tinymce-widget.pot ADDED
@@ -0,0 +1,26 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Black Studio TinyMCE Widget\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"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-Language: Italian\n"
15
+ "X-Poedit-Country: ITALY\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: black-studio-tinymce-widget.php:17
20
+ msgid "Arbitrary text or HTML with visual editor"
21
+ msgstr ""
22
+
23
+ #: black-studio-tinymce-widget.php:19
24
+ msgid "Black Studio TinyMCE"
25
+ msgstr ""
26
+
readme.txt ADDED
@@ -0,0 +1,41 @@
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
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 =
38
+ * Added support for Wordpress Media Library
39
+
40
+ = 0.5 =
41
+ * First Beta Release
screenshot-1.png ADDED
Binary file