Rich Text Tags - Version 1.4

Version Description

  • Improved functionality in WordPress 3.2.1
  • Fixed First argument is expected to be a valid callback, 'wp_tiny_mce_preload_dialogs' error (issue 625561 and 603480
  • Improved plugin layout on main taxonomy page
Download this release

Release Info

Developer katzwebdesign
Plugin Icon 128x128 Rich Text Tags
Version 1.4
Comparing to
See all releases

Code changes from version 1.3.3 to 1.4

Files changed (3) hide show
  1. kws_rt_taxonomy.js +36 -8
  2. readme.txt +11 -1
  3. rich-text-tags.php +56 -54
kws_rt_taxonomy.js CHANGED
@@ -3,18 +3,46 @@
3
  //this is for compatability with cforms
4
  var purl = '';
5
 
6
- jQuery(document).ready(function($) {
7
-
8
- $("textarea#description, textarea#category_description").attr('id', 'content');
9
- $("label[for='description'], label[for='category_description']").attr('for', 'content');
10
-
11
  // Add the Rich Text Editor to the "description" textarea
12
  tinyMCE.execCommand('mceAddControl',false,'content');
13
- tinyMCE.settings['save_callback'] = function (e,c,body) { return c; }
 
 
 
 
 
 
 
14
 
15
- $('label[for="content"]').parent().append('<div id="toggleRichText" class="hide-if-no-js"><p><a href="#">Toggle Rich Text Editor</a></p></div>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- $('#toggleRichText').click(function(e) {
18
  e.preventDefault();
19
  tinyMCE.execCommand('mceToggleEditor',false,'content');
20
  return false;
3
  //this is for compatability with cforms
4
  var purl = '';
5
 
6
+ jQuery(document).ready(function($) {
7
+
 
 
 
8
  // Add the Rich Text Editor to the "description" textarea
9
  tinyMCE.execCommand('mceAddControl',false,'content');
10
+
11
+ if($().prop) {
12
+ $("textarea#description,textarea#tag-description,textarea#category_description").prop('id', 'content');
13
+ $("label[for='description'],label[for='tag-description'],label[for='category_description']").prop('for', 'content');
14
+ } else {
15
+ $("textarea#description,textarea#tag-description,textarea#category_description").attr('id', 'content');
16
+ $("label[for='description'],label[for='tag-description'],label[for='category_description']").attr('for', 'content');
17
+ }
18
 
19
+ // We do this the right way on the Update (Edit) page.
20
+ if($('.wp-list-table').length === 0) {
21
+ tinyMCE.settings['save_callback'] = function (e,c,body) { return c; }
22
+ $('label[for="content"]').parent().append('<div id="toggleRichText" class="hide-if-no-js"><p><a href="#">Toggle Rich Text Editor</a></p></div>');
23
+ } else { // Otherwise, we hack it.
24
+
25
+ $('label[for="content"]').append('<a id="toggleRichText" class="hide-if-no-js alignright" href="#">Toggle Rich Text Editor</a>');
26
+
27
+ // We've added an invalid element to trap the submission process
28
+ $('#addtag').prepend('<div class="form-field form-required hide-if-js"><input aria-required="true" type="hidden" id="richtextadded" /></div>');
29
+
30
+ $('#submit').click(function(){
31
+
32
+ $('#wpbody form textarea').html(tinyMCE.activeEditor.getContent({format : 'raw'}));
33
+
34
+ $('#richtextadded').val('1').removeClass('form-invalid');
35
+ if(validateForm($(this).parents('form'))) {
36
+ if($('table.wp-list-table.widefat').length > 0) {
37
+ tinyMCE.activeEditor.setContent('<p><br data-mce-bogus="1"></p>',{format : 'raw'});
38
+ }
39
+ } else {
40
+ $('#richtextadded').val('').addClass('form-invalid');
41
+ }
42
+ });
43
+ }
44
 
45
+ $('#toggleRichText').click(function(e) {
46
  e.preventDefault();
47
  tinyMCE.execCommand('mceToggleEditor',false,'content');
48
  return false;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: katzwebdesign
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=zackkatz%40gmail%2ecom&item_name=Rich%20Text%20Tags&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
  Tags: tag, tags, taxonomy, taxonomies, category, categories, category description, rich text category, editor, rich text, description, tag description, taxonomy description, rich text, wysiwyg, tinyMCE, SEO, search engine optimization
5
  Requires at least: 2.6
6
- Tested up to: 3.1.2
7
  Stable tag: trunk
8
 
9
  The Rich Text Tags Plugin allows you to edit tag, category, and taxonomy descriptions using Wordpress' built in WYSIWYG editor.
@@ -35,6 +35,11 @@ Use the PHP functions `tag_description()` and `category_description()` in your t
35
 
36
  == Upgrade Notice ==
37
 
 
 
 
 
 
38
  = 1.3.3 =
39
  * Fixed issue <a href="http://wordpress.org/support/topic/537590">#537590</a>, where the rich text editor's link button wouldn't work. Thanks to <a href="http://wordpress.org/support/profile/deannas" rel="nofollow">DeannaS</a>
40
 
@@ -62,6 +67,11 @@ Use the PHP functions `tag_description()` and `category_description()` in your t
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
65
  = 1.3.3 =
66
  * Fixed issue <a href="http://wordpress.org/support/topic/537590">#537590</a>, where the rich text editor's link button wouldn't work. Thanks to <a href="http://wordpress.org/support/profile/deannas" rel="nofollow">DeannaS</a>
67
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=zackkatz%40gmail%2ecom&item_name=Rich%20Text%20Tags&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
  Tags: tag, tags, taxonomy, taxonomies, category, categories, category description, rich text category, editor, rich text, description, tag description, taxonomy description, rich text, wysiwyg, tinyMCE, SEO, search engine optimization
5
  Requires at least: 2.6
6
+ Tested up to: 3.2.1
7
  Stable tag: trunk
8
 
9
  The Rich Text Tags Plugin allows you to edit tag, category, and taxonomy descriptions using Wordpress' built in WYSIWYG editor.
35
 
36
  == Upgrade Notice ==
37
 
38
+ = 1.4 =
39
+ * Improved functionality in WordPress 3.2.1
40
+ * Fixed `First argument is expected to be a valid callback, 'wp_tiny_mce_preload_dialogs'` error (<a href="http://wordpress.org/support/topic/625561">issue <a href="http://wordpress.org/support/topic/625561">625561</a> and <a href="http://wordpress.org/support/topic/603480">603480</a>
41
+ * Improved plugin layout on main taxonomy page
42
+
43
  = 1.3.3 =
44
  * Fixed issue <a href="http://wordpress.org/support/topic/537590">#537590</a>, where the rich text editor's link button wouldn't work. Thanks to <a href="http://wordpress.org/support/profile/deannas" rel="nofollow">DeannaS</a>
45
 
67
 
68
  == Changelog ==
69
 
70
+ = 1.4 =
71
+ * Improved functionality in WordPress 3.2.1
72
+ * Fixed `First argument is expected to be a valid callback, 'wp_tiny_mce_preload_dialogs'` error (<a href="http://wordpress.org/support/topic/625561">issue <a href="http://wordpress.org/support/topic/625561">625561</a> and <a href="http://wordpress.org/support/topic/603480">603480</a>
73
+ * Improved plugin layout on main taxonomy page
74
+
75
  = 1.3.3 =
76
  * Fixed issue <a href="http://wordpress.org/support/topic/537590">#537590</a>, where the rich text editor's link button wouldn't work. Thanks to <a href="http://wordpress.org/support/profile/deannas" rel="nofollow">DeannaS</a>
77
 
rich-text-tags.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Rich Text Tags, Categories, and Taxonomies
4
  Plugin URI: http://www.seodenver.com/rich-text-tags/
5
  Description: This plugin offers rich text editing capabilities for descriptions of tags, categories, and taxonomies.
6
  Author: Katz Web Services, Inc.
7
- Version: 1.3.3
8
  Author URI: http://www.katzwebservices.com
9
  */
10
  /*
@@ -37,18 +37,18 @@ Author URI: http://www.katzwebservices.com
37
  add_action('plugins_loaded', 'kws_rich_text_tags');
38
  function kws_rich_text_tags() {
39
 
40
- global $wpdb, $user, $current_user;
41
 
42
  // ADD EVENTS
43
  if(
44
- $GLOBALS['pagenow'] == 'edit-tags.php' && $_REQUEST['action'] == 'edit' ||
45
- $GLOBALS['pagenow'] == 'categories.php' && $_REQUEST['action'] == 'edit' //(!isset($_REQUEST['action']) || $_REQUEST['action'] == 'edit')
46
  ) {
47
  if(!user_can_richedit()) { return; }
48
 
49
  wp_enqueue_script('post');
50
  //if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
51
- if(floatval($GLOBALS['wp_version']) >= 2.7) {
52
  // wp_enqueue_script('tiny_mce');
53
  wp_enqueue_script('jquery');
54
  wp_enqueue_script('thickbox');
@@ -61,63 +61,34 @@ function kws_rich_text_tags() {
61
  add_filter( 'tiny_mce_before_init', 'kws_rt_tinymce_settings');
62
 
63
  // Thanks, DeannaS!
64
- add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 );
 
 
65
 
66
  wp_enqueue_script('media');
67
- wp_enqueue_script( 'postbox' );
68
  wp_enqueue_script('media-upload');
69
  wp_enqueue_script('swfupload-all');
70
  wp_enqueue_script('swfupload-handlers');
71
 
72
  add_action('init','kws_rt_taxonomy_load_mce');
73
  add_action('wp_print_scripts','kws_rt_taxonomy_scripts');
74
- } elseif(
75
- $GLOBALS['pagenow'] == 'edit-tags.php' ||
76
- $GLOBALS['pagenow'] == 'categories.php'
77
- ) {
78
- add_filter('get_terms', 'kws_shorten_term_description');
79
- }
80
-
81
- function kws_wp_trim_excerpt($text) {
82
- $raw_excerpt = $text;
83
-
84
- # $text = strip_shortcodes( $text );
85
- # $text = apply_filters('the_content', $text);
86
- $text = str_replace(']]>', ']]&gt;', $text);
87
- # $text = strip_tags($text);
88
- $excerpt_length = apply_filters('term_excerpt_length', 40);
89
- $excerpt_more = ' ' . '[...]';
90
- $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
91
- if ( count($words) > $excerpt_length ) {
92
- array_pop($words);
93
- $text = implode(' ', $words);
94
- $text = $text . $excerpt_more;
95
- } else {
96
- $text = implode(' ', $words);
97
- }
98
- return apply_filters('wp_trim_term_excerpt', force_balance_tags($text), $raw_excerpt);
99
- }
100
-
101
- function kws_shorten_term_description($terms = array(), $taxonomies = null, $args = array()) {
102
- if(is_array($terms)) {
103
- foreach($terms as $key=>$term) {
104
- if(is_object($term) && isset($term->description)) {
105
- $term->description = kws_wp_trim_excerpt($term->description);
106
- }
107
- }
108
  }
109
- return $terms;
110
  }
111
 
112
 
113
- if($GLOBALS['pagenow'] == 'edit-tags.php' && $_REQUEST['action'] == 'edit') {
114
- if(isset($_REQUEST['taxonomy'])) {
115
- add_action(esc_attr($_REQUEST['taxonomy']).'_edit_form_fields', 'kws_show_media_upload');
116
- } else {
117
- add_action('edit_tag_form_fields','kws_show_media_upload'); // Add link to disable Rich Text
118
- add_action('edit_term','kws_rt_taxonomy_save');
119
- }
120
- // add_action( 'media_buttons', 'media_buttons' );
121
  }
122
 
123
  // Enable shortcodes in category, taxonomy, tag descriptions
@@ -129,7 +100,7 @@ function kws_rich_text_tags() {
129
 
130
  add_action('init', 'kws_rt_remove_filter');
131
 
132
- if($GLOBALS['pagenow'] == 'categories.php' && $_REQUEST['action'] == 'edit') { // (!isset($_REQUEST['action']) || $_REQUEST['action'] == 'edit')) {
133
  add_action('edit_category_form_fields','kws_show_media_upload'); // Add link to disable Rich Text
134
  add_action('edit_category','kws_rt_category_save');
135
  }
@@ -143,7 +114,7 @@ function kws_rich_text_tags() {
143
  }
144
  function kws_rt_taxonomy_scripts() {
145
  global $pagenow;
146
- if( $pagenow == 'edit-tags.php' && $_REQUEST['action'] == 'edit' ||
147
  $pagenow == 'categories.php' && $_REQUEST['action'] == 'edit') {
148
  echo '<link rel="stylesheet" href="'.WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'kws_rt_taxonomy.css" type="text/css" media="all" />' . "\n";
149
  }
@@ -198,9 +169,9 @@ EOF;
198
 
199
  function kws_rt_tinymce_settings($array = array()) {
200
  global $pagenow;
201
- if( $pagenow == 'edit-tags.php' && $_REQUEST['action'] == 'edit' ||
202
  $pagenow == 'categories.php' && $_REQUEST['action'] == 'edit') {
203
- if( $pagenow == 'edit-tags.php' && $_REQUEST['action'] == 'edit' ) {
204
  $array['editor_selector'] = 'description';
205
  } else {
206
  $array['editor_selector'] = 'category_description';
@@ -220,4 +191,35 @@ EOF;
220
  }
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  ?>
4
  Plugin URI: http://www.seodenver.com/rich-text-tags/
5
  Description: This plugin offers rich text editing capabilities for descriptions of tags, categories, and taxonomies.
6
  Author: Katz Web Services, Inc.
7
+ Version: 1.4
8
  Author URI: http://www.katzwebservices.com
9
  */
10
  /*
37
  add_action('plugins_loaded', 'kws_rich_text_tags');
38
  function kws_rich_text_tags() {
39
 
40
+ global $wpdb, $user, $current_user, $pagenow, $wp_version;
41
 
42
  // ADD EVENTS
43
  if(
44
+ $pagenow == 'edit-tags.php' ||
45
+ $pagenow == 'categories.php'
46
  ) {
47
  if(!user_can_richedit()) { return; }
48
 
49
  wp_enqueue_script('post');
50
  //if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
51
+ if(floatval($wp_version) >= 2.7) {
52
  // wp_enqueue_script('tiny_mce');
53
  wp_enqueue_script('jquery');
54
  wp_enqueue_script('thickbox');
61
  add_filter( 'tiny_mce_before_init', 'kws_rt_tinymce_settings');
62
 
63
  // Thanks, DeannaS!
64
+ if(function_exists('wp_tiny_mce_preload_dialogs')) {
65
+ add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 );
66
+ }
67
 
68
  wp_enqueue_script('media');
69
+ wp_enqueue_script('postbox');
70
  wp_enqueue_script('media-upload');
71
  wp_enqueue_script('swfupload-all');
72
  wp_enqueue_script('swfupload-handlers');
73
 
74
  add_action('init','kws_rt_taxonomy_load_mce');
75
  add_action('wp_print_scripts','kws_rt_taxonomy_scripts');
76
+
77
+ if(empty($_REQUEST['action'])) {
78
+ add_filter('get_terms', 'kws_shorten_term_description');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
+
81
  }
82
 
83
 
84
+ if($pagenow == 'edit-tags.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
85
+ if(isset($_REQUEST['taxonomy'])) {
86
+ add_action(esc_attr($_REQUEST['taxonomy']).'_edit_form_fields', 'kws_show_media_upload');
87
+ } else {
88
+ add_action('edit_tag_form_fields','kws_show_media_upload'); // Add link to disable Rich Text
89
+ add_action('edit_term','kws_rt_taxonomy_save');
90
+ }
91
+ // add_action( 'media_buttons', 'media_buttons' );
92
  }
93
 
94
  // Enable shortcodes in category, taxonomy, tag descriptions
100
 
101
  add_action('init', 'kws_rt_remove_filter');
102
 
103
+ if($pagenow == 'categories.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { // (!isset($_REQUEST['action']) || $_REQUEST['action'] == 'edit')) {
104
  add_action('edit_category_form_fields','kws_show_media_upload'); // Add link to disable Rich Text
105
  add_action('edit_category','kws_rt_category_save');
106
  }
114
  }
115
  function kws_rt_taxonomy_scripts() {
116
  global $pagenow;
117
+ if( $pagenow == 'edit-tags.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit' ||
118
  $pagenow == 'categories.php' && $_REQUEST['action'] == 'edit') {
119
  echo '<link rel="stylesheet" href="'.WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'kws_rt_taxonomy.css" type="text/css" media="all" />' . "\n";
120
  }
169
 
170
  function kws_rt_tinymce_settings($array = array()) {
171
  global $pagenow;
172
+ if( $pagenow == 'edit-tags.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit' ||
173
  $pagenow == 'categories.php' && $_REQUEST['action'] == 'edit') {
174
+ if( $pagenow == 'edit-tags.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit' ) {
175
  $array['editor_selector'] = 'description';
176
  } else {
177
  $array['editor_selector'] = 'category_description';
191
  }
192
  }
193
 
194
+ function kws_wp_trim_excerpt($text) {
195
+ $raw_excerpt = $text;
196
+
197
+ # $text = strip_shortcodes( $text );
198
+ # $text = apply_filters('the_content', $text);
199
+ $text = str_replace(']]>', ']]&gt;', $text);
200
+ # $text = strip_tags($text);
201
+ $excerpt_length = apply_filters('term_excerpt_length', 40);
202
+ $excerpt_more = ' ' . '[...]';
203
+ $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
204
+ if ( count($words) > $excerpt_length ) {
205
+ array_pop($words);
206
+ $text = implode(' ', $words);
207
+ $text = $text . $excerpt_more;
208
+ } else {
209
+ $text = implode(' ', $words);
210
+ }
211
+ return apply_filters('wp_trim_term_excerpt', force_balance_tags($text), $raw_excerpt);
212
+ }
213
+
214
+ function kws_shorten_term_description($terms = array(), $taxonomies = null, $args = array()) {
215
+ if(is_array($terms)) {
216
+ foreach($terms as $key=>$term) {
217
+ if(is_object($term) && isset($term->description)) {
218
+ $term->description = kws_wp_trim_excerpt($term->description);
219
+ }
220
+ }
221
+ }
222
+ return $terms;
223
+ }
224
+
225
  ?>