Rich Text Excerpts - Version 1.2.1

Version Description

  • removed a debugging setting from the plugin which set the textarea_rows to 20. Setting textarea_rows in wp_editor() doesn't appear to have any effect anyway
  • tidied up javascript and added error checking for selection of post types
  • additional error checking in the validation routine
Download this release

Release Info

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

Code changes from version 1.2 to 1.2.1

languages/rich-text-excerpts.pot CHANGED
@@ -1,52 +1,61 @@
1
- # Copyright (C) 2012 Rich Text Excerpts
2
  # This file is distributed under the same license as the Rich Text Excerpts package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Rich Text Excerpts 1.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/rich-text-excerpts\n"
7
- "POT-Creation-Date: 2012-09-23 20:16:00+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: rich-text-excerpts.php:98
16
  msgid "Excerpt"
17
  msgstr ""
18
 
19
- #. #-#-#-#-# plugin.pot (Rich Text Excerpts 1.2) #-#-#-#-#
 
 
 
 
20
  #. Plugin Name of the plugin/theme
21
- #: rich-text-excerpts.php:149
22
  msgid "Rich Text Excerpts"
23
  msgstr ""
24
 
25
- #: rich-text-excerpts.php:169
26
  msgid "Rich Text Excerpts Options"
27
  msgstr ""
28
 
29
- #: rich-text-excerpts.php:174
30
  msgid "Save Changes"
31
  msgstr ""
32
 
33
- #: rich-text-excerpts.php:194
34
- msgid "Choose which post types will have rich text editor for excerpts"
35
  msgstr ""
36
 
37
- #: rich-text-excerpts.php:203
38
  msgid "Editor Options"
39
  msgstr ""
40
 
41
- #: rich-text-excerpts.php:209
42
  msgid "Choose which Editor is used for excerpts"
43
  msgstr ""
44
 
45
- #: rich-text-excerpts.php:217
46
  msgid "Editor Settings"
47
  msgstr ""
48
 
49
- #: rich-text-excerpts.php:271
 
 
 
 
 
50
  msgid ""
51
  "Post types not selected here will use the regular plain text editor for "
52
  "excerpts. If the post type you want is not listed here, it does not "
@@ -54,15 +63,15 @@ msgid ""
54
  "the Wordpress Codex"
55
  msgstr ""
56
 
57
- #: rich-text-excerpts.php:281
58
  msgid "Use the minimal editor configuration used in PressThis"
59
  msgstr ""
60
 
61
- #: rich-text-excerpts.php:283
62
  msgid "Use the full version of the editor"
63
  msgstr ""
64
 
65
- #: rich-text-excerpts.php:284
66
  msgid ""
67
  "Choose whether to use the full TinyMCE editor, or the &ldquo;teeny&rdquo; "
68
  "version of the editor (recommended). Customising the full TinyMCE editor is "
@@ -71,7 +80,7 @@ msgid ""
71
  "controls it will have here"
72
  msgstr ""
73
 
74
- #: rich-text-excerpts.php:294
75
  msgid ""
76
  "Stop removing the &lt;p&gt; and &lt;br&gt; tags when saving and show them in "
77
  "the HTML editor This will make it possible to use more advanced coding in "
@@ -80,58 +89,58 @@ msgid ""
80
  "it permanently"
81
  msgstr ""
82
 
83
- #: rich-text-excerpts.php:296
84
  msgid "Enable upload media button"
85
  msgstr ""
86
 
87
- #: rich-text-excerpts.php:297
88
  msgid "Number of rows to use in the text editor (minimum is 3)"
89
  msgstr ""
90
 
91
- #: rich-text-excerpts.php:298
92
  msgid "Toolbar Buttons and Plugins"
93
  msgstr ""
94
 
95
- #: rich-text-excerpts.php:303
96
  msgid "For a list of buttons and plugins in TinyMCE, see the TinyMCE wiki"
97
  msgstr ""
98
 
99
- #: rich-text-excerpts.php:303
100
  msgid ""
101
  "There is also some documentation on the implementation of TinyMCE in "
102
  "Wordpress on the Wordpress Codex"
103
  msgstr ""
104
 
105
- #: rich-text-excerpts.php:303
106
  msgid "Button and plugin names should be separated using commas"
107
  msgstr ""
108
 
109
- #: rich-text-excerpts.php:304
110
  msgid ""
111
  "Plugins to add - make sure you add any plugin specific buttons to the editor "
112
  "below"
113
  msgstr ""
114
 
115
- #: rich-text-excerpts.php:305
116
  msgid ""
117
  "Toolbar buttons - use the word &lsquo;separator&rsquo; to separate groups of "
118
  "buttons"
119
  msgstr ""
120
 
121
- #: rich-text-excerpts.php:312
122
  msgid ""
123
  "Configure the buttons for the advanced editor using the TinyMCE Advanced "
124
  "plugin"
125
  msgstr ""
126
 
127
- #: rich-text-excerpts.php:314
128
  msgid ""
129
  "If you want to configure the buttons for the advanced editor, install and "
130
  "activate the TinyMCE Advanced plugin"
131
  msgstr ""
132
 
133
  #. Plugin URI of the plugin/theme
134
- msgid "https://bitbucket.org/bjorsq/rich-text-excerpts"
135
  msgstr ""
136
 
137
  #. Description of the plugin/theme
1
+ # Copyright (C) 2013 Rich Text Excerpts
2
  # This file is distributed under the same license as the Rich Text Excerpts package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Rich Text Excerpts 1.2.1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/rich-text-excerpts\n"
7
+ "POT-Creation-Date: 2013-04-21 08:52:53+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: rich-text-excerpts.php:140
16
  msgid "Excerpt"
17
  msgstr ""
18
 
19
+ #: rich-text-excerpts.php:192
20
+ msgid "Settings"
21
+ msgstr ""
22
+
23
+ #. #-#-#-#-# plugin.pot (Rich Text Excerpts 1.2.1) #-#-#-#-#
24
  #. Plugin Name of the plugin/theme
25
+ #: rich-text-excerpts.php:204
26
  msgid "Rich Text Excerpts"
27
  msgstr ""
28
 
29
+ #: rich-text-excerpts.php:238
30
  msgid "Rich Text Excerpts Options"
31
  msgstr ""
32
 
33
+ #: rich-text-excerpts.php:243
34
  msgid "Save Changes"
35
  msgstr ""
36
 
37
+ #: rich-text-excerpts.php:263
38
+ msgid "Choose which post types will use a rich text editor for excerpts"
39
  msgstr ""
40
 
41
+ #: rich-text-excerpts.php:272
42
  msgid "Editor Options"
43
  msgstr ""
44
 
45
+ #: rich-text-excerpts.php:278
46
  msgid "Choose which Editor is used for excerpts"
47
  msgstr ""
48
 
49
+ #: rich-text-excerpts.php:286
50
  msgid "Editor Settings"
51
  msgstr ""
52
 
53
+ #: rich-text-excerpts.php:342
54
+ msgid ""
55
+ "If you want to disable support for all post types, please disable the plugin"
56
+ msgstr ""
57
+
58
+ #: rich-text-excerpts.php:343
59
  msgid ""
60
  "Post types not selected here will use the regular plain text editor for "
61
  "excerpts. If the post type you want is not listed here, it does not "
63
  "the Wordpress Codex"
64
  msgstr ""
65
 
66
+ #: rich-text-excerpts.php:353
67
  msgid "Use the minimal editor configuration used in PressThis"
68
  msgstr ""
69
 
70
+ #: rich-text-excerpts.php:355
71
  msgid "Use the full version of the editor"
72
  msgstr ""
73
 
74
+ #: rich-text-excerpts.php:356
75
  msgid ""
76
  "Choose whether to use the full TinyMCE editor, or the &ldquo;teeny&rdquo; "
77
  "version of the editor (recommended). Customising the full TinyMCE editor is "
80
  "controls it will have here"
81
  msgstr ""
82
 
83
+ #: rich-text-excerpts.php:374
84
  msgid ""
85
  "Stop removing the &lt;p&gt; and &lt;br&gt; tags when saving and show them in "
86
  "the HTML editor This will make it possible to use more advanced coding in "
89
  "it permanently"
90
  msgstr ""
91
 
92
+ #: rich-text-excerpts.php:376
93
  msgid "Enable upload media button"
94
  msgstr ""
95
 
96
+ #: rich-text-excerpts.php:377
97
  msgid "Number of rows to use in the text editor (minimum is 3)"
98
  msgstr ""
99
 
100
+ #: rich-text-excerpts.php:378
101
  msgid "Toolbar Buttons and Plugins"
102
  msgstr ""
103
 
104
+ #: rich-text-excerpts.php:383
105
  msgid "For a list of buttons and plugins in TinyMCE, see the TinyMCE wiki"
106
  msgstr ""
107
 
108
+ #: rich-text-excerpts.php:383
109
  msgid ""
110
  "There is also some documentation on the implementation of TinyMCE in "
111
  "Wordpress on the Wordpress Codex"
112
  msgstr ""
113
 
114
+ #: rich-text-excerpts.php:383
115
  msgid "Button and plugin names should be separated using commas"
116
  msgstr ""
117
 
118
+ #: rich-text-excerpts.php:384
119
  msgid ""
120
  "Plugins to add - make sure you add any plugin specific buttons to the editor "
121
  "below"
122
  msgstr ""
123
 
124
+ #: rich-text-excerpts.php:385
125
  msgid ""
126
  "Toolbar buttons - use the word &lsquo;separator&rsquo; to separate groups of "
127
  "buttons"
128
  msgstr ""
129
 
130
+ #: rich-text-excerpts.php:392
131
  msgid ""
132
  "Configure the buttons for the advanced editor using the TinyMCE Advanced "
133
  "plugin"
134
  msgstr ""
135
 
136
+ #: rich-text-excerpts.php:394
137
  msgid ""
138
  "If you want to configure the buttons for the advanced editor, install and "
139
  "activate the TinyMCE Advanced plugin"
140
  msgstr ""
141
 
142
  #. Plugin URI of the plugin/theme
143
+ msgid "http://wordpress.org/extend/plugins/rich-text-excerpts/"
144
  msgstr ""
145
 
146
  #. Description of the plugin/theme
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: excerpt, editor, TinyMCE, formatting
5
  Requires at least: 3.3
6
  Tested up to: 3.6
7
- Stable tag: 1.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -17,8 +17,7 @@ The Plugin uses the [wp_editor](http://codex.wordpress.org/Function_Reference/wp
17
  The plugin utilises three action hooks:
18
 
19
  * [add_meta_boxes](http://adambrown.info/p/wp_hooks/hook/add_meta_boxes) is used to remove the excerpt meta box generated by Wordpress
20
- * [edit_form_advanced](http://adambrown.info/p/wp_hooks/hook/edit_form_advanced) is used to add the excerpt editor to posts.
21
- * [edit_page_form](http://adambrown.info/p/wp_hooks/hook/edit_page_form) is used to add the excerpt editor to pages.
22
 
23
  **Note:** the new editing box cannot be placed in a sortable, movable meta box because of an issue with using TinyMCE in sortables documented here:
24
 
@@ -45,6 +44,11 @@ If you want to use excerpts in Custom Post Types, do it when you create them usi
45
 
46
  == Changelog ==
47
 
 
 
 
 
 
48
  = 1.2 =
49
  * Added translations (no idea whether these work though!)
50
  * Fixed some bugs in plugin options saving/retrieval
@@ -67,4 +71,4 @@ If you want to use excerpts in Custom Post Types, do it when you create them usi
67
 
68
  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.
69
 
70
- If you can translate this plugin, please get in touch - there is a POT file with the plugin for translators to use.
4
  Tags: excerpt, editor, TinyMCE, formatting
5
  Requires at least: 3.3
6
  Tested up to: 3.6
7
+ Stable tag: 1.2.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
17
  The plugin utilises three action hooks:
18
 
19
  * [add_meta_boxes](http://adambrown.info/p/wp_hooks/hook/add_meta_boxes) is used to remove the excerpt meta box generated by Wordpress
20
+ * [edit_form_advanced](http://adambrown.info/p/wp_hooks/hook/edit_form_advanced) and [edit_page_form](http://adambrown.info/p/wp_hooks/hook/edit_page_form) are used to add the excerpt editor to posts and pages - see the [Notes section on the Codex page for wp_editor](http://codex.wordpress.org/Function_Reference/wp_editor).
 
21
 
22
  **Note:** the new editing box cannot be placed in a sortable, movable meta box because of an issue with using TinyMCE in sortables documented here:
23
 
44
 
45
  == Changelog ==
46
 
47
+ = 1.2.1 =
48
+ * removed a debugging setting from the plugin which set the `textarea_rows` to 20. Setting `textarea_rows` in `wp_editor()` doesn't appear to have any effect anyway
49
+ * tidied up javascript and added error checking for selection of post types
50
+ * additional error checking in the validation routine
51
+
52
  = 1.2 =
53
  * Added translations (no idea whether these work though!)
54
  * Fixed some bugs in plugin options saving/retrieval
71
 
72
  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.
73
 
74
+ If you can translate this plugin, please get in touch - there is a POT file with the plugin for translators to use. I've made translations using Google translate, but not sure if these are any good.
rich-text-excerpts.css CHANGED
@@ -1,3 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .js .rich-text-excerpt h3 {
2
  cursor: default;
3
  }
@@ -7,3 +30,12 @@
7
  .rich-text-excerpt div.rte-wrap {
8
  padding:10px;
9
  }
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Plugin Name: Rich Text Excerpts
3
+ Plugin URI: http://wordpress.org/extend/plugins/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.2.1
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
  .js .rich-text-excerpt h3 {
25
  cursor: default;
26
  }
30
  .rich-text-excerpt div.rte-wrap {
31
  padding:10px;
32
  }
33
+ .rte-post-types-error {
34
+ background-color: rgb(255, 255, 224);
35
+ border:1px solid rgb(230, 219, 85);
36
+ -webkit-border-radius:3px;
37
+ border-radius:3px;
38
+ color: rgb(51, 51, 51);
39
+ padding: 4px 0.5em;
40
+ display:none;
41
+ }
rich-text-excerpts.js CHANGED
@@ -1,11 +1,10 @@
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.2
8
- Text Domain: rich-text-excerpts
9
  License: GPLv3
10
 
11
  This program is free software; you can redistribute it and/or modify
@@ -22,7 +21,32 @@ You should have received a copy of the GNU General Public License
22
  along with this program; if not, write to the Free Software
23
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
  */
25
- jQuery(function($){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  function check_editor_options()
27
  {
28
  if ($('.rte-options-editor-type').length) {
@@ -35,10 +59,32 @@ jQuery(function($){
35
  }
36
  }
37
  }
38
- $('.rte-options-editor-type').click(function(){
39
- check_editor_options();
40
- });
41
- check_editor_options();
42
- /* turn off javascript on postbox heading */
43
- window.setTimeout(function(){$('.rich-text-excerpt h3').unbind('click.postboxes');},500);
44
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /*
2
  Plugin Name: Rich Text Excerpts
3
+ Plugin URI: http://wordpress.org/extend/plugins/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.2.1
 
8
  License: GPLv3
9
 
10
  This program is free software; you can redistribute it and/or modify
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(document).ready(function($){
25
+ /* this block hides and shows the options for the teeny version of the editor */
26
+ if ($('.rte-options-editor-type').length) {
27
+ /* add a handler to the radio buttons used for editor type selection */
28
+ $('.rte-options-editor-type').click(function(){
29
+ check_editor_options();
30
+ });
31
+ /* initial check on page load */
32
+ check_editor_options();
33
+ }
34
+ /* this block prevents the de-selection of all post types on the settings page */
35
+ if ($('.rte-post-types').length) {
36
+ /* keep track of the last checkbox checked */
37
+ var lastchecked = false;
38
+ /* add a handler to the checkboxes for post type support */
39
+ $('.rte-post-types').click(function(e){
40
+ lastchecked = $(this);
41
+ check_post_type_options(e);
42
+ });
43
+ /* initial check on page load */
44
+ check_post_type_options();
45
+ }
46
+ /**
47
+ * function to check the editor type selected for the plugin and show/hide the options
48
+ * for the appropriate type
49
+ */
50
  function check_editor_options()
51
  {
52
  if ($('.rte-options-editor-type').length) {
59
  }
60
  }
61
  }
62
+ /**
63
+ * function to check the post-types checkboxes and ensure that one is checked
64
+ */
65
+ function check_post_type_options(evt)
66
+ {
67
+ if ($('.rte-post-types').length) {
68
+ if (!$('.rte-post-types:checked').length) {
69
+ if (lastchecked === false) {
70
+ $('.rte-post-types:first').attr('checked', 'checked');
71
+ } else {
72
+ lastchecked.attr('checked', 'checked');
73
+ }
74
+ $('.rte-post-types-error').show();
75
+ } else {
76
+ $('.rte-post-types-error').hide();
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * this removes the click.postboxes handler added by wordpress to the .postbox h3
82
+ * for the rich text excerpt editor. This is because the editor is placed in a
83
+ * static metabox (the postbox class is used for formatting only) - it cannot be
84
+ * expanded, hidden or moved
85
+ */
86
+ if ($('.rich-text-excerpt h3').length) {
87
+ /* turn off javascript on postbox heading - leave a little time for it to be added first */
88
+ window.setTimeout(function(){jQuery('.rich-text-excerpt h3').unbind('click.postboxes');},500);
89
+ }
90
+ });
rich-text-excerpts.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/extend/plugins/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.2
9
  Text Domain: rich-text-excerpts
10
  License: GPLv3
11
 
@@ -53,6 +53,10 @@ class RichTextExcerpts {
53
  */
54
  add_action( 'admin_menu', array( __CLASS__, 'add_plugin_admin_menu' ) );
55
  add_action( 'admin_init', array( __CLASS__, 'register_plugin_options' ) );
 
 
 
 
56
  /**
57
  * register text domain
58
  */
@@ -77,8 +81,9 @@ class RichTextExcerpts {
77
  */
78
  public static function on_activation()
79
  {
80
- if ( ! current_user_can( 'activate_plugins' ) )
81
  return;
 
82
  update_option('rich_text_excerpts_options', self::get_default_plugin_options());
83
  }
84
 
@@ -87,8 +92,9 @@ class RichTextExcerpts {
87
  */
88
  public static function on_deactivation()
89
  {
90
- if ( ! current_user_can( 'activate_plugins' ) )
91
  return;
 
92
  delete_option('rich_text_excerpts_options');
93
  }
94
 
@@ -131,13 +137,13 @@ class RichTextExcerpts {
131
  {
132
  global $post;
133
  $plugin_options = self::get_plugin_options();
134
- printf('<div class="postbox rich-text-excerpt"><h3><label for="excerpt">%s</label></h3><div style="padding:10px;">', __('Excerpt', 'rich-text-excerpts'));
135
  /* options for editor */
136
  $options = array(
137
  "wpautop" => $plugin_options['editor_settings']['wpautop'],
138
  "media_buttons" => $plugin_options['editor_settings']['media_buttons'],
139
  "textarea_name" => 'excerpt',
140
- "textarea_rows" => 20,//$plugin_options['editor_settings']['textarea_rows'],
141
  "teeny" => ($plugin_options['editor_type'] === "teeny")? true: false
142
  );
143
  /* "echo" the editor */
@@ -176,6 +182,19 @@ class RichTextExcerpts {
176
  * PLUGIN OPTIONS ADMINISTRATION *
177
  ************************************************************/
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  /**
180
  * add an admin page under settings to configure the plugin
181
  */
@@ -183,9 +202,15 @@ class RichTextExcerpts {
183
  {
184
  /* Plugin Options page */
185
  $options_page = add_submenu_page("options-general.php", __('Rich Text Excerpts', 'rich-text-excerpts'), __('Rich Text Excerpts', 'rich-text-excerpts'), "manage_options", "rich_text_excerpts_options", array( __CLASS__, "plugin_options_page" ) );
186
- /* Use the admin_print_scripts action to add scripts for theme options */
 
 
 
187
  add_action( 'admin_print_scripts', array( __CLASS__, 'plugin_admin_scripts' ) );
188
- /* Use the admin_print_styles action to add CSS for theme options */
 
 
 
189
  add_action( 'admin_print_styles', array( __CLASS__, 'plugin_admin_styles' ) );
190
  }
191
 
@@ -235,7 +260,7 @@ class RichTextExcerpts {
235
  );
236
  add_settings_field(
237
  'supported_post_types',
238
- __('Choose which post types will have rich text editor for excerpts', 'rich-text-excerpts'),
239
  array( __CLASS__, 'options_setting_post_types' ),
240
  'rte',
241
  'post-type-options'
@@ -311,14 +336,15 @@ class RichTextExcerpts {
311
  foreach ($post_types as $post_type ) {
312
  if ( post_type_supports($post_type, 'excerpt') ) {
313
  $chckd = (in_array($post_type, $options["supported_post_types"]))? ' checked="checked"': '';
314
- 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);
315
  }
316
  }
 
317
  printf('<p>%s<br /><a href="http://codex.wordpress.org/Function_Reference/add_post_type_support">add_post_type_support()</a></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 the Wordpress Codex', 'rich-text-excerpts'));
318
  }
319
 
320
  /**
321
- * settings section text
322
  */
323
  public static function options_setting_editor_type()
324
  {
@@ -331,7 +357,15 @@ class RichTextExcerpts {
331
  }
332
 
333
  /**
334
- * general settings for text editor
 
 
 
 
 
 
 
 
335
  */
336
  public static function options_editor_settings()
337
  {
@@ -363,7 +397,7 @@ class RichTextExcerpts {
363
  }
364
 
365
  /**
366
- * takes a string of comma-separated arguments and splits/trims it
367
  */
368
  public static function get_mce_array($inputStr = '')
369
  {
@@ -376,11 +410,12 @@ class RichTextExcerpts {
376
 
377
  /**
378
  * removes empty elements from an array
 
379
  */
380
  public static function cleanup_array($arr = array())
381
  {
382
  $output = array();
383
- if (is_array($arr)) {
384
  $arr = array_map('trim', $arr);
385
  foreach ($arr as $str) {
386
  if (!empty($str)) {
@@ -393,37 +428,48 @@ class RichTextExcerpts {
393
 
394
  /**
395
  * input validation callback
 
396
  */
397
  public static function validate_rich_text_excerpts_options($plugin_options)
398
  {
 
399
  $defaults = self::get_default_plugin_options();
 
400
  if (!isset($plugin_options['supported_post_types']) || !is_array($plugin_options['supported_post_types'])) {
401
  $plugin_options['supported_post_types'] = $defaults['supported_post_types'];
402
  }
 
403
  if (!isset($plugin_options['editor_type']) || !in_array($plugin_options['editor_type'], array('teeny','tiny'))) {
404
  $plugin_options['editor_type'] = $defaults['editor_type'];
405
  }
 
406
  if (!isset($plugin_options['editor_settings'])) {
407
  $plugin_options['editor_settings'] = $defaults['editor_settings'];
408
  } else {
 
409
  if (!isset($plugin_options['editor_settings']['wpautop'])) {
410
- $plugin_options['editor_settings']['wpautop'] = true;
411
  } else {
412
  $plugin_options['editor_settings']['wpautop'] = (bool) $plugin_options['editor_settings']['wpautop'];
413
  }
 
414
  if (!isset($plugin_options['editor_settings']['media_buttons'])) {
415
- $plugin_options['editor_settings']['media_buttons'] = false;
416
  } else {
417
  $plugin_options['editor_settings']['media_buttons'] = (bool) $plugin_options['editor_settings']['media_buttons'];
418
  }
 
419
  $plugin_options['editor_settings']['textarea_rows'] = isset($plugin_options['editor_settings']['textarea_rows'])? intval($plugin_options['editor_settings']['textarea_rows']): $defaults['editor_settings']['textarea_rows'];
420
  if ($plugin_options['editor_settings']['textarea_rows'] < 3) {
421
  $plugin_options['editor_settings']['textarea_rows'] = 3;
422
  }
 
423
  if (!isset($plugin_options['editor_settings']['plugins'])) {
424
  $plugin_options['editor_settings']['plugins'] = $defaults['editor_settings']['plugins'];
425
  } else {
 
426
  if (!is_array($plugin_options['editor_settings']['plugins'])) {
 
427
  if (trim($plugin_options['editor_settings']['plugins']) === "") {
428
  $plugin_options['editor_settings']['plugins'] = array();
429
  } else {
@@ -436,7 +482,9 @@ class RichTextExcerpts {
436
  if (!isset($plugin_options['editor_settings']['buttons'])) {
437
  $plugin_options['editor_settings']['buttons'] = $defaults['editor_settings']['buttons'];
438
  } else {
 
439
  if (!is_array($plugin_options['editor_settings']['buttons'])) {
 
440
  if (trim($plugin_options['editor_settings']['buttons']) === "") {
441
  $plugin_options['editor_settings']['buttons'] = array();
442
  } else {
@@ -446,6 +494,7 @@ class RichTextExcerpts {
446
  $plugin_options['editor_settings']['buttons'] = self::cleanup_array($plugin_options['editor_settings']['buttons']);
447
  }
448
  }
 
449
  if (!count($plugin_options['editor_settings']['buttons'])) {
450
  $plugin_options['editor_settings']['buttons'] = $defaults['editor_settings']['buttons'];
451
  $plugin_options['editor_settings']['plugins'] = $defaults['editor_settings']['plugins'];
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.2.1
9
  Text Domain: rich-text-excerpts
10
  License: GPLv3
11
 
53
  */
54
  add_action( 'admin_menu', array( __CLASS__, 'add_plugin_admin_menu' ) );
55
  add_action( 'admin_init', array( __CLASS__, 'register_plugin_options' ) );
56
+ /**
57
+ * add a link to the settings page from the plugins page
58
+ */
59
+ add_filter( 'plugin_action_links', array( __CLASS__, 'add_settings_page_link'), 10, 2 );
60
  /**
61
  * register text domain
62
  */
81
  */
82
  public static function on_activation()
83
  {
84
+ if ( ! current_user_can( 'activate_plugins' ) ) {
85
  return;
86
+ }
87
  update_option('rich_text_excerpts_options', self::get_default_plugin_options());
88
  }
89
 
92
  */
93
  public static function on_deactivation()
94
  {
95
+ if ( ! current_user_can( 'activate_plugins' ) ) {
96
  return;
97
+ }
98
  delete_option('rich_text_excerpts_options');
99
  }
100
 
137
  {
138
  global $post;
139
  $plugin_options = self::get_plugin_options();
140
+ printf('<div class="postbox rich-text-excerpt"><h3><label for="excerpt">%s</label></h3><div class="rte-wrap">', __('Excerpt', 'rich-text-excerpts'));
141
  /* options for editor */
142
  $options = array(
143
  "wpautop" => $plugin_options['editor_settings']['wpautop'],
144
  "media_buttons" => $plugin_options['editor_settings']['media_buttons'],
145
  "textarea_name" => 'excerpt',
146
+ "textarea_rows" => $plugin_options['editor_settings']['textarea_rows'],
147
  "teeny" => ($plugin_options['editor_type'] === "teeny")? true: false
148
  );
149
  /* "echo" the editor */
182
  * PLUGIN OPTIONS ADMINISTRATION *
183
  ************************************************************/
184
 
185
+ /**
186
+ * adds a link to the settings page from the plugins listing page
187
+ * called using the plugin_action_links filter
188
+ */
189
+ public static function add_settings_page_link($links, $file)
190
+ {
191
+ if ($file == plugin_basename(__FILE__)) {
192
+ $settings_page_link = sprintf('<a href="%s">%s</a>', admin_url('options-general.php?page=rich_text_excerpts_options'), __('Settings', 'rich-text-excerpts'));
193
+ $links[] = $settings_page_link;
194
+ }
195
+ return $links;
196
+ }
197
+
198
  /**
199
  * add an admin page under settings to configure the plugin
200
  */
202
  {
203
  /* Plugin Options page */
204
  $options_page = add_submenu_page("options-general.php", __('Rich Text Excerpts', 'rich-text-excerpts'), __('Rich Text Excerpts', 'rich-text-excerpts'), "manage_options", "rich_text_excerpts_options", array( __CLASS__, "plugin_options_page" ) );
205
+ /**
206
+ * Use the admin_print_scripts action to add scripts.
207
+ * Script is needed on both the theme options page and post/page editor
208
+ */
209
  add_action( 'admin_print_scripts', array( __CLASS__, 'plugin_admin_scripts' ) );
210
+ /**
211
+ * Use the admin_print_styles action to add CSS.
212
+ * CSS is needed for the post/page editor only
213
+ */
214
  add_action( 'admin_print_styles', array( __CLASS__, 'plugin_admin_styles' ) );
215
  }
216
 
260
  );
261
  add_settings_field(
262
  'supported_post_types',
263
+ __('Choose which post types will use a rich text editor for excerpts', 'rich-text-excerpts'),
264
  array( __CLASS__, 'options_setting_post_types' ),
265
  'rte',
266
  'post-type-options'
336
  foreach ($post_types as $post_type ) {
337
  if ( post_type_supports($post_type, 'excerpt') ) {
338
  $chckd = (in_array($post_type, $options["supported_post_types"]))? ' checked="checked"': '';
339
+ printf('<p class="rte-post-types-inputs"><input class="rte-post-types" 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);
340
  }
341
  }
342
+ printf('<div class="rte-post-types-error"></p>%s</p></div>', __('If you want to disable support for all post types, please disable the plugin', 'rich-text-excerpts'));
343
  printf('<p>%s<br /><a href="http://codex.wordpress.org/Function_Reference/add_post_type_support">add_post_type_support()</a></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 the Wordpress Codex', 'rich-text-excerpts'));
344
  }
345
 
346
  /**
347
+ * editor type radios
348
  */
349
  public static function options_setting_editor_type()
350
  {
357
  }
358
 
359
  /**
360
+ * Settings for text editor
361
+ * Follows the Wordpress wp_editor function. Arguments not implemented are:
362
+ * - tabindex - may be a way to find out what this should be for a metabox and pass to wp_editor automatically?
363
+ * - editor_css - Additional CSS styling applied for both visual and HTML editors buttons, needs to include <style> tags, can use "scoped" (hard to validate)
364
+ * - editor_class - Any extra CSS Classes to append to the Editor textarea (could be useful?)
365
+ * - dfw - Whether to replace the default fullscreen editor with DFW (needs specific DOM elements and css)
366
+ * - tinymce - Load TinyMCE, can be used to pass settings directly to TinyMCE using an array() - direct people to TinyMCE Advanced rther than implement this
367
+ * - quicktags - Load Quicktags, can be used to pass settings directly to Quicktags using an array() (could be useful? does TA handle quicktags?)
368
+ * @see http://codex.wordpress.org/Function_Reference/wp_editor
369
  */
370
  public static function options_editor_settings()
371
  {
397
  }
398
 
399
  /**
400
+ * takes a string of comma-separated arguments and splits it into an array
401
  */
402
  public static function get_mce_array($inputStr = '')
403
  {
410
 
411
  /**
412
  * removes empty elements from an array
413
+ * Always returns an array, no matter what is passed to it
414
  */
415
  public static function cleanup_array($arr = array())
416
  {
417
  $output = array();
418
+ if (is_array($arr) && count($arr)) {
419
  $arr = array_map('trim', $arr);
420
  foreach ($arr as $str) {
421
  if (!empty($str)) {
428
 
429
  /**
430
  * input validation callback
431
+ * also used to sanitise options in get_plugin_options()
432
  */
433
  public static function validate_rich_text_excerpts_options($plugin_options)
434
  {
435
+ /* get defaults as a fallabck for missing values */
436
  $defaults = self::get_default_plugin_options();
437
+ /* make sure supported post types is an array */
438
  if (!isset($plugin_options['supported_post_types']) || !is_array($plugin_options['supported_post_types'])) {
439
  $plugin_options['supported_post_types'] = $defaults['supported_post_types'];
440
  }
441
+ /* make sure editor type is one of the allowed types */
442
  if (!isset($plugin_options['editor_type']) || !in_array($plugin_options['editor_type'], array('teeny','tiny'))) {
443
  $plugin_options['editor_type'] = $defaults['editor_type'];
444
  }
445
+ /* make sure there are some editor settings */
446
  if (!isset($plugin_options['editor_settings'])) {
447
  $plugin_options['editor_settings'] = $defaults['editor_settings'];
448
  } else {
449
+ /* make sure wpautop is set, and a boolean value */
450
  if (!isset($plugin_options['editor_settings']['wpautop'])) {
451
+ $plugin_options['editor_settings']['wpautop'] = $defaults['editor_settings']['wpautop'];
452
  } else {
453
  $plugin_options['editor_settings']['wpautop'] = (bool) $plugin_options['editor_settings']['wpautop'];
454
  }
455
+ /* make sure media_buttons is set, and a boolean value */
456
  if (!isset($plugin_options['editor_settings']['media_buttons'])) {
457
+ $plugin_options['editor_settings']['media_buttons'] = $defaults['editor_settings']['media_buttons'];
458
  } else {
459
  $plugin_options['editor_settings']['media_buttons'] = (bool) $plugin_options['editor_settings']['media_buttons'];
460
  }
461
+ /* make sure textarea_rows is set, and is an integer greater than 3 */
462
  $plugin_options['editor_settings']['textarea_rows'] = isset($plugin_options['editor_settings']['textarea_rows'])? intval($plugin_options['editor_settings']['textarea_rows']): $defaults['editor_settings']['textarea_rows'];
463
  if ($plugin_options['editor_settings']['textarea_rows'] < 3) {
464
  $plugin_options['editor_settings']['textarea_rows'] = 3;
465
  }
466
+ /* make sure plugins and buttons are set, and are arrays */
467
  if (!isset($plugin_options['editor_settings']['plugins'])) {
468
  $plugin_options['editor_settings']['plugins'] = $defaults['editor_settings']['plugins'];
469
  } else {
470
+ /* if this is a string, we are coming from the settings form */
471
  if (!is_array($plugin_options['editor_settings']['plugins'])) {
472
+ /* tidy up the string and make sure we end up with an array */
473
  if (trim($plugin_options['editor_settings']['plugins']) === "") {
474
  $plugin_options['editor_settings']['plugins'] = array();
475
  } else {
482
  if (!isset($plugin_options['editor_settings']['buttons'])) {
483
  $plugin_options['editor_settings']['buttons'] = $defaults['editor_settings']['buttons'];
484
  } else {
485
+ /* if this is a string, we are coming from the settings form */
486
  if (!is_array($plugin_options['editor_settings']['buttons'])) {
487
+ /* tidy up the string and make sure we end up with an array */
488
  if (trim($plugin_options['editor_settings']['buttons']) === "") {
489
  $plugin_options['editor_settings']['buttons'] = array();
490
  } else {
494
  $plugin_options['editor_settings']['buttons'] = self::cleanup_array($plugin_options['editor_settings']['buttons']);
495
  }
496
  }
497
+ /* if the buttons array is empty, reset both buttons and plugins to the default value */
498
  if (!count($plugin_options['editor_settings']['buttons'])) {
499
  $plugin_options['editor_settings']['buttons'] = $defaults['editor_settings']['buttons'];
500
  $plugin_options['editor_settings']['plugins'] = $defaults['editor_settings']['plugins'];