Version Description
Download this release
Release Info
Developer | mitchoyoshitaka |
Plugin | Yet Another Related Posts Plugin (YARPP) |
Version | 3.0b4 |
Comparing to | |
See all releases |
Code changes from version 3.0b3 to 3.0b4
yarpp-templates/template-example.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php /*
|
2 |
Example template
|
3 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
4 |
-
*/
|
5 |
-
|
6 |
<?php if ($related_query->have_posts()):?>
|
7 |
<ol>
|
8 |
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
|
1 |
<?php /*
|
2 |
Example template
|
3 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
4 |
+
*/
|
5 |
+
?><h3>Related Posts</h3>
|
6 |
<?php if ($related_query->have_posts()):?>
|
7 |
<ol>
|
8 |
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
|
yarpp-templates/template-list.php
CHANGED
@@ -2,17 +2,18 @@
|
|
2 |
List template
|
3 |
This template returns the related posts as a comma-separated list.
|
4 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
5 |
-
*/
|
6 |
-
|
7 |
|
8 |
<?php if ($related_query->have_posts()):
|
9 |
$postsArray = array();
|
10 |
while ($related_query->have_posts()) : $related_query->the_post();
|
11 |
-
$postsArray[] = '<
|
12 |
endwhile;
|
13 |
|
14 |
-
echo implode(', ',$postsArray); // print out a list of the related items, separated by commas
|
|
|
|
|
15 |
|
16 |
-
else:
|
17 |
<p>No related posts.</p>
|
18 |
<?php endif; ?>
|
2 |
List template
|
3 |
This template returns the related posts as a comma-separated list.
|
4 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
5 |
+
*/
|
6 |
+
?><h3>Related Posts</h3>
|
7 |
|
8 |
<?php if ($related_query->have_posts()):
|
9 |
$postsArray = array();
|
10 |
while ($related_query->have_posts()) : $related_query->the_post();
|
11 |
+
$postsArray[] = '<a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a><!-- ('.get_the_score().')-->';
|
12 |
endwhile;
|
13 |
|
14 |
+
echo implode(', '."\n",$postsArray); // print out a list of the related items, separated by commas
|
15 |
+
|
16 |
+
else:?>
|
17 |
|
|
|
18 |
<p>No related posts.</p>
|
19 |
<?php endif; ?>
|
yet-another-related-posts-plugin/includes.php
CHANGED
@@ -126,8 +126,8 @@ function yarpp_activate() {
|
|
126 |
return 0;
|
127 |
}
|
128 |
}
|
129 |
-
add_option('yarpp_version','3.
|
130 |
-
update_option('yarpp_version','3.
|
131 |
return 1;
|
132 |
}
|
133 |
|
@@ -178,8 +178,8 @@ function yarpp_upgrade_check($inuse = false) {
|
|
178 |
$wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content`)"); update_option('yarpp_version','2.03');
|
179 |
}
|
180 |
|
181 |
-
if (eregi_replace('[a-z].*$','',get_option('yarpp_version')) < 3.0 or get_option('yarpp_version') != '3.
|
182 |
-
update_option('yarpp_version','3.
|
183 |
|
184 |
//if (!$inuse)
|
185 |
// echo '<div id="message" class="updated fade" style="background-color: rgb(207, 235, 247);">'.__('<h3>An important message from YARPP:</h3><p>Thank you for upgrading to YARPP 2. YARPP 2.0 adds the much requested ability to limit related entry results by certain tags or categories. 2.0 also brings more fine tuned control of the magic algorithm, letting you specify how the algorithm should consider or not consider entry content, titles, tags, and categories. Make sure to adjust the new settings to your liking and perhaps readjust your threshold.</p><p>For more information, check out the <a href="http://mitcho.com/code/yarpp/">YARPP documentation</a>. (This message will not be displayed again.)</p>','yarpp').'</div>';
|
126 |
return 0;
|
127 |
}
|
128 |
}
|
129 |
+
add_option('yarpp_version','3.0b4');
|
130 |
+
update_option('yarpp_version','3.0b4');
|
131 |
return 1;
|
132 |
}
|
133 |
|
178 |
$wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content`)"); update_option('yarpp_version','2.03');
|
179 |
}
|
180 |
|
181 |
+
if (eregi_replace('[a-z].*$','',get_option('yarpp_version')) < 3.0 or get_option('yarpp_version') != '3.0b4') {
|
182 |
+
update_option('yarpp_version','3.0b4');
|
183 |
|
184 |
//if (!$inuse)
|
185 |
// echo '<div id="message" class="updated fade" style="background-color: rgb(207, 235, 247);">'.__('<h3>An important message from YARPP:</h3><p>Thank you for upgrading to YARPP 2. YARPP 2.0 adds the much requested ability to limit related entry results by certain tags or categories. 2.0 also brings more fine tuned control of the magic algorithm, letting you specify how the algorithm should consider or not consider entry content, titles, tags, and categories. Make sure to adjust the new settings to your liking and perhaps readjust your threshold.</p><p>For more information, check out the <a href="http://mitcho.com/code/yarpp/">YARPP documentation</a>. (This message will not be displayed again.)</p>','yarpp').'</div>';
|
yet-another-related-posts-plugin/magic.php
CHANGED
@@ -48,6 +48,18 @@ function yarpp_fields_filter($arg) {
|
|
48 |
return $arg;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
//=CACHING===========
|
52 |
|
53 |
function yarpp_sql($type,$args,$giveresults = true,$reference_ID=false,$domain='website') {
|
@@ -203,18 +215,23 @@ function yarpp_sql($type,$args,$giveresults = true,$reference_ID=false,$domain='
|
|
203 |
/* new in 2.1! the domain argument refers to {website,widget,rss}, though widget is not used yet. */
|
204 |
|
205 |
function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'website') {
|
206 |
-
global $wpdb, $post, $userdata, $yarpp_time, $wp_query, $id, $page, $pages;
|
207 |
-
|
208 |
-
if ($yarpp_time) // if we're already in a YARPP loop, stop now.
|
209 |
-
return false;
|
210 |
|
211 |
-
if (
|
212 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
|
214 |
get_currentuserinfo();
|
215 |
|
216 |
// set the "domain prefix", used for all the preferences.
|
217 |
-
if ($domain == 'rss')
|
218 |
$domainprefix = 'rss_';
|
219 |
else
|
220 |
$domainprefix = '';
|
@@ -241,7 +258,10 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
|
|
241 |
|
242 |
$output = '';
|
243 |
|
244 |
-
$
|
|
|
|
|
|
|
245 |
// just so we can return to normal later
|
246 |
$current_query = $wp_query;
|
247 |
$current_post = $post;
|
@@ -251,13 +271,16 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
|
|
251 |
|
252 |
$related_query = new WP_Query();
|
253 |
$orders = split(' ',$order);
|
254 |
-
$
|
255 |
-
|
|
|
|
|
|
|
256 |
if ($domain == 'metabox') {
|
257 |
include('template-metabox.php');
|
258 |
} elseif ($use_template) {
|
259 |
ob_start();
|
260 |
-
include('
|
261 |
$output = ob_get_contents();
|
262 |
ob_end_clean();
|
263 |
} else {
|
@@ -265,7 +288,10 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
|
|
265 |
}
|
266 |
|
267 |
unset($related_query);
|
268 |
-
$
|
|
|
|
|
|
|
269 |
|
270 |
// restore the older wp_query.
|
271 |
$wp_query = null; $wp_query = $current_query; unset($current_query);
|
48 |
return $arg;
|
49 |
}
|
50 |
|
51 |
+
function yarpp_demo_request_filter($arg) {
|
52 |
+
global $wpdb, $yarpp_demo_time, $yarpp_limit;
|
53 |
+
if ($yarpp_demo_time) {
|
54 |
+
$wpdb->query("set @count = 0;");
|
55 |
+
$arg = "SELECT SQL_CALC_FOUND_ROWS ID + $yarpp_limit as ID, post_author, post_date, post_date_gmt, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' as post_content,
|
56 |
+
concat('".__('Example post ','yarpp')."',@count:=@count+1) as post_title, 0 as post_category, '' as post_excerpt, 'publish' as post_status, 'open' as comment_status, 'open' as ping_status, '' as post_password, concat('example-post-',@count) as post_name, '' as to_ping, '' as pinged, post_modified, post_modified_gmt, '' as post_content_filtered, 0 as post_parent, concat('PERMALINK',@count) as guid, 0 as menu_order, 'post' as post_type, '' as post_mime_type, 0 as comment_count, 'SCORE' as score
|
57 |
+
FROM wp_posts
|
58 |
+
ORDER BY ID DESC LIMIT 0, $yarpp_limit";
|
59 |
+
}
|
60 |
+
return $arg;
|
61 |
+
}
|
62 |
+
|
63 |
//=CACHING===========
|
64 |
|
65 |
function yarpp_sql($type,$args,$giveresults = true,$reference_ID=false,$domain='website') {
|
215 |
/* new in 2.1! the domain argument refers to {website,widget,rss}, though widget is not used yet. */
|
216 |
|
217 |
function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'website') {
|
218 |
+
global $wpdb, $post, $userdata, $yarpp_time, $yarpp_demo_time, $wp_query, $id, $page, $pages;
|
|
|
|
|
|
|
219 |
|
220 |
+
if ($domain != 'demo_web' and $domain != 'demo_rss') {
|
221 |
+
if ($yarpp_time) // if we're already in a YARPP loop, stop now.
|
222 |
+
return false;
|
223 |
+
|
224 |
+
if (is_object($post) and !$reference_ID)
|
225 |
+
$reference_ID = $post->ID;
|
226 |
+
} else {
|
227 |
+
if ($yarpp_demo_time) // if we're already in a YARPP loop, stop now.
|
228 |
+
return false;
|
229 |
+
}
|
230 |
|
231 |
get_currentuserinfo();
|
232 |
|
233 |
// set the "domain prefix", used for all the preferences.
|
234 |
+
if ($domain == 'rss' or $domain == 'demo_rss')
|
235 |
$domainprefix = 'rss_';
|
236 |
else
|
237 |
$domainprefix = '';
|
258 |
|
259 |
$output = '';
|
260 |
|
261 |
+
if ($domain != 'demo_web' and $domain != 'demo_rss')
|
262 |
+
$yarpp_time = true; // get ready for YARPP TIME!
|
263 |
+
else
|
264 |
+
$yarpp_demo_time = true;
|
265 |
// just so we can return to normal later
|
266 |
$current_query = $wp_query;
|
267 |
$current_post = $post;
|
271 |
|
272 |
$related_query = new WP_Query();
|
273 |
$orders = split(' ',$order);
|
274 |
+
if ($domain != 'demo_web' and $domain != 'demo_rss')
|
275 |
+
$related_query->query("p=$reference_ID&orderby=".$orders[0]."&order=".$orders[1]);
|
276 |
+
else
|
277 |
+
$related_query->query('');
|
278 |
+
|
279 |
if ($domain == 'metabox') {
|
280 |
include('template-metabox.php');
|
281 |
} elseif ($use_template) {
|
282 |
ob_start();
|
283 |
+
include(WP_CONTENT_DIR.'/plugins/yarpp-templates/'.$template_file);
|
284 |
$output = ob_get_contents();
|
285 |
ob_end_clean();
|
286 |
} else {
|
288 |
}
|
289 |
|
290 |
unset($related_query);
|
291 |
+
if ($domain != 'demo_web' and $domain != 'demo_rss')
|
292 |
+
$yarpp_time = false; // YARPP time is over... :(
|
293 |
+
else
|
294 |
+
$yarpp_demo_time = false;
|
295 |
|
296 |
// restore the older wp_query.
|
297 |
$wp_query = null; $wp_query = $current_query; unset($current_query);
|
yet-another-related-posts-plugin/services.php
CHANGED
@@ -30,26 +30,26 @@ function yarpp_ajax_display_distags() {
|
|
30 |
}
|
31 |
|
32 |
function yarpp_ajax_display_demo_web() {
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$
|
38 |
-
|
39 |
-
|
40 |
-
echo $
|
41 |
exit;
|
42 |
}
|
43 |
|
44 |
function yarpp_ajax_display_demo_rss() {
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$
|
50 |
-
|
51 |
-
|
52 |
-
echo $
|
53 |
exit;
|
54 |
}
|
55 |
|
30 |
}
|
31 |
|
32 |
function yarpp_ajax_display_demo_web() {
|
33 |
+
global $wpdb, $post, $userdata, $yarpp_demo_time, $wp_query, $id, $page, $pages, $yarpp_limit;
|
34 |
+
|
35 |
+
header("Content-Type: text/html; charset=UTF-8");
|
36 |
+
|
37 |
+
$yarpp_limit = yarpp_get_option('limit');
|
38 |
+
$return = yarpp_related(array('post'),array(),false,false,'demo_web');
|
39 |
+
unset($yarpp_limit);
|
40 |
+
echo ereg_replace("[\n\r]",'',nl2br(htmlspecialchars($return)));
|
41 |
exit;
|
42 |
}
|
43 |
|
44 |
function yarpp_ajax_display_demo_rss() {
|
45 |
+
global $wpdb, $post, $userdata, $yarpp_demo_time, $wp_query, $id, $page, $pages, $yarpp_limit;
|
46 |
+
|
47 |
+
header("Content-Type: text/html; charset=utf-8");
|
48 |
+
|
49 |
+
$yarpp_limit = yarpp_get_option('rss_limit');
|
50 |
+
$return = yarpp_related(array('post'),array(),false,false,'demo_rss');
|
51 |
+
unset($yarpp_limit);
|
52 |
+
echo ereg_replace("[\n\r]",'',nl2br(htmlspecialchars($return)));
|
53 |
exit;
|
54 |
}
|
55 |
|
yet-another-related-posts-plugin/yarpp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Yet Another Related Posts Plugin
|
4 |
Plugin URI: http://mitcho.com/code/yarpp/
|
5 |
Description: Returns a list of the related entries based on a unique algorithm using titles, post bodies, tags, and categories. Now with RSS feed support!
|
6 |
-
Version: 3.
|
7 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
8 |
Author URI: http://mitcho.com/
|
9 |
*/
|
@@ -44,4 +44,5 @@ add_filter('posts_join','yarpp_join_filter');
|
|
44 |
add_filter('posts_where','yarpp_where_filter');
|
45 |
add_filter('posts_orderby','yarpp_orderby_filter');
|
46 |
add_filter('posts_fields','yarpp_fields_filter');
|
|
|
47 |
add_action('parse_query','yarpp_set_score_override_flag'); // sets the score override flag.
|
3 |
Plugin Name: Yet Another Related Posts Plugin
|
4 |
Plugin URI: http://mitcho.com/code/yarpp/
|
5 |
Description: Returns a list of the related entries based on a unique algorithm using titles, post bodies, tags, and categories. Now with RSS feed support!
|
6 |
+
Version: 3.0b4
|
7 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
8 |
Author URI: http://mitcho.com/
|
9 |
*/
|
44 |
add_filter('posts_where','yarpp_where_filter');
|
45 |
add_filter('posts_orderby','yarpp_orderby_filter');
|
46 |
add_filter('posts_fields','yarpp_fields_filter');
|
47 |
+
add_filter('posts_request','yarpp_demo_request_filter');
|
48 |
add_action('parse_query','yarpp_set_score_override_flag'); // sets the score override flag.
|