Version Description
- Improved thumbnail support
- Optimized random posts generation
- Drop support for WordPress 2.x
Download this release
Release Info
Developer | jureham |
Plugin | WordPress Related Posts |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.4
- defaults.php +8 -3
- lang/default.po +2 -2
- lang/wp_related_posts-zh_CN.po +2 -2
- readme.txt +10 -7
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- settings.php +87 -39
- static/settings.js.php +7 -1
- static/themes.js +22 -12
- static/thumbs/0.jpg +0 -0
- static/thumbs/1.jpg +0 -0
- static/thumbs/10.jpg +0 -0
- static/thumbs/11.jpg +0 -0
- static/thumbs/12.jpg +0 -0
- static/thumbs/13.jpg +0 -0
- static/thumbs/14.jpg +0 -0
- static/thumbs/2.jpg +0 -0
- static/thumbs/3.jpg +0 -0
- static/thumbs/4.jpg +0 -0
- static/thumbs/5.jpg +0 -0
- static/thumbs/6.jpg +0 -0
- static/thumbs/7.jpg +0 -0
- static/thumbs/8.jpg +0 -0
- static/thumbs/9.jpg +0 -0
- thumbnailer.php +108 -0
- utils.php +8 -9
- versions.php +36 -0
- wp_related_posts.php +65 -46
defaults.php
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
<?php
|
2 |
define("WP_RP_STATIC_BASE_URL", "http://dtmvdvtzf8rz0.cloudfront.net/static/");
|
3 |
-
define("WP_RP_THEMES_PATH", "css/");
|
|
|
4 |
define("WP_RP_JSON_PATH", "json/");
|
5 |
-
define("WP_RP_THEME_DEFAULT", "
|
6 |
define("WP_RP_THEME_PLAIN", "plain.css");
|
7 |
|
8 |
define("WP_RP_TITLE_TAG_DEFAULT", "h3");
|
9 |
|
10 |
-
define("WP_RP_AUTO_APPEND",
|
11 |
define("WP_RP_TITLE", "Related posts");
|
12 |
define("WP_RP_POST_LIMIT", 5);
|
13 |
define("WP_RP_APPEND_TO_RSS", true);
|
14 |
define("WP_RP_RELATED_FALLBACK", "random");
|
15 |
define("WP_RP_RELATED_FALLBACK_TITLE", "Random posts");
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
define("WP_RP_STATIC_BASE_URL", "http://dtmvdvtzf8rz0.cloudfront.net/static/");
|
3 |
+
define("WP_RP_THEMES_PATH", "css-text/");
|
4 |
+
define("WP_RP_THEMES_THUMBNAILS_PATH", "css-img/");
|
5 |
define("WP_RP_JSON_PATH", "json/");
|
6 |
+
define("WP_RP_THEME_DEFAULT", "vertical-m.css");
|
7 |
define("WP_RP_THEME_PLAIN", "plain.css");
|
8 |
|
9 |
define("WP_RP_TITLE_TAG_DEFAULT", "h3");
|
10 |
|
11 |
+
define("WP_RP_AUTO_APPEND", 'yes');
|
12 |
define("WP_RP_TITLE", "Related posts");
|
13 |
define("WP_RP_POST_LIMIT", 5);
|
14 |
define("WP_RP_APPEND_TO_RSS", true);
|
15 |
define("WP_RP_RELATED_FALLBACK", "random");
|
16 |
define("WP_RP_RELATED_FALLBACK_TITLE", "Random posts");
|
17 |
+
|
18 |
+
define("WP_RP_THUMBNAILS_WIDTH", 150);
|
19 |
+
define("WP_RP_THUMBNAILS_HEIGHT", 150);
|
20 |
+
define("WP_RP_THUMBNAILS_DEFAULTS_COUNT", 15);
|
lang/default.po
CHANGED
@@ -176,11 +176,11 @@ msgid "Thumbnail Setting:"
|
|
176 |
msgstr ""
|
177 |
|
178 |
#: ../wp_related_posts.php:462
|
179 |
-
msgid "Display Thumbnails For Related Posts
|
180 |
msgstr ""
|
181 |
|
182 |
#: ../wp_related_posts.php:466
|
183 |
-
msgid "
|
184 |
msgstr ""
|
185 |
|
186 |
#: ../wp_related_posts.php:468
|
176 |
msgstr ""
|
177 |
|
178 |
#: ../wp_related_posts.php:462
|
179 |
+
msgid "Display Thumbnails For Related Posts"
|
180 |
msgstr ""
|
181 |
|
182 |
#: ../wp_related_posts.php:466
|
183 |
+
msgid "Display Post Titles"
|
184 |
msgstr ""
|
185 |
|
186 |
#: ../wp_related_posts.php:468
|
lang/wp_related_posts-zh_CN.po
CHANGED
@@ -176,11 +176,11 @@ msgid "Thumbnail Setting:"
|
|
176 |
msgstr "缩略图设置:"
|
177 |
|
178 |
#: ../wp_related_posts.php:462
|
179 |
-
msgid "Display Thumbnails For Related Posts
|
180 |
msgstr "给相关日志显示缩略图?"
|
181 |
|
182 |
#: ../wp_related_posts.php:466
|
183 |
-
msgid "
|
184 |
msgstr "在使用给相关日志显示缩略图的同时还显示相关日志的标题等文本?"
|
185 |
|
186 |
#: ../wp_related_posts.php:468
|
176 |
msgstr "缩略图设置:"
|
177 |
|
178 |
#: ../wp_related_posts.php:462
|
179 |
+
msgid "Display Thumbnails For Related Posts"
|
180 |
msgstr "给相关日志显示缩略图?"
|
181 |
|
182 |
#: ../wp_related_posts.php:466
|
183 |
+
msgid "Display Post Titles"
|
184 |
msgstr "在使用给相关日志显示缩略图的同时还显示相关日志的标题等文本?"
|
185 |
|
186 |
#: ../wp_related_posts.php:468
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Plugin Name ===
|
2 |
-
Contributors:
|
3 |
Tags: Related,Posts
|
4 |
-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=
|
5 |
-
Requires at least:
|
6 |
-
Tested up to: 3.4.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
WordPress Related Posts Plugin will generate a related posts via WordPress tags, and add the related posts to feed.
|
10 |
|
@@ -12,8 +12,6 @@ WordPress Related Posts Plugin will generate a related posts via WordPress tags,
|
|
12 |
|
13 |
WordPress Related Posts Plugin will generate a related posts via WordPress tags, and add the related posts to feed.
|
14 |
|
15 |
-
Please search and submit your transaltion here: <a href="http://fairyfish.net/2008/06/06/wordpress-related-posts-plugin-translation/">http://fairyfish.net/2008/06/06/wordpress-related-posts-plugin-translation/</a>
|
16 |
-
|
17 |
== Installation ==
|
18 |
|
19 |
1. Upload the folder WPRP to the `/wp-content/plugins/` directory
|
@@ -27,6 +25,11 @@ Please search and submit your transaltion here: <a href="http://fairyfish.net/20
|
|
27 |
|
28 |
== Changelog ==
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
= 1.3 =
|
31 |
* Code cleanup
|
32 |
* First two CSS themes added to Settings. More designs to come.
|
1 |
=== Plugin Name ===
|
2 |
+
Contributors: jureham
|
3 |
Tags: Related,Posts
|
4 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LB3MVPLUAWCY6
|
5 |
+
Requires at least: 3.0
|
6 |
+
Tested up to: 3.4.2
|
7 |
+
Stable tag: 1.4
|
8 |
|
9 |
WordPress Related Posts Plugin will generate a related posts via WordPress tags, and add the related posts to feed.
|
10 |
|
12 |
|
13 |
WordPress Related Posts Plugin will generate a related posts via WordPress tags, and add the related posts to feed.
|
14 |
|
|
|
|
|
15 |
== Installation ==
|
16 |
|
17 |
1. Upload the folder WPRP to the `/wp-content/plugins/` directory
|
25 |
|
26 |
== Changelog ==
|
27 |
|
28 |
+
= 1.4 =
|
29 |
+
* Improved thumbnail support
|
30 |
+
* Optimized random posts generation
|
31 |
+
* Drop support for WordPress 2.x
|
32 |
+
|
33 |
= 1.3 =
|
34 |
* Code cleanup
|
35 |
* First two CSS themes added to Settings. More designs to come.
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
settings.php
CHANGED
@@ -9,8 +9,7 @@ function wp_add_related_posts_options_page() {
|
|
9 |
}
|
10 |
|
11 |
function wp_rp_themes_scripts() {
|
12 |
-
|
13 |
-
wp_enqueue_script("wp_rp_themes_script", path_join($plugin_path, "static/themes.js"), array( 'jquery' ) );
|
14 |
}
|
15 |
|
16 |
function wp_related_posts_options_subpanel() {
|
@@ -35,9 +34,20 @@ function wp_related_posts_options_subpanel() {
|
|
35 |
'wp_rp_thumbnail' => isset($_POST['wp_rp_thumbnail_option']) ? trim($_POST['wp_rp_thumbnail_option']) : false,
|
36 |
'wp_rp_thumbnail_text' => isset($_POST['wp_rp_thumbnail_text_option']) ? trim($_POST['wp_rp_thumbnail_text_option']) : false,
|
37 |
'wp_rp_thumbnail_post_meta' => isset($_POST['wp_rp_thumbnail_post_meta_option']) ? trim($_POST['wp_rp_thumbnail_post_meta_option']) : false,
|
|
|
|
|
38 |
'wp_rp_theme' => isset($_POST['wp_rp_theme']) ? trim($_POST['wp_rp_theme']) : false
|
39 |
);
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
if ($wp_rp_saved != $wp_rp)
|
42 |
if(!update_option("wp_rp",$wp_rp))
|
43 |
$message = "Update Failed";
|
@@ -56,21 +66,31 @@ function wp_related_posts_options_subpanel() {
|
|
56 |
|
57 |
$wp_rp_theme = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : WP_RP_THEME_DEFAULT;
|
58 |
|
59 |
-
include dirname(__FILE__) . "/static/settings.js.php"
|
|
|
|
|
|
|
|
|
|
|
60 |
?>
|
61 |
|
62 |
<input type="hidden" id="wp_rp_theme_url" value="<?=WP_RP_STATIC_BASE_URL . WP_RP_THEMES_PATH?>" />
|
63 |
<input type="hidden" id="wp_rp_json_url" value="<?=WP_RP_STATIC_BASE_URL . WP_RP_JSON_PATH?>" />
|
|
|
64 |
<input type="hidden" id="wp_rp_theme_selected" value="<?=$wp_rp_theme?>" />
|
65 |
|
66 |
<h2><?php _e("Related Posts Settings",'wp_related_posts');?></h2>
|
67 |
|
68 |
<div id="wp-rp-survey" class="updated highlight" style="display:none;"><p><?php _e("Please fill out",'wp_related_posts');?> <a class="link" target="_blank" href="http://wprelatedposts.polldaddy.com/s/new-features"><?php _e("a quick survey", 'wp_related_posts');?></a>.<a href="#" class="close" style="float: right;">x</a></p></div>
|
69 |
|
|
|
|
|
|
|
|
|
70 |
<p><?php _e("WordPress Related Posts Plugin places a list of related articles via WordPress tags at the bottom of your post.",'wp_related_posts');?> </p>
|
71 |
<?php _e("If you have any questions please contact us at",'wp_related_posts');?> <a target="_blank" href="mailto:relatedpostsplugin@gmail.com"><?php _e("support", 'wp_related_posts');?></a>.</p>
|
72 |
|
73 |
-
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=wordpress-related-posts">
|
74 |
<h3><?php _e("Basic Settings",'wp_related_posts');?></h3>
|
75 |
<table class="form-table">
|
76 |
<tr valign="top">
|
@@ -82,7 +102,7 @@ function wp_related_posts_options_subpanel() {
|
|
82 |
<tr valign="top">
|
83 |
<th scope="row"><?php _e("Maximum Number of Posts:",'wp_related_posts');?></th>
|
84 |
<td>
|
85 |
-
<input name="wp_rp_limit_option" type="
|
86 |
</td>
|
87 |
</tr>
|
88 |
<tr valign="top">
|
@@ -95,11 +115,11 @@ function wp_related_posts_options_subpanel() {
|
|
95 |
'order' => 'ASC',
|
96 |
'hide_empty' => false
|
97 |
);
|
98 |
-
foreach (get_categories($args) as $
|
99 |
?>
|
100 |
<label>
|
101 |
-
<input name="wp_rp_exclude_option[]" type="checkbox" id="wp_rp_exclude" value="<?=$
|
102 |
-
<?=$
|
103 |
<br />
|
104 |
</label>
|
105 |
<?php } ?>
|
@@ -113,37 +133,64 @@ function wp_related_posts_options_subpanel() {
|
|
113 |
<th scope="row"><?php _e("Thumbnail Options:",'wp_related_posts'); ?></th>
|
114 |
<td>
|
115 |
<label>
|
116 |
-
<input name="wp_rp_thumbnail_option" type="checkbox" id="wp_rp_thumbnail" value="yes"
|
117 |
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
118 |
</label>
|
119 |
<br />
|
120 |
<span id="wp_rp_thumbnail_span" style="<?php echo ($wp_rp["wp_rp_thumbnail"] == 'yes') ? '' : 'display:none;'; ?>">
|
121 |
<label>
|
122 |
-
<input name="wp_rp_thumbnail_text_option" type="checkbox" id="wp_rp_thumbnail_text" value="yes" <?php
|
123 |
-
<?php _e("
|
124 |
</label>
|
125 |
<br />
|
126 |
-
|
127 |
-
<?php _e("Which field is used for thumbnail?",'wp_related_posts');?>
|
128 |
-
<select name="wp_rp_thumbnail_post_meta_option" id="wp_rp_thumbnail_post_meta" class="postform">
|
129 |
<?php
|
130 |
global $wpdb;
|
131 |
|
132 |
-
if (function_exists('has_post_thumbnail')) {
|
133 |
-
echo '<option value="wprp_featured_image">' . __("Use Featured Image", "wp_related_posts") . '</option>';
|
134 |
-
}
|
135 |
-
|
136 |
$post_metas = $wpdb->get_col( "SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)" );
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
|
|
|
|
138 |
foreach ( $post_metas as $post_meta ) {
|
139 |
$post_meta = esc_attr( $post_meta );
|
140 |
?>
|
141 |
-
|
142 |
-
<option value="<?php echo $post_meta; ?>" <?php if($wp_rp["wp_rp_thumbnail_post_meta"] == $post_meta) echo 'selected' ?>><?php echo $post_meta;?> </option>;
|
143 |
<?php
|
144 |
}
|
145 |
?>
|
146 |
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
</span>
|
148 |
</td>
|
149 |
</tr>
|
@@ -151,17 +198,17 @@ function wp_related_posts_options_subpanel() {
|
|
151 |
<th scope="row"><?php _e("Display Options:",'wp_related_posts'); ?></th>
|
152 |
<td>
|
153 |
<label>
|
154 |
-
<input name="wp_rp_comments_option" type="checkbox" id="wp_rp_comments" value="yes"
|
155 |
<?php _e("Display Number of Comments",'wp_related_posts');?>
|
156 |
</label>
|
157 |
<br />
|
158 |
<label>
|
159 |
-
<input name="wp_rp_date_option" type="checkbox" id="wp_rp_date" value="yes"
|
160 |
<?php _e("Display Publish Date",'wp_related_posts');?>
|
161 |
</label>
|
162 |
<br />
|
163 |
<label>
|
164 |
-
<input name="wp_rp_except_option" type="checkbox" id="wp_rp_except" value="yes"
|
165 |
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
166 |
</label>
|
167 |
<label id="wp_rp_except_number_label" style="<?php echo ($wp_rp["wp_rp_except"] == 'yes') ? '' : 'display:none;'; ?>">
|
@@ -172,13 +219,14 @@ function wp_related_posts_options_subpanel() {
|
|
172 |
<?php _e("Related Posts Title Tag",'wp_related_posts'); ?>
|
173 |
<select name="wp_rp_title_tag_option" id="wp_rp_title_tag" class="postform">
|
174 |
<?php
|
175 |
-
$wp_rp_title_tag_array = array('h2','h3','h4','p','div');
|
176 |
-
|
|
|
177 |
$wp_rp_title_tag = WP_RP_TITLE_TAG_DEFAULT;
|
178 |
-
|
179 |
-
foreach ($wp_rp_title_tag_array as $wp_rp_title_tag_a){
|
180 |
?>
|
181 |
-
<option value="<?php echo $wp_rp_title_tag_a; ?>"
|
182 |
<?php
|
183 |
}
|
184 |
?>
|
@@ -194,11 +242,11 @@ function wp_related_posts_options_subpanel() {
|
|
194 |
<th scope="row"><?php _e("Display:",'wp_related_posts'); ?></th>
|
195 |
<td>
|
196 |
<select name="wp_no_rp_option" id="wp_no_rp" onchange="wp_no_rp_onchange();" class="postform">
|
197 |
-
<option value="text"
|
198 |
-
<option value="random"
|
199 |
-
<option value="commented"
|
200 |
<?php if (function_exists('akpc_most_popular')){ ?>
|
201 |
-
<option value="popularity" <?php
|
202 |
<?php } ?>
|
203 |
</select>
|
204 |
</td>
|
@@ -206,18 +254,18 @@ function wp_related_posts_options_subpanel() {
|
|
206 |
<tr valign="top" scope="row">
|
207 |
<th id="wp_no_rp_title" scope="row">
|
208 |
<?php
|
209 |
-
switch
|
210 |
case 'text':
|
211 |
-
_e("No Related Posts Text:",'wp_related_posts');
|
212 |
break;
|
213 |
case 'random':
|
214 |
-
_e("Random Posts Title:",'wp_related_posts');
|
215 |
break;
|
216 |
case 'commented':
|
217 |
-
_e("Most Commented Posts Title:",'wp_related_posts');
|
218 |
break;
|
219 |
case 'popularity':
|
220 |
-
_e("Most Popular Posts Title:",'wp_related_posts');
|
221 |
break;
|
222 |
}
|
223 |
?>
|
@@ -232,12 +280,12 @@ function wp_related_posts_options_subpanel() {
|
|
232 |
<tr valign="top">
|
233 |
<td>
|
234 |
<label>
|
235 |
-
<input name="wp_rp_auto_option" type="checkbox" id="wp_rp_auto" value="yes"
|
236 |
<?php _e("Auto Insert Related Posts",'wp_related_posts');?>
|
237 |
</label>
|
238 |
<br />
|
239 |
<label>
|
240 |
-
<input name="wp_rp_rss_option" type="checkbox" id="wp_rp_rss" value="yes"
|
241 |
<?php _e("Display Related Posts in Feed",'wp_related_posts');?>
|
242 |
</label>
|
243 |
</td>
|
9 |
}
|
10 |
|
11 |
function wp_rp_themes_scripts() {
|
12 |
+
wp_enqueue_script("wp_rp_themes_script", plugins_url("static/themes.js", __FILE__), array( 'jquery' ) );
|
|
|
13 |
}
|
14 |
|
15 |
function wp_related_posts_options_subpanel() {
|
34 |
'wp_rp_thumbnail' => isset($_POST['wp_rp_thumbnail_option']) ? trim($_POST['wp_rp_thumbnail_option']) : false,
|
35 |
'wp_rp_thumbnail_text' => isset($_POST['wp_rp_thumbnail_text_option']) ? trim($_POST['wp_rp_thumbnail_text_option']) : false,
|
36 |
'wp_rp_thumbnail_post_meta' => isset($_POST['wp_rp_thumbnail_post_meta_option']) ? trim($_POST['wp_rp_thumbnail_post_meta_option']) : false,
|
37 |
+
'wp_rp_thumbnail_extract' => isset($_POST['wp_rp_thumbnail_extract']) ? trim($_POST['wp_rp_thumbnail_extract']) : false,
|
38 |
+
'wp_rp_thumbnail_featured' => isset($_POST['wp_rp_thumbnail_featured']) ? trim($_POST['wp_rp_thumbnail_featured']) : false,
|
39 |
'wp_rp_theme' => isset($_POST['wp_rp_theme']) ? trim($_POST['wp_rp_theme']) : false
|
40 |
);
|
41 |
|
42 |
+
$default_thumbnail_path = wp_rp_upload_default_thumbnail_file();
|
43 |
+
if ($default_thumbnail_path) {
|
44 |
+
$wp_rp['wp_rp_default_thumbnail_path'] = $default_thumbnail_path;
|
45 |
+
} else {
|
46 |
+
if (!isset($_POST['wp_rp_default_thumbnail_remove']) || !$_POST['wp_rp_default_thumbnail_remove']) {
|
47 |
+
$wp_rp['wp_rp_default_thumbnail_path'] = $wp_rp_saved['wp_rp_default_thumbnail_path'];
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
if ($wp_rp_saved != $wp_rp)
|
52 |
if(!update_option("wp_rp",$wp_rp))
|
53 |
$message = "Update Failed";
|
66 |
|
67 |
$wp_rp_theme = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : WP_RP_THEME_DEFAULT;
|
68 |
|
69 |
+
include dirname(__FILE__) . "/static/settings.js.php";
|
70 |
+
|
71 |
+
if (isset($wp_rp['wp_rp_log_new_user']) && $wp_rp['wp_rp_log_new_user']) {
|
72 |
+
$wp_rp['wp_rp_log_new_user'] = false;
|
73 |
+
update_option('wp_rp', $wp_rp);
|
74 |
+
}
|
75 |
?>
|
76 |
|
77 |
<input type="hidden" id="wp_rp_theme_url" value="<?=WP_RP_STATIC_BASE_URL . WP_RP_THEMES_PATH?>" />
|
78 |
<input type="hidden" id="wp_rp_json_url" value="<?=WP_RP_STATIC_BASE_URL . WP_RP_JSON_PATH?>" />
|
79 |
+
<input type="hidden" id="wp_rp_version" value="<?=WP_RP_VERSION?>" />
|
80 |
<input type="hidden" id="wp_rp_theme_selected" value="<?=$wp_rp_theme?>" />
|
81 |
|
82 |
<h2><?php _e("Related Posts Settings",'wp_related_posts');?></h2>
|
83 |
|
84 |
<div id="wp-rp-survey" class="updated highlight" style="display:none;"><p><?php _e("Please fill out",'wp_related_posts');?> <a class="link" target="_blank" href="http://wprelatedposts.polldaddy.com/s/new-features"><?php _e("a quick survey", 'wp_related_posts');?></a>.<a href="#" class="close" style="float: right;">x</a></p></div>
|
85 |
|
86 |
+
<?php if (!isset($wp_rp["wp_rp_thumbnail"]) || !$wp_rp["wp_rp_thumbnail"]) { ?>
|
87 |
+
<div id="wp-rp-thumbnails-info" class="updated" style="display:none;"><p><?php _e("Check out the new and updated <i>Related posts with Thumbnails</i> by clicking and checking the <i>Display Thumbnails For Related Posts</i> setting",'wp_related_posts');?>.<a href="#" class="close" style="float: right;">x</a></p></div>
|
88 |
+
<?php } ?>
|
89 |
+
|
90 |
<p><?php _e("WordPress Related Posts Plugin places a list of related articles via WordPress tags at the bottom of your post.",'wp_related_posts');?> </p>
|
91 |
<?php _e("If you have any questions please contact us at",'wp_related_posts');?> <a target="_blank" href="mailto:relatedpostsplugin@gmail.com"><?php _e("support", 'wp_related_posts');?></a>.</p>
|
92 |
|
93 |
+
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=wordpress-related-posts">
|
94 |
<h3><?php _e("Basic Settings",'wp_related_posts');?></h3>
|
95 |
<table class="form-table">
|
96 |
<tr valign="top">
|
102 |
<tr valign="top">
|
103 |
<th scope="row"><?php _e("Maximum Number of Posts:",'wp_related_posts');?></th>
|
104 |
<td>
|
105 |
+
<input name="wp_rp_limit_option" type="number" step="1" id="wp_rp_limit" value="<?php echo $wp_rp["wp_rp_limit"]; ?>" />
|
106 |
</td>
|
107 |
</tr>
|
108 |
<tr valign="top">
|
115 |
'order' => 'ASC',
|
116 |
'hide_empty' => false
|
117 |
);
|
118 |
+
foreach (get_categories($args) as $category) {
|
119 |
?>
|
120 |
<label>
|
121 |
+
<input name="wp_rp_exclude_option[]" type="checkbox" id="wp_rp_exclude" value="<?=$category->cat_ID?>" <?= in_array($category->cat_ID, $exclude) ? "checked=\"checked\"" : ""; ?> />
|
122 |
+
<?=$category->cat_name?>
|
123 |
<br />
|
124 |
</label>
|
125 |
<?php } ?>
|
133 |
<th scope="row"><?php _e("Thumbnail Options:",'wp_related_posts'); ?></th>
|
134 |
<td>
|
135 |
<label>
|
136 |
+
<input name="wp_rp_thumbnail_option" type="checkbox" id="wp_rp_thumbnail" value="yes"<?php checked($wp_rp["wp_rp_thumbnail"], 'yes'); ?> onclick="wp_rp_thumbnail_onclick();" >
|
137 |
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
138 |
</label>
|
139 |
<br />
|
140 |
<span id="wp_rp_thumbnail_span" style="<?php echo ($wp_rp["wp_rp_thumbnail"] == 'yes') ? '' : 'display:none;'; ?>">
|
141 |
<label>
|
142 |
+
<input name="wp_rp_thumbnail_text_option" type="checkbox" id="wp_rp_thumbnail_text" value="yes" <?php checked($wp_rp["wp_rp_thumbnail_text"], 'yes'); ?>>
|
143 |
+
<?php _e("Display Post Titles",'wp_related_posts');?>
|
144 |
</label>
|
145 |
<br />
|
146 |
+
|
|
|
|
|
147 |
<?php
|
148 |
global $wpdb;
|
149 |
|
|
|
|
|
|
|
|
|
150 |
$post_metas = $wpdb->get_col( "SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)" );
|
151 |
+
$show_custom_thumbnails = wp_rp_show_custom_thumbnails($wp_rp);
|
152 |
+
|
153 |
+
if($post_metas) {
|
154 |
+
?>
|
155 |
+
<label><input name="wp_rp_thumbnail_featured" type="radio" value="yes" <?php checked(!$show_custom_thumbnails); ?>> Use featured image</label>
|
156 |
+
<label><input name="wp_rp_thumbnail_featured" type="radio" value="no" <?php checked($show_custom_thumbnails); ?>> Use custom field</label>
|
157 |
|
158 |
+
<select name="wp_rp_thumbnail_post_meta_option" id="wp_rp_thumbnail_post_meta" class="postform">
|
159 |
+
<?php
|
160 |
foreach ( $post_metas as $post_meta ) {
|
161 |
$post_meta = esc_attr( $post_meta );
|
162 |
?>
|
163 |
+
<option value="<?php echo $post_meta; ?>"<?php selected($wp_rp["wp_rp_thumbnail_post_meta"], $post_meta); ?>><?php echo $post_meta;?></option>
|
|
|
164 |
<?php
|
165 |
}
|
166 |
?>
|
167 |
</select>
|
168 |
+
<br />
|
169 |
+
<?php } ?>
|
170 |
+
|
171 |
+
<label>
|
172 |
+
<input name="wp_rp_thumbnail_extract" type="checkbox" value="yes"<?php checked($wp_rp["wp_rp_thumbnail_extract"], 'yes'); ?>>
|
173 |
+
<?php _e("If featured image is missing, show the first uploaded image of the post",'wp_related_posts');?>
|
174 |
+
</label>
|
175 |
+
<br />
|
176 |
+
|
177 |
+
|
178 |
+
<br />
|
179 |
+
<label>
|
180 |
+
<?php _e("For posts without images, a default image will be shown. <br/>
|
181 |
+
You can upload your own default image here",'wp_related_posts');?>
|
182 |
+
<input type="file" name="wp_rp_default_thumbnail" />
|
183 |
+
</label>
|
184 |
+
<?php if (isset($wp_rp['wp_rp_default_thumbnail_path']) && $wp_rp['wp_rp_default_thumbnail_path']) { ?>
|
185 |
+
<span style="display: inline-block; vertical-align: top; *display: inline; zoom: 1;">
|
186 |
+
<img style="padding: 3px; border: 1px solid #DFDFDF; border-radius: 3px;" valign="top" width="80" height="80" src="<?=wp_rp_get_default_thumbnail_url();?>" alt="selected thumbnail" />
|
187 |
+
<br />
|
188 |
+
<label>
|
189 |
+
<input type="checkbox" name="wp_rp_default_thumbnail_remove" />
|
190 |
+
<?php _e("Remove selected",'wp_related_posts');?>
|
191 |
+
</label>
|
192 |
+
</span>
|
193 |
+
<?php } ?>
|
194 |
</span>
|
195 |
</td>
|
196 |
</tr>
|
198 |
<th scope="row"><?php _e("Display Options:",'wp_related_posts'); ?></th>
|
199 |
<td>
|
200 |
<label>
|
201 |
+
<input name="wp_rp_comments_option" type="checkbox" id="wp_rp_comments" value="yes"<?php checked($wp_rp["wp_rp_comments"], 'yes'); ?>>
|
202 |
<?php _e("Display Number of Comments",'wp_related_posts');?>
|
203 |
</label>
|
204 |
<br />
|
205 |
<label>
|
206 |
+
<input name="wp_rp_date_option" type="checkbox" id="wp_rp_date" value="yes"<?php checked($wp_rp["wp_rp_date"], 'yes'); ?>>
|
207 |
<?php _e("Display Publish Date",'wp_related_posts');?>
|
208 |
</label>
|
209 |
<br />
|
210 |
<label>
|
211 |
+
<input name="wp_rp_except_option" type="checkbox" id="wp_rp_except" value="yes"<?php checked($wp_rp["wp_rp_except"], 'yes'); ?> onclick="wp_rp_except_onclick();" >
|
212 |
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
213 |
</label>
|
214 |
<label id="wp_rp_except_number_label" style="<?php echo ($wp_rp["wp_rp_except"] == 'yes') ? '' : 'display:none;'; ?>">
|
219 |
<?php _e("Related Posts Title Tag",'wp_related_posts'); ?>
|
220 |
<select name="wp_rp_title_tag_option" id="wp_rp_title_tag" class="postform">
|
221 |
<?php
|
222 |
+
$wp_rp_title_tag_array = array('h2', 'h3', 'h4', 'p', 'div');
|
223 |
+
|
224 |
+
if(!isset($wp_rp_title_tag) || $wp_rp_title_tag === false)
|
225 |
$wp_rp_title_tag = WP_RP_TITLE_TAG_DEFAULT;
|
226 |
+
|
227 |
+
foreach ($wp_rp_title_tag_array as $wp_rp_title_tag_a) {
|
228 |
?>
|
229 |
+
<option value="<?php echo esc_attr($wp_rp_title_tag_a); ?>"<?php selected($wp_rp_title_tag, $wp_rp_title_tag_a); ?>><<?php echo esc_html($wp_rp_title_tag_a); ?>></option>
|
230 |
<?php
|
231 |
}
|
232 |
?>
|
242 |
<th scope="row"><?php _e("Display:",'wp_related_posts'); ?></th>
|
243 |
<td>
|
244 |
<select name="wp_no_rp_option" id="wp_no_rp" onchange="wp_no_rp_onchange();" class="postform">
|
245 |
+
<option value="text"<?php selected($wp_no_rp, 'text'); ?> ><?php _e("Text: 'No Related Posts'",'wp_related_posts'); ?></option>
|
246 |
+
<option value="random"<?php selected($wp_no_rp, 'random'); ?>><?php _e("Random Posts",'wp_related_posts'); ?></option>
|
247 |
+
<option value="commented"<?php selected($wp_no_rp, 'commented'); ?>><?php _e("Most Commented Posts",'wp_related_posts'); ?></option>
|
248 |
<?php if (function_exists('akpc_most_popular')){ ?>
|
249 |
+
<option value="popularity" <?php selected($wp_no_rp, 'popularity'); ?>><?php _e("Most Popular Posts",'wp_related_posts'); ?></option>
|
250 |
<?php } ?>
|
251 |
</select>
|
252 |
</td>
|
254 |
<tr valign="top" scope="row">
|
255 |
<th id="wp_no_rp_title" scope="row">
|
256 |
<?php
|
257 |
+
switch($wp_no_rp) {
|
258 |
case 'text':
|
259 |
+
_e("No Related Posts Text:", 'wp_related_posts');
|
260 |
break;
|
261 |
case 'random':
|
262 |
+
_e("Random Posts Title:", 'wp_related_posts');
|
263 |
break;
|
264 |
case 'commented':
|
265 |
+
_e("Most Commented Posts Title:", 'wp_related_posts');
|
266 |
break;
|
267 |
case 'popularity':
|
268 |
+
_e("Most Popular Posts Title:", 'wp_related_posts');
|
269 |
break;
|
270 |
}
|
271 |
?>
|
280 |
<tr valign="top">
|
281 |
<td>
|
282 |
<label>
|
283 |
+
<input name="wp_rp_auto_option" type="checkbox" id="wp_rp_auto" value="yes"<?php checked($wp_rp["wp_rp_auto"], 'yes'); ?>>
|
284 |
<?php _e("Auto Insert Related Posts",'wp_related_posts');?>
|
285 |
</label>
|
286 |
<br />
|
287 |
<label>
|
288 |
+
<input name="wp_rp_rss_option" type="checkbox" id="wp_rp_rss" value="yes"<?php checked($wp_rp["wp_rp_rss"], 'yes'); ?>>
|
289 |
<?php _e("Display Related Posts in Feed",'wp_related_posts');?>
|
290 |
</label>
|
291 |
</td>
|
static/settings.js.php
CHANGED
@@ -41,6 +41,10 @@
|
|
41 |
var wp_rp_thumbnail_span = document.getElementById('wp_rp_thumbnail_span');
|
42 |
if(wp_rp_thumbnail.checked){
|
43 |
wp_rp_thumbnail_span.style.display = '';
|
|
|
|
|
|
|
|
|
44 |
} else {
|
45 |
wp_rp_thumbnail_span.style.display = 'none';
|
46 |
}
|
@@ -52,7 +56,9 @@
|
|
52 |
var _gaq = _gaq || [];
|
53 |
_gaq.push(['_setAccount', 'UA-34712447-1']);
|
54 |
_gaq.push(['_trackPageview']);
|
55 |
-
|
|
|
|
|
56 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_version', '<?=get_bloginfo('version');?>', 0, true]);
|
57 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_language', '<?=get_bloginfo('language');?>', 0, true]);
|
58 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_plugin_version', '<?php $plugin_data = get_plugin_data(__FILE__); echo $plugin_data['Version'];?>', 0, true]);
|
41 |
var wp_rp_thumbnail_span = document.getElementById('wp_rp_thumbnail_span');
|
42 |
if(wp_rp_thumbnail.checked){
|
43 |
wp_rp_thumbnail_span.style.display = '';
|
44 |
+
jQuery('#wp-rp-thumbnails-info').fadeOut();
|
45 |
+
if (window.localStorage) {
|
46 |
+
window.localStorage.wp_rp_thumbnails_info = "close";
|
47 |
+
}
|
48 |
} else {
|
49 |
wp_rp_thumbnail_span.style.display = 'none';
|
50 |
}
|
56 |
var _gaq = _gaq || [];
|
57 |
_gaq.push(['_setAccount', 'UA-34712447-1']);
|
58 |
_gaq.push(['_trackPageview']);
|
59 |
+
<?php if(isset($wp_rp['wp_rp_log_new_user']) && $wp_rp['wp_rp_log_new_user']) { ?>
|
60 |
+
_gaq.push(['_trackEvent', 'wp_related_posts', 'new_user', 'new_user', 0, true]);
|
61 |
+
<?php } ?>
|
62 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_version', '<?=get_bloginfo('version');?>', 0, true]);
|
63 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_language', '<?=get_bloginfo('language');?>', 0, true]);
|
64 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_plugin_version', '<?php $plugin_data = get_plugin_data(__FILE__); echo $plugin_data['Version'];?>', 0, true]);
|
static/themes.js
CHANGED
@@ -2,31 +2,28 @@
|
|
2 |
$(function () {
|
3 |
var wrap = $('#wp_rp_theme_options_wrap'),
|
4 |
json_url = $('#wp_rp_json_url').val(),
|
|
|
5 |
current_theme = $('#wp_rp_theme_selected').val(),
|
6 |
themes = null,
|
7 |
update_themes = function () {
|
8 |
-
var td = $('<td />');
|
9 |
-
|
10 |
wrap.empty();
|
11 |
if ($('#wp_rp_theme_title').length === 0) {
|
12 |
wrap.append('<th scope="row">Select Theme:</th>');
|
13 |
}
|
14 |
-
wrap.append(td);
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
}
|
24 |
},
|
25 |
append_get_themes_script = function () {
|
26 |
var script = document.createElement('script'),
|
27 |
body = document.getElementsByTagName("body").item(0);
|
28 |
script.type = 'text/javascript';
|
29 |
-
script.src = json_url + 'themes.js';
|
30 |
|
31 |
body.appendChild(script);
|
32 |
};
|
@@ -35,7 +32,9 @@
|
|
35 |
if (data && data.themes) {
|
36 |
themes = data.themes;
|
37 |
|
38 |
-
|
|
|
|
|
39 |
}
|
40 |
};
|
41 |
|
@@ -45,11 +44,22 @@
|
|
45 |
$('#wp-rp-survey').show();
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
48 |
$('#wp-rp-survey .close, #wp-rp-survey .link').click(function () {
|
49 |
$('#wp-rp-survey').fadeOut();
|
50 |
if (window.localStorage) {
|
51 |
window.localStorage.wp_wp_survey_1 = "close";
|
52 |
}
|
53 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
});
|
55 |
}(jQuery));
|
2 |
$(function () {
|
3 |
var wrap = $('#wp_rp_theme_options_wrap'),
|
4 |
json_url = $('#wp_rp_json_url').val(),
|
5 |
+
plugin_version = $('#wp_rp_version').val(),
|
6 |
current_theme = $('#wp_rp_theme_selected').val(),
|
7 |
themes = null,
|
8 |
update_themes = function () {
|
|
|
|
|
9 |
wrap.empty();
|
10 |
if ($('#wp_rp_theme_title').length === 0) {
|
11 |
wrap.append('<th scope="row">Select Theme:</th>');
|
12 |
}
|
|
|
13 |
|
14 |
+
var td = $('<td />');
|
15 |
+
$.each(themes, function (i, theme) {
|
16 |
+
var selected = theme.location === current_theme ? 'checked="checked"' : '';
|
17 |
|
18 |
+
td.append('<label><input ' + selected + ' type="radio" name="wp_rp_theme" value="' + theme.location + '" /> ' + theme.name + '</label><br />');
|
19 |
+
});
|
20 |
+
wrap.append(td);
|
|
|
21 |
},
|
22 |
append_get_themes_script = function () {
|
23 |
var script = document.createElement('script'),
|
24 |
body = document.getElementsByTagName("body").item(0);
|
25 |
script.type = 'text/javascript';
|
26 |
+
script.src = json_url + 'themes.js?plv=' + plugin_version;
|
27 |
|
28 |
body.appendChild(script);
|
29 |
};
|
32 |
if (data && data.themes) {
|
33 |
themes = data.themes;
|
34 |
|
35 |
+
if(themes) {
|
36 |
+
update_themes();
|
37 |
+
}
|
38 |
}
|
39 |
};
|
40 |
|
44 |
$('#wp-rp-survey').show();
|
45 |
}
|
46 |
|
47 |
+
if (!window.localStorage || !window.localStorage.wp_rp_thumbnails_info) {
|
48 |
+
$('#wp-rp-thumbnails-info').show();
|
49 |
+
}
|
50 |
+
|
51 |
$('#wp-rp-survey .close, #wp-rp-survey .link').click(function () {
|
52 |
$('#wp-rp-survey').fadeOut();
|
53 |
if (window.localStorage) {
|
54 |
window.localStorage.wp_wp_survey_1 = "close";
|
55 |
}
|
56 |
});
|
57 |
+
|
58 |
+
$('#wp-rp-thumbnails-info .close').click(function () {
|
59 |
+
$('#wp-rp-thumbnails-info').fadeOut();
|
60 |
+
if (window.localStorage) {
|
61 |
+
window.localStorage.wp_rp_thumbnails_info = "close";
|
62 |
+
}
|
63 |
+
});
|
64 |
});
|
65 |
}(jQuery));
|
static/thumbs/0.jpg
ADDED
Binary file
|
static/thumbs/1.jpg
ADDED
Binary file
|
static/thumbs/10.jpg
ADDED
Binary file
|
static/thumbs/11.jpg
ADDED
Binary file
|
static/thumbs/12.jpg
ADDED
Binary file
|
static/thumbs/13.jpg
ADDED
Binary file
|
static/thumbs/14.jpg
ADDED
Binary file
|
static/thumbs/2.jpg
ADDED
Binary file
|
static/thumbs/3.jpg
ADDED
Binary file
|
static/thumbs/4.jpg
ADDED
Binary file
|
static/thumbs/5.jpg
ADDED
Binary file
|
static/thumbs/6.jpg
ADDED
Binary file
|
static/thumbs/7.jpg
ADDED
Binary file
|
static/thumbs/8.jpg
ADDED
Binary file
|
static/thumbs/9.jpg
ADDED
Binary file
|
thumbnailer.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wp_rp_upload_default_thumbnail_file() {
|
4 |
+
if (!empty($_FILES['wp_rp_default_thumbnail'])) {
|
5 |
+
$file = $_FILES['wp_rp_default_thumbnail'];
|
6 |
+
$upload = wp_handle_upload($file, array('test_form' => false));
|
7 |
+
|
8 |
+
if(!isset($upload['error']) && isset($upload['file'])) {
|
9 |
+
$path = image_resize($upload['file'], WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
|
10 |
+
if (!is_wp_error($path)) {
|
11 |
+
$upload_dir = wp_upload_dir();
|
12 |
+
return $upload_dir['subdir'] . '/' . wp_basename($path);
|
13 |
+
}
|
14 |
+
}
|
15 |
+
}
|
16 |
+
return false;
|
17 |
+
}
|
18 |
+
|
19 |
+
function wp_rp_get_default_thumbnail_url($seed=false) {
|
20 |
+
$wp_rp = get_option("wp_rp");
|
21 |
+
$upload_dir = wp_upload_dir();
|
22 |
+
|
23 |
+
if (isset($wp_rp['wp_rp_default_thumbnail_path']) && $wp_rp['wp_rp_default_thumbnail_path']) {
|
24 |
+
return $upload_dir['baseurl'] . $wp_rp['wp_rp_default_thumbnail_path'];
|
25 |
+
} else {
|
26 |
+
if ($seed) {
|
27 |
+
$next_seed = rand();
|
28 |
+
srand($seed);
|
29 |
+
}
|
30 |
+
$file = rand(0, WP_RP_THUMBNAILS_DEFAULTS_COUNT - 1) . '.jpg';
|
31 |
+
if ($seed) {
|
32 |
+
srand($next_seed);
|
33 |
+
}
|
34 |
+
return plugins_url('/static/thumbs/' . $file, __FILE__);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
function wp_rp_extract_post_image($post_id) {
|
39 |
+
// We don't have an image stored for this post yet - find the first uploaded image and save it
|
40 |
+
$args = array(
|
41 |
+
'post_type' => 'attachment',
|
42 |
+
'numberposts' => 1,
|
43 |
+
'post_status' => null,
|
44 |
+
'post_parent' => $post_id,
|
45 |
+
'orderby' => 'id',
|
46 |
+
'order' => 'ASC',
|
47 |
+
);
|
48 |
+
$attachments = get_posts($args);
|
49 |
+
$image_id = '-1';
|
50 |
+
if ( $attachments ) {
|
51 |
+
foreach ( $attachments as $attachment ) {
|
52 |
+
$img = wp_get_attachment_image($attachment->ID, 'thumbnail');
|
53 |
+
if($img) {
|
54 |
+
$image_id = $attachment->ID;
|
55 |
+
break;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
add_post_meta($post_id, '_wp_rp_image_id', $image_id);
|
61 |
+
return $image_id;
|
62 |
+
}
|
63 |
+
|
64 |
+
function wp_rp_show_custom_thumbnails($wp_rp) {
|
65 |
+
// If user has thumbnails on, ALWAYS start with featured image, UNLESS the following conditions hold:
|
66 |
+
// `wp_rp_thumbnail_post_meta` is set and is not "wprp_featured_image"
|
67 |
+
// AND
|
68 |
+
// `wp_rp_thumbnail_featured` is not "yes"
|
69 |
+
return isset($wp_rp["wp_rp_thumbnail_post_meta"]) && $wp_rp["wp_rp_thumbnail_post_meta"] &&
|
70 |
+
$wp_rp["wp_rp_thumbnail_post_meta"] !== 'wprp_featured_image' &&
|
71 |
+
$wp_rp["wp_rp_thumbnail_post_meta"] !== 'wp_rp_thumbnail_ignore_field'
|
72 |
+
&&
|
73 |
+
(!isset($wp_rp["wp_rp_thumbnail_featured"]) || $wp_rp["wp_rp_thumbnail_featured"] !== "yes");
|
74 |
+
}
|
75 |
+
|
76 |
+
function wp_get_post_thumbnail_img($related_post) {
|
77 |
+
$wp_rp = get_option("wp_rp");
|
78 |
+
|
79 |
+
if (!isset($wp_rp["wp_rp_thumbnail"]) || !$wp_rp["wp_rp_thumbnail"]) {
|
80 |
+
return false;
|
81 |
+
}
|
82 |
+
|
83 |
+
if (wp_rp_show_custom_thumbnails($wp_rp)) {
|
84 |
+
$thumbnail_src = get_post_meta($related_post->ID, $wp_rp["wp_rp_thumbnail_post_meta"], true);
|
85 |
+
if ($thumbnail_src) {
|
86 |
+
$img = '<img src="' . esc_attr($thumbnail_src) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
87 |
+
return $img;
|
88 |
+
}
|
89 |
+
} else if (function_exists('has_post_thumbnail') && has_post_thumbnail($related_post->ID)) {
|
90 |
+
$img = get_the_post_thumbnail($related_post->ID, 'thumbnail');
|
91 |
+
return $img;
|
92 |
+
}
|
93 |
+
|
94 |
+
if (isset($wp_rp["wp_rp_thumbnail_extract"]) && $wp_rp["wp_rp_thumbnail_extract"] === 'yes') {
|
95 |
+
$image_id = get_post_meta($related_post->ID, '_wp_rp_image_id', true);
|
96 |
+
if ($image_id === '') {
|
97 |
+
$image_id = wp_rp_extract_post_image($related_post->ID);
|
98 |
+
}
|
99 |
+
if ($image_id !== '-1') {
|
100 |
+
$img = wp_get_attachment_image($image_id, 'thumbnail');
|
101 |
+
return $img;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
$img = '<img src="'. esc_attr(wp_rp_get_default_thumbnail_url($related_post->ID)) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
106 |
+
return $img;
|
107 |
+
}
|
108 |
+
|
utils.php
CHANGED
@@ -50,7 +50,10 @@ if ( ! defined( 'WPMU_PLUGIN_DIR' ) )
|
|
50 |
define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' );
|
51 |
|
52 |
|
|
|
53 |
/* WP RP backwards compatibility */
|
|
|
|
|
54 |
function wp_random_posts ($number = 10){
|
55 |
$limitclause="LIMIT " . $number;
|
56 |
$random_posts = wp_get_random_posts ($limitclause);
|
@@ -58,7 +61,7 @@ function wp_random_posts ($number = 10){
|
|
58 |
foreach ($random_posts as $random_post ){
|
59 |
$output .= '<li>';
|
60 |
|
61 |
-
$output .= '<a href="'.get_permalink($random_post->ID).'" title="'.wptexturize($random_post->post_title).'">'.wptexturize($random_post->post_title).'</a></li>';
|
62 |
}
|
63 |
|
64 |
$output = '<ul class="randome_post">' . $output . '</ul>';
|
@@ -70,10 +73,8 @@ function wp_most_popular_posts ($number = 10){
|
|
70 |
$limitclause="LIMIT " . $number;
|
71 |
$most_popular_posts = wp_get_most_popular_posts ($limitclause);
|
72 |
|
73 |
-
foreach
|
74 |
-
$output .=
|
75 |
-
|
76 |
-
$output .= '<a href="'.get_permalink($most_popular_post->ID).'" title="'.wptexturize($most_popular_post->post_title).'">'.wptexturize($most_popular_post->post_title).'</a></li>';
|
77 |
}
|
78 |
|
79 |
$output = '<ul class="most_popular_post">' . $output . '</ul>';
|
@@ -85,10 +86,8 @@ function wp_most_commented_posts ($number = 10){
|
|
85 |
$limitclause="LIMIT " . $number;
|
86 |
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
|
87 |
|
88 |
-
foreach
|
89 |
-
$output .=
|
90 |
-
|
91 |
-
$output .= '<a href="'.get_permalink($most_commented_post->ID).'" title="'.wptexturize($most_commented_post->post_title).'">'.wptexturize($most_commented_post->post_title).'</a></li>';
|
92 |
}
|
93 |
|
94 |
$output = '<ul class="most_commented_post">' . $output . '</ul>';
|
50 |
define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' );
|
51 |
|
52 |
|
53 |
+
/* ***************************** */
|
54 |
/* WP RP backwards compatibility */
|
55 |
+
/* ***************************** */
|
56 |
+
|
57 |
function wp_random_posts ($number = 10){
|
58 |
$limitclause="LIMIT " . $number;
|
59 |
$random_posts = wp_get_random_posts ($limitclause);
|
61 |
foreach ($random_posts as $random_post ){
|
62 |
$output .= '<li>';
|
63 |
|
64 |
+
$output .= '<a href="' . get_permalink($random_post->ID) . '" title="' . esc_attr(wptexturize($random_post->post_title)) . '">' . wptexturize($random_post->post_title) . '</a></li>';
|
65 |
}
|
66 |
|
67 |
$output = '<ul class="randome_post">' . $output . '</ul>';
|
73 |
$limitclause="LIMIT " . $number;
|
74 |
$most_popular_posts = wp_get_most_popular_posts ($limitclause);
|
75 |
|
76 |
+
foreach($most_popular_posts as $most_popular_post) {
|
77 |
+
$output .= '<li><a href="' . get_permalink($most_popular_post->ID) . '" title="' . esc_attr(wptexturize($most_popular_post->post_title)) . '">' . wptexturize($most_popular_post->post_title) . '</a></li>';
|
|
|
|
|
78 |
}
|
79 |
|
80 |
$output = '<ul class="most_popular_post">' . $output . '</ul>';
|
86 |
$limitclause="LIMIT " . $number;
|
87 |
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
|
88 |
|
89 |
+
foreach($most_commented_posts as $most_commented_post) {
|
90 |
+
$output .= '<li><a href="'.get_permalink($most_commented_post->ID).'" title="' . esc_attr(wptexturize($most_commented_post->post_title)) . '">' . wptexturize($most_commented_post->post_title) . '</a></li>';
|
|
|
|
|
91 |
}
|
92 |
|
93 |
$output = '<ul class="most_commented_post">' . $output . '</ul>';
|
versions.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/* ************************* */
|
5 |
+
/* Version 1.3 */
|
6 |
+
/* ************************* */
|
7 |
+
|
8 |
+
/* Settings:
|
9 |
+
|
10 |
+
wp_no_rp what to do if there are no related posts (`text`, `random`, most `commented` posts)
|
11 |
+
wp_no_rp_text text to show if there are no realted posts
|
12 |
+
wp_rp_auto auto insert related posts
|
13 |
+
wp_rp_comments display number of comments
|
14 |
+
wp_rp_date display publish date
|
15 |
+
wp_rp_except display post excerpt
|
16 |
+
wp_rp_except_number maximum number of characters to display for excerpt
|
17 |
+
wp_rp_exclude categories to exclude
|
18 |
+
wp_rp_limit maximum number of related posts
|
19 |
+
wp_rp_rss display related posts in RSS feed
|
20 |
+
wp_rp_template unused
|
21 |
+
wp_rp_theme related posts display theme
|
22 |
+
wp_rp_thumbnail display thumbnail for related posts
|
23 |
+
wp_rp_thumbnail_post_meta meta field to use for thumbnail
|
24 |
+
wp_rp_thumbnail_text show post title under thumbnails
|
25 |
+
wp_rp_title related posts title
|
26 |
+
wp_rp_title_tag related posts title tag (e.g. h2, h3, div, ...)
|
27 |
+
|
28 |
+
*/
|
29 |
+
|
30 |
+
/* Compatibility with wp_rp 1.3 - FIXME */
|
31 |
+
$wp_rp = get_option("wp_rp");
|
32 |
+
if (!isset($wp_rp['wp_rp_thumbnail_extract']) && $wp_rp['wp_rp_thumbnail_post_meta'] === 'wprp_featured_image') {
|
33 |
+
$wp_rp['wp_rp_thumbnail_extract'] = 'yes';
|
34 |
+
|
35 |
+
update_option( "wp_rp", $wp_rp );
|
36 |
+
}
|
wp_related_posts.php
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
-
Version: 1.
|
5 |
-
Plugin URI: http://
|
6 |
Description: Generate a related posts list via tags of WordPress
|
7 |
-
Author:
|
8 |
-
Author URI: http://
|
9 |
*/
|
10 |
|
|
|
|
|
|
|
11 |
include_once dirname(__FILE__) . '/defaults.php';
|
12 |
include_once dirname(__FILE__) . '/utils.php';
|
13 |
include_once dirname(__FILE__) . '/widget.php';
|
|
|
14 |
include_once dirname(__FILE__) . '/settings.php';
|
15 |
|
16 |
add_action('init', 'init_textdomain');
|
@@ -20,16 +24,21 @@ function init_textdomain(){
|
|
20 |
|
21 |
register_activation_hook( __FILE__, 'activate_wp_related_posts' );
|
22 |
function activate_wp_related_posts() {
|
23 |
-
$wp_rp = get_option("wp_rp");
|
24 |
|
25 |
-
if (
|
26 |
-
// plain for old users, modern for new
|
27 |
// This hook doesn't fire on updates for wp >= 3.1
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
if (!isset($wp_rp['wp_rp_auto'])) {
|
@@ -56,6 +65,9 @@ function activate_wp_related_posts() {
|
|
56 |
$wp_rp['wp_no_rp_text'] = WP_RP_RELATED_FALLBACK_TITLE;
|
57 |
}
|
58 |
}
|
|
|
|
|
|
|
59 |
update_option( "wp_rp", $wp_rp );
|
60 |
}
|
61 |
|
@@ -86,11 +98,32 @@ function wp_fetch_related_posts($limitclause="") {
|
|
86 |
return $related_posts;
|
87 |
}
|
88 |
|
89 |
-
function wp_fetch_random_posts ($
|
90 |
global $wpdb, $post;
|
91 |
|
92 |
-
$
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
function wp_fetch_most_commented_posts($limitclause="") {
|
@@ -117,10 +150,11 @@ function wp_fetch_content() {
|
|
117 |
$wp_rp = get_option("wp_rp");
|
118 |
|
119 |
if (isset($wp_rp["wp_rp_limit"]) && $wp_rp["wp_rp_limit"]) {
|
120 |
-
$
|
121 |
} else {
|
122 |
-
$
|
123 |
}
|
|
|
124 |
|
125 |
$wp_rp_title = isset($wp_rp["wp_rp_title"]) ? $wp_rp["wp_rp_title"] : "";
|
126 |
$related_posts = wp_fetch_related_posts($limitclause);
|
@@ -137,14 +171,14 @@ function wp_fetch_content() {
|
|
137 |
$wp_rp_title = "";
|
138 |
}
|
139 |
|
140 |
-
if ($wp_no_rp
|
|
|
|
|
141 |
$related_posts = wp_fetch_most_commented_posts($limitclause);
|
142 |
-
} else if ($wp_no_rp
|
143 |
$related_posts = wp_fetch_most_popular_posts($limitclause);
|
144 |
-
} else
|
145 |
-
$related_posts =
|
146 |
-
} else { // random
|
147 |
-
$related_posts = wp_fetch_random_posts($limitclause);
|
148 |
}
|
149 |
}
|
150 |
|
@@ -154,26 +188,6 @@ function wp_fetch_content() {
|
|
154 |
);
|
155 |
}
|
156 |
|
157 |
-
function wp_get_post_thumbnail_img($related_post) {
|
158 |
-
$wp_rp = get_option("wp_rp");
|
159 |
-
|
160 |
-
$img = false;
|
161 |
-
if (isset($wp_rp["wp_rp_thumbnail"]) && $wp_rp["wp_rp_thumbnail"] && isset($wp_rp["wp_rp_thumbnail_post_meta"]) && $wp_rp["wp_rp_thumbnail_post_meta"]) {
|
162 |
-
if ($wp_rp["wp_rp_thumbnail_post_meta"] === 'wprp_featured_image') {
|
163 |
-
if (function_exists('has_post_thumbnail') && has_post_thumbnail($related_post->ID)) {
|
164 |
-
$img = get_the_post_thumbnail($related_post->ID, 'thumbnail');
|
165 |
-
}
|
166 |
-
} else {
|
167 |
-
$thumbnail_src = get_post_meta($related_post->ID, $wp_rp["wp_rp_thumbnail_post_meta"], true);
|
168 |
-
if ($thumbnail_src) {
|
169 |
-
$img = '<img src="'. $thumbnail_src .'" alt="'.wptexturize($related_post->post_title).'" />';
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
return $img;
|
175 |
-
}
|
176 |
-
|
177 |
function wp_generate_related_posts_list_items($related_posts) {
|
178 |
$wp_rp = get_option("wp_rp");
|
179 |
$output = "";
|
@@ -183,7 +197,7 @@ function wp_generate_related_posts_list_items($related_posts) {
|
|
183 |
|
184 |
$img = wp_get_post_thumbnail_img($related_post);
|
185 |
if ($img) {
|
186 |
-
$output .= '<a href="'.get_permalink($related_post->ID).'" title="'.wptexturize($related_post->post_title).'">' . $img . '</a>';
|
187 |
}
|
188 |
|
189 |
if (!$wp_rp["wp_rp_thumbnail"] || ($wp_rp["wp_rp_thumbnail"] && ($wp_rp["wp_rp_thumbnail_text"] || !$img))) {
|
@@ -192,7 +206,7 @@ function wp_generate_related_posts_list_items($related_posts) {
|
|
192 |
$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
|
193 |
}
|
194 |
|
195 |
-
$output .= '<a href="'.get_permalink($related_post->ID).'" title="'.wptexturize($related_post->post_title).'">'.wptexturize($related_post->post_title).'</a>';
|
196 |
|
197 |
if ($wp_rp["wp_rp_comments"]){
|
198 |
$output .= " (" . $related_post->comment_count . ")";
|
@@ -249,7 +263,12 @@ function wp_get_related_posts($before_title="", $after_title="") {
|
|
249 |
$wp_rp_title = $content['title'];
|
250 |
|
251 |
$wp_rp_theme = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : WP_RP_THEME_PLAIN;
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
if ($related_posts) {
|
255 |
$output = wp_generate_related_posts_list_items($related_posts);
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
+
Version: 1.4
|
5 |
+
Plugin URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
6 |
Description: Generate a related posts list via tags of WordPress
|
7 |
+
Author: Jure Ham
|
8 |
+
Author URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
9 |
*/
|
10 |
|
11 |
+
define( 'WP_RP_VERSION', '1.4' );
|
12 |
+
|
13 |
+
include_once dirname(__FILE__) . '/versions.php';
|
14 |
include_once dirname(__FILE__) . '/defaults.php';
|
15 |
include_once dirname(__FILE__) . '/utils.php';
|
16 |
include_once dirname(__FILE__) . '/widget.php';
|
17 |
+
include_once dirname(__FILE__) . '/thumbnailer.php';
|
18 |
include_once dirname(__FILE__) . '/settings.php';
|
19 |
|
20 |
add_action('init', 'init_textdomain');
|
24 |
|
25 |
register_activation_hook( __FILE__, 'activate_wp_related_posts' );
|
26 |
function activate_wp_related_posts() {
|
27 |
+
$wp_rp = get_option("wp_rp", array());
|
28 |
|
29 |
+
if (count($wp_rp) === 0) { // this is a new user...
|
|
|
30 |
// This hook doesn't fire on updates for wp >= 3.1
|
31 |
+
$wp_rp['wp_rp_log_new_user'] = true;
|
32 |
+
$wp_rp['wp_rp_thumbnail'] = 'yes';
|
33 |
+
// default theme for new users
|
34 |
+
$wp_rp['wp_rp_theme'] = WP_RP_THEME_DEFAULT;
|
35 |
+
}
|
36 |
+
|
37 |
+
$wp_rp['wp_rp_version'] = WP_RP_VERSION;
|
38 |
+
|
39 |
+
if (!isset($wp_rp['wp_rp_theme'])) {
|
40 |
+
// keep plain theme for old users for backwards compatibility
|
41 |
+
$wp_rp['wp_rp_theme'] = WP_RP_THEME_PLAIN;
|
42 |
}
|
43 |
|
44 |
if (!isset($wp_rp['wp_rp_auto'])) {
|
65 |
$wp_rp['wp_no_rp_text'] = WP_RP_RELATED_FALLBACK_TITLE;
|
66 |
}
|
67 |
}
|
68 |
+
if (!isset($wp_rp['wp_rp_thumbnail_extract'])) {
|
69 |
+
$wp_rp['wp_rp_thumbnail_extract'] = 'yes';
|
70 |
+
}
|
71 |
update_option( "wp_rp", $wp_rp );
|
72 |
}
|
73 |
|
98 |
return $related_posts;
|
99 |
}
|
100 |
|
101 |
+
function wp_fetch_random_posts ($limit = 10) {
|
102 |
global $wpdb, $post;
|
103 |
|
104 |
+
$q1 = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND ID != $post->ID";
|
105 |
+
|
106 |
+
$ids = $wpdb->get_col($q1, 0);
|
107 |
+
$count = count($ids);
|
108 |
+
if($count <= 1) {
|
109 |
+
if($count === 0) return false;
|
110 |
+
if($count === 1) $rnd = $ids;
|
111 |
+
} else {
|
112 |
+
$next_seed = rand();
|
113 |
+
$t = time();
|
114 |
+
$seed = $t - $t % 300 + $post->ID << 4; // We keep the same seed for 5 minutes, so MySQL can cache the `q2` query.
|
115 |
+
srand($seed);
|
116 |
+
$rnd = array_rand($ids, min($limit, $count)); // This is an array of random indexes, sorted
|
117 |
+
shuffle($rnd);
|
118 |
+
foreach ($rnd as &$i) { // Here, index is passed by reference, so we can modify it
|
119 |
+
$i = $ids[$i]; // Replace indexes with corresponding IDs
|
120 |
+
}
|
121 |
+
$ids = $rnd;
|
122 |
+
srand($next_seed);
|
123 |
+
}
|
124 |
+
|
125 |
+
$q2 = "SELECT ID, post_title, post_content, post_excerpt, post_date, comment_count FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND ID IN (" . implode(',', $ids) . ")";
|
126 |
+
return $wpdb->get_results($q2);
|
127 |
}
|
128 |
|
129 |
function wp_fetch_most_commented_posts($limitclause="") {
|
150 |
$wp_rp = get_option("wp_rp");
|
151 |
|
152 |
if (isset($wp_rp["wp_rp_limit"]) && $wp_rp["wp_rp_limit"]) {
|
153 |
+
$limit = $wp_rp["wp_rp_limit"];
|
154 |
} else {
|
155 |
+
$limit = WP_RP_POST_LIMIT;
|
156 |
}
|
157 |
+
$limitclause = "LIMIT $limit";
|
158 |
|
159 |
$wp_rp_title = isset($wp_rp["wp_rp_title"]) ? $wp_rp["wp_rp_title"] : "";
|
160 |
$related_posts = wp_fetch_related_posts($limitclause);
|
171 |
$wp_rp_title = "";
|
172 |
}
|
173 |
|
174 |
+
if ($wp_no_rp == "text") {
|
175 |
+
$related_posts = false;
|
176 |
+
} else if ($wp_no_rp === "commented") {
|
177 |
$related_posts = wp_fetch_most_commented_posts($limitclause);
|
178 |
+
} else if ($wp_no_rp == "popularity" && function_exists('akpc_most_popular')) {
|
179 |
$related_posts = wp_fetch_most_popular_posts($limitclause);
|
180 |
+
} else {
|
181 |
+
$related_posts = wp_fetch_random_posts($limit);
|
|
|
|
|
182 |
}
|
183 |
}
|
184 |
|
188 |
);
|
189 |
}
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
function wp_generate_related_posts_list_items($related_posts) {
|
192 |
$wp_rp = get_option("wp_rp");
|
193 |
$output = "";
|
197 |
|
198 |
$img = wp_get_post_thumbnail_img($related_post);
|
199 |
if ($img) {
|
200 |
+
$output .= '<a href="' . get_permalink($related_post->ID) . '" title="' . esc_attr(wptexturize($related_post->post_title)) . '">' . $img . '</a>';
|
201 |
}
|
202 |
|
203 |
if (!$wp_rp["wp_rp_thumbnail"] || ($wp_rp["wp_rp_thumbnail"] && ($wp_rp["wp_rp_thumbnail_text"] || !$img))) {
|
206 |
$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
|
207 |
}
|
208 |
|
209 |
+
$output .= '<a href="' . get_permalink($related_post->ID) . '" title="' . esc_attr(wptexturize($related_post->post_title)) . '">' . wptexturize($related_post->post_title) . '</a>';
|
210 |
|
211 |
if ($wp_rp["wp_rp_comments"]){
|
212 |
$output .= " (" . $related_post->comment_count . ")";
|
263 |
$wp_rp_title = $content['title'];
|
264 |
|
265 |
$wp_rp_theme = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : WP_RP_THEME_PLAIN;
|
266 |
+
|
267 |
+
if (isset($wp_rp["wp_rp_thumbnail"]) && $wp_rp["wp_rp_thumbnail"]) {
|
268 |
+
$wp_rp_theme_url = WP_RP_STATIC_BASE_URL . WP_RP_THEMES_THUMBNAILS_PATH . $wp_rp_theme;
|
269 |
+
} else {
|
270 |
+
$wp_rp_theme_url = WP_RP_STATIC_BASE_URL . WP_RP_THEMES_PATH . $wp_rp_theme;
|
271 |
+
}
|
272 |
|
273 |
if ($related_posts) {
|
274 |
$output = wp_generate_related_posts_list_items($related_posts);
|