Advanced Excerpt - Version 4.2

Version Description

  • Feature: Toggle excerpt filtering when there's no break (<!--more-->) tag in the post content
  • Feature: Toggle excerpt filtering for the the_excerpt() and the_content() functions
  • Feature: Toggle excerpt filtering on certain page types
  • Improvement: Added HTML5 tags to the allowed tags list
  • Improvement: Options are now automatically removed from wp_options when the plugin is deleted from the dashboard
  • Improvement: Added several WordPress filters, allowing developers to extend/modify the default functionality of the plugin
  • Improvement: Additional strings were made i18n friendly
  • Improvement: All options are now stored in one row in wp_options rather than one row per option
  • Improvement: Several UI elements have be reworded and styled differently to improve user experience
  • Fix: Now works with themes using the_content() on archive pages (i.e. WordPress default themes and others)
  • Fix: Notices/warning were appearing when the options were saved while having a checkbox option unchecked
  • Fix: The "Read More" link was being incorrectly appended into certain HTML tags, e.g. table tags and list tags
Download this release

Release Info

Developer aprea
Plugin Icon wp plugin Advanced Excerpt
Version 4.2
Comparing to
See all releases

Code changes from version 4.1.1 to 4.2

COPYING DELETED
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
advanced-excerpt.js DELETED
@@ -1,70 +0,0 @@
1
- // Advanced Excerpt options script
2
- jQuery(function($)
3
- {
4
- var plugin_prefix = 'advancedexcerpt';
5
- var tag_cols = $('#' + plugin_prefix + '_tags_table tr:eq(1) td').length;
6
-
7
- var tag_list = new Array();
8
- $('#' + plugin_prefix + '_tags_table input').each(function(i, el)
9
- {
10
- tag_list.push($(el).val());
11
- });
12
-
13
- // Add a tag to the checkbox table
14
- $('#' + plugin_prefix + '_add_tag').click(function(event)
15
- {
16
- event.preventDefault();
17
-
18
- var tag = $('#' + plugin_prefix + '_more_tags option:selected').val();
19
-
20
- // No duplicate tags in the table
21
- if($.inArray(tag, tag_list) > -1)
22
- {
23
- return;
24
- }
25
- tag_list.push(tag);
26
-
27
- var last_row = $('#' + plugin_prefix + '_tags_table tr:last-child');
28
- var tag_count = last_row.find('input').length;
29
- var tag_cell = $(
30
- '<td>' +
31
- '<input name="' + plugin_prefix + '_allowed_tags[]" type="checkbox" value="' + tag + '" checked="checked" />' +
32
- '<code>' + tag + '</code>' +
33
- '</td>'
34
- );
35
-
36
- if(tag_count < tag_cols)
37
- {
38
- // Add to last row
39
- var span = last_row.find('td[colspan]');
40
- if(span.attr('colspan') > 1)
41
- {
42
- span.attr('colspan', span.attr('colspan') - 1);
43
- tag_cell.insertBefore(span);
44
- }
45
- else
46
- {
47
- span.replaceWith(tag_cell);
48
- }
49
- }
50
- else
51
- {
52
- // New row
53
- $('<tr><td colspan="' + (tag_cols - 1) + '">&nbsp;</td></tr>').insertAfter(last_row).prepend(tag_cell);
54
- }
55
- });
56
-
57
- // Check all boxes
58
- $('#' + plugin_prefix + '_select_all').click(function(event)
59
- {
60
- event.preventDefault();
61
- $('input[name="' + plugin_prefix + '_allowed_tags[]"]:gt(0)').attr('checked', 'checked');
62
- });
63
-
64
- // Uncheck all boxes
65
- $('#' + plugin_prefix + '_select_none').click(function(event)
66
- {
67
- event.preventDefault();
68
- $('input[name="' + plugin_prefix + '_allowed_tags[]"]:gt(0)').removeAttr('checked');
69
- });
70
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
advanced-excerpt.php CHANGED
@@ -1,495 +1,25 @@
1
- <?php
2
- /*
3
- Plugin Name: Advanced Excerpt
4
- Plugin URI: http://basvd.com/code/advanced-excerpt/
5
- Description: Several improvements over WP's default excerpt. The size of the excerpt can be limited using character or word count, and HTML markup is not removed.
6
- Version: 4.1.1
7
- Author: Bas van Doren
8
- Author URI: http://basvd.com/
9
-
10
- Copyright 2007 Bas van Doren
11
-
12
- This program is free software; you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation; either version 3 of the License, or
15
- (at your option) any later version.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program. If not, see <http://www.gnu.org/licenses/>.
24
- */
25
-
26
- if (!class_exists('AdvancedExcerpt')):
27
- class AdvancedExcerpt
28
- {
29
- // Plugin configuration
30
- public $name;
31
- public $text_domain;
32
- public $options;
33
- public $default_options = array(
34
- 'length' => 40,
35
- 'use_words' => 1,
36
- 'no_custom' => 1,
37
- 'no_shortcode' => 1,
38
- 'finish_word' => 0,
39
- 'finish_sentence' => 0,
40
- 'ellipsis' => '&hellip;',
41
- 'read_more' => 'Read the rest',
42
- 'add_link' => 0,
43
- 'allowed_tags' => array('_all')
44
- );
45
-
46
- // Basic HTML tags (determines which tags are in the checklist by default)
47
- public static $options_basic_tags = array
48
- (
49
- 'a', 'abbr', 'acronym', 'b', 'big',
50
- 'blockquote', 'br', 'center', 'cite', 'code', 'dd', 'del', 'div', 'dl', 'dt',
51
- 'em', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins',
52
- 'li', 'ol', 'p', 'pre', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub',
53
- 'sup', 'table', 'td', 'th', 'tr', 'u', 'ul'
54
- );
55
-
56
- // Almost all HTML tags (extra options)
57
- public static $options_all_tags = array(
58
- 'a', 'abbr', 'acronym', 'address', 'applet',
59
- 'area', 'b', 'bdo', 'big', 'blockquote', 'br', 'button', 'caption', 'center',
60
- 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl',
61
- 'dt', 'em', 'fieldset', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3',
62
- 'h4', 'h5', 'h6', 'hr', 'i', 'iframe', 'img', 'input', 'ins', 'isindex', 'kbd',
63
- 'label', 'legend', 'li', 'map', 'menu', 'noframes', 'noscript', 'object',
64
- 'ol', 'optgroup', 'option', 'p', 'param', 'pre', 'q', 's', 'samp', 'script',
65
- 'select', 'small', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table',
66
- 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul',
67
- 'var'
68
- );
69
-
70
- // Singleton
71
- private static $inst = null;
72
- public static function Instance($new = false)
73
- {
74
- if (self::$inst == null || $new)
75
- {
76
- self::$inst = new AdvancedExcerpt();
77
- }
78
- return self::$inst;
79
- }
80
-
81
- private function __construct()
82
- {
83
- $this->name = strtolower(get_class());
84
- $this->text_domain = $this->name;
85
- $this->load_options();
86
-
87
- load_plugin_textdomain($this->text_domain, false, dirname(plugin_basename(__FILE__)));
88
- register_activation_hook(__FILE__, array(
89
- &$this,
90
- 'install'
91
- ));
92
- //register_deactivation_hook($file, array(&$this, 'uninstall'));
93
-
94
- add_action('admin_menu', array(
95
- &$this,
96
- 'add_pages'
97
- ));
98
-
99
- // Replace the default filter (see /wp-includes/default-filters.php)
100
- //remove_filter('get_the_excerpt', 'wp_trim_excerpt');
101
- // Replace everything
102
- remove_all_filters('get_the_excerpt');
103
- add_filter('get_the_excerpt', array(
104
- &$this,
105
- 'filter'
106
- ));
107
- }
108
-
109
- public function filter($text)
110
- {
111
- // Extract options (skip collisions)
112
- if (is_array($this->options))
113
- {
114
- extract($this->options, EXTR_SKIP);
115
- $this->options = null; // Reset
116
- }
117
- extract($this->default_options, EXTR_SKIP);
118
-
119
- // Avoid custom excerpts
120
- if (!empty($text) && !$no_custom)
121
- return $text;
122
-
123
- // Get the full content and filter it
124
- $text = get_the_content('');
125
- if (1 == $no_shortcode)
126
- $text = strip_shortcodes($text);
127
- $text = apply_filters('the_content', $text);
128
-
129
- // From the default wp_trim_excerpt():
130
- // Some kind of precaution against malformed CDATA in RSS feeds I suppose
131
- $text = str_replace(']]>', ']]&gt;', $text);
132
-
133
- // Determine allowed tags
134
- if(!isset($allowed_tags))
135
- $allowed_tags = self::$options_all_tags;
136
-
137
- if(isset($exclude_tags))
138
- $allowed_tags = array_diff($allowed_tags, $exclude_tags);
139
-
140
- // Strip HTML if allow-all is not set
141
- if (!in_array('_all', $allowed_tags))
142
- {
143
- if (count($allowed_tags) > 0)
144
- $tag_string = '<' . implode('><', $allowed_tags) . '>';
145
- else
146
- $tag_string = '';
147
- $text = strip_tags($text, $tag_string);
148
- }
149
-
150
- // Create the excerpt
151
- $text = $this->text_excerpt($text, $length, $use_words, $finish_word, $finish_sentence);
152
-
153
- // Add the ellipsis or link
154
- $text = $this->text_add_more($text, $ellipsis, ($add_link) ? $read_more : false);
155
-
156
- return $text;
157
- }
158
-
159
- public function text_excerpt($text, $length, $use_words, $finish_word, $finish_sentence)
160
- {
161
- $tokens = array();
162
- $out = '';
163
- $w = 0;
164
-
165
- // Divide the string into tokens; HTML tags, or words, followed by any whitespace
166
- // (<[^>]+>|[^<>\s]+\s*)
167
- preg_match_all('/(<[^>]+>|[^<>\s]+)\s*/u', $text, $tokens);
168
- foreach ($tokens[0] as $t)
169
- { // Parse each token
170
- if ($w >= $length && !$finish_sentence)
171
- { // Limit reached
172
- break;
173
- }
174
- if ($t[0] != '<')
175
- { // Token is not a tag
176
- if ($w >= $length && $finish_sentence && preg_match('/[\?\.\!]\s*$/uS', $t) == 1)
177
- { // Limit reached, continue until ? . or ! occur at the end
178
- $out .= trim($t);
179
- break;
180
- }
181
- if (1 == $use_words)
182
- { // Count words
183
- $w++;
184
- } else
185
- { // Count/trim characters
186
- $chars = trim($t); // Remove surrounding space
187
- $c = strlen($chars);
188
- if ($c + $w > $length && !$finish_sentence)
189
- { // Token is too long
190
- $c = ($finish_word) ? $c : $length - $w; // Keep token to finish word
191
- $t = substr($t, 0, $c);
192
- }
193
- $w += $c;
194
- }
195
- }
196
- // Append what's left of the token
197
- $out .= $t;
198
- }
199
-
200
- return trim(force_balance_tags($out));
201
- }
202
-
203
- public function text_add_more($text, $ellipsis, $read_more)
204
- {
205
- // New filter in WP2.9, seems unnecessary for now
206
- //$ellipsis = apply_filters('excerpt_more', $ellipsis);
207
-
208
- if ($read_more)
209
- $ellipsis .= sprintf(' <a href="%s" class="read_more">%s</a>', get_permalink(), $read_more);
210
-
211
- $pos = strrpos($text, '</');
212
- if ($pos !== false)
213
- // Inside last HTML tag
214
- $text = substr_replace($text, $ellipsis, $pos, 0);
215
- else
216
- // After the content
217
- $text .= $ellipsis;
218
-
219
- return $text;
220
- }
221
-
222
- public function install()
223
- {
224
- foreach($this->default_options as $k => $v)
225
- {
226
- add_option($this->name . '_' . $k, $v);
227
- }
228
- }
229
-
230
- public function uninstall()
231
- {
232
- // Nothing to do (note: deactivation hook is also disabled)
233
- }
234
-
235
- private function load_options()
236
- {
237
- foreach($this->default_options as $k => $v)
238
- {
239
- $this->default_options[$k] = get_option($this->name . '_' . $k, $v);
240
- }
241
- }
242
-
243
- private function update_options()
244
- {
245
- $length = (int) $_POST[$this->name . '_length'];
246
- $use_words = ('on' == $_POST[$this->name . '_use_words']) ? 1 : 0;
247
- $no_custom = ('on' == $_POST[$this->name . '_no_custom']) ? 1 : 0;
248
- $no_shortcode = ('on' == $_POST[$this->name . '_no_shortcode']) ? 1 : 0;
249
- $finish_word = ('on' == $_POST[$this->name . '_finish_word']) ? 1 : 0;
250
- $finish_sentence = ('on' == $_POST[$this->name . '_finish_sentence']) ? 1 : 0;
251
- $add_link = ('on' == $_POST[$this->name . '_add_link']) ? 1 : 0;
252
-
253
- // TODO: Drop magic quotes (deprecated in php 5.3)
254
- $ellipsis = (get_magic_quotes_gpc() == 1) ? stripslashes($_POST[$this->name . '_ellipsis']) : $_POST[$this->name . '_ellipsis'];
255
- $read_more = (get_magic_quotes_gpc() == 1) ? stripslashes($_POST[$this->name . '_read_more']) : $_POST[$this->name . '_read_more'];
256
-
257
- $allowed_tags = array_unique((array) $_POST[$this->name . '_allowed_tags']);
258
-
259
- update_option($this->name . '_length', $length);
260
- update_option($this->name . '_use_words', $use_words);
261
- update_option($this->name . '_no_custom', $no_custom);
262
- update_option($this->name . '_no_shortcode', $no_shortcode);
263
- update_option($this->name . '_finish_word', $finish_word);
264
- update_option($this->name . '_finish_sentence', $finish_sentence);
265
- update_option($this->name . '_ellipsis', $ellipsis);
266
- update_option($this->name . '_read_more', $read_more);
267
- update_option($this->name . '_add_link', $add_link);
268
- update_option($this->name . '_allowed_tags', $allowed_tags);
269
-
270
- $this->load_options();
271
- ?>
272
- <div id="message" class="updated fade"><p>Options saved.</p></div>
273
- <?php
274
- }
275
-
276
- public function page_options()
277
- {
278
- if ('POST' == $_SERVER['REQUEST_METHOD'])
279
- {
280
- check_admin_referer($this->name . '_update_options');
281
- $this->update_options();
282
- }
283
-
284
- extract($this->default_options, EXTR_SKIP);
285
-
286
- $ellipsis = htmlentities($ellipsis);
287
- $read_more = htmlentities($read_more);
288
-
289
- $tag_list = array_unique(self::$options_basic_tags + $allowed_tags);
290
- sort($tag_list);
291
- $tag_cols = 5;
292
- ?>
293
- <div class="wrap">
294
- <div id="icon-options-general" class="icon32"><br /></div>
295
- <h2><?php
296
- _e("Advanced Excerpt Options", $this->text_domain);
297
- ?></h2>
298
- <form method="post" action="">
299
- <?php
300
- if (function_exists('wp_nonce_field'))
301
- wp_nonce_field($this->name . '_update_options');
302
- ?>
303
-
304
- <table class="form-table">
305
- <tr valign="top">
306
- <th scope="row"><label for="<?php echo $this->name; ?>_length">
307
- <?php _e("Excerpt Length:", $this->text_domain); ?></label></th>
308
- <td>
309
- <input name="<?php echo $this->name; ?>_length" type="text"
310
- id="<?php echo $this->name; ?>_length"
311
- value="<?php echo $length; ?>" size="2"/>
312
- <input name="<?php echo $this->name; ?>_use_words" type="checkbox"
313
- id="<?php echo $this->name; ?>_use_words" value="on"<?php
314
- echo (1 == $use_words) ? ' checked="checked"' : ''; ?>/>
315
- <?php _e("Use words?", $this->text_domain); ?>
316
- </td>
317
- </tr>
318
- <tr valign="top">
319
- <th scope="row"><label for="<?php echo $this->name; ?>_ellipsis">
320
- <?php _e("Ellipsis:", $this->text_domain); ?></label></th>
321
- <td>
322
- <input name="<?php echo $this->name; ?>_ellipsis" type="text"
323
- id="<?php echo $this->name; ?>_ellipsis"
324
- value="<?php echo $ellipsis; ?>" size="5"/>
325
- <?php _e('(use <a href="http://www.w3schools.com/tags/ref_entities.asp">HTML entities</a>)', $this->text_domain); ?>
326
- <br />
327
- <?php _e("Will substitute the part of the post that is omitted in the excerpt.", $this->text_domain); ?>
328
- </td>
329
- </tr>
330
- <tr valign="top">
331
- <th scope="row"><label for="<?php echo $this->name; ?>_length">
332
- <?php _e("Finish:", $this->text_domain); ?></label></th>
333
- <td>
334
- <input name="<?php echo $this->name; ?>_finish_word" type="checkbox"
335
- id="<?php echo $this->name; ?>_finish_word" value="on"<?php
336
- echo (1 == $finish_word) ? ' checked="checked"' : ''; ?>/>
337
- <?php _e("Word", $this->text_domain); ?><br/>
338
- <input name="<?php echo $this->name; ?>_finish_sentence" type="checkbox"
339
- id="<?php echo $this->name; ?>_finish_sentence" value="on"<?php
340
- echo (1 == $finish_sentence) ? ' checked="checked"' : ''; ?>/>
341
- <?php _e("Sentence", $this->text_domain); ?>
342
- <br />
343
- <?php _e("Prevents cutting a word or sentence at the end of an excerpt. This option can result in (slightly) longer excerpts.", $this->text_domain); ?>
344
- </td>
345
- </tr>
346
- <tr valign="top">
347
- <th scope="row"><label for="<?php echo $this->name; ?>_read_more">
348
- <?php _e("&lsquo;Read-more&rsquo; Text:", $this->text_domain); ?></label></th>
349
- <td>
350
- <input name="<?php echo $this->name; ?>_read_more" type="text"
351
- id="<?php echo $this->name; ?>_read_more" value="<?php echo $read_more; ?>" />
352
- <input name="<?php echo $this->name; ?>_add_link" type="checkbox"
353
- id="<?php echo $this->name; ?>_add_link" value="on" <?php
354
- echo (1 == $add_link) ? 'checked="checked" ' : ''; ?>/>
355
- <?php _e("Add link to excerpt", $this->text_domain); ?>
356
- </td>
357
- </tr>
358
- <tr valign="top">
359
- <th scope="row"><label for="<?php echo $this->name; ?>_no_custom">
360
- <?php _e("No Custom Excerpts:", $this->text_domain); ?></label></th>
361
- <td>
362
- <input name="<?php echo $this->name; ?>_no_custom" type="checkbox"
363
- id="<?php echo $this->name; ?>_no_custom" value="on" <?php
364
- echo (1 == $no_custom) ? 'checked="checked" ' : ''; ?>/>
365
- <?php _e("Generate excerpts even if a post has a custom excerpt attached.", $this->text_domain); ?>
366
- </td>
367
- </tr>
368
- <tr valign="top">
369
- <th scope="row"><label for="<?php echo $this->name; ?>_no_shortcode">
370
- <?php _e("Strip Shortcodes:", $this->text_domain); ?></label></th>
371
- <td>
372
- <input name="<?php echo $this->name; ?>_no_shortcode" type="checkbox"
373
- id="<?php echo $this->name; ?>_no_shortcode" value="on" <?php
374
- echo (1 == $no_shortcode) ? 'checked="checked" ' : ''; ?>/>
375
- <?php _e("Remove shortcodes from the excerpt. <em>(recommended)</em>", $this->text_domain); ?>
376
- </td>
377
- </tr>
378
- <tr valign="top">
379
- <th scope="row"><?php _e("Keep Markup:", $this->text_domain); ?></th>
380
- <td>
381
- <table id="<?php echo $this->name; ?>_tags_table">
382
- <tr>
383
- <td colspan="<?php echo $tag_cols; ?>">
384
- <input name="<?php echo $this->name; ?>_allowed_tags[]" type="checkbox"
385
- value="_all" <?php echo (in_array('_all', $allowed_tags)) ? 'checked="checked" ' : ''; ?>/>
386
- <?php _e("Don't remove any markup", $this->text_domain); ?>
387
- </td>
388
- </tr>
389
- <?php
390
- $i = 0;
391
- foreach ($tag_list as $tag):
392
- if ($tag == '_all')
393
- continue;
394
- if (0 == $i % $tag_cols):
395
- ?>
396
- <tr>
397
- <?php
398
- endif;
399
- $i++;
400
- ?>
401
- <td>
402
- <input name="<?php echo $this->name; ?>_allowed_tags[]" type="checkbox"
403
- value="<?php echo $tag; ?>" <?php
404
- echo (in_array($tag, $allowed_tags)) ? 'checked="checked" ' : ''; ?>/>
405
- <code><?php echo $tag; ?></code>
406
- </td>
407
- <?php
408
- if (0 == $i % $tag_cols):
409
- $i = 0;
410
- echo '</tr>';
411
- endif;
412
- endforeach;
413
- if (0 != $i % $tag_cols):
414
- ?>
415
- <td colspan="<?php echo ($tag_cols - $i); ?>">&nbsp;</td>
416
- </tr>
417
- <?php
418
- endif;
419
- ?>
420
- </table>
421
- <a href="" id="<?php echo $this->name; ?>_select_all">Select all</a>
422
- / <a href="" id="<?php echo $this->name; ?>_select_none">Select none</a><br />
423
- More tags:
424
- <select name="<?php echo $this->name; ?>_more_tags" id="<?php echo $this->name; ?>_more_tags">
425
- <?php
426
- foreach (self::$options_all_tags as $tag):
427
- ?>
428
- <option value="<?php echo $tag; ?>"><?php echo $tag; ?></option>
429
- <?php
430
- endforeach;
431
- ?>
432
- </select>
433
- <input type="button" name="<?php echo $this->name; ?>_add_tag" id="<?php echo $this->name; ?>_add_tag" class="button" value="Add tag" />
434
- </td>
435
- </tr>
436
- </table>
437
- <p class="submit"><input type="submit" name="Submit" class="button-primary"
438
- value="<?php _e("Save Changes", $this->text_domain); ?>" /></p>
439
- </form>
440
- </div>
441
- <?php
442
- }
443
-
444
- public function page_script()
445
- {
446
- wp_enqueue_script($this->name . '_script', WP_PLUGIN_URL . '/advanced-excerpt/advanced-excerpt.js', array(
447
- 'jquery'
448
- ));
449
- }
450
-
451
- public function add_pages()
452
- {
453
- $options_page = add_options_page(__("Advanced Excerpt Options", $this->text_domain), __("Excerpt", $this->text_domain), 'manage_options', 'options-' . $this->name, array(
454
- &$this,
455
- 'page_options'
456
- ));
457
-
458
- // Scripts
459
- add_action('admin_print_scripts-' . $options_page, array(
460
- &$this,
461
- 'page_script'
462
- ));
463
- }
464
- }
465
-
466
- AdvancedExcerpt::Instance();
467
-
468
- // Do not use outside the Loop!
469
- function the_advanced_excerpt($args = '', $get = false)
470
- {
471
- if (!empty($args) && !is_array($args))
472
- {
473
- $args = wp_parse_args($args);
474
-
475
- // Parse query style parameters
476
- if (isset($args['ellipsis']))
477
- $args['ellipsis'] = urldecode($args['ellipsis']);
478
-
479
- if (isset($args['allowed_tags']))
480
- $args['allowed_tags'] = preg_split('/[\s,]+/', $args['allowed_tags']);
481
-
482
- if (isset($args['exclude_tags']))
483
- {
484
- $args['exclude_tags'] = preg_split('/[\s,]+/', $args['exclude_tags']);
485
- }
486
- }
487
- // Set temporary options
488
- AdvancedExcerpt::Instance()->options = $args;
489
-
490
- if ($get)
491
- return get_the_excerpt();
492
- else
493
- the_excerpt();
494
- }
495
- endif;
1
+ <?php
2
+ /*
3
+ Plugin Name: Advanced Excerpt
4
+ Plugin URI: http://wordpress.org/plugins/advanced-excerpt/
5
+ Description: Control the appearance of WordPress post excerpts
6
+ Version: 4.2
7
+ Author: Delicious Brains
8
+ Author URI: http://deliciousbrains.com/
9
+ */
10
+
11
+ $GLOBALS['advanced_excerpt_version'] = '4.2';
12
+
13
+ function advanced_excerpt_load_textdomain() {
14
+ load_plugin_textdomain( 'advanced-excerpt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
15
+ }
16
+ add_action( 'wp_loaded', 'advanced_excerpt_load_textdomain' );
17
+
18
+ require_once 'class/advanced-excerpt.php';
19
+ require_once 'functions/functions.php';
20
+
21
+ function advanced_excerpt_init() {
22
+ global $advanced_excerpt;
23
+ $advanced_excerpt = new Advanced_Excerpt( __FILE__ );
24
+ }
25
+ add_action( 'init', 'advanced_excerpt_init', 5 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
advancedexcerpt-nl_NL.mo DELETED
Binary file
advancedexcerpt.po DELETED
@@ -1,64 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Advanced Excerpt\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-01-14 16:33+0100\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: Bas van Doren\n"
8
- "Language-Team: \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: _e;__\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: .\n"
15
-
16
- #: advanced-excerpt.php:223
17
- #: advanced-excerpt.php:279
18
- msgid "Advanced Excerpt Options"
19
- msgstr "Verbeterde Uittreksel Opties"
20
-
21
- #: advanced-excerpt.php:231
22
- msgid "Excerpt Length:"
23
- msgstr "Lengte van uittreksel:"
24
-
25
- #: advanced-excerpt.php:234
26
- msgid "Use words?"
27
- msgstr "Gebruik woorden?"
28
-
29
- #: advanced-excerpt.php:238
30
- msgid "Ellipsis:"
31
- msgstr "Weglating:"
32
-
33
- #: advanced-excerpt.php:240
34
- msgid "(use <a href=\"http://www.w3schools.com/tags/ref_entities.asp\">HTML entities</a>)"
35
- msgstr "(gebruik <a href=\"http://www.w3schools.com/tags/ref_entities.asp\">HTML entiteiten</a>)"
36
-
37
- #: advanced-excerpt.php:242
38
- msgid "Will substitute the part of the post that is omitted in the excerpt."
39
- msgstr "Vervangt het deel van het bericht dat weggelaten wordt in de uittreksel."
40
-
41
- #: advanced-excerpt.php:246
42
- msgid "No Custom Excerpts:"
43
- msgstr "Negeer gebruikers uittreksels:"
44
-
45
- #: advanced-excerpt.php:249
46
- msgid "Generate excerpts even if a post has a custom excerpt attached."
47
- msgstr "Genereer altijd een uittreksel, ook als er al een bij het bericht gevoegd is."
48
-
49
- #: advanced-excerpt.php:253
50
- msgid "Keep Markup:"
51
- msgstr "Behoud opmaak:"
52
-
53
- #: advanced-excerpt.php:267
54
- msgid "See <a href=\"http://xref.redalt.com/wptrunk/nav.htm?wp-includes/kses.php.source.htm\"><code>wp-includes/kses.php</code></a> if you want to control more tags."
55
- msgstr "Zie <a href=\"http://xref.redalt.com/wptrunk/nav.htm?wp-includes/kses.php.source.htm\"><code>wp-includes/kses.php</code></a> als je meer controle wil over deze tags."
56
-
57
- #: advanced-excerpt.php:271
58
- msgid "Save Changes"
59
- msgstr "Wijzigingen opslaan"
60
-
61
- #: advanced-excerpt.php:279
62
- msgid "Excerpt"
63
- msgstr "Uittreksel"
64
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
asset/css/styles.css ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .advanced-excerpt .advanced-excerpt-container {
2
+ position: relative;
3
+ }
4
+ .advanced-excerpt .advanced-excerpt-main {
5
+ margin-right: 320px;
6
+ min-height: 775px;
7
+ }
8
+ .advanced-excerpt #length {
9
+ vertical-align: inherit;
10
+ }
11
+ .advanced-excerpt #tags-table {
12
+ border-collapse: collapse;
13
+ }
14
+ .advanced-excerpt #tags-table td {
15
+ padding: 0px 20px 30px 0px;
16
+ }
17
+ .advanced-excerpt #read-more {
18
+ margin-top: 7px;
19
+ }
20
+ .advanced-excerpt .monospaced {
21
+ font-family: Consolas,Monaco,monospace;
22
+ }
23
+ .advanced-excerpt .sub-options {
24
+ margin: 4px 0px 0px 20px;
25
+ }
26
+ .advanced-excerpt .disabled {
27
+ color: #999999;
28
+ cursor: default;
29
+ }
30
+ .advanced-excerpt .disabled input {
31
+ cursor: default;
32
+ }
33
+ .advanced-excerpt #advanced-excerpt-sidebar {
34
+ position: absolute;
35
+ top: 0;
36
+ right: 0;
37
+ width: 292px;
38
+ }
39
+ .advanced-excerpt #advanced-excerpt-sidebar .inside {
40
+ padding: 20px;
41
+ border: 1px solid #ccc;
42
+ border-bottom: none;
43
+ }
44
+ .advanced-excerpt #advanced-excerpt-sidebar .author {
45
+ padding-bottom: 20px;
46
+ margin-bottom: 20px;
47
+ border-bottom: 1px solid #ccc;
48
+ overflow: hidden;
49
+ }
50
+ .advanced-excerpt #advanced-excerpt-sidebar .author img {
51
+ float: left;
52
+ margin-right: 20px;
53
+ }
54
+ .advanced-excerpt #advanced-excerpt-sidebar .author .desc {
55
+ float: left;
56
+ }
57
+ .advanced-excerpt #advanced-excerpt-sidebar .author h3 {
58
+ font-size: 12px;
59
+ margin: 0;
60
+ }
61
+ .advanced-excerpt #advanced-excerpt-sidebar .author h2 {
62
+ font-size: 18px;
63
+ margin: 0;
64
+ padding: 0;
65
+ }
66
+ .advanced-excerpt #advanced-excerpt-sidebar .author h2 a {
67
+ color: #464646;
68
+ text-decoration: none;
69
+ }
70
+ .advanced-excerpt #advanced-excerpt-sidebar .author h2 a:hover {
71
+ color: #000;
72
+ }
73
+ .advanced-excerpt #advanced-excerpt-sidebar .author p {
74
+ margin: 0;
75
+ }
76
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe h2 {
77
+ padding: 0;
78
+ margin: 0;
79
+ margin-bottom: 0.5em;
80
+ color: #666;
81
+ font-size: 20px;
82
+ line-height: 1.2em;
83
+ }
84
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe h3 {
85
+ font-size: 16px;
86
+ margin: 0;
87
+ }
88
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe p {
89
+ margin: 0;
90
+ }
91
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe p.interesting {
92
+ margin-bottom: 1em;
93
+ }
94
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe .links {
95
+ margin-bottom: 2em;
96
+ }
97
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe .links a {
98
+ text-decoration: none;
99
+ }
100
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe .promise {
101
+ color: #999;
102
+ font-size: 12px;
103
+ line-height: 1.4em;
104
+ }
105
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe .field {
106
+ margin-bottom: 0.5em;
107
+ }
108
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe .field p {
109
+ margin-bottom: 0.3em;
110
+ }
111
+ .advanced-excerpt #advanced-excerpt-sidebar .subscribe .field.submit-button {
112
+ margin-bottom: 1em;
113
+ }
114
+ @media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx) {
115
+ .advanced-excerpt #advanced-excerpt-sidebar .wpmdb-banner {
116
+ background-image: url(../img/wp-migrate-db-pro@2x.jpg);
117
+ background-size: 292px 292px;
118
+ width: 292px;
119
+ height: 292px;
120
+ display: block;
121
+ }
122
+ .advanced-excerpt #advanced-excerpt-sidebar .wpmdb-banner img {
123
+ display: none;
124
+ }
125
+ }
asset/img/wp-migrate-db-pro.jpg ADDED
Binary file
asset/img/wp-migrate-db-pro@2x.jpg ADDED
Binary file
asset/js/advanced-excerpt.js ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+
3
+ $(document).ready(function() {
4
+ var tag_cols = $('#tags-table tr:eq(1) td').length;
5
+
6
+ var tag_list = new Array();
7
+ $('#tags-table input').each(function(i, el){
8
+ tag_list.push($(el).val());
9
+ });
10
+
11
+ $('#the-content').change(function(event){
12
+ if( $(this).is(':checked') ){
13
+ $('#the-content-no-break-label').removeClass('disabled');
14
+ $('#the-content-no-break').removeAttr('disabled');
15
+ } else {
16
+ $('#the-content-no-break-label').addClass('disabled');
17
+ $('#the-content-no-break').attr('disabled','disabled');
18
+ $('#the-content-no-break').attr('checked', false);
19
+ }
20
+ });
21
+
22
+ $('#add-link').change(function(event){
23
+ if( $(this).is(':checked') ){
24
+ $('#read-more').removeAttr('disabled');
25
+ } else {
26
+ $('#read-more').attr('disabled','disabled');
27
+ }
28
+ });
29
+
30
+ $('input[name=allowed_tags_option]').change(function(event){
31
+ if ( 'dont_remove_any' == $(this).val() ){
32
+ $('#tags-table tr').not(':first-child').hide();
33
+ $('.tags-control').hide();
34
+ } else {
35
+ $('#tags-table tr').not(':first-child').show();
36
+ $('.tags-control').show();
37
+ }
38
+ });
39
+
40
+ // Add a tag to the checkbox table
41
+ $('#add-tag').click(function(event){
42
+ event.preventDefault();
43
+
44
+ var tag = $('#more-tags option:selected').val();
45
+
46
+ // No duplicate tags in the table
47
+ if($.inArray(tag, tag_list) > -1){
48
+ return;
49
+ }
50
+ tag_list.push(tag);
51
+
52
+ var last_row = $('#tags-table tr:last-child');
53
+ var tag_count = last_row.find('input').length;
54
+ var tag_cell = $(
55
+ '<td>' +
56
+ '<label for="ae-' + tag + '">' +
57
+ '<input name="allowed_tags[]" type="checkbox" id="ae-' + tag + '" value="' + tag + '" checked="checked" />' +
58
+ '<code>' + tag + '</code>' +
59
+ '</label>' +
60
+ '</td>'
61
+ );
62
+
63
+ if(tag_count < tag_cols){
64
+ // Add to last row
65
+ var span = last_row.find('td[colspan]');
66
+ if(span.attr('colspan') > 1){
67
+ span.attr('colspan', span.attr('colspan') - 1);
68
+ tag_cell.insertBefore(span);
69
+ } else {
70
+ span.replaceWith(tag_cell);
71
+ }
72
+ } else {
73
+ // New row
74
+ $('<tr><td colspan="' + (tag_cols - 1) + '">&nbsp;</td></tr>').insertAfter(last_row).prepend(tag_cell);
75
+ }
76
+ });
77
+
78
+ // Check all boxes
79
+ $('#select-all').click(function(event){
80
+ event.preventDefault();
81
+ $('input[name="allowed_tags[]"]:gt(0)').attr('checked', 'checked');
82
+ });
83
+
84
+ // Uncheck all boxes
85
+ $('#select-none').click(function(event){
86
+ event.preventDefault();
87
+ $('input[name="allowed_tags[]"]:gt(0)').removeAttr('checked');
88
+ });
89
+ });
90
+
91
+ })(jQuery);
asset/js/advanced-excerpt.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(a){a(document).ready(function(){var b=a("#tags-table tr:eq(1) td").length,c=new Array;a("#tags-table input").each(function(b,d){c.push(a(d).val())}),a("#the-content").change(function(){a(this).is(":checked")?(a("#the-content-no-break-label").removeClass("disabled"),a("#the-content-no-break").removeAttr("disabled")):(a("#the-content-no-break-label").addClass("disabled"),a("#the-content-no-break").attr("disabled","disabled"),a("#the-content-no-break").attr("checked",!1))}),a("#add-link").change(function(){a(this).is(":checked")?a("#read-more").removeAttr("disabled"):a("#read-more").attr("disabled","disabled")}),a("input[name=allowed_tags_option]").change(function(){"dont_remove_any"==a(this).val()?(a("#tags-table tr").not(":first-child").hide(),a(".tags-control").hide()):(a("#tags-table tr").not(":first-child").show(),a(".tags-control").show())}),a("#add-tag").click(function(d){d.preventDefault();var e=a("#more-tags option:selected").val();if(!(a.inArray(e,c)>-1)){c.push(e);var f=a("#tags-table tr:last-child"),g=f.find("input").length,h=a('<td><label for="ae-'+e+'"><input name="allowed_tags[]" type="checkbox" id="ae-'+e+'" value="'+e+'" checked="checked" /><code>'+e+"</code></label></td>");if(b>g){var i=f.find("td[colspan]");i.attr("colspan")>1?(i.attr("colspan",i.attr("colspan")-1),h.insertBefore(i)):i.replaceWith(h)}else a('<tr><td colspan="'+(b-1)+'">&nbsp;</td></tr>').insertAfter(f).prepend(h)}}),a("#select-all").click(function(b){b.preventDefault(),a('input[name="allowed_tags[]"]:gt(0)').attr("checked","checked")}),a("#select-none").click(function(b){b.preventDefault(),a('input[name="allowed_tags[]"]:gt(0)').removeAttr("checked")})})}(jQuery);
class/advanced-excerpt.php ADDED
@@ -0,0 +1,402 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Advanced_Excerpt {
3
+ public $options;
4
+
5
+ /*
6
+ * Some of the following options below are linked to checkboxes on the plugin's option page.
7
+ * If any checkbox options are added/removed/modified in the future please ensure you also update
8
+ * the $checkbox_options variable in the update_options() method.
9
+ */
10
+ public $default_options = array(
11
+ 'length' => 40,
12
+ 'length_type' => 'words',
13
+ 'no_custom' => 1,
14
+ 'no_shortcode' => 1,
15
+ 'finish' => 'exact',
16
+ 'ellipsis' => '&hellip;',
17
+ 'read_more' => 'Read the rest',
18
+ 'add_link' => 0,
19
+ 'allowed_tags' => array(),
20
+ 'the_excerpt' => 1,
21
+ 'the_content' => 1,
22
+ 'the_content_no_break' => 0,
23
+ 'exclude_pages' => array(),
24
+ 'allowed_tags_option' => 'dont_remove_any',
25
+ );
26
+
27
+ public $options_basic_tags; // Basic HTML tags (determines which tags are in the checklist by default)
28
+ public $options_all_tags; // Almost all HTML tags (extra options)
29
+
30
+ function __construct( $plugin_file_path ) {
31
+ $this->load_options();
32
+
33
+ $this->plugin_version = $GLOBALS['advanced_excerpt_version'];
34
+ $this->plugin_file_path = $plugin_file_path;
35
+ $this->plugin_dir_path = plugin_dir_path( $plugin_file_path );
36
+ $this->plugin_folder_name = basename( $this->plugin_dir_path );
37
+ $this->plugin_basename = plugin_basename( $plugin_file_path );
38
+ $this->plugin_base ='options-general.php?page=advanced-excerpt';
39
+
40
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_REQUEST['page'] ) && 'advanced-excerpt' === $_REQUEST['page'] ) {
41
+ check_admin_referer( 'advanced_excerpt_update_options' );
42
+ $this->update_options();
43
+ }
44
+
45
+ $this->options_basic_tags = apply_filters( 'advanced_excerpt_basic_tags', array(
46
+ 'a', 'abbr', 'acronym', 'address', 'article', 'aside', 'audio', 'b', 'big',
47
+ 'blockquote', 'br', 'canvas', 'center', 'cite', 'code', 'dd', 'del', 'div', 'dl', 'dt',
48
+ 'em', 'embed', 'form', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'i', 'img', 'ins',
49
+ 'li', 'nav', 'ol', 'p', 'pre', 'q', 's', 'section', 'small', 'span', 'strike', 'strong', 'sub',
50
+ 'sup', 'svg', 'table', 'td', 'template', 'th', 'time', 'tr', 'u', 'ul', 'video'
51
+ ) );
52
+
53
+ $this->options_all_tags = apply_filters( 'advanced_excerpt_all_tags', array(
54
+ 'a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big',
55
+ 'blockquote', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'data',
56
+ 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption',
57
+ 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr',
58
+ 'i', 'iframe', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'legend', 'li', 'main', 'map',
59
+ 'mark', 'math', 'menu', 'menuitem', 'meter', 'nav', 'noframes', 'noscript', 'object', 'ol', 'optgroup',
60
+ 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section',
61
+ 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'svg', 'table',
62
+ 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var',
63
+ 'video', 'wbr'
64
+ ) );
65
+
66
+ if ( is_admin() ) {
67
+ $this->admin_init();
68
+ }
69
+
70
+ add_action( 'loop_start', array( $this, 'hook_content_filters' ) );
71
+ }
72
+
73
+ function hook_content_filters() {
74
+ /*
75
+ * Allow developers to skip running the advanced excerpt filters on certain page types.
76
+ * They can do so by using the "Disable On" checkboxes on the options page or
77
+ * by passing in an array of page types they'd like to skip
78
+ * e.g. array( 'search', 'author' );
79
+ * The filter, when implemented, takes precedence over the options page selection.
80
+ *
81
+ * WordPress default themes (and others) do not use the_excerpt() or get_the_excerpt()
82
+ * instead they use the_content(). As such, we also need to hook into the_content().
83
+ * To ensure we're not changing the content of posts / pages we first check if is_singular().
84
+ */
85
+ $page_types = $this->get_current_page_types();
86
+ $skip_page_types = array_unique( array_merge( array( 'singular' ), $this->options['exclude_pages'] ) );
87
+ $skip_page_types = apply_filters( 'advanced_excerpt_skip_page_types', $skip_page_types );
88
+ $page_type_matches = array_intersect( $page_types, $skip_page_types );
89
+ if ( !empty( $page_types ) && !empty( $page_type_matches ) ) return;
90
+
91
+ if( 1 == $this->options['the_excerpt'] ) {
92
+ remove_all_filters( 'get_the_excerpt' );
93
+ add_filter( 'get_the_excerpt', array( $this, 'filter' ) );
94
+ }
95
+
96
+ if( 1 == $this->options['the_content'] ) {
97
+ add_filter( 'the_content', array( $this, 'filter' ) );
98
+ }
99
+ }
100
+
101
+ function admin_init() {
102
+ add_action( 'admin_menu', array( $this, 'add_pages' ) );
103
+ add_filter( 'plugin_action_links_' . $this->plugin_basename, array( $this, 'plugin_action_links' ) );
104
+ }
105
+
106
+ function load_options() {
107
+ /*
108
+ * An older version of this plugin used to individually store each of it's options as a row in wp_options (1 row per option).
109
+ * The code below checks if their installations once used an older version of this plugin and attempts to update
110
+ * the option storage to the new method (all options stored in a single row in the DB as an array)
111
+ */
112
+ $update_options = false;
113
+ $update_from_legacy = false;
114
+ if ( false !== get_option( 'advancedexcerpt_length' ) ) {
115
+ $legacy_options = array( 'length', 'use_words', 'no_custom', 'no_shortcode', 'finish_word', 'finish_sentence', 'ellipsis', 'read_more', 'add_link', 'allowed_tags' );
116
+
117
+ foreach ( $legacy_options as $legacy_option ) {
118
+ $option_name = 'advancedexcerpt_' . $legacy_option;
119
+ $this->options[$legacy_option] = get_option( $option_name );
120
+ delete_option( $option_name );
121
+ }
122
+
123
+ // filtering the_content() is disabled by default when migrating from version 4.1.1 of the plugin
124
+ $this->options['the_excerpt'] = 1;
125
+ $this->options['the_content'] = 0;
126
+
127
+ $update_options = true;
128
+ $update_from_legacy = true;
129
+ } else {
130
+ $this->options = get_option( 'advanced_excerpt' );
131
+ }
132
+
133
+ // convert legacy option use_words to it's udpated equivalent
134
+ if ( isset( $this->options['use_words'] ) ) {
135
+ $this->options['length_type'] = ( 1 == $this->options['use_words'] ) ? 'words' : 'characters';
136
+ unset( $this->options['use_words'] );
137
+ $update_options = true;
138
+ }
139
+
140
+ // convert legacy options finish_word & finish_sentence to their udpated equivalents
141
+ if ( isset( $this->options['finish_sentence'] ) ) {
142
+ if ( 0 == $this->options['finish_word'] && 0 == $this->options['finish_sentence'] ) {
143
+ $this->options['finish'] = 'exact';
144
+ } else if ( 1 == $this->options['finish_word'] && 1 == $this->options['finish_sentence'] ) {
145
+ $this->options['finish'] = 'sentence';
146
+ } else if ( 0 == $this->options['finish_word'] && 1 == $this->options['finish_sentence'] ) {
147
+ $this->options['finish'] = 'sentence';
148
+ } else {
149
+ $this->options['finish'] = 'word';
150
+ }
151
+ unset( $this->options['finish_word'] );
152
+ unset( $this->options['finish_sentence'] );
153
+ $update_options = true;
154
+ }
155
+
156
+ // convert legacy option '_all' in the allowed_tags option to it's updated equivalent
157
+ if ( isset( $this->options['allowed_tags'] ) ) {
158
+ if ( false !== ( $all_key = array_search( '_all', $this->options['allowed_tags'] ) ) ) {
159
+ unset( $this->options['allowed_tags'][$all_key] );
160
+ $this->options['allowed_tags_option'] = 'dont_remove_any';
161
+ } elseif( $update_from_legacy ) {
162
+ $this->options['allowed_tags_option'] = 'remove_all_tags_except';
163
+ }
164
+ }
165
+
166
+ // if no options exist then this is a fresh install, set up some default options
167
+ if ( empty( $this->options ) ) {
168
+ $this->options = $this->default_options;
169
+ $update_options = true;
170
+ }
171
+
172
+ $this->options = wp_parse_args( $this->options, $this->default_options );
173
+
174
+ if ( $update_options ) {
175
+ update_option( 'advanced_excerpt', $this->options );
176
+ }
177
+ }
178
+
179
+ function add_pages() {
180
+ $options_page = add_options_page( __( "Advanced Excerpt Options", 'advanced-excerpt' ), __( "Excerpt", 'advanced-excerpt' ), 'manage_options', 'advanced-excerpt', array( $this, 'page_options' ) );
181
+ // Scripts
182
+ add_action( 'admin_print_scripts-' . $options_page, array( $this, 'page_assets' ) );
183
+ }
184
+
185
+ function page_assets() {
186
+ $version = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? time() : $this->plugin_version;
187
+ $plugins_url = trailingslashit( plugins_url() ) . trailingslashit( $this->plugin_folder_name );
188
+
189
+ // css
190
+ $src = $plugins_url . 'asset/css/styles.css';
191
+ wp_enqueue_style( 'advanced-excerpt-styles', $src, array(), $version );
192
+
193
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
194
+
195
+ // js
196
+ $src = $plugins_url . 'asset/js/advanced-excerpt' . $suffix . '.js';
197
+ wp_enqueue_script( 'advanced-excerpt-script', $src, array( 'jquery' ), $version, true );
198
+ }
199
+
200
+ function plugin_action_links( $links ) {
201
+ $link = sprintf( '<a href="%s">%s</a>', admin_url( $this->plugin_base ), __( 'Settings', 'advanced-excerpt' ) );
202
+ array_unshift( $links, $link );
203
+ return $links;
204
+ }
205
+
206
+ function filter( $text ) {
207
+ global $post;
208
+ extract( wp_parse_args( $this->options, $this->default_options ), EXTR_SKIP );
209
+ $original_excerpt = $text;
210
+
211
+ // Avoid custom excerpts
212
+ if ( !empty( $text ) && !$no_custom ) {
213
+ return $text;
214
+ }
215
+
216
+ // Get the full content and filter it
217
+ $text = $post->post_content;
218
+ if ( 1 == $no_shortcode ) {
219
+ $text = strip_shortcodes( $text );
220
+ }
221
+ if( 1 == $this->options['the_content'] ) {
222
+ remove_filter( 'the_content', array( $this, 'filter' ) ); // prevent recursion
223
+ }
224
+ $text = apply_filters( 'the_content', $text );
225
+ if( 1 == $this->options['the_content'] ) {
226
+ add_filter( 'the_content', array( $this, 'filter' ) ); // add our filter back in
227
+ }
228
+
229
+ if ( $the_content_no_break && false !== strpos( $text, '<!--more-->' ) ) {
230
+ return $original_excerpt;
231
+ }
232
+
233
+ // From the default wp_trim_excerpt():
234
+ // Some kind of precaution against malformed CDATA in RSS feeds I suppose
235
+ $text = str_replace( ']]>', ']]&gt;', $text );
236
+
237
+ $original_post_content = $text;
238
+
239
+ // Determine allowed tags
240
+ if ( !isset( $allowed_tags ) ) {
241
+ $allowed_tags = $this->options_all_tags;
242
+ }
243
+
244
+ if ( isset( $exclude_tags ) ) {
245
+ $allowed_tags = array_diff( $allowed_tags, $exclude_tags );
246
+ }
247
+
248
+ // Strip HTML if $allowed_tags_option is set to 'remove_all_tags_except'
249
+ if ( 'remove_all_tags_except' === $allowed_tags_option ) {
250
+ if ( count( $allowed_tags ) > 0 ) {
251
+ $tag_string = '<' . implode( '><', $allowed_tags ) . '>';
252
+ } else {
253
+ $tag_string = '';
254
+ }
255
+ $text = strip_tags( $text, $tag_string );
256
+ }
257
+
258
+ // Create the excerpt
259
+ $text = $this->text_excerpt( $text, $length, $length_type, $finish );
260
+
261
+ // Add the ellipsis or link
262
+ if ( !apply_filters( 'advanced_excerpt_disable_add_more', false, $original_post_content, $this->options ) ) {
263
+ $text = $this->text_add_more( $text, $ellipsis, ( $add_link ) ? $read_more : false );
264
+ }
265
+
266
+ return apply_filters( 'advanced_excerpt_content', $text );
267
+ }
268
+
269
+ function text_excerpt( $text, $length, $length_type, $finish ) {
270
+ $tokens = array();
271
+ $out = '';
272
+ $w = 0;
273
+
274
+ // Divide the string into tokens; HTML tags, or words, followed by any whitespace
275
+ // (<[^>]+>|[^<>\s]+\s*)
276
+ preg_match_all( '/(<[^>]+>|[^<>\s]+)\s*/u', $text, $tokens );
277
+ foreach ( $tokens[0] as $t ) { // Parse each token
278
+ if ( $w >= $length && 'sentence' != $finish ) { // Limit reached
279
+ break;
280
+ }
281
+ if ( $t[0] != '<' ) { // Token is not a tag
282
+ if ( $w >= $length && 'sentence' == $finish && preg_match( '/[\?\.\!]\s*$/uS', $t ) == 1 ) { // Limit reached, continue until ? . or ! occur at the end
283
+ $out .= trim( $t );
284
+ break;
285
+ }
286
+ if ( 'words' == $length_type ) { // Count words
287
+ $w++;
288
+ } else { // Count/trim characters
289
+ $chars = trim( $t ); // Remove surrounding space
290
+ $c = strlen( $chars );
291
+ if ( $c + $w > $length && 'sentence' != $finish ) { // Token is too long
292
+ $c = ( 'word' == $finish ) ? $c : $length - $w; // Keep token to finish word
293
+ $t = substr( $t, 0, $c );
294
+ }
295
+ $w += $c;
296
+ }
297
+ }
298
+ // Append what's left of the token
299
+ $out .= $t;
300
+ }
301
+
302
+ return trim( force_balance_tags( $out ) );
303
+ }
304
+
305
+ public function text_add_more( $text, $ellipsis, $read_more ) {
306
+ if ( $read_more ) {
307
+ $link_template = apply_filters( 'advanced_excerpt_read_more_link_template', ' <a href="%1$s" class="read-more">%2$s</a>', get_permalink(), $read_more );
308
+ $ellipsis .= sprintf( $link_template, get_permalink(), $read_more );
309
+ }
310
+
311
+ $pos = strrpos( $text, '</' );
312
+
313
+ if ( $pos !== false ) {
314
+ // get the "clean" name of the last closing tag in the text, e.g. p, a, strong, div
315
+ $last_tag = strtolower( trim( str_replace( array( '<', '/', '>' ), '', substr( $text, $pos ) ) ) );
316
+
317
+ /*
318
+ * There was previously a problem where our 'read-more' links were being appending incorrectly into unsuitable HTML tags.
319
+ * As such we're now maintaining a whitelist of HTML tags that are suitable for being appended into.
320
+ */
321
+ $allow_tags_to_append_into = apply_filters( 'advanced_excerpt_allow_tags_to_append_into', array( 'p', 'div', 'article', 'section' ) );
322
+
323
+ if( !in_array( $last_tag, $allow_tags_to_append_into ) ) {
324
+ // After the content
325
+ $text .= $ellipsis;
326
+ return $text;
327
+ }
328
+ // Inside last HTML tag
329
+ $text = substr_replace( $text, $ellipsis, $pos, 0 );
330
+ return $text;
331
+ }
332
+
333
+ // After the content
334
+ $text .= $ellipsis;
335
+ return $text;
336
+ }
337
+
338
+ function update_options() {
339
+ $_POST = stripslashes_deep( $_POST );
340
+ $this->options['length'] = (int) $_POST['length'];
341
+
342
+ $checkbox_options = array( 'no_custom', 'no_shortcode', 'add_link', 'the_excerpt', 'the_content', 'the_content_no_break' );
343
+
344
+ foreach ( $checkbox_options as $checkbox_option ) {
345
+ $this->options[$checkbox_option] = ( isset( $_POST[$checkbox_option] ) ) ? 1 : 0;
346
+ }
347
+
348
+ $this->options['length_type'] = $_POST['length_type'];
349
+ $this->options['finish'] = $_POST['finish'];
350
+ $this->options['ellipsis'] = $_POST['ellipsis'];
351
+ $this->options['read_more'] = isset( $_POST['read_more'] ) ? $_POST['read_more'] : $this->options['read_more'];
352
+ $this->options['allowed_tags'] = ( isset( $_POST['allowed_tags'] ) ) ? array_unique( (array) $_POST['allowed_tags'] ) : array();
353
+ $this->options['exclude_pages'] = ( isset( $_POST['exclude_pages'] ) ) ? array_unique( (array) $_POST['exclude_pages'] ) : array();
354
+ $this->options['allowed_tags_option'] = $_POST['allowed_tags_option'];
355
+
356
+ update_option( 'advanced_excerpt', $this->options );
357
+
358
+ wp_redirect( admin_url( $this->plugin_base ) . '&settings-updated=1' );
359
+ exit;
360
+ }
361
+
362
+ function page_options() {
363
+ extract( $this->options, EXTR_SKIP );
364
+
365
+ $ellipsis = htmlentities( $ellipsis );
366
+ $read_more = htmlentities( $read_more );
367
+
368
+ $tag_list = array_unique( array_merge( $this->options_basic_tags, $allowed_tags ) );
369
+ sort( $tag_list );
370
+ $tag_cols = 5;
371
+
372
+ // provides a set of checkboxes allowing the user to exclude the excerpt filter on certain page types
373
+ $exclude_pages_list = array(
374
+ 'home' => __( 'Home Page', 'advanced-excerpt' ),
375
+ 'feed' => __( 'Posts RSS Feed', 'advanced-excerpt' ),
376
+ 'search' => __( 'Search Archive', 'advanced-excerpt' ),
377
+ 'author' => __( 'Author Archive', 'advanced-excerpt' ),
378
+ 'category' => __( 'Category Archive', 'advanced-excerpt' ),
379
+ 'tag' => __( 'Tag Archive', 'advanced-excerpt' ),
380
+ );
381
+ $exclude_pages_list = apply_filters( 'advanced_excerpt_exclude_pages_list', $exclude_pages_list );
382
+
383
+ require_once $this->plugin_dir_path . 'template/options.php';
384
+ }
385
+
386
+ function get_current_page_types() {
387
+ global $wp_query;
388
+ if ( ! isset( $wp_query ) ) return false;
389
+ $wp_query_object_vars = get_object_vars( $wp_query );
390
+
391
+ $page_types = array();
392
+ foreach( $wp_query_object_vars as $key => $value ) {
393
+ if ( false === strpos( $key, 'is_' ) ) continue;
394
+ if ( true === $value ) {
395
+ $page_types[] = str_replace( 'is_', '', $key );
396
+ }
397
+ }
398
+
399
+ return $page_types;
400
+ }
401
+
402
+ }
functions/functions.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Do not use outside the Loop!
4
+ function the_advanced_excerpt( $args = '', $get = false ) {
5
+ global $advanced_excerpt;
6
+ if ( !empty( $args ) && !is_array( $args ) ) {
7
+ $args = wp_parse_args( $args );
8
+
9
+ // Parse query style parameters
10
+ if ( isset( $args['ellipsis'] ) ) {
11
+ $args['ellipsis'] = urldecode( $args['ellipsis'] );
12
+ }
13
+
14
+ if ( isset( $args['allowed_tags'] ) ) {
15
+ $args['allowed_tags'] = preg_split( '/[\s,]+/', $args['allowed_tags'] );
16
+ }
17
+
18
+ if ( isset( $args['exclude_tags'] ) ) {
19
+ $args['exclude_tags'] = preg_split( '/[\s,]+/', $args['exclude_tags'] );
20
+ }
21
+ }
22
+
23
+ // convert legacy arg use_words to it's udpated equivalent
24
+ if ( isset( $args['use_words'] ) ) {
25
+ $args['length_type'] = ( 1 == $args['use_words'] ) ? 'words' : 'characters';
26
+ unset( $args['use_words'] );
27
+ }
28
+
29
+ // convert legacy args finish_word & finish_sentence to their udpated equivalents
30
+ if ( isset( $args['finish_word'] ) || isset( $args['finish_sentence'] ) ) {
31
+
32
+ $defaults = array(
33
+ 'finish_word' => 0,
34
+ 'finish_sentence' => 0
35
+ );
36
+
37
+ $args = wp_parse_args( $args, $defaults );
38
+
39
+ if ( 0 == $args['finish_word'] && 0 == $args['finish_sentence'] ) {
40
+ $args['finish'] = 'exact';
41
+ } else if ( 1 == $args['finish_word'] && 1 == $args['finish_sentence'] ) {
42
+ $args['finish'] = 'sentence';
43
+ } else if ( 0 == $args['finish_word'] && 1 == $args['finish_sentence'] ) {
44
+ $args['finish'] = 'sentence';
45
+ } else {
46
+ $args['finish'] = 'word';
47
+ }
48
+
49
+ unset( $args['finish_word'] );
50
+ unset( $args['finish_sentence'] );
51
+ }
52
+
53
+ // Set temporary options
54
+ $advanced_excerpt->options = $args;
55
+
56
+ if ( $get ) {
57
+ return get_the_excerpt();
58
+ } else {
59
+ the_excerpt();
60
+ }
61
+ }
languages/advanced-excerpt.pot ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Advanced Excerpt\n"
4
+ "POT-Creation-Date: 2014-05-27 14:13+1000\n"
5
+ "PO-Revision-Date: 2014-05-27 14:14+1000\n"
6
+ "Last-Translator: Delicious Brains <nom@deliciousbrains.com>\n"
7
+ "Language-Team: Delicious Brains <nom@deliciousbrains.com>\n"
8
+ "Language: en\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.5\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
16
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
17
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+
21
+ #: class/advanced-excerpt.php:180 template/options.php:2
22
+ msgid "Advanced Excerpt Options"
23
+ msgstr ""
24
+
25
+ #: class/advanced-excerpt.php:180
26
+ msgid "Excerpt"
27
+ msgstr ""
28
+
29
+ #: class/advanced-excerpt.php:201
30
+ msgid "Settings"
31
+ msgstr ""
32
+
33
+ #: class/advanced-excerpt.php:374
34
+ msgid "Home Page"
35
+ msgstr ""
36
+
37
+ #: class/advanced-excerpt.php:375
38
+ msgid "Posts RSS Feed"
39
+ msgstr ""
40
+
41
+ #: class/advanced-excerpt.php:376
42
+ msgid "Search Archive"
43
+ msgstr ""
44
+
45
+ #: class/advanced-excerpt.php:377
46
+ msgid "Author Archive"
47
+ msgstr ""
48
+
49
+ #: class/advanced-excerpt.php:378
50
+ msgid "Category Archive"
51
+ msgstr ""
52
+
53
+ #: class/advanced-excerpt.php:379
54
+ msgid "Tag Archive"
55
+ msgstr ""
56
+
57
+ #: template/options.php:4
58
+ msgid "Options saved."
59
+ msgstr ""
60
+
61
+ #: template/options.php:17
62
+ msgid "Excerpt Length:"
63
+ msgstr ""
64
+
65
+ #: template/options.php:23
66
+ msgid "Characters"
67
+ msgstr ""
68
+
69
+ #: template/options.php:24
70
+ msgid "Words"
71
+ msgstr ""
72
+
73
+ #: template/options.php:31
74
+ msgid "Ellipsis:"
75
+ msgstr ""
76
+
77
+ #: template/options.php:37
78
+ #, php-format
79
+ msgid "(use <a href=\"%s\" target=\"_blank\">HTML entities</a>)"
80
+ msgstr ""
81
+
82
+ #: template/options.php:39
83
+ msgid "Will substitute the part of the post that is omitted in the excerpt."
84
+ msgstr ""
85
+
86
+ #: template/options.php:44
87
+ msgid "Finish:"
88
+ msgstr ""
89
+
90
+ #: template/options.php:50
91
+ msgid "Exact"
92
+ msgstr ""
93
+
94
+ #: template/options.php:54
95
+ msgid "Word"
96
+ msgstr ""
97
+
98
+ #: template/options.php:58
99
+ msgid "Sentence"
100
+ msgstr ""
101
+
102
+ #: template/options.php:62
103
+ msgid ""
104
+ "Prevents cutting a word or sentence at the end of an excerpt. This option "
105
+ "can result in (slightly) longer excerpts."
106
+ msgstr ""
107
+
108
+ #: template/options.php:67
109
+ msgid "Read More Link:"
110
+ msgstr ""
111
+
112
+ #: template/options.php:72
113
+ msgid "Add read more link to excerpt"
114
+ msgstr ""
115
+
116
+ #: template/options.php:80
117
+ msgid "No Custom Excerpts:"
118
+ msgstr ""
119
+
120
+ #: template/options.php:86
121
+ msgid "Generate excerpts even if a post has a custom excerpt attached."
122
+ msgstr ""
123
+
124
+ #: template/options.php:93
125
+ msgid "Strip Shortcodes:"
126
+ msgstr ""
127
+
128
+ #: template/options.php:99
129
+ msgid "Remove shortcodes from the excerpt. <em>(recommended)</em>"
130
+ msgstr ""
131
+
132
+ #: template/options.php:105
133
+ msgid "Filter:"
134
+ msgstr ""
135
+
136
+ #: template/options.php:122
137
+ msgid ""
138
+ "Only filter <span class='monospaced'>the_content()</span> when there's no "
139
+ "break (&lt;!--more--&gt;) tag in the post content"
140
+ msgstr ""
141
+
142
+ #: template/options.php:128
143
+ msgid ""
144
+ "Themes may use <code>the_excerpt()</code> for some pages (e.g. search "
145
+ "results) and <code>the_content()</code> on others (e.g. blog archives). "
146
+ "Depending on your theme and what pages you want this plugin to affect, you "
147
+ "may need to adjust these settings."
148
+ msgstr ""
149
+
150
+ #: template/options.php:134
151
+ msgid "Disable On:"
152
+ msgstr ""
153
+
154
+ #: template/options.php:148
155
+ msgid "Disables excerpt filtering for certain page types."
156
+ msgstr ""
157
+
158
+ #: template/options.php:154
159
+ msgid "Strip Tags:"
160
+ msgstr ""
161
+
162
+ #: template/options.php:163
163
+ msgid "Don't remove any tags"
164
+ msgstr ""
165
+
166
+ #: template/options.php:167
167
+ msgid "Remove all tags except the following"
168
+ msgstr ""
169
+
170
+ #: template/options.php:197
171
+ msgid "Select all"
172
+ msgstr ""
173
+
174
+ #: template/options.php:197
175
+ msgid "Select none"
176
+ msgstr ""
177
+
178
+ #: template/options.php:198
179
+ msgid "More tags"
180
+ msgstr ""
181
+
182
+ #: template/options.php:205
183
+ msgid "Add tag"
184
+ msgstr ""
185
+
186
+ #: template/options.php:211
187
+ msgid "Save Changes"
188
+ msgstr ""
189
+
190
+ #: template/sidebar.php:7
191
+ msgid "Maintained by"
192
+ msgstr ""
193
+
194
+ #: template/sidebar.php:10
195
+ msgid "Profile"
196
+ msgstr ""
197
+
198
+ #: template/sidebar.php:12
199
+ msgid "Donate"
200
+ msgstr ""
201
+
202
+ #: template/sidebar.php:18
203
+ msgid "WordPress Development and Deployment Strategy"
204
+ msgstr ""
205
+
206
+ #: template/sidebar.php:23
207
+ msgid ""
208
+ "<strong>Free pro tips</strong> on advanced WordPress development techniques "
209
+ "and deployment strategies."
210
+ msgstr ""
211
+
212
+ #: template/sidebar.php:27
213
+ msgid "Your Name"
214
+ msgstr ""
215
+
216
+ #: template/sidebar.php:31
217
+ msgid "Your Email"
218
+ msgstr ""
219
+
220
+ #: template/sidebar.php:35
221
+ msgid "Subscribe"
222
+ msgstr ""
223
+
224
+ #: template/sidebar.php:39
225
+ msgid ""
226
+ "I promise I will not use your email for anything else and you can "
227
+ "unsubscribe with <span style=\"white-space: nowrap;\">1-click anytime</span>."
228
+ msgstr ""
229
+
230
+ #: template/sidebar.php:45
231
+ msgid ""
232
+ "WP Migrate DB Pro &mdash; Push and pull your database from one WordPress "
233
+ "install to another in 1-click."
234
+ msgstr ""
readme.txt CHANGED
@@ -1,12 +1,13 @@
1
  === Advanced Excerpt ===
2
- Contributors: basvd
3
- Tags: excerpt, advanced, post, posts, template, formatting
4
- Donate link: http://basvd.com/code/advanced-excerpt/
5
  Requires at least: 3.2
6
- Tested up to: 3.3
7
- Stable tag: 4.1.1
 
8
 
9
- Several improvements over WP's default excerpt. The size can be limited using character or word count, and HTML markup is not removed.
10
 
11
  == Description ==
12
 
@@ -23,13 +24,18 @@ This plugin adds several improvements to WordPress' default way of creating exce
23
 
24
  Most of the above features are optional and/or can be customized by the user or theme developer.
25
 
26
- == Installation ==
 
 
 
 
27
 
28
- After you've downloaded and extracted the files:
 
 
29
 
30
- 1. Upload the complete `advanced-excerpt` folder to the `/wp-content/plugins/` directory
31
- 2. Activate the plugin through the 'Plugins' menu in WordPress
32
- 3. Go to 'Excerpt' under the 'Settings' menu and configure the plugin
33
 
34
  == Frequently Asked Questions ==
35
 
@@ -39,19 +45,15 @@ A short version of a post that is usually displayed wherever the whole post woul
39
 
40
  = Why do I need this plugin? =
41
 
42
- The default excerpt created by WordPress removes all HTML. If your theme uses `the_excerpt()` to view excerpts, they might look weird because of this (smilies are removed, lists are flattened, etc.) This plugin fixes that and also gives you more control over excerpts.
43
 
44
  = Does it work for WordPress version x.x.x? =
45
 
46
- During development, the plugin is tested with the most recent version(s) of WordPress. The range of tested versions is listed on this page (3.2 - 3.3 at the moment). It might work on older versions, but it's better to just keep your installation up-to-date.
47
-
48
- The plugin requires PHP 5 to work. So if you are using WordPress before 3.2, make sure you have it (WP 3.2 and higher require PHP 5 already).
49
 
50
  = Is this plugin available in my language? / How do I translate this plugin? =
51
 
52
- The plugin comes bundled with a few (2) languages. The correct language will automatically be selected to match your [WordPress locale](http://codex.wordpress.org/WordPress_in_Your_Language).
53
-
54
- More information on translation will be added in the future.
55
 
56
  = Does this plugin support multibyte characters, such as Chinese? =
57
 
@@ -61,18 +63,17 @@ If you require multibyte character support on your website, you can [override th
61
 
62
  = Can I manually call the filter in my WP theme or plugin? =
63
 
64
- The plugin automatically hooks on `the_excerpt()` function and uses the parameters specified in the options panel.
65
 
66
  If you want to call the filter with different options, you can use `the_advanced_excerpt()` template tag provided by this plugin. This tag accepts [query-string-style parameters](http://codex.wordpress.org/Template_Tags/How_to_Pass_Tag_Parameters#Tags_with_query-string-style_parameters) (theme developers will be familiar with this notation).
67
 
68
  The following parameters can be set:
69
 
70
  * `length`, an integer that determines the length of the excerpt
71
- * `use_words`, if set to `1`, the excerpt length will be in words; if set to `0`, characters will be used for the count
72
  * `no_custom`, if set to `1`, an excerpt will be generated even if the post has a custom excerpt; if set to `0`, the custom excerpt will be used
73
  * `no_shortcode`, if set to `1`, shortcodes are removed from the excerpt; if set to `0`, shortcodes will be parsed
74
- * `finish_word`, if set to `1`, the last word in the excerpt will not be cut off; if set to `0`, no effort is made to finish the word
75
- * `finish_sentence`, if set to `1`, the last sentence in the excerpt will not be cut off; if set to `0`, no effort is made to include the full sentence
76
  * `ellipsis`, the string that will substitute the omitted part of the post; if you want to use HTML entities in the string, use `%26` instead of the `&` prefix to avoid breaking the query
77
  * `read_more`, the text used in the read-more link
78
  * `add_link`, if set to `1`, the read-more link will be appended; if `0`, no link will be added
@@ -81,15 +82,34 @@ The following parameters can be set:
81
 
82
  A custom advanced excerpt call could look like this:
83
 
84
- `the_advanced_excerpt('length=320&use_words=0&no_custom=1&ellipsis=%26hellip;&exclude_tags=img,p,strong');`
85
 
86
  = Does this plugin work outside the Loop? =
87
 
88
  No, this plugin fetches the post from The Loop and there is currently no way to pass a post ID or any custom input to it.
89
  However, you can [start The Loop manually](http://codex.wordpress.org/The_Loop#Multiple_Loops) and apply the plugin as usual.
90
 
 
 
 
 
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  = 4.1 =
94
  * Fix: Template function with custom options works again
95
  * Fix: Data before header bug (retro-fixed in 4.0)
1
  === Advanced Excerpt ===
2
+ Contributors: bradt, aprea
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5VPMGLLK94XJC
4
+ Tags: excerpt, post, content, formatting
5
  Requires at least: 3.2
6
+ Tested up to: 3.9
7
+ Stable tag: 4.2
8
+ License: GPLv3
9
 
10
+ Control the appearance of WordPress post excerpts
11
 
12
  == Description ==
13
 
24
 
25
  Most of the above features are optional and/or can be customized by the user or theme developer.
26
 
27
+ Interested in contributing to Advanced Excerpt? Please visit https://github.com/deliciousbrains/wp-advanced-excerpt
28
+
29
+ See [our wiki](https://github.com/deliciousbrains/wp-advanced-excerpt/wiki) for additional documentation.
30
+
31
+ Banner image credit - [chillihead](https://www.flickr.com/photos/chillihead/)
32
 
33
+ Original plugin author - [basvd](http://profiles.wordpress.org/basvd)
34
+
35
+ == Installation ==
36
 
37
+ 1. Use WordPress' built-in installer
38
+ 2. Access the "Excerpt" menu option under Settings
 
39
 
40
  == Frequently Asked Questions ==
41
 
45
 
46
  = Why do I need this plugin? =
47
 
48
+ The default excerpt created by WordPress removes all HTML. If your theme uses `the_excerpt()` or `the_content()` to view excerpts, they might look weird because of this (smilies are removed, lists are flattened, etc.) This plugin fixes that and also gives you more control over excerpts.
49
 
50
  = Does it work for WordPress version x.x.x? =
51
 
52
+ During development, the plugin is tested with the most recent version(s) of WordPress. It might work on older versions, but it's better to just keep your installation up-to-date.
 
 
53
 
54
  = Is this plugin available in my language? / How do I translate this plugin? =
55
 
56
+ Advanced Excerpt is internationalization (i18n) friendly. If you'd like to contribute a translation for your language please do so by opening a [pull request](https://github.com/deliciousbrains/wp-advanced-excerpt).
 
 
57
 
58
  = Does this plugin support multibyte characters, such as Chinese? =
59
 
63
 
64
  = Can I manually call the filter in my WP theme or plugin? =
65
 
66
+ The plugin automatically hooks on `the_excerpt()` and `the_content()` functions and uses the parameters specified in the options panel.
67
 
68
  If you want to call the filter with different options, you can use `the_advanced_excerpt()` template tag provided by this plugin. This tag accepts [query-string-style parameters](http://codex.wordpress.org/Template_Tags/How_to_Pass_Tag_Parameters#Tags_with_query-string-style_parameters) (theme developers will be familiar with this notation).
69
 
70
  The following parameters can be set:
71
 
72
  * `length`, an integer that determines the length of the excerpt
73
+ * `length_type`, enumeration, if set to `words` the excerpt length will be in words; if set to `characters` the excerpt length will be in characters
74
  * `no_custom`, if set to `1`, an excerpt will be generated even if the post has a custom excerpt; if set to `0`, the custom excerpt will be used
75
  * `no_shortcode`, if set to `1`, shortcodes are removed from the excerpt; if set to `0`, shortcodes will be parsed
76
+ * `finish`, enumeration, if set to `exact` the excerpt will be the exact lenth as defined by the "Excerpt Length" option. If set to `word` the last word in the excerpt will be completed. If set to `sentence` the last sentence in the excerpt will be completed.
 
77
  * `ellipsis`, the string that will substitute the omitted part of the post; if you want to use HTML entities in the string, use `%26` instead of the `&` prefix to avoid breaking the query
78
  * `read_more`, the text used in the read-more link
79
  * `add_link`, if set to `1`, the read-more link will be appended; if `0`, no link will be added
82
 
83
  A custom advanced excerpt call could look like this:
84
 
85
+ `the_advanced_excerpt('length=320&length_type=words&no_custom=1&ellipsis=%26hellip;&exclude_tags=img,p,strong');`
86
 
87
  = Does this plugin work outside the Loop? =
88
 
89
  No, this plugin fetches the post from The Loop and there is currently no way to pass a post ID or any custom input to it.
90
  However, you can [start The Loop manually](http://codex.wordpress.org/The_Loop#Multiple_Loops) and apply the plugin as usual.
91
 
92
+ == Screenshots ==
93
+
94
+ 1. The options page
95
+ 2. An example of an excerpt generated by the plugin
96
+
97
  == Changelog ==
98
 
99
+ = 4.2 =
100
+ * Feature: Toggle excerpt filtering when there's no break (<!--more-->) tag in the post content
101
+ * Feature: Toggle excerpt filtering for the `the_excerpt()` and `the_content()` functions
102
+ * Feature: Toggle excerpt filtering on certain page types
103
+ * Improvement: Added HTML5 tags to the allowed tags list
104
+ * Improvement: Options are now automatically removed from `wp_options` when the plugin is deleted from the dashboard
105
+ * Improvement: Added several WordPress filters, allowing developers to extend/modify the default functionality of the plugin
106
+ * Improvement: Additional strings were made i18n friendly
107
+ * Improvement: All options are now stored in one row in wp_options rather than one row per option
108
+ * Improvement: Several UI elements have be reworded and styled differently to improve user experience
109
+ * Fix: Now works with themes using `the_content()` on archive pages (i.e. WordPress default themes and others)
110
+ * Fix: Notices/warning were appearing when the options were saved while having a checkbox option unchecked
111
+ * Fix: The "Read More" link was being incorrectly appended into certain HTML tags, e.g. table tags and list tags
112
+
113
  = 4.1 =
114
  * Fix: Template function with custom options works again
115
  * Fix: Data before header bug (retro-fixed in 4.0)
template/options.php ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap advanced-excerpt">
2
+ <h2><?php _e( "Advanced Excerpt Options", 'advanced-excerpt' ); ?></h2>
3
+ <?php if ( isset( $_GET['settings-updated'] ) ) : ?>
4
+ <div id="message" class="updated fade"><p><?php _e( 'Options saved.', 'advanced-excerpt' ); ?></p></div>
5
+ <?php endif; ?>
6
+
7
+ <div class="advanced-excerpt-container">
8
+
9
+ <div class="advanced-excerpt-main">
10
+
11
+ <form method="post" action="" autocomplete="off">
12
+ <?php if ( function_exists( 'wp_nonce_field' ) ) wp_nonce_field( 'advanced_excerpt_update_options' ); ?>
13
+ <table class="form-table">
14
+ <tr valign="top">
15
+ <th scope="row">
16
+ <label for="length">
17
+ <?php _e( "Excerpt Length:", 'advanced-excerpt' ); ?>
18
+ </label>
19
+ </th>
20
+ <td>
21
+ <input name="length" type="text" id="length" value="<?php echo $length; ?>" size="2" />
22
+ <select name="length_type">
23
+ <option value="characters"<?php echo ( 'characters' == $length_type ) ? ' selected="selected"' : ''; ?>><?php _e( "Characters", 'advanced-excerpt' ); ?></option>
24
+ <option value="words"<?php echo ( 'words' == $length_type ) ? ' selected="selected"' : ''; ?>><?php _e( "Words", 'advanced-excerpt' ); ?></option>
25
+ </select>
26
+ </td>
27
+ </tr>
28
+ <tr valign="top">
29
+ <th scope="row">
30
+ <label for="ellipsis">
31
+ <?php _e( "Ellipsis:", 'advanced-excerpt' ); ?>
32
+ </label>
33
+ </th>
34
+ <td>
35
+ <p>
36
+ <input name="ellipsis" type="text" id="ellipsis" value="<?php echo $ellipsis; ?>" size="5" />
37
+ <?php printf( __( '(use <a href="%s" target="_blank">HTML entities</a>)', 'advanced-excerpt' ), 'http://entitycode.com' ); ?>
38
+ </p>
39
+ <p class="description"><?php _e( "Will substitute the part of the post that is omitted in the excerpt.", 'advanced-excerpt' ); ?></p>
40
+ </td>
41
+ </tr>
42
+ <tr valign="top">
43
+ <th scope="row">
44
+ <?php _e( "Finish:", 'advanced-excerpt' ); ?>
45
+ </th>
46
+ <td>
47
+ <p>
48
+ <label for="finish-none">
49
+ <input type="radio" id="finish-none" name="finish" value="exact"<?php echo ( 'exact' == $finish ) ? ' checked="checked"' : ''; ?> />
50
+ <?php _e( "Exact", 'advanced-excerpt' ); ?>
51
+ </label><br />
52
+ <label for="finish-word">
53
+ <input type="radio" id="finish-word" name="finish" value="word"<?php echo ( 'word' == $finish ) ? ' checked="checked"' : ''; ?> />
54
+ <?php _e( "Word", 'advanced-excerpt' ); ?>
55
+ </label><br />
56
+ <label for="finish-sentence">
57
+ <input type="radio" id="finish-sentence" name="finish" value="sentence"<?php echo ( 'sentence' == $finish ) ? ' checked="checked"' : ''; ?> />
58
+ <?php _e( "Sentence", 'advanced-excerpt' ); ?>
59
+ </label>
60
+ </p>
61
+
62
+ <p class="description"><?php _e( "Prevents cutting a word or sentence at the end of an excerpt. This option can result in (slightly) longer excerpts.", 'advanced-excerpt' ); ?></p>
63
+ </td>
64
+ </tr>
65
+ <tr valign="top">
66
+ <th scope="row">
67
+ <?php _e( "Read More Link:", 'advanced-excerpt' ); ?>
68
+ </th>
69
+ <td>
70
+ <label for="add-link">
71
+ <input name="add_link" type="checkbox" id="add-link" value="on" <?php echo ( 1 == $add_link ) ? 'checked="checked"' : ''; ?> />
72
+ <?php _e( "Add read more link to excerpt", 'advanced-excerpt' ); ?>
73
+ </label><br />
74
+ <input name="read_more" type="text" id="read-more" value="<?php echo $read_more; ?>" <?php echo ( 1 !== $add_link ) ? 'disabled="disabled"' : ''; ?> />
75
+ </td>
76
+ </tr>
77
+ <tr valign="top">
78
+ <th scope="row">
79
+ <label for="no-custom">
80
+ <?php _e( "No Custom Excerpts:", 'advanced-excerpt' ); ?>
81
+ </label>
82
+ </th>
83
+ <td>
84
+ <label for="no-custom">
85
+ <input name="no_custom" type="checkbox" id="no-custom" value="on" <?php echo ( 1 == $no_custom ) ? 'checked="checked"' : ''; ?> />
86
+ <?php _e( "Generate excerpts even if a post has a custom excerpt attached.", 'advanced-excerpt' ); ?>
87
+ </label>
88
+ </td>
89
+ </tr>
90
+ <tr valign="top">
91
+ <th scope="row">
92
+ <label for="no-shortcode">
93
+ <?php _e( "Strip Shortcodes:", 'advanced-excerpt' ); ?>
94
+ </label>
95
+ </th>
96
+ <td>
97
+ <label for="no-shortcode">
98
+ <input name="no_shortcode" type="checkbox" id="no-shortcode" value="on" <?php echo ( 1 == $no_shortcode ) ? 'checked="checked"' : ''; ?> />
99
+ <?php _e( "Remove shortcodes from the excerpt. <em>(recommended)</em>", 'advanced-excerpt' ); ?>
100
+ </label>
101
+ </td>
102
+ </tr>
103
+ <tr valign="top">
104
+ <th scope="row">
105
+ <?php _e( "Filter:", 'advanced-excerpt' ); ?>
106
+ </th>
107
+ <td>
108
+ <p>
109
+ <label for="the-excerpt">
110
+ <input name="the_excerpt" type="checkbox" id="the-excerpt" value="on" <?php echo ( 1 == $the_excerpt ) ? 'checked="checked"' : ''; ?> />
111
+ <span class='monospaced'>the_excerpt()</span>
112
+ </label><br />
113
+ <label for="the-content">
114
+ <input name="the_content" type="checkbox" id="the-content" value="on" <?php echo ( 1 == $the_content ) ? 'checked="checked"' : ''; ?> />
115
+ <span class='monospaced'>the_content()</span>
116
+ </label>
117
+ </p>
118
+ <ul class="sub-options">
119
+ <li>
120
+ <label id="the-content-no-break-label" for="the-content-no-break" <?php echo ( 1 !== $the_content ) ? 'class="disabled"' : ''; ?>>
121
+ <input name="the_content_no_break" type="checkbox" id="the-content-no-break" value="on" <?php echo ( 1 == $the_content_no_break && 1 == $the_content ) ? 'checked="checked"' : ''; ?> <?php echo ( 1 !== $the_content ) ? 'disabled="disabled"' : ''; ?> />
122
+ <?php _e( "Only filter <span class='monospaced'>the_content()</span> when there's no break (&lt;!--more--&gt;) tag in the post content", 'advanced-excerpt' ); ?>
123
+ </label>
124
+ </li>
125
+ </ul>
126
+
127
+ <p class="description">
128
+ <?php _e( 'Themes may use <code>the_excerpt()</code> for some pages (e.g. search results) and <code>the_content()</code> on others (e.g. blog archives). Depending on your theme and what pages you want this plugin to affect, you may need to adjust these settings.', 'advanced-excerpt' ); ?>
129
+ </p>
130
+ </td>
131
+ </tr>
132
+ <tr valign="top">
133
+ <th scope="row">
134
+ <?php _e( "Disable On:", 'advanced-excerpt' ); ?>
135
+ </th>
136
+ <td>
137
+ <p>
138
+ <?php foreach ( $exclude_pages_list as $key => $label ) :
139
+ $key_dashed = str_replace( '_', '-', $key ); ?>
140
+ <label for="<?php echo $key_dashed; ?>">
141
+ <input name="exclude_pages[]" type="checkbox" id="<?php echo $key_dashed; ?>" value="<?php echo $key; ?>" <?php echo ( in_array( $key, $exclude_pages ) ) ? 'checked="checked"' : ''; ?> />
142
+ <?php echo $label; ?>
143
+ </label><br />
144
+ <?php endforeach; ?>
145
+ <p>
146
+
147
+ <p class="description">
148
+ <?php _e( 'Disables excerpt filtering for certain page types.', 'advanced-excerpt' ); ?>
149
+ </p>
150
+ </td>
151
+ </tr>
152
+ <tr valign="top">
153
+ <th scope="row">
154
+ <?php _e( "Strip Tags:", 'advanced-excerpt' ); ?>
155
+ </th>
156
+ <td>
157
+ <table id="tags-table">
158
+ <tr>
159
+ <td colspan="<?php echo $tag_cols; ?>">
160
+ <p>
161
+ <label for="dont-remove-any-tags">
162
+ <input name="allowed_tags_option" type="radio" id="dont-remove-any-tags" value="dont_remove_any" <?php echo ( 'dont_remove_any' == $allowed_tags_option ) ? 'checked="checked"' : ''; ?> />
163
+ <?php _e( "Don't remove any tags", 'advanced-excerpt' ); ?>
164
+ </label><br />
165
+ <label for="remove-all-tags-except">
166
+ <input name="allowed_tags_option" type="radio" id="remove-all-tags-except" value="remove_all_tags_except" <?php echo ( 'remove_all_tags_except' == $allowed_tags_option ) ? 'checked="checked"' : ''; ?> />
167
+ <?php _e( "Remove all tags except the following", 'advanced-excerpt' ); ?>
168
+ </label>
169
+ </p>
170
+ </td>
171
+ </tr>
172
+ <?php
173
+ $i = 0;
174
+ foreach ( $tag_list as $tag ) :
175
+ if ( 0 == $i % $tag_cols ) : ?>
176
+ <tr<?php echo ( 'dont_remove_any' == $allowed_tags_option ) ? ' style="display: none;"' : '' ?>>
177
+ <?php endif; $i++; ?>
178
+ <td>
179
+ <label for="<?php echo 'ae-' . $tag; ?>">
180
+ <input name="allowed_tags[]" type="checkbox" id="<?php echo 'ae-' . $tag; ?>" value="<?php echo $tag; ?>" <?php echo ( in_array( $tag, $allowed_tags ) ) ? 'checked="checked" ' : ''; ?> />
181
+ <code><?php echo $tag; ?></code>
182
+ </label>
183
+ </td>
184
+ <?php
185
+ if ( 0 == $i % $tag_cols ):
186
+ $i = 0;
187
+ echo '</tr>';
188
+ endif;
189
+ endforeach;
190
+ if ( 0 != $i % $tag_cols ): ?>
191
+ <td colspan="<?php echo $tag_cols - $i; ?>">&nbsp;</td>
192
+ </tr>
193
+ <?php endif; ?>
194
+ </table>
195
+
196
+ <div class="tags-control"<?php echo ( 'dont_remove_any' == $allowed_tags_option ) ? ' style="display: none;"' : '' ?>>
197
+ <a href="" id="select-all"><?php _e( "Select all", 'advanced-excerpt' ); ?></a> / <a href="" id="select-none"><?php _e( "Select none", 'advanced-excerpt' ); ?></a><br />
198
+ <?php _e( "More tags", 'advanced-excerpt' ); ?>
199
+ <select name="more_tags" id="more-tags">
200
+ <?php foreach ( array_diff( $this->options_all_tags, $this->options_basic_tags ) as $tag ) : ?>
201
+ <option value="<?php echo $tag; ?>"><?php echo $tag; ?></option>
202
+ <?php endforeach; ?>
203
+ </select>
204
+
205
+ <input type="button" name="add_tag" id="add-tag" class="button" value="<?php _e( "Add tag", 'advanced-excerpt' ); ?>" />
206
+ </div>
207
+
208
+ </td>
209
+ </tr>
210
+ </table>
211
+ <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( "Save Changes", 'advanced-excerpt' ); ?>" /></p>
212
+ </form>
213
+
214
+ </div>
215
+
216
+ <?php require_once $this->plugin_dir_path . 'template/sidebar.php'; ?>
217
+
218
+ </div>
219
+
220
+ </div>
template/sidebar.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="advanced-excerpt-sidebar">
2
+ <div class="inside">
3
+
4
+ <div class="author">
5
+ <img src="http://www.gravatar.com/avatar/e538ca4cb34839d4e5e3ccf20c37c67b?s=128&amp;d" width="64" height="64" />
6
+ <div class="desc">
7
+ <h3><?php _e( 'Maintained by', 'advanced-excerpt' ); ?></h3>
8
+ <h2>Brad Touesnard</h2>
9
+ <p>
10
+ <a href="http://profiles.wordpress.org/bradt/" target="_blank"><?php _e( 'Profile', 'advanced-excerpt' ); ?></a>
11
+ &nbsp;&nbsp;
12
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=5VPMGLLK94XJC" target="_blank"><?php _e( 'Donate', 'advanced-excerpt' ); ?></a>
13
+ </p>
14
+ </div>
15
+ </div>
16
+
17
+ <form method="post" action="http://deliciousbrains.createsend.com/t/t/s/tdiull/" target="_blank" class="subscribe">
18
+ <h2><?php _e( 'WordPress Development and Deployment Strategy', 'advanced-excerpt' ); ?></h2>
19
+
20
+ <?php $user = wp_get_current_user(); ?>
21
+
22
+ <p class="interesting">
23
+ <?php _e( '<strong>Free pro tips</strong> on advanced WordPress development techniques and deployment strategies.', 'advanced-excerpt' ); ?>
24
+ </p>
25
+
26
+ <div class="field notify-name">
27
+ <input type="text" name="cm-name" value="<?php echo trim( esc_attr( $user->first_name ) . ' ' . esc_attr( $user->last_name ) ); ?>" placeholder="<?php _e( 'Your Name', 'advanced-excerpt' ); ?>" />
28
+ </div>
29
+
30
+ <div class="field notify-email">
31
+ <input type="email" name="cm-tdiull-tdiull" value="<?php echo esc_attr( $user->user_email ); ?>" placeholder="<?php _e( 'Your Email', 'advanced-excerpt' ); ?>" />
32
+ </div>
33
+
34
+ <div class="field submit-button">
35
+ <input type="submit" class="button" value="<?php _e( 'Subscribe', 'advanced-excerpt' ); ?>" />
36
+ </div>
37
+
38
+ <p class="promise">
39
+ <?php _e( 'I promise I will not use your email for anything else and you can unsubscribe with <span style="white-space: nowrap;">1-click anytime</span>.', 'advanced-excerpt' ); ?>
40
+ </p>
41
+ </form>
42
+
43
+ </div>
44
+
45
+ <a class="wpmdb-banner" target="_blank" href="http://deliciousbrains.com/wp-migrate-db-pro/?utm_source=advanced-excerpt&utm_medium=plugin&utm_campaign=advanced-excerpt"><img src="<?php echo plugins_url( 'asset/img/wp-migrate-db-pro.jpg', $this->plugin_file_path ); ?>" width="292" height="292" alt="<?php _e( 'WP Migrate DB Pro &mdash; Push and pull your database from one WordPress install to another in 1-click.', 'advanced-excerpt' ); ?>" /></a>
46
+
47
+ </div>
uninstall.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Code used when the plugin is removed (not just deactivated but actively deleted through the WordPress Admin).
4
+ */
5
+
6
+ if( !defined( 'ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) exit();
7
+
8
+ delete_option( 'advanced_excerpt' );