Version Description
- Code cleanup
- First two CSS themes added to Settings. More designs to come.
- WordPress featured images are now used for related post thumbnails
- Bugfix: Filter HTML and WP tags from post excerpts
Download this release
Release Info
Developer | jureham |
Plugin | WordPress Related Posts |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.3
- Thumbs.db +0 -0
- defaults.php +15 -0
- lang/default.po +22 -7
- lang/wp_related_posts-zh_CN.mo +0 -0
- lang/wp_related_posts-zh_CN.po +27 -29
- readme.txt +11 -4
- screenshot-1.jpg +0 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- settings.php +249 -0
- static/settings.js.php +66 -0
- static/themes.js +55 -0
- utils.php +120 -0
- widget.php +17 -0
- wp_related_posts.php +216 -434
Thumbs.db
DELETED
Binary file
|
defaults.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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", "modern.css");
|
6 |
+
define("WP_RP_THEME_PLAIN", "plain.css");
|
7 |
+
|
8 |
+
define("WP_RP_TITLE_TAG_DEFAULT", "h3");
|
9 |
+
|
10 |
+
define("WP_RP_AUTO_APPEND", true);
|
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");
|
lang/default.po
CHANGED
@@ -76,7 +76,19 @@ msgid "<a href=\"http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plug
|
|
76 |
msgstr ""
|
77 |
|
78 |
#: ../wp_related_posts.php:332
|
79 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
msgstr ""
|
81 |
|
82 |
#: ../wp_related_posts.php:335
|
@@ -128,15 +140,15 @@ msgid "Display Related Posts on Feed?"
|
|
128 |
msgstr ""
|
129 |
|
130 |
#: ../wp_related_posts.php:399
|
131 |
-
msgid "
|
132 |
msgstr ""
|
133 |
|
134 |
#: ../wp_related_posts.php:403
|
135 |
-
msgid "Display Post
|
136 |
msgstr ""
|
137 |
|
138 |
#: ../wp_related_posts.php:407
|
139 |
-
msgid "Maximum Charaters of
|
140 |
msgstr ""
|
141 |
|
142 |
#: ../wp_related_posts.php:412
|
@@ -156,7 +168,7 @@ msgid "Related Posts with Thumbnail"
|
|
156 |
msgstr ""
|
157 |
|
158 |
#: ../wp_related_posts.php:455
|
159 |
-
msgid "
|
160 |
msgstr ""
|
161 |
|
162 |
#: ../wp_related_posts.php:459
|
@@ -172,10 +184,13 @@ msgid "Do you still want to display text when display thumbnails for related pos
|
|
172 |
msgstr ""
|
173 |
|
174 |
#: ../wp_related_posts.php:468
|
175 |
-
msgid "Which
|
|
|
|
|
|
|
|
|
176 |
msgstr ""
|
177 |
|
178 |
#: ../wp_related_posts.php:486
|
179 |
msgid "Save changes"
|
180 |
msgstr ""
|
181 |
-
|
76 |
msgstr ""
|
77 |
|
78 |
#: ../wp_related_posts.php:332
|
79 |
+
msgid "If you need assistance please contact"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: ../wp_related_posts.php:332
|
83 |
+
msgid "support"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: ../wp_related_posts.php:332
|
87 |
+
msgid "Please fill out"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: ../wp_related_posts.php:332
|
91 |
+
msgid "a quick survey"
|
92 |
msgstr ""
|
93 |
|
94 |
#: ../wp_related_posts.php:335
|
140 |
msgstr ""
|
141 |
|
142 |
#: ../wp_related_posts.php:399
|
143 |
+
msgid "Excerpt Setting:"
|
144 |
msgstr ""
|
145 |
|
146 |
#: ../wp_related_posts.php:403
|
147 |
+
msgid "Display Post Excerpt?"
|
148 |
msgstr ""
|
149 |
|
150 |
#: ../wp_related_posts.php:407
|
151 |
+
msgid "Maximum Charaters of Excerpt."
|
152 |
msgstr ""
|
153 |
|
154 |
#: ../wp_related_posts.php:412
|
168 |
msgstr ""
|
169 |
|
170 |
#: ../wp_related_posts.php:455
|
171 |
+
msgid "Before using Related Posts with Thumbnail, you must set thumbnail image for your every post."
|
172 |
msgstr ""
|
173 |
|
174 |
#: ../wp_related_posts.php:459
|
184 |
msgstr ""
|
185 |
|
186 |
#: ../wp_related_posts.php:468
|
187 |
+
msgid "Which field is used for thumbnail?"
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: ../wp_related_posts.php:468
|
191 |
+
msgid "Use Featured Image"
|
192 |
msgstr ""
|
193 |
|
194 |
#: ../wp_related_posts.php:486
|
195 |
msgid "Save changes"
|
196 |
msgstr ""
|
|
lang/wp_related_posts-zh_CN.mo
CHANGED
Binary file
|
lang/wp_related_posts-zh_CN.po
CHANGED
@@ -3,8 +3,8 @@ msgstr ""
|
|
3 |
"Project-Id-Version: WordPress 2.3 Related Posts Plugin v0.2\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: 2009-09-30 21:04+0800\n"
|
6 |
-
"PO-Revision-Date:
|
7 |
-
"Last-Translator:
|
8 |
"Language-Team: WordPress 中文团队 <team@wp-cn.com>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
@@ -72,12 +72,24 @@ msgid "Related Posts Settings"
|
|
72 |
msgstr "相关日志设置"
|
73 |
|
74 |
#: ../wp_related_posts.php:331
|
75 |
-
msgid "
|
76 |
-
msgstr "
|
77 |
|
78 |
#: ../wp_related_posts.php:332
|
79 |
-
msgid "
|
80 |
-
msgstr "你在使用这个插件的时候如果有任何问题或者需要帮助,请联系
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
#: ../wp_related_posts.php:335
|
83 |
msgid "Do you like this Plugin? Consider to donate!"
|
@@ -128,15 +140,15 @@ msgid "Display Related Posts on Feed?"
|
|
128 |
msgstr "在RSS中添加相关日志?"
|
129 |
|
130 |
#: ../wp_related_posts.php:399
|
131 |
-
msgid "
|
132 |
msgstr "摘要设置:"
|
133 |
|
134 |
#: ../wp_related_posts.php:403
|
135 |
-
msgid "Display Post
|
136 |
msgstr "显示日志摘要?"
|
137 |
|
138 |
#: ../wp_related_posts.php:407
|
139 |
-
msgid "Maximum Charaters of
|
140 |
msgstr "摘要的最大文本。"
|
141 |
|
142 |
#: ../wp_related_posts.php:412
|
@@ -156,7 +168,7 @@ msgid "Related Posts with Thumbnail"
|
|
156 |
msgstr "给相关日志显示缩略图"
|
157 |
|
158 |
#: ../wp_related_posts.php:455
|
159 |
-
msgid "
|
160 |
msgstr "在使用给相关日志显示缩略图这个功能之前,你要确保你每篇日志都有缩略图。"
|
161 |
|
162 |
#: ../wp_related_posts.php:459
|
@@ -172,28 +184,14 @@ msgid "Do you still want to display text when display thumbnails for related pos
|
|
172 |
msgstr "在使用给相关日志显示缩略图的同时还显示相关日志的标题等文本?"
|
173 |
|
174 |
#: ../wp_related_posts.php:468
|
175 |
-
msgid "Which
|
176 |
msgstr "哪个自定义字段是用于缩略图的?"
|
177 |
|
|
|
|
|
|
|
|
|
178 |
#: ../wp_related_posts.php:486
|
179 |
msgid "Save changes"
|
180 |
msgstr "保存修改"
|
181 |
|
182 |
-
#~ msgid ""
|
183 |
-
#~ "Any problem, please contact <a href=\"http://twitter.com/denishua/"
|
184 |
-
#~ "\">denishua</a>."
|
185 |
-
#~ msgstr ""
|
186 |
-
#~ "有任何问题,请联系 <a href=\"http://twitter.com/denishua/\">denishua</a>。"
|
187 |
-
#~ msgid "Something wrong"
|
188 |
-
#~ msgstr "发生错误了"
|
189 |
-
#~ msgid "Related Posts Options…"
|
190 |
-
#~ msgstr "相关日志选项 …"
|
191 |
-
#~ msgid "Related Posts Preference"
|
192 |
-
#~ msgstr "相关日志设置"
|
193 |
-
#~ msgid "When No Related Posts, Dispaly:"
|
194 |
-
#~ msgstr "当没有相关日志时,显示:"
|
195 |
-
#~ msgid "Limit:"
|
196 |
-
#~ msgstr "显示的项数:"
|
197 |
-
#~ msgid "Update Preferences »"
|
198 |
-
#~ msgstr "更新选项 »"
|
199 |
-
|
3 |
"Project-Id-Version: WordPress 2.3 Related Posts Plugin v0.2\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: 2009-09-30 21:04+0800\n"
|
6 |
+
"PO-Revision-Date: 2012-09-11 16:06+0100\n"
|
7 |
+
"Last-Translator: Jure Ham <jure@hamax.si>\n"
|
8 |
"Language-Team: WordPress 中文团队 <team@wp-cn.com>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
72 |
msgstr "相关日志设置"
|
73 |
|
74 |
#: ../wp_related_posts.php:331
|
75 |
+
msgid "WordPress Related Posts Plugin can generate a related posts list via WordPress tags, and add the related posts to feed."
|
76 |
+
msgstr "WordPress 相关日志插件 可以通过 WordPress 的标签系统产生一个相关日志列表,并可以添加相关日志至 RSS 中。"
|
77 |
|
78 |
#: ../wp_related_posts.php:332
|
79 |
+
msgid "If you need assistance please contact"
|
80 |
+
msgstr "你在使用这个插件的时候如果有任何问题或者需要帮助,请联系"
|
81 |
+
|
82 |
+
#: ../wp_related_posts.php:332
|
83 |
+
msgid "support"
|
84 |
+
msgstr "支援"
|
85 |
+
|
86 |
+
#: ../wp_related_posts.php:332
|
87 |
+
msgid "Please fill out"
|
88 |
+
msgstr "请填写"
|
89 |
+
|
90 |
+
#: ../wp_related_posts.php:332
|
91 |
+
msgid "a quick survey"
|
92 |
+
msgstr "调查"
|
93 |
|
94 |
#: ../wp_related_posts.php:335
|
95 |
msgid "Do you like this Plugin? Consider to donate!"
|
140 |
msgstr "在RSS中添加相关日志?"
|
141 |
|
142 |
#: ../wp_related_posts.php:399
|
143 |
+
msgid "Excerpt Setting:"
|
144 |
msgstr "摘要设置:"
|
145 |
|
146 |
#: ../wp_related_posts.php:403
|
147 |
+
msgid "Display Post Excerpt?"
|
148 |
msgstr "显示日志摘要?"
|
149 |
|
150 |
#: ../wp_related_posts.php:407
|
151 |
+
msgid "Maximum Charaters of Excerpt."
|
152 |
msgstr "摘要的最大文本。"
|
153 |
|
154 |
#: ../wp_related_posts.php:412
|
168 |
msgstr "给相关日志显示缩略图"
|
169 |
|
170 |
#: ../wp_related_posts.php:455
|
171 |
+
msgid "Before using Related Posts with Thumbnail, you must set thumbnail image for your every post."
|
172 |
msgstr "在使用给相关日志显示缩略图这个功能之前,你要确保你每篇日志都有缩略图。"
|
173 |
|
174 |
#: ../wp_related_posts.php:459
|
184 |
msgstr "在使用给相关日志显示缩略图的同时还显示相关日志的标题等文本?"
|
185 |
|
186 |
#: ../wp_related_posts.php:468
|
187 |
+
msgid "Which field is used for thumbnail?"
|
188 |
msgstr "哪个自定义字段是用于缩略图的?"
|
189 |
|
190 |
+
#: ../wp_related_posts.php:468
|
191 |
+
msgid "Use Featured Image"
|
192 |
+
msgstr "使用WordPress特色图片"
|
193 |
+
|
194 |
#: ../wp_related_posts.php:486
|
195 |
msgid "Save changes"
|
196 |
msgstr "保存修改"
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: Related,Posts
|
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8490579
|
5 |
Requires at least: 2.3
|
6 |
Tested up to: 3.4.1
|
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 |
|
@@ -21,11 +21,18 @@ Please search and submit your transaltion here: <a href="http://fairyfish.net/20
|
|
21 |
1. Navigate to Manage > Option > WordPress Related Posts to configure plugin output.
|
22 |
|
23 |
== Screenshots ==
|
24 |
-
1. WordPress Related Posts
|
|
|
25 |
|
26 |
|
27 |
== Changelog ==
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
= 1.2.1 =
|
30 |
* Sane defaults
|
31 |
|
@@ -37,8 +44,8 @@ Please search and submit your transaltion here: <a href="http://fairyfish.net/20
|
|
37 |
|
38 |
= 1.1 =
|
39 |
* Thumbnail
|
40 |
-
* Post
|
41 |
* Widget
|
42 |
|
43 |
= 1.0 =
|
44 |
-
* first version
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8490579
|
5 |
Requires at least: 2.3
|
6 |
Tested up to: 3.4.1
|
7 |
+
Stable tag: 1.3
|
8 |
|
9 |
WordPress Related Posts Plugin will generate a related posts via WordPress tags, and add the related posts to feed.
|
10 |
|
21 |
1. Navigate to Manage > Option > WordPress Related Posts to configure plugin output.
|
22 |
|
23 |
== Screenshots ==
|
24 |
+
1. WordPress Related Posts default theme.
|
25 |
+
2. WordPress Related Posts setting.
|
26 |
|
27 |
|
28 |
== Changelog ==
|
29 |
|
30 |
+
= 1.3 =
|
31 |
+
* Code cleanup
|
32 |
+
* First two CSS themes added to Settings. More designs to come.
|
33 |
+
* WordPress featured images are now used for related post thumbnails
|
34 |
+
* Bugfix: Filter HTML and WP tags from post excerpts
|
35 |
+
|
36 |
= 1.2.1 =
|
37 |
* Sane defaults
|
38 |
|
44 |
|
45 |
= 1.1 =
|
46 |
* Thumbnail
|
47 |
+
* Post Excerpt
|
48 |
* Widget
|
49 |
|
50 |
= 1.0 =
|
51 |
+
* first version
|
screenshot-1.jpg
DELETED
Binary file
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
settings.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action('admin_menu', 'wp_add_related_posts_options_page');
|
4 |
+
|
5 |
+
function wp_add_related_posts_options_page() {
|
6 |
+
$page = add_options_page(__('Related Posts','wp_related_posts'), __('Related Posts','wp_related_posts'), 'manage_options', 'wordpress-related-posts', 'wp_related_posts_options_subpanel');
|
7 |
+
|
8 |
+
add_action('admin_print_scripts-' . $page, 'wp_rp_themes_scripts');
|
9 |
+
}
|
10 |
+
|
11 |
+
function wp_rp_themes_scripts() {
|
12 |
+
$plugin_path = path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) ));
|
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() {
|
17 |
+
if (isset($_POST["wp_rp_Submit"]) && $_POST["wp_rp_Submit"]){
|
18 |
+
$message = __("WordPress Related Posts Setting Updated",'wp_related_posts');
|
19 |
+
|
20 |
+
$wp_rp_saved = get_option("wp_rp");
|
21 |
+
|
22 |
+
$wp_rp = array (
|
23 |
+
"wp_rp_title" => isset($_POST['wp_rp_title_option']) ? trim($_POST['wp_rp_title_option']) : false,
|
24 |
+
"wp_rp_title_tag" => isset($_POST['wp_rp_title_tag_option']) ? trim($_POST['wp_rp_title_tag_option']) : false,
|
25 |
+
"wp_no_rp" => isset($_POST['wp_no_rp_option']) ? trim($_POST['wp_no_rp_option']) : false,
|
26 |
+
"wp_no_rp_text" => isset($_POST['wp_no_rp_text_option']) ? trim($_POST['wp_no_rp_text_option']) : false,
|
27 |
+
"wp_rp_except" => isset($_POST['wp_rp_except_option']) ? trim($_POST['wp_rp_except_option']) : false,
|
28 |
+
"wp_rp_except_number" => isset($_POST['wp_rp_except_number_option']) ? trim($_POST['wp_rp_except_number_option']) : false,
|
29 |
+
"wp_rp_limit" => isset($_POST['wp_rp_limit_option']) ? trim($_POST['wp_rp_limit_option']) : false,
|
30 |
+
'wp_rp_exclude' => isset($_POST['wp_rp_exclude_option']) ? join(',', $_POST['wp_rp_exclude_option']) : false,
|
31 |
+
'wp_rp_auto' => isset($_POST['wp_rp_auto_option']) ? trim($_POST['wp_rp_auto_option']) : false,
|
32 |
+
'wp_rp_rss' => isset($_POST['wp_rp_rss_option']) ? trim($_POST['wp_rp_rss_option']) : false,
|
33 |
+
'wp_rp_comments' => isset($_POST['wp_rp_comments_option']) ? trim($_POST['wp_rp_comments_option']) : false,
|
34 |
+
'wp_rp_date' => isset($_POST['wp_rp_date_option']) ? trim($_POST['wp_rp_date_option']) : false,
|
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";
|
44 |
+
|
45 |
+
echo '<div id="message" class="updated fade"><p>'.$message.'.</p></div>';
|
46 |
+
}
|
47 |
+
|
48 |
+
$wp_rp = get_option("wp_rp");
|
49 |
+
|
50 |
+
?>
|
51 |
+
|
52 |
+
<div class="wrap">
|
53 |
+
<?php
|
54 |
+
$wp_no_rp = $wp_rp["wp_no_rp"];
|
55 |
+
$wp_rp_title_tag = $wp_rp["wp_rp_title_tag"];
|
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">
|
77 |
+
<th scope="row"><?php _e("Related Posts Title:",'wp_related_posts'); ?></th>
|
78 |
+
<td>
|
79 |
+
<input name="wp_rp_title_option" type="text" id="wp_rp_title" value="<?php echo $wp_rp["wp_rp_title"]; ?>" class="regular-text" />
|
80 |
+
</td>
|
81 |
+
</tr>
|
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="text" id="wp_rp_limit" value="<?php echo $wp_rp["wp_rp_limit"]; ?>" />
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
<tr valign="top">
|
89 |
+
<th scope="row"><?php _e("Categories to Exclude:",'wp_related_posts');?></th>
|
90 |
+
<td>
|
91 |
+
<?php
|
92 |
+
$exclude = explode(",",$wp_rp["wp_rp_exclude"]);
|
93 |
+
$args = array(
|
94 |
+
'orderby' => 'name',
|
95 |
+
'order' => 'ASC',
|
96 |
+
'hide_empty' => false
|
97 |
+
);
|
98 |
+
foreach (get_categories($args) as $categorie) {
|
99 |
+
?>
|
100 |
+
<label>
|
101 |
+
<input name="wp_rp_exclude_option[]" type="checkbox" id="wp_rp_exclude" value="<?=$categorie->cat_ID?>" <?= in_array($categorie->cat_ID, $exclude) ? "checked=\"checked\"" : ""; ?> />
|
102 |
+
<?=$categorie->cat_name?>
|
103 |
+
<br />
|
104 |
+
</label>
|
105 |
+
<?php } ?>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
</table>
|
109 |
+
<h3>Theme Settings <small style="color: #c33;">(new)</small></h3>
|
110 |
+
<table class="form-table">
|
111 |
+
<tr id="wp_rp_theme_options_wrap"></tr>
|
112 |
+
<tr>
|
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" <?php echo ($wp_rp["wp_rp_thumbnail"] == 'yes') ? 'checked' : ''; ?> onclick="wp_rp_thumbnail_onclick();" >
|
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 echo ($wp_rp["wp_rp_thumbnail_text"] == 'yes') ? 'checked' : ''; ?>>
|
123 |
+
<?php _e("Do you still want to display text when display thumbnails for related posts?",'wp_related_posts');?>
|
124 |
+
</label>
|
125 |
+
<br />
|
126 |
+
<br />
|
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>
|
150 |
+
<tr>
|
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" <?php echo ($wp_rp["wp_rp_comments"] == 'yes') ? 'checked' : ''; ?>>
|
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" <?php echo ($wp_rp["wp_rp_date"] == 'yes') ? 'checked' : ''; ?>>
|
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" <?php echo ($wp_rp["wp_rp_except"] == 'yes') ? 'checked' : ''; ?> onclick="wp_rp_except_onclick();" >
|
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;'; ?>">
|
168 |
+
<input name="wp_rp_except_number_option" type="text" id="wp_rp_except_number" value="<?php echo ($wp_rp["wp_rp_except_number"]); ?> " /> <span class="description"><?php _e('Maximum Number of Characters.','wp_related_posts'); ?></span>
|
169 |
+
</label>
|
170 |
+
<br />
|
171 |
+
<label for="wp_rp_title_tag">
|
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 |
+
if (!isset($wp_rp_title_tag) || $wp_rp_title_tag == 0 ) {
|
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; ?>" <?php if($wp_rp_title_tag == $wp_rp_title_tag_a) echo 'selected' ?> ><<?php echo $wp_rp_title_tag_a; ?>></option>
|
182 |
+
<?php
|
183 |
+
}
|
184 |
+
?>
|
185 |
+
</select>
|
186 |
+
</label>
|
187 |
+
</td>
|
188 |
+
</tr>
|
189 |
+
</table>
|
190 |
+
|
191 |
+
<h3><?php _e("If there are no related posts",'wp_related_posts');?></h3>
|
192 |
+
<table class="form-table">
|
193 |
+
<tr valign="top">
|
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" <?php if($wp_no_rp == 'text') echo 'selected' ?> ><?php _e("Text: 'No Related Posts'",'wp_related_posts'); ?></option>
|
198 |
+
<option value="random" <?php if($wp_no_rp == 'random') echo 'selected' ?>><?php _e("Random Posts",'wp_related_posts'); ?></option>
|
199 |
+
<option value="commented" <?php if($wp_no_rp == 'commented') echo 'selected' ?>><?php _e("Most Commented Posts",'wp_related_posts'); ?></option>
|
200 |
+
<?php if (function_exists('akpc_most_popular')){ ?>
|
201 |
+
<option value="popularity" <?php if($wp_no_rp == 'popularity') echo 'selected' ?>><?php _e("Most Popular Posts",'wp_related_posts'); ?></option>
|
202 |
+
<?php } ?>
|
203 |
+
</select>
|
204 |
+
</td>
|
205 |
+
</tr>
|
206 |
+
<tr valign="top" scope="row">
|
207 |
+
<th id="wp_no_rp_title" scope="row">
|
208 |
+
<?php
|
209 |
+
switch ($wp_no_rp){
|
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 |
+
?>
|
224 |
+
</th>
|
225 |
+
<td>
|
226 |
+
<input name="wp_no_rp_text_option" type="text" id="wp_no_rp_text" value="<?php echo $wp_rp["wp_no_rp_text"]; ?>" class="regular-text" />
|
227 |
+
</td>
|
228 |
+
</tr>
|
229 |
+
</table>
|
230 |
+
<table class="form-table">
|
231 |
+
<h3><?php _e("Other Settings:",'wp_related_posts'); ?></h3>
|
232 |
+
<tr valign="top">
|
233 |
+
<td>
|
234 |
+
<label>
|
235 |
+
<input name="wp_rp_auto_option" type="checkbox" id="wp_rp_auto" value="yes" <?php echo ($wp_rp["wp_rp_auto"] == 'yes') ? 'checked' : ''; ?>>
|
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" <?php echo ($wp_rp["wp_rp_rss"] == 'yes') ? 'checked' : ''; ?>>
|
241 |
+
<?php _e("Display Related Posts in Feed",'wp_related_posts');?>
|
242 |
+
</label>
|
243 |
+
</td>
|
244 |
+
</tr>
|
245 |
+
</table>
|
246 |
+
<p class="submit"><input type="submit" value="<?php _e("Save changes",'wp_related_posts');?>" name="wp_rp_Submit" class="button-primary" /></p>
|
247 |
+
</form>
|
248 |
+
</div>
|
249 |
+
<?php }
|
static/settings.js.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
function wp_no_rp_onchange(){
|
3 |
+
var wp_no_rp = document.getElementById('wp_no_rp');
|
4 |
+
var wp_no_rp_title = document.getElementById('wp_no_rp_title');
|
5 |
+
var wp_no_rp_text = document.getElementById('wp_no_rp_text');
|
6 |
+
switch(wp_no_rp.value){
|
7 |
+
case 'text':
|
8 |
+
wp_no_rp_title.innerHTML = '<?php _e("No Related Posts Text:",'wp_related_posts'); ?>';
|
9 |
+
wp_no_rp_text.value = '<?php _e("No Related Posts",'wp_related_posts'); ?>';
|
10 |
+
break;
|
11 |
+
case 'random':
|
12 |
+
wp_no_rp_title.innerHTML = '<?php _e("Random Posts Title:",'wp_related_posts'); ?>';
|
13 |
+
wp_no_rp_text.value = '<?php _e("Random Posts",'wp_related_posts'); ?>';
|
14 |
+
break;
|
15 |
+
case 'commented':
|
16 |
+
wp_no_rp_title.innerHTML = '<?php _e("Most Commented Posts Title:",'wp_related_posts'); ?>';
|
17 |
+
wp_no_rp_text.value = '<?php _e("Most Commented Posts",'wp_related_posts'); ?>';
|
18 |
+
break;
|
19 |
+
case 'popularity':
|
20 |
+
wp_no_rp_title.innerHTML = '<?php _e("Most Popular Posts Title:",'wp_related_posts'); ?>';
|
21 |
+
wp_no_rp_text.value = '<?php _e("Most Popular Posts",'wp_related_posts'); ?>';
|
22 |
+
break;
|
23 |
+
default:
|
24 |
+
wp_no_rp_title.innerHTML = '';
|
25 |
+
}
|
26 |
+
if(wp_no_rp.value == '<?php echo $wp_no_rp;?>'){
|
27 |
+
wp_no_rp_text.value = '<?php echo $wp_rp["wp_no_rp_text"];?>';
|
28 |
+
}
|
29 |
+
}
|
30 |
+
function wp_rp_except_onclick(){
|
31 |
+
var wp_rp_except = document.getElementById('wp_rp_except');
|
32 |
+
var wp_rp_except_number_label = document.getElementById('wp_rp_except_number_label');
|
33 |
+
if(wp_rp_except.checked){
|
34 |
+
wp_rp_except_number_label.style.display = '';
|
35 |
+
} else {
|
36 |
+
wp_rp_except_number_label.style.display = 'none';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
function wp_rp_thumbnail_onclick(){
|
40 |
+
var wp_rp_thumbnail = document.getElementById('wp_rp_thumbnail');
|
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 |
+
}
|
47 |
+
}
|
48 |
+
</script>
|
49 |
+
|
50 |
+
<script type="text/javascript">
|
51 |
+
|
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]);
|
59 |
+
|
60 |
+
(function() {
|
61 |
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
62 |
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
63 |
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
64 |
+
})();
|
65 |
+
|
66 |
+
</script>
|
static/themes.js
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
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 |
+
if (themes) {
|
17 |
+
$.each(themes, function (i, theme) {
|
18 |
+
var selected = theme.location === current_theme ? 'checked="checked"' : '';
|
19 |
+
|
20 |
+
td.append('<label><input ' + selected + ' type="radio" name="wp_rp_theme" value="' + theme.location + '" /> ' + theme.name + '</label><br />');
|
21 |
+
});
|
22 |
+
wrap.append(tr);
|
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 |
+
};
|
33 |
+
|
34 |
+
window.wp_rp_themes_cb = function (data) {
|
35 |
+
if (data && data.themes) {
|
36 |
+
themes = data.themes;
|
37 |
+
|
38 |
+
update_themes();
|
39 |
+
}
|
40 |
+
};
|
41 |
+
|
42 |
+
append_get_themes_script();
|
43 |
+
|
44 |
+
if (!window.localStorage || !window.localStorage.wp_wp_survey_1) {
|
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));
|
utils.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* WP backwards compatibility */
|
4 |
+
if( !function_exists('strip_shortcodes') ) {
|
5 |
+
// strip_shortcodes introduced in 2.5
|
6 |
+
function strip_shortcodes( $content ){
|
7 |
+
return $content;
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
11 |
+
if( !function_exists('path_is_absolute') ) {
|
12 |
+
function path_is_absolute( $path ) {
|
13 |
+
// this is definitive if true but fails if $path does not exist or contains a symbolic link
|
14 |
+
if ( realpath($path) == $path )
|
15 |
+
return true;
|
16 |
+
|
17 |
+
if ( strlen($path) == 0 || $path[0] == '.' )
|
18 |
+
return false;
|
19 |
+
|
20 |
+
// windows allows absolute paths like this
|
21 |
+
if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
|
22 |
+
return true;
|
23 |
+
|
24 |
+
// a path starting with / or \ is absolute; anything else is relative
|
25 |
+
return ( $path[0] == '/' || $path[0] == '\\' );
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
if( !function_exists('path_join') ) {
|
30 |
+
function path_join( $base, $path ) {
|
31 |
+
if ( path_is_absolute($path) )
|
32 |
+
return $path;
|
33 |
+
return rtrim($base, '/') . '/' . ltrim($path, '/');
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( !defined('WP_SITEURL') )
|
38 |
+
define( 'WP_SITEURL', get_option('siteurl') );
|
39 |
+
if ( ! defined( 'WP_CONTENT_URL' ) )
|
40 |
+
define( 'WP_CONTENT_URL', WP_SITEURL . '/wp-content' );
|
41 |
+
if ( ! defined( 'WP_CONTENT_DIR' ) )
|
42 |
+
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
43 |
+
if ( ! defined( 'WP_PLUGIN_URL' ) )
|
44 |
+
define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
|
45 |
+
if ( ! defined( 'WP_PLUGIN_DIR' ) )
|
46 |
+
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
|
47 |
+
if ( ! defined( 'WPMU_PLUGIN_URL' ) )
|
48 |
+
define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL. '/mu-plugins' );
|
49 |
+
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);
|
57 |
+
|
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>';
|
65 |
+
|
66 |
+
echo $output;
|
67 |
+
}
|
68 |
+
|
69 |
+
function wp_most_popular_posts ($number = 10){
|
70 |
+
$limitclause="LIMIT " . $number;
|
71 |
+
$most_popular_posts = wp_get_most_popular_posts ($limitclause);
|
72 |
+
|
73 |
+
foreach ($most_popular_posts as $most_popular_post ){
|
74 |
+
$output .= '<li>';
|
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>';
|
80 |
+
|
81 |
+
echo $output;
|
82 |
+
}
|
83 |
+
|
84 |
+
function wp_most_commented_posts ($number = 10){
|
85 |
+
$limitclause="LIMIT " . $number;
|
86 |
+
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
|
87 |
+
|
88 |
+
foreach ($most_commented_posts as $most_commented_post ){
|
89 |
+
$output .= '<li>';
|
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>';
|
95 |
+
|
96 |
+
echo $output;
|
97 |
+
}
|
98 |
+
|
99 |
+
function wp23_related_posts() {
|
100 |
+
wp_related_posts();
|
101 |
+
}
|
102 |
+
|
103 |
+
function wp_related_posts() {
|
104 |
+
$output = wp_get_related_posts();
|
105 |
+
echo $output;
|
106 |
+
}
|
107 |
+
|
108 |
+
function wp_get_random_posts ($limitclause="") {
|
109 |
+
return wp_fetch_random_posts($limitclause);
|
110 |
+
}
|
111 |
+
|
112 |
+
function wp_get_most_commented_posts($limitclause="") {
|
113 |
+
return wp_fetch_most_commented_posts($limitclause);
|
114 |
+
}
|
115 |
+
|
116 |
+
function wp_get_most_popular_posts ($limitclause="") {
|
117 |
+
return wp_fetch_most_popular_posts($limitclause);
|
118 |
+
}
|
119 |
+
|
120 |
+
?>
|
widget.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action('plugins_loaded', 'widget_sidebar_wp_related_posts');
|
4 |
+
function widget_sidebar_wp_related_posts() {
|
5 |
+
function widget_wp_related_posts($args) {
|
6 |
+
extract($args);
|
7 |
+
if(!is_single()) return;
|
8 |
+
echo $before_widget;
|
9 |
+
|
10 |
+
//echo $before_title . $wp_rp["wp_rp_title"] . $after_title;
|
11 |
+
$output = wp_get_related_posts($before_title,$after_title);
|
12 |
+
echo $output;
|
13 |
+
echo $after_widget;
|
14 |
+
}
|
15 |
+
|
16 |
+
wp_register_sidebar_widget('wp_related_posts_widget', 'Related Posts', 'widget_wp_related_posts');
|
17 |
+
}
|
wp_related_posts.php
CHANGED
@@ -1,521 +1,303 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
-
Version: 1.
|
5 |
Plugin URI: http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/
|
6 |
Description: Generate a related posts list via tags of WordPress
|
7 |
Author: Denis
|
8 |
Author URI: http://fairyfish.net/
|
9 |
*/
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
add_action('init', 'init_textdomain');
|
12 |
function init_textdomain(){
|
13 |
-
load_plugin_textdomain('wp_related_posts',
|
14 |
}
|
15 |
|
16 |
register_activation_hook( __FILE__, 'activate_wp_related_posts' );
|
17 |
function activate_wp_related_posts() {
|
18 |
$wp_rp = get_option("wp_rp");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if (!isset($wp_rp['wp_rp_auto'])) {
|
20 |
-
$wp_rp['wp_rp_auto'] =
|
21 |
}
|
22 |
if (!isset($wp_rp['wp_rp_title'])) {
|
23 |
-
$wp_rp['wp_rp_title'] =
|
24 |
}
|
25 |
if (!isset($wp_rp['wp_rp_limit'])) {
|
26 |
-
$wp_rp['wp_rp_limit'] =
|
27 |
}
|
28 |
if (!isset($wp_rp['wp_rp_rss'])) {
|
29 |
-
$wp_rp['wp_rp_rss'] =
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
if (!isset($wp_rp['wp_no_rp'])) {
|
32 |
-
$wp_rp['wp_no_rp'] =
|
33 |
if (!isset($wp_rp['wp_no_rp_text'])) {
|
34 |
-
$wp_rp['wp_no_rp_text'] =
|
35 |
}
|
36 |
}
|
37 |
update_option( "wp_rp", $wp_rp );
|
38 |
-
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
$WP_RP_TITLE_TAG_DEFAULT = 'h3';
|
43 |
-
|
44 |
-
function wp_get_related_posts($before_title="",$after_title="") {
|
45 |
global $wpdb, $post;
|
46 |
$wp_rp = get_option("wp_rp");
|
47 |
-
|
48 |
-
$wp_rp_title = $wp_rp["wp_rp_title"];
|
49 |
-
|
50 |
-
$exclude = explode(",",$wp_rp["wp_rp_exclude"]);
|
51 |
-
if ( $exclude != '' ) {
|
52 |
-
$q = 'SELECT tt.term_id FROM '. $wpdb->term_taxonomy.' tt, ' . $wpdb->term_relationships.' tr WHERE tt.taxonomy = \'category\' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = '.$post->ID;
|
53 |
|
54 |
-
$cats = $wpdb->get_results($q);
|
55 |
-
|
56 |
-
foreach(($cats) as $cat) {
|
57 |
-
if (in_array($cat->term_id, $exclude) != false){
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
if(!$post->ID){return;}
|
64 |
$now = current_time('mysql', 1);
|
65 |
$tags = wp_get_post_tags($post->ID);
|
66 |
-
|
67 |
-
$taglist = "'" . $tags[0]->term_id. "'";
|
68 |
-
|
69 |
$tagcount = count($tags);
|
70 |
-
|
|
|
|
|
71 |
for ($i = 1; $i < $tagcount; $i++) {
|
72 |
$taglist = $taglist . ", '" . $tags[$i]->term_id . "'";
|
73 |
}
|
74 |
}
|
75 |
-
|
76 |
-
$
|
77 |
-
if ($
|
78 |
-
$
|
79 |
-
|
80 |
-
$
|
81 |
}
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
$
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
$wp_rp_title = $wp_no_rp_text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
}
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
$output .= '<li>';
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
118 |
}
|
119 |
-
|
120 |
-
if (
|
121 |
-
|
122 |
if ($wp_rp["wp_rp_date"]){
|
123 |
$dateformat = get_option('date_format');
|
124 |
$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
|
125 |
}
|
126 |
-
|
127 |
$output .= '<a href="'.get_permalink($related_post->ID).'" title="'.wptexturize($related_post->post_title).'">'.wptexturize($related_post->post_title).'</a>';
|
128 |
-
|
129 |
if ($wp_rp["wp_rp_comments"]){
|
130 |
$output .= " (" . $related_post->comment_count . ")";
|
131 |
}
|
132 |
-
|
133 |
if ($wp_rp["wp_rp_except"]){
|
134 |
$wp_rp_except_number = trim($wp_rp["wp_rp_except_number"]);
|
135 |
if(!$wp_rp_except_number) $wp_rp_except_number = 200;
|
136 |
if($related_post->post_excerpt){
|
137 |
-
$output .= '<br /><small>'.(mb_substr(strip_tags($related_post->post_excerpt),0,$wp_rp_except_number)).'...</small>';
|
138 |
}else{
|
139 |
-
$output .= '<br /><small>'.(mb_substr(strip_tags($related_post->post_content),0,$wp_rp_except_number)).'...</small>';
|
140 |
}
|
141 |
-
}
|
142 |
}
|
143 |
$output .= '</li>';
|
144 |
}
|
145 |
-
|
146 |
-
$output = '<ul class="related_post">' . $output . '</ul>';
|
147 |
-
|
148 |
-
$wp_rp_title_tag = $wp_rp["wp_rp_title_tag"];
|
149 |
-
if($before_title){
|
150 |
-
if($wp_rp_title != '') $output = $before_title.$wp_rp_title .$after_title. $output;
|
151 |
-
}else{
|
152 |
-
global $WP_RP_TITLE_TAG_DEFAULT;
|
153 |
-
if(!$wp_rp_title_tag) $wp_rp_title_tag = $WP_RP_TITLE_TAG_DEFAULT;
|
154 |
-
if($wp_rp_title != '') $output = '<'.$wp_rp_title_tag.' class="related_post_title">'.$wp_rp_title .'</'.$wp_rp_title_tag.'>'. $output;
|
155 |
-
}
|
156 |
-
|
157 |
return $output;
|
158 |
}
|
159 |
|
160 |
-
function
|
161 |
-
|
162 |
-
$
|
163 |
|
164 |
-
|
165 |
-
|
|
|
166 |
|
167 |
-
|
168 |
-
wp_related_posts();
|
169 |
-
}
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
}
|
177 |
-
|
178 |
-
return $content;
|
179 |
}
|
180 |
|
181 |
-
add_filter('the_content', 'wp_related_posts_auto',99);
|
182 |
-
|
183 |
-
function wp_get_random_posts ($limitclause="") {
|
184 |
-
global $wpdb, $post;
|
185 |
-
|
186 |
-
$q = "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 != $post->ID ORDER BY RAND() $limitclause";
|
187 |
-
return $wpdb->get_results($q);
|
188 |
-
}
|
189 |
|
190 |
-
function
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
foreach ($random_posts as $random_post ){
|
195 |
-
$output .= '<li>';
|
196 |
-
|
197 |
-
$output .= '<a href="'.get_permalink($random_post->ID).'" title="'.wptexturize($random_post->post_title).'">'.wptexturize($random_post->post_title).'</a></li>';
|
198 |
}
|
199 |
-
|
200 |
-
$output = '<ul class="randome_post">' . $output . '</ul>';
|
201 |
-
|
202 |
-
echo $output;
|
203 |
-
}
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
$q = "SELECT ID, post_title, post_content, post_excerpt, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC $limitclause";
|
208 |
-
return $wpdb->get_results($q);
|
209 |
-
}
|
210 |
-
|
211 |
-
function wp_most_commented_posts ($number = 10){
|
212 |
-
$limitclause="LIMIT " . $number;
|
213 |
-
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
|
214 |
-
|
215 |
-
foreach ($most_commented_posts as $most_commented_post ){
|
216 |
-
$output .= '<li>';
|
217 |
-
|
218 |
-
$output .= '<a href="'.get_permalink($most_commented_post->ID).'" title="'.wptexturize($most_commented_post->post_title).'">'.wptexturize($most_commented_post->post_title).'</a></li>';
|
219 |
-
}
|
220 |
-
|
221 |
-
$output = '<ul class="most_commented_post">' . $output . '</ul>';
|
222 |
-
|
223 |
-
echo $output;
|
224 |
-
}
|
225 |
|
226 |
-
|
227 |
-
global $wpdb, $table_prefix;
|
228 |
-
|
229 |
-
$q = $sql = "SELECT p.ID, p.post_title, p.post_content,p.post_excerpt, p.post_date, p.comment_count FROM ". $table_prefix ."ak_popularity as akpc,".$table_prefix ."posts as p WHERE p.ID = akpc.post_id ORDER BY akpc.total DESC $limitclause";;
|
230 |
-
return $wpdb->get_results($q);
|
231 |
-
}
|
232 |
|
233 |
-
|
234 |
-
$
|
235 |
-
$
|
236 |
-
|
237 |
-
foreach ($most_popular_posts as $most_popular_post ){
|
238 |
-
$output .= '<li>';
|
239 |
-
|
240 |
-
$output .= '<a href="'.get_permalink($most_popular_post->ID).'" title="'.wptexturize($most_popular_post->post_title).'">'.wptexturize($most_popular_post->post_title).'</a></li>';
|
241 |
-
}
|
242 |
-
|
243 |
-
$output = '<ul class="most_popular_post">' . $output . '</ul>';
|
244 |
-
|
245 |
-
echo $output;
|
246 |
-
}
|
247 |
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
259 |
}
|
260 |
-
register_sidebar_widget('Related Posts', 'widget_wp_related_posts');
|
261 |
-
}
|
262 |
|
263 |
-
|
264 |
|
265 |
-
|
266 |
-
if (
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
}
|
270 |
|
271 |
-
function
|
272 |
-
if($_POST["wp_rp_Submit"]){
|
273 |
-
$message = __("WordPress Related Posts Setting Updated",'wp_related_posts');
|
274 |
-
|
275 |
-
$wp_rp_saved = get_option("wp_rp");
|
276 |
-
|
277 |
-
$wp_rp = array (
|
278 |
-
"wp_rp_title" => trim($_POST['wp_rp_title_option']),
|
279 |
-
"wp_rp_title_tag" => trim($_POST['wp_rp_title_tag_option']),
|
280 |
-
"wp_no_rp" => trim($_POST['wp_no_rp_option']),
|
281 |
-
"wp_no_rp_text" => trim($_POST['wp_no_rp_text_option']),
|
282 |
-
"wp_rp_except" => trim($_POST['wp_rp_except_option']),
|
283 |
-
"wp_rp_except_number" => trim($_POST['wp_rp_except_number_option']),
|
284 |
-
"wp_rp_limit" => trim($_POST['wp_rp_limit_option']),
|
285 |
-
'wp_rp_exclude' => trim($_POST['wp_rp_exclude_option']),
|
286 |
-
'wp_rp_auto' => trim($_POST['wp_rp_auto_option']),
|
287 |
-
'wp_rp_rss' => trim($_POST['wp_rp_rss_option']),
|
288 |
-
'wp_rp_comments' => trim($_POST['wp_rp_comments_option']),
|
289 |
-
'wp_rp_date' => trim($_POST['wp_rp_date_option']),
|
290 |
-
'wp_rp_thumbnail' => trim($_POST['wp_rp_thumbnail_option']),
|
291 |
-
'wp_rp_thumbnail_text' => trim($_POST['wp_rp_thumbnail_text_option']),
|
292 |
-
'wp_rp_thumbnail_post_meta' => trim($_POST['wp_rp_thumbnail_post_meta_option'])
|
293 |
-
);
|
294 |
-
|
295 |
-
if ($wp_rp_saved != $wp_rp)
|
296 |
-
if(!update_option("wp_rp",$wp_rp))
|
297 |
-
$message = "Update Failed";
|
298 |
-
|
299 |
-
echo '<div id="message" class="updated fade"><p>'.$message.'.</p></div>';
|
300 |
-
}
|
301 |
-
|
302 |
$wp_rp = get_option("wp_rp");
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
var wp_no_rp = document.getElementById('wp_no_rp');
|
312 |
-
var wp_no_rp_title = document.getElementById('wp_no_rp_title');
|
313 |
-
var wp_no_rp_text = document.getElementById('wp_no_rp_text');
|
314 |
-
switch(wp_no_rp.value){
|
315 |
-
case 'text':
|
316 |
-
wp_no_rp_title.innerHTML = '<?php _e("No Related Posts Text:",'wp_related_posts'); ?>';
|
317 |
-
wp_no_rp_text.value = '<?php _e("No Related Posts",'wp_related_posts'); ?>';
|
318 |
-
break;
|
319 |
-
case 'random':
|
320 |
-
wp_no_rp_title.innerHTML = '<?php _e("Random Posts Title:",'wp_related_posts'); ?>';
|
321 |
-
wp_no_rp_text.value = '<?php _e("Random Posts",'wp_related_posts'); ?>';
|
322 |
-
break;
|
323 |
-
case 'commented':
|
324 |
-
wp_no_rp_title.innerHTML = '<?php _e("Most Commented Posts Title:",'wp_related_posts'); ?>';
|
325 |
-
wp_no_rp_text.value = '<?php _e("Most Commented Posts",'wp_related_posts'); ?>';
|
326 |
-
break;
|
327 |
-
case 'popularity':
|
328 |
-
wp_no_rp_title.innerHTML = '<?php _e("Most Popular Posts Title:",'wp_related_posts'); ?>';
|
329 |
-
wp_no_rp_text.value = '<?php _e("Most Popular Posts",'wp_related_posts'); ?>';
|
330 |
-
break;
|
331 |
-
default:
|
332 |
-
wp_no_rp_title.innerHTML = '';
|
333 |
-
}
|
334 |
-
if(wp_no_rp.value == '<?php echo $wp_no_rp;?>'){
|
335 |
-
wp_no_rp_text.value = '<?php echo $wp_rp["wp_no_rp_text"];?>';
|
336 |
-
}
|
337 |
-
}
|
338 |
-
function wp_rp_except_onclick(){
|
339 |
-
var wp_rp_except = document.getElementById('wp_rp_except');
|
340 |
-
var wp_rp_except_number_label = document.getElementById('wp_rp_except_number_label');
|
341 |
-
if(wp_rp_except.checked){
|
342 |
-
wp_rp_except_number_label.style.display = '';
|
343 |
-
} else {
|
344 |
-
wp_rp_except_number_label.style.display = 'none';
|
345 |
-
}
|
346 |
-
}
|
347 |
-
function wp_rp_thumbnail_onclick(){
|
348 |
-
var wp_rp_thumbnail = document.getElementById('wp_rp_thumbnail');
|
349 |
-
var wp_rp_thumbnail_span = document.getElementById('wp_rp_thumbnail_span');
|
350 |
-
if(wp_rp_thumbnail.checked){
|
351 |
-
wp_rp_thumbnail_span.style.display = '';
|
352 |
-
} else {
|
353 |
-
wp_rp_thumbnail_span.style.display = 'none';
|
354 |
-
}
|
355 |
-
}
|
356 |
-
</script>
|
357 |
-
|
358 |
-
<h2><?php _e("Related Posts Settings",'wp_related_posts');?></h2>
|
359 |
-
<p><?php _e("<a href=\"http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/\">WordPress Related Posts </a>Plugin can generate a related posts list via WordPress tags, and add the related posts to feed.",'wp_related_posts');?> </p>
|
360 |
-
<?php _e("Any problem or need help, please contact ",'wp_related_posts');?><a href="mailto:denishua@hotmail.com">denishua</a>.</p>
|
361 |
-
|
362 |
-
<div>
|
363 |
-
<span style="font-size:16px; height:30px; line-height:30px; padding:0 10px;"> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8490579"><?php _e("Do you like this Plugin? Consider to donate!",'wp_related_posts');?></a></span> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8490579"><img src="https://www.paypal.com/en_GB/i/btn/btn_donate_LG.gif" align="left" /></a>
|
364 |
-
</div>
|
365 |
-
|
366 |
-
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo basename(__FILE__); ?>">
|
367 |
-
<h3><?php _e("Basic Setting",'wp_related_posts');?></h3>
|
368 |
-
<table class="form-table">
|
369 |
-
<tr valign="top">
|
370 |
-
<th scope="row"><label for="wp_rp_title"><?php _e("Related Posts Title:",'wp_related_posts'); ?></label></th>
|
371 |
-
<td>
|
372 |
-
<input name="wp_rp_title_option" type="text" id="wp_rp_title" value="<?php echo $wp_rp["wp_rp_title"]; ?>" class="regular-text" />
|
373 |
-
</td>
|
374 |
-
</tr>
|
375 |
-
<tr valign="top">
|
376 |
-
<th scope="row"><label for="wp_rp_title_tag"><?php _e("Related Posts Title Tag:",'wp_related_posts'); ?></label></th>
|
377 |
-
<td>
|
378 |
-
<select name="wp_rp_title_tag_option" id="wp_rp_title_tag" class="postform">
|
379 |
-
<?php
|
380 |
-
$wp_rp_title_tag_array = array('h2','h3','h4','p','div');
|
381 |
-
if (!isset($wp_rp_title_tag) || $wp_rp_title_tag == 0 ) {
|
382 |
-
global $WP_RP_TITLE_TAG_DEFAULT;
|
383 |
-
$wp_rp_title_tag = $WP_RP_TITLE_TAG_DEFAULT;
|
384 |
-
}
|
385 |
-
foreach ($wp_rp_title_tag_array as $wp_rp_title_tag_a){
|
386 |
-
?>
|
387 |
-
<option value="<?php echo $wp_rp_title_tag_a; ?>" <?php if($wp_rp_title_tag == $wp_rp_title_tag_a) echo 'selected' ?> ><<?php echo $wp_rp_title_tag_a; ?>></option>
|
388 |
-
<?php
|
389 |
-
}
|
390 |
-
?>
|
391 |
-
</select>
|
392 |
-
</td>
|
393 |
-
</tr>
|
394 |
-
<tr valign="top">
|
395 |
-
<th scope="row"><label for="wp_rp_limit"><?php _e("Maximum Number:",'wp_related_posts');?></label></th>
|
396 |
-
<td>
|
397 |
-
<input name="wp_rp_limit_option" type="text" id="wp_rp_limit" value="<?php echo $wp_rp["wp_rp_limit"]; ?>" />
|
398 |
-
</td>
|
399 |
-
</tr>
|
400 |
-
<tr valign="top">
|
401 |
-
<th scope="row"><label for="wp_rp_exclude"><?php _e("Exclude(category IDs):",'wp_related_posts');?></label></th>
|
402 |
-
<td>
|
403 |
-
<input name="wp_rp_exclude_option" type="text" id="wp_rp_exclude" value="<?php echo $wp_rp["wp_rp_exclude"]; ?>" /> <span class="description"><?php _e('Enter category IDs of the posts which you don\'t want to display related posts for them. ','wp_related_posts'); ?></span>
|
404 |
-
</td>
|
405 |
-
</tr>
|
406 |
-
<tr valign="top">
|
407 |
-
<th scope="row"><?php _e("Other Setting:",'wp_related_posts'); ?></th>
|
408 |
-
<td>
|
409 |
-
<label>
|
410 |
-
<input name="wp_rp_comments_option" type="checkbox" id="wp_rp_comments" value="yes" <?php echo ($wp_rp["wp_rp_comments"] == 'yes') ? 'checked' : ''; ?>>
|
411 |
-
<?php _e("Display Comments Count?",'wp_related_posts');?>
|
412 |
-
</label>
|
413 |
-
<br />
|
414 |
-
<label>
|
415 |
-
<input name="wp_rp_date_option" type="checkbox" id="wp_rp_date" value="yes" <?php echo ($wp_rp["wp_rp_date"] == 'yes') ? 'checked' : ''; ?>>
|
416 |
-
<?php _e("Display Pubilsh Date?",'wp_related_posts');?>
|
417 |
-
</label>
|
418 |
-
<br />
|
419 |
-
<label>
|
420 |
-
<input name="wp_rp_auto_option" type="checkbox" id="wp_rp_auto" value="yes" <?php echo ($wp_rp["wp_rp_auto"] == 'yes') ? 'checked' : ''; ?>>
|
421 |
-
<?php _e("Auto Insert Related Posts?",'wp_related_posts');?>
|
422 |
-
</label>
|
423 |
-
<br />
|
424 |
-
<label>
|
425 |
-
<input name="wp_rp_rss_option" type="checkbox" id="wp_rp_rss" value="yes" <?php echo ($wp_rp["wp_rp_rss"] == 'yes') ? 'checked' : ''; ?>>
|
426 |
-
<?php _e("Display Related Posts on Feed?",'wp_related_posts');?>
|
427 |
-
</label>
|
428 |
-
</td>
|
429 |
-
</tr>
|
430 |
-
<tr valign="top">
|
431 |
-
<th scope="row"><label for="wp_rp_except"><?php _e("Excerpt Setting:",'wp_related_posts'); ?></label></th>
|
432 |
-
<td>
|
433 |
-
<label>
|
434 |
-
<input name="wp_rp_except_option" type="checkbox" id="wp_rp_except" value="yes" <?php echo ($wp_rp["wp_rp_except"] == 'yes') ? 'checked' : ''; ?> onclick="wp_rp_except_onclick();" >
|
435 |
-
<?php _e("Display Post Excerpt?",'wp_related_posts');?>
|
436 |
-
</label>
|
437 |
-
<br />
|
438 |
-
<label id="wp_rp_except_number_label" style="<?php echo ($wp_rp["wp_rp_except"] == 'yes') ? '' : 'display:none;'; ?>">
|
439 |
-
<input name="wp_rp_except_number_option" type="text" id="wp_rp_except_number" value="<?php echo ($wp_rp["wp_rp_except_number"]); ?> " /> <span class="description"><?php _e('Maximum Charaters of Except.','wp_related_posts'); ?></span>
|
440 |
-
</label>
|
441 |
-
</td>
|
442 |
-
</tr>
|
443 |
-
</table>
|
444 |
-
<h3><?php _e("No Related Post Setting",'wp_related_posts');?></h3>
|
445 |
-
<table class="form-table">
|
446 |
-
<tr valign="top">
|
447 |
-
<th scope="row"><label for="wp_no_rp"><?php _e("Display:",'wp_related_posts'); ?></label></th>
|
448 |
-
<td>
|
449 |
-
<select name="wp_no_rp_option" id="wp_no_rp" onchange="wp_no_rp_onchange();" class="postform">
|
450 |
-
<option value="text" <?php if($wp_no_rp == 'text') echo 'selected' ?> ><?php _e("Text: 'No Related Posts'",'wp_related_posts'); ?></option>
|
451 |
-
<option value="random" <?php if($wp_no_rp == 'random') echo 'selected' ?>><?php _e("Random Posts",'wp_related_posts'); ?></option>
|
452 |
-
<option value="commented" <?php if($wp_no_rp == 'commented') echo 'selected' ?>><?php _e("Most Commented Posts",'wp_related_posts'); ?></option>
|
453 |
-
<?php if (function_exists('akpc_most_popular')){ ?>
|
454 |
-
<option value="popularity" <?php if($wp_no_rp == 'popularity') echo 'selected' ?>><?php _e("Most Popular Posts",'wp_related_posts'); ?></option>
|
455 |
-
<?php } ?>
|
456 |
-
</select>
|
457 |
-
</td>
|
458 |
-
</tr>
|
459 |
-
<tr valign="top" scope="row">
|
460 |
-
<th id="wp_no_rp_title" scope="row"><label for="wp_no_rp_text">
|
461 |
-
<?php
|
462 |
-
switch ($wp_no_rp){
|
463 |
-
case 'text':
|
464 |
-
_e("No Related Posts Text:",'wp_related_posts');
|
465 |
-
break;
|
466 |
-
case 'random':
|
467 |
-
_e("Random Posts Title:",'wp_related_posts');
|
468 |
-
break;
|
469 |
-
case 'commented':
|
470 |
-
_e("Most Commented Posts Title:",'wp_related_posts');
|
471 |
-
break;
|
472 |
-
case 'popularity':
|
473 |
-
_e("Most Popular Posts Title:",'wp_related_posts');
|
474 |
-
break;
|
475 |
-
}
|
476 |
-
?>
|
477 |
-
</label></th>
|
478 |
-
<td>
|
479 |
-
<input name="wp_no_rp_text_option" type="text" id="wp_no_rp_text" value="<?php echo $wp_rp["wp_no_rp_text"]; ?>" class="regular-text" />
|
480 |
-
</td>
|
481 |
-
</tr>
|
482 |
-
</table>
|
483 |
-
<h3><?php _e("Related Posts with Thumbnail",'wp_related_posts');?></h3>
|
484 |
-
<table class="form-table">
|
485 |
-
<tr valign="top">
|
486 |
-
<th colspan="2">
|
487 |
-
<?php _e("Befor usting Related Posts with Thumbnail, you must set thumbnail image for your every post.",'wp_related_posts'); ?>
|
488 |
-
</th>
|
489 |
-
</tr>
|
490 |
-
<tr valign="top">
|
491 |
-
<th scope="row"><label for="wp_rp_thumbnail"><?php _e("Thumbnail Setting:",'wp_related_posts'); ?></label></th>
|
492 |
-
<td>
|
493 |
-
<input name="wp_rp_thumbnail_option" type="checkbox" id="wp_rp_thumbnail" value="yes" <?php echo ($wp_rp["wp_rp_thumbnail"] == 'yes') ? 'checked' : ''; ?> onclick="wp_rp_thumbnail_onclick();" >
|
494 |
-
<?php _e("Display Thumbnails For Related Posts?",'wp_related_posts');?>
|
495 |
-
<br />
|
496 |
-
<span id="wp_rp_thumbnail_span" style="<?php echo ($wp_rp["wp_rp_thumbnail"] == 'yes') ? '' : 'display:none;'; ?>">
|
497 |
-
<input name="wp_rp_thumbnail_text_option" type="checkbox" id="wp_rp_thumbnail_text" value="yes" <?php echo ($wp_rp["wp_rp_thumbnail_text"] == 'yes') ? 'checked' : ''; ?>>
|
498 |
-
<?php _e("Do you still want to display text when display thumbnails for related posts?",'wp_related_posts');?>
|
499 |
-
<br />
|
500 |
-
<?php _e("Which custom field is used for thumbnail?",'wp_related_posts');?>
|
501 |
-
<select name="wp_rp_thumbnail_post_meta_option" id="wp_rp_thumbnail_post_meta" class="postform">
|
502 |
-
<?php
|
503 |
-
global $wpdb;
|
504 |
-
$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)" );
|
505 |
-
|
506 |
-
foreach ( $post_metas as $post_meta ) {
|
507 |
-
$post_meta = esc_attr( $post_meta );
|
508 |
-
?>
|
509 |
-
<option value="<?php echo $post_meta; ?>" <?php if($wp_rp["wp_rp_thumbnail_post_meta"] == $post_meta) echo 'selected' ?>><?php echo $post_meta;?> </option>;
|
510 |
-
<?php
|
511 |
-
}
|
512 |
-
?>
|
513 |
-
</select>
|
514 |
-
</span>
|
515 |
-
</td>
|
516 |
-
</tr>
|
517 |
-
</table>
|
518 |
-
<p class="submit"><input type="submit" value="<?php _e("Save changes",'wp_related_posts');?>" name="wp_rp_Submit" class="button-primary" /></p>
|
519 |
-
</form>
|
520 |
-
</div>
|
521 |
-
<?php }?>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
+
Version: 1.3
|
5 |
Plugin URI: http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/
|
6 |
Description: Generate a related posts list via tags of WordPress
|
7 |
Author: Denis
|
8 |
Author URI: http://fairyfish.net/
|
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');
|
17 |
function init_textdomain(){
|
18 |
+
load_plugin_textdomain('wp_related_posts', false, dirname(plugin_basename (__FILE__)) . '/lang');
|
19 |
}
|
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 (!isset($wp_rp['wp_rp_template'])) {
|
26 |
+
// plain for old users, modern for new
|
27 |
+
// This hook doesn't fire on updates for wp >= 3.1
|
28 |
+
if (count($wp_rp) === 0 && version_compare($wp_version, '3.1', '>=')) {
|
29 |
+
$wp_rp['wp_rp_template'] = WP_RP_THEME_DEFAULT;
|
30 |
+
} else {
|
31 |
+
$wp_rp['wp_rp_template'] = WP_RP_THEME_PLAIN;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
if (!isset($wp_rp['wp_rp_auto'])) {
|
36 |
+
$wp_rp['wp_rp_auto'] = WP_RP_AUTO_APPEND;
|
37 |
}
|
38 |
if (!isset($wp_rp['wp_rp_title'])) {
|
39 |
+
$wp_rp['wp_rp_title'] = WP_RP_TITLE;
|
40 |
}
|
41 |
if (!isset($wp_rp['wp_rp_limit'])) {
|
42 |
+
$wp_rp['wp_rp_limit'] = WP_RP_POST_LIMIT;
|
43 |
}
|
44 |
if (!isset($wp_rp['wp_rp_rss'])) {
|
45 |
+
$wp_rp['wp_rp_rss'] = WP_RP_APPEND_TO_RSS;
|
46 |
+
}
|
47 |
+
if (!isset($wp_rp['wp_rp_thumbnail_text'])) {
|
48 |
+
$wp_rp['wp_rp_thumbnail_text'] = 'yes';
|
49 |
+
}
|
50 |
+
if (!isset($wp_rp['wp_rp_except_number'])) {
|
51 |
+
$wp_rp['wp_rp_except_number'] = 200;
|
52 |
}
|
53 |
if (!isset($wp_rp['wp_no_rp'])) {
|
54 |
+
$wp_rp['wp_no_rp'] = WP_RP_RELATED_FALLBACK;
|
55 |
if (!isset($wp_rp['wp_no_rp_text'])) {
|
56 |
+
$wp_rp['wp_no_rp_text'] = WP_RP_RELATED_FALLBACK_TITLE;
|
57 |
}
|
58 |
}
|
59 |
update_option( "wp_rp", $wp_rp );
|
|
|
60 |
}
|
61 |
|
62 |
+
function wp_fetch_related_posts($limitclause="") {
|
|
|
|
|
|
|
63 |
global $wpdb, $post;
|
64 |
$wp_rp = get_option("wp_rp");
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
if(!$post->ID){return;}
|
67 |
$now = current_time('mysql', 1);
|
68 |
$tags = wp_get_post_tags($post->ID);
|
69 |
+
|
|
|
|
|
70 |
$tagcount = count($tags);
|
71 |
+
$taglist = false;
|
72 |
+
if ($tagcount > 0) {
|
73 |
+
$taglist = "'" . $tags[0]->term_id. "'";
|
74 |
for ($i = 1; $i < $tagcount; $i++) {
|
75 |
$taglist = $taglist . ", '" . $tags[$i]->term_id . "'";
|
76 |
}
|
77 |
}
|
78 |
+
|
79 |
+
$related_posts = false;
|
80 |
+
if ($taglist) {
|
81 |
+
$q = "SELECT p.ID, p.post_title, p.post_content,p.post_excerpt, p.post_date, p.comment_count, count(t_r.object_id) as cnt FROM $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r, $wpdb->posts p WHERE t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id = p.ID AND (t_t.term_id IN ($taglist)) AND p.ID != $post->ID AND p.post_status = 'publish' AND p.post_date_gmt < '$now' GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC $limitclause;";
|
82 |
+
|
83 |
+
$related_posts = $wpdb->get_results($q);
|
84 |
}
|
85 |
+
|
86 |
+
return $related_posts;
|
87 |
+
}
|
88 |
+
|
89 |
+
function wp_fetch_random_posts ($limitclause="") {
|
90 |
+
global $wpdb, $post;
|
91 |
+
|
92 |
+
$q = "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 != $post->ID ORDER BY RAND() $limitclause";
|
93 |
+
return $wpdb->get_results($q);
|
94 |
+
}
|
95 |
+
|
96 |
+
function wp_fetch_most_commented_posts($limitclause="") {
|
97 |
+
global $wpdb;
|
98 |
+
$q = "SELECT ID, post_title, post_content, post_excerpt, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC $limitclause";
|
99 |
+
return $wpdb->get_results($q);
|
100 |
+
}
|
101 |
+
|
102 |
+
function wp_fetch_most_popular_posts ($limitclause="") {
|
103 |
+
global $wpdb, $table_prefix;
|
104 |
+
|
105 |
+
$q = $sql = "SELECT p.ID, p.post_title, p.post_content,p.post_excerpt, p.post_date, p.comment_count FROM ". $table_prefix ."ak_popularity as akpc,".$table_prefix ."posts as p WHERE p.ID = akpc.post_id ORDER BY akpc.total DESC $limitclause";;
|
106 |
+
return $wpdb->get_results($q);
|
107 |
+
}
|
108 |
+
|
109 |
+
function wp_fetch_content() {
|
110 |
+
$default_wp_no_rp_text = array(
|
111 |
+
"random" => __("Random Posts",'wp_related_posts'),
|
112 |
+
"popularity" => __("Random Posts",'wp_related_posts'),
|
113 |
+
"commented" => __("Random Posts",'wp_related_posts'),
|
114 |
+
"text" => __("No Related Post",'wp_related_posts')
|
115 |
+
);
|
116 |
+
|
117 |
+
$wp_rp = get_option("wp_rp");
|
118 |
+
|
119 |
+
if (isset($wp_rp["wp_rp_limit"]) && $wp_rp["wp_rp_limit"]) {
|
120 |
+
$limitclause = "LIMIT " . $wp_rp["wp_rp_limit"];
|
121 |
+
} else {
|
122 |
+
$limitclause = "LIMIT " . WP_RP_POST_LIMIT;
|
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);
|
127 |
+
|
128 |
+
if (!$related_posts) {
|
129 |
+
$wp_no_rp = isset($wp_rp["wp_no_rp"]) ? $wp_rp["wp_no_rp"] : "random";
|
130 |
+
$wp_no_rp_text = isset($wp_rp["wp_no_rp_text"]) ? $wp_rp["wp_no_rp_text"] : false;
|
131 |
+
|
132 |
+
if ($wp_no_rp_text) {
|
133 |
$wp_rp_title = $wp_no_rp_text;
|
134 |
+
} else if ($wp_no_rp_text === false && isset($default_wp_no_rp_text[$wp_no_rp])) {
|
135 |
+
$wp_rp_title = $default_wp_no_rp_text[$wp_no_rp];
|
136 |
+
} else {
|
137 |
+
$wp_rp_title = "";
|
138 |
+
}
|
139 |
+
|
140 |
+
if ($wp_no_rp === "commented") {
|
141 |
+
$related_posts = wp_fetch_most_commented_posts($limitclause);
|
142 |
+
} else if ($wp_no_rp === "popularity" && function_exists('akpc_most_popular')) {
|
143 |
+
$related_posts = wp_fetch_most_popular_posts($limitclause);
|
144 |
+
} else if ($wp_no_rp === "text") {
|
145 |
+
$related_posts = false;
|
146 |
+
} else { // random
|
147 |
+
$related_posts = wp_fetch_random_posts($limitclause);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
return array(
|
152 |
+
"posts" => $related_posts,
|
153 |
+
"title" => $wp_rp_title
|
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 = "";
|
180 |
+
|
181 |
+
foreach ($related_posts as $related_post ) {
|
182 |
$output .= '<li>';
|
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))) {
|
|
|
190 |
if ($wp_rp["wp_rp_date"]){
|
191 |
$dateformat = get_option('date_format');
|
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 . ")";
|
199 |
}
|
200 |
+
|
201 |
if ($wp_rp["wp_rp_except"]){
|
202 |
$wp_rp_except_number = trim($wp_rp["wp_rp_except_number"]);
|
203 |
if(!$wp_rp_except_number) $wp_rp_except_number = 200;
|
204 |
if($related_post->post_excerpt){
|
205 |
+
$output .= '<br /><small>'.(mb_substr(strip_shortcodes(strip_tags($related_post->post_excerpt)),0,$wp_rp_except_number)).'...</small>';
|
206 |
}else{
|
207 |
+
$output .= '<br /><small>'.(mb_substr(strip_shortcodes(strip_tags($related_post->post_content)),0,$wp_rp_except_number)).'...</small>';
|
208 |
}
|
209 |
+
}
|
210 |
}
|
211 |
$output .= '</li>';
|
212 |
}
|
213 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
return $output;
|
215 |
}
|
216 |
|
217 |
+
function wp_should_exclude() {
|
218 |
+
global $wpdb, $post;
|
219 |
+
$wp_rp = get_option("wp_rp");
|
220 |
|
221 |
+
$exclude = explode(",",$wp_rp["wp_rp_exclude"]);
|
222 |
+
if ( $exclude != '' ) {
|
223 |
+
$q = 'SELECT tt.term_id FROM '. $wpdb->term_taxonomy.' tt, ' . $wpdb->term_relationships.' tr WHERE tt.taxonomy = \'category\' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = '.$post->ID;
|
224 |
|
225 |
+
$cats = $wpdb->get_results($q);
|
|
|
|
|
226 |
|
227 |
+
foreach($cats as $cat) {
|
228 |
+
if (in_array($cat->term_id, $exclude) != false){
|
229 |
+
return true;
|
230 |
+
}
|
231 |
+
}
|
232 |
}
|
233 |
+
return false;
|
|
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
+
function wp_get_related_posts($before_title="", $after_title="") {
|
238 |
+
if (wp_should_exclude()) {
|
239 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
240 |
}
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
+
global $wpdb, $post;
|
243 |
+
$wp_rp = get_option("wp_rp");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
+
$output = "";
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
+
$content = wp_fetch_content();
|
248 |
+
$related_posts = $content['posts'];
|
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 |
+
$wp_rp_theme_url = WP_RP_STATIC_BASE_URL . WP_RP_THEMES_PATH . $wp_rp_theme;
|
253 |
+
|
254 |
+
if ($related_posts) {
|
255 |
+
$output = wp_generate_related_posts_list_items($related_posts);
|
256 |
+
} else {
|
257 |
+
$wp_no_rp_text = isset($wp_rp["wp_no_rp_text"]) ? $wp_rp["wp_no_rp_text"] : "";
|
258 |
+
if (!$wp_no_rp_text) {
|
259 |
+
$wp_no_rp_text = $wp_rp_title;
|
260 |
+
}
|
261 |
+
$wp_rp_title = "";
|
262 |
+
$output = '<li>' . $wp_no_rp_text . '</li>';
|
263 |
}
|
|
|
|
|
264 |
|
265 |
+
$output = '<ul class="related_post">' . $output . '</ul>';
|
266 |
|
267 |
+
$wp_rp_title_tag = isset($wp_rp["wp_rp_title_tag"]) ? $wp_rp["wp_rp_title_tag"] : WP_RP_TITLE_TAG_DEFAULT;
|
268 |
+
if ($before_title) {
|
269 |
+
if ($wp_rp_title != '') {
|
270 |
+
$output = $before_title.$wp_rp_title .$after_title. $output;
|
271 |
+
}
|
272 |
+
} else {
|
273 |
+
if ($wp_rp_title != '') {
|
274 |
+
$output = '<'.$wp_rp_title_tag.' class="related_post_title">'.$wp_rp_title .'</'.$wp_rp_title_tag.'>'. $output;
|
275 |
+
}
|
276 |
}
|
277 |
+
|
278 |
+
// figure out how to use wp_enqueue_style
|
279 |
+
$wp_rp_theme_style_loader = '<script type="text/javascript">
|
280 |
+
setTimeout(function () {
|
281 |
+
var link = document.createElement("link");
|
282 |
+
link.rel = "stylesheet";
|
283 |
+
link.href= "' . $wp_rp_theme_url . '";
|
284 |
+
link.type= "text/css";
|
285 |
+
document.getElementsByTagName("body")[0].appendChild(link);
|
286 |
+
}, 1);
|
287 |
+
</script>';
|
288 |
+
|
289 |
+
$output .= $wp_rp_theme_style_loader;
|
290 |
+
|
291 |
+
return $output;
|
292 |
}
|
293 |
|
294 |
+
function wp_related_posts_auto($content){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
$wp_rp = get_option("wp_rp");
|
296 |
+
if ((is_single() && $wp_rp["wp_rp_auto"])||(is_feed() && $wp_rp["wp_rp_rss"])) {
|
297 |
+
$output = wp_get_related_posts();
|
298 |
+
$content = $content . $output;
|
299 |
+
}
|
300 |
+
|
301 |
+
return $content;
|
302 |
+
}
|
303 |
+
add_filter('the_content', 'wp_related_posts_auto', 99);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|