Version Description
- Pageview statistics in settings
- Custom CSS
- Bugfixes
Download this release
Release Info
Developer | jureham |
Plugin | WordPress Related Posts |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.5
- compatibility.php +101 -0
- config.php +244 -0
- defaults.php +0 -20
- readme.txt +8 -2
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- settings.php +409 -248
- static/css/dashboard.css +32 -0
- static/img/arrow.png +0 -0
- static/img/icon_support.png +0 -0
- static/js/dashboard.js +9 -0
- static/js/themes.js +3 -0
- static/settings.js.php +29 -29
- static/themes.js +0 -65
- 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 +16 -24
- utils.php +0 -119
- versions.php +60 -10
- widget.php +8 -6
- wp_related_posts.php +130 -163
compatibility.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* ***************************** */
|
4 |
+
/* WP RP backwards compatibility */
|
5 |
+
/* ***************************** */
|
6 |
+
|
7 |
+
function wp_random_posts ($number = 10){
|
8 |
+
$limitclause="LIMIT " . $number;
|
9 |
+
$random_posts = wp_get_random_posts ($limitclause);
|
10 |
+
|
11 |
+
foreach ($random_posts as $random_post ){
|
12 |
+
$output .= '<li>';
|
13 |
+
|
14 |
+
$output .= '<a href="' . get_permalink($random_post->ID) . '" title="' . esc_attr(wptexturize($random_post->post_title)) . '">' . wptexturize($random_post->post_title) . '</a></li>';
|
15 |
+
}
|
16 |
+
|
17 |
+
$output = '<ul class="randome_post">' . $output . '</ul>';
|
18 |
+
|
19 |
+
echo $output;
|
20 |
+
}
|
21 |
+
|
22 |
+
function wp_most_popular_posts ($number = 10){
|
23 |
+
$limitclause="LIMIT " . $number;
|
24 |
+
$most_popular_posts = wp_get_most_popular_posts ($limitclause);
|
25 |
+
|
26 |
+
foreach($most_popular_posts as $most_popular_post) {
|
27 |
+
$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>';
|
28 |
+
}
|
29 |
+
|
30 |
+
$output = '<ul class="most_popular_post">' . $output . '</ul>';
|
31 |
+
|
32 |
+
echo $output;
|
33 |
+
}
|
34 |
+
|
35 |
+
function wp_most_commented_posts ($number = 10){
|
36 |
+
$limitclause="LIMIT " . $number;
|
37 |
+
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
|
38 |
+
|
39 |
+
foreach($most_commented_posts as $most_commented_post) {
|
40 |
+
$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>';
|
41 |
+
}
|
42 |
+
|
43 |
+
$output = '<ul class="most_commented_post">' . $output . '</ul>';
|
44 |
+
|
45 |
+
echo $output;
|
46 |
+
}
|
47 |
+
|
48 |
+
function wp23_related_posts() {
|
49 |
+
wp_related_posts();
|
50 |
+
}
|
51 |
+
|
52 |
+
function wp_related_posts() {
|
53 |
+
$output = wp_get_related_posts();
|
54 |
+
echo $output;
|
55 |
+
}
|
56 |
+
|
57 |
+
function wp_get_random_posts ($limitclause = '') {
|
58 |
+
return wp_rp_fetch_random_posts($limitclause);
|
59 |
+
}
|
60 |
+
|
61 |
+
function wp_get_most_commented_posts($limitclause = '') {
|
62 |
+
return wp_rp_fetch_most_commented_posts($limitclause);
|
63 |
+
}
|
64 |
+
|
65 |
+
function wp_get_most_popular_posts ($limitclause = '') {
|
66 |
+
return wp_rp_fetch_most_popular_posts($limitclause);
|
67 |
+
}
|
68 |
+
|
69 |
+
function wp_fetch_related_posts($limitclause = '') {
|
70 |
+
return wp_rp_fetch_related_posts($limitclause);
|
71 |
+
}
|
72 |
+
|
73 |
+
function wp_fetch_random_posts($limit = 10) {
|
74 |
+
return wp_rp_fetch_random_posts($limit);
|
75 |
+
}
|
76 |
+
|
77 |
+
function wp_fetch_most_commented_posts($limitclause = '') {
|
78 |
+
return wp_rp_fetch_most_commented_posts($limitclause);
|
79 |
+
}
|
80 |
+
|
81 |
+
function wp_fetch_most_popular_posts($limitclause = '') {
|
82 |
+
return wp_rp_fetch_most_popular_posts($limitclause);
|
83 |
+
}
|
84 |
+
|
85 |
+
function wp_fetch_content() {
|
86 |
+
return wp_rp_fetch_posts_and_title();
|
87 |
+
}
|
88 |
+
|
89 |
+
function wp_generate_related_posts_list_items($related_posts) {
|
90 |
+
return wp_rp_generate_related_posts_list_items($related_posts);
|
91 |
+
}
|
92 |
+
|
93 |
+
function wp_should_exclude() {
|
94 |
+
return wp_rp_should_exclude();
|
95 |
+
}
|
96 |
+
|
97 |
+
function wp_get_related_posts($before_title = '', $after_title = '') {
|
98 |
+
return wp_rp_get_related_posts($before_title, $after_title);
|
99 |
+
}
|
100 |
+
|
101 |
+
?>
|
config.php
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
define('WP_RP_STATIC_BASE_URL', 'http://dtmvdvtzf8rz0.cloudfront.net/static/');
|
4 |
+
define('WP_RP_STATIC_THEMES_PATH', 'css-text/');
|
5 |
+
define('WP_RP_STATIC_THEMES_THUMBS_PATH', 'css-img/');
|
6 |
+
define('WP_RP_STATIC_JSON_PATH', 'json/');
|
7 |
+
|
8 |
+
define("WP_RP_DEFAULT_CUSTOM_CSS",
|
9 |
+
".related_post_title {
|
10 |
+
}
|
11 |
+
ul.related_post {
|
12 |
+
}
|
13 |
+
ul.related_post li {
|
14 |
+
}
|
15 |
+
ul.related_post li a {
|
16 |
+
}
|
17 |
+
ul.related_post li img {
|
18 |
+
}");
|
19 |
+
|
20 |
+
define('WP_RP_THUMBNAILS_WIDTH', 150);
|
21 |
+
define('WP_RP_THUMBNAILS_HEIGHT', 150);
|
22 |
+
define('WP_RP_THUMBNAILS_DEFAULTS_COUNT', 15);
|
23 |
+
|
24 |
+
define("WP_RP_CTR_BASE_URL", "http://d.related-posts.com/");
|
25 |
+
define("WP_RP_CTR_REPORT_URL", "http://t.related-posts.com/pageview/?");
|
26 |
+
define("WP_RP_CTR_PAGEVIEW_FILE", "js/pageview.js");
|
27 |
+
|
28 |
+
|
29 |
+
global $wp_rp_options, $wp_rp_meta;
|
30 |
+
$wp_rp_options = false;
|
31 |
+
$wp_rp_meta = false;
|
32 |
+
|
33 |
+
function wp_rp_get_options()
|
34 |
+
{
|
35 |
+
global $wp_rp_options, $wp_rp_meta;
|
36 |
+
if($wp_rp_options) {
|
37 |
+
return $wp_rp_options;
|
38 |
+
}
|
39 |
+
|
40 |
+
$wp_rp_meta = get_option('wp_rp_meta', false);
|
41 |
+
if(!$wp_rp_meta || $wp_rp_meta['version'] !== WP_RP_VERSION) {
|
42 |
+
wp_rp_upgrade();
|
43 |
+
$wp_rp_meta = get_option('wp_rp_meta');
|
44 |
+
}
|
45 |
+
|
46 |
+
$wp_rp_options = get_option('wp_rp_options');
|
47 |
+
|
48 |
+
if ($wp_rp_options['ctr_dashboard_enabled'] && !$wp_rp_meta['blog_id']) {
|
49 |
+
wp_rp_fetch_blog_credentials();
|
50 |
+
}
|
51 |
+
|
52 |
+
return $wp_rp_options;
|
53 |
+
}
|
54 |
+
|
55 |
+
function wp_rp_get_meta() {
|
56 |
+
global $wp_rp_meta;
|
57 |
+
|
58 |
+
if (!$wp_rp_meta) {
|
59 |
+
wp_rp_get_options();
|
60 |
+
}
|
61 |
+
|
62 |
+
return $wp_rp_meta;
|
63 |
+
}
|
64 |
+
|
65 |
+
function wp_rp_activate_hook() {
|
66 |
+
wp_rp_get_options();
|
67 |
+
}
|
68 |
+
|
69 |
+
function wp_rp_fetch_blog_credentials() {
|
70 |
+
global $wp_rp_meta;
|
71 |
+
|
72 |
+
if (!wp_rp_statistics_supported()) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$options = array(
|
77 |
+
'timeout' => 10
|
78 |
+
);
|
79 |
+
$response = wp_remote_get(WP_RP_CTR_BASE_URL . 'register/?blog_url=' . get_bloginfo('wpurl'), $options);
|
80 |
+
if (wp_remote_retrieve_response_code($response) == 200) {
|
81 |
+
$body = wp_remote_retrieve_body($response);
|
82 |
+
if ($body) {
|
83 |
+
$doc = json_decode($body);
|
84 |
+
if ($doc && $doc->status === 'ok') {
|
85 |
+
$wp_rp_meta['blog_id'] = $doc->data->blog_id;
|
86 |
+
$wp_rp_meta['auth_key'] = $doc->data->auth_key;
|
87 |
+
update_option('wp_rp_meta', $wp_rp_meta);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
function wp_rp_statistics_supported() {
|
93 |
+
return function_exists('json_decode'); // PHP < 5.2.0
|
94 |
+
}
|
95 |
+
|
96 |
+
function wp_rp_upgrade() {
|
97 |
+
$wp_rp_meta = get_option('wp_rp_meta', false);
|
98 |
+
$version = false;
|
99 |
+
|
100 |
+
if($wp_rp_meta) {
|
101 |
+
$version = $wp_rp_meta['version'];
|
102 |
+
} else {
|
103 |
+
$wp_rp_old_options = get_option('wp_rp', false);
|
104 |
+
if($wp_rp_old_options) {
|
105 |
+
$version = '1.4';
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
if($version) {
|
110 |
+
if(version_compare($version, WP_RP_VERSION, '<')) {
|
111 |
+
call_user_func('wp_rp_migrate_' . str_replace('.', '_', $version));
|
112 |
+
wp_rp_upgrade();
|
113 |
+
}
|
114 |
+
} else {
|
115 |
+
wp_rp_install();
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
function wp_rp_install() {
|
120 |
+
$wp_rp_meta = array(
|
121 |
+
'blog_id' => false,
|
122 |
+
'auth_key' => false,
|
123 |
+
'version' => WP_RP_VERSION,
|
124 |
+
'first_version' => WP_RP_VERSION,
|
125 |
+
'new_user' => true,
|
126 |
+
'show_upgrade_tooltip' => false,
|
127 |
+
'show_ctr_banner' => false
|
128 |
+
);
|
129 |
+
|
130 |
+
$wp_rp_options = array(
|
131 |
+
'related_posts_title' => __('Related Posts', 'wp_related_posts'),
|
132 |
+
'related_posts_title_tag' => 'h3',
|
133 |
+
'missing_rp_algorithm' => 'random',
|
134 |
+
'missing_rp_title' => __('Random Posts', 'wp_related_posts'),
|
135 |
+
'display_excerpt' => false,
|
136 |
+
'excerpt_max_length' => 200,
|
137 |
+
'max_related_posts' => 5,
|
138 |
+
'not_on_categories' => '',
|
139 |
+
'on_single_post' => true,
|
140 |
+
'on_rss' => false,
|
141 |
+
'display_comment_count' => false,
|
142 |
+
'display_publish_date' => false,
|
143 |
+
'display_thumbnail' => true,
|
144 |
+
'thumbnail_display_title' => true,
|
145 |
+
'thumbnail_custom_field' => false,
|
146 |
+
'thumbnail_use_attached' => true,
|
147 |
+
'thumbnail_use_custom' => false,
|
148 |
+
'default_thumbnail_path' => false,
|
149 |
+
'theme_name' => 'vertical-m.css',
|
150 |
+
'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
|
151 |
+
'ctr_dashboard_enabled' => wp_rp_statistics_supported()
|
152 |
+
);
|
153 |
+
|
154 |
+
update_option('wp_rp_meta', $wp_rp_meta);
|
155 |
+
update_option('wp_rp_options', $wp_rp_options);
|
156 |
+
}
|
157 |
+
|
158 |
+
function wp_rp_migrate_1_4() {
|
159 |
+
global $wpdb;
|
160 |
+
|
161 |
+
$wp_rp = get_option('wp_rp');
|
162 |
+
|
163 |
+
$wp_rp_options = array();
|
164 |
+
|
165 |
+
////////////////////////////////
|
166 |
+
|
167 |
+
$wp_rp_options['missing_rp_algorithm'] = (isset($wp_rp['wp_no_rp']) && in_array($wp_rp['wp_no_rp'], array('text', 'random', 'commented', 'popularity'))) ? $wp_rp['wp_no_rp'] : 'random';
|
168 |
+
|
169 |
+
if(isset($wp_rp['wp_no_rp_text']) && $wp_rp['wp_no_rp_text']) {
|
170 |
+
$wp_rp_options['missing_rp_title'] = $wp_rp['wp_no_rp_text'];
|
171 |
+
} else {
|
172 |
+
if($wp_rp_options['missing_rp_algorithm'] === 'text') {
|
173 |
+
$wp_rp_options['missing_rp_title'] = __('No Related Posts', 'wp_related_posts');
|
174 |
+
} else {
|
175 |
+
$wp_rp_options['missing_rp_title'] = __('Random Posts', 'wp_related_posts');
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
$wp_rp_options['on_single_post'] = isset($wp_rp['wp_rp_auto']) ? !!$wp_rp['wp_rp_auto'] : true;
|
180 |
+
|
181 |
+
$wp_rp_options['display_comment_count'] = isset($wp_rp['wp_rp_comments']) ? !!$wp_rp['wp_rp_comments'] : false;
|
182 |
+
|
183 |
+
$wp_rp_options['display_publish_date'] = isset($wp_rp['wp_rp_date']) ? !!$wp_rp['wp_rp_date'] : false;
|
184 |
+
|
185 |
+
$wp_rp_options['display_excerpt'] = isset($wp_rp['wp_rp_except']) ? !!$wp_rp['wp_rp_except'] : false;
|
186 |
+
|
187 |
+
if(isset($wp_rp['wp_rp_except_number']) && is_numeric(trim($wp_rp['wp_rp_except_number']))) {
|
188 |
+
$wp_rp_options['excerpt_max_length'] = intval(trim($wp_rp['wp_rp_except_number']));
|
189 |
+
} else {
|
190 |
+
$wp_rp_options['excerpt_max_length'] = 200;
|
191 |
+
}
|
192 |
+
|
193 |
+
$wp_rp_options['not_on_categories'] = isset($wp_rp['wp_rp_exclude']) ? $wp_rp['wp_rp_exclude'] : '';
|
194 |
+
|
195 |
+
if(isset($wp_rp['wp_rp_limit']) && is_numeric(trim($wp_rp['wp_rp_limit']))) {
|
196 |
+
$wp_rp_options['max_related_posts'] = intval(trim($wp_rp['wp_rp_limit']));
|
197 |
+
} else {
|
198 |
+
$wp_rp_options['max_related_posts'] = 5;
|
199 |
+
}
|
200 |
+
|
201 |
+
$wp_rp_options['on_rss'] = isset($wp_rp['wp_rp_rss']) ? !!$wp_rp['wp_rp_rss'] : false;
|
202 |
+
|
203 |
+
$wp_rp_options['theme_name'] = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : 'plain.css';
|
204 |
+
|
205 |
+
$wp_rp_options['display_thumbnail'] = isset($wp_rp['wp_rp_thumbnail']) ? !!$wp_rp['wp_rp_thumbnail'] : false;
|
206 |
+
|
207 |
+
$custom_fields = $wpdb->get_col("SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)");
|
208 |
+
if(isset($wp_rp['wp_rp_thumbnail_post_meta']) && in_array($wp_rp['wp_rp_thumbnail_post_meta'], $custom_fields)) {
|
209 |
+
$wp_rp_options['thumbnail_custom_field'] = $wp_rp['wp_rp_thumbnail_post_meta'];
|
210 |
+
} else {
|
211 |
+
$wp_rp_options['thumbnail_custom_field'] = false;
|
212 |
+
}
|
213 |
+
|
214 |
+
$wp_rp_options['thumbnail_display_title'] = isset($wp_rp['wp_rp_thumbnail_text']) ? !!$wp_rp['wp_rp_thumbnail_text'] : false;
|
215 |
+
|
216 |
+
$wp_rp_options['related_posts_title'] = isset($wp_rp['wp_rp_title']) ? $wp_rp['wp_rp_title'] : '';
|
217 |
+
|
218 |
+
$wp_rp_options['related_posts_title_tag'] = isset($wp_rp['wp_rp_title_tag']) ? $wp_rp['wp_rp_title_tag'] : 'h3';
|
219 |
+
|
220 |
+
$wp_rp_options['default_thumbnail_path'] = (isset($wp_rp['wp_rp_default_thumbnail_path']) && $wp_rp['wp_rp_default_thumbnail_path']) ? $wp_rp['wp_rp_default_thumbnail_path'] : false;
|
221 |
+
|
222 |
+
$wp_rp_options['thumbnail_use_attached'] = isset($wp_rp["wp_rp_thumbnail_extract"]) && ($wp_rp["wp_rp_thumbnail_extract"] === 'yes');
|
223 |
+
|
224 |
+
$wp_rp_options['thumbnail_use_custom'] = $wp_rp_options['thumbnail_custom_field'] && !(isset($wp_rp['wp_rp_thumbnail_featured']) && $wp_rp['wp_rp_thumbnail_featured'] === 'yes');
|
225 |
+
|
226 |
+
$wp_rp_options['theme_custom_css'] = WP_RP_DEFAULT_CUSTOM_CSS;
|
227 |
+
|
228 |
+
$wp_rp_options['ctr_dashboard_enabled'] = false;
|
229 |
+
|
230 |
+
////////////////////////////////
|
231 |
+
|
232 |
+
$wp_rp_meta = array(
|
233 |
+
'blog_id' => false,
|
234 |
+
'auth_key' => false,
|
235 |
+
'version' => '1.5',
|
236 |
+
'first_version' => '1.4',
|
237 |
+
'new_user' => false,
|
238 |
+
'show_upgrade_tooltip' => true,
|
239 |
+
'show_ctr_banner' => true
|
240 |
+
);
|
241 |
+
|
242 |
+
update_option('wp_rp_meta', $wp_rp_meta);
|
243 |
+
update_option('wp_rp_options', $wp_rp_options);
|
244 |
+
}
|
defaults.php
DELETED
@@ -1,20 +0,0 @@
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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=LB3MVPLUAWCY6
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4.2
|
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 |
|
@@ -20,11 +20,17 @@ WordPress Related Posts Plugin will generate a related posts via WordPress tags,
|
|
20 |
|
21 |
== Screenshots ==
|
22 |
1. WordPress Related Posts default theme.
|
23 |
-
2. WordPress Related Posts
|
|
|
24 |
|
25 |
|
26 |
== Changelog ==
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
= 1.4 =
|
29 |
* Improved thumbnail support
|
30 |
* Optimized random posts generation
|
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.5
|
8 |
|
9 |
WordPress Related Posts Plugin will generate a related posts via WordPress tags, and add the related posts to feed.
|
10 |
|
20 |
|
21 |
== Screenshots ==
|
22 |
1. WordPress Related Posts default theme.
|
23 |
+
2. WordPress Related Posts statistics.
|
24 |
+
3. WordPress Related Posts setting.
|
25 |
|
26 |
|
27 |
== Changelog ==
|
28 |
|
29 |
+
= 1.5 =
|
30 |
+
* Pageview statistics in settings
|
31 |
+
* Custom CSS
|
32 |
+
* Bugfixes
|
33 |
+
|
34 |
= 1.4 =
|
35 |
* Improved thumbnail support
|
36 |
* Optimized random posts generation
|
screenshot-1.png
DELETED
Binary file
|
screenshot-2.png
DELETED
Binary file
|
settings.php
CHANGED
@@ -1,297 +1,458 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
4 |
|
5 |
-
function
|
6 |
-
$
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
-
function
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
|
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 |
-
|
52 |
-
if(!update_option("wp_rp",$wp_rp))
|
53 |
-
$message = "Update Failed";
|
54 |
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
$wp_no_rp = $wp_rp["wp_no_rp"];
|
65 |
-
$wp_rp_title_tag = $wp_rp["wp_rp_title_tag"];
|
66 |
|
67 |
-
|
|
|
68 |
|
69 |
-
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
-
?>
|
76 |
|
77 |
-
|
78 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
<td>
|
99 |
-
<input name="wp_rp_title_option" type="text" id="wp_rp_title" value="<?php echo $wp_rp["wp_rp_title"]; ?>" class="regular-text" />
|
100 |
-
</td>
|
101 |
-
</tr>
|
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">
|
109 |
-
<th scope="row"><?php _e("Categories to Exclude:",'wp_related_posts');?></th>
|
110 |
-
<td>
|
111 |
-
<?php
|
112 |
-
$exclude = explode(",",$wp_rp["wp_rp_exclude"]);
|
113 |
-
$args = array(
|
114 |
-
'orderby' => 'name',
|
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 } ?>
|
126 |
-
</td>
|
127 |
-
</tr>
|
128 |
-
</table>
|
129 |
-
<h3>Theme Settings <small style="color: #c33;">(new)</small></h3>
|
130 |
-
<table class="form-table">
|
131 |
-
<tr id="wp_rp_theme_options_wrap"></tr>
|
132 |
-
<tr>
|
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 |
-
|
148 |
-
|
149 |
|
150 |
-
|
151 |
-
$show_custom_thumbnails = wp_rp_show_custom_thumbnails($wp_rp);
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
157 |
|
158 |
-
|
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 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
<label>
|
180 |
-
|
181 |
-
|
182 |
-
<input type="file" name="wp_rp_default_thumbnail" />
|
183 |
</label>
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
<
|
198 |
-
|
|
|
199 |
<td>
|
200 |
-
|
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;'; ?>">
|
215 |
-
<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>
|
216 |
-
</label>
|
217 |
-
<br />
|
218 |
-
<label for="wp_rp_title_tag">
|
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 |
-
?>
|
233 |
-
</select>
|
234 |
-
</label>
|
235 |
</td>
|
236 |
</tr>
|
237 |
-
</table>
|
238 |
-
|
239 |
-
<h3><?php _e("If there are no related posts",'wp_related_posts');?></h3>
|
240 |
-
<table class="form-table">
|
241 |
<tr valign="top">
|
242 |
-
<th scope="row"><?php _e(
|
243 |
<td>
|
244 |
-
|
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>
|
253 |
</tr>
|
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 |
-
?>
|
272 |
-
</th>
|
273 |
-
<td>
|
274 |
-
<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" />
|
275 |
-
</td>
|
276 |
-
</tr>
|
277 |
-
</table>
|
278 |
-
<table class="form-table">
|
279 |
-
<h3><?php _e("Other Settings:",'wp_related_posts'); ?></h3>
|
280 |
<tr valign="top">
|
|
|
281 |
<td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
<label>
|
283 |
-
|
284 |
-
|
285 |
-
|
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>
|
292 |
</tr>
|
293 |
-
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
</div>
|
297 |
<?php }
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Tooltips
|
5 |
+
**/
|
6 |
|
7 |
+
function wp_rp_display_tooltips() {
|
8 |
+
$meta = wp_rp_get_meta();
|
9 |
|
10 |
+
if ($meta['show_upgrade_tooltip']) {
|
11 |
+
global $wp_rp_meta;
|
12 |
+
$meta['show_upgrade_tooltip'] = false;
|
13 |
+
update_option('wp_rp_meta', $meta);
|
14 |
+
$wp_rp_meta = $meta;
|
15 |
+
|
16 |
+
add_action('admin_enqueue_scripts', 'wp_rp_load_upgrade_tooltip');
|
17 |
+
}
|
18 |
}
|
19 |
+
function wp_rp_load_upgrade_tooltip() {
|
20 |
+
if (version_compare(get_bloginfo('version'), '3.3', '<')) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
|
24 |
+
wp_enqueue_style('wp-pointer');
|
25 |
+
wp_enqueue_script('wp-pointer');
|
26 |
+
add_action('admin_print_footer_scripts', 'wp_rp_print_upgrade_tooltip');
|
27 |
+
}
|
28 |
+
function wp_rp_print_upgrade_tooltip() {
|
29 |
+
$content = "<h3>Thanks for updating Related Posts plugin!</h3><p>We've added some new stuff to the Settings, go check them out. Let us know what you think.</p>";
|
30 |
+
wp_rp_print_tooltip($content);
|
31 |
}
|
32 |
|
33 |
+
function wp_rp_print_tooltip($content) {
|
34 |
+
?>
|
35 |
+
<script type="text/javascript">
|
36 |
+
jQuery(function () {
|
37 |
+
var body = jQuery(document.body),
|
38 |
+
collapse = jQuery('#collapse-menu'),
|
39 |
+
menu = jQuery('#menu-settings'),
|
40 |
+
wprpp = menu.find("a[href='options-general.php?page=wordpress-related-posts']"),
|
41 |
+
options = {
|
42 |
+
content: "<?php echo $content; ?>",
|
43 |
+
position: {
|
44 |
+
edge: 'left',
|
45 |
+
align: 'center',
|
46 |
+
of: menu.is('.wp-menu-open') && !menu.is('.folded *') ? wprpp : menu
|
47 |
+
},
|
48 |
+
close: function() {
|
49 |
+
menu.unbind('mouseenter mouseleave', wprpp_pointer);
|
50 |
+
collapse.unbind('mouseenter mouseleave', wprpp_pointer);
|
51 |
+
}
|
52 |
+
},
|
53 |
+
wprpp_pointer = function (e) {
|
54 |
+
setTimeout(function() {
|
55 |
+
if (wprpp.is(':visible')) {
|
56 |
+
options.position.of = wprpp;
|
57 |
+
} else {
|
58 |
+
options.position.of = menu;
|
59 |
+
}
|
60 |
+
body.pointer(options);
|
61 |
+
}, 200);
|
62 |
+
};
|
63 |
|
64 |
+
if (!wprpp.length) {
|
65 |
+
return;
|
|
|
|
|
|
|
|
|
66 |
}
|
|
|
67 |
|
68 |
+
body.pointer(options).pointer('open');
|
|
|
|
|
69 |
|
70 |
+
if (menu.is('.folded *') || !menu.is('.wp-menu-open')) {
|
71 |
+
menu.bind('mouseenter mouseleave', wprpp_pointer);
|
72 |
+
collapse.bind('mouseenter mouseleave', wprpp_pointer);
|
73 |
+
}
|
74 |
+
});
|
75 |
+
</script>
|
76 |
+
<?php
|
77 |
+
}
|
78 |
|
79 |
+
/**
|
80 |
+
* Settings
|
81 |
+
**/
|
82 |
|
83 |
+
add_action('admin_menu', 'wp_rp_settings_admin_menu');
|
84 |
|
85 |
+
function wp_rp_settings_admin_menu() {
|
86 |
+
$page = add_options_page(__('Related Posts', 'wp_related_posts'), __('Related Posts', 'wp_related_posts'), 'manage_options', 'wordpress-related-posts', 'wp_rp_settings_page');
|
|
|
|
|
87 |
|
88 |
+
add_action('admin_print_styles-' . $page, 'wp_rp_settings_styles');
|
89 |
+
add_action('admin_print_scripts-' . $page, 'wp_rp_settings_scripts');
|
90 |
|
91 |
+
wp_rp_display_tooltips();
|
92 |
+
}
|
93 |
|
94 |
+
function wp_rp_settings_scripts() {
|
95 |
+
wp_enqueue_script('wp_rp_themes_script', plugins_url('static/js/themes.js', __FILE__), array('jquery'));
|
96 |
+
wp_enqueue_script("wp_rp_dashboard_script", plugins_url("static/js/dashboard.js", __FILE__), array( 'jquery' ) );
|
97 |
+
}
|
98 |
+
function wp_rp_settings_styles() {
|
99 |
+
wp_enqueue_style("wp_rp_dashaboard_style", plugins_url("static/css/dashboard.css", __FILE__));
|
100 |
+
}
|
101 |
+
|
102 |
+
function wp_rp_settings_page()
|
103 |
+
{
|
104 |
+
global $wp_rp_empty_options;
|
105 |
+
|
106 |
+
$title_tags = array('h2', 'h3', 'h4', 'p', 'div');
|
107 |
+
|
108 |
+
$postdata = stripslashes_deep($_POST);
|
109 |
+
|
110 |
+
if(sizeof($_POST))
|
111 |
+
{
|
112 |
+
$message = __('WordPress Related Posts Setting Updated', 'wp_related_posts');
|
113 |
+
|
114 |
+
$old_options = wp_rp_get_options();
|
115 |
+
$new_options = array(
|
116 |
+
'missing_rp_algorithm' => isset($postdata['wp_rp_missing_rp_algorithm']) ? trim($postdata['wp_rp_missing_rp_algorithm']) : 'random',
|
117 |
+
'missing_rp_title' => isset($postdata['wp_rp_missing_rp_title']) ? ($postdata['wp_rp_missing_rp_title']) : __('Random Posts', 'wp_related_posts'),
|
118 |
+
'on_single_post' => isset($postdata['wp_rp_on_single_post']),
|
119 |
+
'display_comment_count' => isset($postdata['wp_rp_display_comment_count']),
|
120 |
+
'display_publish_date' => isset($postdata['wp_rp_display_publish_date']),
|
121 |
+
'display_excerpt' => isset($postdata['wp_rp_display_excerpt']),
|
122 |
+
'excerpt_max_length' => (isset($postdata['wp_rp_excerpt_max_length']) && is_numeric(trim($postdata['wp_rp_excerpt_max_length']))) ? intval(trim($postdata['wp_rp_excerpt_max_length'])) : 200,
|
123 |
+
'max_related_posts' => (isset($postdata['wp_rp_max_related_posts']) && is_numeric(trim($postdata['wp_rp_max_related_posts']))) ? intval(trim($postdata['wp_rp_max_related_posts'])) : 5,
|
124 |
+
'on_rss' => isset($postdata['wp_rp_on_rss']),
|
125 |
+
'display_thumbnail' => isset($postdata['wp_rp_display_thumbnail']),
|
126 |
+
'thumbnail_custom_field' => isset($postdata['wp_rp_thumbnail_custom_field']) ? trim($postdata['wp_rp_thumbnail_custom_field']) : false,
|
127 |
+
'thumbnail_display_title' => isset($postdata['wp_rp_thumbnail_display_title']),
|
128 |
+
'related_posts_title' => isset($postdata['wp_rp_related_posts_title']) ? trim($postdata['wp_rp_related_posts_title']) : '',
|
129 |
+
'related_posts_title_tag' => isset($postdata['wp_rp_related_posts_title_tag']) ? $postdata['wp_rp_related_posts_title_tag'] : 'h3',
|
130 |
+
'thumbnail_use_attached' => isset($postdata['wp_rp_thumbnail_use_attached']),
|
131 |
+
'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
|
132 |
+
'ctr_dashboard_enabled' => isset($postdata['wp_rp_ctr_dashboard_enabled']) ? $postdata['wp_rp_ctr_dashboard_enabled'] : false
|
133 |
+
);
|
134 |
+
|
135 |
+
if(!isset($postdata['wp_rp_not_on_categories'])) {
|
136 |
+
$new_options['not_on_categories'] = '';
|
137 |
+
} else if(is_array($postdata['wp_rp_not_on_categories'])) {
|
138 |
+
$new_options['not_on_categories'] = join(',', $postdata['wp_rp_not_on_categories']);
|
139 |
+
} else {
|
140 |
+
$new_options['not_on_categories'] = trim($postdata['wp_rp_not_on_categories']);
|
141 |
}
|
|
|
142 |
|
143 |
+
if(isset($postdata['wp_rp_theme_name'])) { // If this isn't set, maybe the AJAX didn't load...
|
144 |
+
$new_options['theme_name'] = trim($postdata['wp_rp_theme_name']);
|
|
|
|
|
145 |
|
146 |
+
if(isset($postdata['wp_rp_theme_custom_css'])) {
|
147 |
+
$new_options['theme_custom_css'] = $postdata['wp_rp_theme_custom_css'];
|
148 |
+
} else {
|
149 |
+
$new_options['theme_custom_css'] = '';
|
150 |
+
}
|
151 |
+
} else {
|
152 |
+
$new_options['theme_name'] = $old_options['theme_name'];
|
153 |
+
$new_options['theme_custom_css'] = $old_options['theme_custom_css'];
|
154 |
+
}
|
155 |
|
156 |
+
$default_thumbnail_path = wp_rp_upload_default_thumbnail_file();
|
157 |
+
if($default_thumbnail_path) {
|
158 |
+
$new_options['default_thumbnail_path'] = $default_thumbnail_path;
|
159 |
+
} else {
|
160 |
+
if(isset($postdata['wp_rp_default_thumbnail_remove'])) {
|
161 |
+
$new_options['default_thumbnail_path'] = false;
|
162 |
+
} else {
|
163 |
+
$new_options['default_thumbnail_path'] = $old_options['default_thumbnail_path'];
|
164 |
+
}
|
165 |
+
}
|
166 |
|
167 |
+
if ($old_options != $new_options) {
|
168 |
+
if($new_options['ctr_dashboard_enabled'] && !$old_options['ctr_dashboard_enabled']) {
|
169 |
+
$meta = wp_rp_get_meta();
|
170 |
+
if($meta['show_ctr_banner']) {
|
171 |
+
$meta['show_ctr_banner'] = false;
|
172 |
+
update_option('wp_rp_meta', $meta);
|
173 |
+
}
|
174 |
+
}
|
175 |
|
176 |
+
global $wp_rp_options;
|
177 |
+
$wp_rp_options = null; // clear options cache to execute wp_rp_get_options again
|
178 |
|
179 |
+
if(!update_option('wp_rp_options', $new_options)) {
|
180 |
+
$message = __('Update Failed', 'wp_related_posts');
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
+
$options = wp_rp_get_options();
|
186 |
+
$meta = wp_rp_get_meta();
|
187 |
|
188 |
+
?>
|
|
|
189 |
|
190 |
+
<div class="wrap" id="wp_rp_wrap">
|
191 |
+
<?php
|
192 |
+
$missing_rp_algorithm = $options['missing_rp_algorithm'];
|
193 |
+
$related_posts_title_tag = $options['related_posts_title_tag'];
|
194 |
+
$theme_name = $options['theme_name'];
|
195 |
+
$theme_custom_css = $options['theme_custom_css'];
|
196 |
|
197 |
+
include(dirname(__FILE__) . '/static/settings.js.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
+
if ($meta['new_user']) {
|
200 |
+
$meta['new_user'] = false;
|
201 |
+
update_option('wp_rp_meta', $meta);
|
202 |
+
}
|
203 |
+
?>
|
204 |
|
205 |
+
<input type="hidden" id="wp_rp_json_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL . WP_RP_STATIC_JSON_PATH); ?>" />
|
206 |
+
<input type="hidden" id="wp_rp_version" value="<?php esc_attr_e(WP_RP_VERSION); ?>" />
|
207 |
+
<input type="hidden" id="wp_rp_theme_selected" value="<?php esc_attr_e($theme_name); ?>" />
|
208 |
+
|
209 |
+
<?php if (wp_rp_statistics_supported() && $options['ctr_dashboard_enabled']):?>
|
210 |
+
<input type="hidden" id="wp_rp_dashboard_url" value="<?php esc_attr_e(WP_RP_CTR_BASE_URL); ?>" />
|
211 |
+
<input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
|
212 |
+
<input type="hidden" id="wp_rp_auth_key" value="<?php esc_attr_e($meta['auth_key']); ?>" />
|
213 |
+
<?php endif; ?>
|
214 |
+
|
215 |
+
<div class="header">
|
216 |
+
<h2 class="title"><?php _e("Related Posts",'wp_related_posts');?></h2>
|
217 |
+
<p class="desc"><?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>
|
218 |
+
<div class="support">
|
219 |
+
<h4><?php _e("Awesome support", 'wp_related_posts'); ?></h4>
|
220 |
+
<p>
|
221 |
+
<?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>.
|
222 |
+
</p>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
<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>
|
226 |
|
227 |
+
<?php if (isset($message)): ?>
|
228 |
+
<div id="message" class="updated fade"><p><?php echo $message ?>.</p></div>
|
229 |
+
<?php endif; ?>
|
230 |
+
|
231 |
+
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=wordpress-related-posts">
|
232 |
+
<?php if (wp_rp_statistics_supported()): ?>
|
233 |
+
<h2><?php _e("Statistics",'wp_related_posts');?></h2>
|
234 |
+
<div id="wp_rp_statistics_wrap">
|
235 |
+
<div class="option-enable">
|
236 |
+
<?php if ($meta['show_ctr_banner']):?>
|
237 |
+
<img src="<?php echo plugins_url("static/img/arrow.png", __FILE__); ?>" class="arrow" />
|
238 |
+
<?php endif; ?>
|
239 |
<label>
|
240 |
+
<input name="wp_rp_ctr_dashboard_enabled" type="checkbox" value="yes" <?php echo $options['ctr_dashboard_enabled'] ? "checked=\"checked\"" : ""; ?> />
|
241 |
+
<span><?php _e("Turn statistics on",'wp_related_posts');?> </span>
|
|
|
242 |
</label>
|
243 |
+
</div>
|
244 |
+
<?php if ($meta['show_ctr_banner']):?>
|
245 |
+
<div class="message enable">
|
246 |
+
<?php _e("Curious about the Click-Through Statistics on your blog?",'wp_related_posts');?>
|
247 |
+
</div>
|
248 |
+
<?php endif; ?>
|
249 |
+
<div class="message unavailable"><?php _e("Statistics currently unavailable",'wp_related_posts');?></div>
|
250 |
+
</div>
|
251 |
+
<?php endif; ?>
|
252 |
+
|
253 |
+
<h2><?php _e("Settings",'wp_related_posts');?></h2>
|
254 |
+
<h3><?php _e("Basic Settings",'wp_related_posts');?></h3>
|
255 |
+
|
256 |
+
<table class="form-table">
|
257 |
+
<tr valign="top">
|
258 |
+
<th scope="row"><?php _e('Related Posts Title:', 'wp_related_posts'); ?></th>
|
259 |
<td>
|
260 |
+
<input name="wp_rp_related_posts_title" type="text" id="wp_rp_related_posts_title" value="<?php esc_attr_e($options['related_posts_title']); ?>" class="regular-text" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
</td>
|
262 |
</tr>
|
|
|
|
|
|
|
|
|
263 |
<tr valign="top">
|
264 |
+
<th scope="row"><?php _e('Number of Posts:', 'wp_related_posts');?></th>
|
265 |
<td>
|
266 |
+
<input name="wp_rp_max_related_posts" type="number" step="1" id="wp_rp_max_related_posts" class="small-text" min="1" value="<?php esc_attr_e($options['max_related_posts']); ?>" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
</td>
|
268 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
<tr valign="top">
|
270 |
+
<th scope="row"><?php _e('Categories to Exclude:', 'wp_related_posts'); ?></th>
|
271 |
<td>
|
272 |
+
<?php
|
273 |
+
$exclude = explode(',', $options['not_on_categories']);
|
274 |
+
$args = array(
|
275 |
+
'orderby' => 'name',
|
276 |
+
'order' => 'ASC',
|
277 |
+
'hide_empty' => false
|
278 |
+
);
|
279 |
+
|
280 |
+
foreach (get_categories($args) as $category) :
|
281 |
+
?>
|
282 |
<label>
|
283 |
+
<input name="wp_rp_not_on_categories[]" type="checkbox" id="wp_rp_not_on_categories" value="<?php esc_attr_e($category->cat_ID); ?>"<?php checked(in_array($category->cat_ID, $exclude)); ?> />
|
284 |
+
<?php esc_html_e($category->cat_name); ?>
|
285 |
+
<br />
|
|
|
|
|
|
|
|
|
286 |
</label>
|
287 |
+
<?php endforeach; ?>
|
288 |
</td>
|
289 |
</tr>
|
290 |
+
</table>
|
291 |
+
|
292 |
+
<h3>Theme Settings <small style="color: #c33;">(new)</small></h3>
|
293 |
+
<table class="form-table">
|
294 |
+
<tr id="wp_rp_theme_options_wrap" style="display: none;">
|
295 |
+
<th scope="row">Select Theme:</th>
|
296 |
+
<td class="theme-list"></td>
|
297 |
+
</tr>
|
298 |
+
<tr id="wp_rp_theme_custom_css_wrap" style="display: none; ">
|
299 |
+
<th scope="row"></th>
|
300 |
+
<td>
|
301 |
+
<textarea style="width: 300px; height: 215px;" name="wp_rp_theme_custom_css" class="custom-css"><?php echo htmlspecialchars($theme_custom_css, ENT_QUOTES); ?></textarea>
|
302 |
+
</td>
|
303 |
+
</tr>
|
304 |
+
<tr>
|
305 |
+
<th scope="row"><?php _e("Thumbnail Options:",'wp_related_posts'); ?></th>
|
306 |
+
<td>
|
307 |
+
<label>
|
308 |
+
<input name="wp_rp_display_thumbnail" type="checkbox" id="wp_rp_display_thumbnail" value="yes"<?php checked($options["display_thumbnail"]); ?> onclick="wp_rp_display_thumbnail_onclick();" />
|
309 |
+
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
310 |
+
</label>
|
311 |
+
<br />
|
312 |
+
<span id="wp_rp_thumbnail_span" style="<?php echo $options["display_thumbnail"] ? '' : 'display:none;'; ?>">
|
313 |
+
<label>
|
314 |
+
<input name="wp_rp_thumbnail_display_title" type="checkbox" id="wp_rp_thumbnail_display_title" value="yes"<?php checked($options["thumbnail_display_title"]); ?> />
|
315 |
+
<?php _e('Display Post Titles', 'wp_related_posts');?>
|
316 |
+
</label>
|
317 |
+
<br />
|
318 |
+
|
319 |
+
<?php
|
320 |
+
global $wpdb;
|
321 |
+
|
322 |
+
$custom_fields = $wpdb->get_col( "SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)" );
|
323 |
+
|
324 |
+
if($custom_fields) :
|
325 |
+
?>
|
326 |
+
<label><input name="wp_rp_thumbnail_use_custom" type="radio" value="no" <?php checked(!$options['thumbnail_use_custom']); ?>> Use featured image</label>
|
327 |
+
<label><input name="wp_rp_thumbnail_use_custom" type="radio" value="yes" <?php checked($options['thumbnail_use_custom']); ?>> Use custom field</label>
|
328 |
+
|
329 |
+
<select name="wp_rp_thumbnail_custom_field" id="wp_rp_thumbnail_custom_field" class="postform">
|
330 |
+
|
331 |
+
<?php foreach ( $custom_fields as $custom_field ) : ?>
|
332 |
+
<option value="<?php esc_attr_e($custom_field); ?>"<?php selected($options["thumbnail_custom_field"], $custom_field); ?>><?php esc_html_e($custom_field);?></option>
|
333 |
+
<?php endforeach; ?>
|
334 |
+
|
335 |
+
</select>
|
336 |
+
<br />
|
337 |
+
<?php endif; ?>
|
338 |
+
|
339 |
+
<label>
|
340 |
+
<input name="wp_rp_thumbnail_use_attached" type="checkbox" value="yes" <?php checked($options["thumbnail_use_attached"]); ?>>
|
341 |
+
<?php _e("If featured image is missing, show the first uploaded image of the post",'wp_related_posts');?>
|
342 |
+
</label>
|
343 |
+
<br />
|
344 |
+
|
345 |
+
|
346 |
+
<br />
|
347 |
+
<label>
|
348 |
+
<?php _e('For posts without images, a default image will be shown.<br/>
|
349 |
+
You can upload your own default image here','wp_related_posts');?>
|
350 |
+
<input type="file" name="wp_rp_default_thumbnail" />
|
351 |
+
</label>
|
352 |
+
<?php if($options['default_thumbnail_path']) : ?>
|
353 |
+
<span style="display: inline-block; vertical-align: top; *display: inline; zoom: 1;">
|
354 |
+
<img style="padding: 3px; border: 1px solid #DFDFDF; border-radius: 3px;" valign="top" width="80" height="80" src="<?php esc_attr_e(wp_rp_get_default_thumbnail_url()); ?>" alt="selected thumbnail" />
|
355 |
+
<br />
|
356 |
+
<label>
|
357 |
+
<input type="checkbox" name="wp_rp_default_thumbnail_remove" value="yes" />
|
358 |
+
<?php _e("Remove selected",'wp_related_posts');?>
|
359 |
+
</label>
|
360 |
+
</span>
|
361 |
+
<?php endif; ?>
|
362 |
+
</span>
|
363 |
+
</td>
|
364 |
+
</tr>
|
365 |
+
<tr>
|
366 |
+
<th scope="row"><?php _e("Display Options:",'wp_related_posts'); ?></th>
|
367 |
+
<td>
|
368 |
+
<label>
|
369 |
+
<input name="wp_rp_display_comment_count" type="checkbox" id="wp_rp_display_comment_count" value="yes" <?php checked($options["display_comment_count"]); ?>>
|
370 |
+
<?php _e("Display Number of Comments",'wp_related_posts');?>
|
371 |
+
</label><br />
|
372 |
+
<label>
|
373 |
+
<input name="wp_rp_display_publish_date" type="checkbox" id="wp_rp_display_publish_date" value="yes" <?php checked($options["display_publish_date"]); ?>>
|
374 |
+
<?php _e("Display Publish Date",'wp_related_posts');?>
|
375 |
+
</label><br />
|
376 |
+
<label>
|
377 |
+
<input name="wp_rp_display_excerpt" type="checkbox" id="wp_rp_display_excerpt" value="yes"<?php checked($options["display_excerpt"]); ?> onclick="wp_rp_display_excerpt_onclick();" >
|
378 |
+
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
379 |
+
</label>
|
380 |
+
<label id="wp_rp_excerpt_max_length_label"<?php echo $options["display_excerpt"] ? '' : ' style="display: none;"'; ?>>
|
381 |
+
<input name="wp_rp_excerpt_max_length" type="text" id="wp_rp_excerpt_max_length" class="small-text" value="<?php esc_attr_e($options["excerpt_max_length"]); ?>" /> <span class="description"><?php _e('Maximum Number of Characters.', 'wp_related_posts'); ?></span>
|
382 |
+
</label><br/>
|
383 |
+
<label for="wp_rp_related_posts_title_tag">
|
384 |
+
<?php _e('Related Posts Title Tag', 'wp_related_posts'); ?>
|
385 |
+
<select name="wp_rp_related_posts_title_tag" id="wp_rp_related_posts_title_tag" class="postform">
|
386 |
+
<?php
|
387 |
+
foreach ($title_tags as $tag) :
|
388 |
+
?>
|
389 |
+
<option value="<?php esc_attr_e($tag); ?>"<?php selected($related_posts_title_tag, $tag); ?>><<?php esc_html_e($tag); ?>></option>
|
390 |
+
<?php endforeach; ?>
|
391 |
+
</select>
|
392 |
+
</label>
|
393 |
+
</td>
|
394 |
+
</tr>
|
395 |
+
</table>
|
396 |
+
|
397 |
+
<h3><?php _e("If there are no related posts",'wp_related_posts');?></h3>
|
398 |
+
<table class="form-table">
|
399 |
+
<tr valign="top">
|
400 |
+
<th scope="row"><?php _e("Display:",'wp_related_posts'); ?></th>
|
401 |
+
<td>
|
402 |
+
<select name="wp_rp_missing_rp_algorithm" id="wp_rp_missing_rp_algorithm" onchange="wp_rp_missing_rp_algorithm_onchange();" class="postform">
|
403 |
+
<option value="text"<?php selected($missing_rp_algorithm, 'text'); ?> ><?php _e("Text: 'No Related Posts'",'wp_related_posts'); ?></option>
|
404 |
+
<option value="random"<?php selected($missing_rp_algorithm, 'random'); ?>><?php _e("Random Posts",'wp_related_posts'); ?></option>
|
405 |
+
<option value="commented"<?php selected($missing_rp_algorithm, 'commented'); ?>><?php _e("Most Commented Posts",'wp_related_posts'); ?></option>
|
406 |
+
<?php if(function_exists('akpc_most_popular')) : ?>
|
407 |
+
<option value="popularity" <?php selected($missing_rp_algorithm, 'popularity'); ?>><?php _e("Most Popular Posts",'wp_related_posts'); ?></option>
|
408 |
+
<?php endif; ?>
|
409 |
+
</select>
|
410 |
+
</td>
|
411 |
+
</tr>
|
412 |
+
<tr valign="top" scope="row">
|
413 |
+
<th id="wp_rp_missing_rp_title_th" scope="row">
|
414 |
+
<?php
|
415 |
+
switch($missing_rp_algorithm) {
|
416 |
+
case 'text':
|
417 |
+
_e('No Related Posts Text:', 'wp_related_posts');
|
418 |
+
break;
|
419 |
+
case 'random':
|
420 |
+
_e('Random Posts Title:', 'wp_related_posts');
|
421 |
+
break;
|
422 |
+
case 'commented':
|
423 |
+
_e('Most Commented Posts Title:', 'wp_related_posts');
|
424 |
+
break;
|
425 |
+
case 'popularity':
|
426 |
+
_e('Most Popular Posts Title:', 'wp_related_posts');
|
427 |
+
break;
|
428 |
+
}
|
429 |
+
?>
|
430 |
+
</th>
|
431 |
+
<td>
|
432 |
+
<input name="wp_rp_missing_rp_title" type="text" id="wp_rp_missing_rp_title" value="<?php esc_attr_e($options['missing_rp_title']); ?>" class="regular-text" />
|
433 |
+
</td>
|
434 |
+
</tr>
|
435 |
+
</table>
|
436 |
+
|
437 |
+
<h3><?php _e("Other Settings:",'wp_related_posts'); ?></h3>
|
438 |
+
<table class="form-table">
|
439 |
+
<tr valign="top">
|
440 |
+
<td>
|
441 |
+
<label>
|
442 |
+
<input name="wp_rp_on_single_post" type="checkbox" id="wp_rp_on_single_post" value="yes" <?php checked($options['on_single_post']); ?>>
|
443 |
+
<?php _e("Auto Insert Related Posts",'wp_related_posts');?>
|
444 |
+
</label>
|
445 |
+
(or add `<?php wp_related_posts()?>` to your single post template)
|
446 |
+
<br />
|
447 |
+
<label>
|
448 |
+
<input name="wp_rp_on_rss" type="checkbox" id="wp_rp_on_rss" value="yes"<?php checked($options['on_rss']); ?>>
|
449 |
+
<?php _e("Display Related Posts in Feed",'wp_related_posts');?>
|
450 |
+
</label>
|
451 |
+
</td>
|
452 |
+
</tr>
|
453 |
+
</table>
|
454 |
+
<p class="submit"><input type="submit" value="<?php _e('Save changes', 'wp_related_posts'); ?>" class="button-primary" /></p>
|
455 |
+
|
456 |
+
</form>
|
457 |
</div>
|
458 |
<?php }
|
static/css/dashboard.css
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#wp_rp_wrap, #wp_rp_wrap h2, #wp_rp_wrap h3, #wp_rp_wrap h4 {color: #464646;}
|
2 |
+
|
3 |
+
#wp_rp_wrap h2 {font-size: 23px;}
|
4 |
+
#wp_rp_wrap h3 {font-size: 14px;}
|
5 |
+
#wp_rp_wrap label {user-select: none;-moz-user-select: none;-webkit-user-select: none;}
|
6 |
+
#wp_rp_wrap p, #wp_rp_wrap h4 {font-size: 12px;}
|
7 |
+
|
8 |
+
#wp_rp_wrap th {padding-left: 0; font-size: 14px;}
|
9 |
+
|
10 |
+
#wp_rp_wrap div.header {border-bottom: 1px solid #ddd; position: relative; padding-bottom: 5px;}
|
11 |
+
#wp_rp_wrap .updated, #wp_rp_wrap .error {max-width: 600px;}
|
12 |
+
#wp_rp_wrap div.header h2.title {font-size: 2.5em; line-height: 1em; font-weight: bold;}
|
13 |
+
#wp_rp_wrap div.header p.desc {font-size: 1.2em; line-height: 1.5em; max-width: 430px;}
|
14 |
+
#wp_rp_wrap div.header div.support {padding: 15px 15px 15px 67px; background: url(../img/icon_support.png) 15px 20px no-repeat; background-size: 37px 37px; border: 1px solid #ddd; position: absolute; top: 10px; right: 0px; width: 150px;}
|
15 |
+
#wp_rp_wrap div.header div.support h4 {text-transform: uppercase; font-weight: bold; margin: 0; font-size: 11px;}
|
16 |
+
#wp_rp_wrap div.header div.support p {margin: 0; font-size: 11px;}
|
17 |
+
#wp_rp_wrap div.header div.support p a {color: #82c1cb; font-weight: bold; text-decoration: none;}
|
18 |
+
|
19 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap {padding: 5px 0;}
|
20 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap .option-enable {width: 790px; text-align: right; height: 30px;}
|
21 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li {display: inline-block; zoom: 1; *display: inline; width: 250px; margin: 0 20px 0 0; padding: 0; position: relative;}
|
22 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li div.overlay {display: none; position: absolute; top: 0; left: 0; width: 240px; padding: 100px 10px 10px 10px; margin: -5px 0 0 -5px; border: 1px solid #ccc; box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);}
|
23 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li div.overlay p {background: #fff; margin: -10px; padding: 10px;}
|
24 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li:hover div.overlay {display: block;}
|
25 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li h4 {border-bottom: 2px solid #ccc; text-transform: uppercase; font-weight: normal; padding: 5px 0; margin: 0;}
|
26 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li h4 span {text-transform: lowercase; font-size: 11px; color: #999; float: right;}
|
27 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li p.num {font-size: 40px; line-height: 40px; color: #82c1cb; font-weight: bold; margin: 15px 0;}
|
28 |
+
|
29 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap div.message {font-size: 25px; line-height: 1em; padding-top: 50px; margin-bottom: 15px; position: relative; font-weight: bold;}
|
30 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap div.message.enable {color: #82c1cb;}
|
31 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap div.message.unavailable {color: #848484; display: none; padding-top: 20px;}
|
32 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap div.option-enable img.arrow {width: 83px; height: 51px; margin-bottom: -40px; margin-right: 1em;}
|
static/img/arrow.png
ADDED
Binary file
|
static/img/icon_support.png
ADDED
Binary file
|
static/js/dashboard.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
(function($){var template_eval=function(template,vars){$.each(vars,function(k,v){template=template.replace(new RegExp('{{ *'+k+' *}}'),v);});return template;};$(function(){var wrap=$('#wp_rp_statistics_wrap'),dashboard_url=$('#wp_rp_dashboard_url').val(),blog_id=$('#wp_rp_blog_id').val(),auth_key=$('#wp_rp_auth_key').val(),li_template='<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>';req_timeout=null,update_interval=null,update_interval_sec=2000,update_interval_error_sec=30000,updating=false,ul=null,set_update_interval=function(interval){if(!interval){interval=update_interval_sec;}
|
3 |
+
clearInterval(update_interval);if(interval>0){update_interval=setInterval(update_dashboard,interval);}},display_error=function(hidden){var wrap=$('#wp_rp_statistics_wrap');if(!hidden){wrap.find('.unavailable').slideDown();}
|
4 |
+
set_update_interval(update_interval_error_sec);updating=false;},create_dashboard=function(){ul=$('<ul class="statistics" />');wrap.find('.unavailable').slideUp();ul.append(template_eval(li_template,{'class':'ctr',title:'click-through rate',description:'Number of clicks on a Related Post divided by the number of times the post was shown to readers. Tip: Using thumbnails will generally rise Click-through Rates.',range:'last 30 days',}));ul.append(template_eval(li_template,{'class':'pageviews',title:'page views',description:'Number of times the page (usually post) was loaded to readers.',range:'last 30 days',}));ul.append(template_eval(li_template,{'class':'clicks',title:'clicks',description:'Number of times a reader has clicked on one of the Related Posts.',range:'last 30 days',}));ul.hide();wrap.append(ul);ul.slideDown();},update_dashboard=function(first){if(updating){return;}
|
5 |
+
updating=true;req_timeout=setTimeout(function(){display_error(!first);},2000);$.getJSON(dashboard_url+'pageviews/?callback=?',{blog_id:blog_id,auth_key:auth_key},function(response){clearTimeout(req_timeout);if(!response||response.status!=='ok'||!response.data){display_error(!first);return;}
|
6 |
+
if(!ul){create_dashboard();}
|
7 |
+
set_update_interval(response.data.update_interval);ul.find('.ctr .num').html(response.data.ctr+'%');ul.find('.pageviews .num').html(response.data.pageviews);ul.find('.clicks .num').html(response.data.clicks);updating=false;});};if(dashboard_url){if(!blog_id||!auth_key){display_error();return;}
|
8 |
+
update_dashboard(true);update_interval=setInterval(update_dashboard,2000);}
|
9 |
+
var em=$("<em>(don't forget to save the changes)</em>").css({'display':'none','color':'red'}),span=$('#wp_rp_statistics_wrap .option-enable span'),label=span.parent(),label_position=label.position(),img=label.parent().find('img'),img_position=img.position(),ctr_checkbox=label.find('input'),initial_ctr_checkbox_value=ctr_checkbox[0].checked;label.css({'position':'absolute','top':label_position.top+'px','left':label_position.left+'px'});img.css({'position':'absolute','top':img_position.top+'px','left':img_position.left+'px'});span.append(em);ctr_checkbox.change(function(){if(this.checked!==initial_ctr_checkbox_value){em.show();}else{em.hide();}});});}(jQuery));
|
static/js/themes.js
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
|
2 |
+
(function($){$(function(){var wrap=$('#wp_rp_theme_options_wrap'),json_url=$('#wp_rp_json_url').val(),plugin_version=$('#wp_rp_version').val(),current_theme=$('#wp_rp_theme_selected').val(),themes=null,update_themes=function(){var td=wrap.find('td.theme-list');td.empty();$.each(themes,function(i,theme){var selected=theme.location===current_theme?'checked="checked"':'';td.append('<label><input '+selected+' class="theme-option" type="radio" name="wp_rp_theme_name" value="'+theme.location+'" /> '+theme.name+'</label><br />');});td.find('input.theme-option[value=custom.css]').change(function(){update_custom_css_area($(this).val());});wrap.append(td);wrap.show();update_custom_css_area(current_theme);},append_get_themes_script=function(){var script=document.createElement('script'),body=document.getElementsByTagName("body").item(0);script.type='text/javascript';script.src=json_url+'themes.js?plv='+plugin_version;body.appendChild(script);},update_custom_css_area=function(selected_theme){var wrap_cc=$('#wp_rp_theme_custom_css_wrap');if(selected_theme==='custom.css'){wrap_cc.show();}else{wrap_cc.hide();}};window.wp_rp_themes_cb=function(data){if(data&&data.themes){themes=data.themes;if(themes){update_themes();}}};append_get_themes_script();if(!window.localStorage||!window.localStorage.wp_wp_survey_1){$('#wp-rp-survey').show();}
|
3 |
+
$('#wp-rp-survey .close, #wp-rp-survey .link').click(function(){$('#wp-rp-survey').fadeOut();if(window.localStorage){window.localStorage.wp_wp_survey_1="close";}});});}(jQuery));
|
static/settings.js.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
function
|
3 |
-
var
|
4 |
-
var
|
5 |
-
var
|
6 |
-
switch(
|
7 |
case 'text':
|
8 |
-
|
9 |
-
|
10 |
break;
|
11 |
case 'random':
|
12 |
-
|
13 |
-
|
14 |
break;
|
15 |
case 'commented':
|
16 |
-
|
17 |
-
|
18 |
break;
|
19 |
case 'popularity':
|
20 |
-
|
21 |
-
|
22 |
break;
|
23 |
default:
|
24 |
-
|
25 |
}
|
26 |
-
if(
|
27 |
-
|
28 |
}
|
29 |
}
|
30 |
-
function
|
31 |
-
var
|
32 |
-
var
|
33 |
-
if(
|
34 |
-
|
35 |
} else {
|
36 |
-
|
37 |
}
|
38 |
}
|
39 |
-
function
|
40 |
-
var
|
41 |
var wp_rp_thumbnail_span = document.getElementById('wp_rp_thumbnail_span');
|
42 |
-
if(
|
43 |
wp_rp_thumbnail_span.style.display = '';
|
44 |
jQuery('#wp-rp-thumbnails-info').fadeOut();
|
45 |
if (window.localStorage) {
|
@@ -56,11 +56,11 @@
|
|
56 |
var _gaq = _gaq || [];
|
57 |
_gaq.push(['_setAccount', 'UA-34712447-1']);
|
58 |
_gaq.push(['_trackPageview']);
|
59 |
-
<?php if(
|
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', '
|
63 |
-
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_language', '
|
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]);
|
65 |
|
66 |
(function() {
|
1 |
<script type="text/javascript">
|
2 |
+
function wp_rp_missing_rp_algorithm_onchange(){
|
3 |
+
var wp_rp_missing_rp_algorithm = document.getElementById('wp_rp_missing_rp_algorithm');
|
4 |
+
var wp_rp_missing_rp_title_th = document.getElementById('wp_rp_missing_rp_title_th');
|
5 |
+
var wp_rp_missing_rp_title = document.getElementById('wp_rp_missing_rp_title');
|
6 |
+
switch(wp_rp_missing_rp_algorithm.value){
|
7 |
case 'text':
|
8 |
+
wp_rp_missing_rp_title_th.innerHTML = '<?php _e("No Related Posts Text:", 'wp_related_posts'); ?>';
|
9 |
+
wp_rp_missing_rp_title.value = '<?php _e("No Related Posts", 'wp_related_posts'); ?>';
|
10 |
break;
|
11 |
case 'random':
|
12 |
+
wp_rp_missing_rp_title_th.innerHTML = '<?php _e("Random Posts Title:", 'wp_related_posts'); ?>';
|
13 |
+
wp_rp_missing_rp_title.value = '<?php _e("Random Posts", 'wp_related_posts'); ?>';
|
14 |
break;
|
15 |
case 'commented':
|
16 |
+
wp_rp_missing_rp_title_th.innerHTML = '<?php _e("Most Commented Posts Title:", 'wp_related_posts'); ?>';
|
17 |
+
wp_rp_missing_rp_title.value = '<?php _e("Most Commented Posts", 'wp_related_posts'); ?>';
|
18 |
break;
|
19 |
case 'popularity':
|
20 |
+
wp_rp_missing_rp_title_th.innerHTML = '<?php _e("Most Popular Posts Title:", 'wp_related_posts'); ?>';
|
21 |
+
wp_rp_missing_rp_title.value = '<?php _e("Most Popular Posts", 'wp_related_posts'); ?>';
|
22 |
break;
|
23 |
default:
|
24 |
+
wp_rp_missing_rp_title_th.innerHTML = '';
|
25 |
}
|
26 |
+
if(wp_rp_missing_rp_algorithm.value == '<?php echo $missing_rp_algorithm;?>') {
|
27 |
+
wp_rp_missing_rp_title.value = '<?php echo $options["missing_rp_title"];?>';
|
28 |
}
|
29 |
}
|
30 |
+
function wp_rp_display_excerpt_onclick(){
|
31 |
+
var wp_rp_display_excerpt = document.getElementById('wp_rp_display_excerpt');
|
32 |
+
var wp_rp_excerpt_max_length_label = document.getElementById('wp_rp_excerpt_max_length_label');
|
33 |
+
if(wp_rp_display_excerpt.checked){
|
34 |
+
wp_rp_excerpt_max_length_label.style.display = '';
|
35 |
} else {
|
36 |
+
wp_rp_excerpt_max_length_label.style.display = 'none';
|
37 |
}
|
38 |
}
|
39 |
+
function wp_rp_display_thumbnail_onclick(){
|
40 |
+
var wp_rp_display_thumbnail = document.getElementById('wp_rp_display_thumbnail');
|
41 |
var wp_rp_thumbnail_span = document.getElementById('wp_rp_thumbnail_span');
|
42 |
+
if(wp_rp_display_thumbnail.checked){
|
43 |
wp_rp_thumbnail_span.style.display = '';
|
44 |
jQuery('#wp-rp-thumbnails-info').fadeOut();
|
45 |
if (window.localStorage) {
|
56 |
var _gaq = _gaq || [];
|
57 |
_gaq.push(['_setAccount', 'UA-34712447-1']);
|
58 |
_gaq.push(['_trackPageview']);
|
59 |
+
<?php if($meta['new_user']) : ?>
|
60 |
_gaq.push(['_trackEvent', 'wp_related_posts', 'new_user', 'new_user', 0, true]);
|
61 |
+
<?php endif; ?>
|
62 |
+
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_version', '<?php bloginfo('version'); ?>', 0, true]);
|
63 |
+
_gaq.push(['_trackEvent', 'wp_related_posts', 'settings_loaded_wp_language', '<?php 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]);
|
65 |
|
66 |
(function() {
|
static/themes.js
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
(function ($) {
|
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 |
-
};
|
30 |
-
|
31 |
-
window.wp_rp_themes_cb = function (data) {
|
32 |
-
if (data && data.themes) {
|
33 |
-
themes = data.themes;
|
34 |
-
|
35 |
-
if(themes) {
|
36 |
-
update_themes();
|
37 |
-
}
|
38 |
-
}
|
39 |
-
};
|
40 |
-
|
41 |
-
append_get_themes_script();
|
42 |
-
|
43 |
-
if (!window.localStorage || !window.localStorage.wp_wp_survey_1) {
|
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
CHANGED
Binary file
|
static/thumbs/1.jpg
CHANGED
Binary file
|
static/thumbs/10.jpg
CHANGED
Binary file
|
static/thumbs/11.jpg
CHANGED
Binary file
|
static/thumbs/12.jpg
CHANGED
Binary file
|
static/thumbs/13.jpg
CHANGED
Binary file
|
static/thumbs/14.jpg
CHANGED
Binary file
|
static/thumbs/2.jpg
CHANGED
Binary file
|
static/thumbs/3.jpg
CHANGED
Binary file
|
static/thumbs/4.jpg
CHANGED
Binary file
|
static/thumbs/5.jpg
CHANGED
Binary file
|
static/thumbs/6.jpg
CHANGED
Binary file
|
static/thumbs/7.jpg
CHANGED
Binary file
|
static/thumbs/8.jpg
CHANGED
Binary file
|
static/thumbs/9.jpg
CHANGED
Binary file
|
thumbnailer.php
CHANGED
@@ -16,12 +16,12 @@ function wp_rp_upload_default_thumbnail_file() {
|
|
16 |
return false;
|
17 |
}
|
18 |
|
19 |
-
function wp_rp_get_default_thumbnail_url($seed=false) {
|
20 |
-
$
|
21 |
$upload_dir = wp_upload_dir();
|
22 |
|
23 |
-
if (
|
24 |
-
return $upload_dir['baseurl'] . $
|
25 |
} else {
|
26 |
if ($seed) {
|
27 |
$next_seed = rand();
|
@@ -61,37 +61,29 @@ function wp_rp_extract_post_image($post_id) {
|
|
61 |
return $image_id;
|
62 |
}
|
63 |
|
64 |
-
function
|
65 |
-
|
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 (
|
80 |
return false;
|
81 |
}
|
82 |
|
83 |
-
if (
|
84 |
-
$thumbnail_src = get_post_meta($related_post->ID, $
|
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 (
|
90 |
-
$
|
|
|
|
|
|
|
|
|
91 |
return $img;
|
92 |
}
|
93 |
|
94 |
-
if
|
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);
|
16 |
return false;
|
17 |
}
|
18 |
|
19 |
+
function wp_rp_get_default_thumbnail_url($seed = false) {
|
20 |
+
$options = wp_rp_get_options();
|
21 |
$upload_dir = wp_upload_dir();
|
22 |
|
23 |
+
if ($options['default_thumbnail_path']) {
|
24 |
+
return $upload_dir['baseurl'] . $options['default_thumbnail_path'];
|
25 |
} else {
|
26 |
if ($seed) {
|
27 |
$next_seed = rand();
|
61 |
return $image_id;
|
62 |
}
|
63 |
|
64 |
+
function wp_rp_get_post_thumbnail_img($related_post) {
|
65 |
+
$options = wp_rp_get_options();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
if (!$options["display_thumbnail"]) {
|
68 |
return false;
|
69 |
}
|
70 |
|
71 |
+
if ($options['thumbnail_use_custom']) {
|
72 |
+
$thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
|
73 |
if ($thumbnail_src) {
|
74 |
$img = '<img src="' . esc_attr($thumbnail_src) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
75 |
return $img;
|
76 |
}
|
77 |
+
} else if (has_post_thumbnail($related_post->ID)) {
|
78 |
+
$attr = array(
|
79 |
+
'alt' => esc_attr(wptexturize($related_post->post_title)),
|
80 |
+
'title' => false
|
81 |
+
);
|
82 |
+
$img = get_the_post_thumbnail($related_post->ID, 'thumbnail', $attr);
|
83 |
return $img;
|
84 |
}
|
85 |
|
86 |
+
if($options["thumbnail_use_attached"]) {
|
87 |
$image_id = get_post_meta($related_post->ID, '_wp_rp_image_id', true);
|
88 |
if ($image_id === '') {
|
89 |
$image_id = wp_rp_extract_post_image($related_post->ID);
|
utils.php
DELETED
@@ -1,119 +0,0 @@
|
|
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 |
-
/* ***************************** */
|
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);
|
60 |
-
|
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>';
|
68 |
-
|
69 |
-
echo $output;
|
70 |
-
}
|
71 |
-
|
72 |
-
function wp_most_popular_posts ($number = 10){
|
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>';
|
81 |
-
|
82 |
-
echo $output;
|
83 |
-
}
|
84 |
-
|
85 |
-
function wp_most_commented_posts ($number = 10){
|
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>';
|
94 |
-
|
95 |
-
echo $output;
|
96 |
-
}
|
97 |
-
|
98 |
-
function wp23_related_posts() {
|
99 |
-
wp_related_posts();
|
100 |
-
}
|
101 |
-
|
102 |
-
function wp_related_posts() {
|
103 |
-
$output = wp_get_related_posts();
|
104 |
-
echo $output;
|
105 |
-
}
|
106 |
-
|
107 |
-
function wp_get_random_posts ($limitclause="") {
|
108 |
-
return wp_fetch_random_posts($limitclause);
|
109 |
-
}
|
110 |
-
|
111 |
-
function wp_get_most_commented_posts($limitclause="") {
|
112 |
-
return wp_fetch_most_commented_posts($limitclause);
|
113 |
-
}
|
114 |
-
|
115 |
-
function wp_get_most_popular_posts ($limitclause="") {
|
116 |
-
return wp_fetch_most_popular_posts($limitclause);
|
117 |
-
}
|
118 |
-
|
119 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
versions.php
CHANGED
@@ -1,5 +1,63 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
/* ************************* */
|
5 |
/* Version 1.3 */
|
@@ -8,8 +66,8 @@
|
|
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
|
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
|
@@ -26,11 +84,3 @@
|
|
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 |
-
}
|
1 |
<?php
|
2 |
|
3 |
+
/* ************************* */
|
4 |
+
/* Version 1.5 */
|
5 |
+
/* ************************* */
|
6 |
+
|
7 |
+
/* Settings:
|
8 |
+
|
9 |
+
wp_no_rp -> missing_rp_algorithm "text" | "random" | "commented" | "popularity" : how to generate posts if there are no related posts found
|
10 |
+
wp_no_rp_text -> missing_rp_title string : the title used if there are no related posts found
|
11 |
+
wp_rp_auto -> on_single_post bool : include related posts on single post pages
|
12 |
+
wp_rp_comments -> display_comment_count bool : display comment count of related posts
|
13 |
+
wp_rp_date -> display_publish_date bool : display the publish date of related posts
|
14 |
+
wp_rp_except -> display_excerpt bool : display short excerpts of related posts
|
15 |
+
wp_rp_except_number -> excerpt_max_length int : the maximum length of the excerpt
|
16 |
+
wp_rp_exclude -> not_on_categories string (comma-separated list of categories) : do not display related articles on posts from these categories
|
17 |
+
wp_rp_limit -> max_related_posts int : the maximum number of related posts to display
|
18 |
+
wp_rp_rss -> on_rss bool : include related posts on rss feed
|
19 |
+
wp_rp_theme -> theme_name string : the name of the theme css file
|
20 |
+
wp_rp_thumbnail -> display_thumbnail bool : show thumbnails for related posts
|
21 |
+
wp_rp_thumbnail_post_meta -> thumbnail_custom_field string | `false` : either the name of a custom field that should be used for thumbnails, or `false`
|
22 |
+
wp_rp_thumbnail_text -> thumbnail_display_title bool : display title (and publish date and comment count) when thumbnails are on
|
23 |
+
wp_rp_title -> related_posts_title string : the title to display above related posts
|
24 |
+
wp_rp_title_tag -> related_posts_title_tag "h2" | "h3" | "h4" | "p" | "div" : the HTML tag to use for title
|
25 |
+
wp_rp_default_thumbnail_path -> default_thumbnail_path string | `false` : the path to the image to use as a default thumbnail, or `false` if not set
|
26 |
+
wp_rp_thumbnail_extract -> thumbnail_use_attached bool : if featured/custom image not found, use the first attached image as thumbnail
|
27 |
+
wp_rp_thumbnail_featured -> thumbnail_use_custom bool : `true` -> use image from custom field, `false` -> use featured image
|
28 |
+
|
29 |
+
+ wp_rp_theme_custom_css -> theme_custom_css string : user defined custom css for related posts
|
30 |
+
|
31 |
+
- wp_rp_version -> meta.version
|
32 |
+
- wp_rp_log_new_user -> meta.new_user
|
33 |
+
*/
|
34 |
+
|
35 |
+
/* Meta options:
|
36 |
+
|
37 |
+
version string : the current version of the settings
|
38 |
+
first_version string : the version which was first installed on this blog
|
39 |
+
new_user bool : set for new users, and unset when they are reported to GA
|
40 |
+
blog_id `false` | string : if the user has registered, the assigned blog_id
|
41 |
+
access_token `false` | string : if the user has registered, the assigned access token
|
42 |
+
show_upgrade_tooltip bool : show a tooltip for upgrades, informing the user of new features
|
43 |
+
show_ctr_banner bool : show a banner for the new CTR tracking option, until the user has first enable the CTR tracking
|
44 |
+
|
45 |
+
/* ************************* */
|
46 |
+
/* Version 1.4 */
|
47 |
+
/* ************************* */
|
48 |
+
|
49 |
+
/* Settings :
|
50 |
+
|
51 |
+
+ wp_rp_default_thumbnail_path the path to default image (on the server) to use as a default thumbnail for posts with no other thumbnail
|
52 |
+
+ wp_rp_log_new_user set for new users, and unset when they are reported as new users to GA
|
53 |
+
+ wp_rp_thumbnail_extract display the first attached image of the post as post's thumbnail
|
54 |
+
+ wp_rp_thumbnail_featured display the post's featured image as post's thumbnail
|
55 |
+
+ wp_rp_version the installed version of the plugin (to know when the code was upgraded) - this was well-meaning, but Tom fucked up and this parameter is not saved (i.e. it is erased as soon as the user modifies any settings)
|
56 |
+
|
57 |
+
- wp_rp_template
|
58 |
+
|
59 |
+
*/
|
60 |
+
|
61 |
|
62 |
/* ************************* */
|
63 |
/* Version 1.3 */
|
66 |
/* Settings:
|
67 |
|
68 |
wp_no_rp what to do if there are no related posts (`text`, `random`, most `commented` posts)
|
69 |
+
wp_no_rp_text title to show if there are no realted posts
|
70 |
+
wp_rp_auto auto insert related posts to single post pages
|
71 |
wp_rp_comments display number of comments
|
72 |
wp_rp_date display publish date
|
73 |
wp_rp_except display post excerpt
|
84 |
wp_rp_title_tag related posts title tag (e.g. h2, h3, div, ...)
|
85 |
|
86 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
widget.php
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
add_action('plugins_loaded', 'widget_sidebar_wp_related_posts');
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
echo $before_widget;
|
9 |
|
10 |
-
//echo $before_title . $
|
11 |
-
$output =
|
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 |
}
|
1 |
<?php
|
2 |
|
3 |
add_action('plugins_loaded', 'widget_sidebar_wp_related_posts');
|
4 |
+
|
5 |
+
function widget_wp_related_posts($args) {
|
6 |
+
if(is_single()) {
|
7 |
+
extract($args);
|
8 |
echo $before_widget;
|
9 |
|
10 |
+
//echo $before_title . $options["related_posts_title"] . $after_title;
|
11 |
+
$output = wp_rp_get_related_posts($before_title, $after_title);
|
12 |
echo $output;
|
13 |
echo $after_widget;
|
14 |
}
|
15 |
+
}
|
16 |
|
17 |
+
function widget_sidebar_wp_related_posts() {
|
18 |
wp_register_sidebar_widget('wp_related_posts_widget', 'Related Posts', 'widget_wp_related_posts');
|
19 |
}
|
wp_related_posts.php
CHANGED
@@ -1,79 +1,45 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
-
Version: 1.
|
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(
|
12 |
|
13 |
-
include_once
|
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 |
-
|
21 |
-
function init_textdomain(){
|
22 |
-
load_plugin_textdomain('wp_related_posts', false, dirname(plugin_basename (__FILE__)) . '/lang');
|
23 |
-
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
-
|
30 |
-
|
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 |
-
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
$wp_rp['wp_rp_theme'] = WP_RP_THEME_PLAIN;
|
42 |
-
}
|
43 |
|
44 |
-
if (
|
45 |
-
$
|
46 |
-
|
47 |
-
if (!isset($wp_rp['wp_rp_title'])) {
|
48 |
-
$wp_rp['wp_rp_title'] = WP_RP_TITLE;
|
49 |
-
}
|
50 |
-
if (!isset($wp_rp['wp_rp_limit'])) {
|
51 |
-
$wp_rp['wp_rp_limit'] = WP_RP_POST_LIMIT;
|
52 |
-
}
|
53 |
-
if (!isset($wp_rp['wp_rp_rss'])) {
|
54 |
-
$wp_rp['wp_rp_rss'] = WP_RP_APPEND_TO_RSS;
|
55 |
-
}
|
56 |
-
if (!isset($wp_rp['wp_rp_thumbnail_text'])) {
|
57 |
-
$wp_rp['wp_rp_thumbnail_text'] = 'yes';
|
58 |
-
}
|
59 |
-
if (!isset($wp_rp['wp_rp_except_number'])) {
|
60 |
-
$wp_rp['wp_rp_except_number'] = 200;
|
61 |
-
}
|
62 |
-
if (!isset($wp_rp['wp_no_rp'])) {
|
63 |
-
$wp_rp['wp_no_rp'] = WP_RP_RELATED_FALLBACK;
|
64 |
-
if (!isset($wp_rp['wp_no_rp_text'])) {
|
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 |
-
|
|
|
72 |
}
|
73 |
|
74 |
-
function
|
75 |
global $wpdb, $post;
|
76 |
-
$
|
77 |
|
78 |
if(!$post->ID){return;}
|
79 |
$now = current_time('mysql', 1);
|
@@ -98,27 +64,36 @@ function wp_fetch_related_posts($limitclause="") {
|
|
98 |
return $related_posts;
|
99 |
}
|
100 |
|
101 |
-
function
|
102 |
global $wpdb, $post;
|
103 |
|
104 |
-
$
|
|
|
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 |
-
|
117 |
-
|
118 |
-
|
119 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
-
$ids = $rnd;
|
122 |
srand($next_seed);
|
123 |
}
|
124 |
|
@@ -126,99 +101,90 @@ function wp_fetch_random_posts ($limit = 10) {
|
|
126 |
return $wpdb->get_results($q2);
|
127 |
}
|
128 |
|
129 |
-
function
|
130 |
global $wpdb;
|
131 |
$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";
|
132 |
return $wpdb->get_results($q);
|
133 |
}
|
134 |
|
135 |
-
function
|
136 |
global $wpdb, $table_prefix;
|
137 |
|
138 |
$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";;
|
139 |
return $wpdb->get_results($q);
|
140 |
}
|
141 |
|
142 |
-
function
|
143 |
-
$
|
144 |
-
"random" => __("Random Posts",'wp_related_posts'),
|
145 |
-
"popularity" => __("Random Posts",'wp_related_posts'),
|
146 |
-
"commented" => __("Random Posts",'wp_related_posts'),
|
147 |
-
"text" => __("No Related Post",'wp_related_posts')
|
148 |
-
);
|
149 |
-
|
150 |
-
$wp_rp = get_option("wp_rp");
|
151 |
|
152 |
-
|
153 |
-
$limit = $wp_rp["wp_rp_limit"];
|
154 |
-
} else {
|
155 |
-
$limit = WP_RP_POST_LIMIT;
|
156 |
-
}
|
157 |
$limitclause = "LIMIT $limit";
|
158 |
|
159 |
-
$
|
160 |
-
$related_posts =
|
161 |
|
162 |
if (!$related_posts) {
|
163 |
-
$
|
164 |
-
$
|
165 |
|
166 |
-
if ($
|
167 |
-
$wp_rp_title = $wp_no_rp_text;
|
168 |
-
} else if ($wp_no_rp_text === false && isset($default_wp_no_rp_text[$wp_no_rp])) {
|
169 |
-
$wp_rp_title = $default_wp_no_rp_text[$wp_no_rp];
|
170 |
-
} else {
|
171 |
-
$wp_rp_title = "";
|
172 |
-
}
|
173 |
-
|
174 |
-
if ($wp_no_rp == "text") {
|
175 |
$related_posts = false;
|
176 |
-
} else if ($
|
177 |
-
$related_posts =
|
178 |
-
} else if ($
|
179 |
-
$related_posts =
|
180 |
} else {
|
181 |
-
$related_posts =
|
182 |
}
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
return array(
|
186 |
"posts" => $related_posts,
|
187 |
-
"title" => $
|
188 |
);
|
189 |
}
|
190 |
|
191 |
-
function
|
192 |
-
$
|
193 |
$output = "";
|
|
|
194 |
|
195 |
foreach ($related_posts as $related_post ) {
|
196 |
-
$output .= '<li>';
|
197 |
|
198 |
-
$img =
|
199 |
if ($img) {
|
200 |
-
$output .= '<a href="' . get_permalink($related_post->ID) . '"
|
201 |
}
|
202 |
|
203 |
-
if (!$
|
204 |
-
if ($
|
205 |
$dateformat = get_option('date_format');
|
206 |
$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
|
207 |
}
|
208 |
|
209 |
-
$output .= '<a href="' . get_permalink($related_post->ID) . '"
|
210 |
|
211 |
-
if ($
|
212 |
$output .= " (" . $related_post->comment_count . ")";
|
213 |
}
|
214 |
|
215 |
-
if ($
|
216 |
-
$
|
217 |
-
if(!$wp_rp_except_number) $wp_rp_except_number = 200;
|
218 |
if($related_post->post_excerpt){
|
219 |
-
$output .= '<br /><small>'.(mb_substr(strip_shortcodes(strip_tags($related_post->post_excerpt)),0
|
220 |
-
}else{
|
221 |
-
$output .= '<br /><small>'.(mb_substr(strip_shortcodes(strip_tags($related_post->post_content)),0
|
222 |
}
|
223 |
}
|
224 |
}
|
@@ -228,95 +194,96 @@ function wp_generate_related_posts_list_items($related_posts) {
|
|
228 |
return $output;
|
229 |
}
|
230 |
|
231 |
-
function
|
232 |
global $wpdb, $post;
|
233 |
-
$
|
234 |
|
235 |
-
$
|
236 |
-
if ( $exclude != '' ) {
|
237 |
-
$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;
|
238 |
|
239 |
-
|
|
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
245 |
}
|
246 |
}
|
247 |
return false;
|
248 |
}
|
249 |
|
250 |
|
251 |
-
function
|
252 |
-
|
|
|
|
|
253 |
return;
|
254 |
-
}
|
255 |
|
256 |
-
|
257 |
-
$
|
258 |
|
259 |
$output = "";
|
260 |
|
261 |
-
$
|
262 |
-
$related_posts = $
|
263 |
-
$
|
264 |
|
265 |
-
$
|
266 |
|
267 |
-
if (
|
268 |
-
$
|
269 |
} else {
|
270 |
-
$
|
271 |
}
|
272 |
|
273 |
if ($related_posts) {
|
274 |
-
$output =
|
275 |
} else {
|
276 |
-
$
|
277 |
-
|
278 |
-
$wp_no_rp_text = $wp_rp_title;
|
279 |
-
}
|
280 |
-
$wp_rp_title = "";
|
281 |
-
$output = '<li>' . $wp_no_rp_text . '</li>';
|
282 |
}
|
283 |
|
284 |
-
$output = '<ul class="related_post">' . $output . '</ul>';
|
285 |
|
286 |
-
$
|
287 |
if ($before_title) {
|
288 |
-
if ($
|
289 |
-
$output = $before_title
|
290 |
}
|
291 |
} else {
|
292 |
-
if ($
|
293 |
-
$output = '<'
|
294 |
}
|
295 |
}
|
296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
// figure out how to use wp_enqueue_style
|
298 |
-
$
|
299 |
setTimeout(function () {
|
300 |
var link = document.createElement("link");
|
301 |
link.rel = "stylesheet";
|
302 |
-
link.href= "' . $
|
303 |
link.type= "text/css";
|
304 |
document.getElementsByTagName("body")[0].appendChild(link);
|
305 |
}, 1);
|
306 |
</script>';
|
307 |
|
308 |
-
$
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$output = wp_get_related_posts();
|
317 |
-
$content = $content . $output;
|
318 |
}
|
319 |
|
320 |
-
|
|
|
321 |
}
|
322 |
-
add_filter('the_content', 'wp_related_posts_auto', 99);
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
+
Version: 1.5
|
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.5');
|
12 |
|
13 |
+
include_once(dirname(__FILE__) . '/config.php');
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
register_activation_hook(__FILE__, 'wp_rp_activate_hook');
|
|
|
|
|
|
|
16 |
|
17 |
+
include_once(dirname(__FILE__) . '/widget.php');
|
18 |
+
include_once(dirname(__FILE__) . '/thumbnailer.php');
|
19 |
+
include_once(dirname(__FILE__) . '/settings.php');
|
20 |
+
include_once(dirname(__FILE__) . '/compatibility.php');
|
21 |
|
22 |
+
add_action('init', 'wp_rp_init_hook');
|
23 |
+
add_filter('the_content', 'wp_rp_add_related_posts_hook', 99);
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
function wp_rp_init_hook() {
|
26 |
+
load_plugin_textdomain('wp_related_posts', false, dirname(plugin_basename (__FILE__)) . '/lang');
|
27 |
+
}
|
28 |
|
29 |
+
function wp_rp_add_related_posts_hook($content) {
|
30 |
+
$options = wp_rp_get_options();
|
|
|
|
|
31 |
|
32 |
+
if ((is_single() && $options["on_single_post"]) || (is_feed() && $options["on_rss"])) {
|
33 |
+
$output = wp_rp_get_related_posts();
|
34 |
+
$content = $content . $output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
+
|
37 |
+
return $content;
|
38 |
}
|
39 |
|
40 |
+
function wp_rp_fetch_related_posts($limitclause = '') {
|
41 |
global $wpdb, $post;
|
42 |
+
$options = wp_rp_get_options();
|
43 |
|
44 |
if(!$post->ID){return;}
|
45 |
$now = current_time('mysql', 1);
|
64 |
return $related_posts;
|
65 |
}
|
66 |
|
67 |
+
function wp_rp_fetch_random_posts ($limit = 10, $exclude_ids = array()) {
|
68 |
global $wpdb, $post;
|
69 |
|
70 |
+
array_push($exclude_ids, $post->ID);
|
71 |
+
$exclude_ids = array_map('intval', $exclude_ids);
|
72 |
|
73 |
+
$q1 = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND ID NOT IN(" . implode(', ', $exclude_ids) . ")";
|
74 |
$ids = $wpdb->get_col($q1, 0);
|
75 |
$count = count($ids);
|
76 |
+
if($count <= 1) {
|
77 |
if($count === 0) return false;
|
78 |
if($count === 1) $rnd = $ids;
|
79 |
} else {
|
80 |
+
$display_number = min($limit, $count);
|
81 |
+
|
82 |
$next_seed = rand();
|
83 |
$t = time();
|
84 |
$seed = $t - $t % 300 + $post->ID << 4; // We keep the same seed for 5 minutes, so MySQL can cache the `q2` query.
|
85 |
srand($seed);
|
86 |
+
|
87 |
+
$rnd = array_rand($ids, $display_number); // This is an array of random indexes, sorted
|
88 |
+
if ($display_number == 1) {
|
89 |
+
$ids = array($ids[$rnd]);
|
90 |
+
} else {
|
91 |
+
shuffle($rnd);
|
92 |
+
foreach ($rnd as &$i) { // Here, index is passed by reference, so we can modify it
|
93 |
+
$i = $ids[$i]; // Replace indexes with corresponding IDs
|
94 |
+
}
|
95 |
+
$ids = $rnd;
|
96 |
}
|
|
|
97 |
srand($next_seed);
|
98 |
}
|
99 |
|
101 |
return $wpdb->get_results($q2);
|
102 |
}
|
103 |
|
104 |
+
function wp_rp_fetch_most_commented_posts($limitclause = '') {
|
105 |
global $wpdb;
|
106 |
$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";
|
107 |
return $wpdb->get_results($q);
|
108 |
}
|
109 |
|
110 |
+
function wp_rp_fetch_most_popular_posts ($limitclause = '') {
|
111 |
global $wpdb, $table_prefix;
|
112 |
|
113 |
$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";;
|
114 |
return $wpdb->get_results($q);
|
115 |
}
|
116 |
|
117 |
+
function wp_rp_fetch_posts_and_title() {
|
118 |
+
$options = wp_rp_get_options();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
+
$limit = $options['max_related_posts'];
|
|
|
|
|
|
|
|
|
121 |
$limitclause = "LIMIT $limit";
|
122 |
|
123 |
+
$title = $options["related_posts_title"];
|
124 |
+
$related_posts = wp_rp_fetch_related_posts($limitclause);
|
125 |
|
126 |
if (!$related_posts) {
|
127 |
+
$missing_rp_algorithm = $options["missing_rp_algorithm"];
|
128 |
+
$title = $options["missing_rp_title"];
|
129 |
|
130 |
+
if ($missing_rp_algorithm == "text") {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
$related_posts = false;
|
132 |
+
} else if ($missing_rp_algorithm === "commented") {
|
133 |
+
$related_posts = wp_rp_fetch_most_commented_posts($limitclause);
|
134 |
+
} else if ($missing_rp_algorithm == "popularity" && function_exists('akpc_most_popular')) {
|
135 |
+
$related_posts = wp_rp_fetch_most_popular_posts($limitclause);
|
136 |
} else {
|
137 |
+
$related_posts = wp_rp_fetch_random_posts($limit);
|
138 |
}
|
139 |
}
|
140 |
|
141 |
+
// fill related posts with random posts if there not enough posts found
|
142 |
+
if(empty($related_posts) || sizeof($related_posts) < $limit) {
|
143 |
+
$src_posts = !is_array($related_posts) ? array() : $related_posts;
|
144 |
+
$exclude_ids = array_map(create_function('$p', 'return $p->ID;'), $src_posts);
|
145 |
+
$random_posts = wp_rp_fetch_random_posts($limit - sizeof($src_posts), $exclude_ids);
|
146 |
+
|
147 |
+
if(!empty($random_posts))
|
148 |
+
$related_posts = array_merge($src_posts, $random_posts);
|
149 |
+
}
|
150 |
+
|
151 |
return array(
|
152 |
"posts" => $related_posts,
|
153 |
+
"title" => $title
|
154 |
);
|
155 |
}
|
156 |
|
157 |
+
function wp_rp_generate_related_posts_list_items($related_posts) {
|
158 |
+
$options = wp_rp_get_options();
|
159 |
$output = "";
|
160 |
+
$i = 0;
|
161 |
|
162 |
foreach ($related_posts as $related_post ) {
|
163 |
+
$output .= '<li position="' . $i++ . '">';
|
164 |
|
165 |
+
$img = wp_rp_get_post_thumbnail_img($related_post);
|
166 |
if ($img) {
|
167 |
+
$output .= '<a href="' . get_permalink($related_post->ID) . '">' . $img . '</a>';
|
168 |
}
|
169 |
|
170 |
+
if (!$options["display_thumbnail"] || ($options["display_thumbnail"] && ($options["thumbnail_display_title"] || !$img))) {
|
171 |
+
if ($options["display_publish_date"]){
|
172 |
$dateformat = get_option('date_format');
|
173 |
$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
|
174 |
}
|
175 |
|
176 |
+
$output .= '<a href="' . get_permalink($related_post->ID) . '">' . wptexturize($related_post->post_title) . '</a>';
|
177 |
|
178 |
+
if ($options["display_comment_count"]){
|
179 |
$output .= " (" . $related_post->comment_count . ")";
|
180 |
}
|
181 |
|
182 |
+
if ($options["display_excerpt"]){
|
183 |
+
$excerpt_max_length = $options["excerpt_max_length"];
|
|
|
184 |
if($related_post->post_excerpt){
|
185 |
+
$output .= '<br /><small>' . (mb_substr(strip_shortcodes(strip_tags($related_post->post_excerpt)), 0, $excerpt_max_length)) . '...</small>';
|
186 |
+
} else {
|
187 |
+
$output .= '<br /><small>' . (mb_substr(strip_shortcodes(strip_tags($related_post->post_content)), 0, $excerpt_max_length)) . '...</small>';
|
188 |
}
|
189 |
}
|
190 |
}
|
194 |
return $output;
|
195 |
}
|
196 |
|
197 |
+
function wp_rp_should_exclude() {
|
198 |
global $wpdb, $post;
|
199 |
+
$options = wp_rp_get_options();
|
200 |
|
201 |
+
if($options['not_on_categories'] === '') { return false; }
|
|
|
|
|
202 |
|
203 |
+
$exclude = explode(",", $options["not_on_categories"]);
|
204 |
+
$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;
|
205 |
|
206 |
+
$cats = $wpdb->get_results($q);
|
207 |
+
|
208 |
+
foreach($cats as $cat) {
|
209 |
+
if (in_array($cat->term_id, $exclude) != false){
|
210 |
+
return true;
|
211 |
}
|
212 |
}
|
213 |
return false;
|
214 |
}
|
215 |
|
216 |
|
217 |
+
function wp_rp_get_related_posts($before_title = '', $after_title = '') {
|
218 |
+
global $wpdb, $post;
|
219 |
+
|
220 |
+
if (wp_rp_should_exclude())
|
221 |
return;
|
|
|
222 |
|
223 |
+
$options = wp_rp_get_options();
|
224 |
+
$meta = wp_rp_get_meta();
|
225 |
|
226 |
$output = "";
|
227 |
|
228 |
+
$posts_and_title = wp_rp_fetch_posts_and_title();
|
229 |
+
$related_posts = $posts_and_title['posts'];
|
230 |
+
$title = $posts_and_title['title'];
|
231 |
|
232 |
+
$theme_name = $options['theme_name'];
|
233 |
|
234 |
+
if ($options["display_thumbnail"]) {
|
235 |
+
$theme_url = WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_THUMBS_PATH . $theme_name;
|
236 |
} else {
|
237 |
+
$theme_url = WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_PATH . $theme_name;
|
238 |
}
|
239 |
|
240 |
if ($related_posts) {
|
241 |
+
$output = wp_rp_generate_related_posts_list_items($related_posts);
|
242 |
} else {
|
243 |
+
$output = '<li>' . $title . '</li>';
|
244 |
+
$title = "";
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
|
247 |
+
$output = '<ul class="related_post wp_rp">' . $output . '</ul>';
|
248 |
|
249 |
+
$title_tag = $options["related_posts_title_tag"];
|
250 |
if ($before_title) {
|
251 |
+
if ($title != '') {
|
252 |
+
$output = $before_title . $title . $after_title . $output;
|
253 |
}
|
254 |
} else {
|
255 |
+
if ($title != '') {
|
256 |
+
$output = '<' . $title_tag . ' class="related_post_title">' . $title . '</' . $title_tag . '>' . $output;
|
257 |
}
|
258 |
}
|
259 |
|
260 |
+
if ($theme_name === 'custom.css') {
|
261 |
+
$theme_custom_css = $options['theme_custom_css'];
|
262 |
+
|
263 |
+
$output .= '<style>' . $theme_custom_css . '</style>';
|
264 |
+
}
|
265 |
+
|
266 |
// figure out how to use wp_enqueue_style
|
267 |
+
$output .= '<script type="text/javascript">
|
268 |
setTimeout(function () {
|
269 |
var link = document.createElement("link");
|
270 |
link.rel = "stylesheet";
|
271 |
+
link.href= "' . esc_js($theme_url) . '";
|
272 |
link.type= "text/css";
|
273 |
document.getElementsByTagName("body")[0].appendChild(link);
|
274 |
}, 1);
|
275 |
</script>';
|
276 |
|
277 |
+
if ($options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key']) {
|
278 |
+
$output .= '<script type="text/javascript">
|
279 |
+
window._wp_rp_blog_id = "' . esc_js($meta['blog_id']) . '";
|
280 |
+
window._wp_rp_ajax_img_src_url = "' . esc_js(WP_RP_CTR_REPORT_URL) . '";
|
281 |
+
window._wp_rp_post_id = ' . esc_js($post->ID) . ';
|
282 |
+
window._wp_rp_thumbnails = ' . ($options["display_thumbnail"] ? 'true' : 'false') . ';
|
283 |
+
</script>
|
284 |
+
<script type="text/javascript" src="' . esc_attr(WP_RP_STATIC_BASE_URL . WP_RP_CTR_PAGEVIEW_FILE) . '"></script>';
|
|
|
|
|
285 |
}
|
286 |
|
287 |
+
|
288 |
+
return $output;
|
289 |
}
|
|