Rich Text Excerpts - Version 1.1

Version Description

  • Addition of plugin options page to Wordpress Admin area, giving users the ability to configure the operation of the plugin
  • Fixed minor bug relating to editor display which was triggered in some circumstances
Download this release

Release Info

Developer bjorsq
Plugin Icon 128x128 Rich Text Excerpts
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

Files changed (3) hide show
  1. readme.txt +9 -22
  2. rich-text-excerpts.js +41 -0
  3. rich-text-excerpts.php +249 -12
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: bjorsq
3
  Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QAQ2WC8UHFMEQ
4
  Tags: excerpt, editor, TinyMCE, formatting
5
  Requires at least: 3.3
6
- Tested up to: 3.4-beta
7
- Stable tag: 1.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -24,28 +24,15 @@ The plugin utilises three action hooks:
24
 
25
  http://core.trac.wordpress.org/ticket/19173
26
 
27
- The editing box for excerpts uses [wp_editor](http://codex.wordpress.org/Function_Reference/wp_editor) to create a rich text editor with the following options:
28
 
29
- `
30
- $options = array(
31
- "wpautop" => true,
32
- "media_buttons" => false,
33
- "textarea_name" => 'excerpt',
34
- "textarea_rows" => 3,
35
- "teeny" => true
36
- );
37
- `
38
-
39
- You could change these lines in the plugin to generate a fully featured editor with media upload fields if you wished - just look at the documentation in the Wordpress Codex for all the details:
40
-
41
- http://codex.wordpress.org/Function_Reference/wp_editor
42
-
43
- The plugin also contains two filters which act on the "teeny" MCE editor instance which is used by default. These currently add the "charmap" and "paste" plugins, remove some buttons (strikethrough, for example), and add a few buttons for the new plugins.
44
 
45
  == Installation ==
46
 
47
  1. Upload the plugin to the `/wp-content/plugins/` directory
48
  2. Activate the plugin through the 'Plugins' menu in WordPress
 
49
 
50
  If you want to use excerpts in pages, add this to your theme's `functions.php` file:
51
 
@@ -58,6 +45,10 @@ If you want to use excerpts in Custom Post Types, do it when you create them usi
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 1.0 =
62
  * Wordpress submission after [initial development on bitbucket](https://bitbucket.org/bjorsq/rich-text-excerpts).
63
 
@@ -69,8 +60,4 @@ If you want to use excerpts in Custom Post Types, do it when you create them usi
69
 
70
  At the moment, the plugin uses [html_entity_decode](http://php.net/manual/en/function.html-entity-decode.php) to decode encoded entities in the excerpt content prior to displaying it in the editor. It would be nice to find a more robust way of accessing the excerpt field data using a Wordpress filter.
71
 
72
- The plugin will change all excerpt fields into rich text editors - there isn't currently an option to only enable it for specified post types (although this would be easy to add).
73
-
74
- The options for the editor should really be placed in an administration page so users can configure the plugin without editing the source. The only trouble is, which options do you put there? The TinyMCE Advanced Plugin does a good job of making the vast number of options for the editor configurable, but how much control do you really need over excerpts? It may be enough to have a simple choice of "tiny" or "teeny", but having any choice at all begs the question "if it can do that, why can't it do this?"
75
-
76
  I use git for version control, so if you want to contribute, go over to [bitbucket](https://bitbucket.org/bjorsq/rich-text-excerpts). I'll push any stable changes to the Wordpress SVN repo when they're ready.
3
  Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QAQ2WC8UHFMEQ
4
  Tags: excerpt, editor, TinyMCE, formatting
5
  Requires at least: 3.3
6
+ Tested up to: 3.5
7
+ Stable tag: 1.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
24
 
25
  http://core.trac.wordpress.org/ticket/19173
26
 
27
+ The editing box for excerpts uses [wp_editor](http://codex.wordpress.org/Function_Reference/wp_editor) to create a rich text editor. You can set the options for the rich text editot in the plugin options page (in the Wordpress Settings menu).
28
 
29
+ The plugin also contains two filters which act on the "teeny" MCE editor instance which is used by default. The plugins and buttons used by the minimal editor can be customised on the plugin options page.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  == Installation ==
32
 
33
  1. Upload the plugin to the `/wp-content/plugins/` directory
34
  2. Activate the plugin through the 'Plugins' menu in WordPress
35
+ 3. Configure the plugin using the Plugin options page under the Settings menu
36
 
37
  If you want to use excerpts in pages, add this to your theme's `functions.php` file:
38
 
45
 
46
  == Changelog ==
47
 
48
+ = 1.1 =
49
+ * Addition of plugin options page to Wordpress Admin area, giving users the ability to configure the operation of the plugin
50
+ * Fixed minor bug relating to editor display which was triggered in some circumstances
51
+
52
  = 1.0 =
53
  * Wordpress submission after [initial development on bitbucket](https://bitbucket.org/bjorsq/rich-text-excerpts).
54
 
60
 
61
  At the moment, the plugin uses [html_entity_decode](http://php.net/manual/en/function.html-entity-decode.php) to decode encoded entities in the excerpt content prior to displaying it in the editor. It would be nice to find a more robust way of accessing the excerpt field data using a Wordpress filter.
62
 
 
 
 
 
63
  I use git for version control, so if you want to contribute, go over to [bitbucket](https://bitbucket.org/bjorsq/rich-text-excerpts). I'll push any stable changes to the Wordpress SVN repo when they're ready.
rich-text-excerpts.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Plugin Name: Rich Text Excerpts
3
+ Plugin URI: https://bitbucket.org/bjorsq/rich-text-excerpts
4
+ Description: Adds rich text editing capability for excerpts using wp_editor()
5
+ Author: Peter Edwards
6
+ Author URI: http://bjorsq.net
7
+ Version: 1.0
8
+ License: GPLv3
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
+ */
24
+ jQuery(function($){
25
+ function check_editor_options()
26
+ {
27
+ if ($('.rte-options-editor-type').length) {
28
+ if ($('#rich_text_excerpts_options-editor_type-teeny').is(':checked')) {
29
+ $('#editor_type_teeny_options').show();
30
+ $('#editor_type_tiny_options').hide();
31
+ } else {
32
+ $('#editor_type_teeny_options').hide();
33
+ $('#editor_type_tiny_options').show();
34
+ }
35
+ }
36
+ }
37
+ $('.rte-options-editor-type').click(function(){
38
+ check_editor_options();
39
+ });
40
+ check_editor_options();
41
+ });
rich-text-excerpts.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://bitbucket.org/bjorsq/rich-text-excerpts
5
  Description: Adds rich text editing capability for excerpts using wp_editor()
6
  Author: Peter Edwards
7
  Author URI: http://bjorsq.net
8
- Version: 1.0
9
  License: GPLv3
10
 
11
  This program is free software; you can redistribute it and/or modify
@@ -46,6 +46,11 @@ class RichTextExcerpts {
46
  */
47
  add_filter('teeny_mce_plugins', array('RichTextExcerpts', 'teeny_mce_plugins'), 10, 2);
48
  add_filter('teeny_mce_buttons', array('RichTextExcerpts', 'teeny_mce_buttons'), 10, 2);
 
 
 
 
 
49
  }
50
 
51
  /**
@@ -76,14 +81,15 @@ class RichTextExcerpts {
76
  public static function post_excerpt_editor()
77
  {
78
  global $post;
79
- print('<div class="postbox-container"><h3 style="float:left;"><label for="excerpt">Excerpt</label></h3>');
 
80
  /* options for editor */
81
  $options = array(
82
- "wpautop" => true,
83
- "media_buttons" => false,
84
  "textarea_name" => 'excerpt',
85
- "textarea_rows" => 3,
86
- "teeny" => true //use minimal editor configuration
87
  );
88
  /* "echo" the editor */
89
  wp_editor(html_entity_decode($post->post_excerpt), 'excerpt', $options );
@@ -95,11 +101,13 @@ class RichTextExcerpts {
95
  */
96
  public static function teeny_mce_plugins($plugins, $editor_id)
97
  {
98
- if (!isset($plugins["paste"])) {
99
- array_push($plugins, "paste");
100
- }
101
- if (!isset($plugins["charmap"])) {
102
- array_push($plugins, "charmap");
 
 
103
  }
104
  return $plugins;
105
  }
@@ -110,7 +118,236 @@ class RichTextExcerpts {
110
  */
111
  public static function teeny_mce_buttons($buttons, $editor_id)
112
  {
113
- return array('bold', 'italic', 'underline', 'separator','pastetext', 'pasteword', 'removeformat', 'separator', 'charmap', 'blockquote', 'separator', 'bullist', 'numlist', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'undo', 'redo', 'separator', 'link', 'unlink');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
 
116
  }
5
  Description: Adds rich text editing capability for excerpts using wp_editor()
6
  Author: Peter Edwards
7
  Author URI: http://bjorsq.net
8
+ Version: 1.1
9
  License: GPLv3
10
 
11
  This program is free software; you can redistribute it and/or modify
46
  */
47
  add_filter('teeny_mce_plugins', array('RichTextExcerpts', 'teeny_mce_plugins'), 10, 2);
48
  add_filter('teeny_mce_buttons', array('RichTextExcerpts', 'teeny_mce_buttons'), 10, 2);
49
+ /**
50
+ * register plugin admin options
51
+ */
52
+ add_action( 'admin_menu', array('RichTextExcerpts', 'add_plugin_admin_menu') );
53
+ add_action( 'admin_init', array('RichTextExcerpts', 'register_plugin_options') );
54
  }
55
 
56
  /**
81
  public static function post_excerpt_editor()
82
  {
83
  global $post;
84
+ $plugin_options = self::get_plugin_options();
85
+ print('<div style="margin-bottom:1em;clear:both;width:100%;"><h3><label for="excerpt">Excerpt</label></h3>');
86
  /* options for editor */
87
  $options = array(
88
+ "wpautop" => $plugin_options['editor_settings']['wpautop'],
89
+ "media_buttons" => $plugin_options['editor_settings']['media_buttons'],
90
  "textarea_name" => 'excerpt',
91
+ "textarea_rows" => $plugin_options['editor_settings']['textarea_rows'],
92
+ "teeny" => ($plugin_options['editor_type'] === "teeny")? true: false
93
  );
94
  /* "echo" the editor */
95
  wp_editor(html_entity_decode($post->post_excerpt), 'excerpt', $options );
101
  */
102
  public static function teeny_mce_plugins($plugins, $editor_id)
103
  {
104
+ $plugin_options = self::get_plugin_options();
105
+ if (count($plugin_options['editor_settings']['plugins'])) {
106
+ foreach ($plugin_options['editor_settings']['plugins'] as $plugin_name) {
107
+ if (!isset($plugins[$plugin_name])) {
108
+ array_push($plugins, $plugin_name);
109
+ }
110
+ }
111
  }
112
  return $plugins;
113
  }
118
  */
119
  public static function teeny_mce_buttons($buttons, $editor_id)
120
  {
121
+ $plugin_options = self::get_plugin_options();
122
+ return $plugin_options['editor_settings']['buttons'];
123
+ }
124
+
125
+
126
+ /************************************************************
127
+ * PLUGIN OPTIONS ADMINISTRATION *
128
+ ************************************************************/
129
+
130
+ /**
131
+ * add an admin page under settings to configure the plugin
132
+ */
133
+ public static function add_plugin_admin_menu()
134
+ {
135
+ /* Plugin Options page */
136
+ $options_page = add_submenu_page("options-general.php", "Rich Text Excerpts", "Rich Text Excerpts", "manage_options", "rich_text_excerpts_options", array('RichTextExcerpts', "plugin_options_page") );
137
+ /* Use the admin_print_scripts action to add scripts for theme options */
138
+ add_action( 'admin_print_scripts-' . $options_page, array('RichTextExcerpts', 'plugin_admin_scripts') );
139
+ /* Use the admin_print_styles action to add CSS for theme options */
140
+ //add_action( 'admin_print_styles-' . $options_page, array('RichTextExcerpts', 'plugin_admin_styles') );
141
+ }
142
+
143
+ /**
144
+ * add script to admin for plugin options
145
+ */
146
+ public static function plugin_admin_scripts()
147
+ {
148
+ wp_enqueue_script('RichTextExcerptsAdminScript', plugins_url('rich-text-excerpts.js', __FILE__), array('jquery'));
149
+ }
150
+
151
+ /**
152
+ * creates the options page
153
+ */
154
+ public static function plugin_options_page()
155
+ {
156
+ print('<div class="wrap"><div class="icon32" id="icon-options-general"><br /></div><h2>Rich Text Excerpts Options</h2>');
157
+ settings_errors('rich_text_excerpts_options');
158
+ print('<form method="post" action="options.php">');
159
+ settings_fields('rich_text_excerpts_options');
160
+ do_settings_sections('rte');
161
+ printf('<p class="submit"><input type="submit" class="button-primary" name="Submit" value="%s" /></p>', _('Save Changes'));
162
+ print('</form></div>');
163
+ }
164
+
165
+ /**
166
+ * registers settings and sections
167
+ */
168
+ function register_plugin_options()
169
+ {
170
+ register_setting('rich_text_excerpts_options', 'rich_text_excerpts_options', array('RichTextExcerpts', 'validate_rich_text_excerpts_options'));
171
+
172
+ /* post type options */
173
+ add_settings_section(
174
+ 'post-type-options',
175
+ 'Post Types',
176
+ array('RichTextExcerpts', 'options_section_text'),
177
+ 'rte'
178
+ );
179
+ add_settings_field(
180
+ 'supported_post_types',
181
+ 'Choose which post types will have rich text editor for excerpts',
182
+ array('RichTextExcerpts', 'options_setting_post_types'),
183
+ 'rte',
184
+ 'post-type-options'
185
+ );
186
+
187
+ /* editor options */
188
+ add_settings_section(
189
+ 'editor-options',
190
+ 'Editor Options',
191
+ array('RichTextExcerpts', 'options_section_text'),
192
+ 'rte'
193
+ );
194
+ add_settings_field(
195
+ 'editor_type',
196
+ 'Choose which Editor is used for excerpts',
197
+ array('RichTextExcerpts', 'options_setting_editor_type'),
198
+ 'rte',
199
+ 'editor-options'
200
+ );
201
+ /* settings for editor */
202
+ add_settings_field(
203
+ 'editor_settings',
204
+ 'Editor Settings',
205
+ array('RichTextExcerpts', 'options_editor_settings'),
206
+ 'rte',
207
+ 'editor-options'
208
+ );
209
+ }
210
+
211
+ /**
212
+ * gets plugin options - merges saved options with defaults
213
+ * @return array
214
+ */
215
+ public static function get_plugin_options()
216
+ {
217
+ $defaults = array(
218
+ "supported_post_types" => array('post'),
219
+ "editor_type" => "teeny",
220
+ "editor_settings" => array(
221
+ "wpautop" => true,
222
+ "media_buttons" => false,
223
+ "textarea_rows" => 3,
224
+ "buttons" => array('bold', 'italic', 'underline', 'separator','pastetext', 'pasteword', 'removeformat', 'separator', 'charmap', 'blockquote', 'separator', 'bullist', 'numlist', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'undo', 'redo', 'separator', 'link', 'unlink'),
225
+ "plugins" => array('charmap', 'paste')
226
+ )
227
+ );
228
+ $saved = get_option('rich_text_excerpts_options');
229
+ foreach ($defaults as $key => $val) {
230
+ if (!isset($saved[$key])) {
231
+ $saved[$key] = $val;
232
+ }
233
+ }
234
+ return $saved;
235
+ }
236
+
237
+ /**
238
+ * settings section text
239
+ */
240
+ public static function options_section_text()
241
+ {
242
+ echo "";
243
+ }
244
+
245
+ /**
246
+ * post type support settings
247
+ */
248
+ public static function options_setting_post_types()
249
+ {
250
+ $options = self::get_plugin_options();
251
+ $post_types = get_post_types(array("public" => true),'names');
252
+ foreach ($post_types as $post_type ) {
253
+ if ( post_type_supports($post_type, 'excerpt') ) {
254
+ $chckd = (in_array($post_type, $options["supported_post_types"]))? ' checked="checked"': '';
255
+ printf('<p><input type="checkbox" name="rich_text_excerpts_options[supported_post_types][]" id="supported_post_types-%s" value="%s"%s /> <label for="supported_post_types-%s">%s</label></p>', $post_type, $post_type, $chckd, $post_type, $post_type);
256
+ }
257
+ }
258
+ print('<p>Post types not selected here will use the regular plain text editor for excerpts. If the post type you want is not listed here, it does not currently support excerpts - to add support for excerpts to a post type, see <a href="http://codex.wordpress.org/Function_Reference/add_post_type_support">add_post_type_support()</a> in the Wordpress Codex.</p>');
259
+ }
260
+
261
+ /**
262
+ * settings section text
263
+ */
264
+ public static function options_setting_editor_type()
265
+ {
266
+ $options = self::get_plugin_options();
267
+ $chckd = ($options["editor_type"] === "teeny")? ' checked="checked"': '';
268
+ printf('<p><input type="radio" name="rich_text_excerpts_options[editor_type]" id="rich_text_excerpts_options-editor_type-teeny" class="rte-options-editor-type" value="teeny"%s /> <label for="rich_text_excerpts_options-editor_type-teeny">Use the minimal editor configuration used in PressThis</label></p>', $chckd);
269
+ $chckd = ($options["editor_type"] === "teeny")? '': ' checked="checked"';
270
+ printf('<p><input type="radio" name="rich_text_excerpts_options[editor_type]" id="rich_text_excerpts_options-editor_type-tiny" class="rte-options-editor-type" value="tiny"%s /> <label for="rich_text_excerpts_options-editor_type-tiny">Use the full version of the editor</label></p>', $chckd);
271
+ print('<p>Choose whether to use the full TinyMCE editor, or the &ldquo;teeny&rdquo; version of the editor (recommended). Customising the full TinyMCE editor is best carried out using a plugin like TinyMCE Advanced. If you choose to use the &ldquo;teeny&rdquo; version of the editor, you can customise the controls it will have here.</p>');
272
+ }
273
+
274
+ /**
275
+ * general settings for text editor
276
+ */
277
+ public static function options_editor_settings()
278
+ {
279
+ $options = self::get_plugin_options();
280
+ $chckd = $options['editor_settings']['wpautop']? '': ' checked="checked"';
281
+ printf('<p><input type="checkbox" name="rich_text_excerpts_options[editor_settings][wpautop]" id="rich_text_excerpts_options-editor_settings-wpautop"%s /> <label for="rich_text_excerpts_options-editor_settings-wpautop">Stop removing the &lt;p&gt; and &lt;br&gt; tags when saving and show them in the HTML editor This will make it possible to use more advanced coding in the HTML editor without the back-end filtering affecting it much. However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently.</label></p>', $chckd);
282
+ $chckd = $options['editor_settings']['media_buttons']? 'checked="checked"': '';
283
+ printf('<p><input type="checkbox" name="rich_text_excerpts_options[editor_settings][media_buttons]" id="rich_text_excerpts_options-editor_settings-media_buttons"%s /> <label for="rich_text_excerpts_options-editor_settings-media_buttons">Enable upload media button</label></p>', $chckd);
284
+ printf('<p><input type="text" length="2" name="rich_text_excerpts_options[editor_settings][textarea_rows]" id="rich_text_excerpts_options-editor_settings-textarea_rows" value="%d" /> <label for="rich_text_excerpts_options-editor_settings-textarea_rows">Number of rows to use in the text editor (minimum is 3)</label></p>', intVal($options['editor_settings']['textarea_rows']));
285
+ print('<p><strong>Toolbar Buttons and Plugins</strong></p>');
286
+ /**
287
+ * settings for teeny text editor
288
+ */
289
+ print('<div id="editor_type_teeny_options">');
290
+ print('<p>For a list of buttons and plugins in TinyMCE, <a href="http://www.tinymce.com/wiki.php/Buttons/controls">see this page on the TinyMCE wiki</a>. There is also some documentation on the <a href="http://codex.wordpress.org/TinyMCE">implementation of TinyMCE in Wordpress on the Wordpress Codex</a>.</p><p>Button and plugin names should be separated using commas.</p>');
291
+ printf('<p><label for="rich_text_excerpts_options-editor_settings-plugins">Plugins to add - make sure you add any plugin specific buttons to the editor below.</label><br /><input type="text" length="50" name="rich_text_excerpts_options[editor_settings][plugins]" id="rich_text_excerpts_options-editor_settings-plugins" value="%s" /></p>', implode(',', $options['editor_settings']['plugins']));
292
+ printf('<p><label for="rich_text_excerpts_options-editor_settings-buttons">Toolbar buttons - use the word &lsquo;separator&rsquo; to separate groups of buttons</label><br /><textarea name="rich_text_excerpts_options[editor_settings][buttons]" id="rich_text_excerpts_options-editor_settings-buttons" cols="100" rows="3">%s</textarea></p>', implode(',', $options['editor_settings']['buttons']));
293
+ print('</div>');
294
+ /**
295
+ * settings for tiny text editor (none to show here, but show links to TinyMCE advanced)
296
+ */
297
+ print('<div id="editor_type_tiny_options">');
298
+ if (is_plugin_active('tinymce-advanced/tinymce-advanced.php')) {
299
+ printf('<p id=""><a href="%s">Configure the buttons for the advanced editor using the TinyMCE Advanced plugin</a>.</p>', admin_url('options-general.php?page=tinymce-advanced'));
300
+ } else {
301
+ printf('<p>If you want to configure the buttons for the advanced editor, <a href="%s">install and activate the TinyMCE Advanced plugin</a>.</p>', admin_url('plugins.php'));
302
+ }
303
+ print('</div>');
304
+ }
305
+
306
+ /**
307
+ * takes a string of comma-separated arguments and splits/trims it
308
+ */
309
+ public static function cleanup_mce_array($inputStr = '')
310
+ {
311
+ if (trim($inputStr) === "") {
312
+ return array();
313
+ } else {
314
+ $input = explode(',', $inputStr);
315
+ $output = array();
316
+ foreach ($input as $str) {
317
+ if (trim($str) !== '') {
318
+ $output[] = $str;
319
+ }
320
+ }
321
+ return $output;
322
+ }
323
+ }
324
+
325
+ /**
326
+ * input validation callback
327
+ */
328
+ public static function validate_rich_text_excerpts_options($plugin_options)
329
+ {
330
+ if (!isset($plugin_options['supported_post_types'])) {
331
+ $plugin_options['supported_post_types'] = array();
332
+ }
333
+ $plugin_options['editor_settings']['wpautop'] = (!isset($plugin_options['editor_settings']['wpautop']));
334
+ $plugin_options['editor_settings']['media_buttons'] = (isset($plugin_options['editor_settings']['media_buttons']));
335
+ $plugin_options['editor_settings']['textarea_rows'] = intval($plugin_options['editor_settings']['textarea_rows']);
336
+ if ($plugin_options['editor_settings']['textarea_rows'] < 3) {
337
+ $plugin_options['editor_settings']['textarea_rows'] = 3;
338
+ }
339
+ if (trim($plugin_options['editor_settings']['plugins']) == "") {
340
+ $plugin_options['editor_settings']['plugins'] = array();
341
+ } else {
342
+ $plugin_options['editor_settings']['plugins'] = self::cleanup_mce_array($plugin_options['editor_settings']['plugins']);
343
+ }
344
+ if (trim($plugin_options['editor_settings']['buttons']) == "") {
345
+ $plugin_options['editor_settings']['buttons'] = array();
346
+ } else {
347
+ $plugin_options['editor_settings']['buttons'] = self::cleanup_mce_array($plugin_options['editor_settings']['buttons']);
348
+ }
349
+
350
+ return $plugin_options;
351
  }
352
 
353
  }