Version Description
- Adds filter to set thumbnail compression quality.
- Adds filter to change the ending string of the excerpt generated by WPP.
- When using multilingual plugins, return the author of the translation instead of the author of the original post.
- Fixes a PHP warning message generated by an unimplemented method in the REST API controller.
- Minor code improvements.
See full changelog.
=
Download this release
Release Info
Developer | hcabrera |
Plugin | WordPress Popular Posts |
Version | 4.2.1 |
Comparing to | |
See all releases |
Code changes from version 4.2.0 to 4.2.1
includes/class-wordpress-popular-posts-helper.php
CHANGED
@@ -76,7 +76,7 @@ class WPP_Helper {
|
|
76 |
* @return string
|
77 |
*/
|
78 |
public static function curdate() {
|
79 |
-
return
|
80 |
}
|
81 |
|
82 |
/**
|
@@ -161,7 +161,7 @@ class WPP_Helper {
|
|
161 |
* @param bool $truncate_by_words
|
162 |
* @return string
|
163 |
*/
|
164 |
-
public static function truncate( $text = '', $length = 25, $truncate_by_words = false ) {
|
165 |
|
166 |
if ( '' !== $text ) {
|
167 |
|
@@ -172,13 +172,13 @@ class WPP_Helper {
|
|
172 |
|
173 |
if ( count($words) > $length ) {
|
174 |
array_pop( $words );
|
175 |
-
$text = rtrim( implode(" ", $words), ",." ) . "
|
176 |
}
|
177 |
|
178 |
}
|
179 |
// Truncate by characters
|
180 |
elseif ( strlen($text) > $length ) {
|
181 |
-
$text = rtrim( mb_substr($text, 0, $length , get_bloginfo('charset')), " ,." ) .
|
182 |
}
|
183 |
|
184 |
}
|
76 |
* @return string
|
77 |
*/
|
78 |
public static function curdate() {
|
79 |
+
return current_time( 'Y-m-d', false );
|
80 |
}
|
81 |
|
82 |
/**
|
161 |
* @param bool $truncate_by_words
|
162 |
* @return string
|
163 |
*/
|
164 |
+
public static function truncate( $text = '', $length = 25, $truncate_by_words = false, $more = '...' ) {
|
165 |
|
166 |
if ( '' !== $text ) {
|
167 |
|
172 |
|
173 |
if ( count($words) > $length ) {
|
174 |
array_pop( $words );
|
175 |
+
$text = rtrim( implode(" ", $words), ",." ) . " {$more}";
|
176 |
}
|
177 |
|
178 |
}
|
179 |
// Truncate by characters
|
180 |
elseif ( strlen($text) > $length ) {
|
181 |
+
$text = rtrim( mb_substr($text, 0, $length , get_bloginfo('charset')), " ,." ) . $more;
|
182 |
}
|
183 |
|
184 |
}
|
includes/class-wordpress-popular-posts-image.php
CHANGED
@@ -226,6 +226,11 @@ class WPP_Image {
|
|
226 |
// valid image, create thumbnail
|
227 |
if ( !is_wp_error($image) ) {
|
228 |
|
|
|
|
|
|
|
|
|
|
|
229 |
$image->resize( $image_meta['width'], $image_meta['height'], $image_meta['crop'] );
|
230 |
$new_img = $image->save( trailingslashit($this->uploads_dir['basedir']) . $image_meta['filename'] . '.' . $image_meta['extension'] );
|
231 |
|
226 |
// valid image, create thumbnail
|
227 |
if ( !is_wp_error($image) ) {
|
228 |
|
229 |
+
$quality = apply_filters( 'wpp_thumbnail_compression_quality', null );
|
230 |
+
if ( ! ctype_digit($quality) )
|
231 |
+
$quality = null;
|
232 |
+
$image->set_quality( $quality );
|
233 |
+
|
234 |
$image->resize( $image_meta['width'], $image_meta['height'], $image_meta['crop'] );
|
235 |
$new_img = $image->save( trailingslashit($this->uploads_dir['basedir']) . $image_meta['filename'] . '.' . $image_meta['extension'] );
|
236 |
|
includes/class-wordpress-popular-posts-output.php
CHANGED
@@ -30,6 +30,14 @@ class WPP_Output {
|
|
30 |
*/
|
31 |
private $default_thumbnail_sizes = array();
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
/**
|
34 |
* WPP_Image object
|
35 |
*
|
@@ -52,6 +60,11 @@ class WPP_Output {
|
|
52 |
|
53 |
$this->default_thumbnail_sizes = $this->wpp_image->get_image_sizes();
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
$this->build_output();
|
56 |
|
57 |
}
|
@@ -142,17 +155,24 @@ class WPP_Output {
|
|
142 |
|
143 |
$post = '';
|
144 |
|
145 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
// Permalink
|
148 |
-
$permalink = $this->get_permalink( $
|
149 |
|
150 |
// Thumbnail
|
151 |
$post_thumbnail = $this->get_thumbnail( $post_object );
|
152 |
|
153 |
// Post title (and title attribute)
|
154 |
-
$post_title_attr = esc_attr( wp_strip_all_tags( $this->get_title( $post_object ) ) );
|
155 |
-
$post_title = $this->get_title( $post_object );
|
156 |
|
157 |
if ( $this->options['shorten_title']['active'] ) {
|
158 |
|
@@ -160,12 +180,12 @@ class WPP_Output {
|
|
160 |
? $this->options['shorten_title']['length']
|
161 |
: 25;
|
162 |
|
163 |
-
$post_title = WPP_Helper::truncate( $post_title, $length, $this->options['shorten_title']['words'] );
|
164 |
|
165 |
}
|
166 |
|
167 |
// Post excerpt
|
168 |
-
$post_excerpt = $this->get_excerpt( $post_object );
|
169 |
|
170 |
// Post rating
|
171 |
$post_rating = $this->get_rating( $post_object );
|
@@ -178,10 +198,10 @@ class WPP_Output {
|
|
178 |
$post_date = $this->get_date( $post_object );
|
179 |
|
180 |
// Post taxonomies
|
181 |
-
$post_taxonomies = $this->get_taxonomies( $
|
182 |
|
183 |
// Post author
|
184 |
-
$post_author = $this->get_author( $post_object );
|
185 |
|
186 |
// Post views count
|
187 |
$post_views = $this->get_pageviews( $post_object );
|
@@ -190,13 +210,13 @@ class WPP_Output {
|
|
190 |
$post_comments = $this->get_comments( $post_object );
|
191 |
|
192 |
// Post meta
|
193 |
-
$post_meta = join( ' | ', $this->get_metadata( $post_object ) );
|
194 |
|
195 |
// Build custom HTML output
|
196 |
if ( $this->options['markup']['custom_html'] ) {
|
197 |
|
198 |
$data = array(
|
199 |
-
'id' => $
|
200 |
'title' => '<a href="' . $permalink . '" title="' . $post_title_attr . '" class="wpp-post-title" target="' . $this->admin_options['tools']['link']['target'] . '">' . $post_title . '</a>',
|
201 |
'summary' => $post_excerpt,
|
202 |
'stats' => $post_meta,
|
@@ -205,7 +225,7 @@ class WPP_Output {
|
|
205 |
'url' => $permalink,
|
206 |
'text_title' => $post_title_attr,
|
207 |
'taxonomy' => $post_taxonomies,
|
208 |
-
'author' => ( !empty($post_author) ) ? '<a href="' . get_author_posts_url( $post_object->uid ) . '">' . $post_author . '</a>' : '',
|
209 |
'views' => ( $this->options['order_by'] == "views" || $this->options['order_by'] == "comments" ) ? number_format_i18n( $post_views ) : number_format_i18n( $post_views, 2 ),
|
210 |
'comments' => number_format_i18n( $post_comments ),
|
211 |
'date' => $post_date
|
@@ -219,7 +239,7 @@ class WPP_Output {
|
|
219 |
$is_single = WPP_Helper::is_single();
|
220 |
|
221 |
$post_thumbnail = ( !empty($post_thumbnail) )
|
222 |
-
? "<a " . ( $is_single == $
|
223 |
: "";
|
224 |
|
225 |
$post_excerpt = ( !empty($post_excerpt) )
|
@@ -236,18 +256,18 @@ class WPP_Output {
|
|
236 |
|
237 |
$wpp_post_class = array();
|
238 |
|
239 |
-
if ( $is_single == $
|
240 |
$wpp_post_class[] = "current";
|
241 |
}
|
242 |
|
243 |
// Allow themers / plugin developer
|
244 |
// to add custom classes to each post
|
245 |
-
$wpp_post_class = apply_filters( "wpp_post_class", $wpp_post_class, $
|
246 |
|
247 |
$post =
|
248 |
"<li" . ( ( is_array( $wpp_post_class ) && !empty( $wpp_post_class ) ) ? ' class="' . esc_attr( implode( " ", $wpp_post_class ) ) . '"' : '' ) . ">\n"
|
249 |
. $post_thumbnail
|
250 |
-
. "<a " . ( $is_single == $
|
251 |
. $post_excerpt
|
252 |
. $post_meta
|
253 |
. $post_rating
|
@@ -264,19 +284,11 @@ class WPP_Output {
|
|
264 |
*
|
265 |
* @since 4.0.12
|
266 |
* @access private
|
267 |
-
* @param
|
268 |
* @return string
|
269 |
*/
|
270 |
-
private function get_permalink(
|
271 |
-
|
272 |
-
$translate = WPP_translate::get_instance();
|
273 |
-
$trid = $translate->get_object_id( $post_object->id, get_post_type( $post_object->id ) );
|
274 |
-
|
275 |
-
if ( $post_object->id != $trid ) {
|
276 |
-
return get_permalink( $trid );
|
277 |
-
}
|
278 |
-
|
279 |
-
return get_permalink( $post_object->id );
|
280 |
}
|
281 |
|
282 |
/**
|
@@ -285,15 +297,13 @@ class WPP_Output {
|
|
285 |
* @since 3.0.0
|
286 |
* @access private
|
287 |
* @param object $post_object
|
|
|
288 |
* @return string
|
289 |
*/
|
290 |
-
private function get_title( stdClass $post_object ) {
|
291 |
-
|
292 |
-
$translate = WPP_translate::get_instance();
|
293 |
-
$trid = $translate->get_object_id( $post_object->id, get_post_type( $post_object->id ) );
|
294 |
|
295 |
-
if ( $post_object->id != $
|
296 |
-
$title = get_the_title( $
|
297 |
}
|
298 |
else {
|
299 |
$title = $post_object->title;
|
@@ -529,10 +539,10 @@ class WPP_Output {
|
|
529 |
*
|
530 |
* @since 3.0.0
|
531 |
* @access private
|
532 |
-
* @param
|
533 |
* @return string
|
534 |
*/
|
535 |
-
private function get_taxonomies(
|
536 |
|
537 |
$post_tax = '';
|
538 |
|
@@ -547,15 +557,7 @@ class WPP_Output {
|
|
547 |
$taxonomy = $this->options['stats_tag']['taxonomy']['name'];
|
548 |
}
|
549 |
|
550 |
-
$
|
551 |
-
$trid = $translate->get_object_id( $post_object->id, get_post_type( $post_object->id ) );
|
552 |
-
|
553 |
-
if ( $post_object->id != $trid ) {
|
554 |
-
$terms = wp_get_post_terms( $trid, $taxonomy );
|
555 |
-
}
|
556 |
-
else {
|
557 |
-
$terms = wp_get_post_terms( $post_object->id, $taxonomy );
|
558 |
-
}
|
559 |
|
560 |
if ( !is_wp_error( $terms ) ) {
|
561 |
|
@@ -602,12 +604,13 @@ class WPP_Output {
|
|
602 |
* @since 3.0.0
|
603 |
* @access private
|
604 |
* @param object $post_object
|
|
|
605 |
* @return string
|
606 |
*/
|
607 |
-
private function get_author( stdClass $post_object ) {
|
608 |
|
609 |
$author = ( $this->options['stats_tag']['author'] )
|
610 |
-
? get_the_author_meta( 'display_name', $post_object->uid )
|
611 |
: "";
|
612 |
|
613 |
return $author;
|
@@ -620,19 +623,17 @@ class WPP_Output {
|
|
620 |
* @since 3.0.0
|
621 |
* @access private
|
622 |
* @param object $post_object
|
|
|
623 |
* @return string
|
624 |
*/
|
625 |
-
private function get_excerpt( stdClass $post_object ) {
|
626 |
|
627 |
$excerpt = '';
|
628 |
|
629 |
if ( $this->options['post-excerpt']['active'] ) {
|
630 |
|
631 |
-
$
|
632 |
-
|
633 |
-
|
634 |
-
if ( $post_object->id != $trid ) {
|
635 |
-
$the_post = get_post( $trid );
|
636 |
|
637 |
$excerpt = ( empty($the_post->post_excerpt) )
|
638 |
? $the_post->post_content
|
@@ -674,7 +675,7 @@ class WPP_Output {
|
|
674 |
// Balance tags, if needed
|
675 |
if ( '' !== $excerpt ) {
|
676 |
|
677 |
-
$excerpt = WPP_helper::truncate( $excerpt, $this->options['post-excerpt']['length'], $this->options['post-excerpt']['words'] );
|
678 |
|
679 |
if ( $this->options['post-excerpt']['keep_format'] )
|
680 |
$excerpt = force_balance_tags( $excerpt );
|
@@ -710,9 +711,10 @@ class WPP_Output {
|
|
710 |
* @since 3.0.0
|
711 |
* @access private
|
712 |
* @param object $post_object
|
|
|
713 |
* @return array
|
714 |
*/
|
715 |
-
private function get_metadata( stdClass $post_object ) {
|
716 |
|
717 |
$stats = array();
|
718 |
|
@@ -762,8 +764,8 @@ class WPP_Output {
|
|
762 |
|
763 |
// author
|
764 |
if ( $this->options['stats_tag']['author'] ) {
|
765 |
-
$author = $this->get_author( $post_object );
|
766 |
-
$display_name = '<a href="' . get_author_posts_url( $post_object->uid ) . '">' . $author . '</a>';
|
767 |
$stats[] = '<span class="wpp-author">' . sprintf(__('by %s', 'wordpress-popular-posts'), $display_name).'</span>';
|
768 |
}
|
769 |
|
@@ -776,7 +778,7 @@ class WPP_Output {
|
|
776 |
// taxonomy
|
777 |
if ( $this->options['stats_tag']['category'] ) {
|
778 |
|
779 |
-
$post_tax = $this->get_taxonomies( $
|
780 |
|
781 |
if ( $post_tax != '' ) {
|
782 |
$stats[] = '<span class="wpp-category">' . sprintf( __('under %s', 'wordpress-popular-posts'), $post_tax ) . '</span>';
|
30 |
*/
|
31 |
private $default_thumbnail_sizes = array();
|
32 |
|
33 |
+
/**
|
34 |
+
* Default excerpt 'more' string.
|
35 |
+
*
|
36 |
+
* @since 4.2.1
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
private $more;
|
40 |
+
|
41 |
/**
|
42 |
* WPP_Image object
|
43 |
*
|
60 |
|
61 |
$this->default_thumbnail_sizes = $this->wpp_image->get_image_sizes();
|
62 |
|
63 |
+
$this->more = '...';
|
64 |
+
|
65 |
+
if ( has_filter('wpp_excerpt_more') )
|
66 |
+
$this->more = apply_filters( 'wpp_excerpt_more', $this->more );
|
67 |
+
|
68 |
$this->build_output();
|
69 |
|
70 |
}
|
155 |
|
156 |
$post = '';
|
157 |
|
158 |
+
$post_id = $post_object->id;
|
159 |
+
|
160 |
+
$translate = WPP_translate::get_instance();
|
161 |
+
$trid = $translate->get_object_id( $post_object->id, get_post_type( $post_object->id ) );
|
162 |
+
|
163 |
+
if ( $post_id != $trid ) {
|
164 |
+
$post_id = $trid;
|
165 |
+
}
|
166 |
|
167 |
// Permalink
|
168 |
+
$permalink = $this->get_permalink( $post_id );
|
169 |
|
170 |
// Thumbnail
|
171 |
$post_thumbnail = $this->get_thumbnail( $post_object );
|
172 |
|
173 |
// Post title (and title attribute)
|
174 |
+
$post_title_attr = esc_attr( wp_strip_all_tags( $this->get_title( $post_object, $post_id ) ) );
|
175 |
+
$post_title = $this->get_title( $post_object, $post_id );
|
176 |
|
177 |
if ( $this->options['shorten_title']['active'] ) {
|
178 |
|
180 |
? $this->options['shorten_title']['length']
|
181 |
: 25;
|
182 |
|
183 |
+
$post_title = WPP_Helper::truncate( $post_title, $length, $this->options['shorten_title']['words'], $this->more );
|
184 |
|
185 |
}
|
186 |
|
187 |
// Post excerpt
|
188 |
+
$post_excerpt = $this->get_excerpt( $post_object, $post_id );
|
189 |
|
190 |
// Post rating
|
191 |
$post_rating = $this->get_rating( $post_object );
|
198 |
$post_date = $this->get_date( $post_object );
|
199 |
|
200 |
// Post taxonomies
|
201 |
+
$post_taxonomies = $this->get_taxonomies( $post_id );
|
202 |
|
203 |
// Post author
|
204 |
+
$post_author = $this->get_author( $post_object, $post_id );
|
205 |
|
206 |
// Post views count
|
207 |
$post_views = $this->get_pageviews( $post_object );
|
210 |
$post_comments = $this->get_comments( $post_object );
|
211 |
|
212 |
// Post meta
|
213 |
+
$post_meta = join( ' | ', $this->get_metadata( $post_object, $post_id ) );
|
214 |
|
215 |
// Build custom HTML output
|
216 |
if ( $this->options['markup']['custom_html'] ) {
|
217 |
|
218 |
$data = array(
|
219 |
+
'id' => $post_id,
|
220 |
'title' => '<a href="' . $permalink . '" title="' . $post_title_attr . '" class="wpp-post-title" target="' . $this->admin_options['tools']['link']['target'] . '">' . $post_title . '</a>',
|
221 |
'summary' => $post_excerpt,
|
222 |
'stats' => $post_meta,
|
225 |
'url' => $permalink,
|
226 |
'text_title' => $post_title_attr,
|
227 |
'taxonomy' => $post_taxonomies,
|
228 |
+
'author' => ( !empty($post_author) ) ? '<a href="' . get_author_posts_url( $post_object->uid != $post_id ? get_post_field( 'post_author', $post_id ) : $post_object->uid ) . '">' . $post_author . '</a>' : '',
|
229 |
'views' => ( $this->options['order_by'] == "views" || $this->options['order_by'] == "comments" ) ? number_format_i18n( $post_views ) : number_format_i18n( $post_views, 2 ),
|
230 |
'comments' => number_format_i18n( $post_comments ),
|
231 |
'date' => $post_date
|
239 |
$is_single = WPP_Helper::is_single();
|
240 |
|
241 |
$post_thumbnail = ( !empty($post_thumbnail) )
|
242 |
+
? "<a " . ( $is_single == $post_id ? '' : "href=\"{$permalink}\"" ) . " title=\"{$post_title_attr}\" target=\"{$this->admin_options['tools']['link']['target']}\">{$post_thumbnail}</a>\n"
|
243 |
: "";
|
244 |
|
245 |
$post_excerpt = ( !empty($post_excerpt) )
|
256 |
|
257 |
$wpp_post_class = array();
|
258 |
|
259 |
+
if ( $is_single == $post_id ) {
|
260 |
$wpp_post_class[] = "current";
|
261 |
}
|
262 |
|
263 |
// Allow themers / plugin developer
|
264 |
// to add custom classes to each post
|
265 |
+
$wpp_post_class = apply_filters( "wpp_post_class", $wpp_post_class, $post_id );
|
266 |
|
267 |
$post =
|
268 |
"<li" . ( ( is_array( $wpp_post_class ) && !empty( $wpp_post_class ) ) ? ' class="' . esc_attr( implode( " ", $wpp_post_class ) ) . '"' : '' ) . ">\n"
|
269 |
. $post_thumbnail
|
270 |
+
. "<a " . ( $is_single == $post_id ? '' : "href=\"{$permalink}\"" ) . " title=\"{$post_title_attr}\" class=\"wpp-post-title\" target=\"{$this->admin_options['tools']['link']['target']}\">{$post_title}</a>\n"
|
271 |
. $post_excerpt
|
272 |
. $post_meta
|
273 |
. $post_rating
|
284 |
*
|
285 |
* @since 4.0.12
|
286 |
* @access private
|
287 |
+
* @param integer $post_id
|
288 |
* @return string
|
289 |
*/
|
290 |
+
private function get_permalink( int $post_id ) {
|
291 |
+
return get_permalink( $post_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
|
294 |
/**
|
297 |
* @since 3.0.0
|
298 |
* @access private
|
299 |
* @param object $post_object
|
300 |
+
* @param integer $post_id
|
301 |
* @return string
|
302 |
*/
|
303 |
+
private function get_title( stdClass $post_object, int $post_id ) {
|
|
|
|
|
|
|
304 |
|
305 |
+
if ( $post_object->id != $post_id ) {
|
306 |
+
$title = get_the_title( $post_id );
|
307 |
}
|
308 |
else {
|
309 |
$title = $post_object->title;
|
539 |
*
|
540 |
* @since 3.0.0
|
541 |
* @access private
|
542 |
+
* @param integer $post_id
|
543 |
* @return string
|
544 |
*/
|
545 |
+
private function get_taxonomies( int $post_id ) {
|
546 |
|
547 |
$post_tax = '';
|
548 |
|
557 |
$taxonomy = $this->options['stats_tag']['taxonomy']['name'];
|
558 |
}
|
559 |
|
560 |
+
$terms = wp_get_post_terms( $post_id, $taxonomy );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
|
562 |
if ( !is_wp_error( $terms ) ) {
|
563 |
|
604 |
* @since 3.0.0
|
605 |
* @access private
|
606 |
* @param object $post_object
|
607 |
+
* @param integer $post_id
|
608 |
* @return string
|
609 |
*/
|
610 |
+
private function get_author( stdClass $post_object, int $post_id ) {
|
611 |
|
612 |
$author = ( $this->options['stats_tag']['author'] )
|
613 |
+
? get_the_author_meta( 'display_name', $post_object->uid != $post_id ? get_post_field( 'post_author', $post_id ) : $post_object->uid )
|
614 |
: "";
|
615 |
|
616 |
return $author;
|
623 |
* @since 3.0.0
|
624 |
* @access private
|
625 |
* @param object $post_object
|
626 |
+
* @param integer $post_id
|
627 |
* @return string
|
628 |
*/
|
629 |
+
private function get_excerpt( stdClass $post_object, int $post_id ) {
|
630 |
|
631 |
$excerpt = '';
|
632 |
|
633 |
if ( $this->options['post-excerpt']['active'] ) {
|
634 |
|
635 |
+
if ( $post_object->id != $post_id ) {
|
636 |
+
$the_post = get_post( $post_id );
|
|
|
|
|
|
|
637 |
|
638 |
$excerpt = ( empty($the_post->post_excerpt) )
|
639 |
? $the_post->post_content
|
675 |
// Balance tags, if needed
|
676 |
if ( '' !== $excerpt ) {
|
677 |
|
678 |
+
$excerpt = WPP_helper::truncate( $excerpt, $this->options['post-excerpt']['length'], $this->options['post-excerpt']['words'], $this->more );
|
679 |
|
680 |
if ( $this->options['post-excerpt']['keep_format'] )
|
681 |
$excerpt = force_balance_tags( $excerpt );
|
711 |
* @since 3.0.0
|
712 |
* @access private
|
713 |
* @param object $post_object
|
714 |
+
* @param integer $post_id
|
715 |
* @return array
|
716 |
*/
|
717 |
+
private function get_metadata( stdClass $post_object, int $post_id ) {
|
718 |
|
719 |
$stats = array();
|
720 |
|
764 |
|
765 |
// author
|
766 |
if ( $this->options['stats_tag']['author'] ) {
|
767 |
+
$author = $this->get_author( $post_object, $post_id );
|
768 |
+
$display_name = '<a href="' . get_author_posts_url( $post_object->uid != $post_id ? get_post_field( 'post_author', $post_id ) : $post_object->uid ) . '">' . $author . '</a>';
|
769 |
$stats[] = '<span class="wpp-author">' . sprintf(__('by %s', 'wordpress-popular-posts'), $display_name).'</span>';
|
770 |
}
|
771 |
|
778 |
// taxonomy
|
779 |
if ( $this->options['stats_tag']['category'] ) {
|
780 |
|
781 |
+
$post_tax = $this->get_taxonomies( $post_id );
|
782 |
|
783 |
if ( $post_tax != '' ) {
|
784 |
$stats[] = '<span class="wpp-category">' . sprintf( __('under %s', 'wordpress-popular-posts'), $post_tax ) . '</span>';
|
includes/class-wordpress-popular-posts-rest-controller.php
CHANGED
@@ -26,7 +26,6 @@ class WP_REST_Popular_Posts_Controller extends WP_REST_Controller {
|
|
26 |
array(
|
27 |
'methods' => WP_REST_Server::READABLE,
|
28 |
'callback' => array( $this, 'get_items' ),
|
29 |
-
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
30 |
'args' => $this->get_collection_params(),
|
31 |
),
|
32 |
array(
|
@@ -34,7 +33,6 @@ class WP_REST_Popular_Posts_Controller extends WP_REST_Controller {
|
|
34 |
'callback' => array( $this, 'update_views_count' ),
|
35 |
'args' => $this->get_tracking_params(),
|
36 |
),
|
37 |
-
'schema' => array( $this, 'get_public_item_schema' ),
|
38 |
)
|
39 |
);
|
40 |
|
@@ -50,19 +48,6 @@ class WP_REST_Popular_Posts_Controller extends WP_REST_Controller {
|
|
50 |
);
|
51 |
}
|
52 |
|
53 |
-
/**
|
54 |
-
* Checks whether a given request has permission to get popular posts.
|
55 |
-
*
|
56 |
-
* @since 4.1.0
|
57 |
-
*
|
58 |
-
* @param WP_REST_Request $request Full details about the request.
|
59 |
-
* @return WP_Error|bool True if the request has read access, WP_Error object otherwise.
|
60 |
-
*/
|
61 |
-
public function get_items_permissions_check( $request ) {
|
62 |
-
// TO-DO: Are there scenarios where this request should be rejected?
|
63 |
-
return true;
|
64 |
-
}
|
65 |
-
|
66 |
/**
|
67 |
* Retrieves the popular posts.
|
68 |
*
|
26 |
array(
|
27 |
'methods' => WP_REST_Server::READABLE,
|
28 |
'callback' => array( $this, 'get_items' ),
|
|
|
29 |
'args' => $this->get_collection_params(),
|
30 |
),
|
31 |
array(
|
33 |
'callback' => array( $this, 'update_views_count' ),
|
34 |
'args' => $this->get_tracking_params(),
|
35 |
),
|
|
|
36 |
)
|
37 |
);
|
38 |
|
48 |
);
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* Retrieves the popular posts.
|
53 |
*
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: hcabrera
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hcabrerab%40gmail%2ecom&lc=GB&item_name=WordPress%20Popular%20Posts%20Plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG_global%2egif%3aNonHosted
|
4 |
Tags: popular, posts, widget, popularity, top
|
5 |
Requires at least: 4.7
|
6 |
-
Tested up to:
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 4.2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -88,36 +88,13 @@ The FAQ section has been moved [here](https://github.com/cabrerahector/wordpress
|
|
88 |
4. WordPress Popular Posts Stats panel.
|
89 |
|
90 |
== Changelog ==
|
91 |
-
= 4.2.
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
-
|
96 |
-
-
|
97 |
-
-
|
98 |
-
- Adds filter hook [wpp_taxonomy_separator](https://github.com/cabrerahector/wordpress-popular-posts/wiki/3.-Filters#wpp_taxonomy_separator).
|
99 |
-
- You can now also pass arrays when using the parameters `post_type`, `cat`, `term_id`, `pid` or `author` (see [issue 169](https://github.com/cabrerahector/wordpress-popular-posts/issues/169#issuecomment-419667083) for details).
|
100 |
-
- The plugin will use language packs from wordpress.org from now on.
|
101 |
-
- Minor fixes and improvements.
|
102 |
-
|
103 |
-
Check the [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-4-2-is-all-about-speed/) for more details!
|
104 |
-
|
105 |
-
= 4.1.2 =
|
106 |
-
|
107 |
-
- Enables [Data Caching](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#caching) by default (new installs only).
|
108 |
-
- The Parameters section (Settings > WordPress Popular Posts > Parameters) is now mobile-friendly.
|
109 |
-
- Updated the documentation in the Parameters section.
|
110 |
-
- Refactored WPP's caching mechanism into its own class.
|
111 |
-
- Removed unused code.
|
112 |
-
|
113 |
-
= 4.1.1 =
|
114 |
-
|
115 |
-
**If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is highly recommended.**
|
116 |
-
|
117 |
-
- Improves compatibility with Cloudflare's Rocket Loader.
|
118 |
-
- Code cleanup.
|
119 |
-
- Fixes a minor bug (plugin returning the wrong excerpt when a translation plugin is used).
|
120 |
-
- Bumps minimum required PHP version to 5.3.
|
121 |
|
122 |
See [full changelog](https://github.com/cabrerahector/wordpress-popular-posts/blob/master/changelog.md).
|
123 |
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hcabrerab%40gmail%2ecom&lc=GB&item_name=WordPress%20Popular%20Posts%20Plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG_global%2egif%3aNonHosted
|
4 |
Tags: popular, posts, widget, popularity, top
|
5 |
Requires at least: 4.7
|
6 |
+
Tested up to: 5.0
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 4.2.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
88 |
4. WordPress Popular Posts Stats panel.
|
89 |
|
90 |
== Changelog ==
|
91 |
+
= 4.2.1 =
|
92 |
|
93 |
+
- Adds [filter to set thumbnail compression quality](https://github.com/cabrerahector/wordpress-popular-posts/wiki/3.-Filters#wpp_thumbnail_compression_quality).
|
94 |
+
- Adds [filter to change the ending string of the excerpt](https://github.com/cabrerahector/wordpress-popular-posts/wiki/3.-Filters#wpp_excerpt_more) generated by WPP.
|
95 |
+
- When using multilingual plugins, return the author of the translation instead of the author of the original post.
|
96 |
+
- Fixes a PHP warning message generated by an unimplemented method in the REST API controller.
|
97 |
+
- Minor code improvements.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
See [full changelog](https://github.com/cabrerahector/wordpress-popular-posts/blob/master/changelog.md).
|
100 |
|
wordpress-popular-posts.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: WordPress Popular Posts
|
17 |
* Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/
|
18 |
* Description: A highly customizable widget that displays the most popular posts on your blog.
|
19 |
-
* Version: 4.2.
|
20 |
* Author: Hector Cabrera
|
21 |
* Author URI: https://cabrerahector.com/
|
22 |
* License: GPL-2.0+
|
@@ -29,7 +29,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
29 |
die();
|
30 |
}
|
31 |
|
32 |
-
define( 'WPP_VER', '4.2.
|
33 |
|
34 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordpress-popular-posts-admin-notices.php';
|
35 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordpress-popular-posts-activator.php';
|
16 |
* Plugin Name: WordPress Popular Posts
|
17 |
* Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/
|
18 |
* Description: A highly customizable widget that displays the most popular posts on your blog.
|
19 |
+
* Version: 4.2.1
|
20 |
* Author: Hector Cabrera
|
21 |
* Author URI: https://cabrerahector.com/
|
22 |
* License: GPL-2.0+
|
29 |
die();
|
30 |
}
|
31 |
|
32 |
+
define( 'WPP_VER', '4.2.1' );
|
33 |
|
34 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordpress-popular-posts-admin-notices.php';
|
35 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordpress-popular-posts-activator.php';
|