Similar Posts – Best Related Posts Plugin for WordPress - Version 2.7

Version Description

Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 Similar Posts – Best Related Posts Plugin for WordPress
Version 2.7
Comparing to
See all releases

Code changes from version 2.6.2.0 to 2.7

admin-subpages.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Similar Posts
4
+ * (c) Web factory Ltd, 2008 - 2016
5
+ */
6
+
7
+
8
+ /*
9
+ A simple library class to ease the use of a further level of submenus in the admin pages
10
+ Uses no javascript but 'borrows' some CSS it shouldn't
11
+ */
12
+
13
+ define('ADMIN_SUBPAGES_LIBRARY', true);
14
+
15
+ class admin_subpages {
16
+ var $pages = array();
17
+ var $parent_page = '';
18
+ var $current_page = array();
19
+
20
+ function __construct($parent_page='') {
21
+ if ($parent_page === '') {
22
+ $parent_page = $_SERVER['QUERY_STRING'];
23
+ $p1 = strpos($parent_page, 'page=');
24
+ $p2 = strpos($parent_page, '&');
25
+ if ($p2 === false) {
26
+ $parent_page = substr($parent_page, $p1+5);
27
+ } else {
28
+ $parent_page = substr($parent_page, $p1+5, $p2-$p1-5);
29
+ }
30
+ }
31
+ $this->parent_page = $parent_page;
32
+ }
33
+
34
+ function add_subpage($title, $slug, $view) {
35
+ $this->pages[] = array('title' => $title, 'slug' => $slug, 'view' => $view);
36
+ }
37
+
38
+ function add_subpages($pages) {
39
+ foreach ($pages as $page) {
40
+ $this->pages[] = array('title' => $page[0], 'slug' => $page[1], 'view' => $page[2]);
41
+ }
42
+ }
43
+
44
+ function page_from_slug($slug) {
45
+ if (!isset($slug) || !$slug) {
46
+ return $this->pages[0];
47
+ }
48
+ foreach ($this->pages as $page) {
49
+ if ($page['slug'] === $slug) {
50
+ return $page;
51
+ }
52
+ }
53
+ die('non-existent slug');
54
+ }
55
+
56
+ function display_menu() {
57
+ echo "\n<ul id=\"submenu\" class=\"similarposts-tabs-menu\" style=\"display: block\">\n";
58
+ // for compatibility with WP mu
59
+ $base = (isset($_SERVER['REDIRECT_URL'])) ? $_SERVER['REDIRECT_URL'] : $_SERVER['PHP_SELF'];
60
+ $base .= '?page=' . $this->parent_page . '&subpage=';
61
+ $this->current_page = (isset($_GET['subpage']))?$this->page_from_slug($_GET['subpage']):$this->page_from_slug(false);
62
+ foreach($this->pages as $page) {
63
+ if($page === $this->current_page) {
64
+ echo "<li style=\"display: inline\"><a href=\"$base{$page['slug']}\" class=\"current\" style=\"display: inline\">{$page['title']}</a></li>\n";
65
+ } else {
66
+ echo "<li style=\"display: inline\"><a href=\"$base{$page['slug']}\" style=\"display: inline\">{$page['title']}</a></li>\n";
67
+ }
68
+ }
69
+ echo "</ul>\n";
70
+ }
71
+
72
+ function display_view() {
73
+ $this->current_page['view']();
74
+ }
75
+
76
+ function display() {
77
+ $this->display_menu();
78
+ $this->display_view();
79
+ }
80
+
81
+ }
admin_common_functions.php ADDED
@@ -0,0 +1,1041 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Similar Posts
4
+ * (c) Web factory Ltd, 2008 - 2016
5
+ */
6
+
7
+
8
+ /*
9
+ Library for the Recent Posts, Random Posts, Recent Comments, and Similar Posts plugins
10
+ -- provides the admin routines which the plugins share
11
+ */
12
+
13
+ define('ACF_LIBRARY', true);
14
+
15
+ function ppl_options_from_post($options, $args) {
16
+ foreach ($args as $arg) {
17
+ switch ($arg) {
18
+ case 'limit':
19
+ case 'skip':
20
+ $options[$arg] = ppl_check_cardinal($_POST[$arg]);
21
+ break;
22
+ case 'excluded_cats':
23
+ case 'included_cats':
24
+ if (isset($_POST[$arg])) {
25
+ // get the subcategories too
26
+ if (function_exists('get_term_children')) {
27
+ $catarray = $_POST[$arg];
28
+ foreach ($catarray as $cat) {
29
+ $catarray = array_merge($catarray, get_term_children($cat, 'category'));
30
+ }
31
+ $_POST[$arg] = array_unique($catarray);
32
+ }
33
+ $options[$arg] = implode(',', $_POST[$arg]);
34
+ } else {
35
+ $options[$arg] = '';
36
+ }
37
+ break;
38
+ case 'excluded_authors':
39
+ case 'included_authors':
40
+ if (isset($_POST[$arg])) {
41
+ $options[$arg] = implode(',', $_POST[$arg]);
42
+ } else {
43
+ $options[$arg] = '';
44
+ }
45
+ break;
46
+ case 'excluded_posts':
47
+ case 'included_posts':
48
+ $check = explode(',', rtrim($_POST[$arg]));
49
+ $ids = array();
50
+ foreach ($check as $id) {
51
+ $id = ppl_check_cardinal($id);
52
+ if ($id !== 0) $ids[] = $id;
53
+ }
54
+ $options[$arg] = implode(',', array_unique($ids));
55
+ break;
56
+ case 'stripcodes':
57
+ $st = explode("\n", trim($_POST['starttags']));
58
+ $se = explode("\n", trim($_POST['endtags']));
59
+ if (count($st) != count($se)) {
60
+ $options['stripcodes'] = array(array());
61
+ } else {
62
+ $num = count($st);
63
+ for ($i = 0; $i < $num; $i++) {
64
+ $options['stripcodes'][$i]['start'] = $st[$i];
65
+ $options['stripcodes'][$i]['end'] = $se[$i];
66
+ }
67
+ }
68
+ break;
69
+ case 'age':
70
+ $options['age']['direction'] = $_POST['age-direction'];
71
+ $options['age']['length'] = ppl_check_cardinal($_POST['age-length']);
72
+ $options['age']['duration'] = $_POST['age-duration'];
73
+ break;
74
+ case 'custom':
75
+ $options['custom']['key'] = $_POST['custom-key'];
76
+ $options['custom']['op'] = $_POST['custom-op'];
77
+ $options['custom']['value'] = $_POST['custom-value'];
78
+ break;
79
+ case 'sort':
80
+ $options['sort']['by1'] = $_POST['sort-by1'];
81
+ $options['sort']['order1'] = $_POST['sort-order1'];
82
+ if ($options['sort']['order1'] === 'SORT_ASC') $options['sort']['order1'] = SORT_ASC; else $options['sort']['order1'] = SORT_DESC;
83
+ $options['sort']['case1'] = $_POST['sort-case1'];
84
+ $options['sort']['by2'] = $_POST['sort-by2'];
85
+ $options['sort']['order2'] = $_POST['sort-order2'];
86
+ if ($options['sort']['order2'] === 'SORT_ASC') $options['sort']['order2'] = SORT_ASC; else $options['sort']['order2'] = SORT_DESC;
87
+ $options['sort']['case2'] = $_POST['sort-case2'];
88
+ if ($options['sort']['by1'] === '') {
89
+ $options['sort']['order1'] = SORT_ASC;
90
+ $options['sort']['case1'] = 'false';
91
+ $options['sort']['by2'] = '';
92
+ }
93
+ if ($options['sort']['by2'] === '') {
94
+ $options['sort']['order2'] = SORT_ASC;
95
+ $options['sort']['case2'] = 'false';
96
+ }
97
+ break;
98
+ case 'status':
99
+ unset($options['status']);
100
+ $options['status']['publish'] = $_POST['status-publish'];
101
+ $options['status']['private'] = $_POST['status-private'];
102
+ $options['status']['draft'] = $_POST['status-draft'];
103
+ $options['status']['future'] = $_POST['status-future'];
104
+ break;
105
+ case 'num_terms':
106
+ $options['num_terms'] = $_POST['num_terms'];
107
+ if ($options['num_terms'] < 1) $options['num_terms'] = 20;
108
+ break;
109
+ default:
110
+ $options[$arg] = trim($_POST[$arg]);
111
+ }
112
+ }
113
+ return $options;
114
+ }
115
+
116
+ function ppl_check_cardinal($string) {
117
+ $value = intval($string);
118
+ return ($value > 0) ? $value : 0;
119
+ }
120
+
121
+ function ppl_display_available_tags($plugin_name) {
122
+ ?>
123
+ <h3><?php _e('Available Tags', 'post_plugin_library'); ?></h3>
124
+ <ul style="list-style-type: none;">
125
+ <li title="">{author}</li>
126
+ <li title="">{authorurl}</li>
127
+ <li title="">{categoryid}</li>
128
+ <li title="">{categorylinks}</li>
129
+ <li title="">{categorynames}</li>
130
+ <li title="">{commentcount}</li>
131
+ <li title="">{custom}</li>
132
+ <li title="">{date}</li>
133
+ <li title="">{dateedited}</li>
134
+ <li title="">{excerpt}</li>
135
+ <li title="">{fullpost}</li>
136
+ <li title="">{gravatar}</li>
137
+ <li title="">{if}</li>
138
+ <li title="">{image}</li>
139
+ <li title="">{imagealt}</li>
140
+ <li title="">{imagesrc}</li>
141
+ <li title="">{link}</li>
142
+ <li title="">{php}</li>
143
+ <li title="">{postid}</li>
144
+ <li title="">{postviews}</li>
145
+ <?php if ($plugin_name === 'similar-posts') { ?>
146
+ <li title="">{score}</li>
147
+ <?php } ?>
148
+ <li title="">{snippet}</li>
149
+ <li title="">{tags}</li>
150
+ <li title="">{taglinks}</li>
151
+ <li title="">{title}</li>
152
+ <li title="">{time}</li>
153
+ <li title="">{timeedited}</li>
154
+ <li title="">{totalpages}</li>
155
+ <li title="">{totalposts}</li>
156
+ <li title="">{url}</li>
157
+ </ul>
158
+ <?php
159
+ }
160
+
161
+ function ppl_display_available_comment_tags() {
162
+ ?>
163
+ <ul style="list-style-type: none;">
164
+ <li title="">{commentexcerpt}</li>
165
+ <li title="">{commentsnippet}</li>
166
+ <li title="">{commentdate}</li>
167
+ <li title="">{commenttime}</li>
168
+ <li title="">{commentdategmt}</li>
169
+ <li title="">{commenttimegmt}</li>
170
+ <li title="">{commenter}</li>
171
+ <li title="">{commenterip}</li>
172
+ <li title="">{commenterurl}</li>
173
+ <li title="">{commenterlink}</li>
174
+ <li title="">{commenturl}</li>
175
+ <li title="">{commentpopupurl}</li>
176
+ <li title="">{commentlink}</li>
177
+ <li title="">{commentlink2}</li>
178
+ </ul>
179
+ <?php
180
+ }
181
+
182
+ /*
183
+
184
+ inserts a form button to submit a bug report to my web site
185
+
186
+ */
187
+ function get_plugin_version($prefix) {
188
+ $plugin_version = str_replace('-', '_', $prefix) . '_version';
189
+ global $$plugin_version;
190
+ return ${$plugin_version};
191
+ }
192
+
193
+
194
+
195
+ /*
196
+
197
+ inserts a form button to completely remove the plugin and all its options etc.
198
+
199
+ */
200
+
201
+ function ppl_confirm_eradicate() {
202
+ return (isset($_POST['eradicate-check']) && 'yes'===$_POST['eradicate-check']);
203
+ }
204
+
205
+ function ppl_deactivate_plugin($plugin_file) {
206
+ $current = get_option('active_plugins');
207
+ $plugin_file = substr($plugin_file, strlen(WP_PLUGIN_DIR)+1);
208
+ $plugin_file = str_replace('\\', '/', $plugin_file);
209
+ if (in_array($plugin_file, $current)) {
210
+ array_splice($current, array_search($plugin_file, $current), 1);
211
+ update_option('active_plugins', $current);
212
+ }
213
+ }
214
+
215
+
216
+ /*
217
+
218
+ For the display of the option pages
219
+
220
+ */
221
+
222
+ function ppl_display_limit($limit) {
223
+ ?>
224
+ <tr valign="top">
225
+ <th scope="row"><label for="limit"><?php _e('Number of posts to show:', 'post_plugin_library') ?></label></th>
226
+ <td><input name="limit" type="number" id="limit" style="width: 60px;" value="<?php echo $limit; ?>" size="2" /></td>
227
+ </tr>
228
+ <?php
229
+ }
230
+
231
+ function ppl_display_unique($unique) {
232
+ ?>
233
+ <tr valign="top">
234
+ <th scope="row"><label for="unique"><?php _e('Show just one comment per post?', 'post_plugin_library') ?></label></th>
235
+ <td>
236
+ <select name="unique" id="unique" >
237
+ <option <?php if($unique == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
238
+ <option <?php if($unique == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
239
+ </select>
240
+ </td>
241
+ </tr>
242
+ <?php
243
+ }
244
+
245
+ function ppl_display_skip($skip) {
246
+ ?>
247
+ <tr valign="top">
248
+ <th scope="row"><label for="skip"><?php _e('Number of posts to skip:', 'post_plugin_library') ?></label></th>
249
+ <td><input name="skip" type="number" id="skip" style="width: 60px;" value="<?php echo $skip; ?>" size="2" /></td>
250
+ </tr>
251
+ <?php
252
+ }
253
+
254
+ function ppl_display_omit_current_post($omit_current_post) {
255
+ ?>
256
+ <tr valign="top">
257
+ <th scope="row"><label for="omit_current_post"><?php _e('Omit the current post?', 'post_plugin_library') ?></label></th>
258
+ <td>
259
+ <select name="omit_current_post" id="omit_current_post" >
260
+ <option <?php if($omit_current_post == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
261
+ <option <?php if($omit_current_post == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
262
+ </select>
263
+ </td>
264
+ </tr>
265
+ <?php
266
+ }
267
+
268
+ function ppl_display_just_current_post($just_current_post) {
269
+ ?>
270
+ <tr valign="top">
271
+ <th scope="row"><label for="just_current_post"><?php _e('Show just the current post?', 'post_plugin_library') ?></label></th>
272
+ <td>
273
+ <select name="just_current_post" id="just_current_post" >
274
+ <option <?php if($just_current_post == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
275
+ <option <?php if($just_current_post == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
276
+ </select>
277
+ </td>
278
+ </tr>
279
+ <?php
280
+ }
281
+
282
+ function ppl_display_show_private($show_private) {
283
+ ?>
284
+ <tr valign="top">
285
+ <th scope="row"><label for="show_private"><?php _e('Show password-protected posts?', 'post_plugin_library') ?></label></th>
286
+ <td>
287
+ <select name="show_private" id="show_private">
288
+ <option <?php if($show_private == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
289
+ <option <?php if($show_private == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
290
+ </select>
291
+ </td>
292
+ </tr>
293
+ <?php
294
+ }
295
+
296
+ function ppl_display_show_pages($show_pages) {
297
+ ?>
298
+ <tr valign="top">
299
+ <th scope="row"><label for="show_pages"><?php _e('Show static pages?', 'post_plugin_library') ?></label></th>
300
+ <td>
301
+ <select name="show_pages" id="show_pages">
302
+ <option <?php if($show_pages == 'false') { echo 'selected="selected"'; } ?> value="false">No pages, just posts</option>
303
+ <option <?php if($show_pages == 'true') { echo 'selected="selected"'; } ?> value="true">Both pages and posts</option>
304
+ <option <?php if($show_pages == 'but') { echo 'selected="selected"'; } ?> value="but">Pages but no posts</option>
305
+ </select>
306
+ </td>
307
+ </tr>
308
+ <?php
309
+ }
310
+
311
+ function ppl_display_show_attachments($show_attachments) {
312
+ ?>
313
+ <tr valign="top">
314
+ <th scope="row"><label for="show_attachments"><?php _e('Show attachments?', 'post_plugin_library') ?></label></th>
315
+ <td>
316
+ <select name="show_attachments" id="show_attachments">
317
+ <option <?php if($show_attachments == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
318
+ <option <?php if($show_attachments == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
319
+ </select>
320
+ </td>
321
+ </tr>
322
+ <?php
323
+ }
324
+
325
+ function ppl_display_match_author($match_author) {
326
+ ?>
327
+ <tr valign="top">
328
+ <th scope="row"><label for="match_author"><?php _e('Match the current post\'s author?', 'post_plugin_library') ?></label></th>
329
+ <td>
330
+ <select name="match_author" id="match_author">
331
+ <option <?php if($match_author == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
332
+ <option <?php if($match_author == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
333
+ </select>
334
+ </td>
335
+ </tr>
336
+ <?php
337
+ }
338
+
339
+ function ppl_display_match_cat($match_cat) {
340
+ ?>
341
+ <tr valign="top">
342
+ <th scope="row"><label for="match_cat"><?php _e('Match the current post\'s category?', 'post_plugin_library') ?></label></th>
343
+ <td>
344
+ <select name="match_cat" id="match_cat">
345
+ <option <?php if($match_cat == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
346
+ <option <?php if($match_cat == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
347
+ </select>
348
+ </td>
349
+ </tr>
350
+ <?php
351
+ }
352
+
353
+ function ppl_display_match_tags($match_tags) {
354
+ global $wp_version;
355
+ ?>
356
+ <tr valign="top">
357
+ <th scope="row"><label for="match_tags"><?php _e('Match the current post\'s tags?', 'post_plugin_library') ?></label></th>
358
+ <td>
359
+ <select name="match_tags" id="match_tags" <?php if ($wp_version < 2.3) echo 'disabled="true"'; ?> >
360
+ <option <?php if($match_tags == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
361
+ <option <?php if($match_tags == 'any') { echo 'selected="selected"'; } ?> value="any">Any tag</option>
362
+ <option <?php if($match_tags == 'all') { echo 'selected="selected"'; } ?> value="all">Every tag</option>
363
+ </select>
364
+ </td>
365
+ </tr>
366
+ <?php
367
+ }
368
+
369
+ function ppl_display_none_text($none_text) {
370
+ ?>
371
+ <tr valign="top">
372
+ <th scope="row"><label for="none_text"><?php _e('Default display if no matches:', 'post_plugin_library') ?></label></th>
373
+ <td><input name="none_text" type="text" id="none_text" value="<?php echo htmlspecialchars(stripslashes($none_text)); ?>" size="40" /></td>
374
+ </tr>
375
+ <?php
376
+ }
377
+
378
+ function ppl_display_no_text($no_text) {
379
+ ?>
380
+ <tr valign="top">
381
+ <th scope="row"><label for="no_text"><?php _e('Show nothing if no matches?', 'post_plugin_library') ?></label></th>
382
+ <td>
383
+ <select name="no_text" id="no_text">
384
+ <option <?php if($no_text == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
385
+ <option <?php if($no_text == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
386
+ </select>
387
+ </td>
388
+ </tr>
389
+ <?php
390
+ }
391
+
392
+ function ppl_display_prefix($prefix) {
393
+ ?>
394
+ <tr valign="top">
395
+ <th scope="row"><label for="prefix"><?php _e('Text and codes before the list:', 'post_plugin_library') ?></label></th>
396
+ <td><input name="prefix" type="text" id="prefix" value="<?php echo htmlspecialchars(stripslashes($prefix)); ?>" size="40" /></td>
397
+ </tr>
398
+ <?php
399
+ }
400
+
401
+ function ppl_display_suffix($suffix) {
402
+ ?>
403
+ <tr valign="top">
404
+ <th scope="row"><label for="suffix"><?php _e('Text and codes after the list:', 'post_plugin_library') ?></label></th>
405
+ <td><input name="suffix" type="text" id="suffix" value="<?php echo htmlspecialchars(stripslashes($suffix)); ?>" size="40" /></td>
406
+ </tr>
407
+ <?php
408
+ }
409
+
410
+ function ppl_display_output_template($output_template) {
411
+ ?>
412
+ <tr valign="top">
413
+ <th scope="row"><label for="output_template"><?php _e('Output template:', 'post_plugin_library') ?></label></th>
414
+ <td><textarea name="output_template" id="output_template" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($output_template)); ?></textarea></td>
415
+ </tr>
416
+ <?php
417
+ }
418
+
419
+ function ppl_display_divider($divider) {
420
+ ?>
421
+ <tr valign="top">
422
+ <th scope="row"><label for="divider"><?php _e('Text and codes between items:', 'post_plugin_library') ?></label></th>
423
+ <td><input name="divider" type="text" id="divider" value="<?php echo $divider; ?>" size="40" /></td>
424
+ </tr>
425
+ <?php
426
+ }
427
+
428
+ function ppl_display_tag_str($tag_str) {
429
+ global $wp_version;
430
+ ?>
431
+ <tr valign="top">
432
+ <th scope="row"><label for="tag_str"><?php _e('Match posts with tags:<br />(a,b matches posts with either tag, a+b only matches posts with both tags)', 'post_plugin_library') ?></label></th>
433
+ <td><input name="tag_str" type="text" id="tag_str" value="<?php echo $tag_str; ?>" <?php if ($wp_version < 2.3) echo 'disabled="true"'; ?> size="40" /></td>
434
+ </tr>
435
+ <?php
436
+ }
437
+
438
+ function ppl_display_excluded_posts($excluded_posts) {
439
+ ?>
440
+ <tr valign="top">
441
+ <th scope="row"><label for="excluded_posts"><?php _e('Posts to exclude:', 'post_plugin_library') ?></label></th>
442
+ <td><input name="excluded_posts" type="text" id="excluded_posts" value="<?php echo $excluded_posts; ?>" size="40" /> <?php _e('comma-separated IDs', 'post_plugin_library'); ?></td>
443
+ </tr>
444
+ <?php
445
+ }
446
+
447
+ function ppl_display_included_posts($included_posts) {
448
+ ?>
449
+ <tr valign="top">
450
+ <th scope="row"><label for="included_posts"><?php _e('Posts to include:', 'post_plugin_library') ?></label></th>
451
+ <td><input name="included_posts" type="text" id="included_posts" value="<?php echo $included_posts; ?>" size="40" /> <?php _e('comma-separated IDs', 'post_plugin_library'); ?></td>
452
+ </tr>
453
+ <?php
454
+ }
455
+
456
+ function ppl_display_authors($excluded_authors, $included_authors) {
457
+ global $wpdb;
458
+ ?>
459
+ <tr valign="top">
460
+ <th scope="row"><?php _e('Authors to exclude/include:', 'post_plugin_library') ?></th>
461
+ <td>
462
+ <table class="similarposts-inner-table">
463
+ <?php
464
+ $users = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
465
+ if ($users) {
466
+ $excluded = explode(',', $excluded_authors);
467
+ $included = explode(',', $included_authors);
468
+ echo "\n\t<tr valign=\"top\"><td><strong>Author</strong></td><td><strong>Exclude</strong></td><td><strong>Include</strong></td></tr>";
469
+ foreach ($users as $user) {
470
+ if (false === in_array($user->ID, $excluded)) {
471
+ $ex_ischecked = '';
472
+ } else {
473
+ $ex_ischecked = 'checked';
474
+ }
475
+ if (false === in_array($user->ID, $included)) {
476
+ $in_ischecked = '';
477
+ } else {
478
+ $in_ischecked = 'checked';
479
+ }
480
+ echo "\n\t<tr valign=\"top\"><td>$user->user_login</td><td><input type=\"checkbox\" name=\"excluded_authors[]\" value=\"$user->ID\" $ex_ischecked /></td><td><input type=\"checkbox\" name=\"included_authors[]\" value=\"$user->ID\" $in_ischecked /></td></tr>";
481
+ }
482
+ }
483
+ ?>
484
+ </table>
485
+ </td>
486
+ </tr>
487
+ <?php
488
+ }
489
+
490
+ function ppl_display_cats($excluded_cats, $included_cats) {
491
+ global $wpdb;
492
+ ?>
493
+ <tr valign="top">
494
+ <th scope="row"><?php _e('Categories to exclude/include:', 'post_plugin_library') ?></th>
495
+ <td>
496
+ <table class="similarposts-inner-table">
497
+ <?php
498
+ if (function_exists("get_categories")) {
499
+ $categories = get_categories();//('&hide_empty=1');
500
+ } else {
501
+ //$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE category_count <> 0 ORDER BY cat_name");
502
+ $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
503
+ }
504
+ if ($categories) {
505
+ echo "\n\t<tr valign=\"top\"><td><strong>Category</strong></td><td><strong>Exclude</strong></td><td><strong>Include</strong></td></tr>";
506
+ $excluded = explode(',', $excluded_cats);
507
+ $included = explode(',', $included_cats);
508
+ $level = 0;
509
+ $cats_added = array();
510
+ $last_parent = 0;
511
+ $cat_parent = 0;
512
+ foreach ($categories as $category) {
513
+ $category->cat_name = esc_html($category->cat_name);
514
+ if (false === in_array($category->cat_ID, $excluded)) {
515
+ $ex_ischecked = '';
516
+ } else {
517
+ $ex_ischecked = 'checked';
518
+ }
519
+ if (false === in_array($category->cat_ID, $included)) {
520
+ $in_ischecked = '';
521
+ } else {
522
+ $in_ischecked = 'checked';
523
+ }
524
+ $last_parent = $cat_parent;
525
+ $cat_parent = $category->category_parent;
526
+ if ($cat_parent == 0) {
527
+ $level = 0;
528
+ } elseif ($last_parent != $cat_parent) {
529
+ if (in_array($cat_parent, $cats_added)) {
530
+ $level = $level - 1;
531
+ } else {
532
+ $level = $level + 1;
533
+ }
534
+ $cats_added[] = $cat_parent;
535
+ }
536
+ $pad = str_repeat('&nbsp;', 3*$level);
537
+ echo "\n\t<tr valign=\"top\"><td>$pad$category->cat_name</td><td><input type=\"checkbox\" name=\"excluded_cats[]\" value=\"$category->cat_ID\" $ex_ischecked /></td><td><input type=\"checkbox\" name=\"included_cats[]\" value=\"$category->cat_ID\" $in_ischecked /></td></tr>";
538
+ }
539
+ }
540
+ ?>
541
+ </table>
542
+ </td>
543
+ </tr>
544
+ <?php
545
+ }
546
+
547
+ function ppl_display_stripcodes($stripcodes) {
548
+ ?>
549
+ <tr valign="top">
550
+ <th scope="row"><?php _e('Other plugins\' tags to remove from snippet:', 'post_plugin_library') ?></th>
551
+ <td>
552
+ <table>
553
+ <tr><td style="border-bottom-width: 0"><label for="starttags"><?php _e('opening', 'post_plugin_library') ?></label></td><td style="border-bottom-width: 0"><label for="endtags"><?php _e('closing', 'post_plugin_library') ?></label></td></tr>
554
+ <tr valign="top"><td style="border-bottom-width: 0">
555
+ <textarea name="starttags" id="starttags" rows="4" cols="20"><?php
556
+ foreach ($stripcodes as $tag) {
557
+ if(array_key_exists('start',$tag)){
558
+ echo htmlspecialchars(stripslashes($tag['start']))."\n";
559
+ }
560
+ }
561
+ ?></textarea></td><td style="border-bottom-width: 0">
562
+
563
+ <textarea name="endtags" id="endtags" rows="4" cols="20"><?php
564
+ foreach ($stripcodes as $tag) {
565
+ if(array_key_exists('end',$tag)){
566
+ echo htmlspecialchars(stripslashes($tag['end']))."\n";
567
+ }
568
+ }
569
+ ?></textarea>
570
+ </td></tr>
571
+ </table>
572
+ </td>
573
+ </tr>
574
+ <?php
575
+ }
576
+
577
+ function ppl_display_age($age) {
578
+ ?>
579
+ <tr valign="top">
580
+ <th scope="row"><label for="age-direction"><?php _e('Ignore posts:', 'post_plugin_library') ?></label></th>
581
+ <td>
582
+
583
+ <select name="age-direction" id="age-direction">
584
+ <option <?php if($age['direction'] == 'before') { echo 'selected="selected"'; } ?> value="before">less than</option>
585
+ <option <?php if($age['direction'] == 'after') { echo 'selected="selected"'; } ?> value="after">more than</option>
586
+ <option <?php if($age['direction'] == 'none') { echo 'selected="selected"'; } ?> value="none">-----</option>
587
+ </select>
588
+ <input style="vertical-align: middle; width: 60px;" name="age-length" type="number" id="age-length" value="<?php echo $age['length']; ?>" size="4" />
589
+
590
+ <select name="age-duration" id="age-duration">
591
+ <option <?php if($age['duration'] == 'day') { echo 'selected="selected"'; } ?> value="day">day(s)</option>
592
+ <option <?php if($age['duration'] == 'month') { echo 'selected="selected"'; } ?> value="month">month(s)</option>
593
+ <option <?php if($age['duration'] == 'year') { echo 'selected="selected"'; } ?> value="year">year(s)</option>
594
+ </select>
595
+ old
596
+
597
+ </td>
598
+ </tr>
599
+ <?php
600
+ }
601
+
602
+ function ppl_display_status($status) {
603
+ ?>
604
+ <tr valign="top">
605
+ <th scope="row"><?php _e('Display posts that are:', 'post_plugin_library') ?></th>
606
+ <td>
607
+
608
+ <label for="status-publish">Published</label>
609
+ <select name="status-publish" id="status-publish" <?php if (!function_exists('get_post_type')) echo 'disabled="true"'; ?>>
610
+ <option <?php if($status['publish'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
611
+ <option <?php if($status['publish'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
612
+ </select>
613
+
614
+ <label for="status-private">Private</label>
615
+ <select name="status-private" id="status-private" <?php if (!function_exists('get_post_type')) echo 'disabled="true"'; ?>>
616
+ <option <?php if($status['private'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
617
+ <option <?php if($status['private'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
618
+ </select>
619
+
620
+ <label for="status-draft">Draft</label>
621
+ <select name="status-draft" id="status-draft" <?php if (!function_exists('get_post_type')) echo 'disabled="true"'; ?>>
622
+ <option <?php if($status['draft'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
623
+ <option <?php if($status['draft'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
624
+ </select>
625
+
626
+ <label for="status-future">Future</label>
627
+ <select name="status-future" id="status-future" <?php if (!function_exists('get_post_type')) echo 'disabled="true"'; ?>>
628
+ <option <?php if($status['future'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
629
+ <option <?php if($status['future'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
630
+ </select>
631
+
632
+ </td>
633
+ </tr>
634
+ <?php
635
+ }
636
+
637
+ function ppl_display_custom($custom) {
638
+ ?>
639
+ <tr valign="top">
640
+ <th scope="row"><?php _e('Match posts by custom field:', 'post_plugin_library') ?></th>
641
+ <td>
642
+ <table>
643
+ <tr><td style="border-bottom-width: 0">Field Name</td><td style="border-bottom-width: 0"></td><td style="border-bottom-width: 0">Field Value</td></tr>
644
+ <tr>
645
+ <td style="border-bottom-width: 0"><input name="custom-key" type="text" id="custom-key" value="<?php echo $custom['key']; ?>" size="20" /></td>
646
+ <td style="border-bottom-width: 0">
647
+ <select name="custom-op" id="custom-op">
648
+ <option <?php if($custom['op'] == '=') { echo 'selected="selected"'; } ?> value="=">=</option>
649
+ <option <?php if($custom['op'] == '!=') { echo 'selected="selected"'; } ?> value="!=">!=</option>
650
+ <option <?php if($custom['op'] == '>') { echo 'selected="selected"'; } ?> value=">">></option>
651
+ <option <?php if($custom['op'] == '>=') { echo 'selected="selected"'; } ?> value=">=">>=</option>
652
+ <option <?php if($custom['op'] == '<') { echo 'selected="selected"'; } ?> value="<"><</option>
653
+ <option <?php if($custom['op'] == '<=') { echo 'selected="selected"'; } ?> value="<="><=</option>
654
+ <option <?php if($custom['op'] == 'LIKE') { echo 'selected="selected"'; } ?> value="LIKE">LIKE</option>
655
+ <option <?php if($custom['op'] == 'NOT LIKE') { echo 'selected="selected"'; } ?> value="NOT LIKE">NOT LIKE</option>
656
+ <option <?php if($custom['op'] == 'REGEXP') { echo 'selected="selected"'; } ?> value="REGEXP">REGEXP</option>
657
+ <option <?php if($custom['op'] == 'EXISTS') { echo 'selected="selected"'; } ?> value="EXISTS">EXISTS</option>
658
+ </select>
659
+ </td>
660
+ <td style="border-bottom-width: 0"><input name="custom-value" type="text" id="custom-value" value="<?php echo $custom['value']; ?>" size="20" /></td>
661
+ </tr>
662
+ </table>
663
+ </td>
664
+ </tr>
665
+ <?php
666
+ }
667
+
668
+ function ppl_display_append($options) {
669
+ ?>
670
+ <tr valign="top">
671
+ <th scope="row"><?php _e('Output after post:', 'post_plugin_library') ?></th>
672
+ <td>
673
+ <table>
674
+ <tr><td style="border-bottom-width: 0"><label for="append_on">Activate</label></td><td style="border-bottom-width: 0"><label for="append_priority">Priority</label></td><td style="border-bottom-width: 0"><label for="append_parameters">Parameters</label></td><td style="border-bottom-width: 0"><label for="append_condition">Condition</label></td></tr>
675
+ <tr>
676
+ <td style="border-bottom-width: 0">
677
+ <select name="append_on" id="append_on">
678
+ <option <?php if($options['append_on'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
679
+ <option <?php if($options['append_on'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
680
+ </select>
681
+ </td>
682
+ <td style="border-bottom-width: 0"><input name="append_priority" type="number" id="append_priority" style="width: 60px;" value="<?php echo $options['append_priority']; ?>" size="3" /></td>
683
+ <td style="border-bottom-width: 0"><textarea name="append_parameters" id="append_parameters" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($options['append_parameters'])); ?></textarea></td>
684
+ <td style="border-bottom-width: 0"><textarea name="append_condition" id="append_condition" rows="4" cols="20"><?php echo htmlspecialchars(stripslashes($options['append_condition'])); ?></textarea></td>
685
+ </tr></table>
686
+ </td>
687
+ </tr>
688
+ <?php
689
+ }
690
+
691
+ function ppl_display_feed($options) {
692
+ ?>
693
+ <tr valign="top">
694
+ <th scope="row"><?php _e('Output in RSS feeds:', 'post_plugin_library') ?></th>
695
+ <td>
696
+ <table>
697
+ <tr><td style="border-bottom-width: 0"><label for="feed_on">Activate</label></td><td style="border-bottom-width: 0"><label for="feed_priority">Priority</label></td><td style="border-bottom-width: 0"><label for="feed_parameters">Parameters</label></td></tr>
698
+ <tr>
699
+ <td style="border-bottom-width: 0">
700
+ <select name="feed_on" id="feed_on">
701
+ <option <?php if($options['feed_on'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
702
+ <option <?php if($options['feed_on'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
703
+ </select>
704
+ </td>
705
+ <td style="border-bottom-width: 0"><input name="feed_priority" type="number" id="feed_priority" style="width: 60px;" value="<?php echo $options['feed_priority']; ?>" size="3" /></td>
706
+ <td style="border-bottom-width: 0"><textarea name="feed_parameters" id="feed_parameters" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($options['feed_parameters'])); ?></textarea></td>
707
+ </tr></table>
708
+ </td>
709
+ </tr>
710
+ <?php
711
+ }
712
+
713
+ function ppl_display_widget($options) {
714
+ ?>
715
+ <tr valign="top">
716
+ <th scope="row"><?php _e('Output in widget:', 'post_plugin_library') ?></th>
717
+ <td>
718
+ <table>
719
+ <tr><td style="border-bottom-width: 0"></td><td style="border-bottom-width: 0"></td><td style="border-bottom-width: 0"><label for="widget_parameters">Parameters</label></td><td style="border-bottom-width: 0"><label for="widget_condition">Condition</label></td></tr>
720
+ <tr>
721
+ <td style="border-bottom-width: 0;visibility: hidden;">
722
+ <select name="dummy" id="dummy1">
723
+ <option value="false">No</option>
724
+ <option value="true">Yes</option>
725
+ </select>
726
+ </td>
727
+ <td style="border-bottom-width: 0;visibility: hidden;"><input name="dummy2" type="text" id="dummy2" value="" size="3" /></td>
728
+ <td style="border-bottom-width: 0"><textarea name="widget_parameters" id="widget_parameters" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($options['widget_parameters'])); ?></textarea></td>
729
+ <td style="border-bottom-width: 0"><textarea name="widget_condition" id="widget_condition" rows="4" cols="20"><?php echo htmlspecialchars(stripslashes($options['widget_condition'])); ?></textarea></td>
730
+ </tr></table>
731
+ </td>
732
+ </tr>
733
+ <?php
734
+ }
735
+
736
+ function ppl_display_feed_active($feed_active) {
737
+ ?>
738
+ <tr valign="top">
739
+ <th scope="row"><label for="feed_active"><?php _e('Add Similar Posts to feeds? (DEPRECATED! This setting will be removed in the next major release - use the placement settings instead)', 'post_plugin_library') ?></label></th>
740
+ <td>
741
+ <select name="feed_active" id="feed_active">
742
+ <option <?php if($feed_active == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
743
+ <option <?php if($feed_active == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
744
+ </select>
745
+ </td>
746
+ </tr>
747
+ <?php
748
+ }
749
+
750
+ function ppl_display_content_filter($content_filter) {
751
+ ?>
752
+ <tr valign="top">
753
+ <th scope="row"><?php _e('Output in content:<br />(<em>via</em> special tags)', 'post_plugin_library') ?></th>
754
+ <td>
755
+ <table>
756
+ <tr><td style="border-bottom-width: 0"><label for="content_filter">Activate</label></td></tr>
757
+ <tr>
758
+ <td style="border-bottom-width: 0">
759
+ <select name="content_filter" id="content_filter">
760
+ <option <?php if($content_filter == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
761
+ <option <?php if($content_filter == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
762
+ </select>
763
+ </td>
764
+ </tr>
765
+ </table>
766
+ </td>
767
+ </tr>
768
+ <?php
769
+ }
770
+
771
+ function ppl_display_sort($sort) {
772
+ global $wpdb;
773
+ ?>
774
+ <tr valign="top">
775
+ <th scope="row"><?php _e('Sort Output By:<br />leave blank for default order', 'post_plugin_library') ?></th>
776
+ <td>
777
+ <table>
778
+ <tr><td style="border-bottom-width: 0"></td><td style="border-bottom-width: 0">Output Tag</td><td style="border-bottom-width: 0">Order</td><td style="border-bottom-width: 0">Case</td></tr>
779
+ <tr>
780
+ <td style="border-bottom-width: 0">first</td>
781
+ <td style="border-bottom-width: 0"><input name="sort-by1" type="text" id="sort-by1" value="<?php echo $sort['by1']; ?>" size="20" /></td>
782
+ <td style="border-bottom-width: 0">
783
+ <select name="sort-order1" id="sort-order1">
784
+ <option <?php if($sort['order1'] == SORT_ASC) { echo 'selected="selected"'; } ?> value="SORT_ASC">ascending</option>
785
+ <option <?php if($sort['order1'] == SORT_DESC) { echo 'selected="selected"'; } ?> value="SORT_DESC">descending</option>
786
+ </select>
787
+ </td>
788
+ <td style="border-bottom-width: 0">
789
+ <select name="sort-case1" id="sort-case1">
790
+ <option <?php if($sort['case1'] == 'false') { echo 'selected="selected"'; } ?> value="false">case-sensitive</option>
791
+ <option <?php if($sort['case1'] == 'true') { echo 'selected="selected"'; } ?> value="true">case-insensitive</option>
792
+ </select>
793
+ </td>
794
+ </tr>
795
+ <tr>
796
+ <td style="border-bottom-width: 0">then</td>
797
+ <td style="border-bottom-width: 0"><input name="sort-by2" type="text" id="sort-by2" value="<?php echo $sort['by2']; ?>" size="20" /></td>
798
+ <td style="border-bottom-width: 0">
799
+ <select name="sort-order2" id="sort-order2">
800
+ <option <?php if($sort['order2'] == SORT_ASC) { echo 'selected="selected"'; } ?> value="SORT_ASC">ascending</option>
801
+ <option <?php if($sort['order2'] == SORT_DESC) { echo 'selected="selected"'; } ?> value="SORT_DESC">descending</option>
802
+ </select>
803
+ </td>
804
+ <td style="border-bottom-width: 0">
805
+ <select name="sort-case2" id="sort-case2">
806
+ <option <?php if($sort['case2'] == 'false') { echo 'selected="selected"'; } ?> value="false">case-sensitive</option>
807
+ <option <?php if($sort['case2'] == 'true') { echo 'selected="selected"'; } ?> value="true">case-insensitive</option>
808
+ </select>
809
+ </td>
810
+ </tr>
811
+ </table>
812
+ </td>
813
+ </tr>
814
+ <?php
815
+ }
816
+
817
+ function ppl_display_orderby($options) {
818
+ global $wpdb;
819
+ $limit = 30;
820
+ $keys = $wpdb->get_col( "
821
+ SELECT meta_key
822
+ FROM $wpdb->postmeta
823
+ WHERE meta_key NOT LIKE '\_%'
824
+ GROUP BY meta_key
825
+ ORDER BY meta_id DESC
826
+ LIMIT $limit" );
827
+ $metaselect = "<select id='orderby' name='orderby'>\n\t<option value=''></option>";
828
+ if ( $keys ) {
829
+ natcasesort($keys);
830
+ foreach ( $keys as $key ) {
831
+ $key = esc_attr( $key );
832
+ if ($options['orderby'] == $key) {
833
+ $metaselect .= "\n\t<option selected='selected' value='$key'>$key</option>";
834
+ } else {
835
+ $metaselect .= "\n\t<option value='$key'>$key</option>";
836
+ }
837
+ }
838
+ $metaselect .= "</select>";
839
+ }
840
+
841
+ ?>
842
+ <tr valign="top">
843
+ <th scope="row"><?php _e('Select output by custom field:', 'post_plugin_library') ?></th>
844
+ <td>
845
+ <table>
846
+ <tr><td style="border-bottom-width: 0">Field</td><td style="border-bottom-width: 0">Order</td><td style="border-bottom-width: 0">Case</td></tr>
847
+ <tr>
848
+ <td style="border-bottom-width: 0">
849
+ <?php echo $metaselect; ?>
850
+ </td>
851
+ <td style="border-bottom-width: 0">
852
+ <select name="orderby_order" id="orderby_order">
853
+ <option <?php if($options['orderby_order'] == 'ASC') { echo 'selected="selected"'; } ?> value="ASC">ascending</option>
854
+ <option <?php if($options['orderby_order'] == 'DESC') { echo 'selected="selected"'; } ?> value="DESC">descending</option>
855
+ </select>
856
+ </td>
857
+ <td style="border-bottom-width: 0">
858
+ <select name="orderby_case" id="orderby_case">
859
+ <option <?php if($options['orderby_case'] == 'false') { echo 'selected="selected"'; } ?> value="false">case-sensitive</option>
860
+ <option <?php if($options['orderby_case'] == 'true') { echo 'selected="selected"'; } ?> value="true">case-insensitive</option>
861
+ <option <?php if($options['orderby_case'] == 'num') { echo 'selected="selected"'; } ?> value="num">numeric</option>
862
+ </select>
863
+ </td>
864
+ </tr>
865
+ </table>
866
+ </td>
867
+ </tr>
868
+ <?php
869
+ }
870
+
871
+ // now for similar_posts
872
+
873
+ function ppl_display_num_terms($num_terms) {
874
+ ?>
875
+ <tr valign="top">
876
+ <th scope="row"><label for="num_terms"><?php _e('Maximum number of words to use for match:', 'post_plugin_library') ?></label></th>
877
+ <td><input name="num_terms" type="number" id="num_terms" style="width: 60px;" value="<?php echo $num_terms; ?>" size="3" /></td>
878
+ </tr>
879
+ <?php
880
+ }
881
+
882
+ function ppl_display_term_extraction($term_extraction) {
883
+ ?>
884
+ <tr valign="top">
885
+ <th scope="row" title=""><label for="term_extraction"><?php _e('Extract terms to match by:', 'post_plugin_library') ?></label></th>
886
+ <td>
887
+ <select name="term_extraction" id="term_extraction">
888
+ <option <?php if($term_extraction == 'frequency') { echo 'selected="selected"'; } ?> value="frequency">Word Frequency</option>
889
+ <option <?php if($term_extraction == 'pagerank') { echo 'selected="selected"'; } ?> value="pagerank">TextRank Algorithm</option>
890
+ </select>
891
+ </td>
892
+ </tr>
893
+ <?php
894
+ }
895
+
896
+ function ppl_display_weights($options) {
897
+ ?>
898
+ <tr valign="top">
899
+ <th scope="row"><?php _e('Relative importance of:', 'post_plugin_library') ?></th>
900
+ <td>
901
+ <label for="weight_content">content: </label><input name="weight_content" type="number" style="width: 60px;" id="weight_content" value="<?php echo round(100 * $options['weight_content']); ?>" size="3" /> %
902
+ <label for="weight_title" style="margin-left:20px;">title: </label><input name="weight_title" type="number" style="width: 60px;" id="weight_title" value="<?php echo round(100 * $options['weight_title']); ?>" size="3" /> %
903
+ <label for="weight_tags" style="margin-left:20px;">tags: </label><input name="weight_tags" type="number" style="width: 60px;" id="weight_tags" value="<?php echo round(100 * $options['weight_tags']); ?>" size="3" /> % ( adds up to 100% )
904
+ </td>
905
+ </tr>
906
+ <?php
907
+ }
908
+
909
+ function ppl_display_hand_links($hand_links) {
910
+ ?>
911
+ <tr valign="top">
912
+ <th scope="row"><label for="hand_links"><?php _e('Look for manual links in custom field?', 'post_plugin_library') ?></label></th>
913
+ <td>
914
+ <select name="hand_links" id="hand_links">
915
+ <option <?php if($hand_links == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
916
+ <option <?php if($hand_links == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
917
+ </select>
918
+ </td>
919
+ </tr>
920
+ <?php
921
+ }
922
+
923
+ // now for recent_comments
924
+
925
+ function ppl_display_show_type($show_type) {
926
+ ?>
927
+ <tr valign="top">
928
+ <th scope="row" title=""><label for="show_type"><?php _e('Type of comment to show:', 'post_plugin_library') ?></label></th>
929
+ <td>
930
+ <select name="show_type" id="show_type">
931
+ <option <?php if($show_type == 'all') { echo 'selected="selected"'; } ?> value="all">All kinds of comment</option>
932
+ <option <?php if($show_type == 'comments') { echo 'selected="selected"'; } ?> value="comments">Just plain comments</option>
933
+ <option <?php if($show_type == 'trackbacks') { echo 'selected="selected"'; } ?> value="trackbacks">Just trackbacks and pingbacks</option>
934
+ </select>
935
+ </td>
936
+ </tr>
937
+ <?php
938
+ }
939
+
940
+ function ppl_display_group_by($group_by) {
941
+ ?>
942
+ <tr valign="top">
943
+ <th scope="row" title=""><?php _e('Type of grouping:', 'post_plugin_library') ?></th>
944
+ <td>
945
+ <select name="group_by" id="group_by">
946
+ <option <?php if($group_by == 'post') { echo 'selected="selected"'; } ?> value="post">By Post</option>
947
+ <option <?php if($group_by == 'none') { echo 'selected="selected"'; } ?> value="none">Ungrouped</option>
948
+ <option <?php if($group_by == 'author') { echo 'selected="selected"'; } ?> value="author">By Commenter</option>
949
+ </select>
950
+ (overrides the sort criteria above)
951
+ </td>
952
+ </tr>
953
+ <?php
954
+ }
955
+
956
+ function ppl_display_group_template($group_template) {
957
+ ?>
958
+ <tr valign="top">
959
+ <th scope="row"><label for="group_template"><?php _e('Group title template:', 'post_plugin_library') ?></label></th>
960
+ <td><textarea name="group_template" id="group_template" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($group_template)); ?></textarea></td>
961
+ </tr>
962
+ <?php
963
+ }
964
+
965
+ function ppl_display_no_author_comments($no_author_comments) {
966
+ ?>
967
+ <tr valign="top">
968
+ <th scope="row"><label for="no_author_comments"><?php _e('Omit comments by the post author?', 'post_plugin_library') ?></label></th>
969
+ <td>
970
+ <select name="no_author_comments" id="no_author_comments">
971
+ <option <?php if($no_author_comments == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
972
+ <option <?php if($no_author_comments == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
973
+ </select>
974
+ </td>
975
+ </tr>
976
+ <?php
977
+ }
978
+
979
+ function ppl_display_no_user_comments($no_user_comments) {
980
+ ?>
981
+ <tr valign="top">
982
+ <th scope="row"><label for="no_user_comments"><?php _e('Omit comments by registered users?', 'post_plugin_library') ?></label></th>
983
+ <td>
984
+ <select name="no_user_comments" id="no_user_comments">
985
+ <option <?php if($no_user_comments == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
986
+ <option <?php if($no_user_comments == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
987
+ </select>
988
+ </td>
989
+ </tr>
990
+ <?php
991
+ }
992
+
993
+ function ppl_display_date_modified($date_modified) {
994
+ ?>
995
+ <tr valign="top">
996
+ <th scope="row"><?php _e('Order by date of last edit rather than date of creation?', 'post_plugin_library') ?></th>
997
+ <td>
998
+ <select name="date_modified" id="date_modified">
999
+ <option <?php if($date_modified == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
1000
+ <option <?php if($date_modified == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
1001
+ </select>
1002
+ </td>
1003
+ </tr>
1004
+ <?php
1005
+ }
1006
+
1007
+ // 'borrowed', with adaptations, from Stephen Rider at http://striderweb.com/nerdaphernalia/
1008
+ function ppl_get_plugin_data($plugin_file) {
1009
+ // You can optionally pass a specific value to fetch, e.g. 'Version' -- but it's inefficient to do that multiple times
1010
+ // As of WP 2.5.1: 'Name', 'Title', 'Description', 'Author', 'Version'
1011
+ // As of WP 2.7-bleeding: 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version', 'TextDomain', 'DomainPath'
1012
+ if(!function_exists( 'get_plugin_data' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php');
1013
+ static $plugin_data;
1014
+ if(!$plugin_data) {
1015
+ $plugin_data = get_plugin_data($plugin_file);
1016
+ if (!isset($plugin_data['Title'])) {
1017
+ if ('' != $plugin_data['PluginURI'] && '' != $plugin_data['Name']) {
1018
+ $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="'. __('Visit plugin homepage', 'post-plugin-library') . '">' . $plugin_data['Name'] . '</a>';
1019
+ } else {
1020
+ $plugin_data['Title'] = $name;
1021
+ }
1022
+ }
1023
+ }
1024
+ return $plugin_data;
1025
+ }
1026
+
1027
+ function ppl_admin_footer($plugin_file, $donate_key='') {
1028
+ /*$plugin_data = ppl_get_plugin_data($plugin_file);
1029
+ $output = array();
1030
+ $output[] = $plugin_data['Title'] . ' plugin';
1031
+ $output[] = 'Version ' . $plugin_data['Version'];
1032
+ $output[] = 'by ' . $plugin_data['Author'];
1033
+ if ($donate_key) {
1034
+ $donate_url = 'http://rmarsh.com/donate/' . $donate_key . '/';
1035
+ // random shades of red, orange and yellow to attract attention -- subtly I hope
1036
+ $colour = '#ff' . dechex(mt_rand(0, 255)) . '00';
1037
+ $output[] = '<a href="' . $donate_url . '" style="font-weight: bold;color: '.$colour.';" rel="nofollow" title="If you like ' . $plugin_data['Name'] . ' plugin why not make a tiny/small/large donation towards its upkeep">All donations welcomed!</a>';
1038
+ }
1039
+ echo implode(' | ', $output) . '<br />';
1040
+ */
1041
+ }
common_functions.php ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Similar Posts
4
+ * (c) Web factory Ltd, 2008 - 2016
5
+ */
6
+
7
+
8
+ /*
9
+ Library for the Recent Posts, Random Posts, Recent Comments, and Similar Posts plugins
10
+ -- provides the routines which the plugins share
11
+ */
12
+
13
+ define('CF_LIBRARY', true);
14
+
15
+ function ppl_parse_args($args) {
16
+ // $args is of the form 'key1=val1&key2=val2'
17
+ // The code copes with null values, e.g., 'key1=&key2=val2'
18
+ // and arguments with embedded '=', e.g. 'output_template=<li class="stuff">{...}</li>'.
19
+ $result = array();
20
+ if($args){
21
+ // the default separator is '&' but you may wish to include the character in a title, say,
22
+ // so you can specify an alternative separator by making the first character of $args
23
+ // '&' and the second character your new separator...
24
+ if (substr($args, 0, 1) === '&') {
25
+ $s = substr($args, 1, 1);
26
+ $args = substr($args, 2);
27
+ } else {
28
+ $s = '&';
29
+ }
30
+ // separate the arguments into key=value pairs
31
+ $arguments = explode($s, $args);
32
+ foreach($arguments as $arg){
33
+ if($arg){
34
+ // find the position of the first '='
35
+ $i = strpos($arg, '=');
36
+ // if not a valid format ('key=value) we ignore it
37
+ if ($i){
38
+ $key = substr($arg, 0, $i);
39
+ $val = substr($arg, $i+1);
40
+ $result[$key]=$val;
41
+ }
42
+ }
43
+ }
44
+ }
45
+ return $result;
46
+ }
47
+
48
+ function ppl_set_options($option_key, $arg, $default_output_template) {
49
+ $options = get_option($option_key);
50
+ // deal with compound options
51
+ if (isset($arg['custom-key'])) {$arg['custom']['key'] = $arg['custom-key']; unset($arg['custom-key']);}
52
+ if (isset($arg['custom-op'])) {$arg['custom']['op'] = $arg['custom-op']; unset($arg['custom-op']);}
53
+ if (isset($arg['custom-value'])) {$arg['custom']['value'] = $arg['custom-value']; unset($arg['custom-value']);}
54
+ if (isset($arg['age-direction'])) {$arg['age']['direction'] = $arg['age-direction']; unset($arg['age-direction']);}
55
+ if (isset($arg['age-length'])) {$arg['age']['length'] = $arg['age-length']; unset($arg['age-length']);}
56
+ if (isset($arg['age-duration'])) {$arg['age']['duration'] = $arg['age-duration']; unset($arg['age-duration']);}
57
+ if (isset($arg['sort-by1'])) {$arg['sort']['by1'] = $arg['sort-by1']; unset($arg['sort-by1']);}
58
+ if (isset($arg['sort-order1'])) {$arg['sort']['order1'] = $arg['sort-order1']; unset($arg['sort-order1']);}
59
+ if (isset($arg['sort-case1'])) {$arg['sort']['case1'] = $arg['sort-case1']; unset($arg['sort-case1']);}
60
+ if (isset($arg['sort-by2'])) {$arg['sort']['by2'] = $arg['sort-by2']; unset($arg['sort-by2']);}
61
+ if (isset($arg['sort-order2'])) {$arg['sort']['order2'] = $arg['sort-order2']; unset($arg['sort-order2']);}
62
+ if (isset($arg['sort-case2'])) {$arg['sort']['case2'] = $arg['sort-case2']; unset($arg['sort-case2']);}
63
+ if (isset($arg['status-publish'])) {$arg['status']['publish'] = $arg['status-publish']; unset($arg['status-publish']);}
64
+ if (isset($arg['status-private'])) {$arg['status']['private'] = $arg['status-private']; unset($arg['status-private']);}
65
+ if (isset($arg['status-draft'])) {$arg['status']['draft'] = $arg['status-draft']; unset($arg['status-draft']);}
66
+ if (isset($arg['status-future'])) {$arg['status']['future'] = $arg['status-future']; unset($arg['status-future']);}
67
+ // then fill in the defaults
68
+ if (!isset($arg['limit'])) $arg['limit'] = stripslashes(@$options['limit']);
69
+ if (!isset($arg['skip'])) $arg['skip'] = stripslashes(@$options['skip']);
70
+ if (!isset($arg['divider'])) $arg['divider'] = stripslashes(@$options['divider']);
71
+ if (!isset($arg['omit_current_post'])) $arg['omit_current_post'] = @$options['omit_current_post'];
72
+ if (!isset($arg['just_current_post'])) $arg['just_current_post'] = @$options['just_current_post'];
73
+ if (!isset($arg['show_private'])) $arg['show_private'] = @$options['show_private'];
74
+ if (!isset($arg['show_pages'])) $arg['show_pages'] = @$options['show_pages'];
75
+ if (!isset($arg['show_attachments'])) $arg['show_attachments'] = @$options['show_attachments'];
76
+ if (!isset($arg['none_text'])) $arg['none_text'] = stripslashes(@$options['none_text']);
77
+ if (!isset($arg['no_text'])) $arg['no_text'] = @$options['no_text'];
78
+ if (!isset($arg['tag_str'])) $arg['tag_str'] = stripslashes(@$options['tag_str']);
79
+ if (!isset($arg['excluded_cats'])) $arg['excluded_cats'] = stripslashes(@$options['excluded_cats']);
80
+ if (!isset($arg['included_cats'])) $arg['included_cats'] = stripslashes(@$options['included_cats']);
81
+ if (!isset($arg['excluded_authors'])) $arg['excluded_authors'] = stripslashes(@$options['excluded_authors']);
82
+ if (!isset($arg['included_authors'])) $arg['included_authors'] = stripslashes(@$options['included_authors']);
83
+ if (!isset($arg['excluded_posts'])) $arg['excluded_posts'] = stripslashes(@$options['excluded_posts']);
84
+ if (!isset($arg['included_posts'])) $arg['included_posts'] = stripslashes(@$options['included_posts']);
85
+ if (!isset($arg['stripcodes'])) $arg['stripcodes'] = @$options['stripcodes'];
86
+ if (!isset($arg['prefix'])) $arg['prefix'] = stripslashes(@$options['prefix']);
87
+ if (!isset($arg['suffix'])) $arg['suffix'] = stripslashes(@$options['suffix']);
88
+ if (!isset($arg['output_template'])) $arg['output_template'] = stripslashes(@$options['output_template']);
89
+ // an empty output_template makes no sense so we fall back to the default
90
+ if ($arg['output_template'] == '') $arg['output_template'] = $default_output_template;
91
+ if (!isset($arg['match_cat'])) $arg['match_cat'] = @$options['match_cat'];
92
+ if (!isset($arg['match_tags'])) $arg['match_tags'] = @$options['match_tags'];
93
+ if (!isset($arg['match_author'])) $arg['match_author'] = @$options['match_author'];
94
+ if (!isset($arg['age'])) $arg['age'] = @$options['age'];
95
+ if (!isset($arg['custom'])) $arg['custom'] = @$options['custom'];
96
+ if (!isset($arg['sort'])) $arg['sort'] = @$options['sort'];
97
+ if (!isset($arg['status'])) $arg['status'] = @$options['status'];
98
+
99
+ // just for recent_posts
100
+ if (!isset($arg['date_modified'])) $arg['date_modified'] = @$options['date_modified'];
101
+
102
+ // just for recent_comments
103
+ if (!isset($arg['group_by'])) $arg['group_by'] = @$options['group_by'];
104
+ if (!isset($arg['group_template'])) $arg['group_template'] = stripslashes(@$options['group_template']);
105
+ if (!isset($arg['show_type'])) $arg['show_type'] = @$options['show_type'];
106
+ if (!isset($arg['no_author_comments'])) $arg['no_author_comments'] = @$options['no_author_comments'];
107
+ if (!isset($arg['no_user_comments'])) $arg['no_user_comments'] = @$options['no_user_comments'];
108
+ if (!isset($arg['unique'])) $arg['unique'] = @$options['unique'];
109
+
110
+ // just for similar_posts[feed]
111
+ if (!isset($arg['combine'])) $arg['combine'] = @$options['crossmatch'];
112
+ if (!isset($arg['weight_content'])) $arg['weight_content'] = @$options['weight_content'];
113
+ if (!isset($arg['weight_title'])) $arg['weight_title'] = @$options['weight_title'];
114
+ if (!isset($arg['weight_tags'])) $arg['weight_tags'] = @$options['weight_tags'];
115
+ if (!isset($arg['num_terms'])) $arg['num_terms'] = stripslashes(@$options['num_terms']);
116
+ if (!isset($arg['term_extraction'])) $arg['term_extraction'] = @$options['term_extraction'];
117
+ if (!isset($arg['hand_links'])) $arg['hand_links'] = @$options['hand_links'];
118
+
119
+ // just for other_posts
120
+ if (!isset($arg['orderby'])) $arg['orderby'] = stripslashes(@$options['orderby']);
121
+ if (!isset($arg['orderby_order'])) $arg['orderby_order'] = @$options['orderby_order'];
122
+ if (!isset($arg['orderby_case'])) $arg['orderby_case'] = @$options['orderby_case'];
123
+
124
+ // the last options cannot be set via arguments
125
+ $arg['stripcodes'] = @$options['stripcodes'];
126
+ $arg['utf8'] = @$options['utf8'];
127
+ $arg['cjk'] = @$options['cjk'];
128
+ $arg['use_stemmer'] = @$options['use_stemmer'];
129
+ $arg['batch'] = @$options['batch'];
130
+ $arg['content_filter'] = @$options['content_filter'];
131
+ $arg['widget_parameters'] = stripslashes(@$options['widget_parameters']);
132
+ $arg['widget_condition'] = stripslashes(@$options['widget_condition']);
133
+ $arg['feed_on'] = @$options['feed_on'];
134
+ $arg['feed_priority'] = @$options['feed_priority'];
135
+ $arg['feed_parameters'] = stripslashes(@$options['feed_parameters']);
136
+ $arg['append_on'] = @$options['append_on'];
137
+ $arg['append_priority'] = @$options['append_priority'];
138
+ $arg['append_parameters'] = stripslashes(@$options['append_parameters']);
139
+ $arg['append_condition'] = stripslashes(@$options['append_condition']);
140
+ $arg['exclude_users'] = @$options['exclude_users'];
141
+ $arg['count_home'] = @$options['count_home'];
142
+ $arg['count_feed'] = @$options['count_feed'];
143
+ $arg['count_single'] = @$options['count_single'];
144
+ $arg['count_archive'] = @$options['count_archive'];
145
+ $arg['count_category'] = @$options['count_category'];
146
+ $arg['count_page'] = @$options['count_page'];
147
+ $arg['count_search'] = @$options['count_search'];
148
+
149
+ return $arg;
150
+ }
151
+
152
+ function ppl_prepare_template($template) {
153
+ // Now we process the output_template to find the embedded tags which are to be replaced
154
+ // with values taken from the database.
155
+ // A tag is of the form, {tag:ext}, where the tag part will be evaluated and replaced
156
+ // and the optional ext part provides extra data pertinent to that tag
157
+
158
+
159
+ preg_match_all('/{((?:[^{}]|{[^{}]*})*)}/', $template, $matches);
160
+ $translations = array();
161
+ if(is_array($matches)){
162
+
163
+ foreach($matches[1] as $match) {
164
+ if(strpos($match,':')!==false){
165
+ list($tag, $ext) = explode(':', $match, 2);
166
+ } else {
167
+ $tag = $match;
168
+ $ext = false;
169
+ }
170
+ $action = output_tag_action($tag);
171
+ if (function_exists($action)) {
172
+ // store the action that instantiates the tag
173
+ $translations['acts'][] = $action;
174
+ // add the tag in a form ready to use in translation later
175
+ $translations['fulltags'][] = '{'.$match.'}';
176
+ // the extra data if any
177
+ $translations['exts'][] = $ext;
178
+ }
179
+ }
180
+ }
181
+ return $translations;
182
+ }
183
+
184
+ function ppl_expand_template($result, $template, $translations, $option_key) {
185
+ global $wpdb, $wp_version;
186
+ $replacements = array();
187
+
188
+ if(array_key_exists('fulltags',$translations)){
189
+ $numtags = count($translations['fulltags']);
190
+ for ($i = 0; $i < $numtags; $i++) {
191
+ $fulltag = $translations['fulltags'][$i];
192
+ $act = $translations['acts'][$i];
193
+ $ext = $translations['exts'][$i];
194
+ $replacements[$fulltag] = $act($option_key, $result, $ext);
195
+ }
196
+ }
197
+ // Replace every valid tag with its value
198
+ $tmp = strtr($template, $replacements)."\n";
199
+ return $tmp;
200
+ }
201
+
202
+
203
+ function ppl_sort_items($sort, $results, $option_key, $group_template, $items) {
204
+ $translations1 = ppl_prepare_template($sort['by1']);
205
+ foreach ($results as $result) {
206
+ $key1 = ppl_expand_template($result, $sort['by1'], $translations1, $option_key);
207
+ if ($sort['case1'] !== 'false') $key1 = strtolower($key1);
208
+ $keys1[] = $key1;
209
+ }
210
+ if ($sort['by2'] !== '') {
211
+ $translations2 = ppl_prepare_template($sort['by2']);
212
+ foreach ($results as $result) {
213
+ $key2 = ppl_expand_template($result, $sort['by2'], $translations2, $option_key);
214
+ if ($sort['case2'] !== 'false') $key2 = strtolower($key2);
215
+ $keys2[] = $key2;
216
+ }
217
+ }
218
+ if (!empty($keys2)) {
219
+ array_multisort($keys1, intval($sort['order1']), $keys2, intval($sort['order2']), $results, $items);
220
+ } else {
221
+ array_multisort($keys1, intval($sort['order1']), $results, $items);
222
+ }
223
+ // merge the group titles into the items
224
+ if ($group_template) {
225
+ $group_translations = ppl_prepare_template($group_template);
226
+ $prev_key = '';
227
+ $insertions = 0;
228
+ foreach ($keys1 as $n => $key) {
229
+ if ($prev_key !== $key) {
230
+ array_splice($items, $n+$insertions, 0, ppl_expand_template($results[$n], $group_template, $group_translations, $option_key));
231
+ $insertions++;
232
+ }
233
+ $prev_key = $key;
234
+ }
235
+ }
236
+ return $items;
237
+ }
238
+
239
+ // the $post global can be overwritten by the use of $wp_query so we go back to the source
240
+ // note the addition of a 'manual overide' allowing the current posts to me marked by similar_posts_mark_current for example
241
+ function ppl_current_post_id($manual_current_ID = -1) {
242
+ $the_ID = -1;
243
+ if ($manual_current_ID > 0) {
244
+ $the_ID = $manual_current_ID;
245
+ } else if (isset($GLOBALS['wp_the_query'])) {
246
+ $the_ID = $GLOBALS['wp_the_query']->post->ID;
247
+ if (!$the_ID) $the_ID = $GLOBALS['wp_the_query']->posts[0]->ID;
248
+ } else {
249
+ $the_ID = $GLOBALS['post']->ID;
250
+ }
251
+ return $the_ID;
252
+ }
253
+
254
+
255
+ /*
256
+
257
+ Functions to fill in the WHERE part of the workhorse SQL
258
+
259
+ */
260
+
261
+ function where_match_author() {
262
+ $current_author = $GLOBALS['wp_the_query']->post->post_author;
263
+ return "post_author = $current_author";
264
+ }
265
+
266
+ function where_match_tags($match_tags) {
267
+ global $wpdb, $wp_version;
268
+ $args = array('fields' => 'ids');
269
+ $tag_ids = wp_get_object_terms(ppl_current_post_id(), 'post_tag', $args);
270
+ if ( is_array($tag_ids) && count($tag_ids) > 0 ) {
271
+ if ($match_tags === 'any') {
272
+ $ids = get_objects_in_term($tag_ids, 'post_tag');
273
+ } else {
274
+ $ids = array();
275
+ foreach ($tag_ids as $tag_id){
276
+ if (count($ids) > 0) {
277
+ $ids = array_intersect($ids, get_objects_in_term($tag_id, 'post_tag'));
278
+ } else {
279
+ $ids = get_objects_in_term($tag_id, 'post_tag');
280
+ }
281
+ }
282
+ }
283
+ if ( is_array($ids) && count($ids) > 0 ) {
284
+ $ids = array_unique($ids);
285
+ $out_posts = "'" . implode("', '", $ids) . "'";
286
+ $sql = "$wpdb->posts.ID IN ($out_posts)";
287
+ } else {
288
+ $sql = "1 = 2";
289
+ }
290
+ } else {
291
+ $sql = "1 = 2";
292
+ }
293
+ return $sql;
294
+ }
295
+
296
+ function where_show_pages($show_pages, $show_attachments='false') {
297
+ if (function_exists('get_post_type')) {
298
+ $typelist = array();
299
+ if ($show_attachments === 'true') {$typelist[] = "'attachment'";};
300
+ if ($show_pages === 'true') {$typelist[] = "'page'"; $typelist[] = "'post'";}
301
+ else if ($show_pages === 'false') {$typelist[] = "'post'";}
302
+ else if ($show_pages === 'but') {$typelist[] = "'page'";};
303
+ if (count($typelist)===1) {
304
+ $sql = "post_type=$typelist[0]";
305
+ } else {
306
+ $sql = "post_type IN (" . implode(',',$typelist) . ")";
307
+ }
308
+ } else {
309
+ if ($show_pages === 'true') $sql = "post_status IN ('publish', 'static')";
310
+ else if ($show_pages === 'false') $sql = "post_status = 'publish'";
311
+ else if ($show_pages === 'but') $sql = "post_status = 'static'";
312
+ }
313
+ return $sql;
314
+ }
315
+
316
+ function where_show_status($status, $include_inherit='false') {
317
+ $set = array();
318
+ $status = (array) $status;
319
+ // a quick way of allowing for attachments having status=inherit
320
+ if ($include_inherit === 'true') $status['inherit'] = 'true';
321
+ foreach ($status as $name => $state) {
322
+ if ($state === 'true') $set[] = "'$name'";
323
+ }
324
+ if ($set) {
325
+ $result = implode(',', $set);
326
+ return "post_status IN ($result)";
327
+ } else {
328
+ return "1 = 2";
329
+ }
330
+ }
331
+
332
+ // a replacement, for WP < 2.3, ONLY category children
333
+ if (!function_exists('get_term_children')) {
334
+ function get_term_children($term, $taxonomy) {
335
+ if ($taxonomies !== 'category') return array();
336
+ return get_categories('child_of='.$term);
337
+ }
338
+ }
339
+
340
+
341
+ // a replacement, for WP < 2.3, ONLY to get posts with given category IDs
342
+ if (!function_exists('get_objects_in_term')) {
343
+ function get_objects_in_term($terms, $taxonomies) {
344
+ global $wpdb;
345
+ if ($taxonomies !== 'category') return array();
346
+ $terms = "'" . implode("', '", $terms) . "'";
347
+ $object_ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id IN ($terms)");
348
+ if (!$object_ids) return array();
349
+ return $object_ids;
350
+ }
351
+ }
352
+
353
+ function where_match_category() {
354
+ global $wpdb, $wp_version;
355
+ $cat_ids = '';
356
+ foreach(get_the_category() as $cat) {
357
+ if ($cat->cat_ID) $cat_ids .= $cat->cat_ID . ',';
358
+ }
359
+ $cat_ids = rtrim($cat_ids, ',');
360
+ $catarray = explode(',', $cat_ids);
361
+ foreach ( $catarray as $cat ) {
362
+ $catarray = array_merge($catarray, get_term_children($cat, 'category'));
363
+ }
364
+ $catarray = array_unique($catarray);
365
+ $ids = get_objects_in_term($catarray, 'category');
366
+ $ids = array_unique($ids);
367
+ if ( is_array($ids) && count($ids) > 0 ) {
368
+ $out_posts = "'" . implode("', '", $ids) . "'";
369
+ $sql = "$wpdb->posts.ID IN ($out_posts)";
370
+ } else {
371
+ $sql = "1 = 2";
372
+ }
373
+ return $sql;
374
+ }
375
+
376
+ function where_included_cats($included_cats) {
377
+ global $wpdb, $wp_version;
378
+ $catarray = explode(',', $included_cats);
379
+ foreach ( $catarray as $cat ) {
380
+ $catarray = array_merge($catarray, get_term_children($cat, 'category'));
381
+ }
382
+ $catarray = array_unique($catarray);
383
+ $ids = get_objects_in_term($catarray, 'category');
384
+ if ( is_array($ids) && count($ids) > 0 ) {
385
+ $ids = array_unique($ids);
386
+ $in_posts = "'" . implode("', '", $ids) . "'";
387
+ $sql = "ID IN ($in_posts)";
388
+ } else {
389
+ $sql = "1 = 2";
390
+ }
391
+ return $sql;
392
+ }
393
+
394
+ function where_excluded_cats($excluded_cats) {
395
+ global $wpdb, $wp_version;
396
+ $catarray = explode(',', $excluded_cats);
397
+ foreach ( $catarray as $cat ) {
398
+ $catarray = array_merge($catarray, get_term_children($cat, 'category'));
399
+ }
400
+ $catarray = array_unique($catarray);
401
+ $ids = get_objects_in_term($catarray, 'category');
402
+ if ( is_array($ids) && count($ids) > 0 ) {
403
+ $out_posts = "'" . implode("', '", $ids) . "'";
404
+ $sql = "$wpdb->posts.ID NOT IN ($out_posts)";
405
+ } else {
406
+ $sql = "1 = 1";
407
+ }
408
+ return $sql;
409
+ }
410
+
411
+ function where_excluded_authors($excluded_authors){
412
+ return "post_author NOT IN ( $excluded_authors )";
413
+ }
414
+
415
+ function where_included_authors($included_authors){
416
+ return "post_author IN ( $included_authors )";
417
+ }
418
+
419
+ function where_excluded_posts($excluded_posts) {
420
+ return "ID NOT IN ( $excluded_posts )";
421
+ }
422
+
423
+ function where_included_posts($included_posts) {
424
+ return "ID IN ( $included_posts )";
425
+ }
426
+
427
+ function where_tag_str($tag_str) {
428
+ global $wpdb;
429
+ if ( strpos($tag_str, ',') !== false ) {
430
+ $intags = explode(',', $tag_str);
431
+ foreach ( (array) $intags as $tag ) {
432
+ $tags[] = sanitize_term_field('name', $tag, 0, 'post_tag', 'db');
433
+ }
434
+ $tag_type = 'any';
435
+ } else if ( strpos($tag_str, '+') !== false ) {
436
+ $intags = explode('+', $tag_str);
437
+ foreach ( (array) $intags as $tag ) {
438
+ $tags[] = sanitize_term_field('name', $tag, 0, 'post_tag', 'db');
439
+ }
440
+ $tag_type = 'all';
441
+ } else {
442
+ $tags[] = sanitize_term_field('name', $tag_str, 0, 'post_tag', 'db');
443
+ $tag_type = 'any';
444
+ }
445
+ $ids = array();
446
+ if ($tag_type == 'any') {
447
+ foreach ($tags as $tag){
448
+ if (is_term($tag, 'post_tag')) {
449
+ $t = get_term_by('name', $tag, 'post_tag');
450
+ $ids = array_merge($ids, get_objects_in_term($t->term_id, 'post_tag'));
451
+ }
452
+ }
453
+ } else {
454
+ foreach ($tags as $tag){
455
+ if (is_term($tag, 'post_tag')) {
456
+ $t = get_term_by('name', $tag, 'post_tag');
457
+ if (count($ids) > 0) {
458
+ $ids = array_intersect($ids, get_objects_in_term($t->term_id, 'post_tag'));
459
+ } else {
460
+ $ids = get_objects_in_term($t->term_id, 'post_tag');
461
+ }
462
+ }
463
+ }
464
+ }
465
+ if ( is_array($ids) && count($ids) > 0 ) {
466
+ $ids = array_unique($ids);
467
+ $out_posts = "'" . implode("', '", $ids) . "'";
468
+ $sql .= "$wpdb->posts.ID IN ($out_posts)";
469
+ } else $sql .= "1 = 2";
470
+ return $sql;
471
+ }
472
+
473
+ // note the addition of a 'manual overide' allowing the current posts to me marked by similar_posts_mark_current for example
474
+ function where_omit_post($manual_current_ID = -1) {
475
+ $postid = ppl_current_post_id($manual_current_ID);
476
+ if ($postid <= 1) $postid = -1;
477
+ return "ID != $postid";
478
+ }
479
+
480
+ function where_just_post() {
481
+ $postid = ppl_current_post_id();
482
+ if ($postid <= 1) $postid = -1;
483
+ return "ID = $postid";
484
+ }
485
+
486
+ function where_hide_pass() {
487
+ return "post_password =''";
488
+ }
489
+
490
+ function where_hide_future() {
491
+ // from wp 2.1 future posts are taken care of by post status
492
+ $time_difference = get_option('gmt_offset');
493
+ $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
494
+ $sql = "post_date <= '$now'";
495
+ return $sql;
496
+ }
497
+
498
+ function where_fulltext_match($weight_title, $titleterms, $weight_content, $contentterms, $weight_tags, $tagterms) {
499
+ $wsql = array();
500
+ if ($weight_title) $wsql[] = "MATCH (`title`) AGAINST ( \"$titleterms\" )";
501
+ if ($weight_content) $wsql[] = "MATCH (`content`) AGAINST ( \"$contentterms\" )";
502
+ if ($weight_tags) $wsql[] = "MATCH (`tags`) AGAINST ( \"$tagterms\" )";
503
+ return '(' . implode(' OR ', $wsql) . ') ' ;
504
+ }
505
+
506
+ function where_author_comments() {
507
+ $author_email = get_the_author_email();
508
+ return "'$author_email' != comment_author_email";
509
+ }
510
+
511
+ function where_user_comments() {
512
+ return "user_id = 0";
513
+ }
514
+
515
+ function score_fulltext_match($table_name, $weight_title, $titleterms, $weight_content, $contentterms, $weight_tags, $tagterms, $forced_ids='') {
516
+ global $wpdb;
517
+ $wsql = array();
518
+ if ($weight_title) $wsql[] = "(".number_format($weight_title, 4, '.', '')." * (MATCH (`title`) AGAINST ( \"$titleterms\" )))";
519
+ if ($weight_content) $wsql[] = "(".number_format($weight_content, 4, '.', '')." * (MATCH (`content`) AGAINST ( \"$contentterms\" )))";
520
+ if ($weight_tags) $wsql[] = "(".number_format($weight_tags, 4, '.', '')." * (MATCH (`tags`) AGAINST ( \"$tagterms\" )))";
521
+ if ($forced_ids) {
522
+ // apply a delta function to boost the score for certain IDs
523
+ $fIDs = explode(',', $forced_ids);
524
+ foreach($fIDs as $fID) {
525
+ $wsql[] = "100 * (1 - SIGN(ID ^ $fID))"; // the previous delta was $wsql[] = "100*EXP(-10*POW((ID-$fID),2))";
526
+
527
+ }
528
+ }
529
+ return '(' . implode(' + ', $wsql) . " ) as score FROM `$table_name` LEFT JOIN `$wpdb->posts` ON `pID` = `ID` ";
530
+ }
531
+
532
+ function where_comment_type($comment_type) {
533
+ if ($comment_type === 'comments') $sql = "comment_type = ''";
534
+ elseif ($comment_type === 'trackbacks') $sql = "comment_type != ''";
535
+ return $sql;
536
+ }
537
+
538
+ function where_check_age($direction, $length, $duration) {
539
+ global $wp_version;
540
+ if ('none' === $direction) return '';
541
+ $age = "DATE_SUB(CURDATE(), INTERVAL $length $duration)";
542
+ // we only filter out posts based on age, not pages
543
+ if ('before' === $direction) {
544
+ if (function_exists('get_post_type')) {
545
+ return "(post_date <= $age OR post_type='page')";
546
+ } else {
547
+ return "(post_date <= $age OR post_status='static')";
548
+ }
549
+ } else {
550
+ if (function_exists('get_post_type')) {
551
+ return "(post_date >= $age OR post_type='page')";
552
+ } else {
553
+ return "(post_date >= $age OR post_status='static')";
554
+ }
555
+ }
556
+ }
557
+
558
+ function where_check_custom($key, $op, $value) {
559
+ if ($op === 'EXISTS') {
560
+ return "meta_key = '$key'";
561
+ } else {
562
+ return "(meta_key = '$key' && meta_value $op '$value')";
563
+ }
564
+ }
565
+
566
+ /*
567
+
568
+ End of SQL functions
569
+
570
+ */
571
+
572
+ function ppl_microtime() {
573
+ list($usec, $sec) = explode(" ", microtime());
574
+ return ((float)$usec + (float)$sec);
575
+ }
576
+
577
+ /*
578
+
579
+ Some routines to handle appending output
580
+
581
+ */
582
+
583
+ // array of what to append to posts
584
+ global $ppl_filter_data;
585
+ $ppl_filter_data = array();
586
+
587
+ // each plugin calls this on startup to have content scanned for its own tag
588
+ function ppl_register_post_filter($type, $key, $class, $condition='') {
589
+ global $ppl_filter_data;
590
+ $options = get_option($key);
591
+ $priority = $options[$type . '_priority'];
592
+ $parameters = stripslashes($options[$type . '_parameters']);
593
+ $ppl_filter_data [] = array('type' => $type, 'priority' => $priority, 'class' => $class, 'parameters' => $parameters, 'key' => $key, 'condition' => stripslashes($condition));
594
+ // we want them in decreasing priority
595
+ sort($ppl_filter_data);
596
+ }
597
+
598
+ function ppl_post_filter($content) {
599
+ global $ppl_filter_data;
600
+ foreach ($ppl_filter_data as $data) {
601
+ if (('append' === $data['type'] && !is_feed() && eval($data['condition'])) || ('feed' === $data['type'] && is_feed()) ){
602
+ $content .= call_user_func_array(array($data['class'], 'execute'), array($data['parameters'], '<li>{link}</li>', $data['key']));
603
+ }
604
+ }
605
+ return $content;
606
+ }
607
+
608
+ function ppl_post_filter_init() {
609
+ global $ppl_filter_data;
610
+ if (!$ppl_filter_data) return;
611
+ add_filter('the_content', 'ppl_post_filter', 5);
612
+ }
613
+
614
+ // watch out that the registration functions are called earlier
615
+ add_action ('init', 'ppl_post_filter_init');
616
+
617
+ /*
618
+
619
+ Now some routines to handle content filtering
620
+
621
+ */
622
+
623
+ // the '|'-separated list of valid content filter tags
624
+ global $ppl_filter_tags;
625
+
626
+ // each plugin calls this on startup to have content scanned for its own tag
627
+ function ppl_register_content_filter($tag) {
628
+ global $ppl_filter_tags;
629
+ if (!$ppl_filter_tags) {
630
+ $ppl_filter_tags = $tag;
631
+ } else {
632
+ $tags = explode('|', $ppl_filter_tags);
633
+ $tags[] = $tag;
634
+ $tags = array_unique($tags);
635
+ $ppl_filter_tags = implode('|', $tags);
636
+ }
637
+ }
638
+
639
+
640
+ function ppl_do_replace($matches) {
641
+ return call_user_func(array($matches[1], 'execute'), $matches[2]);
642
+ }
643
+
644
+ function ppl_content_filter($content) {
645
+ global $ppl_filter_tags;
646
+ // replaces every instance of "<!--RecentPosts-->", for example, with the output of the plugin
647
+ // the filter tag can be followed by text which will be used as a parameter string to change the behaviour of the plugin
648
+ return preg_replace_callback("/<!--($ppl_filter_tags)\s*(.*)-->/", "ppl_do_replace", $content);
649
+ }
650
+
651
+ function ppl_content_filter_init() {
652
+ global $ppl_filter_tags;
653
+ if (!$ppl_filter_tags) return;
654
+ add_filter( 'the_content', 'ppl_content_filter', 5 );
655
+ add_filter( 'the_content_rss', 'ppl_content_filter', 5 );
656
+ add_filter( 'the_excerpt', 'ppl_content_filter', 5 );
657
+ add_filter( 'the_excerpt_rss', 'ppl_content_filter', 5 );
658
+ add_filter( 'widget_text', 'ppl_content_filter', 5 );
659
+ }
660
+
661
+ // watch out that the registration functions are called earlier
662
+ add_action ('init', 'ppl_content_filter_init');
663
+ add_action ('init', 'ppl_post_filter_init');
css/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // silence is golden
css/similar-posts-admin.css ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Similar Posts
3
+ * (c) Web factory Ltd, 2008 - 2016
4
+ */
5
+
6
+
7
+ .similarposts-tab-content{
8
+ background: #FFFFFF;
9
+ padding: 20px;
10
+ border: 1px solid #dcdcdc;
11
+ margin-top: 0px;
12
+ border-top: none;
13
+ }
14
+
15
+ .similarposts-tabs-menu{
16
+ background: #FFFFFF;
17
+ padding: 20px;
18
+ border: 1px solid #dcdcdc;
19
+ margin: 10px 20px 0 2px;
20
+ border-bottom: 2px solid #0085ba;
21
+ }
22
+
23
+ .similarposts-tabs-menu li a{
24
+ font-size: 16px;
25
+ text-decoration: none;
26
+ padding: 18px 12px;
27
+ font-weight: 500;
28
+ color: #999;
29
+ box-sizing:content-box;
30
+ }
31
+
32
+ .similarposts-tabs-menu li a:hover{
33
+ border:none;
34
+ border-bottom: 4px solid #0085ba;
35
+ color:#23282d;
36
+ }
37
+
38
+ .similarposts-tabs-menu li a:focus{
39
+ outline: none;
40
+ outline-style:none;
41
+ box-shadow:none;
42
+ }
43
+
44
+ .similarposts-tabs-menu li a.current{
45
+ color:#23282d;
46
+ border-bottom: 4px solid #0085ba;
47
+ }
48
+
49
+
50
+
51
+ .similarposts-inner-table{
52
+ border-spacing: 0;
53
+ border-collapse: collapse;
54
+ }
55
+
56
+
57
+ .similarposts-inner-table tr td{
58
+ border:1px solid #CCC;
59
+ }
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // silence is golden
languages/en/stemmer.php CHANGED
@@ -331,5 +331,3 @@ function stem($word) {
331
  }
332
  return $stemmedword;
333
  }
334
-
335
- ?>
331
  }
332
  return $stemmedword;
333
  }
 
 
languages/en/stopwords.php CHANGED
@@ -1,4 +1,3 @@
1
  <?php
2
  // the list of common words we want to ignore. NB anything shorter than 4 characters is knocked by the plugin and doesn't need to figure here
3
  $overusedwords = array("able", "about", "above", "according", "accordingly", "across", "actually", "after", "afterwards", "again", "against", "ain't", "allow", "allows", "almost", "alone", "along", "already", "also", "although", "always", "among", "amongst", "another", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "aren't", "around", "aside", "asking", "associated", "available", "away", "awfully", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "came", "cannot", "can't", "cause", "causes", "certain", "certainly", "changes", "clearly", "come", "comes", "concerning", "conse'uently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn't", "course", "currently", "definitely", "described", "despite", "didn't", "different", "does", "doesn't", "doing", "done", "don't", "down", "downwards", "during", "each", "eight", "either", "else", "elsewhere", "enough", "entirely", "especially", "even", "ever", "every", "everybody", "everyone", "everything", "everywhere", "exactly", "example", "except", "fifth", "first", "five", "followed", "following", "follows", "former", "formerly", "forth", "four", "from", "further", "furthermore", "gets", "getting", "given", "gives", "goes", "going", "gone", "gotten", "greetings", "hadn't", "happens", "hardly", "hasn't", "have", "haven't", "having", "hello", "help", "hence", "here", "hereafter", "hereby", "herein", "hereupon", "he's", "hers", "herself", "himself", "hither", "hopefully", "howbeit", "however", "ignored", "i'll", "it'd", "it's", "i've", "immediate", "inasmuch", "indeed", "indicate", "indicated", "indicates", "inner", "insofar", "instead", "into", "inward", "isn't", "itself", "just", "keep", "keeps", "kept", "know", "known", "knows", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "like", "liked", "likely", "little", "look", "looking", "looks", "mainly", "many", "maybe", "mean", "meanwhile", "merely", "might", "more", "moreover", "most", "mostly", "much", "must", "mustn't", "myself", "name", "namely", "near", "nearly", "necessary", "need", "needs", "neither", "never", "nevertheless", "next", "nine", "nobody", "none", "noone", "normally", "nothing", "novel", "nowhere", "obviously", "often", "okay", "once", "ones", "one's", "only", "onto", "other", "others", "otherwise", "ought", "ours", "ourselves", "outside", "over", "overall", "particular", "particularly", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provides", "'uite", "rather", "really", "reasonably", "regarding", "regardless", "regards", "relatively", "respectively", "right", "said", "same", "saying", "says", "second", "secondly", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "should", "shouldn't", "since", "some", "somebody", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "such", "sure", "take", "taken", "tell", "tends", "than", "thank", "thanks", "that", "that's", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "there's", "thereupon", "these", "they", "think", "third", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "together", "took", "toward", "towards", "tried", "tries", "truly", "trying", "twice", "under", "unfortunately", "unless", "unlikely", "until", "unto", "upon", "used", "useful", "uses", "using", "usually", "value", "various", "very", "want", "wants", "wasn't", "welcome", "we'd", "well", "went", "were", "weren't", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "whoever", "whole", "whom", "whose", "will", "willing", "wish", "with", "within", "without", "wonder", "would", "wouldn't", "your", "yours", "yourself", "yourselves", "zero");
4
- ?>
1
  <?php
2
  // the list of common words we want to ignore. NB anything shorter than 4 characters is knocked by the plugin and doesn't need to figure here
3
  $overusedwords = array("able", "about", "above", "according", "accordingly", "across", "actually", "after", "afterwards", "again", "against", "ain't", "allow", "allows", "almost", "alone", "along", "already", "also", "although", "always", "among", "amongst", "another", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "aren't", "around", "aside", "asking", "associated", "available", "away", "awfully", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "came", "cannot", "can't", "cause", "causes", "certain", "certainly", "changes", "clearly", "come", "comes", "concerning", "conse'uently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn't", "course", "currently", "definitely", "described", "despite", "didn't", "different", "does", "doesn't", "doing", "done", "don't", "down", "downwards", "during", "each", "eight", "either", "else", "elsewhere", "enough", "entirely", "especially", "even", "ever", "every", "everybody", "everyone", "everything", "everywhere", "exactly", "example", "except", "fifth", "first", "five", "followed", "following", "follows", "former", "formerly", "forth", "four", "from", "further", "furthermore", "gets", "getting", "given", "gives", "goes", "going", "gone", "gotten", "greetings", "hadn't", "happens", "hardly", "hasn't", "have", "haven't", "having", "hello", "help", "hence", "here", "hereafter", "hereby", "herein", "hereupon", "he's", "hers", "herself", "himself", "hither", "hopefully", "howbeit", "however", "ignored", "i'll", "it'd", "it's", "i've", "immediate", "inasmuch", "indeed", "indicate", "indicated", "indicates", "inner", "insofar", "instead", "into", "inward", "isn't", "itself", "just", "keep", "keeps", "kept", "know", "known", "knows", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "like", "liked", "likely", "little", "look", "looking", "looks", "mainly", "many", "maybe", "mean", "meanwhile", "merely", "might", "more", "moreover", "most", "mostly", "much", "must", "mustn't", "myself", "name", "namely", "near", "nearly", "necessary", "need", "needs", "neither", "never", "nevertheless", "next", "nine", "nobody", "none", "noone", "normally", "nothing", "novel", "nowhere", "obviously", "often", "okay", "once", "ones", "one's", "only", "onto", "other", "others", "otherwise", "ought", "ours", "ourselves", "outside", "over", "overall", "particular", "particularly", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provides", "'uite", "rather", "really", "reasonably", "regarding", "regardless", "regards", "relatively", "respectively", "right", "said", "same", "saying", "says", "second", "secondly", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "should", "shouldn't", "since", "some", "somebody", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "such", "sure", "take", "taken", "tell", "tends", "than", "thank", "thanks", "that", "that's", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "there's", "thereupon", "these", "they", "think", "third", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "together", "took", "toward", "towards", "tried", "tries", "truly", "trying", "twice", "under", "unfortunately", "unless", "unlikely", "until", "unto", "upon", "used", "useful", "uses", "using", "usually", "value", "various", "very", "want", "wants", "wasn't", "welcome", "we'd", "well", "went", "were", "weren't", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "whoever", "whole", "whom", "whose", "will", "willing", "wish", "with", "within", "without", "wonder", "would", "wouldn't", "your", "yours", "yourself", "yourselves", "zero");
 
languages/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // silence is golden
license.txt ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
output_tags.php ADDED
@@ -0,0 +1,1075 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Similar Posts
4
+ * (c) Web factory Ltd, 2008 - 2016
5
+ */
6
+
7
+ /*
8
+ Library for the Recent Posts, Random Posts, Recent Comments, and Similar Posts plugins
9
+ -- provides the routines which evaluate output template tags
10
+ */
11
+
12
+ define('OT_LIBRARY', true);
13
+
14
+ // Called by the post plugins to match output tags to the actions that evaluate them
15
+ function output_tag_action($tag) {
16
+ return 'otf_'.$tag;
17
+ }
18
+
19
+ /*
20
+ innards
21
+ */
22
+
23
+ // To add a new output template tag all you need to do is write a tag function like those below.
24
+
25
+ // All the tag functions must follow the pattern of 'otf_title' below.
26
+ // the name is the tag name prefixed by 'otf_'
27
+ // the arguments are always $option_key, $result and $ext
28
+ // $option_key the key to the plugin's options
29
+ // $result the particular row of the query result
30
+ // $ext some extra data which a tag may use
31
+ // the return value is the value of the tag as a string
32
+
33
+ function otf_postid ($option_key, $result, $ext) {
34
+ return $result->ID;
35
+ }
36
+
37
+ function otf_title ($option_key, $result, $ext) {
38
+ $value = oth_truncate_text($result->post_title, $ext);
39
+ return apply_filters('the_title', $value);
40
+ }
41
+
42
+ function otf_url($option_key, $result, $ext) {
43
+ $value = apply_filters('the_permalink', get_permalink($result->ID));
44
+ return oth_truncate_text($value, $ext);
45
+ }
46
+
47
+ function otf_author($option_key, $result, $ext) {
48
+ $type = false;
49
+ if ($ext) {
50
+ $s = explode(':', $ext);
51
+ if (count($s) == 1) {
52
+ $type = $s[0];
53
+ }
54
+ }
55
+ switch ($type) {
56
+ case 'display':
57
+ $author = get_the_author_meta('display_name',$result->post_author);
58
+ break;
59
+ case 'full':
60
+ $auth = get_userdata($result->post_author);
61
+ $author = $auth->first_name.' '.$auth->last_name;
62
+ break;
63
+ case 'reverse':
64
+ $auth = get_userdata($result->post_author);
65
+ $author = $auth->last_name.', '.$auth->first_name;
66
+ break;
67
+ case 'first':
68
+ $auth = get_userdata($result->post_author);
69
+ $author = $auth->first_name;
70
+ break;
71
+ case 'last':
72
+ $auth = get_userdata($result->post_author);
73
+ $author = $auth->last_name;
74
+ break;
75
+ default:
76
+ $author = get_the_author_meta('display_name',$result->post_author);
77
+ }
78
+ return $author;
79
+ }
80
+
81
+ function otf_authorurl($option_key, $result, $ext) {
82
+ return get_author_posts_url($result->post_author);
83
+ }
84
+
85
+ function otf_date($option_key, $result, $ext) {
86
+ if ($ext === 'raw') return $result->post_date;
87
+ else return oth_format_date($result->post_date, $ext);
88
+ }
89
+
90
+ function otf_dateedited($option_key, $result, $ext) {
91
+ if ($ext === 'raw') return $result->post_modified;
92
+ else return oth_format_date($result->post_modified, $ext);
93
+ }
94
+
95
+ function otf_time($option_key, $result, $ext) {
96
+ return oth_format_time($result->post_date, $ext);
97
+ }
98
+
99
+ function otf_timeedited($option_key, $result, $ext) {
100
+ return oth_format_time($result->post_modified, $ext);
101
+ }
102
+
103
+ function otf_excerpt($option_key, $result, $ext) {
104
+ if (!$ext) {
105
+ $len = 55;
106
+ $type = 'a';
107
+ } else {
108
+ $s = explode(':', $ext);
109
+ if (count($s) == 1) {
110
+ $s[] = 'a';
111
+ }
112
+ $len = $s[0];
113
+ $type = $s[1];
114
+ if ($type === 'b') {
115
+ if (count($s) > 2) {
116
+ $more = $s[2];
117
+ } else {
118
+ $more = ' &hellip;';
119
+ }
120
+ if (count($s) > 3) {
121
+ if ($s[3] === 'link') {
122
+ $url = otf_url($option_key, $result, '');
123
+ $more = '<a href="'.$url.'">'.$more.'</a>';
124
+ }
125
+ }
126
+ if (count($s) > 4) {
127
+ $numsent = $s[4];
128
+ }
129
+ }
130
+ }
131
+ switch ($type) {
132
+ case 'a':
133
+ $value = trim($result->post_excerpt);
134
+ if ($value == '') $value = $result->post_content;
135
+ $value = oth_trim_excerpt($value, $ext);
136
+ break;
137
+ case 'b':
138
+ $value = trim($result->post_excerpt);
139
+ if ($value === '') {
140
+ $value = $result->post_content;
141
+ $value = convert_smilies($value);
142
+ $value = oth_trim_extract($value, $len, $more, $numsent);
143
+ $value = apply_filters('get_the_content', $value);
144
+ remove_filter('the_content', 'ppl_content_filter', 5);
145
+ remove_filter('the_content', 'ppl_post_filter', 5);
146
+ $value = apply_filters('the_content', $value);
147
+ add_filter('the_content', 'ppl_content_filter', 5);
148
+ add_filter('the_content', 'ppl_post_filter', 5);
149
+
150
+ } else {
151
+ $value = convert_smilies($value);
152
+ $value = apply_filters('get_the_excerpt', $value);
153
+ remove_filter('the_excerpt', 'ppl_content_filter', 5);
154
+ $value = apply_filters('the_excerpt', $value);
155
+ add_filter('the_excerpt', 'ppl_content_filter', 5);
156
+ }
157
+ break;
158
+ default:
159
+ $value = trim($result->post_excerpt);
160
+ if ($value == '') $value = $result->post_content;
161
+ $value = oth_trim_excerpt($value, $len);
162
+ break;
163
+ }
164
+ return $value;
165
+ }
166
+
167
+ function otf_snippet($option_key, $result, $ext) {
168
+ $len = 100;
169
+ $type = 'char';
170
+ $more = '';
171
+ $link = 'nolink';
172
+ if ($ext) {
173
+ $s = explode(':', $ext);
174
+ if ($s[0]) $len = $s[0];
175
+ if ($s[1]) $type = $s[1];
176
+ if ($s[2]) $more = $s[2];
177
+ if ($s[3]) $link = $s[3];
178
+ }
179
+ if ($link === 'link') {
180
+ $url = otf_url($option_key, $result, '');
181
+ $more = '<a href="'.$url.'">'.$more.'</a>';
182
+ }
183
+ return oth_format_snippet($result->post_content, $option_key, $type, $len, $more);
184
+ }
185
+
186
+ function otf_snippetword($option_key, $result, $ext) {
187
+ $len = 100;
188
+ $more = '';
189
+ $link = 'nolink';
190
+ if ($ext) {
191
+ $s = explode(':', $ext);
192
+ if ($s[0]) $len = $s[0];
193
+ if ($s[1]) $more = $s[1];
194
+ if ($s[2]) $link = $s[2];
195
+ }
196
+ if ($link === 'link') {
197
+ $url = otf_url($option_key, $result, '');
198
+ $more = '<a href="'.$url.'">'.$more.'</a>';
199
+ }
200
+ return oth_format_snippet($result->post_content, $option_key, 'word', $len, $more);
201
+ }
202
+
203
+ function otf_fullpost($option_key, $result, $ext) {
204
+ remove_filter( 'the_content', 'ppl_content_filter', 5 );
205
+ remove_filter( 'the_content', 'ppl_post_filter', 5 );
206
+ $value = apply_filters('the_content', $result->post_content);
207
+ add_filter( 'the_content', 'ppl_content_filter', 5 );
208
+ add_filter( 'the_content', 'ppl_post_filter', 5 );
209
+ return str_replace(']]>', ']]&gt;', $value);
210
+ }
211
+
212
+ function otf_commentcount($option_key, $result, $ext) {
213
+ $value = $result->comment_count;
214
+ if ($ext) {
215
+ $s = explode(':', $ext);
216
+ if (count($s) == 3) {
217
+ if ($value == 0) $value = $s[0];
218
+ elseif ($value == 1) $value .= ' ' . $s[1];
219
+ else $value .= ' ' . $s[2];
220
+ }
221
+ }
222
+ return $value;
223
+ }
224
+
225
+ function otf_commentexcerpt($option_key, $result, $ext) {
226
+ if (!$ext) {
227
+ $len = 55;
228
+ $type = 'a';
229
+ } else {
230
+ $s = explode(':', $ext);
231
+ if (count($s) == 1) {
232
+ $s[] = 'a';
233
+ }
234
+ $len = $s[0];
235
+ $type = $s[1];
236
+ if ($type === 'b') {
237
+ if (count($s) > 2) {
238
+ $more = $s[2];
239
+ } else {
240
+ $more = ' &hellip;';
241
+ }
242
+ if (count($s) > 3) {
243
+ if ($s[3] === 'link') {
244
+ $url = otf_commenturl($option_key, $result, '');
245
+ $more = '<a href="'.$url.'">'.$more.'</a>';
246
+ }
247
+ }
248
+ }
249
+ }
250
+ switch ($type) {
251
+ case 'a':
252
+ $value = oth_trim_comment_excerpt($result->comment_content, $ext);
253
+ break;
254
+ case 'b':
255
+ $value = $result->comment_content;
256
+ $value = convert_smilies($value);
257
+
258
+ $text = str_replace(']]>', ']]&gt;', $value);
259
+ if ($len <= count(preg_split('/[\s]+/', strip_tags($text), -1))) {
260
+ // remove html entities for now
261
+ $text = str_replace("\x06", "", $text);
262
+ preg_match_all("/&([a-z\d]{2,7}|#\d{2,5});/i", $text, $ents);
263
+ $text = preg_replace("/&([a-z\d]{2,7}|#\d{2,5});/i", "\x06", $text);
264
+ // now we start counting
265
+ $parts = preg_split('/([\s]+)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
266
+ $in_tag = false;
267
+ $num_words = 0;
268
+ $text = '';
269
+ foreach($parts as $part) {
270
+ if(0 < preg_match('/<[^>]*$/s', $part)) {
271
+ $in_tag = true;
272
+ } else if(0 < preg_match('/>[^<]*$/s', $part)) {
273
+ $in_tag = false;
274
+ }
275
+ if(!$in_tag && '' != trim($part) && substr($part, -1, 1) != '>') {
276
+ $num_words++;
277
+ }
278
+ $text .= $part;
279
+ if($num_words >= $len && !$in_tag) break;
280
+ }
281
+ // put back the missing html entities
282
+ foreach ($ents[0] as $ent) $text = preg_replace("/\x06/", $ent, $text, 1);
283
+ $text = balanceTags($text, true);
284
+ $value = $text . $more;
285
+ }
286
+ $value = apply_filters('get_comment_text', $value);
287
+ break;
288
+ default:
289
+ $value = oth_trim_comment_excerpt($result->comment_content, $ext);
290
+ break;
291
+ }
292
+ return $value;
293
+ }
294
+
295
+ function otf_commentsnippet($option_key, $result, $ext) {
296
+ $len = 100;
297
+ $type = 'char';
298
+ $more = '';
299
+ $link = 'nolink';
300
+ if ($ext) {
301
+ $s = explode(':', $ext);
302
+ if ($s[0]) $len = $s[0];
303
+ if ($s[1]) $type = $s[1];
304
+ if ($s[2]) $more = $s[2];
305
+ if ($s[3]) $link = $s[3];
306
+ }
307
+ if ($link === 'link') {
308
+ $url = otf_commenturl($option_key, $result, '');
309
+ $more = '<a href="'.$url.'">'.$more.'</a>';
310
+ }
311
+ return oth_format_snippet($result->comment_content, $option_key, $type, $len, $more);
312
+ }
313
+
314
+ function otf_commentsnippetword($option_key, $result, $ext) {
315
+ $len = 100;
316
+ $more = '';
317
+ $link = 'nolink';
318
+ if ($ext) {
319
+ $s = explode(':', $ext);
320
+ if ($s[0]) $len = $s[0];
321
+ if ($s[1]) $more = $s[1];
322
+ if ($s[2]) $link = $s[2];
323
+ }
324
+ if ($link === 'link') {
325
+ $url = otf_commenturl($option_key, $result, '');
326
+ $more = '<a href="'.$url.'">'.$more.'</a>';
327
+ }
328
+ return oth_format_snippet($result->comment_content, $option_key, 'word', $len, $more);
329
+ }
330
+
331
+ function otf_commentdate($option_key, $result, $ext) {
332
+ if ($ext === 'raw') return $result->comment_date;
333
+ return oth_format_date($result->comment_date, $ext);
334
+ }
335
+
336
+ function otf_commenttime($option_key, $result, $ext) {
337
+ return oth_format_time($result->comment_date, $ext);
338
+ }
339
+
340
+ function otf_commentdategmt($option_key, $result, $ext) {
341
+ if ($ext === 'raw') return $result->comment_date_gmt;
342
+ return oth_format_date($result->comment_date_gmt, $ext);
343
+ }
344
+
345
+ function otf_commenttimegmt($option_key, $result, $ext) {
346
+ return oth_format_time($result->comment_date_gmt, $ext);
347
+ }
348
+
349
+ function otf_commenter($option_key, $result, $ext) {
350
+ $value = $result->comment_author;
351
+ $value = apply_filters('get_comment_author', $value);
352
+ $value = apply_filters('comment_author', $value);
353
+ return oth_truncate_text($value, $ext);
354
+ }
355
+
356
+ function otf_commenterurl($option_key, $result, $ext) {
357
+ $value = $result->comment_author_url;
358
+ $value = apply_filters('get_comment_author_url', $value);
359
+ return oth_truncate_text($value, $ext);
360
+ }
361
+
362
+ function otf_commenterlink($option_key, $result, $ext) {
363
+ $url = otf_commenterurl($option_key, $result, '');
364
+ $author = otf_commenter($option_key, $result, $ext);
365
+ if (empty($url) || $url == 'http://') $value = $author;
366
+ else $value = "<a href='$url' rel='external nofollow'>$author</a>";
367
+ return $value;
368
+ }
369
+
370
+ function otf_commenterip($option_key, $result, $ext) {
371
+ return $result->comment_author_IP;
372
+ }
373
+
374
+ function otf_commenturl($option_key, $result, $ext) {
375
+ $value = apply_filters('the_permalink', get_permalink($result->ID)) . '#comment-' . $result->comment_ID;
376
+ return oth_truncate_text($value, $ext);
377
+ }
378
+
379
+ function otf_commentlink($option_key, $result, $ext) {
380
+ $ttl = otf_commenter($option_key, $result, '');
381
+ $ttl = '<span class="rc-commenter">' . $ttl . '</span>';
382
+ if (!$ext) $ext = ' commented on ';
383
+ $ttl .= $ext;
384
+ $ttl .= '<span class="rc-title">'.otf_title($option_key, $result, '').'</span>';
385
+ $pml = otf_commenturl($option_key, $result, '');
386
+ $pdt = oth_format_date($result->comment_date_gmt, '');
387
+ $pdt .= __(' at ', 'post_plugin_library');
388
+ $pdt .= oth_format_time($result->comment_date_gmt, '');
389
+ return "<a href=\"$pml\" rel=\"bookmark\" title=\"$pdt\">$ttl</a>";
390
+ }
391
+
392
+ function otf_commentlink2($option_key, $result, $ext) {
393
+ $commenturl = otf_commenturl($option_key, $result, '');
394
+ $commentdate = otf_commentdate($option_key, $result, '');
395
+ $commenttime = otf_commenttime($option_key, $result, '');
396
+ $title = otf_title($option_key, $result, '');
397
+ $commenter = otf_commenter($option_key, $result, '');
398
+ $commentexcerpt = otf_commentexcerpt($option_key, $result, '10');
399
+ return "<a href=\"$commenturl\" rel=\"bookmark\" title=\"$commentdate at $commenttime on '$title'\">$commenter</a> - $commentexcerpt&hellip;";
400
+ }
401
+
402
+ function otf_commentpopupurl($option_key, $result, $ext) {
403
+ global $wpcommentspopupfile, $wpcommentsjavascript;
404
+ $output = '';
405
+ if ( $wpcommentsjavascript ) {
406
+ if ( empty( $wpcommentspopupfile ) )
407
+ $home = get_option('home');
408
+ else
409
+ $home = get_option('siteurl');
410
+ $output .= $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $result->ID;
411
+ $output .= '#comment-' . $result->comment_ID;
412
+ $output .= '" onclick="wpopen(this.href); return false';
413
+ }
414
+ return $output;
415
+ }
416
+
417
+ function otf_catlinks($option_key, $result, $ext) {
418
+ return otf_categorylinks($option_key, $result, $ext);
419
+ }
420
+
421
+ function otf_categorylinks($option_key, $result, $ext) {
422
+ $cats = get_the_category($result->ID);
423
+ $value = ''; $n = 0;
424
+ foreach ($cats as $cat) {
425
+ if ($n > 0) $value .= $ext;
426
+ $catname = apply_filters('single_cat_title', $cat->cat_name);
427
+ $value .= '<a href="' . get_category_link($cat->cat_ID) . '" title="' . sprintf(__("View all posts in %s", 'post_plugin_library'), $catname) . '" rel="category tag">'.$catname.'</a> ';
428
+ ++$n;
429
+ }
430
+ return $value;
431
+ }
432
+
433
+ function otf_catnames($option_key, $result, $ext) {
434
+ return otf_categorynames($option_key, $result, $ext);
435
+ }
436
+
437
+ function otf_categorynames($option_key, $result, $ext) {
438
+ $cats = get_the_category($result->ID);
439
+ $value = ''; $n = 0;
440
+ foreach ($cats as $cat) {
441
+ if ($n > 0) $value .= $ext;
442
+ $value .= apply_filters('single_cat_title', $cat->cat_name);
443
+ ++$n;
444
+ }
445
+ return $value;
446
+ }
447
+
448
+ function otf_custom($option_key, $result, $ext) {
449
+ $custom = get_post_custom($result->ID);
450
+ return $custom[$ext][0];
451
+ }
452
+
453
+ function otf_tags($option_key, $result, $ext) {
454
+ $tags = (array) get_the_tags($result->ID);
455
+ $tag_list = array();
456
+ foreach ( $tags as $tag ) {
457
+ $tag_list[] = $tag->name;
458
+ }
459
+ if (!$ext) $ext = ', ';
460
+ $tag_list = join( $ext, $tag_list );
461
+ return $tag_list;
462
+ }
463
+
464
+ function otf_taglinks($option_key, $result, $ext) {
465
+ $tags = (array) get_the_tags($result->ID);
466
+ $tag_list = '';
467
+ $tag_links = array();
468
+ foreach ( $tags as $tag ) {
469
+ $link = get_tag_link($tag->term_id);
470
+ if ( is_wp_error( $link ) )
471
+ return $link;
472
+ $tag_links[] = '<a href="' . $link . '" rel="tag">' . $tag->name . '</a>';
473
+ }
474
+ if (!$ext) $ext = ' ';
475
+ $tag_links = join( $ext, $tag_links );
476
+ $tag_links = apply_filters( 'the_tags', $tag_links );
477
+ $tag_list .= $tag_links;
478
+ return $tag_list;
479
+ }
480
+
481
+ function otf_totalposts($option_key, $result, $ext) {
482
+ global $wpdb;
483
+ $value = '';
484
+ if (function_exists('get_post_type')) {
485
+ $value = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
486
+ } else {
487
+ $value = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
488
+ }
489
+ return $value;
490
+ }
491
+
492
+ function otf_totalpages($option_key, $result, $ext) {
493
+ global $wpdb;
494
+ $value = '';
495
+ if (function_exists('get_post_type')) {
496
+ $value = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish'");
497
+ } else {
498
+ $value = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'static'");
499
+ }
500
+ return $value;
501
+ }
502
+
503
+ function otf_link($option_key, $result, $ext) {
504
+ $ttl = otf_title($option_key, $result, $ext);
505
+ $pml = otf_url($option_key, $result, null);
506
+ $pdt = otf_date($option_key, $result, null);
507
+ return "<a href=\"$pml\" rel=\"bookmark\" title=\"$pdt\">$ttl</a>";
508
+ }
509
+
510
+ function otf_score($option_key, $result, $ext) {
511
+ return sprintf("%.0f", $result->score);
512
+ }
513
+
514
+ // tries to get the number of post views from a few popular plugins if the are installed
515
+ function otf_postviews($option_key, $result, $ext) {
516
+ global $wpdb;
517
+ // alex king's popularity contest
518
+ if (class_exists('ak_popularity_contest')) $count = $akpc->get_post_total($result->ID);
519
+ // my own post view count
520
+ else if (function_exists('popular_posts_views')) $count = popular_posts_views($result->ID);
521
+ // lester chan's postviews
522
+ else if (function_exists('the_views')) {
523
+ $count = get_post_custom($result->ID);
524
+ $count = intval($count['views'][0]);
525
+ }
526
+ // mark ghosh's top10
527
+ else if (function_exists('show_post_count')) {$id = $result->ID; $count = $wpdb->get_var("select cntaccess from mostAccessed WHERE postnumber = $id");}
528
+ // Ivan Djurdjevac's CountPosts
529
+ else if (function_exists('HitThisPost')) {$id = $result->ID; $count = $wpdb->get_var("SELECT post_hits FROM $wpdb->posts WHERE ID=$id");}
530
+ if (!$count) $count = 0;
531
+ return $count;
532
+ }
533
+
534
+ function oth_get_actual_size($imgtag) {
535
+ // first try extracting the width and height attributes
536
+ if (preg_match('/\s+width\s*=\s*[\'|\"](.*?)[\'|\"]/is', $imgtag, $matches)) {
537
+ $current_width = $matches[1];
538
+ if (preg_match('/\s+height\s*=\s*[\'|\"](.*?)[\'|\"]/is', $imgtag, $matches)) {
539
+ $current_height = $matches[1];
540
+ }
541
+ }
542
+ // then try using the GD library
543
+ if (!(($current_width) && ($current_height))) {
544
+ // extract the image src url
545
+ preg_match('/\s+src\s*=\s*[\'|\"](.*?)[\'|\"]/is', $imgtag, $matches);
546
+ $error_level = error_reporting(0);
547
+ if (function_exists('getimagesize') && $imagesize = getimagesize($matches[1])) {
548
+ $current_width = $imagesize['0'];
549
+ $current_height = $imagesize['1'];
550
+ } else {
551
+ // if all else fails...
552
+ $current_width = $current_height = 0;
553
+ }
554
+ error_reporting($error_level);
555
+ }
556
+ return array($current_width, $current_height);
557
+ }
558
+
559
+ function oth_image_size_full($w, $h, $imgtag){
560
+ return array(1, 1);
561
+ }
562
+
563
+ function oth_image_size_scale($w, $h, $imgtag){
564
+ $maxsize = max($w, $h);
565
+ list($current_width, $current_height) = oth_get_actual_size($imgtag);
566
+ $width_ratio = $height_ratio = 1.0;
567
+ if ($current_width > $maxsize)
568
+ $width_ratio = $maxsize / $current_width;
569
+ if ($current_height > $maxsize)
570
+ $height_ratio = $maxsize / $current_height;
571
+ // the smaller ratio is the one we need to fit it to the constraining box
572
+ $ratio = min( $width_ratio, $height_ratio );
573
+ $w = intval($current_width * $ratio);
574
+ $h = intval($current_height * $ratio);
575
+ return array($w, $h);
576
+ }
577
+
578
+ function oth_image_size_blank($w, $h, $imgtag){
579
+ return array(0, 0);
580
+ }
581
+
582
+ function oth_image_size_exact($w, $h, $imgtag){
583
+ return array($w, $h);
584
+ }
585
+
586
+ function oth_image_size_fixedw($w, $h, $imgtag){
587
+ list($current_width, $current_height) = oth_get_actual_size($imgtag);
588
+ $h = intval($w * ($current_height / $current_width));
589
+ return array($w, $h);
590
+ }
591
+
592
+ function oth_image_size_fixedh($w, $h, $imgtag){
593
+ list($current_width, $current_height) = oth_get_actual_size($imgtag);
594
+ $w = intval($h * ($current_width / $current_height));
595
+ return array($w, $h);
596
+ }
597
+
598
+ function oth_test($x) {
599
+ if (empty($x)) return 'a';
600
+ if (is_numeric($x)) return 'b';
601
+ return 'c';
602
+ }
603
+
604
+ function oth_process($w, $h) {
605
+ static $table = array( 'a' => array('a' => 'full', 'b' => 'scale', 'c' => 'blank'),
606
+ 'b' => array('a' => 'scale', 'b' => 'exact', 'c' => 'fixedw'),
607
+ 'c' => array('a' => 'blank', 'b' => 'fixedh', 'c' => 'blank'));
608
+ return 'oth_image_size_' . $table[oth_test($w)][oth_test($h)];
609
+ }
610
+
611
+ function otf_image($option_key, $result, $ext) {
612
+ // extract any image tags
613
+ $content = $result->post_content;
614
+ if ($ext) {
615
+ $s = explode(':', $ext);
616
+ if ($s[3] === 'post') {
617
+ $content = apply_filters('the_content', $content);
618
+ }
619
+ }
620
+ if ($s[4] === 'link') {
621
+ $pattern = '/<a.+?<img.+?>.+?a>/i';
622
+ $pattern2 = '#(<a.+?<img.+?)(/>|>)#is';
623
+ } else {
624
+ $pattern = '/<img.+?>/i';
625
+ $pattern2 = '#(<img.+?)(/>|>)#is';
626
+ }
627
+ if (!preg_match_all($pattern, $content, $matches)) {
628
+ // no <img> tags in content
629
+ if (($s[5]) && ($s[6])) {
630
+ // a default <img> tag has been given
631
+ return $s[5].':'.$s[6];
632
+ } else {
633
+ return '';
634
+ }
635
+ }
636
+ $i = $s[0];
637
+ if (!$i) $i = 0;
638
+ $imgtag = $matches[0][$i];
639
+ $process = oth_process($s[1],$s[2]);
640
+ list($w, $h) = $process(intval($s[1]), intval($s[2]), $imgtag);
641
+ if ($w === 0) return '';
642
+ if ($w === 1) return $imgtag;
643
+ // remove height or width if present
644
+ $imgtag = preg_replace('/(width|height)\s*=\s*[\'|\"](.*?)[\'|\"]/is', '', $imgtag);
645
+ // insert the new size
646
+ $imgtag = preg_replace($pattern2, "$1 height=\"$h\" width=\"$w\" $2", $imgtag);
647
+ return $imgtag;
648
+ }
649
+
650
+ function otf_imagesrc($option_key, $result, $ext) {
651
+ // extract any image tags
652
+ $content = $result->post_content;
653
+ if ($ext) {
654
+ $s = explode(':', $ext);
655
+ if ($s[1] === 'post') {
656
+ $content = apply_filters('the_content', $content);
657
+ }
658
+ if ($s[2]) $suffix = $s[2];
659
+ }
660
+ $pattern = '/<img.+?src\s*=\s*[\'|\"](.*?)[\'|\"].+?>/i';
661
+ if (!preg_match_all($pattern, $content, $matches)) return '';
662
+ $i = $s[0];
663
+ if (!$i) $i = 0;
664
+ $imgsrc = $matches[1][$i];
665
+ if ($suffix) {
666
+ if ($suffix === '?m') $suffix = '-' . get_option('medium_size_w') . 'x' . get_option('medium_size_h');
667
+ if ($suffix === '?t') $suffix = '-' . get_option('thumbnail_size_w') . 'x' . get_option('thumbnail_size_h');
668
+ $pathinfo = pathinfo($imgsrc);
669
+ $extension = $pathinfo['extension'];
670
+ $imgsrc = str_replace(".$extension", "$suffix.$extension", $imgsrc);
671
+ }
672
+ return $imgsrc;
673
+ }
674
+
675
+ function otf_imagealt($option_key, $result, $ext) {
676
+ // extract any image tags
677
+ $content = $result->post_content;
678
+ if ($ext) {
679
+ $s = explode(':', $ext);
680
+ if ($s[1] === 'post') {
681
+ $content = apply_filters('the_content', $content);
682
+ }
683
+ if ($s[2]) $suffix = $s[2];
684
+ }
685
+ $pattern = '/<img.+?alt\s*=\s*[\'|\"](.*?)[\'|\"].+?>/i';
686
+ if (!preg_match_all($pattern, $content, $matches)) return '';
687
+ $i = $s[0];
688
+ if (!$i) $i = 0;
689
+ return $matches[1][$i];
690
+ }
691
+
692
+ function otf_gravatar($option_key, $result, $ext) {
693
+ $size = 96;
694
+ $rating = '';
695
+ $default = "http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=$size"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
696
+ if ($ext) {
697
+ $s = explode(':', $ext);
698
+ if (isset($s[0])) $size = $s[0];
699
+ if (isset($s[1])) $rating = $s[1];
700
+ if (isset($s[3])) {
701
+ $default = 'http:'.$s[3];
702
+ } else {
703
+ if (isset($s[2])) $default = $s[2];
704
+ }
705
+ }
706
+ $email = '';
707
+ if (isset($result->comment_author_email)) {
708
+ $email = $result->comment_author_email;
709
+ } else {
710
+ $user = get_userdata($result->post_author);
711
+ if ($user) $email = $user->user_email;
712
+ }
713
+ if (!empty($email)) {
714
+ $out = 'http://www.gravatar.com/avatar/';
715
+ $out .= md5(strtolower($email));
716
+ $out .= '?s='.$size;
717
+ $out .= '&amp;d=' . urlencode( $default );
718
+ if ('' !== $rating)
719
+ $out .= "&amp;r={$rating}";
720
+ $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />";
721
+ } else {
722
+ $avatar = "<img alt='' src='{$default}' class='avatar avatar-{$size} avatar-default' height='{$size}' width='{$size}' />";
723
+ }
724
+ return apply_filters('get_avatar', $avatar, $email, $size, $default);
725
+ }
726
+
727
+ // returns the principal category id of a post -- if a cats are hierarchical chooses the most specific -- if multiple cats chooses the first (numerically smallest)
728
+ function otf_categoryid($option_key, $result, $ext) {
729
+ $cats = get_the_category($result->ID);
730
+ foreach ($cats as $cat) {
731
+ $parents[] = $cat->category_parent;
732
+ }
733
+ foreach ($cats as $cat) {
734
+ if (!in_array($cat->cat_ID, $parents)) $categories[] = $cat->cat_ID;
735
+ }
736
+ return $categories[0];
737
+ }
738
+
739
+ // fails if parentheses are out of order or nested
740
+ function oth_splitapart($subject) {
741
+ $bits = explode(':', $subject);
742
+ $inside = false;
743
+ $newbits = array();
744
+ $acc = '';
745
+ foreach ($bits as $bit) {
746
+ if (false !== strpos($bit, '{')) {
747
+ $inside = true;
748
+ $acc = '';
749
+ }
750
+ if (false !== strpos($bit, '}')) {
751
+ $inside = false;
752
+ if ($acc !== '') {
753
+ $acc .= ':' . $bit;
754
+ } else {
755
+ $acc = $bit;
756
+ }
757
+ }
758
+ if ($inside) {
759
+ if ($acc !== '') {
760
+ $acc .= ':' . $bit;
761
+ } else {
762
+ $acc = $bit;
763
+ }
764
+ } else {
765
+ if ($acc !== '') {
766
+ $newbits[] = $acc;
767
+ $acc = '';
768
+ } else {
769
+ $newbits[] = $bit;
770
+ }
771
+ }
772
+ }
773
+ return $newbits;
774
+ }
775
+
776
+ function otf_if($option_key, $result, $ext) {
777
+ global $post;
778
+ $ID = ppl_current_post_id();
779
+ $condition = 'true';
780
+ $true = '';
781
+ $false = '';
782
+ if ($ext) {
783
+ $s = oth_splitapart($ext);
784
+ if (isset($s[0])) $condition = $s[0];
785
+ if (isset($s[1])) $true = $s[1];
786
+ if (isset($s[2])) $false = $s[2];
787
+ }
788
+ if (strpos($condition, '{')!==false) {
789
+ $condition = ppl_expand_template($result, $condition, ppl_prepare_template($condition), $option_key);
790
+ }
791
+ if (eval("return ($condition);")) $tag = $true; else $tag = $false;
792
+ // if the replacement tag contains pseudotags expand them
793
+ if (strpos($tag, '}')!==false) {
794
+ $tag = ppl_expand_template($result, $tag, ppl_prepare_template($tag), $option_key);
795
+ }
796
+ return $tag;
797
+ }
798
+
799
+ function otf_php($option_key, $result, $ext) {
800
+ global $post;
801
+ $ID = ppl_current_post_id();
802
+ $value = '';
803
+ if ($ext) {
804
+ if (strpos($ext, '{')!==false) {
805
+ $ext = ppl_expand_template($result, $ext, ppl_prepare_template($ext), $option_key);
806
+ }
807
+ ob_start();
808
+ eval($ext);
809
+ $value = ob_get_contents();
810
+ ob_end_clean();
811
+ }
812
+ return $value;
813
+ }
814
+
815
+
816
+ // ****************************** Helper Functions *********************************************
817
+
818
+ function oth_truncate_text($text, $ext) {
819
+ if (!$ext) {
820
+ return $text;
821
+ }
822
+ $s = explode(':', $ext);
823
+ if (count($s) > 2) {
824
+ return $text;
825
+ }
826
+ if (count($s) == 1) {
827
+ $s[] = 'wrap';
828
+ }
829
+ $length = $s[0];
830
+ $type = $s[1];
831
+ switch ($type) {
832
+ case 'wrap':
833
+ $length += strlen('<br />');
834
+ if (!function_exists('mb_detect_encoding')) {
835
+ return wordwrap($text, $length, '<br />', true);
836
+ } else {
837
+ $e = mb_detect_encoding($text);
838
+ $formatted = '';
839
+ $position = -1;
840
+ $prev_position = 0;
841
+ $last_line = -1;
842
+ while($position = mb_strpos($text, " ", ++$position, $e)) {
843
+ if($position > $last_line + $length + 1) {
844
+ $formatted.= mb_substr($text, $last_line + 1, $prev_position - $last_line - 1, $e).'<br />';
845
+ $last_line = $prev_position;
846
+ }
847
+ $prev_position = $position;
848
+ }
849
+ $formatted.= mb_substr($text, $last_line + 1, mb_strlen( $text ), $e);
850
+ return $formatted;
851
+ }
852
+ case 'chop':
853
+ if (!function_exists('mb_detect_encoding')) {
854
+ return substr($text, 0, $length);
855
+ } else {
856
+ $e = mb_detect_encoding($text);
857
+ return mb_substr($text, 0, $length, $e);
858
+ }
859
+ case 'trim':
860
+ if (strlen($text) > $length) {
861
+ } else {
862
+ return $text;
863
+ }
864
+ if (!function_exists('mb_detect_encoding')) {
865
+ $textlen = strlen($text);
866
+ if ($textlen > $length) {
867
+ $text = substr($text, 0, $length-2);
868
+ return rtrim($text,".").'&hellip;';
869
+ } else {
870
+ return $text;
871
+ }
872
+ } else {
873
+ $e = mb_detect_encoding($text);
874
+ $textlen = mb_strlen($text, $e);
875
+ if ($textlen > $length) {
876
+ $text = mb_substr($text, 0, $length-2, $e);
877
+ return rtrim($text,".").'&hellip;';
878
+ } else {
879
+ return $text;
880
+ }
881
+ }
882
+ case 'snip':
883
+ if (!function_exists('mb_detect_encoding')) {
884
+ $textlen = strlen($text);
885
+ if ($textlen > $length) {
886
+ $b = floor(($length - 2)/2);
887
+ $l = $textlen - $b - 1;
888
+ return substr($text, 0, $b).'&hellip;'.substr($text, $l);
889
+ } else {
890
+ return $text;
891
+ }
892
+ } else {
893
+ $e = mb_detect_encoding($text);
894
+ $textlen = mb_strlen($text, $e);
895
+ if ($textlen > $length) {
896
+ $b = floor(($length - 2)/2);
897
+ $l = $textlen - $b - 1;
898
+ return mb_substr($text, 0, $b, $e).'&hellip;'.mb_substr($text, $l, 1000, $e);
899
+ } else {
900
+ return $text;
901
+ }
902
+ }
903
+ default:
904
+ return wordwrap($t, $length, '<br />', true);
905
+ }
906
+ }
907
+
908
+ function oth_trim_extract($text, $len, $more, $numsent) {
909
+ $text = str_replace(']]>', ']]&gt;', $text);
910
+ if(strpos($text, '<!--more-->')) {
911
+ $parts = explode('<!--more-->', $text, 2);
912
+ $text = $parts[0];
913
+ } else {
914
+ if ($len > count(preg_split('/[\s]+/', strip_tags($text), -1))) return $text;
915
+ // remove html entities for now
916
+ $text = str_replace("\x06", "", $text);
917
+ preg_match_all("/&([a-z\d]{2,7}|#\d{2,5});/i", $text, $ents);
918
+ $text = preg_replace("/&([a-z\d]{2,7}|#\d{2,5});/i", "\x06", $text);
919
+ // now we start counting
920
+ $parts = preg_split('/([\s]+)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
921
+ $in_tag = false;
922
+ $num_words = 0;
923
+ $sentences = array();
924
+ $words = '';
925
+ foreach($parts as $part) {
926
+ if(0 < preg_match('/<[^>]*$/s', $part)) {
927
+ $in_tag = true;
928
+ } else if(0 < preg_match('/>[^<]*$/s', $part)) {
929
+ $in_tag = false;
930
+ }
931
+ if(!$in_tag && '' != trim($part) && substr($part, -1, 1) != '>') {
932
+ $num_words++;
933
+ }
934
+ if(!$in_tag && '' != trim($part) && false !== strpos('.?!', substr($part, -1, 1))) {
935
+ $sentences [] = $words . $part;
936
+ $words = '';
937
+ } else {
938
+ $words .= $part;
939
+ }
940
+ if($num_words >= $len && !$in_tag) break;
941
+ }
942
+ if (!isset($numsent)) {
943
+ $text = implode('', $sentences) . $words;
944
+ } else {
945
+ $numsent = abs($numsent);
946
+ if ($numsent == 0) {
947
+ $text = implode('', $sentences);
948
+ } else {
949
+ $text = implode('', array_slice($sentences, 0, $numsent));
950
+ }
951
+ }
952
+ // put back the missing html entities
953
+ foreach ($ents[0] as $ent) $text = preg_replace("/\x06/", $ent, $text, 1);
954
+ }
955
+ $text = balanceTags($text, true);
956
+ $text = $text . $more;
957
+ return $text;
958
+ }
959
+
960
+ function oth_format_snippet($content, $option_key, $trim, $len, $more) {
961
+ $content = strip_tags($content);
962
+ $p = get_option($option_key);
963
+ if ($p['stripcodes']) $content = oth_strip_special_tags($content, $p['stripcodes']);
964
+ // strip extra whitespace
965
+ $content = preg_replace('/\s+/u', ' ', $content);
966
+ $content = stripslashes($content);
967
+ if (function_exists('mb_detect_encoding')) $enc = mb_detect_encoding($content);
968
+ // grab a maximum number of characters
969
+ if ($enc) {
970
+ mb_internal_encoding($enc);
971
+ if (mb_strlen($content) >= $len) {
972
+ $snippet = mb_substr($content, 0, $len);
973
+ if ($trim == 'word' && mb_strlen($snippet) == $len) {
974
+ // trim back to the last full word--NB if our snippet ends on a word
975
+ // boundary we still have to trim back to the non-word character
976
+ // (the final 's' in the pattern makes sure we match newlines)
977
+ preg_match('/^(.*)\W/su', $snippet, $matches);
978
+ //if we can't get a single full word we use the full snippet
979
+ // (we use $matches[1] because we don't want the white-space)
980
+ if ($matches[1]) $snippet = $matches[1];
981
+ }
982
+ $snippet .= $more;
983
+ } else {
984
+ $snippet = $content;
985
+ }
986
+ } else {
987
+ if (strlen($content) >= $len) {
988
+ $snippet = substr($content, 0, $len);
989
+ if ($trim == 'word' && strlen($snippet) == $len) {
990
+ // trim back to the last full word--NB if our snippet ends on a word
991
+ // boundary we still have to trim back to the non-word character
992
+ // (the final 's' in the pattern makes sure we match newlines)
993
+ preg_match('/^(.*)\W/s', $snippet, $matches);
994
+ //if we can't get a single full word we use the full snippet
995
+ // (we use $matches[1] because we don't want the white-space)
996
+ if ($matches[1]) $snippet = $matches[1];
997
+ }
998
+ $snippet .= $more;
999
+ } else {
1000
+ $snippet = $content;
1001
+ }
1002
+ }
1003
+ return $snippet;
1004
+ }
1005
+
1006
+ function oth_strip_special_tags($text, $stripcodes) {
1007
+ $numtags = count($stripcodes);
1008
+ for ($i = 0; $i < $numtags; $i++) {
1009
+ if (!$stripcodes[$i]['start'] || !$stripcodes[$i]['end']) return $text;
1010
+ $pattern = '/('. oth_regescape($stripcodes[$i]['start']) . '(.*?)' . oth_regescape($stripcodes[$i]['end']) . ')/i';
1011
+ $text = preg_replace($pattern, '', $text);
1012
+ }
1013
+ return $text;
1014
+ }
1015
+
1016
+ function oth_trim_excerpt($content, $len) {
1017
+ // taken from the wp_trim_excerpt filter
1018
+ remove_filter( 'the_content', 'ppl_content_filter', 5 );
1019
+ remove_filter( 'the_content', 'ppl_post_filter', 5 );
1020
+ $text = apply_filters('the_content', $content);
1021
+ add_filter( 'the_content', 'ppl_content_filter', 5 );
1022
+ add_filter( 'the_content', 'ppl_post_filter', 5 );
1023
+ $text = str_replace(']]>', ']]&gt;', $text);
1024
+ $text = strip_tags($text);
1025
+ if (!$len) $len = 55;
1026
+ $excerpt_length = $len;
1027
+ $words = explode(' ', $text, $excerpt_length + 1);
1028
+ if (count($words) > $excerpt_length) {
1029
+ array_pop($words);
1030
+ $text = implode(' ', $words);
1031
+ }
1032
+ $text = convert_smilies($text);
1033
+ return $text;
1034
+ }
1035
+
1036
+ function oth_trim_comment_excerpt($content, $len) {
1037
+ // adapted from the wp_trim_excerpt filter
1038
+ $text = $content;
1039
+ $text = apply_filters('get_comment_text', $text);
1040
+ $text = str_replace(']]>', ']]&gt;', $text);
1041
+ $text = strip_tags($text);
1042
+ if (!$len) $len = 55;
1043
+ $excerpt_length = $len;
1044
+ $words = explode(' ', $text, $excerpt_length + 1);
1045
+ if (count($words) > $excerpt_length) {
1046
+ array_pop($words);
1047
+ $text = implode(' ', $words);
1048
+ }
1049
+ $text = convert_smilies($text);
1050
+ return $text;
1051
+ }
1052
+
1053
+ function oth_format_date($date, $fmt) {
1054
+ if (!$fmt) $fmt = get_option('date_format');
1055
+ $d = mysql2date($fmt, $date);
1056
+ $d = apply_filters('get_the_time', $d, $fmt);
1057
+ return apply_filters('the_time', $d, $fmt);
1058
+ }
1059
+
1060
+ function oth_format_time($time, $fmt) {
1061
+ if (!$fmt) $fmt = get_option('time_format');
1062
+ $d = mysql2date($fmt, $time);
1063
+ $d = apply_filters('get_the_time', $d, $fmt);
1064
+ return apply_filters('the_time', $d, $fmt);
1065
+ }
1066
+
1067
+ function oth_regescape($s) {
1068
+ $s = str_replace('\\', '\\\\', $s);
1069
+ $s = str_replace('/', '\\/', $s);
1070
+ $s = str_replace('[', '\\[', $s);
1071
+ $s = str_replace(']', '\\]', $s);
1072
+ return $s;
1073
+ }
1074
+
1075
+ ?>
readme.txt CHANGED
@@ -1,35 +1,78 @@
1
- === Similar Posts ===
2
- Contributors: RobMarsh
3
- Donate link: http://rmarsh.com/donate/similar-posts/
4
- Tags: posts, related, similar, related posts, similar posts, tags, post-plugins
5
- Requires at least: 1.5
6
- Tested up to: 2.6.2
7
- Stable tag: 2.6.2.0
8
- Displays a list of posts similar to the current one based on content, title and/or tags.
 
 
 
9
 
10
  == Description ==
11
 
12
- Similar Posts displays a list of posts that are similar or related to the current posts. The list can be customised in *many* ways. Similarity is judged according to a post's title, content, and tags and you can adjust the balance of factors to fit your own blog.
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- This plugin **requires** the latest version of the *Post-Plugin Library:* [download it now](http://downloads.wordpress.org/plugin/post-plugin-library.zip).
15
 
16
  == Installation ==
17
 
18
- 1. IMPORTANT! If you are upgrading from a previous version first deactivate the plugin, then delete the plugin folder from your server.
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- 1. If you have the *Similar Posts Feed* plugin installed you must deactivate it before installing Similar Posts (which now does the same job).
21
 
22
- 1. Upload the plugin folder to your /wp-content/plugins/ folder. If you haven't already you should also install the [Post-Plugin Library](http://wordpress.org/extend/plugins/post-plugin-library/)></a>.
23
 
24
- 1. Go to the **Plugins** page and activate the plugin.
25
 
26
- 1. Put `<?php similar_posts(); ?>` at the place in your template where you want the list of related posts to appear or use the plugin as a widget.
27
 
28
- 1. Use the **Options/Settings** page to adjust the behaviour of the plugin.
29
 
30
- [My web site](http://rmarsh.com/) has [full instructions](http://rmarsh.com/plugins/similar-posts/) and [information on customisation](http://rmarsh.com/plugins/post-options/).
31
 
32
- == Version History ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  * 2.6.2.0
35
  * fixed a problem with the stemming algorithm and overused words
@@ -131,4 +174,11 @@ This plugin **requires** the latest version of the *Post-Plugin Library:* [downl
131
  * 2.5b9
132
  * clarifying installation instructions
133
 
134
- * [previous versions](http://rmarsh.com/plugins/similar-posts/)
 
 
 
 
 
 
 
1
+ === Similar Posts - Powerful Related Posts Plugin ===
2
+ Contributors: WebFactory
3
+ Tags: posts, related, similar, related posts, similar posts, tags, connected posts, navigation, related posts widget, related content, similar content
4
+ License: GPLv2 or later
5
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
+ Requires at least: 4.0
7
+ Tested up to: 4.6
8
+ Stable tag: 2.7
9
+
10
+ Displays a list of related posts similar to the current one based on content, title and/or tags. Works with all themes and is very customizable!
11
+
12
 
13
  == Description ==
14
 
15
+ Similar Posts displays a list of posts that are similar or related to the current posts. The list can be customised in **many ways**. Similarity is judged according to a post's title, content, and tags and you can adjust the balance of factors to fit your own site.
16
+
17
+ **Few Notable Options**
18
+
19
+ * complete control over the display & layout of displayed posts
20
+ * over 30 tags for display template customization
21
+ * matching of current post's category, tags, content and author
22
+ * post excluding by author, ID, category, tags and custom fields
23
+ * output in posts, widgets and RSS
24
+ * over 50 options available
25
+
26
+ [Full list of options and instructions](http://rmarsh.com/plugins/post-options/).
27
+
28
+ Originally developed by [Robert Marsh](http://rmarsh.com/).
29
 
 
30
 
31
  == Installation ==
32
 
33
+ Follow the usual routine;
34
+
35
+ 1. Open WordPress admin, go to Plugins, click Add New
36
+ 2. Enter "Similar Posts" in search and hit Enter
37
+ 3. Plugin will show up as the first on the list, click "Install Now"
38
+ 4. Activate & go to Settings - Similar Posts to configure
39
+
40
+ Or if needed, upload manually;
41
+
42
+ 1. Download the plugin.
43
+ 2. Unzip it and upload to _wp-content/plugin/_
44
+ 3. Open WordPress admin - Plugins and click "Activate" next to the plugin
45
+ 4. Activate & go to Settings - Similar Posts to configure
46
 
 
47
 
48
+ == Frequently Asked Questions ==
49
 
50
+ = Who is this plugin for? =
51
 
52
+ For anyone who want to keep visitors longer on their site by giving them more quality, related content when and where they need it - below the article they're currently reading.
53
 
54
+ = It's not working!!! Arrrrrrrrr =
55
 
56
+ Read the <a href="http://wordpress.org/support/plugin/similar-posts">support forum</a> rules (no seriously, read them) and then if needed open new a thread.
57
 
58
+
59
+ == Screenshots ==
60
+
61
+ 1. General options screen
62
+ 2. Output options screen
63
+ 3. Filter options screen
64
+ 4. Placement options screen
65
+ 5. Miscellaneous options screen
66
+ 6. Index options secreen
67
+
68
+
69
+ == ChangeLog ==
70
+
71
+ * 2.7 - 2016/09/13
72
+ * WebFactory took over development
73
+ * no longer requires any additional plugins
74
+ * fixed all notices and errors
75
+ * fully compatible with the latest version of WP
76
 
77
  * 2.6.2.0
78
  * fixed a problem with the stemming algorithm and overused words
174
  * 2.5b9
175
  * clarifying installation instructions
176
 
177
+
178
+ == Upgrade Notice ==
179
+
180
+ The plugin **no longer requires** the latest version of the Post-Plugin Library.
181
+
182
+ If you are upgrading from a version older than v2.6.2.0 first deactivate the plugin, then delete the plugin folder from your server.
183
+
184
+ If you have the Similar Posts Feed plugin installed you must deactivate it before installing Similar Posts (which now does the same job).
similar-posts-admin.php CHANGED
@@ -1,15 +1,20 @@
1
  <?php
2
-
 
 
 
 
 
3
  // Admin stuff for Similar Posts Plugin, Version 2.6.2.0
4
 
5
  function similar_posts_option_menu() {
6
- add_options_page(__('Similar Posts Options', 'similar_posts'), __('Similar Posts', 'similar_posts'), 8, 'similar-posts', 'similar_posts_options_page');
7
  }
8
 
9
  add_action('admin_menu', 'similar_posts_option_menu', 1);
10
 
11
  function similar_posts_for_feed_option_menu() {
12
- add_options_page(__('Similar Posts Feed Options', 'similar_posts'), __('Similar Posts Feed', 'similar_posts'), 8, 'similar-posts-feed', 'similar_posts_for_feed_options_page');
13
  }
14
 
15
  // this sneaky piece of work lets the similar posts feed menu appear and disappear
@@ -32,25 +37,28 @@ add_action('plugins_loaded', 'juggle_similar_posts_menus');
32
  function similar_posts_options_page(){
33
  echo '<div class="wrap"><h2>';
34
  _e('Similar Posts ', 'similar_posts');
35
- echo '<a href="http://rmarsh.com/plugins/post-options/" style="font-size: 0.8em;">';
36
- _e('help and instructions');
37
- echo '</a></h2></div>';
38
- if (!SimilarPosts::check_post_plugin_library('<h1>'.sprintf(__('Please install the %sPost Plugin Library%s plugin.'), '<a href="http://downloads.wordpress.org/plugin/post-plugin-library.zip">', '</a>').'</h1>')) return;
39
  $m = new admin_subpages();
40
  $m->add_subpage('General', 'general', 'similar_posts_general_options_subpage');
41
  $m->add_subpage('Output', 'output', 'similar_posts_output_options_subpage');
42
  $m->add_subpage('Filter', 'filter', 'similar_posts_filter_options_subpage');
43
  $m->add_subpage('Placement', 'placement', 'similar_posts_placement_options_subpage');
44
- $m->add_subpage('Other', 'other', 'similar_posts_other_options_subpage');
45
  $m->add_subpage('Manage the Index', 'index', 'similar_posts_index_options_subpage');
46
- $m->add_subpage('Report a Bug', 'bug', 'similar_posts_bug_subpage');
47
- $m->add_subpage('Remove this Plugin', 'remove', 'similar_posts_remove_subpage');
48
  $m->display();
 
 
 
 
 
49
  add_action('in_admin_footer', 'similar_posts_admin_footer');
50
  }
51
 
52
  function similar_posts_admin_footer() {
53
  ppl_admin_footer(str_replace('-admin', '', __FILE__), "similar-posts");
 
54
  }
55
 
56
  function similar_posts_general_options_subpage(){
@@ -63,14 +71,14 @@ function similar_posts_general_options_subpage(){
63
  $options = ppl_options_from_post($options, array('limit', 'skip', 'show_private', 'show_pages', 'show_attachments', 'status', 'age', 'omit_current_post', 'match_cat', 'match_tags', 'match_author'));
64
  update_option('similar-posts', $options);
65
  // Show a message to say we've done something
66
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
67
  }
68
  //now we drop into html to display the option page form
69
  ?>
70
- <div class="wrap">
71
- <h2><?php _e('General Settings', 'similar_posts'); ?></h2>
72
  <form method="post" action="">
73
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save General Settings', 'similar_posts') ?>" /></div>
74
  <table class="optiontable form-table">
75
  <?php
76
  ppl_display_limit($options['limit']);
@@ -86,7 +94,7 @@ function similar_posts_general_options_subpage(){
86
  ppl_display_match_author($options['match_author']);
87
  ?>
88
  </table>
89
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save General Settings', 'similar_posts') ?>" /></div>
90
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
91
  </form>
92
  </div>
@@ -103,17 +111,17 @@ function similar_posts_output_options_subpage(){
103
  $options = ppl_options_from_post($options, array('output_template', 'prefix', 'suffix', 'none_text', 'no_text', 'divider', 'sort', 'group_template'));
104
  update_option('similar-posts', $options);
105
  // Show a message to say we've done something
106
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
107
  }
108
  //now we drop into html to display the option page form
109
  ?>
110
- <div class="wrap">
111
- <h2><?php _e('Output Settings', 'similar_posts'); ?></h2>
112
  <form method="post" action="">
113
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Output Settings', 'similar_posts') ?>" /></div>
114
  <table class="optiontable form-table">
115
  <tr>
116
- <td>
117
  <table>
118
  <?php
119
  ppl_display_output_template($options['output_template']);
@@ -131,7 +139,7 @@ function similar_posts_output_options_subpage(){
131
  <?php ppl_display_available_tags('similar-posts'); ?>
132
  </td></tr>
133
  </table>
134
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Output Settings', 'similar_posts') ?>" /></div>
135
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
136
  </form>
137
  </div>
@@ -148,14 +156,14 @@ function similar_posts_filter_options_subpage(){
148
  $options = ppl_options_from_post($options, array('excluded_posts', 'included_posts', 'excluded_authors', 'included_authors', 'excluded_cats', 'included_cats', 'tag_str', 'custom'));
149
  update_option('similar-posts', $options);
150
  // Show a message to say we've done something
151
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
152
  }
153
  //now we drop into html to display the option page form
154
  ?>
155
- <div class="wrap">
156
- <h2><?php _e('Filter Settings', 'similar_posts'); ?></h2>
157
  <form method="post" action="">
158
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Filter Settings', 'similar_posts') ?>" /></div>
159
  <table class="optiontable form-table">
160
  <?php
161
  ppl_display_excluded_posts($options['excluded_posts']);
@@ -166,7 +174,7 @@ function similar_posts_filter_options_subpage(){
166
  ppl_display_custom($options['custom']);
167
  ?>
168
  </table>
169
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Filter Settings', 'similar_posts') ?>" /></div>
170
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
171
  </form>
172
  </div>
@@ -183,14 +191,14 @@ function similar_posts_placement_options_subpage(){
183
  $options = ppl_options_from_post($options, array('content_filter', 'widget_parameters', 'widget_condition', 'feed_on', 'feed_priority', 'feed_parameters', 'append_on', 'append_priority', 'append_parameters', 'append_condition'));
184
  update_option('similar-posts', $options);
185
  // Show a message to say we've done something
186
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
187
  }
188
  //now we drop into html to display the option page form
189
  ?>
190
- <div class="wrap">
191
- <h2><?php _e('Placement Settings', 'similar_posts'); ?></h2>
192
  <form method="post" action="">
193
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Placement Settings', 'similar_posts') ?>" /></div>
194
  <table class="optiontable form-table">
195
  <?php
196
  ppl_display_append($options);
@@ -199,7 +207,7 @@ function similar_posts_placement_options_subpage(){
199
  ppl_display_content_filter($options['content_filter']);
200
  ?>
201
  </table>
202
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Placement Settings', 'similar_posts') ?>" /></div>
203
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
204
  </form>
205
  </div>
@@ -223,14 +231,14 @@ function similar_posts_other_options_subpage(){
223
  $options['weight_tags'] = $wtags / $wcombined;
224
  update_option('similar-posts', $options);
225
  // Show a message to say we've done something
226
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
227
  }
228
  //now we drop into html to display the option page form
229
  ?>
230
- <div class="wrap">
231
- <h2><?php _e('Other Settings', 'similar_posts'); ?></h2>
232
  <form method="post" action="">
233
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Other Settings', 'similar_posts') ?>" /></div>
234
  <table class="optiontable form-table">
235
  <?php
236
  ppl_display_weights($options);
@@ -241,7 +249,7 @@ function similar_posts_other_options_subpage(){
241
  ppl_display_stripcodes($options['stripcodes']);
242
  ?>
243
  </table>
244
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Other Settings', 'similar_posts') ?>" /></div>
245
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
246
  </form>
247
  </div>
@@ -274,9 +282,8 @@ function similar_posts_index_options_subpage(){
274
  $options = get_option('similar-posts');
275
  }
276
  ?>
277
- <div class="wrap">
278
  <?php
279
- echo '<h2>'.__('Manage Index', 'similar_posts').'</h2>';
280
  echo '<p>'.__('Similar Posts maintains a special index to help search for related posts. The index is created when the plugin is activated and then kept up-to-date automatically when posts are added, edited, or deleted.', 'similar_posts').'</p>';
281
  echo '<p>'.__('The options that affect the index can be set below.', 'similar_posts').'</p>';
282
  echo '<p>'.__('If you are using a language other than english you may find that the plugin mangles some characters since PHP is normally blind to multibyte characters. You can force the plugin to interpret extended characters as UTF-8 at the expense of a little speed but this facility is only available if your installation of PHP supports the mbstring functions.', 'similar_posts').'</p>';
@@ -288,7 +295,7 @@ function similar_posts_index_options_subpage(){
288
  <form method="post" action="">
289
  <table class="optiontable form-table">
290
  <tr valign="top">
291
- <th scope="row"><?php _e('Handle extended characters?', 'similar_posts') ?></th>
292
  <td>
293
  <select name="utf8" id="utf8" <?php if (!function_exists('mb_split')) echo 'disabled="true"'; ?> >
294
  <option <?php if($options['utf8'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
@@ -297,7 +304,7 @@ function similar_posts_index_options_subpage(){
297
  </td>
298
  </tr>
299
  <tr valign="top">
300
- <th scope="row"><?php _e('Treat as Chinese, Korean, or Japanese?', 'similar_posts') ?></th>
301
  <td>
302
  <select name="cjk" id="cjk" <?php if (!function_exists('mb_split')) echo 'disabled="true"'; ?> >
303
  <option <?php if($options['cjk'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
@@ -306,7 +313,7 @@ function similar_posts_index_options_subpage(){
306
  </td>
307
  </tr>
308
  <tr valign="top">
309
- <th scope="row"><?php _e('Treat Related Word Variations:', 'similar_posts') ?></th>
310
  <td>
311
  <select name="use_stemmer" id="use_stemmer">
312
  <option <?php if($options['use_stemmer'] == 'false') { echo 'selected="selected"'; } ?> value="false">Strictly</option>
@@ -316,12 +323,12 @@ function similar_posts_index_options_subpage(){
316
  </td>
317
  </tr>
318
  <tr valign="top">
319
- <th scope="row"><?php _e('Batch size:', 'similar_posts') ?></th>
320
- <td><input name="batch" type="text" id="batch" value="<?php echo $options['batch']; ?>" size="3" /></td>
321
  </tr>
322
  </table>
323
  <div class="submit">
324
- <input type="submit" name="reindex_all" value="<?php _e('Recreate Index', 'similar_posts') ?>" />
325
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-manage-update-options'); ?>
326
  </div>
327
  </form>
@@ -330,13 +337,6 @@ function similar_posts_index_options_subpage(){
330
  }
331
 
332
 
333
- function similar_posts_bug_subpage(){
334
- ppl_bug_form('similar-posts');
335
- }
336
-
337
- function similar_posts_remove_subpage(){
338
- ppl_plugin_eradicate_form(str_replace('-admin', '', __FILE__));
339
- }
340
 
341
  function similar_posts_for_feed_options_page(){
342
  echo '<div class="wrap"><h2>';
@@ -349,8 +349,6 @@ function similar_posts_for_feed_options_page(){
349
  $m->add_subpage('Output', 'output', 'similar_posts_feed_output_options_subpage');
350
  $m->add_subpage('Filter', 'filter', 'similar_posts_feed_filter_options_subpage');
351
  $m->add_subpage('Other', 'other', 'similar_posts_feed_other_options_subpage');
352
- $m->add_subpage('Report a Bug', 'bug', 'similar_posts_feed_bug_subpage');
353
- $m->add_subpage('Remove this Plugin', 'remove', 'similar_posts_feed_remove_subpage');
354
  $m->display();
355
  }
356
 
@@ -364,14 +362,14 @@ function similar_posts_feed_general_options_subpage(){
364
  $options = ppl_options_from_post($options, array('limit', 'skip', 'show_private', 'show_pages', 'show_attachments', 'status', 'age', 'omit_current_post', 'match_cat', 'match_tags', 'match_author'));
365
  update_option('similar-posts-feed', $options);
366
  // Show a message to say we've done something
367
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
368
  }
369
  //now we drop into html to display the option page form
370
  ?>
371
- <div class="wrap">
372
  <h2><?php _e('General Settings', 'similar_posts'); ?></h2>
373
  <form method="post" action="">
374
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save General Settings', 'similar_posts') ?>" /></div>
375
  <table class="optiontable form-table">
376
  <?php
377
  ppl_display_limit($options['limit']);
@@ -387,7 +385,7 @@ function similar_posts_feed_general_options_subpage(){
387
  ppl_display_match_author($options['match_author']);
388
  ?>
389
  </table>
390
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save General Settings', 'similar_posts') ?>" /></div>
391
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
392
  </form>
393
  </div>
@@ -404,14 +402,14 @@ function similar_posts_feed_output_options_subpage(){
404
  $options = ppl_options_from_post($options, array('output_template', 'prefix', 'suffix', 'none_text', 'no_text', 'divider', 'sort', 'group_template'));
405
  update_option('similar-posts-feed', $options);
406
  // Show a message to say we've done something
407
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
408
  }
409
  //now we drop into html to display the option page form
410
  ?>
411
- <div class="wrap">
412
  <h2><?php _e('Output Settings', 'similar_posts'); ?></h2>
413
  <form method="post" action="">
414
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Output Settings', 'similar_posts') ?>" /></div>
415
  <table class="optiontable form-table">
416
  <tr>
417
  <td>
@@ -432,7 +430,7 @@ function similar_posts_feed_output_options_subpage(){
432
  <?php ppl_display_available_tags('similar-posts'); ?>
433
  </td></tr>
434
  </table>
435
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Output Settings', 'similar_posts') ?>" /></div>
436
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
437
  </form>
438
  </div>
@@ -449,14 +447,14 @@ function similar_posts_feed_filter_options_subpage(){
449
  $options = ppl_options_from_post($options, array('excluded_posts', 'included_posts', 'excluded_authors', 'included_authors', 'excluded_cats', 'included_cats', 'tag_str', 'custom'));
450
  update_option('similar-posts-feed', $options);
451
  // Show a message to say we've done something
452
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
453
  }
454
  //now we drop into html to display the option page form
455
  ?>
456
- <div class="wrap">
457
  <h2><?php _e('Filter Settings', 'similar_posts'); ?></h2>
458
  <form method="post" action="">
459
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Filter Settings', 'similar_posts') ?>" /></div>
460
  <table class="optiontable form-table">
461
  <?php
462
  ppl_display_excluded_posts($options['excluded_posts']);
@@ -467,7 +465,7 @@ function similar_posts_feed_filter_options_subpage(){
467
  ppl_display_custom($options['custom']);
468
  ?>
469
  </table>
470
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Filter Settings', 'similar_posts') ?>" /></div>
471
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
472
  </form>
473
  </div>
@@ -491,14 +489,14 @@ function similar_posts_feed_other_options_subpage(){
491
  $options['weight_tags'] = $wtags / $wcombined;
492
  update_option('similar-posts-feed', $options);
493
  // Show a message to say we've done something
494
- echo '<div class="updated fade"><p>' . __('Options saved', 'similar_posts') . '</p></div>';
495
  }
496
  //now we drop into html to display the option page form
497
  ?>
498
- <div class="wrap">
499
  <h2><?php _e('Other Settings', 'similar_posts'); ?></h2>
500
  <form method="post" action="">
501
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Other Settings', 'similar_posts') ?>" /></div>
502
  <table class="optiontable form-table">
503
  <?php
504
  ppl_display_weights($options);
@@ -508,27 +506,13 @@ function similar_posts_feed_other_options_subpage(){
508
  ppl_display_stripcodes($options['stripcodes']);
509
  ?>
510
  </table>
511
- <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Other Settings', 'similar_posts') ?>" /></div>
512
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
513
  </form>
514
  </div>
515
  <?php
516
  }
517
 
518
- function similar_posts_feed_bug_subpage(){
519
- ppl_bug_form('similar-posts-feed');
520
- }
521
-
522
- function similar_posts_feed_remove_subpage(){
523
- function eradicate() {
524
- global $wpdb, $table_prefix;
525
- delete_option('similar-posts');
526
- delete_option('similar-posts-feed');
527
- $table_name = $table_prefix . 'similar_posts_feed';
528
- $wpdb->query("DROP TABLE `$table_name`");
529
- }
530
- ppl_plugin_eradicate_form('eradicate', str_replace('-admin', '', __FILE__));
531
- }
532
 
533
  // sets up the index for the blog
534
  function save_index_entries ($utf8=false, $use_stemmer='false', $batch=100, $cjk=false) {
1
  <?php
2
+ /*
3
+ * Similar Posts
4
+ * (c) Web factory Ltd, 2008 - 2016
5
+ */
6
+
7
+
8
  // Admin stuff for Similar Posts Plugin, Version 2.6.2.0
9
 
10
  function similar_posts_option_menu() {
11
+ add_options_page(__('Similar Posts Options', 'similar_posts'), __('Similar Posts', 'similar_posts'), 'edit_theme_options', 'similar-posts', 'similar_posts_options_page');
12
  }
13
 
14
  add_action('admin_menu', 'similar_posts_option_menu', 1);
15
 
16
  function similar_posts_for_feed_option_menu() {
17
+ add_options_page(__('Similar Posts Feed Options', 'similar_posts'), __('Similar Posts Feed', 'similar_posts'), 'edit_theme_options', 'similar-posts-feed', 'similar_posts_for_feed_options_page');
18
  }
19
 
20
  // this sneaky piece of work lets the similar posts feed menu appear and disappear
37
  function similar_posts_options_page(){
38
  echo '<div class="wrap"><h2>';
39
  _e('Similar Posts ', 'similar_posts');
40
+ echo '</h2></div>';
41
+
42
+
 
43
  $m = new admin_subpages();
44
  $m->add_subpage('General', 'general', 'similar_posts_general_options_subpage');
45
  $m->add_subpage('Output', 'output', 'similar_posts_output_options_subpage');
46
  $m->add_subpage('Filter', 'filter', 'similar_posts_filter_options_subpage');
47
  $m->add_subpage('Placement', 'placement', 'similar_posts_placement_options_subpage');
48
+ $m->add_subpage('Misc', 'other', 'similar_posts_other_options_subpage');
49
  $m->add_subpage('Manage the Index', 'index', 'similar_posts_index_options_subpage');
 
 
50
  $m->display();
51
+
52
+ //echo '<div class="wrap"><a target="_blank" href="http://rmarsh.com/plugins/post-options/">';
53
+ //_e('Detailed help &amp; instructions');
54
+ //echo '</a></div>';
55
+
56
  add_action('in_admin_footer', 'similar_posts_admin_footer');
57
  }
58
 
59
  function similar_posts_admin_footer() {
60
  ppl_admin_footer(str_replace('-admin', '', __FILE__), "similar-posts");
61
+
62
  }
63
 
64
  function similar_posts_general_options_subpage(){
71
  $options = ppl_options_from_post($options, array('limit', 'skip', 'show_private', 'show_pages', 'show_attachments', 'status', 'age', 'omit_current_post', 'match_cat', 'match_tags', 'match_author'));
72
  update_option('similar-posts', $options);
73
  // Show a message to say we've done something
74
+ echo '<div class="updated settings-error notice"><p>' . __('<b>Settings saved.</b>', 'similar_posts') . '</p></div>';
75
  }
76
  //now we drop into html to display the option page form
77
  ?>
78
+ <div class="wrap similarposts-tab-content">
79
+
80
  <form method="post" action="">
81
+
82
  <table class="optiontable form-table">
83
  <?php
84
  ppl_display_limit($options['limit']);
94
  ppl_display_match_author($options['match_author']);
95
  ?>
96
  </table>
97
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Settings', 'similar_posts') ?>" /></div>
98
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
99
  </form>
100
  </div>
111
  $options = ppl_options_from_post($options, array('output_template', 'prefix', 'suffix', 'none_text', 'no_text', 'divider', 'sort', 'group_template'));
112
  update_option('similar-posts', $options);
113
  // Show a message to say we've done something
114
+ echo '<div class="updated settings-error notice"><p>' . __('<b>Settings saved.</b>', 'similar_posts') . '</p></div>';
115
  }
116
  //now we drop into html to display the option page form
117
  ?>
118
+ <div class="wrap similarposts-tab-content">
119
+
120
  <form method="post" action="">
121
+
122
  <table class="optiontable form-table">
123
  <tr>
124
+ <td style="padding-top: 0; vertical-align: top;">
125
  <table>
126
  <?php
127
  ppl_display_output_template($options['output_template']);
139
  <?php ppl_display_available_tags('similar-posts'); ?>
140
  </td></tr>
141
  </table>
142
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Settings', 'similar_posts') ?>" /></div>
143
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
144
  </form>
145
  </div>
156
  $options = ppl_options_from_post($options, array('excluded_posts', 'included_posts', 'excluded_authors', 'included_authors', 'excluded_cats', 'included_cats', 'tag_str', 'custom'));
157
  update_option('similar-posts', $options);
158
  // Show a message to say we've done something
159
+ echo '<div class="updated settings-error notice"><p>' . __('<b>Settings saved.</b>', 'similar_posts') . '</p></div>';
160
  }
161
  //now we drop into html to display the option page form
162
  ?>
163
+ <div class="wrap similarposts-tab-content">
164
+
165
  <form method="post" action="">
166
+
167
  <table class="optiontable form-table">
168
  <?php
169
  ppl_display_excluded_posts($options['excluded_posts']);
174
  ppl_display_custom($options['custom']);
175
  ?>
176
  </table>
177
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Settings', 'similar_posts') ?>" /></div>
178
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
179
  </form>
180
  </div>
191
  $options = ppl_options_from_post($options, array('content_filter', 'widget_parameters', 'widget_condition', 'feed_on', 'feed_priority', 'feed_parameters', 'append_on', 'append_priority', 'append_parameters', 'append_condition'));
192
  update_option('similar-posts', $options);
193
  // Show a message to say we've done something
194
+ echo '<div class="updated settings-error notice"><p>' . __('<b>Settings saved.</b>', 'similar_posts') . '</p></div>';
195
  }
196
  //now we drop into html to display the option page form
197
  ?>
198
+ <div class="wrap similarposts-tab-content">
199
+
200
  <form method="post" action="">
201
+
202
  <table class="optiontable form-table">
203
  <?php
204
  ppl_display_append($options);
207
  ppl_display_content_filter($options['content_filter']);
208
  ?>
209
  </table>
210
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Settings', 'similar_posts') ?>" /></div>
211
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
212
  </form>
213
  </div>
231
  $options['weight_tags'] = $wtags / $wcombined;
232
  update_option('similar-posts', $options);
233
  // Show a message to say we've done something
234
+ echo '<div class="updated settings-error notice"><p>' . __('<b>Settings saved.</b>', 'similar_posts') . '</p></div>';
235
  }
236
  //now we drop into html to display the option page form
237
  ?>
238
+ <div class="wrap similarposts-tab-content">
239
+
240
  <form method="post" action="">
241
+
242
  <table class="optiontable form-table">
243
  <?php
244
  ppl_display_weights($options);
249
  ppl_display_stripcodes($options['stripcodes']);
250
  ?>
251
  </table>
252
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Settings', 'similar_posts') ?>" /></div>
253
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-update-options'); ?>
254
  </form>
255
  </div>
282
  $options = get_option('similar-posts');
283
  }
284
  ?>
285
+ <div class="wrap similarposts-tab-content">
286
  <?php
 
287
  echo '<p>'.__('Similar Posts maintains a special index to help search for related posts. The index is created when the plugin is activated and then kept up-to-date automatically when posts are added, edited, or deleted.', 'similar_posts').'</p>';
288
  echo '<p>'.__('The options that affect the index can be set below.', 'similar_posts').'</p>';
289
  echo '<p>'.__('If you are using a language other than english you may find that the plugin mangles some characters since PHP is normally blind to multibyte characters. You can force the plugin to interpret extended characters as UTF-8 at the expense of a little speed but this facility is only available if your installation of PHP supports the mbstring functions.', 'similar_posts').'</p>';
295
  <form method="post" action="">
296
  <table class="optiontable form-table">
297
  <tr valign="top">
298
+ <th scope="row"><label for="utf8"><?php _e('Handle extended characters?', 'similar_posts') ?></label></th>
299
  <td>
300
  <select name="utf8" id="utf8" <?php if (!function_exists('mb_split')) echo 'disabled="true"'; ?> >
301
  <option <?php if($options['utf8'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
304
  </td>
305
  </tr>
306
  <tr valign="top">
307
+ <th scope="row"><label for="cjk"><?php _e('Treat as Chinese, Korean, or Japanese?', 'similar_posts') ?></label></th>
308
  <td>
309
  <select name="cjk" id="cjk" <?php if (!function_exists('mb_split')) echo 'disabled="true"'; ?> >
310
  <option <?php if($options['cjk'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
313
  </td>
314
  </tr>
315
  <tr valign="top">
316
+ <th scope="row"><label for="use_stemmer"><?php _e('Treat Related Word Variations:', 'similar_posts') ?></label></th>
317
  <td>
318
  <select name="use_stemmer" id="use_stemmer">
319
  <option <?php if($options['use_stemmer'] == 'false') { echo 'selected="selected"'; } ?> value="false">Strictly</option>
323
  </td>
324
  </tr>
325
  <tr valign="top">
326
+ <th scope="row"><label for="batch"><?php _e('Batch size:', 'similar_posts') ?></label></th>
327
+ <td><input name="batch" type="number" style="width: 60px;" id="batch" value="<?php echo $options['batch']; ?>" size="3" /></td>
328
  </tr>
329
  </table>
330
  <div class="submit">
331
+ <input type="submit" class="button button-primary" name="reindex_all" value="<?php _e('Recreate Index', 'similar_posts') ?>" />
332
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-manage-update-options'); ?>
333
  </div>
334
  </form>
337
  }
338
 
339
 
 
 
 
 
 
 
 
340
 
341
  function similar_posts_for_feed_options_page(){
342
  echo '<div class="wrap"><h2>';
349
  $m->add_subpage('Output', 'output', 'similar_posts_feed_output_options_subpage');
350
  $m->add_subpage('Filter', 'filter', 'similar_posts_feed_filter_options_subpage');
351
  $m->add_subpage('Other', 'other', 'similar_posts_feed_other_options_subpage');
 
 
352
  $m->display();
353
  }
354
 
362
  $options = ppl_options_from_post($options, array('limit', 'skip', 'show_private', 'show_pages', 'show_attachments', 'status', 'age', 'omit_current_post', 'match_cat', 'match_tags', 'match_author'));
363
  update_option('similar-posts-feed', $options);
364
  // Show a message to say we've done something
365
+ echo '<div class="updated fade similarposts-settings-saved"><p>' . __('Settings saved', 'similar_posts') . '</p></div>';
366
  }
367
  //now we drop into html to display the option page form
368
  ?>
369
+ <div class="wrap similarposts-tab-content">
370
  <h2><?php _e('General Settings', 'similar_posts'); ?></h2>
371
  <form method="post" action="">
372
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save General Settings', 'similar_posts') ?>" /></div>
373
  <table class="optiontable form-table">
374
  <?php
375
  ppl_display_limit($options['limit']);
385
  ppl_display_match_author($options['match_author']);
386
  ?>
387
  </table>
388
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save General Settings', 'similar_posts') ?>" /></div>
389
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
390
  </form>
391
  </div>
402
  $options = ppl_options_from_post($options, array('output_template', 'prefix', 'suffix', 'none_text', 'no_text', 'divider', 'sort', 'group_template'));
403
  update_option('similar-posts-feed', $options);
404
  // Show a message to say we've done something
405
+ echo '<div class="updated fade similarposts-settings-saved"><p>' . __('Settings saved', 'similar_posts') . '</p></div>';
406
  }
407
  //now we drop into html to display the option page form
408
  ?>
409
+ <div class="wrap similarposts-tab-content">
410
  <h2><?php _e('Output Settings', 'similar_posts'); ?></h2>
411
  <form method="post" action="">
412
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Output Settings', 'similar_posts') ?>" /></div>
413
  <table class="optiontable form-table">
414
  <tr>
415
  <td>
430
  <?php ppl_display_available_tags('similar-posts'); ?>
431
  </td></tr>
432
  </table>
433
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Output Settings', 'similar_posts') ?>" /></div>
434
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
435
  </form>
436
  </div>
447
  $options = ppl_options_from_post($options, array('excluded_posts', 'included_posts', 'excluded_authors', 'included_authors', 'excluded_cats', 'included_cats', 'tag_str', 'custom'));
448
  update_option('similar-posts-feed', $options);
449
  // Show a message to say we've done something
450
+ echo '<div class="updated fade similarposts-settings-saved"><p>' . __('Settings saved', 'similar_posts') . '</p></div>';
451
  }
452
  //now we drop into html to display the option page form
453
  ?>
454
+ <div class="wrap similarposts-tab-content">
455
  <h2><?php _e('Filter Settings', 'similar_posts'); ?></h2>
456
  <form method="post" action="">
457
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Filter Settings', 'similar_posts') ?>" /></div>
458
  <table class="optiontable form-table">
459
  <?php
460
  ppl_display_excluded_posts($options['excluded_posts']);
465
  ppl_display_custom($options['custom']);
466
  ?>
467
  </table>
468
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Filter Settings', 'similar_posts') ?>" /></div>
469
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
470
  </form>
471
  </div>
489
  $options['weight_tags'] = $wtags / $wcombined;
490
  update_option('similar-posts-feed', $options);
491
  // Show a message to say we've done something
492
+ echo '<div class="updated fade similarposts-settings-saved"><p>' . __('Settings saved', 'similar_posts') . '</p></div>';
493
  }
494
  //now we drop into html to display the option page form
495
  ?>
496
+ <div class="wrap similarposts-tab-content">
497
  <h2><?php _e('Other Settings', 'similar_posts'); ?></h2>
498
  <form method="post" action="">
499
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Other Settings', 'similar_posts') ?>" /></div>
500
  <table class="optiontable form-table">
501
  <?php
502
  ppl_display_weights($options);
506
  ppl_display_stripcodes($options['stripcodes']);
507
  ?>
508
  </table>
509
+ <div class="submit"><input type="submit" class="button button-primary" name="update_options" value="<?php _e('Save Other Settings', 'similar_posts') ?>" /></div>
510
  <?php if (function_exists('wp_nonce_field')) wp_nonce_field('similar-posts-feed-update-options'); ?>
511
  </form>
512
  </div>
513
  <?php
514
  }
515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
 
517
  // sets up the index for the blog
518
  function save_index_entries ($utf8=false, $use_stemmer='false', $batch=100, $cjk=false) {
similar-posts.php CHANGED
@@ -1,33 +1,33 @@
1
  <?php
2
  /*
3
- Plugin Name:Similar Posts
4
- Plugin URI: http://rmarsh.com/plugins/similar-posts/
5
- Description: Displays a <a href="options-general.php?page=similar-posts.php">highly configurable</a> list of related posts. Similarity can be based on any combination of word usage in the content, title, or tags. Don't be disturbed if it takes a few moments to complete the installation -- the plugin is indexing your posts. <a href="http://rmarsh.com/plugins/post-options/">Instructions and help online</a>. Requires the latest version of the <a href="http://wordpress.org/extend/plugins/post-plugin-library/">Post-Plugin Library</a> to be installed.
6
- Version: 2.6.2.0
7
- Author: Rob Marsh, SJ
8
- Author URI: http://rmarsh.com/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  */
10
 
11
- /*
12
- Copyright 2008 Rob Marsh, SJ (http://rmarsh.com)
13
-
14
- This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License as published by
16
- the Free Software Foundation; either version 2 of the License, or
17
- (at your option) any later version.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details: http://www.gnu.org/licenses/gpl.txt
23
- */
24
-
25
- $similar_posts_version = $similar_posts_feed_version= '2.6.2.0';
26
 
27
  /*
28
  Template Tag: Displays the posts most similar to the current post.
29
  e.g.: <?php similar_posts(); ?>
30
- Full help and instructions at http://rmarsh.com/plugins/post-options/
31
  */
32
 
33
  function similar_posts($args = '') {
@@ -39,12 +39,21 @@ function similar_posts_mark_current(){
39
  $similar_posts_current_ID = $post->ID;
40
  }
41
 
42
- /*
43
 
44
- 'innards'
 
 
 
 
 
 
 
45
 
46
- */
47
-
 
 
48
 
49
  if (!defined('DSEP')) define('DSEP', DIRECTORY_SEPARATOR);
50
  if (!defined('POST_PLUGIN_LIBRARY')) SimilarPosts::install_post_plugin_library();
@@ -52,9 +61,37 @@ if (!defined('POST_PLUGIN_LIBRARY')) SimilarPosts::install_post_plugin_library()
52
  $similar_posts_current_ID = -1;
53
 
54
  class SimilarPosts {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- function execute($args='', $default_output_template='<li>{link}</li>', $option_key='similar-posts'){
57
- if (!SimilarPosts::check_post_plugin_library('<a href="http://downloads.wordpress.org/plugin/post-plugin-library.zip">'.__('Post-Plugin Library missing').'</a>')) return '';
58
  global $table_prefix, $wpdb, $wp_version, $similar_posts_current_ID;
59
  $start_time = ppl_microtime();
60
  $postid = ppl_current_post_id($similar_posts_current_ID);
@@ -109,7 +146,9 @@ class SimilarPosts {
109
  if ($options['hand_links'] === 'true') {
110
  // check custom field for manual links
111
  $forced_ids = $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $postid AND meta_key = 'sp_similar' ") ;
112
- }
 
 
113
  // the workhorse...
114
  $sql = "SELECT *, ";
115
  $sql .= score_fulltext_match($table_name, $weight_title, $titleterms, $weight_content, $contentterms, $weight_tags, $tagterms, $forced_ids);
@@ -169,24 +208,18 @@ class SimilarPosts {
169
  return ($output) ? $output . sprintf("<!-- Similar Posts took %.3f ms -->", 1000 * (ppl_microtime() - $start_time)) : '';
170
  }
171
 
172
- // tries to install the post-plugin-library plugin
173
- function install_post_plugin_library() {
174
- $plugin_path = 'post-plugin-library/post-plugin-library.php';
175
- $current = get_option('active_plugins');
176
- if (!in_array($plugin_path, $current)) {
177
- $current[] = $plugin_path;
178
- update_option('active_plugins', $current);
179
- do_action('activate_'.$plugin_path);
180
- }
181
- }
182
 
183
- function check_post_plugin_library($msg) {
184
- $exists = function_exists('ppl_microtime');
185
- if (!$exists) echo $msg;
186
- return $exists;
187
- }
 
188
 
189
- }
190
 
191
  function sp_terms_by_freq($ID, $num_terms = 20) {
192
  if (!$ID) return array('', '', '');
@@ -199,6 +232,9 @@ function sp_terms_by_freq($ID, $num_terms = 20) {
199
  $n = 0;
200
  $wordtable = array();
201
  while ($word !== false) {
 
 
 
202
  $wordtable[$word] += 1;
203
  $word = strtok(' ');
204
  }
@@ -522,7 +558,7 @@ function widget_rrm_similar_posts_init() {
522
  }
523
  }
524
  function widget_rrm_similar_posts_control() {
525
- if ( $_POST['widget_rrm_similar_posts_submit'] ) {
526
  $options['title'] = strip_tags(stripslashes($_POST['widget_rrm_similar_posts_title']));
527
  $options['number'] = (int) $_POST["widget_rrm_similar_posts_number"];
528
  $options['condition'] = stripslashes(trim($_POST["widget_rrm_similar_posts_condition"], '; '));
@@ -530,20 +566,20 @@ function widget_rrm_similar_posts_init() {
530
  } else {
531
  $options = get_option('widget_rrm_similar_posts');
532
  }
533
- $title = attribute_escape($options['title']);
534
  if ( !$number = (int) $options['number'] )
535
  $number = 5;
536
- $condition = attribute_escape($options['condition']);
537
  ?>
538
  <p><label for="widget_rrm_similar_posts_title"> <?php _e('Title:', 'similar_posts'); ?> <input style="width: 200px;" id="widget_rrm_similar_posts_title" name="widget_rrm_similar_posts_title" type="text" value="<?php echo $title; ?>" /></label></p>
539
- <p><label for="widget_rrm_similar_posts_number"> <?php _e('Number of posts to show:', 'similar_posts'); ?> <input style="width: 25px; text-align: center;" id="widget_rrm_similar_posts_number" name="widget_rrm_similar_posts_number" type="text" value="<?php echo $number; ?>" /></label> <?php _e('(at most 15)', 'similar_posts'); ?> </p>
540
  <p><label for="widget_rrm_similar_posts_condition"> <?php echo sprintf(__('Show only if page: (e.g., %sis_single()%s)', 'similar_posts'), '<a href="http://codex.wordpress.org/Conditional_Tags" title="help">', '</a>'); ?> <input style="width: 200px;" id="widget_rrm_similar_posts_condition" name="widget_rrm_similar_posts_condition" type="text" value="<?php echo $condition; ?>" /></label></p>
541
  <input type="hidden" id="widget_rrm_similar_posts_submit" name="widget_rrm_similar_posts_submit" value="1" />
542
  There are many more <a href="options-general.php?page=similar-posts.php">options</a> available.
543
  <?php
544
  }
545
- register_sidebar_widget(__('Similar Posts +', 'similar_posts'), 'widget_rrm_similar_posts');
546
- register_widget_control(__('Similar Posts +', 'similar_posts'), 'widget_rrm_similar_posts_control', 300, 100);
547
  }
548
 
549
  add_action('plugins_loaded', 'widget_rrm_similar_posts_init');
@@ -554,7 +590,11 @@ add_action('plugins_loaded', 'widget_rrm_similar_posts_init');
554
  */
555
 
556
  //the next lines find the language WordPress is using
557
- $language = substr(WPLANG, 0, 2);
 
 
 
 
558
  //if no language is specified make it the default which is 'en'
559
  if ($language == '') {
560
  $language = 'en';
@@ -568,17 +608,32 @@ if (!file_exists($languagedir)) {
568
  // import the stemming algorithm ... a single function called 'stem'
569
  require_once($languagedir.'stemmer.php');
570
  require_once($languagedir.'stopwords.php');
 
 
571
  global $overusedwords;
572
- $overusedwords = array_flip($overusedwords);
 
 
573
 
574
  // do not try and use this function directly -- it is automatically installed when the option is set to show similar posts in feeds // moreover it is deprecated and going soon
575
  function similar_posts_for_feed($content) {
576
  return (is_feed()) ? $content . SimilarPosts::execute('', '<li>{link}</li>', 'similar-posts-feed') : $content;
577
  }
578
 
 
 
 
 
 
 
 
 
 
579
  function similar_posts_init () {
580
  global $overusedwords, $wp_db_version;
581
  load_plugin_textdomain('similar_posts');
 
 
582
 
583
  $options = get_option('similar-posts');
584
  if ($options['feed_active'] === 'true') add_filter('the_content', 'similar_posts_for_feed');
@@ -600,8 +655,12 @@ function similar_posts_init () {
600
  add_action('edit_post', 'sp_save_index_entry', 1);
601
  add_action('publish_post', 'sp_save_index_entry', 1);
602
  }
603
- }
 
 
 
 
 
604
 
605
  add_action ('init', 'similar_posts_init', 1);
606
-
607
- ?>
1
  <?php
2
  /*
3
+ Plugin Name: Similar Posts
4
+ Plugin URI: https://wordpress.org/plugins/similar-posts/
5
+ Description: Displays a highly configurable list of related posts. Similarity can be based on any combination of word usage in the content, title, or tags.
6
+ Version: 2.7
7
+ Author: Web Factory Ltd
8
+ Author URI: http://www.webfactoryltd.com/
9
+ Text Domain: similar-posts
10
+
11
+ Copyright 2008 - 2016 Web factory Ltd (email : similarposts@webfactoryltd.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License, version 2, as
15
+ published by the Free Software Foundation.
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, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  /*
29
  Template Tag: Displays the posts most similar to the current post.
30
  e.g.: <?php similar_posts(); ?>
 
31
  */
32
 
33
  function similar_posts($args = '') {
39
  $similar_posts_current_ID = $post->ID;
40
  }
41
 
42
+ define ('POST_PLUGIN_LIBRARY', true);
43
 
44
+ if ( ! defined( 'WP_CONTENT_URL' ) )
45
+ define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
46
+ if ( ! defined( 'WP_CONTENT_DIR' ) )
47
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
48
+ if ( ! defined( 'WP_PLUGIN_URL' ) )
49
+ define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
50
+ if ( ! defined( 'WP_PLUGIN_DIR' ) )
51
+ define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
52
 
53
+ if (!defined('CF_LIBRARY')) require(WP_PLUGIN_DIR.'/similar-posts/common_functions.php');
54
+ if (!defined('ACF_LIBRARY')) require(WP_PLUGIN_DIR.'/similar-posts/admin_common_functions.php');
55
+ if (!defined('OT_LIBRARY')) require(WP_PLUGIN_DIR.'/similar-posts/output_tags.php');
56
+ if (!defined('ADMIN_SUBPAGES_LIBRARY')) require(WP_PLUGIN_DIR.'/similar-posts/admin-subpages.php');
57
 
58
  if (!defined('DSEP')) define('DSEP', DIRECTORY_SEPARATOR);
59
  if (!defined('POST_PLUGIN_LIBRARY')) SimilarPosts::install_post_plugin_library();
61
  $similar_posts_current_ID = -1;
62
 
63
  class SimilarPosts {
64
+ static $version = 0;
65
+
66
+ static function get_plugin_version() {
67
+ $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
68
+ SimilarPosts::$version = $plugin_data['version'];
69
+
70
+ return $plugin_data['version'];
71
+ } // get_plugin_version
72
+
73
+ // check if plugin's admin page is shown
74
+ static function is_plugin_admin_page($page = 'settings') {
75
+ $current_screen = get_current_screen();
76
+
77
+ if ($page == 'settings' && $current_screen->id == 'settings_page_similar-posts') {
78
+ return true;
79
+ }
80
+
81
+ return false;
82
+ } // is_plugin_admin_page
83
+
84
+ // add settings link to plugins page
85
+ static function plugin_action_links($links) {
86
+ $settings_link = '<a href="' . admin_url('options-general.php?page=similar-posts') . '" title="Settings for Similar Posts">Settings</a>';
87
+
88
+ array_unshift($links, $settings_link);
89
+
90
+ return $links;
91
+ } // plugin_action_links
92
+
93
 
94
+ static function execute($args='', $default_output_template='<li>{link}</li>', $option_key='similar-posts'){
 
95
  global $table_prefix, $wpdb, $wp_version, $similar_posts_current_ID;
96
  $start_time = ppl_microtime();
97
  $postid = ppl_current_post_id($similar_posts_current_ID);
146
  if ($options['hand_links'] === 'true') {
147
  // check custom field for manual links
148
  $forced_ids = $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $postid AND meta_key = 'sp_similar' ") ;
149
+ } else {
150
+ $forced_ids = '';
151
+ }
152
  // the workhorse...
153
  $sql = "SELECT *, ";
154
  $sql .= score_fulltext_match($table_name, $weight_title, $titleterms, $weight_content, $contentterms, $weight_tags, $tagterms, $forced_ids);
208
  return ($output) ? $output . sprintf("<!-- Similar Posts took %.3f ms -->", 1000 * (ppl_microtime() - $start_time)) : '';
209
  }
210
 
211
+ // save some info
212
+ static function activate() {
213
+ $options = get_option('similar_posts_meta', array());
 
 
 
 
 
 
 
214
 
215
+ if (empty($options['first_version'])) {
216
+ $options['first_version'] = SimilarPosts::get_plugin_version();
217
+ $options['first_install'] = current_time('timestamp');
218
+ update_option('similar_posts_meta', $options);
219
+ }
220
+ } // activate
221
 
222
+ } // similarposts class
223
 
224
  function sp_terms_by_freq($ID, $num_terms = 20) {
225
  if (!$ID) return array('', '', '');
232
  $n = 0;
233
  $wordtable = array();
234
  while ($word !== false) {
235
+ if(!array_key_exists($word,$wordtable)){
236
+ $wordtable[$word]=0;
237
+ }
238
  $wordtable[$word] += 1;
239
  $word = strtok(' ');
240
  }
558
  }
559
  }
560
  function widget_rrm_similar_posts_control() {
561
+ if ( isset($_POST['widget_rrm_similar_posts_submit']) ) {
562
  $options['title'] = strip_tags(stripslashes($_POST['widget_rrm_similar_posts_title']));
563
  $options['number'] = (int) $_POST["widget_rrm_similar_posts_number"];
564
  $options['condition'] = stripslashes(trim($_POST["widget_rrm_similar_posts_condition"], '; '));
566
  } else {
567
  $options = get_option('widget_rrm_similar_posts');
568
  }
569
+ $title = esc_attr($options['title']);
570
  if ( !$number = (int) $options['number'] )
571
  $number = 5;
572
+ $condition = esc_attr($options['condition']);
573
  ?>
574
  <p><label for="widget_rrm_similar_posts_title"> <?php _e('Title:', 'similar_posts'); ?> <input style="width: 200px;" id="widget_rrm_similar_posts_title" name="widget_rrm_similar_posts_title" type="text" value="<?php echo $title; ?>" /></label></p>
575
+ <p><label for="widget_rrm_similar_posts_number"> <?php _e('Number of posts to show:', 'similar_posts'); ?> <input style="width: 50px; text-align: center;" id="widget_rrm_similar_posts_number" name="widget_rrm_similar_posts_number" type="number" value="<?php echo $number; ?>" /></label> <?php _e('(at most 15)', 'similar_posts'); ?> </p>
576
  <p><label for="widget_rrm_similar_posts_condition"> <?php echo sprintf(__('Show only if page: (e.g., %sis_single()%s)', 'similar_posts'), '<a href="http://codex.wordpress.org/Conditional_Tags" title="help">', '</a>'); ?> <input style="width: 200px;" id="widget_rrm_similar_posts_condition" name="widget_rrm_similar_posts_condition" type="text" value="<?php echo $condition; ?>" /></label></p>
577
  <input type="hidden" id="widget_rrm_similar_posts_submit" name="widget_rrm_similar_posts_submit" value="1" />
578
  There are many more <a href="options-general.php?page=similar-posts.php">options</a> available.
579
  <?php
580
  }
581
+ wp_register_sidebar_widget('similar_posts_widget', __('Similar Posts', 'similar_posts'), 'widget_rrm_similar_posts');
582
+ wp_register_widget_control('similar_posts_widget', __('Similar Posts', 'similar_posts'), 'widget_rrm_similar_posts_control', 300, 100);
583
  }
584
 
585
  add_action('plugins_loaded', 'widget_rrm_similar_posts_init');
590
  */
591
 
592
  //the next lines find the language WordPress is using
593
+ if(defined('WPLANG')){
594
+ $language = substr(WPLANG, 0, 2);
595
+ } else {
596
+ $language = '';
597
+ }
598
  //if no language is specified make it the default which is 'en'
599
  if ($language == '') {
600
  $language = 'en';
608
  // import the stemming algorithm ... a single function called 'stem'
609
  require_once($languagedir.'stemmer.php');
610
  require_once($languagedir.'stopwords.php');
611
+
612
+
613
  global $overusedwords;
614
+ if(is_array($overusedwords)) {
615
+ $overusedwords = array_flip($overusedwords);
616
+ }
617
 
618
  // do not try and use this function directly -- it is automatically installed when the option is set to show similar posts in feeds // moreover it is deprecated and going soon
619
  function similar_posts_for_feed($content) {
620
  return (is_feed()) ? $content . SimilarPosts::execute('', '<li>{link}</li>', 'similar-posts-feed') : $content;
621
  }
622
 
623
+ function similar_posts_wp_admin_style() {
624
+ if (SimilarPosts::is_plugin_admin_page('settings')) {
625
+ wp_register_style( 'similar-posts-admin', plugins_url('', __FILE__) . '/css/similar-posts-admin.css', false, SimilarPosts::$version );
626
+ wp_enqueue_style( 'similar-posts-admin' );
627
+ }
628
+ }
629
+
630
+
631
+
632
  function similar_posts_init () {
633
  global $overusedwords, $wp_db_version;
634
  load_plugin_textdomain('similar_posts');
635
+
636
+ SimilarPosts::get_plugin_version();
637
 
638
  $options = get_option('similar-posts');
639
  if ($options['feed_active'] === 'true') add_filter('the_content', 'similar_posts_for_feed');
655
  add_action('edit_post', 'sp_save_index_entry', 1);
656
  add_action('publish_post', 'sp_save_index_entry', 1);
657
  }
658
+ add_action( 'admin_enqueue_scripts', 'similar_posts_wp_admin_style' );
659
+
660
+ // aditional links in plugin description
661
+ add_filter('plugin_action_links_' . basename(dirname(__FILE__)) . '/' . basename(__FILE__),
662
+ array('SimilarPosts', 'plugin_action_links'));
663
+ } // init
664
 
665
  add_action ('init', 'similar_posts_init', 1);
666
+ register_activation_hook(__FILE__, array('SimilarPosts', 'activate'));
 
similar-posts.pot DELETED
@@ -1,248 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR Rob Marsh, SJ
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/similar-posts\n"
11
- "POT-Creation-Date: 2008-09-09 13:52+0000\n"
12
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "MIME-Version: 1.0\n"
16
- "Content-Type: text/plain; charset=CHARSET\n"
17
- "Content-Transfer-Encoding: 8bit\n"
18
-
19
- #: similar-posts-admin.php:6
20
- msgid "Similar Posts Options"
21
- msgstr ""
22
-
23
- #: similar-posts-admin.php:6 similar-posts-admin.php:645
24
- #: similar-posts-admin.php:648 similar-posts.php:506
25
- msgid "Similar Posts"
26
- msgstr ""
27
-
28
- #: similar-posts-admin.php:12
29
- msgid "Similar Posts Feed Options"
30
- msgstr ""
31
-
32
- #: similar-posts-admin.php:12
33
- msgid "Similar Posts Feed"
34
- msgstr ""
35
-
36
- #: similar-posts-admin.php:34
37
- msgid "Similar Posts "
38
- msgstr ""
39
-
40
- #: similar-posts-admin.php:36 similar-posts-admin.php:345
41
- msgid "help and instructions"
42
- msgstr ""
43
-
44
- #: similar-posts-admin.php:38
45
- #, php-format
46
- msgid "Please install the %sPost Plugin Library%s plugin."
47
- msgstr ""
48
-
49
- #: similar-posts-admin.php:66 similar-posts-admin.php:106
50
- #: similar-posts-admin.php:151 similar-posts-admin.php:186
51
- #: similar-posts-admin.php:226 similar-posts-admin.php:367
52
- #: similar-posts-admin.php:407 similar-posts-admin.php:452
53
- #: similar-posts-admin.php:494
54
- msgid "Options saved"
55
- msgstr ""
56
-
57
- #: similar-posts-admin.php:71 similar-posts-admin.php:372
58
- msgid "General Settings"
59
- msgstr ""
60
-
61
- #: similar-posts-admin.php:73 similar-posts-admin.php:89
62
- #: similar-posts-admin.php:374 similar-posts-admin.php:390
63
- msgid "Save General Settings"
64
- msgstr ""
65
-
66
- #: similar-posts-admin.php:111 similar-posts-admin.php:412
67
- msgid "Output Settings"
68
- msgstr ""
69
-
70
- #: similar-posts-admin.php:113 similar-posts-admin.php:134
71
- #: similar-posts-admin.php:414 similar-posts-admin.php:435
72
- msgid "Save Output Settings"
73
- msgstr ""
74
-
75
- #: similar-posts-admin.php:156 similar-posts-admin.php:457
76
- msgid "Filter Settings"
77
- msgstr ""
78
-
79
- #: similar-posts-admin.php:158 similar-posts-admin.php:169
80
- #: similar-posts-admin.php:459 similar-posts-admin.php:470
81
- msgid "Save Filter Settings"
82
- msgstr ""
83
-
84
- #: similar-posts-admin.php:191
85
- msgid "Placement Settings"
86
- msgstr ""
87
-
88
- #: similar-posts-admin.php:193 similar-posts-admin.php:202
89
- msgid "Save Placement Settings"
90
- msgstr ""
91
-
92
- #: similar-posts-admin.php:231 similar-posts-admin.php:499
93
- msgid "Other Settings"
94
- msgstr ""
95
-
96
- #: similar-posts-admin.php:233 similar-posts-admin.php:244
97
- #: similar-posts-admin.php:501 similar-posts-admin.php:511
98
- msgid "Save Other Settings"
99
- msgstr ""
100
-
101
- #: similar-posts-admin.php:272
102
- #, php-format
103
- msgid "Indexed %d posts."
104
- msgstr ""
105
-
106
- #: similar-posts-admin.php:279
107
- msgid "Manage Index"
108
- msgstr ""
109
-
110
- #: similar-posts-admin.php:280
111
- msgid ""
112
- "Similar Posts maintains a special index to help search for related posts. "
113
- "The index is created when the plugin is activated and then kept up-to-date "
114
- "automatically when posts are added, edited, or deleted."
115
- msgstr ""
116
-
117
- #: similar-posts-admin.php:281
118
- msgid "The options that affect the index can be set below."
119
- msgstr ""
120
-
121
- #: similar-posts-admin.php:282
122
- msgid ""
123
- "If you are using a language other than english you may find that the plugin "
124
- "mangles some characters since PHP is normally blind to multibyte characters. "
125
- "You \tcan force the plugin to interpret extended characters as UTF-8 at the "
126
- "expense of a little speed but this facility is only available if your "
127
- "installation of PHP supports the mbstring functions."
128
- msgstr ""
129
-
130
- #: similar-posts-admin.php:283
131
- msgid ""
132
- "Languages like Chinese, Korean and Japanese pose a special difficulty for "
133
- "the full-text search algorithm. As an experiment I have introduced an option "
134
- "below to work around some of these issues. The text must be encoded as UTF-"
135
- "8. I would be very grateful for feedback from any users knowledgeable in "
136
- "these languages."
137
- msgstr ""
138
-
139
- #: similar-posts-admin.php:284
140
- msgid ""
141
- "Some related word forms should really be counted together, e.g., \"follow\", "
142
- "\"follows\", and \"following\". By default, Similar Posts treats such "
143
- "differences strictly but has two other algorithms which are more relaxed: "
144
- "<em>stemming</em> and <em>fuzzy matching</em>. The stemming algorithm tries "
145
- "to reduce related forms to their root stem. Stemming algorithms are provided "
146
- "for english, german, spanish, french and italian but stemmers for other "
147
- "languages can be created: see the help for instructions. Fuzzy matching uses "
148
- "the \"metaphone\" algorithm to handle word variations. Note: both stemming "
149
- "and fuzzy matching slow down the indexing more than a little. It is worth "
150
- "experimenting with the three possibilities to see what improves the "
151
- "similarity of posts in your particular circumstances."
152
- msgstr ""
153
-
154
- #: similar-posts-admin.php:285
155
- msgid ""
156
- "The indexing routine processes posts in batches of 100 by default. If you "
157
- "run into problems with limited memory you can opt to make the batches "
158
- "smaller."
159
- msgstr ""
160
-
161
- #: similar-posts-admin.php:286
162
- msgid ""
163
- "Note: the process of indexing may take a little while. On my modest machine "
164
- "500 posts take between 5 seconds and 20 seconds (with stemming and utf-8 "
165
- "support). Don't worry if the screen fails to update until finished."
166
- msgstr ""
167
-
168
- #: similar-posts-admin.php:291
169
- msgid "Handle extended characters?"
170
- msgstr ""
171
-
172
- #: similar-posts-admin.php:300
173
- msgid "Treat as Chinese, Korean, or Japanese?"
174
- msgstr ""
175
-
176
- #: similar-posts-admin.php:309
177
- msgid "Treat Related Word Variations:"
178
- msgstr ""
179
-
180
- #: similar-posts-admin.php:319
181
- msgid "Batch size:"
182
- msgstr ""
183
-
184
- #: similar-posts-admin.php:324
185
- msgid "Recreate Index"
186
- msgstr ""
187
-
188
- #: similar-posts-admin.php:343
189
- msgid "Similar Posts Feed "
190
- msgstr ""
191
-
192
- #: similar-posts-admin.php:604 similar-posts-admin.php:660
193
- msgid "None Found"
194
- msgstr ""
195
-
196
- #: similar-posts.php:57
197
- msgid "Post-Plugin Library missing"
198
- msgstr ""
199
-
200
- #: similar-posts.php:538
201
- msgid "Title:"
202
- msgstr ""
203
-
204
- #: similar-posts.php:539
205
- msgid "Number of posts to show:"
206
- msgstr ""
207
-
208
- #: similar-posts.php:539
209
- msgid "(at most 15)"
210
- msgstr ""
211
-
212
- #: similar-posts.php:540
213
- #, php-format
214
- msgid "Show only if page: (e.g., %sis_single()%s)"
215
- msgstr ""
216
-
217
- #: similar-posts.php:545 similar-posts.php:546
218
- msgid "Similar Posts +"
219
- msgstr ""
220
-
221
- #. Plugin Name of an extension
222
- msgid "Similar Posts"
223
- msgstr ""
224
-
225
- #. Plugin URI of an extension
226
- msgid "http://rmarsh.com/plugins/similar-posts/"
227
- msgstr ""
228
-
229
- #. Description of an extension
230
- msgid ""
231
- "Displays a <a href=\"options-general.php?page=similar-posts.php\">highly "
232
- "configurable</a> list of related posts. Similarity can be based on any "
233
- "combination of word usage in the content, title, or tags. Don't be disturbed "
234
- "if it takes a few moments to complete the installation -- the plugin is "
235
- "indexing your posts. <a "
236
- "href=\"http://rmarsh.com/plugins/post-options/\">Instructions and help "
237
- "online</a>. Requires the latest version of the <a "
238
- "href=\"http://wordpress.org/extend/plugins/post-plugin-library/\">Post-Plugin "
239
- "Library</a> to be installed."
240
- msgstr ""
241
-
242
- #. Author of an extension
243
- msgid "Rob Marsh, SJ"
244
- msgstr ""
245
-
246
- #. Author URI of an extension
247
- msgid "http://rmarsh.com/"
248
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uninstall.php CHANGED
@@ -1,11 +1,17 @@
1
  <?php
2
- if (defined('ABSPATH') && defined('WP_UNINSTALL_PLUGIN')
3
- && strtolower(WP_UNINSTALL_PLUGIN) === 'similar-posts/similar-posts.php') {
 
 
 
 
 
4
  global $wpdb, $table_prefix;
 
5
  delete_option('similar-posts');
6
  delete_option('similar-posts-feed');
7
  delete_option('widget_rrm_similar_posts');
8
- $table_name = $table_prefix . 'similar_posts';
 
9
  $wpdb->query("DROP TABLE `$table_name`");
10
  }
11
- ?>
1
  <?php
2
+ /*
3
+ * Similar Posts
4
+ * (c) Web factory Ltd, 2008 - 2016
5
+ */
6
+
7
+
8
+ if (defined('ABSPATH') && defined('WP_UNINSTALL_PLUGIN')) {
9
  global $wpdb, $table_prefix;
10
+
11
  delete_option('similar-posts');
12
  delete_option('similar-posts-feed');
13
  delete_option('widget_rrm_similar_posts');
14
+
15
+ $table_name = $table_prefix . 'similar_posts';
16
  $wpdb->query("DROP TABLE `$table_name`");
17
  }