Version Description
- Enables Data Caching by default (new installs only).
- The Parameters section (Settings > WordPress Popular Posts > Parameters) is now mobile-friendly.
- Updated the documentation in the Parameters section.
- Refactored WPP's caching mechanism into its own class.
- Removed unused code.
Download this release
Release Info
Developer | hcabrera |
Plugin | WordPress Popular Posts |
Version | 4.1.2 |
Comparing to | |
See all releases |
Code changes from version 4.1.1 to 4.1.2
- admin/css/admin.css +29 -0
- admin/partials/admin.php +247 -244
- includes/class-wordpress-popular-posts-cache.php +110 -0
- includes/class-wordpress-popular-posts-rest-controller.php +10 -50
- includes/class-wordpress-popular-posts-settings.php +2 -2
- includes/class-wordpress-popular-posts-widget.php +10 -50
- includes/class-wordpress-popular-posts.php +5 -0
- public/class-wordpress-popular-posts-public.php +11 -63
- readme.txt +15 -11
- wordpress-popular-posts.php +2 -2
admin/css/admin.css
CHANGED
@@ -336,6 +336,35 @@
|
|
336 |
display: inline;
|
337 |
}
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
.clear {
|
340 |
float:none;
|
341 |
clear:both;
|
336 |
display: inline;
|
337 |
}
|
338 |
|
339 |
+
#wpp_params {}
|
340 |
+
|
341 |
+
#wpp_params div {
|
342 |
+
}
|
343 |
+
|
344 |
+
#wpp_params div table {
|
345 |
+
width: 100%;
|
346 |
+
min-width: 800px;
|
347 |
+
background: white;
|
348 |
+
}
|
349 |
+
|
350 |
+
#wpp_params div table tr th {
|
351 |
+
font-size: 1.2em;
|
352 |
+
text-align: left;
|
353 |
+
border-bottom: #dedede 1px solid;
|
354 |
+
}
|
355 |
+
|
356 |
+
#wpp_params div table tr th,
|
357 |
+
#wpp_params div table tr td {
|
358 |
+
padding: 1em;
|
359 |
+
}
|
360 |
+
|
361 |
+
#wpp_params div table tr td {
|
362 |
+
position: static !important;
|
363 |
+
clear: none !important;
|
364 |
+
display: table-cell !important;
|
365 |
+
vertical-align: top;
|
366 |
+
}
|
367 |
+
|
368 |
.clear {
|
369 |
float:none;
|
370 |
clear:both;
|
admin/partials/admin.php
CHANGED
@@ -707,250 +707,253 @@ if ( !$wpp_rand = get_option("wpp_rand") ) {
|
|
707 |
'https://github.com/cabrerahector/wordpress-popular-posts/wiki/1.-Using-WPP-on-posts-&-pages'
|
708 |
); ?></p>
|
709 |
<br />
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
<
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
<
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
<
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
<
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
<
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
<
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
<
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
<
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
<
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
<
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
<
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
<
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
<
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
<
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
<
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
<
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
<
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
<
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
<
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
<
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
<
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
<
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
<
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
<
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
<
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
<
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
<
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
<
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
<
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
<
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
<
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
<
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
<
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
<
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
|
|
|
|
|
|
954 |
</div>
|
955 |
</div>
|
956 |
<!-- End params -->
|
707 |
'https://github.com/cabrerahector/wordpress-popular-posts/wiki/1.-Using-WPP-on-posts-&-pages'
|
708 |
); ?></p>
|
709 |
<br />
|
710 |
+
|
711 |
+
<div style="overflow-x: auto;">
|
712 |
+
<table cellspacing="0" class="wp-list-table">
|
713 |
+
<thead>
|
714 |
+
<tr>
|
715 |
+
<th class="manage-column column-title"><?php _e('Parameter', 'wordpress-popular-posts'); ?></th>
|
716 |
+
<th class="manage-column column-title"><?php _e('What it does ', 'wordpress-popular-posts'); ?></th>
|
717 |
+
<th class="manage-column column-title"><?php _e('Possible values', 'wordpress-popular-posts'); ?></th>
|
718 |
+
<th class="manage-column column-title"><?php _e('Defaults to', 'wordpress-popular-posts'); ?></th>
|
719 |
+
<th class="manage-column column-title"><?php _e('Example', 'wordpress-popular-posts'); ?></th>
|
720 |
+
</tr>
|
721 |
+
</thead>
|
722 |
+
<tbody>
|
723 |
+
<tr>
|
724 |
+
<td><strong>header</strong></td>
|
725 |
+
<td><?php _e('Sets a heading for the list', 'wordpress-popular-posts'); ?></td>
|
726 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
727 |
+
<td><?php _e('None', 'wordpress-popular-posts'); ?></td>
|
728 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'header' => 'Popular Posts'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp header='Popular Posts']<br /><br /></td>
|
729 |
+
</tr>
|
730 |
+
<tr class="alternate">
|
731 |
+
<td><strong>header_start</strong></td>
|
732 |
+
<td><?php _e('Set the opening tag for the heading of the list', 'wordpress-popular-posts'); ?></td>
|
733 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
734 |
+
<td><h2></td>
|
735 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'header' => 'Popular Posts', <br /> 'header_start' => '<h3 class="title">',<br /> 'header_end' => '</h3>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp header='Popular Posts' header_start='<h3 class="title">' header_end='</h3>']<br /><br /></td>
|
736 |
+
</tr>
|
737 |
+
<tr>
|
738 |
+
<td><strong>header_end</strong></td>
|
739 |
+
<td><?php _e('Set the closing tag for the heading of the list', 'wordpress-popular-posts'); ?></td>
|
740 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
741 |
+
<td></h2></td>
|
742 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'header' => 'Popular Posts', <br /> 'header_start' => '<h3 class="title">',<br /> 'header_end' => '</h3>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp header='Popular Posts' header_start='<h3 class="title">' header_end='</h3>']<br /><br /></td>
|
743 |
+
</tr>
|
744 |
+
<tr class="alternate">
|
745 |
+
<td><strong>limit</strong></td>
|
746 |
+
<td><?php _e('Sets the maximum number of popular posts to be shown on the listing', 'wordpress-popular-posts'); ?></td>
|
747 |
+
<td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td>
|
748 |
+
<td>10</td>
|
749 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'limit' => 5<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp limit=5]<br /><br /></td>
|
750 |
+
</tr>
|
751 |
+
<tr>
|
752 |
+
<td><strong>range</strong></td>
|
753 |
+
<td><?php _e('Tells WordPress Popular Posts to retrieve the most popular entries within the time range specified by you', 'wordpress-popular-posts'); ?></td>
|
754 |
+
<td>"last24hours", "last7days", "last30days", "all", "custom"</td>
|
755 |
+
<td>last24hours</td>
|
756 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'last7days'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='last7days']<br /><br /></td>
|
757 |
+
</tr>
|
758 |
+
<tr class="alternate">
|
759 |
+
<td><strong>time_quantity</strong></td>
|
760 |
+
<td><?php _e('Especifies the number of time units of the custom time range', 'wordpress-popular-posts'); ?></td>
|
761 |
+
<td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td>
|
762 |
+
<td>24</td>
|
763 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'custom',<br /> 'time_quantity' => 1,<br /> 'time_unit' => 'hour'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='custom' time_quantity=1 time_unit='hour']<br /><br /></td>
|
764 |
+
</tr>
|
765 |
+
<tr>
|
766 |
+
<td><strong>time_unit</strong></td>
|
767 |
+
<td><?php _e('Especifies the time unit of the custom time range', 'wordpress-popular-posts'); ?></td>
|
768 |
+
<td>minute, hour, day, week, month</td>
|
769 |
+
<td>hour</td>
|
770 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'custom',<br /> 'time_quantity' => 1,<br /> 'time_unit' => 'hour'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='custom' time_quantity=1 time_unit='hour']<br /><br /></td>
|
771 |
+
</tr>
|
772 |
+
<tr class="alternate">
|
773 |
+
<td><strong>freshness</strong></td>
|
774 |
+
<td><?php _e('Tells WordPress Popular Posts to retrieve the most popular entries published within the time range specified by you', 'wordpress-popular-posts'); ?></td>
|
775 |
+
<td>1 (true), 0 (false)</td>
|
776 |
+
<td>0</td>
|
777 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'weekly',<br /> 'freshness' => 1<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='last7days' freshness=1]<br /><br /></td>
|
778 |
+
</tr>
|
779 |
+
<tr>
|
780 |
+
<td><strong>order_by</strong></td>
|
781 |
+
<td><?php _e('Sets the sorting option of the popular posts', 'wordpress-popular-posts'); ?></td>
|
782 |
+
<td>"comments", "views", "avg" <?php _e('(for average views per day)', 'wordpress-popular-posts'); ?></td>
|
783 |
+
<td>views</td>
|
784 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'order_by' => 'comments'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp order_by='comments']<br /><br /></td>
|
785 |
+
</tr>
|
786 |
+
<tr class="alternate">
|
787 |
+
<td><strong>post_type</strong></td>
|
788 |
+
<td><?php _e('Defines the type of posts to show on the listing', 'wordpress-popular-posts'); ?></td>
|
789 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
790 |
+
<td>post</td>
|
791 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'post_type' => 'post,page,your-custom-post-type'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp post_type='post,page,your-custom-post-type']<br /><br /></td>
|
792 |
+
</tr>
|
793 |
+
<tr>
|
794 |
+
<td><strong>pid</strong></td>
|
795 |
+
<td><?php _e('If set, WordPress Popular Posts will exclude the specified post(s) ID(s) form the listing.', 'wordpress-popular-posts'); ?></td>
|
796 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
797 |
+
<td><?php _e('None', 'wordpress-popular-posts'); ?></td>
|
798 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'pid' => '60,25,31'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp pid='60,25,31']<br /><br /></td>
|
799 |
+
</tr>
|
800 |
+
<tr class="alternate">
|
801 |
+
<td><strong>cat</strong></td>
|
802 |
+
<td><?php _e('If set, WordPress Popular Posts will retrieve all entries that belong to the specified category ID(s). If a minus sign is used, entries associated to the category will be excluded instead.', 'wordpress-popular-posts'); ?></td>
|
803 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
804 |
+
<td><?php _e('None', 'wordpress-popular-posts'); ?></td>
|
805 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'cat' => '1,55,-74'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp cat='1,55,-74']<br /><br /></td>
|
806 |
+
</tr>
|
807 |
+
<tr>
|
808 |
+
<td><strong>taxonomy</strong></td>
|
809 |
+
<td><?php _e('If set, WordPress Popular Posts will filter posts by a given taxonomy.', 'wordpress-popular-posts'); ?></td>
|
810 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
811 |
+
<td><?php _e('None', 'wordpress-popular-posts'); ?></td>
|
812 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'taxonomy' => 'post_tag',<br /> 'term_id' => '118,75,15'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp taxonomy='post_tag' term_id='118,75,15']<br /><br /></td>
|
813 |
+
</tr>
|
814 |
+
<tr class="alternate">
|
815 |
+
<td><strong>term_id</strong></td>
|
816 |
+
<td><?php _e('If set, WordPress Popular Posts will retrieve all entries that belong to the specified term ID(s). If a minus sign is used, entries associated to the term(s) will be excluded instead.', 'wordpress-popular-posts'); ?></td>
|
817 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
818 |
+
<td><?php _e('None', 'wordpress-popular-posts'); ?></td>
|
819 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'taxonomy' => 'post_tag',<br /> 'term_id' => '118,75,15'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp taxonomy='post_tag' term_id='118,75,15']<br /><br /></td>
|
820 |
+
</tr>
|
821 |
+
<tr>
|
822 |
+
<td><strong>author</strong></td>
|
823 |
+
<td><?php _e('If set, WordPress Popular Posts will retrieve all entries created by specified author(s) ID(s).', 'wordpress-popular-posts'); ?></td>
|
824 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
825 |
+
<td><?php _e('None', 'wordpress-popular-posts'); ?></td>
|
826 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'author' => '75,8,120'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp author='75,8,120']<br /><br /></td>
|
827 |
+
</tr>
|
828 |
+
<tr class="alternate">
|
829 |
+
<td><strong>title_length</strong></td>
|
830 |
+
<td><?php _e('If set, WordPress Popular Posts will shorten each post title to "n" characters whenever possible', 'wordpress-popular-posts'); ?></td>
|
831 |
+
<td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td>
|
832 |
+
<td>25</td>
|
833 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'title_length' => 25<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp title_length=25]<br /><br /></td>
|
834 |
+
</tr>
|
835 |
+
<tr>
|
836 |
+
<td><strong>title_by_words</strong></td>
|
837 |
+
<td><?php _e('If set to 1, WordPress Popular Posts will shorten each post title to "n" words instead of characters', 'wordpress-popular-posts'); ?></td>
|
838 |
+
<td>1 (true), (0) false</td>
|
839 |
+
<td>0</td>
|
840 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'title_by_words' => 1,<br /> 'title_length' => 25<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp title_by_words=1 title_length=25]<br /><br /></td>
|
841 |
+
</tr>
|
842 |
+
<tr class="alternate">
|
843 |
+
<td><strong>excerpt_length</strong></td>
|
844 |
+
<td><?php _e('If set, WordPress Popular Posts will build and include an excerpt of "n" characters long from the content of each post listed as popular', 'wordpress-popular-posts'); ?></td>
|
845 |
+
<td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td>
|
846 |
+
<td>0</td>
|
847 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'excerpt_length' => 55,<br /> 'post_html' => '<li>{thumb} {title} <span class="wpp-excerpt">{summary}</span></li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp excerpt_length=25 post_html='<li>{thumb} {title} <span class="wpp-excerpt">{summary}</span></li>']<br /><br /></td>
|
848 |
+
</tr>
|
849 |
+
<tr>
|
850 |
+
<td><strong>excerpt_format</strong></td>
|
851 |
+
<td><?php _e('If set, WordPress Popular Posts will maintaing all styling tags (strong, italic, etc) and hyperlinks found in the excerpt', 'wordpress-popular-posts'); ?></td>
|
852 |
+
<td>1 (true), (0) false</td>
|
853 |
+
<td>0</td>
|
854 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'excerpt_format' => 1,<br /> 'excerpt_length' => 55,<br /> 'post_html' => '<li>{thumb} {title} <span class="wpp-excerpt">{summary}</span></li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp excerpt_format=1 excerpt_length=25 post_html='<li>{thumb} {title} <span class="wpp-excerpt">{summary}</span></li>']<br /><br /></td>
|
855 |
+
</tr>
|
856 |
+
<tr class="alternate">
|
857 |
+
<td><strong>excerpt_by_words</strong></td>
|
858 |
+
<td><?php _e('If set to 1, WordPress Popular Posts will shorten the excerpt to "n" words instead of characters', 'wordpress-popular-posts'); ?></td>
|
859 |
+
<td>1 (true), (0) false</td>
|
860 |
+
<td>0</td>
|
861 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'excerpt_by_words' => 1,<br /> 'excerpt_length' => 55,<br /> 'post_html' => '<li>{thumb} {title} <span class="wpp-excerpt">{summary}</span></li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp excerpt_by_words=1 excerpt_length=55 post_html='<li>{thumb} {title} <span class="wpp-excerpt">{summary}</span></li>']<br /><br /></td>
|
862 |
+
</tr>
|
863 |
+
<tr>
|
864 |
+
<td><strong>thumbnail_width</strong></td>
|
865 |
+
<td><?php _e('If set, and if your current server configuration allows it, you will be able to display thumbnails of your posts. This attribute sets the width for thumbnails', 'wordpress-popular-posts'); ?></td>
|
866 |
+
<td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td>
|
867 |
+
<td>0</td>
|
868 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'thumbnail_width' => 30,<br /> 'thumbnail_height' => 30<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp thumbnail_width=30 thumbnail_height=30]<br /><br /></td>
|
869 |
+
</tr>
|
870 |
+
<tr class="alternate">
|
871 |
+
<td><strong>thumbnail_height</strong></td>
|
872 |
+
<td><?php _e('If set, and if your current server configuration allows it, you will be able to display thumbnails of your posts. This attribute sets the height for thumbnails', 'wordpress-popular-posts'); ?></td>
|
873 |
+
<td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td>
|
874 |
+
<td>0</td>
|
875 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'thumbnail_width' => 30,<br /> 'thumbnail_height' => 30<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp thumbnail_width=30 thumbnail_height=30]<br /><br /></td>
|
876 |
+
</tr>
|
877 |
+
<tr>
|
878 |
+
<td><strong>rating</strong></td>
|
879 |
+
<td><?php _e('If set, and if the WP-PostRatings plugin is installed and enabled on your blog, WordPress Popular Posts will show how your visitors are rating your entries', 'wordpress-popular-posts'); ?></td>
|
880 |
+
<td>1 (true), (0) false</td>
|
881 |
+
<td>0</td>
|
882 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'rating' => 1,<br /> 'post_html' => '<li>{thumb} {title} {rating}</li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp rating=1 post_html='<li>{thumb} {title} {rating}</li>']<br /><br /></td>
|
883 |
+
</tr>
|
884 |
+
<tr class="alternate">
|
885 |
+
<td><strong>stats_comments</strong></td>
|
886 |
+
<td><?php _e('If set, WordPress Popular Posts will show how many comments each popular post has got during the specified time range', 'wordpress-popular-posts'); ?></td>
|
887 |
+
<td>1 (true), 0 (false)</td>
|
888 |
+
<td>0</td>
|
889 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_comments' => 1<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_comments=1]<br /><br /></td>
|
890 |
+
</tr>
|
891 |
+
<tr>
|
892 |
+
<td><strong>stats_views</strong></td>
|
893 |
+
<td><?php _e('If set, WordPress Popular Posts will show how many views each popular post has got during the specified time range', 'wordpress-popular-posts'); ?></td>
|
894 |
+
<td>1 (true), (0) false</td>
|
895 |
+
<td>1</td>
|
896 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_views' => 0<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_views=0]<br /><br /></td>
|
897 |
+
</tr>
|
898 |
+
<tr class="alternate">
|
899 |
+
<td><strong>stats_author</strong></td>
|
900 |
+
<td><?php _e('If set, WordPress Popular Posts will show who published each popular post on the list', 'wordpress-popular-posts'); ?></td>
|
901 |
+
<td>1 (true), (0) false</td>
|
902 |
+
<td>0</td>
|
903 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_author' => 1<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_author=1]<br /><br /></td>
|
904 |
+
</tr>
|
905 |
+
<tr>
|
906 |
+
<td><strong>stats_date</strong></td>
|
907 |
+
<td><?php _e('If set, WordPress Popular Posts will display the date when each popular post on the list was published', 'wordpress-popular-posts'); ?></td>
|
908 |
+
<td>1 (true), (0) false</td>
|
909 |
+
<td>0</td>
|
910 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_date' => 1<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_date=1]<br /><br /></td>
|
911 |
+
</tr>
|
912 |
+
<tr class="alternate">
|
913 |
+
<td><strong>stats_date_format</strong></td>
|
914 |
+
<td><?php _e('Sets the date format', 'wordpress-popular-posts'); ?></td>
|
915 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
916 |
+
<td>0</td>
|
917 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_date' => 1,<br /> 'stats_date_format' => 'F j, Y'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_date=1 stats_date_format='F j, Y']<br /><br /></td>
|
918 |
+
</tr>
|
919 |
+
<tr>
|
920 |
+
<td><strong>stats_category</strong></td>
|
921 |
+
<td><?php _e('If set, WordPress Popular Posts will display the categories associated to each entry', 'wordpress-popular-posts'); ?></td>
|
922 |
+
<td>1 (true), (0) false</td>
|
923 |
+
<td>0</td>
|
924 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_category' => 1, <br /> 'post_html' => '<li>{thumb} <a href="{url}">{text_title}</a> {category}</li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_taxonomy=1 post_html='<li>{thumb} <a href="{url}">{text_title}</a> {category}</li>']<br /><br /></td>
|
925 |
+
</tr>
|
926 |
+
<tr class="alternate">
|
927 |
+
<td><strong>stats_taxonomy</strong></td>
|
928 |
+
<td><?php _e('If set, WordPress Popular Posts will display the taxonomies associated to each entry', 'wordpress-popular-posts'); ?></td>
|
929 |
+
<td>1 (true), (0) false</td>
|
930 |
+
<td>0</td>
|
931 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_taxonomy' => 1, <br /> 'post_html' => '<li>{thumb} <a href="{url}">{text_title}</a> {taxonomy}</li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_taxonomy=1 post_html='<li>{thumb} <a href="{url}">{text_title}</a> {taxonomy}</li>']<br /><br /></td>
|
932 |
+
</tr>
|
933 |
+
<tr>
|
934 |
+
<td><strong>wpp_start</strong></td>
|
935 |
+
<td><?php _e('Sets the opening tag for the listing', 'wordpress-popular-posts'); ?></td>
|
936 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
937 |
+
<td><ul></td>
|
938 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'wpp_start' => '<ol>',<br /> 'wpp_end' => '</ol>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp wpp_start='<ol>' wpp_end='</ol>']<br /><br /></td>
|
939 |
+
</tr>
|
940 |
+
<tr class="alternate">
|
941 |
+
<td><strong>wpp_end</strong></td>
|
942 |
+
<td><?php _e('Sets the closing tag for the listing', 'wordpress-popular-posts'); ?></td>
|
943 |
+
<td><?php _e('Text string', 'wordpress-popular-posts'); ?></td>
|
944 |
+
<td></ul></td>
|
945 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'wpp_start' => '<ol>',<br /> 'wpp_end' => '</ol>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp wpp_start='<ol>' wpp_end='</ol>']<br /><br /></td>
|
946 |
+
</tr>
|
947 |
+
<tr>
|
948 |
+
<td><strong>post_html</strong></td>
|
949 |
+
<td><?php _e('Sets the HTML structure of each post', 'wordpress-popular-posts'); ?></td>
|
950 |
+
<td><?php _e('Text string, custom HTML', 'wordpress-popular-posts'); ?>.<br /><br /><strong><?php _e('Available Content Tags', 'wordpress-popular-posts'); ?>:</strong> <br /><br /><em>{thumb}</em> (<?php _e('returns thumbnail linked to post/page, requires thumbnail_width & thumbnail_height', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{thumb_img}</em> (<?php _e('returns thumbnail image without linking to post/page, requires thumbnail_width & thumbnail_height', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{thumb_url}</em> (<?php _e('returns thumbnail url, requires thumbnail_width & thumbnail_height', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{title}</em> (<?php _e('returns linked post/page title', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{pid}</em> (<?php _e('returns the post/page ID', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{summary}</em> (<?php _e('returns post/page excerpt, and requires excerpt_length to be greater than 0', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{stats}</em> (<?php _e('returns the default stats tags', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{rating}</em> (<?php _e('returns post/page current rating, requires WP-PostRatings installed and enabled', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{score}</em> (<?php _e('returns post/page current rating as an integer, requires WP-PostRatings installed and enabled', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{url}</em> (<?php _e('returns the URL of the post/page', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{text_title}</em> (<?php _e('returns post/page title, no link', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{author}</em> (<?php _e('returns linked author name, requires stats_author=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{category}</em> (<?php _e('returns linked category name, requires stats_category=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{taxonomy}</em> (<?php _e('returns linked taxonomy names, requires stats_taxonomy=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{views}</em> (<?php _e('returns views count only, no text', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{comments}</em> (<?php _e('returns comments count only, no text, requires stats_comments=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{date}</em> (<?php _e('returns post/page date, requires stats_date=1', 'wordpress-popular-posts'); ?>)</td>
|
951 |
+
<td><li>{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li></td>
|
952 |
+
<td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'post_html' => '<li>{thumb} <a href="{url}">{text_title}</a></li>'<br />);<br /><br />wpp_get_mostpopular( $args );<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp post_html='<li>{thumb} <a href="{url}">{text_title}</a></li>']<br /><br /></td>
|
953 |
+
</tr>
|
954 |
+
</tbody>
|
955 |
+
</table>
|
956 |
+
</div>
|
957 |
</div>
|
958 |
</div>
|
959 |
<!-- End params -->
|
includes/class-wordpress-popular-posts-cache.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Helper class to store data in cache for a fixed amount of time.
|
5 |
+
*
|
6 |
+
* @link https://cabrerahector.com
|
7 |
+
* @since 4.1.2
|
8 |
+
*
|
9 |
+
* @package WordPressPopularPosts
|
10 |
+
* @subpackage WordPressPopularPosts/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Helper class to store data in cache for a fixed amount of time.
|
15 |
+
*
|
16 |
+
* Stores data in cache via WordPress Transients (or any other available
|
17 |
+
* method in the future) for a fixed amount of time to reduce the number
|
18 |
+
* of database calls.
|
19 |
+
*
|
20 |
+
* @package WordPressPopularPosts
|
21 |
+
* @subpackage WordPressPopularPosts/includes
|
22 |
+
* @author Hector Cabrera <me@cabrerahector.com>
|
23 |
+
*/
|
24 |
+
class WPP_Cache {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Retrieves cached data.
|
28 |
+
*
|
29 |
+
* @since 4.1.2
|
30 |
+
* @access public
|
31 |
+
* @param string $key The name of the cached data.
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public static function get( $key ) {
|
35 |
+
return get_transient( $key );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Retrieves cached data.
|
40 |
+
*
|
41 |
+
* @since 4.1.2
|
42 |
+
* @access public
|
43 |
+
* @param string $key The name of the cached data.
|
44 |
+
* @param mixed $data The data being stored.
|
45 |
+
*/
|
46 |
+
public static function set( $key = null, $data = array(), $time_value = 1, $time_unit = 'minute' ) {
|
47 |
+
|
48 |
+
if ( !$key )
|
49 |
+
return false;
|
50 |
+
|
51 |
+
if (
|
52 |
+
!is_int( $time_value )
|
53 |
+
|| $time_value <= 0
|
54 |
+
) {
|
55 |
+
$time_value = 1;
|
56 |
+
}
|
57 |
+
|
58 |
+
switch( $time_unit ){
|
59 |
+
|
60 |
+
case 'minute':
|
61 |
+
$time = 60;
|
62 |
+
break;
|
63 |
+
|
64 |
+
case 'hour':
|
65 |
+
$time = 60 * 60;
|
66 |
+
break;
|
67 |
+
|
68 |
+
case 'day':
|
69 |
+
$time = 60 * 60 * 24;
|
70 |
+
break;
|
71 |
+
|
72 |
+
case 'week':
|
73 |
+
$time = 60 * 60 * 24 * 7;
|
74 |
+
break;
|
75 |
+
|
76 |
+
case 'month':
|
77 |
+
$time = 60 * 60 * 24 * 30;
|
78 |
+
break;
|
79 |
+
|
80 |
+
case 'year':
|
81 |
+
$time = 60 * 60 * 24 * 365;
|
82 |
+
break;
|
83 |
+
|
84 |
+
default:
|
85 |
+
$time = 60;
|
86 |
+
break;
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
$expiration = $time * $time_value;
|
91 |
+
|
92 |
+
// Store transient
|
93 |
+
set_transient( $key, $data, $expiration );
|
94 |
+
|
95 |
+
// Store transient in WPP transients array for garbage collection
|
96 |
+
$wpp_transients = get_option( 'wpp_transients' );
|
97 |
+
|
98 |
+
if ( !$wpp_transients ) {
|
99 |
+
$wpp_transients = array( $key );
|
100 |
+
add_option( 'wpp_transients', $wpp_transients );
|
101 |
+
} else {
|
102 |
+
if ( !in_array($key, $wpp_transients) ) {
|
103 |
+
$wpp_transients[] = $key;
|
104 |
+
update_option( 'wpp_transients', $wpp_transients );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
includes/class-wordpress-popular-posts-rest-controller.php
CHANGED
@@ -137,62 +137,22 @@ class WP_REST_Popular_Posts_Controller extends WP_REST_Controller {
|
|
137 |
// Return cached results
|
138 |
if ( $admin_options['tools']['cache']['active'] ) {
|
139 |
|
140 |
-
$
|
141 |
-
$popular_posts =
|
142 |
|
143 |
if ( false === $popular_posts ) {
|
144 |
|
145 |
$popular_posts = new WPP_Query( $instance );
|
146 |
|
147 |
-
|
|
|
148 |
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
break;
|
156 |
-
|
157 |
-
case 'day':
|
158 |
-
$time = 60 * 60 * 24;
|
159 |
-
break;
|
160 |
-
|
161 |
-
case 'week':
|
162 |
-
$time = 60 * 60 * 24 * 7;
|
163 |
-
break;
|
164 |
-
|
165 |
-
case 'month':
|
166 |
-
$time = 60 * 60 * 24 * 30;
|
167 |
-
break;
|
168 |
-
|
169 |
-
case 'year':
|
170 |
-
$time = 60 * 60 * 24 * 365;
|
171 |
-
break;
|
172 |
-
|
173 |
-
default:
|
174 |
-
$time = 60 * 60;
|
175 |
-
break;
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
$expiration = $time * $admin_options['tools']['cache']['interval']['value'];
|
180 |
-
|
181 |
-
// Store transient
|
182 |
-
set_transient( $transient_name, $popular_posts, $expiration );
|
183 |
-
|
184 |
-
// Store transient in WPP transients array for garbage collection
|
185 |
-
$wpp_transients = get_option('wpp_transients');
|
186 |
-
|
187 |
-
if ( !$wpp_transients ) {
|
188 |
-
$wpp_transients = array( $transient_name );
|
189 |
-
add_option( 'wpp_transients', $wpp_transients );
|
190 |
-
} else {
|
191 |
-
if ( !in_array($transient_name, $wpp_transients) ) {
|
192 |
-
$wpp_transients[] = $transient_name;
|
193 |
-
update_option( 'wpp_transients', $wpp_transients );
|
194 |
-
}
|
195 |
-
}
|
196 |
|
197 |
}
|
198 |
|
137 |
// Return cached results
|
138 |
if ( $admin_options['tools']['cache']['active'] ) {
|
139 |
|
140 |
+
$key = md5( json_encode($instance) );
|
141 |
+
$popular_posts = WPP_Cache::get( $key );
|
142 |
|
143 |
if ( false === $popular_posts ) {
|
144 |
|
145 |
$popular_posts = new WPP_Query( $instance );
|
146 |
|
147 |
+
$time_value = $admin_options['tools']['cache']['interval']['value']; // eg. 5
|
148 |
+
$time_unit = $admin_options['tools']['cache']['interval']['time']; // eg. 'minute'
|
149 |
|
150 |
+
WPP_Cache::set(
|
151 |
+
$key,
|
152 |
+
$popular_posts,
|
153 |
+
$time_value,
|
154 |
+
$time_unit
|
155 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
}
|
158 |
|
includes/class-wordpress-popular-posts-settings.php
CHANGED
@@ -113,9 +113,9 @@ class WPP_Settings {
|
|
113 |
'expires_after' => 180
|
114 |
),
|
115 |
'cache' => array(
|
116 |
-
'active' =>
|
117 |
'interval' => array(
|
118 |
-
'time' => '
|
119 |
'value' => 1
|
120 |
)
|
121 |
),
|
113 |
'expires_after' => 180
|
114 |
),
|
115 |
'cache' => array(
|
116 |
+
'active' => true,
|
117 |
'interval' => array(
|
118 |
+
'time' => 'minute',
|
119 |
'value' => 1
|
120 |
)
|
121 |
),
|
includes/class-wordpress-popular-posts-widget.php
CHANGED
@@ -312,62 +312,22 @@ class WPP_Widget extends WP_Widget {
|
|
312 |
// Return cached results
|
313 |
if ( $this->admin_options['tools']['cache']['active'] ) {
|
314 |
|
315 |
-
$
|
316 |
-
$popular_posts =
|
317 |
|
318 |
if ( false === $popular_posts ) {
|
319 |
|
320 |
$popular_posts = new WPP_Query( $instance );
|
321 |
|
322 |
-
|
|
|
323 |
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
break;
|
331 |
-
|
332 |
-
case 'day':
|
333 |
-
$time = 60 * 60 * 24;
|
334 |
-
break;
|
335 |
-
|
336 |
-
case 'week':
|
337 |
-
$time = 60 * 60 * 24 * 7;
|
338 |
-
break;
|
339 |
-
|
340 |
-
case 'month':
|
341 |
-
$time = 60 * 60 * 24 * 30;
|
342 |
-
break;
|
343 |
-
|
344 |
-
case 'year':
|
345 |
-
$time = 60 * 60 * 24 * 365;
|
346 |
-
break;
|
347 |
-
|
348 |
-
default:
|
349 |
-
$time = 60 * 60;
|
350 |
-
break;
|
351 |
-
|
352 |
-
}
|
353 |
-
|
354 |
-
$expiration = $time * $this->admin_options['tools']['cache']['interval']['value'];
|
355 |
-
|
356 |
-
// Store transient
|
357 |
-
set_transient( $transient_name, $popular_posts, $expiration );
|
358 |
-
|
359 |
-
// Store transient in WPP transients array for garbage collection
|
360 |
-
$wpp_transients = get_option('wpp_transients');
|
361 |
-
|
362 |
-
if ( !$wpp_transients ) {
|
363 |
-
$wpp_transients = array( $transient_name );
|
364 |
-
add_option( 'wpp_transients', $wpp_transients );
|
365 |
-
} else {
|
366 |
-
if ( !in_array($transient_name, $wpp_transients) ) {
|
367 |
-
$wpp_transients[] = $transient_name;
|
368 |
-
update_option( 'wpp_transients', $wpp_transients );
|
369 |
-
}
|
370 |
-
}
|
371 |
|
372 |
}
|
373 |
|
312 |
// Return cached results
|
313 |
if ( $this->admin_options['tools']['cache']['active'] ) {
|
314 |
|
315 |
+
$key = md5( json_encode($instance) );
|
316 |
+
$popular_posts = WPP_Cache::get( $key );
|
317 |
|
318 |
if ( false === $popular_posts ) {
|
319 |
|
320 |
$popular_posts = new WPP_Query( $instance );
|
321 |
|
322 |
+
$time_value = $this->admin_options['tools']['cache']['interval']['value']; // eg. 5
|
323 |
+
$time_unit = $this->admin_options['tools']['cache']['interval']['time']; // eg. 'minute'
|
324 |
|
325 |
+
WPP_Cache::set(
|
326 |
+
$key,
|
327 |
+
$popular_posts,
|
328 |
+
$time_value,
|
329 |
+
$time_unit
|
330 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
|
332 |
}
|
333 |
|
includes/class-wordpress-popular-posts.php
CHANGED
@@ -45,6 +45,11 @@ class WordPressPopularPosts {
|
|
45 |
*/
|
46 |
private function load_dependencies(){
|
47 |
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* The class responsible for defining internationalization functionality of the plugin.
|
50 |
*/
|
45 |
*/
|
46 |
private function load_dependencies(){
|
47 |
|
48 |
+
/**
|
49 |
+
* Caching class.
|
50 |
+
*/
|
51 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-cache.php';
|
52 |
+
|
53 |
/**
|
54 |
* The class responsible for defining internationalization functionality of the plugin.
|
55 |
*/
|
public/class-wordpress-popular-posts-public.php
CHANGED
@@ -104,16 +104,13 @@ class WPP_Public {
|
|
104 |
|
105 |
wp_register_script( 'wpp-js', plugin_dir_url( __FILE__ ) . 'js/wpp-4.1.0.min.js', array(), $this->version, false );
|
106 |
|
107 |
-
$wp_rest_api = class_exists( 'WP_REST_Controller', false );
|
108 |
-
|
109 |
$params = array(
|
110 |
-
'rest_api' => (int) $wp_rest_api,
|
111 |
'sampling_active' => (int) $this->admin_options['tools']['sampling']['active'],
|
112 |
'sampling_rate' => $this->admin_options['tools']['sampling']['rate'],
|
113 |
'ajax_url' => esc_url_raw( rest_url( 'wordpress-popular-posts/v1/popular-posts/' ) ),
|
114 |
'action' => 'update_views_ajax',
|
115 |
'ID' => $is_single,
|
116 |
-
'token' =>
|
117 |
'debug' => WP_DEBUG
|
118 |
);
|
119 |
wp_localize_script( 'wpp-js', 'wpp_params', $params );
|
@@ -376,9 +373,6 @@ class WPP_Public {
|
|
376 |
if ( empty( $ids ) ) {
|
377 |
$shortcode_ops['pid'] = '';
|
378 |
}
|
379 |
-
else {
|
380 |
-
$instance['pid'] = implode( ",", $ids );
|
381 |
-
}
|
382 |
|
383 |
// Category filter
|
384 |
$ids = array_filter( explode( ",", $shortcode_ops['cat'] ), 'is_numeric' );
|
@@ -386,9 +380,6 @@ class WPP_Public {
|
|
386 |
if ( empty( $ids ) ) {
|
387 |
$shortcode_ops['cat'] = '';
|
388 |
}
|
389 |
-
else {
|
390 |
-
$instance['cat'] = implode( ",", $ids );
|
391 |
-
}
|
392 |
|
393 |
// Author filter
|
394 |
$ids = array_filter( explode( ",", $shortcode_ops['author'] ), 'is_numeric' );
|
@@ -396,9 +387,6 @@ class WPP_Public {
|
|
396 |
if ( empty( $ids ) ) {
|
397 |
$shortcode_ops['author'] = '';
|
398 |
}
|
399 |
-
else {
|
400 |
-
$instance['author'] = implode( ",", $ids );
|
401 |
-
}
|
402 |
|
403 |
$shortcode_content = '';
|
404 |
|
@@ -416,62 +404,22 @@ class WPP_Public {
|
|
416 |
// Return cached results
|
417 |
if ( $this->admin_options['tools']['cache']['active'] ) {
|
418 |
|
419 |
-
$
|
420 |
-
$popular_posts =
|
421 |
|
422 |
if ( false === $popular_posts ) {
|
423 |
|
424 |
$popular_posts = new WPP_Query( $shortcode_ops );
|
425 |
|
426 |
-
|
427 |
-
|
428 |
-
case 'minute':
|
429 |
-
$time = 60;
|
430 |
-
break;
|
431 |
-
|
432 |
-
case 'hour':
|
433 |
-
$time = 60 * 60;
|
434 |
-
break;
|
435 |
-
|
436 |
-
case 'day':
|
437 |
-
$time = 60 * 60 * 24;
|
438 |
-
break;
|
439 |
-
|
440 |
-
case 'week':
|
441 |
-
$time = 60 * 60 * 24 * 7;
|
442 |
-
break;
|
443 |
-
|
444 |
-
case 'month':
|
445 |
-
$time = 60 * 60 * 24 * 30;
|
446 |
-
break;
|
447 |
-
|
448 |
-
case 'year':
|
449 |
-
$time = 60 * 60 * 24 * 365;
|
450 |
-
break;
|
451 |
-
|
452 |
-
default:
|
453 |
-
$time = 60 * 60;
|
454 |
-
break;
|
455 |
-
|
456 |
-
}
|
457 |
-
|
458 |
-
$expiration = $time * $this->admin_options['tools']['cache']['interval']['value'];
|
459 |
-
|
460 |
-
// Store transient
|
461 |
-
set_transient( $transient_name, $popular_posts, $expiration );
|
462 |
-
|
463 |
-
// Store transient in WPP transients array for garbage collection
|
464 |
-
$wpp_transients = get_option('wpp_transients');
|
465 |
|
466 |
-
|
467 |
-
$
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
update_option( 'wpp_transients', $wpp_transients );
|
473 |
-
}
|
474 |
-
}
|
475 |
|
476 |
}
|
477 |
|
104 |
|
105 |
wp_register_script( 'wpp-js', plugin_dir_url( __FILE__ ) . 'js/wpp-4.1.0.min.js', array(), $this->version, false );
|
106 |
|
|
|
|
|
107 |
$params = array(
|
|
|
108 |
'sampling_active' => (int) $this->admin_options['tools']['sampling']['active'],
|
109 |
'sampling_rate' => $this->admin_options['tools']['sampling']['rate'],
|
110 |
'ajax_url' => esc_url_raw( rest_url( 'wordpress-popular-posts/v1/popular-posts/' ) ),
|
111 |
'action' => 'update_views_ajax',
|
112 |
'ID' => $is_single,
|
113 |
+
'token' => wp_create_nonce( 'wp_rest' ),
|
114 |
'debug' => WP_DEBUG
|
115 |
);
|
116 |
wp_localize_script( 'wpp-js', 'wpp_params', $params );
|
373 |
if ( empty( $ids ) ) {
|
374 |
$shortcode_ops['pid'] = '';
|
375 |
}
|
|
|
|
|
|
|
376 |
|
377 |
// Category filter
|
378 |
$ids = array_filter( explode( ",", $shortcode_ops['cat'] ), 'is_numeric' );
|
380 |
if ( empty( $ids ) ) {
|
381 |
$shortcode_ops['cat'] = '';
|
382 |
}
|
|
|
|
|
|
|
383 |
|
384 |
// Author filter
|
385 |
$ids = array_filter( explode( ",", $shortcode_ops['author'] ), 'is_numeric' );
|
387 |
if ( empty( $ids ) ) {
|
388 |
$shortcode_ops['author'] = '';
|
389 |
}
|
|
|
|
|
|
|
390 |
|
391 |
$shortcode_content = '';
|
392 |
|
404 |
// Return cached results
|
405 |
if ( $this->admin_options['tools']['cache']['active'] ) {
|
406 |
|
407 |
+
$key = md5( json_encode($shortcode_ops) );
|
408 |
+
$popular_posts = WPP_Cache::get( $key );
|
409 |
|
410 |
if ( false === $popular_posts ) {
|
411 |
|
412 |
$popular_posts = new WPP_Query( $shortcode_ops );
|
413 |
|
414 |
+
$time_value = $this->admin_options['tools']['cache']['interval']['value']; // eg. 5
|
415 |
+
$time_unit = $this->admin_options['tools']['cache']['interval']['time']; // eg. 'minute'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
|
417 |
+
WPP_Cache::set(
|
418 |
+
$key,
|
419 |
+
$popular_posts,
|
420 |
+
$time_value,
|
421 |
+
$time_unit
|
422 |
+
);
|
|
|
|
|
|
|
423 |
|
424 |
}
|
425 |
|
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: 4.9.
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 4.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -58,8 +58,9 @@ Please make sure your site meets the [minimum requirements](https://github.com/c
|
|
58 |
|
59 |
1. Go to Appearance > Widgets, drag and drop the **WordPress Popular Posts** widget to your sidebar. Once you're done configuring it, hit the Save button.
|
60 |
2. If you have a caching plugin installed on your site, flush its cache now so WPP can start tracking your site.
|
61 |
-
3.
|
62 |
-
4.
|
|
|
63 |
|
64 |
That's it!
|
65 |
|
@@ -85,6 +86,14 @@ The FAQ section has been moved [here](https://github.com/cabrerahector/wordpress
|
|
85 |
4. WordPress Popular Posts Stats panel.
|
86 |
|
87 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
= 4.1.1 =
|
89 |
|
90 |
**If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is highly recommended.**
|
@@ -107,11 +116,6 @@ The FAQ section has been moved [here](https://github.com/cabrerahector/wordpress
|
|
107 |
|
108 |
See the [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-4-1-is-here/) for more details!
|
109 |
|
110 |
-
= 4.0.13 =
|
111 |
-
|
112 |
-
- Improvements to WPP's upgrade process.
|
113 |
-
- Fixes ALT text missing from IMG tags.
|
114 |
-
|
115 |
See [full changelog](https://github.com/cabrerahector/wordpress-popular-posts/blob/master/changelog.md).
|
116 |
|
117 |
== Credits ==
|
@@ -119,5 +123,5 @@ See [full changelog](https://github.com/cabrerahector/wordpress-popular-posts/bl
|
|
119 |
* Flame graphic by freevector/Vecteezy.com.
|
120 |
|
121 |
== Upgrade Notice ==
|
122 |
-
= 4.
|
123 |
-
If you're using a caching plugin, flushing its cache after upgrading to this version is
|
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: 4.9.8
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 4.1.2
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
58 |
|
59 |
1. Go to Appearance > Widgets, drag and drop the **WordPress Popular Posts** widget to your sidebar. Once you're done configuring it, hit the Save button.
|
60 |
2. If you have a caching plugin installed on your site, flush its cache now so WPP can start tracking your site.
|
61 |
+
3. If you have a security / firewall plugin installed on your site, make sure you [allow WPP access to the REST API](https://wordpress.org/support/topic/wpp-does-not-count-properly/#post-10411163) so it can start tracking your site.
|
62 |
+
4. Go to Appearance > Editor. Under "Templates", click on `header.php` and make sure that the `<?php wp_head(); ?>` tag is present (should be right before the closing `</head>` tag).
|
63 |
+
5. (Optional, but highly recommended for large / high traffic sites) Enabling [Data Sampling](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#data-sampling) and/or [Caching](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#caching) might be a good idea. Check [here](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance) for more.
|
64 |
|
65 |
That's it!
|
66 |
|
86 |
4. WordPress Popular Posts Stats panel.
|
87 |
|
88 |
== Changelog ==
|
89 |
+
= 4.1.2 =
|
90 |
+
|
91 |
+
- Enables [Data Caching](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#caching) by default (new installs only).
|
92 |
+
- The Parameters section (Settings > WordPress Popular Posts > Parameters) is now mobile-friendly.
|
93 |
+
- Updated the documentation in the Parameters section.
|
94 |
+
- Refactored WPP's caching mechanism into its own class.
|
95 |
+
- Removed unused code.
|
96 |
+
|
97 |
= 4.1.1 =
|
98 |
|
99 |
**If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is highly recommended.**
|
116 |
|
117 |
See the [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-4-1-is-here/) for more details!
|
118 |
|
|
|
|
|
|
|
|
|
|
|
119 |
See [full changelog](https://github.com/cabrerahector/wordpress-popular-posts/blob/master/changelog.md).
|
120 |
|
121 |
== Credits ==
|
123 |
* Flame graphic by freevector/Vecteezy.com.
|
124 |
|
125 |
== Upgrade Notice ==
|
126 |
+
= 4.1.2 =
|
127 |
+
If you're using a caching plugin, flushing its cache after upgrading to this version is recommended.
|
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.1.
|
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.1.
|
33 |
|
34 |
/*
|
35 |
* The code that runs during plugin activation.
|
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.1.2
|
20 |
* Author: Hector Cabrera
|
21 |
* Author URI: https://cabrerahector.com/
|
22 |
* License: GPL-2.0+
|
29 |
die();
|
30 |
}
|
31 |
|
32 |
+
define( 'WPP_VER', '4.1.2' );
|
33 |
|
34 |
/*
|
35 |
* The code that runs during plugin activation.
|