Top 10 – Popular posts plugin for WordPress - Version 2.5.0

Version Description

  • Features:

    • Upgrade old options to Settings API
    • New widget to display the overall count i.e. visits across all your site posts
    • Added a filter to override the number of days that maintenance considers to delete the database entries
    • New option to disable tracking for logged in users. Find "Track logged-in users" under the "Counter/Tracker" tab in the settings screen
  • Enhancements:

    • Make $ajax_tptn_tracker global. Contributed by @pkirk
  • Bug fixes:

    • Make sure that $post object is available in tptn_pc_content filter. Contributed by @mtws
    • When editing Attachment post types, metabox should now save correctly
    • Disable top_ten_nonce as it wasn't needed for front-end users and conflicted with caching plugins
  • Deprecated:

    • tptn_default_options (no replacement) and tptn_read_options (Use tptn_get_settings instead)
Download this release

Release Info

Developer Ajay
Plugin Icon 128x128 Top 10 – Popular posts plugin for WordPress
Version 2.5.0
Comparing to
See all releases

Code changes from version 2.4.4 to 2.5.0

Files changed (48) hide show
  1. README.md +7 -4
  2. admin/admin.php +0 -660
  3. admin/deprecated.php +0 -69
  4. admin/main-view.php +0 -979
  5. changelog.txt +143 -0
  6. includes/activate-deactivate.php +24 -23
  7. {admin → includes/admin}/admin-columns.php +54 -61
  8. {admin → includes/admin}/admin-dashboard.php +27 -22
  9. {admin → includes/admin}/admin-metabox.php +68 -51
  10. includes/admin/admin.php +347 -0
  11. {admin → includes/admin}/cache.php +13 -9
  12. admin/class-stats.php → includes/admin/class-top-ten-statistics-table.php +97 -67
  13. includes/admin/help-tab.php +148 -0
  14. {admin → includes/admin}/images/fb.png +0 -0
  15. {admin → includes/admin}/images/index.php +0 -0
  16. {admin → includes/admin}/images/tptn-left-thumbs.png +0 -0
  17. {admin → includes/admin}/images/twitter.jpg +0 -0
  18. {admin → includes/admin}/index.php +0 -0
  19. includes/admin/register-settings.php +1001 -0
  20. includes/admin/save-settings.php +356 -0
  21. includes/admin/settings-page.php +675 -0
  22. includes/admin/sidebar.php +96 -0
  23. includes/admin/tools.php +186 -0
  24. includes/counter.php +60 -56
  25. includes/cron.php +34 -21
  26. includes/deprecated.php +199 -26
  27. includes/formatting.php +17 -17
  28. includes/js/top-10-tracker.js +1 -1
  29. includes/l10n.php +8 -8
  30. includes/modules/class-top-10-widget.php +0 -350
  31. includes/modules/class-top-ten-count-widget.php +134 -0
  32. includes/modules/class-top-ten-widget.php +356 -0
  33. includes/modules/exclusions.php +5 -5
  34. includes/modules/shortcode.php +24 -20
  35. includes/modules/taxonomies.php +12 -12
  36. includes/public/display-posts.php +123 -116
  37. includes/public/media.php +109 -108
  38. includes/public/output-generator.php +101 -98
  39. includes/public/styles.php +9 -9
  40. includes/tracker.php +46 -46
  41. languages/top-10-en_US.mo +0 -0
  42. languages/top-10-en_US.po +1124 -114
  43. languages/top-10-en_US.pot +1126 -115
  44. languages/top-10-fa_IR.mo +0 -0
  45. languages/top-10-fa_IR.po +0 -310
  46. readme.txt +30 -154
  47. top-10.php +59 -188
  48. uninstall.php +8 -7
README.md CHANGED
@@ -1,10 +1,13 @@
 
 
 
1
  [![Build Status](https://travis-ci.org/WebberZone/top-10.svg?branch=master)](https://travis-ci.org/WebberZone/top-10)
2
 
3
  # Top 10 - Popular posts plugin for WordPress
4
 
5
  __Requires:__ 4.1
6
 
7
- __Tested up to:__ 4.7
8
 
9
  __License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)
10
 
@@ -16,9 +19,9 @@ Track daily and total visits on your blog posts. Display the count as well as po
16
 
17
  WordPress doesn't have an in-built system to track page views or displaying popular posts. [Top 10](https://webberzone.com/plugins/top-10/) is an easy to use, yet, powerful WordPress plugin that will count the number of page views of your posts, pages and any custom post types. You can then display the page view counts as well as display your most popular posts.
18
 
19
- Top 10 will add a widget that you can use to display the popular posts list.
20
 
21
- Although several similar plugins exist today, Top 10 is one of the most feature rich popular post plugins with support for thumbnails, shortcodes, widgets, custom post types and CSS styles. The inbuilt caching system also helps reduce server load by caching your popular posts output. The tracking uses ajax and is thus compatible with most popular caching plugins.
22
 
23
  Top 10 also has powerful API and is fully extendable with WordPress actions and filters to allow you easily extend the code base to add new features or tweak existing ones.
24
 
@@ -78,7 +81,7 @@ For more screenshots visit the [WordPress plugin page](http://wordpress.org/plug
78
 
79
  ## Frequently Asked Questions
80
 
81
- Check out the [FAQ on the plugin page](http://wordpress.org/plugins/top-10/faq/).
82
 
83
  If your question isn't listed there, please create a new post at the [WordPress.org support forum](http://wordpress.org/support/plugin/top-10). It is the fastest way to get support as I monitor the forums regularly. I also provide [premium *paid* support via email](https://webberzone.com/support/).
84
 
1
+ [![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/top-10.svg?style=flat-square)](https://wordpress.org/plugins/top-10/)
2
+ [![License](https://img.shields.io/badge/license-GPL_v2%2B-orange.svg?style=flat-square)](http://opensource.org/licenses/GPL-2.0)
3
+ [![WordPress Tested](https://img.shields.io/wordpress/v/top-10.svg?style=flat-square)](https://wordpress.org/plugins/top-10/)
4
  [![Build Status](https://travis-ci.org/WebberZone/top-10.svg?branch=master)](https://travis-ci.org/WebberZone/top-10)
5
 
6
  # Top 10 - Popular posts plugin for WordPress
7
 
8
  __Requires:__ 4.1
9
 
10
+ __Tested up to:__ 4.9
11
 
12
  __License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html)
13
 
19
 
20
  WordPress doesn't have an in-built system to track page views or displaying popular posts. [Top 10](https://webberzone.com/plugins/top-10/) is an easy to use, yet, powerful WordPress plugin that will count the number of page views of your posts, pages and any custom post types. You can then display the page view counts as well as display your most popular posts.
21
 
22
+ Top 10 adds two widgets that you can use to display a list of popular posts and the counta cross all your blog posts.
23
 
24
+ Although several similar plugins exist today, Top 10 is one of the most feature-rich popular post plugins with support for thumbnails, shortcodes, widgets, custom post types and CSS styles. The inbuilt caching system also helps reduce server load by caching your popular posts output. The tracking uses ajax and is thus compatible with most popular caching plugins.
25
 
26
  Top 10 also has powerful API and is fully extendable with WordPress actions and filters to allow you easily extend the code base to add new features or tweak existing ones.
27
 
81
 
82
  ## Frequently Asked Questions
83
 
84
+ Check out the [FAQ on the plugin page](http://wordpress.org/plugins/top-10/faq/) and the [FAQ on the WebberZone knowledgebase](https://webberzone.com/support/section/top-10/).
85
 
86
  If your question isn't listed there, please create a new post at the [WordPress.org support forum](http://wordpress.org/support/plugin/top-10). It is the fastest way to get support as I monitor the forums regularly. I also provide [premium *paid* support via email](https://webberzone.com/support/).
87
 
admin/admin.php DELETED
@@ -1,660 +0,0 @@
1
- <?php
2
- /**
3
- * Top 10 Admin interface.
4
- *
5
- * This page is accessible via Top 10 Settings menu item
6
- *
7
- * @package Top_Ten
8
- * @author Ajay D'Souza <me@ajaydsouza.com>
9
- * @license GPL-2.0+
10
- * @link https://webberzone.com
11
- * @copyright 2008-2016 Ajay D'Souza
12
- */
13
-
14
- /**** If this file is called directly, abort. ****/
15
- if ( ! defined( 'WPINC' ) ) {
16
- die;
17
- }
18
-
19
-
20
- /**
21
- * Function generates the plugin settings page.
22
- *
23
- * @since 1.0
24
- */
25
- function tptn_options() {
26
-
27
- global $wpdb;
28
-
29
- $tptn_settings = tptn_read_options();
30
-
31
- /* Temporary check to remove the deprecated hook */
32
- if ( wp_next_scheduled( 'ald_tptn_hook' ) ) {
33
- wp_clear_scheduled_hook( 'ald_tptn_hook' );
34
-
35
- tptn_enable_run( $tptn_settings['cron_hour'], $tptn_settings['cron_min'], $tptn_settings['cron_recurrence'] );
36
- }
37
-
38
- /*
39
- Temporary check if default styles are off and left thumbnails are selected - will be eventually deprecated
40
- This is a mismatch, so we force it to no style
41
- */
42
- if ( ( false === $tptn_settings['include_default_style'] ) && ( 'left_thumbs' === $tptn_settings['tptn_styles'] ) ) {
43
- $tptn_settings['tptn_styles'] = 'no_style';
44
- update_option( 'ald_tptn_settings', $tptn_settings );
45
- }
46
- if ( ( true === $tptn_settings['include_default_style'] ) && ( 'left_thumbs' !== $tptn_settings['tptn_styles'] ) ) {
47
- $tptn_settings['tptn_styles'] = 'left_thumbs';
48
- update_option( 'ald_tptn_settings', $tptn_settings );
49
- }
50
-
51
- /* Parse post types */
52
- parse_str( $tptn_settings['post_types'], $post_types );
53
- $wp_post_types = get_post_types( array(
54
- 'public' => true,
55
- ) );
56
- $posts_types_inc = array_intersect( $wp_post_types, $post_types );
57
-
58
- /* Save options has been triggered */
59
- if ( ( isset( $_POST['tptn_save'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
60
-
61
- /* General options */
62
- $tptn_settings['activate_overall'] = isset( $_POST['activate_overall'] ) ? true : false;
63
- $tptn_settings['activate_daily'] = isset( $_POST['activate_daily'] ) ? true : false;
64
- $tptn_settings['cache'] = isset( $_POST['cache'] ) ? true : false;
65
- $tptn_settings['daily_midnight'] = isset( $_POST['daily_midnight'] ) ? true : false;
66
- $tptn_settings['daily_range'] = absint( $_POST['daily_range'] );
67
- $tptn_settings['hour_range'] = absint( $_POST['hour_range'] );
68
- $tptn_settings['uninstall_clean_options'] = isset( $_POST['uninstall_clean_options'] ) ? true : false;
69
- $tptn_settings['uninstall_clean_tables'] = isset( $_POST['uninstall_clean_tables'] ) ? true : false;
70
- $tptn_settings['show_metabox'] = ( isset( $_POST['show_metabox'] ) ? true : false );
71
- $tptn_settings['show_metabox_admins'] = ( isset( $_POST['show_metabox_admins'] ) ? true : false );
72
- $tptn_settings['show_credit'] = isset( $_POST['show_credit'] ) ? true : false;
73
-
74
- /* Counter and tracker options */
75
- $tptn_settings['add_to_content'] = isset( $_POST['add_to_content'] ) ? true : false;
76
- $tptn_settings['count_on_pages'] = isset( $_POST['count_on_pages'] ) ? true : false;
77
- $tptn_settings['add_to_feed'] = isset( $_POST['add_to_feed'] ) ? true : false;
78
- $tptn_settings['add_to_home'] = isset( $_POST['add_to_home'] ) ? true : false;
79
- $tptn_settings['add_to_category_archives'] = isset( $_POST['add_to_category_archives'] ) ? true : false;
80
- $tptn_settings['add_to_tag_archives'] = isset( $_POST['add_to_tag_archives'] ) ? true : false;
81
- $tptn_settings['add_to_archives'] = isset( $_POST['add_to_archives'] ) ? true : false;
82
-
83
- $tptn_settings['count_disp_form'] = wp_kses_post( wp_unslash( $_POST['count_disp_form'] ) );
84
- $tptn_settings['count_disp_form_zero'] = wp_kses_post( wp_unslash( $_POST['count_disp_form_zero'] ) );
85
- $tptn_settings['dynamic_post_count'] = isset( $_POST['dynamic_post_count'] ) ? true : false;
86
-
87
- $tptn_settings['tracker_type'] = sanitize_text_field( $_POST['tracker_type'] );
88
- $tptn_settings['track_authors'] = isset( $_POST['track_authors'] ) ? true : false;
89
- $tptn_settings['track_admins'] = isset( $_POST['track_admins'] ) ? true : false;
90
- $tptn_settings['track_editors'] = isset( $_POST['track_editors'] ) ? true : false;
91
-
92
- $tptn_settings['pv_in_admin'] = isset( $_POST['pv_in_admin'] ) ? true : false;
93
- $tptn_settings['show_count_non_admins'] = isset( $_POST['show_count_non_admins'] ) ? true : false;
94
-
95
- /* Popular post list options */
96
- $tptn_settings['limit'] = absint( $_POST['limit'] );
97
- $tptn_settings['how_old'] = absint( $_POST['how_old'] );
98
-
99
- // Process post types to be selected.
100
- $wp_post_types = get_post_types( array(
101
- 'public' => true,
102
- ) );
103
- $post_types_arr = ( isset( $_POST['post_types'] ) && is_array( $_POST['post_types'] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['post_types'] ) ) : array( 'post' => 'post' );
104
- $post_types = array_intersect( $wp_post_types, $post_types_arr );
105
- $tptn_settings['post_types'] = http_build_query( $post_types, '', '&' );
106
-
107
- $tptn_settings['exclude_post_ids'] = empty( $_POST['exclude_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_post_ids'] ) ) ) ) );
108
-
109
- /**** Exclude categories ****/
110
- $exclude_categories_slugs = array_map( 'trim', explode( ',', sanitize_text_field( $_POST['exclude_cat_slugs'] ) ) );
111
-
112
- foreach ( $exclude_categories_slugs as $exclude_categories_slug ) {
113
- $category_obj = get_term_by( 'name', $exclude_categories_slug, 'category' );
114
-
115
- // Fall back to slugs since that was the default format before v2.4.0.
116
- if ( false === $category_obj ) {
117
- $category_obj = get_term_by( 'slug', $exclude_categories_slug, 'category' );
118
- }
119
- if ( isset( $category_obj->term_taxonomy_id ) ) {
120
- $exclude_categories[] = $category_obj->term_taxonomy_id;
121
- $exclude_cat_slugs[] = $category_obj->name;
122
- }
123
- }
124
- $tptn_settings['exclude_categories'] = ( isset( $exclude_categories ) ) ? join( ',', $exclude_categories ) : '';
125
- $tptn_settings['exclude_cat_slugs'] = ( isset( $exclude_cat_slugs ) ) ? join( ',', $exclude_cat_slugs ) : '';
126
-
127
- $tptn_settings['title'] = wp_kses_post( $_POST['title'] );
128
- $tptn_settings['title_daily'] = wp_kses_post( $_POST['title_daily'] );
129
-
130
- $tptn_settings['blank_output'] = ( 'blank' === sanitize_text_field( $_POST['blank_output'] ) ) ? true : false;
131
- $tptn_settings['blank_output_text'] = wp_kses_post( $_POST['blank_output_text'] );
132
-
133
- $tptn_settings['show_excerpt'] = isset( $_POST['show_excerpt'] ) ? true : false;
134
- $tptn_settings['excerpt_length'] = absint( $_POST['excerpt_length'] );
135
- $tptn_settings['show_date'] = isset( $_POST['show_date'] ) ? true : false;
136
- $tptn_settings['show_author'] = isset( $_POST['show_author'] ) ? true : false;
137
- $tptn_settings['title_length'] = absint( $_POST['title_length'] );
138
- $tptn_settings['disp_list_count'] = isset( $_POST['disp_list_count'] ) ? true : false;
139
-
140
- $tptn_settings['link_new_window'] = isset( $_POST['link_new_window'] ) ? true : false;
141
- $tptn_settings['link_nofollow'] = isset( $_POST['link_nofollow'] ) ? true : false;
142
- $tptn_settings['exclude_on_post_ids'] = empty( $_POST['exclude_on_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( $_POST['exclude_on_post_ids'] ) ) ) );
143
-
144
- // List HTML options
145
- $tptn_settings['before_list'] = wp_kses_post( $_POST['before_list'] );
146
- $tptn_settings['after_list'] = wp_kses_post( $_POST['after_list'] );
147
- $tptn_settings['before_list_item'] = wp_kses_post( $_POST['before_list_item'] );
148
- $tptn_settings['after_list_item'] = wp_kses_post( $_POST['after_list_item'] );
149
-
150
- /* Thumbnail options */
151
- $tptn_settings['post_thumb_op'] = sanitize_text_field( $_POST['post_thumb_op'] );
152
- $tptn_settings['thumb_size'] = sanitize_text_field( $_POST['thumb_size'] );
153
- $tptn_settings['thumb_width'] = absint( $_POST['thumb_width'] );
154
- $tptn_settings['thumb_height'] = absint( $_POST['thumb_height'] );
155
- $tptn_settings['thumb_crop'] = ( isset( $_POST['thumb_crop'] ) ? true : false );
156
- $tptn_settings['thumb_html'] = sanitize_text_field( $_POST['thumb_html'] );
157
-
158
- $tptn_settings['thumb_meta'] = empty( $_POST['thumb_meta'] ) ? 'post-image' : sanitize_text_field( $_POST['thumb_meta'] );
159
- $tptn_settings['scan_images'] = isset( $_POST['scan_images'] ) ? true : false;
160
- $tptn_settings['thumb_default_show'] = isset( $_POST['thumb_default_show'] ) ? true : false;
161
- $tptn_settings['thumb_default'] = ( ( '' === esc_url_raw( $_POST['thumb_default'] ) ) || ( '/default.png' === esc_url_raw( $_POST['thumb_default'] ) ) ) ? TOP_TEN_PLUGIN_URL . '/default.png' : esc_url_raw( $_POST['thumb_default'] );
162
-
163
- /* Styles */
164
- $tptn_settings['custom_CSS'] = wp_kses_post( $_POST['custom_CSS'] );
165
-
166
- $tptn_settings['tptn_styles'] = sanitize_text_field( $_POST['tptn_styles'] );
167
-
168
- if ( 'left_thumbs' === $tptn_settings['tptn_styles'] ) {
169
- $tptn_settings['include_default_style'] = true;
170
- $tptn_settings['post_thumb_op'] = 'inline';
171
- } elseif ( 'text_only' === $tptn_settings['tptn_styles'] ) {
172
- $tptn_settings['include_default_style'] = false;
173
- $tptn_settings['post_thumb_op'] = 'text_only';
174
- } else {
175
- $tptn_settings['include_default_style'] = false;
176
- }
177
-
178
- /**
179
- * Filter the settings array just before saving them to the database
180
- *
181
- * @since 2.0.4
182
- *
183
- * @param array $tptn_settings Settings array
184
- */
185
- $tptn_settings = apply_filters( 'tptn_save_options', $tptn_settings );
186
-
187
- /* Update the options */
188
- update_option( 'ald_tptn_settings', $tptn_settings );
189
-
190
- /* Let's get the options again after we update them */
191
- $tptn_settings = tptn_read_options();
192
- parse_str( $tptn_settings['post_types'], $post_types );
193
- $posts_types_inc = array_intersect( $wp_post_types, $post_types );
194
-
195
- // Delete the cache.
196
- tptn_cache_delete();
197
-
198
- /* Echo a success message */
199
- $str = '<div id="message" class="updated fade"><p>' . __( 'Options saved successfully. If enabled, the cache has been cleared.', 'top-10' ) . '</p>';
200
-
201
- if ( 'left_thumbs' === $tptn_settings['tptn_styles'] ) {
202
- $str .= '<p>' . __( 'Left Thumbnails style selected. Post thumbnail location set to Inline before text.', 'top-10' ) . '</p>';
203
- }
204
- if ( 'text_only' === $tptn_settings['tptn_styles'] ) {
205
- $str .= '<p>' . __( 'Text Only style selected. Thumbnails will not be displayed.', 'top-10' ) . '</p>';
206
- }
207
- if ( 'tptn_thumbnail' !== $tptn_settings['thumb_size'] ) {
208
- $thumb_size = tptn_get_all_image_sizes( $tptn_settings['thumb_size'] );
209
- $str .= '<p>' . sprintf( __( 'Pre-built thumbnail size selected. Thumbnail set to %1$d x %2$d.', 'top-10' ), $thumb_size['width'], $thumb_size['height'] ) . '</p>';
210
- }
211
-
212
- $str .= '</div>';
213
-
214
- echo $str;
215
- }
216
-
217
- /* Default options has been triggered */
218
- if ( ( isset( $_POST['tptn_default'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
219
- delete_option( 'ald_tptn_settings' );
220
- $tptn_settings = tptn_default_options();
221
- update_option( 'ald_tptn_settings', $tptn_settings );
222
- tptn_disable_run();
223
-
224
- $str = '<div id="message" class="updated fade"><p>' . __( 'Options set to Default.', 'top-10' ) . '</p></div>';
225
- echo $str;
226
- }
227
-
228
- /* Truncate overall posts table */
229
- if ( ( isset( $_POST['tptn_trunc_all'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
230
- tptn_trunc_count( false );
231
- $str = '<div id="message" class="updated fade"><p>' . __( 'Top 10 popular posts reset', 'top-10' ) . '</p></div>';
232
- echo $str;
233
- }
234
-
235
- /* Truncate daily posts table */
236
- if ( ( isset( $_POST['tptn_trunc_daily'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
237
- tptn_trunc_count( true );
238
- $str = '<div id="message" class="updated fade"><p>' . __( 'Top 10 daily popular posts reset', 'top-10' ) . '</p></div>';
239
- echo $str;
240
- }
241
-
242
- /* Clean duplicates */
243
- if ( ( isset( $_POST['tptn_clean_duplicates'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
244
- tptn_clean_duplicates( true );
245
- tptn_clean_duplicates( false );
246
- $str = '<div id="message" class="updated fade"><p>' . __( 'Duplicate rows cleaned from tables', 'top-10' ) . '</p></div>';
247
- echo $str;
248
- }
249
-
250
- /* Merge blog IDs */
251
- if ( ( isset( $_POST['tptn_merge_blogids'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
252
- tptn_merge_blogids( true );
253
- tptn_merge_blogids( false );
254
- $str = '<div id="message" class="updated fade"><p>' . __( 'Post counts across blog IDs 0 and 1 have been merged', 'top-10' ) . '</p></div>';
255
- echo $str;
256
- }
257
-
258
- /* Save maintenance options */
259
- if ( ( isset( $_POST['tptn_mnts_save'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
260
- $tptn_settings['cron_hour'] = min( 23, absint( $_POST['cron_hour'] ) );
261
- $tptn_settings['cron_min'] = min( 59, absint( $_POST['cron_min'] ) );
262
- $tptn_settings['cron_recurrence'] = sanitize_text_field( $_POST['cron_recurrence'] );
263
-
264
- if ( isset( $_POST['cron_on'] ) ) {
265
- $tptn_settings['cron_on'] = true;
266
- tptn_enable_run( $tptn_settings['cron_hour'], $tptn_settings['cron_min'], $tptn_settings['cron_recurrence'] );
267
- $str = '<div id="message" class="updated fade"><p>' . __( 'Scheduled maintenance enabled / modified', 'top-10' ) . '</p></div>';
268
- } else {
269
- $tptn_settings['cron_on'] = false;
270
- tptn_disable_run();
271
- $str = '<div id="message" class="updated fade"><p>' . __( 'Scheduled maintenance disabled', 'top-10' ) . '</p></div>';
272
- }
273
- update_option( 'ald_tptn_settings', $tptn_settings );
274
- $tptn_settings = tptn_read_options();
275
-
276
- echo $str;
277
- }
278
-
279
- if ( ( isset( $_POST['tptn_import'] ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
280
-
281
- $top_ten_all_mu_tables = isset( $_POST['top_ten_all_mu_tables'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['top_ten_all_mu_tables'] ) ) : array();
282
- $top_ten_mu_tables_blog_ids = explode( ',', sanitize_text_field( $_POST['top_ten_mu_tables_blog_ids'] ) );
283
- $top_ten_mu_tables_sel_blog_ids = array_values( $top_ten_all_mu_tables );
284
-
285
- foreach ( $top_ten_mu_tables_sel_blog_ids as $top_ten_mu_tables_sel_blog_id ) {
286
- $sql = '
287
- INSERT INTO ' . $wpdb->base_prefix . "top_ten (postnumber, cntaccess, blog_id)
288
- SELECT postnumber, cntaccess, '%d' FROM " . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten
289
- ON DUPLICATE KEY UPDATE ' . $wpdb->base_prefix . 'top_ten.cntaccess = ' . $wpdb->base_prefix . 'top_ten.cntaccess + (
290
- SELECT ' . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten.cntaccess FROM ' . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten WHERE ' . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten.postnumber = ' . $wpdb->base_prefix . 'top_ten.postnumber
291
- )
292
- ';
293
-
294
- $wpdb->query( $wpdb->prepare( $sql, $top_ten_mu_tables_sel_blog_id ) );
295
-
296
- $sql = '
297
- INSERT INTO ' . $wpdb->base_prefix . "top_ten_daily (postnumber, cntaccess, dp_date, blog_id)
298
- SELECT postnumber, cntaccess, dp_date, '%d' FROM " . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten_daily
299
- ON DUPLICATE KEY UPDATE ' . $wpdb->base_prefix . 'top_ten_daily.cntaccess = ' . $wpdb->base_prefix . 'top_ten_daily.cntaccess + (
300
- SELECT ' . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten_daily.cntaccess FROM ' . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten_daily WHERE ' . $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten_daily.postnumber = ' . $wpdb->base_prefix . 'top_ten_daily.postnumber
301
- )
302
- ';
303
-
304
- $wpdb->query( $wpdb->prepare( $sql, $top_ten_mu_tables_sel_blog_id ) );
305
- }
306
-
307
- update_site_option( 'top_ten_mu_tables_sel_blog_ids', array_unique( array_merge( $top_ten_mu_tables_sel_blog_ids, get_site_option( 'top_ten_mu_tables_sel_blog_ids', array() ) ) ) );
308
-
309
- $str = '<div id="message" class="updated fade"><p>' . __( 'Counts from selected sites have been imported.', 'top-10' ) . '</p></div>';
310
- echo $str;
311
- }
312
-
313
- if ( ( ( isset( $_POST['tptn_delete_selected_tables'] ) ) || ( isset( $_POST['tptn_delete_imported_tables'] ) ) ) && ( check_admin_referer( 'tptn-plugin-settings' ) ) ) {
314
- $top_ten_all_mu_tables = isset( $_POST['top_ten_all_mu_tables'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['top_ten_all_mu_tables'] ) ) : array();
315
- $top_ten_mu_tables_blog_ids = explode( ',', sanitize_text_field( $_POST['top_ten_mu_tables_blog_ids'] ) );
316
- $top_ten_mu_tables_sel_blog_ids = array_values( $top_ten_all_mu_tables );
317
-
318
- if ( isset( $_POST['tptn_delete_selected_tables'] ) ) {
319
- $top_ten_mu_tables_sel_blog_ids = array_intersect( $top_ten_mu_tables_sel_blog_ids, get_site_option( 'top_ten_mu_tables_sel_blog_ids', array() ) );
320
- } else {
321
- $top_ten_mu_tables_sel_blog_ids = get_site_option( 'top_ten_mu_tables_sel_blog_ids', array() );
322
- }
323
-
324
- if ( ! empty( $top_ten_mu_tables_sel_blog_ids ) ) {
325
-
326
- $sql = 'DROP TABLE ';
327
- foreach ( $top_ten_mu_tables_sel_blog_ids as $top_ten_mu_tables_sel_blog_id ) {
328
- $sql .= $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten, ';
329
- $sql .= $wpdb->base_prefix . $top_ten_mu_tables_sel_blog_id . '_top_ten_daily, ';
330
- }
331
- $sql = substr( $sql, 0, -2 );
332
-
333
- $wpdb->query( $sql );
334
- $str = '<div id="message" class="updated fade"><p>' . __( 'Selected tables have been deleted. Note that only imported tables have been deleted.', 'top-10' ) . '</p></div>';
335
- echo $str;
336
- }
337
- }
338
-
339
- /**** Include the views page ****/
340
- include_once( 'main-view.php' );
341
- }
342
-
343
-
344
- /**
345
- * Function to generate the right sidebar of the Settings and Admin popular posts pages.
346
- *
347
- * @since 1.8.1
348
- */
349
- function tptn_admin_side() {
350
- ?>
351
- <div id="donatediv" class="postbox">
352
- <div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'top-10' ); ?>">
353
- <br />
354
- </div>
355
- <h3 class='hndle'><span><?php esc_html_e( 'Support the development', 'top-10' ); ?></span></h3>
356
- <div class="inside">
357
- <div id="donate-form">
358
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
359
- <input type="hidden" name="cmd" value="_xclick">
360
- <input type="hidden" name="business" value="donate@ajaydsouza.com">
361
- <input type="hidden" name="lc" value="IN">
362
- <input type="hidden" name="item_name" value="<?php esc_attr_e( 'Donation for Top 10', 'top-10' ); ?>">
363
- <input type="hidden" name="item_number" value="tptn_admin">
364
- <strong><?php esc_html_e( 'Enter amount in USD:', 'top-10' ); ?></strong>
365
- <input name="amount" value="10.00" size="6" type="text">
366
- <br />
367
- <input type="hidden" name="currency_code" value="USD">
368
- <input type="hidden" name="button_subtype" value="services">
369
- <input type="hidden" name="bn" value="PP-BuyNowBF:btn_donate_LG.gif:NonHosted">
370
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="<?php esc_attr_e( 'Send your donation to the author of Top 10', 'top-10' ); ?>">
371
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
372
- </form>
373
- </div>
374
- </div>
375
- </div>
376
- <div id="qlinksdiv" class="postbox">
377
- <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'top-10' ); ?>">
378
- <br />
379
- </div>
380
- <h3 class='hndle'><span><?php esc_html_e( 'Quick links', 'top-10' ); ?></span></h3>
381
- <div class="inside">
382
- <div id="quick-links">
383
- <ul>
384
- <li>
385
- <a href="https://webberzone.com/" target="_blank">
386
- WebberZone
387
- </a>
388
- </li>
389
- <li>
390
- <a href="https://webberzone.com/plugins/top-10/" target="_blank">
391
- <?php esc_html_e( 'Top 10 plugin page', 'top-10' ); ?>
392
- </a>
393
- </li>
394
- <li>
395
- <a href="https://github.com/ajaydsouza/top-10" target="_blank">
396
- <?php esc_html_e( 'Top 10 Github page', 'top-10' ); ?>
397
- </a>
398
- </li>
399
- <li>
400
- <a href="https://wordpress.org/plugins/top-10/faq/" target="_blank">
401
- <?php esc_html_e( 'FAQ', 'top-10' ); ?>
402
- </a>
403
- </li>
404
- <li>
405
- <a href="https://wordpress.org/support/plugin/top-10" target="_blank">
406
- <?php esc_html_e( 'Support', 'top-10' ); ?>
407
- </a>
408
- </li>
409
- <li>
410
- <a href="https://wordpress.org/support/view/plugin-reviews/top-10" target="_blank">
411
- <?php esc_html_e( 'Reviews', 'top-10' ); ?>
412
- </a>
413
- </li>
414
- <li>
415
- <a href="https://ajaydsouza.com/" target="_blank">
416
- <?php esc_html_e( "Ajay's blog", 'top-10' ); ?>
417
- </a>
418
- </li>
419
- <li>
420
- <a href="https://webberzone.com/plugins/" target="_blank">
421
- <?php esc_html_e( 'Other plugins', 'top-10' ); ?>
422
- </a>
423
- </li>
424
- </ul>
425
- </div>
426
- </div>
427
- </div>
428
- <div id="followdiv" class="postbox">
429
- <div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'top-10' ); ?>">
430
- <br />
431
- </div>
432
- <h3 class='hndle'><span><?php esc_html_e( 'Follow us', 'top-10' ); ?></span></h3>
433
- <div class="inside">
434
- <a href="https://facebook.com/webberzone/" target="_blank"><img src="<?php echo esc_url( TOP_TEN_PLUGIN_URL . '/admin/images/fb.png' ); ?>" width="100" height="100" /></a>
435
- <a href="https://twitter.com/webberzonewp/" target="_blank"><img src="<?php echo esc_url( TOP_TEN_PLUGIN_URL . '/admin/images/twitter.jpg' ); ?>" width="100" height="100" /></a>
436
- </div>
437
- </div>
438
-
439
- <?php
440
- }
441
-
442
-
443
- /**
444
- * Add Top 10 menu in WP-Admin.
445
- *
446
- * @since 1.0
447
- */
448
- function tptn_adminmenu() {
449
-
450
- $plugin_page = add_menu_page( __( 'Top 10 Settings', 'top-10' ), __( 'Top 10', 'top-10' ), 'manage_options', 'tptn_options', 'tptn_options', 'dashicons-editor-ol' );
451
- add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
452
-
453
- $plugin_page = add_submenu_page( 'tptn_options', __( 'Top 10 Settings', 'top-10' ), __( 'Top 10 Settings', 'top-10' ), 'manage_options', 'tptn_options', 'tptn_options' );
454
- add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
455
-
456
- $tptn_stats_screen = new Top_Ten_Statistics;
457
-
458
- $plugin_page = add_submenu_page( 'tptn_options', __( 'View Popular Posts', 'top-10' ), __( 'View Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts', array( $tptn_stats_screen, 'plugin_settings_page' ) );
459
- add_action( "load-$plugin_page", array( $tptn_stats_screen, 'screen_option' ) );
460
- add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
461
-
462
- $plugin_page = add_submenu_page( 'tptn_options', __( 'Daily Popular Posts', 'top-10' ), __( 'Daily Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts&orderby=daily_count&order=desc', array( $tptn_stats_screen, 'plugin_settings_page' ) );
463
- add_action( "load-$plugin_page", array( $tptn_stats_screen, 'screen_option' ) );
464
- add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
465
-
466
- }
467
- add_action( 'admin_menu', 'tptn_adminmenu' );
468
-
469
-
470
- /**
471
- * Add JS and CSS to admin header.
472
- *
473
- * @since 1.6
474
- */
475
- function tptn_adminhead() {
476
-
477
- wp_enqueue_script( 'common' );
478
- wp_enqueue_script( 'wp-lists' );
479
- wp_enqueue_script( 'postbox' );
480
- wp_enqueue_script( 'plugin-install' );
481
- wp_enqueue_script( 'suggest' );
482
-
483
- add_thickbox();
484
-
485
- ?>
486
- <style type="text/css">
487
- .postbox .handlediv:before {
488
- right: 12px;
489
- font: 400 20px/1 dashicons;
490
- speak: none;
491
- display: inline-block;
492
- top: 0;
493
- position: relative;
494
- -webkit-font-smoothing: antialiased;
495
- -moz-osx-font-smoothing: grayscale;
496
- text-decoration: none!important;
497
- content: '\f142';
498
- padding: 8px 10px;
499
- }
500
-
501
- .postbox.closed .handlediv:before {
502
- content: '\f140';
503
- }
504
-
505
- .wrap h2:before {
506
- content: "\f204";
507
- display: inline-block;
508
- -webkit-font-smoothing: antialiased;
509
- font: normal 29px/1 'dashicons';
510
- vertical-align: middle;
511
- margin-right: 0.3em;
512
- }
513
- </style>
514
-
515
- <script type="text/javascript">
516
- //<![CDATA[
517
- jQuery(document).ready(function ($) {
518
- // close postboxes that should be closed
519
- $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
520
- // postboxes setup
521
- postboxes.add_postbox_toggles('tptn_options');
522
- });
523
-
524
- // Function to add auto suggest.
525
- function setSuggest( id, taxonomy ) {
526
- jQuery('#' + id).suggest("<?php echo admin_url( 'admin-ajax.php?action=ajax-tag-search&tax=' ); ?>" + taxonomy, {multiple:true, multipleSep: ","});
527
- }
528
-
529
- // Function check the form submission.
530
- function checkForm() {
531
- answer = true;
532
- if (siw && siw.selectingSomething)
533
- answer = false;
534
- return answer;
535
- } //
536
-
537
- // Function to clear the cache.
538
- function clearCache() {
539
- /**** since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php ****/
540
- jQuery.post(ajaxurl, {
541
- action: 'tptn_clear_cache'
542
- }, function (response, textStatus, jqXHR) {
543
- alert(response.message);
544
- }, 'json');
545
- }
546
- //]]>
547
- </script>
548
-
549
- <?php
550
- }
551
-
552
-
553
- /**
554
- * Adding WordPress plugin action links.
555
- *
556
- * @version 1.9.2
557
- *
558
- * @param array $links Action links.
559
- * @return array Links array with our settings link added.
560
- */
561
- function tptn_plugin_actions_links( $links ) {
562
-
563
- return array_merge(
564
- array(
565
- 'settings' => '<a href="' . admin_url( 'options-general.php?page=tptn_options' ) . '">' . __( 'Settings', 'top-10' ) . '</a>',
566
- ),
567
- $links
568
- );
569
-
570
- }
571
- add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __DIR__ ) . 'top-10.php' ), 'tptn_plugin_actions_links' );
572
-
573
-
574
- /**
575
- * Add links to the plugin action row.
576
- *
577
- * @since 1.5
578
- *
579
- * @param array $links Action links.
580
- * @param array $file Plugin file name.
581
- * @return array Links array with our links added
582
- */
583
- function tptn_plugin_actions( $links, $file ) {
584
- $plugin = plugin_basename( TOP_TEN_PLUGIN_FILE );
585
-
586
- if ( $file == $plugin ) {
587
- $links[] = '<a href="https://wordpress.org/support/plugin/top-10/">' . __( 'Support', 'top-10' ) . '</a>';
588
- $links[] = '<a href="https://ajaydsouza.com/donate/">' . __( 'Donate', 'top-10' ) . '</a>';
589
- $links[] = '<a href="https://github.com/WebberZone/top-10">' . __( 'Contribute', 'contextual-related-posts' ) . '</a>';
590
- }
591
- return $links;
592
- }
593
- add_filter( 'plugin_row_meta', 'tptn_plugin_actions', 10, 2 );
594
-
595
-
596
- /**
597
- * Function to delete all duplicate rows in the posts table.
598
- *
599
- * @since 1.6.2
600
- *
601
- * @param bool $daily Daily flag.
602
- */
603
- function tptn_clean_duplicates( $daily = false ) {
604
- global $wpdb;
605
-
606
- $table_name = $wpdb->base_prefix . 'top_ten';
607
- if ( $daily ) {
608
- $table_name .= '_daily';
609
- }
610
-
611
- $wpdb->query( 'CREATE TEMPORARY TABLE ' . $table_name . '_temp AS SELECT * FROM ' . $table_name . ' GROUP BY postnumber' );
612
- $wpdb->query( "TRUNCATE TABLE $table_name" );
613
- $wpdb->query( 'INSERT INTO ' . $table_name . ' SELECT * FROM ' . $table_name . '_temp' );
614
- }
615
-
616
-
617
- /**
618
- * Function to merge counts with post numbers of blog ID 0 and 1 respectively.
619
- *
620
- * @since 2.0.4
621
- *
622
- * @param bool $daily Daily flag
623
- */
624
- function tptn_merge_blogids( $daily = false ) {
625
- global $wpdb;
626
-
627
- $table_name = $wpdb->base_prefix . 'top_ten';
628
- if ( $daily ) {
629
- $table_name .= '_daily';
630
- }
631
-
632
- if ( $daily ) {
633
- $wpdb->query( "
634
- INSERT INTO `$table_name` (postnumber, cntaccess, dp_date, blog_id) (
635
- SELECT
636
- postnumber,
637
- SUM(cntaccess) as sumCount,
638
- dp_date,
639
- 1
640
- FROM `$table_name`
641
- WHERE blog_ID IN (0,1)
642
- GROUP BY postnumber, dp_date
643
- ) ON DUPLICATE KEY UPDATE cntaccess = VALUES(cntaccess);
644
- " );
645
- } else {
646
- $wpdb->query( "
647
- INSERT INTO `$table_name` (postnumber, cntaccess, blog_id) (
648
- SELECT
649
- postnumber,
650
- SUM(cntaccess) as sumCount,
651
- 1
652
- FROM `$table_name`
653
- WHERE blog_ID IN (0,1)
654
- GROUP BY postnumber
655
- ) ON DUPLICATE KEY UPDATE cntaccess = VALUES(cntaccess);
656
- " );
657
- }
658
-
659
- $wpdb->query( "DELETE FROM $table_name WHERE blog_id = 0" );
660
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/deprecated.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * Deprecated functions from Top 10 - Admin. You shouldn't
4
- * use these functions and look for the alternatives instead. The functions will be
5
- * removed in a later version.
6
- *
7
- * @package Top_Ten
8
- */
9
-
10
- /**
11
- * Function to generate the top 10 daily popular posts page.
12
- *
13
- * @since 1.9.2
14
- * @deprecated 2.2.0
15
- */
16
- function tptn_manage_daily() {
17
- tptn_manage( 1 );
18
- }
19
-
20
-
21
- /**
22
- * Function to generate the top 10 popular posts page.
23
- *
24
- * @since 1.3
25
- * @deprecated 2.2.0
26
- *
27
- * @param int $daily Overall popular.
28
- */
29
- function tptn_manage( $daily = 0 ) {
30
-
31
- $paged = isset( $_GET['paged'] ) ? intval( $_GET['paged'] ) : 0;
32
- $limit = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 0;
33
- $daily = isset( $_GET['daily'] ) ? intval( $_GET['daily'] ) : $daily;
34
-
35
- ?>
36
-
37
- <div class="wrap">
38
- <h2>
39
- <?php if ( ! $daily ) {
40
- esc_html_e( 'Popular Posts', 'top-10' );
41
- } else {
42
- esc_html_e( 'Daily Popular Posts', 'top-10' );
43
- } ?>
44
- </h2>
45
- <div id="poststuff">
46
- <div id="post-body" class="metabox-holder columns-2">
47
- <div id="post-body-content">
48
- <?php echo tptn_pop_display( $daily, $paged, $limit, false ); ?>
49
- </div>
50
- <!-- /post-body-content -->
51
- <div id="postbox-container-1" class="postbox-container">
52
- <div id="side-sortables" class="meta-box-sortables ui-sortable">
53
- <?php tptn_admin_side(); ?>
54
- </div>
55
- <!-- /side-sortables -->
56
- </div>
57
- <!-- /postbox-container-1 -->
58
- </div>
59
- <!-- /post-body -->
60
- <br class="clear" />
61
- </div>
62
- <!-- /poststuff -->
63
- </div>
64
- <!-- /wrap -->
65
-
66
- <?php
67
- }
68
-
69
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/main-view.php DELETED
@@ -1,979 +0,0 @@
1
- <?php
2
- /**
3
- * Top 10 Admin interface - Main screen.
4
- *
5
- * This page is accessible via Top 10 Settings menu item
6
- *
7
- * @package Top_Ten
8
- * @author Ajay D'Souza <me@ajaydsouza.com>
9
- * @license GPL-2.0+
10
- * @link https://webberzone.com
11
- * @copyright 2008-2016 Ajay D'Souza
12
- */
13
-
14
- // If this file is called directly, abort.
15
- if ( ! defined( 'WPINC' ) ) {
16
- die;
17
- }
18
-
19
- ?>
20
-
21
- <div class="wrap">
22
- <h2><?php esc_html_e( 'Top 10 Settings', 'top-10' ); ?></h2>
23
-
24
- <ul class="subsubsub">
25
- <?php
26
- /**
27
- * Fires before the navigation bar in the Settings page
28
- *
29
- * @since 2.0.0
30
- */
31
- do_action( 'tptn_admin_nav_bar_before' )
32
- ?>
33
-
34
- <li><a href="#genopdiv"><?php esc_html_e( 'General options', 'top-10' ); ?></a> | </li>
35
- <li><a href="#counteropdiv"><?php esc_html_e( 'Counter and tracker options', 'top-10' ); ?></a> | </li>
36
- <li><a href="#pplopdiv"><?php esc_html_e( 'Popular post list options', 'top-10' ); ?></a> | </li>
37
- <li><a href="#thumbopdiv"><?php esc_html_e( 'Thumbnail options', 'top-10' ); ?></a> | </li>
38
- <li><a href="#customcssdiv"><?php esc_html_e( 'Styles', 'top-10' ); ?></a> | </li>
39
- <li><a href="#tptn_maintenance_op"><?php esc_html_e( 'Maintenance', 'top-10' ); ?></a></li>
40
-
41
- <?php
42
- /**
43
- * Fires after the navigation bar in the Settings page
44
- *
45
- * @since 2.0.0
46
- */
47
- do_action( 'tptn_admin_nav_bar_after' )
48
- ?>
49
- </ul>
50
-
51
- <div id="poststuff">
52
- <div id="post-body" class="metabox-holder columns-2">
53
- <div id="post-body-content">
54
- <form method="post" id="tptn_options" name="tptn_options" onsubmit="return checkForm()">
55
- <div id="genopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
56
- <h3 class='hndle'><span><?php esc_html_e( 'General options', 'top-10' ); ?></span></h3>
57
- <div class="inside">
58
- <table class="form-table">
59
-
60
- <?php
61
- /**
62
- * Fires before General options block.
63
- *
64
- * @since 2.0.0
65
- *
66
- * @param array $tptn_settings Top 10 settings array
67
- */
68
- do_action( 'tptn_admin_general_options_before', $tptn_settings );
69
- ?>
70
-
71
- <tr>
72
- <th scope="row"><?php esc_html_e( 'Enable trackers:', 'top-10' ); ?></th>
73
- <td>
74
- <p>
75
- <label>
76
- <input type="checkbox" name="activate_overall" id="activate_overall" <?php checked( true, $tptn_settings['activate_overall'] ); ?> />
77
- <?php esc_html_e( 'Overall', 'top-10' ); ?>
78
- </label>
79
- </p>
80
- <p>
81
- <label>
82
- <input type="checkbox" name="activate_daily" id="activate_daily" <?php checked( true, $tptn_settings['activate_daily'] ); ?> />
83
- <?php esc_html_e( 'Daily', 'top-10' ); ?>
84
- </label>
85
- </p>
86
- </td>
87
- </tr>
88
- <tr>
89
- <th scope="row"><label for="cache"><?php esc_html_e( 'Enable cache:', 'top-10' ); ?></label></th>
90
- <td>
91
- <p><input type="checkbox" name="cache" id="cache" <?php checked( true, $tptn_settings['cache'] ); ?> /></p>
92
- <p class="description"><?php esc_html_e( 'If activated, Top 10 will use the Transients API to cache the popular posts output for 1 hour.', 'top-10' ); ?></p>
93
- <p><input type="button" name="cache_clear" id="cache_clear" value="<?php esc_attr_e( 'Clear cache', 'top-10' ); ?>" class="button-secondary" onclick="return clearCache();" /></p>
94
- </td>
95
- </tr>
96
- <tr>
97
- <th scope="row"><label for="daily_midnight"><?php esc_html_e( 'Start daily counts from midnight:', 'top-10' ); ?></label></th>
98
- <td>
99
- <input type="checkbox" name="daily_midnight" id="daily_midnight" <?php checked( true, $tptn_settings['daily_midnight'] ); ?> />
100
- <p class="description"><?php esc_html_e( 'Daily counter will display number of visits from midnight. This option is checked by default and mimics the way most normal counters work. Turning this off will allow you to use the hourly setting in the next option.', 'top-10' ); ?></p>
101
- </td>
102
- </tr>
103
- <tr>
104
- <th scope="row"><label for="daily_range"><?php esc_html_e( 'Daily popular contains top posts over:', 'top-10' ); ?></label></th>
105
- <td>
106
- <input type="textbox" name="daily_range" id="daily_range" size="3" value="<?php echo esc_attr( $tptn_settings['daily_range'] ); ?>"> <?php esc_html_e( 'day(s)', 'top-10' ); ?>
107
- <input type="textbox" name="hour_range" id="hour_range" size="3" value="<?php echo esc_attr( $tptn_settings['hour_range'] ); ?>"> <?php esc_html_e( 'hour(s)', 'top-10' ); ?>
108
- <p class="description"><?php esc_html_e( 'Think of Daily Popular has a custom date range applied as a global setting. Instead of displaying popular posts from the past day, this setting lets you display posts for as many days or as few hours as you want. This can be overridden in the widget.', 'top-10' ); ?></p>
109
- </td>
110
- </tr>
111
- <tr>
112
- <th scope="row"><label for="uninstall_clean_options"><?php esc_html_e( 'Delete options on uninstall', 'top-10' ); ?></label></th>
113
- <td>
114
- <input type="checkbox" name="uninstall_clean_options" id="uninstall_clean_options" <?php checked( true, $tptn_settings['uninstall_clean_options'] ); ?> />
115
- <p class="description"><?php esc_html_e( 'If this is checked, all settings related to Top 10 are removed from the database if you choose to uninstall/delete the plugin.', 'top-10' ); ?></p>
116
- </td>
117
- </tr>
118
- <tr>
119
- <th scope="row"><label for="uninstall_clean_tables"><?php esc_html_e( 'Delete counter data on uninstall', 'top-10' ); ?></label></th>
120
- <td>
121
- <input type="checkbox" name="uninstall_clean_tables" id="uninstall_clean_tables" <?php checked( true, $tptn_settings['uninstall_clean_tables'] ); ?> />
122
- <p class="description"><?php esc_html_e( 'If this is checked, the tables containing the counter statistics are removed from the database if you choose to uninstall/delete the plugin.', 'top-10' ); ?></p>
123
- <p class="description"><?php esc_html_e( "Keep this unchecked if you choose to reinstall the plugin and don't want to lose your counter data.", 'top-10' ); ?></p>
124
- </td>
125
- </tr>
126
- <tr><th scope="row"><label for="show_metabox"><?php esc_html_e( 'Show metabox:', 'top-10' ); ?></label></th>
127
- <td>
128
- <input type="checkbox" name="show_metabox" id="show_metabox" <?php checked( true, $tptn_settings['show_metabox'] ); ?> />
129
- <p class="description"><?php esc_html_e( 'This will add the Top 10 metabox on Edit Posts or Add New Posts screens. Also applies to Pages and Custom Post Types.', 'top-10' ); ?></p>
130
- </td>
131
- </tr>
132
-
133
- <tr><th scope="row"><label for="show_metabox_admins"><?php esc_html_e( 'Limit metabox to Admins only:', 'top-10' ); ?></label></th>
134
- <td>
135
- <input type="checkbox" name="show_metabox_admins" id="show_metabox_admins" <?php checked( true, $tptn_settings['show_metabox_admins'] ); ?> />
136
- <p class="description"><?php esc_html_e( 'If this is selected, the metabox will be hidden from anyone who is not an Admin. Otherwise, by default, Contributors and above will be able to see the metabox. This applies only if the above option is selected.', 'top-10' ); ?></p>
137
- </td>
138
- </tr>
139
-
140
- <tr>
141
- <th scope="row"><label for="show_credit"><?php esc_html_e( 'Link to Top 10 plugin page', 'top-10' ); ?></label></th>
142
- <td>
143
- <input type="checkbox" name="show_credit" id="show_credit" <?php checked( true, $tptn_settings['show_credit'] ); ?> />
144
- <p class="description"><?php esc_html_e( 'A link to the plugin is added as an extra list item to the list of popular posts', 'top-10' ); ?></p>
145
- </td>
146
- </tr>
147
- <tr>
148
- <td scope="row" colspan="2">
149
- <input type="submit" name="tptn_save" id="tptn_genop_save" value="<?php esc_attr_e( 'Save Options', 'top-10' ); ?>" class="button button-primary" />
150
- </td>
151
- </tr>
152
-
153
- <?php
154
- /**
155
- * Fires after General options block.
156
- *
157
- * @since 2.0.0
158
- *
159
- * @param array $tptn_settings Top 10 settings array
160
- */
161
- do_action( 'tptn_admin_general_options_after', $tptn_settings );
162
- ?>
163
-
164
- </table>
165
- </div>
166
- </div>
167
- <div id="counteropdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
168
- <h3 class='hndle'><span><?php esc_html_e( 'Counter and tracker options', 'top-10' ); ?></span></h3>
169
- <div class="inside">
170
- <table class="form-table">
171
-
172
- <?php
173
- /**
174
- * Fires before Counter options block.
175
- *
176
- * @since 2.0.0
177
- *
178
- * @param array $tptn_settings Top 10 settings array
179
- */
180
- do_action( 'tptn_admin_counter_options_before', $tptn_settings );
181
- ?>
182
-
183
- <tr>
184
- <th scope="row"><?php esc_html_e( 'Display number of views on:', 'top-10' ); ?></th>
185
- <td>
186
- <label><input type="checkbox" name="add_to_content" id="add_to_content" <?php checked( true, $tptn_settings['add_to_content'] ); ?> /> <?php esc_html_e( 'Posts', 'top-10' ); ?></label><br />
187
- <label><input type="checkbox" name="count_on_pages" id="count_on_pages" <?php checked( true, $tptn_settings['count_on_pages'] ); ?> /> <?php esc_html_e( 'Pages', 'top-10' ); ?></label><br />
188
- <label><input type="checkbox" name="add_to_home" id="add_to_home" <?php checked( true, $tptn_settings['add_to_home'] ); ?> /> <?php esc_html_e( 'Home page', 'top-10' ); ?></label></label><br />
189
- <label><input type="checkbox" name="add_to_feed" id="add_to_feed" <?php checked( true, $tptn_settings['add_to_feed'] ); ?> /> <?php esc_html_e( 'Feeds', 'top-10' ); ?></label></label><br />
190
- <label><input type="checkbox" name="add_to_category_archives" id="add_to_category_archives" <?php checked( true, $tptn_settings['add_to_category_archives'] ); ?> /> <?php esc_html_e( 'Category archives', 'top-10' ); ?></label><br />
191
- <label><input type="checkbox" name="add_to_tag_archives" id="add_to_tag_archives" <?php checked( true, $tptn_settings['add_to_tag_archives'] ); ?> /> <?php esc_html_e( 'Tag archives', 'top-10' ); ?></label></label><br />
192
- <label><input type="checkbox" name="add_to_archives" id="add_to_archives" <?php checked( true, $tptn_settings['add_to_archives'] ); ?> /> <?php esc_html_e( 'Other archives', 'top-10' ); ?></label></label>
193
- <p class="description">
194
- <?php printf( esc_html__( 'If you choose to disable this, please add %s to your template file where you want it displayed', 'top-10' ), "<code>&lt;?php if ( function_exists ( 'echo_tptn_post_count' ) ) echo_tptn_post_count(); ?&gt;</code>" ); ?>
195
- </p>
196
- </td>
197
- </tr>
198
- <tr>
199
- <th scope="row"><label for="title"><?php esc_html_e( 'Format to display the post views:', 'top-10' ); ?></label></th>
200
- <td>
201
- <textarea name="count_disp_form" id="count_disp_form" cols="50" rows="3" style="width:100%"><?php echo esc_textarea( $tptn_settings['count_disp_form'] ); ?></textarea>
202
- <p class="description">
203
- <?php printf( esc_html__( 'Use %1$s to display the total count, %2$s for daily count and %3$s for overall counts across all posts. Default display is %4$s ', 'top-10' ),
204
- '<code>%totalcount%</code>',
205
- '<code>%dailycount%</code>',
206
- '<code>%overallcount%</code>',
207
- '<code>(Visited %totalcount% times, %dailycount% visits today)</code>'
208
- ); ?>
209
- </p>
210
- </td>
211
- </tr>
212
- <tr>
213
- <th scope="row"><label for="title"><?php esc_html_e( 'What do display when there are no visits?', 'top-10' ); ?></label></th>
214
- <td>
215
- <textarea name="count_disp_form_zero" id="count_disp_form_zero" cols="50" rows="3" style="width:100%"><?php echo esc_textarea( $tptn_settings['count_disp_form_zero'] ); ?></textarea>
216
- <p class="description"><?php esc_html_e( "This text applies only when there are 0 hits for the post and it isn't a single page. e.g. if you display post views on the homepage or archives then this text will be used. To override this, just enter the same text as above option.", 'top-10' ); ?>
217
- </td>
218
- </tr>
219
- <tr>
220
- <th scope="row"><label for="dynamic_post_count"><?php esc_html_e( 'Always display latest post count', 'top-10' ); ?></label></th>
221
- <td>
222
- <input type="checkbox" name="dynamic_post_count" id="dynamic_post_count" <?php checked( true, $tptn_settings['dynamic_post_count'] ); ?> />
223
- <p class="description"><?php esc_html_e( 'This option uses JavaScript and will increase your page load time. Turn this off if you are not using caching plugins or are OK with displaying older cached counts.', 'top-10' ); ?></p>
224
- </td>
225
- </tr>
226
-
227
- <tr><th scope="row"><?php esc_html_e( 'Tracker type', 'top-10' ); ?>:</th>
228
- <td>
229
- <?php
230
- $trackers = tptn_get_tracker_types();
231
-
232
- foreach ( $trackers as $tracker ) :
233
- ?>
234
-
235
- <label>
236
- <input type="radio" name="tracker_type" value="<?php echo esc_attr( $tracker['id'] ); ?>" id="<?php echo esc_attr( $tracker['id'] ); ?>" <?php checked( $tracker['id'], $tptn_settings['tracker_type'], true ) ?> />
237
- <?php echo esc_html( $tracker['name'] ) ?>
238
- </label>
239
- - <em><?php echo esc_html( $tracker['description'] ) ?></em>
240
- <br />
241
-
242
- <?php endforeach; ?>
243
- </td>
244
- </tr>
245
-
246
- <tr>
247
- <th scope="row"><label><?php esc_html_e( 'Track user groups', 'top-10' ); ?></label></th>
248
- <td>
249
- <label>
250
- <input type="checkbox" name="track_authors" id="track_authors" <?php checked( true, $tptn_settings['track_authors'], true ); ?> />
251
- <?php esc_html_e( 'Authors on their own posts', 'top-10' ); ?>
252
- </label><br />
253
- <label>
254
- <input type="checkbox" name="track_editors" id="track_editors" <?php checked( true, $tptn_settings['track_editors'], true ); ?> />
255
- <?php esc_html_e( 'Editors', 'top-10' ); ?>
256
- </label><br />
257
- <label>
258
- <input type="checkbox" name="track_admins" id="track_admins" <?php checked( true, $tptn_settings['track_admins'], true ); ?> />
259
- <?php esc_html_e( 'Admins', 'top-10' ); ?>
260
- </label>
261
- <p class="description"><?php esc_html_e( 'If the current user falls into any one of the three groups when browsing a post, then the tracker is disabled', 'top-10' ); ?></p>
262
- </td>
263
- </tr>
264
- <tr>
265
- <th scope="row"><label for="pv_in_admin"><?php esc_html_e( 'Display page views on Posts and Pages in Admin', 'top-10' ); ?></label></th>
266
- <td>
267
- <input type="checkbox" name="pv_in_admin" id="pv_in_admin" <?php checked( true, $tptn_settings['pv_in_admin'] ); ?> />
268
- <p class="description"><?php esc_html_e( "Adds three columns called Total Views, Today's Views and Views to All Posts and All Pages", 'top-10' ); ?></p>
269
- </td>
270
- </tr>
271
- <tr>
272
- <th scope="row"><label for="show_count_non_admins"><?php esc_html_e( 'Show number of views to non-admins', 'top-10' ); ?></label></th>
273
- <td>
274
- <input type="checkbox" name="show_count_non_admins" id="show_count_non_admins" <?php checked( true, $tptn_settings['show_count_non_admins'] ); ?> />
275
- <p class="description"><?php esc_html_e( "If you disable this then non-admins won't see the above columns or view the independent pages with the top posts", 'top-10' ); ?></p>
276
- </td>
277
- </tr>
278
- <tr>
279
- <td scope="row" colspan="2">
280
- <input type="submit" name="tptn_save" id="tptn_counterop_save" value="<?php esc_html_e( 'Save Options', 'top-10' ); ?>" class="button button-primary" />
281
- </td>
282
- </tr>
283
-
284
- <?php
285
- /**
286
- * Fires after Counter options block.
287
- *
288
- * @since 2.0.0
289
- *
290
- * @param array $tptn_settings Top 10 settings array
291
- */
292
- do_action( 'tptn_admin_counter_options_after', $tptn_settings );
293
- ?>
294
-
295
- </table>
296
- </div>
297
- </div>
298
- <div id="pplopdiv" class="postbox"><div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
299
- <h3 class='hndle'><span><?php esc_html_e( 'Popular post list options', 'top-10' ); ?></span></h3>
300
- <div class="inside">
301
- <table class="form-table">
302
-
303
- <?php
304
- /**
305
- * Fires before Popular post list options block.
306
- *
307
- * @since 2.0.0
308
- *
309
- * @param array $tptn_settings Top 10 settings array
310
- */
311
- do_action( 'tptn_admin_list_options_before', $tptn_settings );
312
- ?>
313
-
314
- <tr>
315
- <th scope="row"><label for="limit"><?php esc_html_e( 'Number of popular posts to display:', 'top-10' ); ?></label></th>
316
- <td>
317
- <input type="textbox" name="limit" id="limit" value="<?php echo esc_attr( stripslashes( $tptn_settings['limit'] ) ); ?>">
318
- <p class="description"><?php esc_html_e( "Maximum number of posts that will be displayed in the list. This option is used if you don't specify the number of posts in the widget or shortcodes", 'top-10' ); ?></p>
319
- </td>
320
- </tr>
321
- <tr>
322
- <th scope="row"><label for="how_old"><?php esc_html_e( 'Published age of posts:', 'top-10' ); ?></label></th>
323
- <td>
324
- <input type="textbox" name="how_old" id="how_old" value="<?php echo esc_attr( stripslashes( $tptn_settings['how_old'] ) ); ?>"> <?php esc_html_e( 'days', 'top-10' ); ?>
325
- <p class="description"><?php esc_html_e( 'This options allows you to only show posts that have been published within the above day range. Applies to both overall posts and daily posts lists.', 'top-10' ); ?></p>
326
- <p class="description"><?php esc_html_e( 'e.g. 365 days will only show posts published in the last year in the popular posts lists. Enter 0 for no restriction.', 'top-10' ); ?></p>
327
- </td>
328
- </tr>
329
- <tr>
330
- <th scope="row"><?php esc_html_e( 'Post types to include in results (including custom post types)', 'top-10' ); ?></th>
331
- <td>
332
- <?php foreach ( $wp_post_types as $wp_post_type ) { ?>
333
-
334
- <label>
335
- <input type="checkbox" name="post_types[]" value="<?php echo esc_attr( $wp_post_type ); ?>" <?php checked( true, in_array( $wp_post_type, $posts_types_inc, true ) ); ?> />
336
- <?php echo esc_html( $wp_post_type ); ?>
337
- </label>
338
- <br />
339
-
340
- <?php } ?>
341
- </td>
342
- </tr>
343
- <tr>
344
- <th scope="row"><label for="exclude_post_ids"><?php esc_html_e( 'List of post or page IDs to exclude from the results:', 'top-10' ); ?></label></th>
345
- <td><input type="textbox" name="exclude_post_ids" id="exclude_post_ids" value="<?php echo esc_attr( stripslashes( $tptn_settings['exclude_post_ids'] ) ); ?>" style="width:250px">
346
- <p class="description"><?php esc_html_e( 'Enter comma separated list of IDs. e.g. 188,320,500', 'top-10' ); ?></p>
347
- </td>
348
- </tr>
349
- <tr>
350
- <th scope="row"><label for="exclude_cat_slugs"><?php esc_html_e( 'Exclude Categories:', 'top-10' ); ?></label></th>
351
- <td>
352
- <label><input type="textbox" name="exclude_cat_slugs" id="exclude_cat_slugs" value="<?php echo esc_attr( $tptn_settings['exclude_cat_slugs'] ); ?>" onfocus="setSuggest('exclude_cat_slugs', 'category');" class="widefat"></label>
353
- <p class="description"><?php esc_html_e( 'Comma separated list of category names. The field above has an autocomplete so simply start typing in the starting letters and it will prompt you with options. Does not support tags or custom taxonomies.', 'top-10' ); ?></p>
354
- <p class="description highlight">
355
- <?php
356
- esc_html_e( 'Excluded category IDs are:', 'top-10' );
357
- echo ' ' . esc_html( $tptn_settings['exclude_categories'] );
358
- ?>
359
- </p>
360
- <p class="description">
361
- <?php
362
- printf( esc_html__( 'These might differ from the IDs visible in the Categories page which use the %1$s. Top 10 uses the %2$s which is unique to this taxonomy.', 'top-10' ), '<code>term_id</code>', '<code>term_taxonomy_id</code>' ); ?>
363
- ?>
364
- </p>
365
- </td>
366
- </tr>
367
- <tr>
368
- <th scope="row"><label for="title"><?php esc_html_e( 'Title of popular posts:', 'top-10' ); ?></label></th>
369
- <td>
370
- <input type="textbox" name="title" id="title" value="<?php echo esc_attr( $tptn_settings['title'] ); ?>" style="width:250px" />
371
- </td>
372
- </tr>
373
- <tr>
374
- <th scope="row"><label for="title_daily"><?php esc_html_e( 'Title of daily popular posts:', 'top-10' ); ?></label></th>
375
- <td>
376
- <input type="textbox" name="title_daily" id="title_daily" value="<?php echo esc_attr( $tptn_settings['title_daily'] ); ?>" style="width:250px" />
377
- </td>
378
- </tr>
379
- <tr>
380
- <th scope="row"><label for="blank_output"><?php esc_html_e( 'When there are no posts, what should be shown?', 'top-10' ); ?></label></th>
381
- <td>
382
- <label>
383
- <input type="radio" name="blank_output" value="blank" id="blank_output_0" <?php checked( true, $tptn_settings['blank_output'] ); ?> />
384
- <?php esc_html_e( 'Blank Output', 'top-10' ); ?>
385
- </label>
386
- <br />
387
- <label>
388
- <input type="radio" name="blank_output" value="customs" id="blank_output_1" <?php checked( false, $tptn_settings['blank_output'] ); ?> />
389
- <?php esc_html_e( 'Display:', 'top-10' ); ?>
390
- </label>
391
- <input type="textbox" name="blank_output_text" id="blank_output_text" value="<?php echo esc_attr( $tptn_settings['blank_output_text'] ); ?>" style="width:250px" />
392
- </td>
393
- </tr>
394
- <tr>
395
- <th scope="row"><label for="show_excerpt"><?php esc_html_e( 'Show post excerpt in list?', 'top-10' ); ?></label></th>
396
- <td>
397
- <input type="checkbox" name="show_excerpt" id="show_excerpt" <?php checked( true, $tptn_settings['show_excerpt'] ); ?> />
398
- </td>
399
- </tr>
400
- <tr>
401
- <th scope="row"><label for="excerpt_length"><?php esc_html_e( 'Length of excerpt (in words):', 'top-10' ); ?></label></th>
402
- <td>
403
- <input type="textbox" name="excerpt_length" id="excerpt_length" value="<?php echo esc_attr( $tptn_settings['excerpt_length'] ); ?>" />
404
- </td>
405
- </tr>
406
- <tr>
407
- <th scope="row"><label for="show_author"><?php esc_html_e( 'Show post author in list?', 'top-10' ); ?></label></th>
408
- <td>
409
- <input type="checkbox" name="show_author" id="show_author" <?php checked( true, $tptn_settings['show_author'] ); ?> />
410
- </td>
411
- </tr>
412
- <tr>
413
- <th scope="row"><label for="show_date"><?php esc_html_e( 'Show post date in list?', 'top-10' ); ?></label></th>
414
- <td>
415
- <input type="checkbox" name="show_date" id="show_date" <?php checked( $tptn_settings['show_date'] ); ?> />
416
- </td>
417
- </tr>
418
- <tr>
419
- <th scope="row"><label for="title_length"><?php esc_html_e( 'Limit post title length (in characters)', 'top-10' ); ?></label></th>
420
- <td>
421
- <input type="textbox" name="title_length" id="title_length" value="<?php echo esc_attr( $tptn_settings['title_length'] ); ?>" />
422
- </td>
423
- </tr>
424
- <tr>
425
- <th scope="row"><label for="disp_list_count"><?php esc_html_e( 'Show view count in list?', 'top-10' ); ?></label></th>
426
- <td>
427
- <input type="checkbox" name="disp_list_count" id="disp_list_count" <?php checked( true, $tptn_settings['disp_list_count'] ); ?> />
428
- </td>
429
- </tr>
430
- <tr>
431
- <th scope="row"><label for="link_new_window "><?php esc_html_e( 'Open links in new window', 'top-10' ); ?></label></th>
432
- <td>
433
- <input type="checkbox" name="link_new_window" id="link_new_window" <?php checked( true, $tptn_settings['link_new_window'] ); ?> />
434
- </td>
435
- </tr>
436
- <tr>
437
- <th scope="row"><label for="link_nofollow"><?php esc_html_e( 'Add nofollow attribute to links in the list', 'top-10' ); ?></label></th>
438
- <td>
439
- <input type="checkbox" name="link_nofollow" id="link_nofollow" <?php checked( true, $tptn_settings['link_nofollow'] ); ?> />
440
- </td>
441
- </tr>
442
- <tr>
443
- <th scope="row"><label for="exclude_on_post_ids"><?php esc_html_e( 'Exclude display of related posts on these posts / pages', 'top-10' ); ?></label></th>
444
- <td>
445
- <input type="textbox" name="exclude_on_post_ids" id="exclude_on_post_ids" value="<?php echo esc_attr( stripslashes( $tptn_settings['exclude_on_post_ids'] ) ); ?>" style="width:250px">
446
- <p class="description"><?php esc_html_e( 'Enter comma separated list of IDs. e.g. 188,320,500', 'top-10' ); ?></p>
447
- </td>
448
- </tr>
449
-
450
- <tr style="background: #eee"><th scope="row" colspan="2"><?php esc_html_e( 'Customise the list HTML', 'top-10' ); ?></th>
451
- </tr>
452
- <tr>
453
- <th scope="row"><label for="before_list"><?php esc_html_e( 'HTML to display before the list of posts:', 'top-10' ); ?></label></th>
454
- <td>
455
- <input type="textbox" name="before_list" id="before_list" value="<?php echo esc_attr( stripslashes( $tptn_settings['before_list'] ) ); ?>" style="width:250px" />
456
- </td>
457
- </tr>
458
- <tr>
459
- <th scope="row"><label for="before_list_item"><?php esc_html_e( 'HTML to display before each list item:', 'top-10' ); ?></label></th>
460
- <td>
461
- <input type="textbox" name="before_list_item" id="before_list_item" value="<?php echo esc_attr( stripslashes( $tptn_settings['before_list_item'] ) ); ?>" style="width:250px" />
462
- </td>
463
- </tr>
464
- <tr>
465
- <th scope="row"><label for="after_list_item"><?php esc_html_e( 'HTML to display after each list item:', 'top-10' ); ?></label></th>
466
- <td>
467
- <input type="textbox" name="after_list_item" id="after_list_item" value="<?php echo esc_attr( stripslashes( $tptn_settings['after_list_item'] ) ); ?>" style="width:250px" />
468
- </td>
469
- </tr>
470
- <tr>
471
- <th scope="row"><label for="after_list"><?php esc_html_e( 'HTML to display after the list of posts:', 'top-10' ); ?></label></th>
472
- <td>
473
- <input type="textbox" name="after_list" id="after_list" value="<?php echo esc_attr( stripslashes( $tptn_settings['after_list'] ) ); ?>" style="width:250px" />
474
- </td>
475
- </tr>
476
- <tr>
477
- <td scope="row" colspan="2">
478
- <input type="submit" name="tptn_save" id="tptn_pplop_save" value="<?php esc_attr_e( 'Save Options', 'top-10' ); ?>" class="button button-primary" />
479
- </td>
480
- </tr>
481
-
482
- <?php
483
- /**
484
- * Fires after Popular post list options block.
485
- *
486
- * @since 2.0.0
487
- *
488
- * @param array $tptn_settings Top 10 settings array
489
- */
490
- do_action( 'tptn_admin_list_options_after', $tptn_settings );
491
- ?>
492
-
493
- </table>
494
- </div>
495
- </div>
496
- <div id="thumbopdiv" class="postbox"><div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
497
- <h3 class='hndle'><span><?php esc_html_e( 'Thumbnail options', 'top-10' ); ?></span></h3>
498
- <div class="inside">
499
- <table class="form-table">
500
-
501
- <?php
502
- /**
503
- * Fires before thumbnail options block.
504
- *
505
- * @since 2.0.0
506
- *
507
- * @param array $tptn_settings Top 10 settings array
508
- */
509
- do_action( 'tptn_admin_thumbnail_options_before', $tptn_settings );
510
- ?>
511
-
512
- <tr><th scope="row"><label for="post_thumb_op"><?php esc_html_e( 'Location of post thumbnail:', 'top-10' ); ?></label></th>
513
- <td>
514
- <label>
515
- <input type="radio" name="post_thumb_op" value="inline" id="post_thumb_op_0" <?php checked( 'inline', $tptn_settings['post_thumb_op'], true ); ?> />
516
- <?php esc_html_e( 'Display thumbnails inline with posts, before title', 'top-10' ); ?>
517
- </label>
518
- <br />
519
- <label>
520
- <input type="radio" name="post_thumb_op" value="after" id="post_thumb_op_1" <?php checked( 'after', $tptn_settings['post_thumb_op'], true ); ?> />
521
- <?php esc_html_e( 'Display thumbnails inline with posts, after title', 'top-10' ); ?>
522
- </label>
523
- <br />
524
- <label>
525
- <input type="radio" name="post_thumb_op" value="thumbs_only" id="post_thumb_op_2" <?php checked( 'thumbs_only', $tptn_settings['post_thumb_op'], true ); ?> />
526
- <?php esc_html_e( 'Display only thumbnails, no text', 'top-10' ); ?>
527
- </label>
528
- <br />
529
- <label>
530
- <input type="radio" name="post_thumb_op" value="text_only" id="post_thumb_op_3" <?php checked( 'text_only', $tptn_settings['post_thumb_op'], true ); ?> />
531
- <?php esc_html_e( 'Do not display thumbnails, only text.', 'top-10' ); ?>
532
- </label>
533
-
534
- <?php if ( 'left_thumbs' === $tptn_settings['tptn_styles'] ) { ?>
535
- <p style="color: #F00"><?php esc_html_e( 'This setting cannot be changed because an inbuilt style has been selected under the Styles section. If you would like to change this option, please select No styles under the Styles section.', 'top-10' ); ?></p>
536
- <?php } ?>
537
- </td>
538
- </tr>
539
- <tr><th scope="row"><?php esc_html_e( 'Thumbnail size:', 'top-10' ); ?></th>
540
- <td>
541
- <?php
542
- $tptn_get_all_image_sizes = tptn_get_all_image_sizes();
543
-
544
- if ( isset( $tptn_get_all_image_sizes['tptn_thumbnail'] ) ) {
545
- unset( $tptn_get_all_image_sizes['tptn_thumbnail'] );
546
- }
547
-
548
- foreach ( $tptn_get_all_image_sizes as $size ) :
549
- ?>
550
- <label>
551
- <input type="radio" name="thumb_size" value="<?php echo esc_attr( $size['name'] ); ?>" id="<?php echo esc_attr( $size['name'] ); ?>" <?php checked( $tptn_settings['thumb_size'], $size['name'], true ); ?> />
552
- <?php echo esc_attr( $size['name'] ); ?> ( <?php echo esc_attr( $size['width'] ); ?>x<?php echo esc_attr( $size['height'] ); ?>
553
- <?php
554
- if ( $size['crop'] ) {
555
- echo 'cropped';
556
- }
557
- ?>
558
- )
559
- </label>
560
- <br />
561
- <?php endforeach; ?>
562
-
563
- <label>
564
- <input type="radio" name="thumb_size" value="tptn_thumbnail" id="tptn_thumbnail" <?php checked( $tptn_settings['thumb_size'], 'tptn_thumbnail', true ); ?> /> <?php esc_html_e( 'Custom size', 'top-10' ); ?>
565
- </label>
566
- <p class="description">
567
- <?php esc_html_e( 'You can choose from existing image sizes above or create a custom size. If you have chosen Custom size above, then enter the width, height and crop settings below. For best results, use a cropped image.', 'top-10' ); ?><br />
568
- <?php esc_html_e( 'If you change the width and/or height below, existing images will not be automatically resized.', 'top-10' ); ?>
569
- <?php printf(
570
- esc_html__( 'I recommend using %1$s or %2$s to regenerate all image sizes.', 'top-10' ),
571
- '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=otf-regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">OTF Regenerate Thumbnails</a>',
572
- '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">Regenerate Thumbnails</a>'
573
- ); ?>
574
- </p>
575
- <p class="description">
576
- <?php esc_html_e( "If you're using the Left Thumbs style below then the thumbnail width and height that you set here will supersede the widget. Alternatively, choose <strong>Style attributes</strong> under <strong>Image size attributes</strong> option below", 'top-10' ); ?>
577
- </p>
578
- </td>
579
- </tr>
580
- <tr><th scope="row"><label for="thumb_width"><?php esc_html_e( 'Width of custom thumbnail', 'top-10' ); ?>:</label></th>
581
- <td>
582
- <input type="textbox" name="thumb_width" id="thumb_width" value="<?php echo esc_attr( stripslashes( $tptn_settings['thumb_width'] ) ); ?>" style="width:50px" />px
583
- </td>
584
- </tr>
585
- <tr><th scope="row"><label for="thumb_height"><?php esc_html_e( 'Height of custom thumbnail', 'top-10' ); ?>:</label></th>
586
- <td>
587
- <input type="textbox" name="thumb_height" id="thumb_height" value="<?php echo esc_attr( stripslashes( $tptn_settings['thumb_height'] ) ); ?>" style="width:50px" />px
588
- </td>
589
- </tr>
590
- <tr><th scope="row"><label for="thumb_crop"><?php esc_html_e( 'Hard crop thumbnails', 'top-10' ); ?>:</label></th>
591
- <td>
592
- <input type="checkbox" name="thumb_crop" id="thumb_crop" <?php checked( true, $tptn_settings['thumb_crop'] ); ?> />
593
- <p class="description">
594
- <?php esc_html_e( 'By default, thumbnails will be proportionately cropped. Check this box to hard crop the thumbnails.', 'top-10' ); ?>
595
- <?php printf( esc_html__( "<a href='%s' target='_blank'>Difference between soft and hard crop</a>", 'top-10' ), esc_url( 'http://www.davidtan.org/wordpress-hard-crop-vs-soft-crop-difference-comparison-example/' ) ); ?>
596
- </p>
597
- </td>
598
- </tr>
599
- <tr><th scope="row"><label for="thumb_html"><?php esc_html_e( 'Image size attributes:', 'top-10' ); ?></label></th>
600
- <td>
601
- <label>
602
- <input type="radio" name="thumb_html" value="css" id="thumb_html_0" <?php checked( 'css', $tptn_settings['thumb_html'], true ); ?> />
603
- <?php esc_html_e( 'Style attributes. e.g.', 'top-10' );
604
- echo ' <code>style="max-width:' . esc_attr( $tptn_settings['thumb_width'] ) . 'px;max-height:' . esc_attr( $tptn_settings['thumb_height'] ) . 'px;"</code>'; ?>
605
- </label>
606
- <br />
607
- <label>
608
- <input type="radio" name="thumb_html" value="html" id="thumb_html_1" <?php checked( 'html', $tptn_settings['thumb_html'], true ); ?> />
609
- <?php esc_html_e( 'HTML width and height attributes. e.g.', 'top-10' );
610
- echo ' <code>width="' . esc_attr( $tptn_settings['thumb_width'] ) . '" height="' . esc_attr( $tptn_settings['thumb_height'] ) . '"</code>' ?>
611
- </label>
612
- <br />
613
- <label>
614
- <input type="radio" name="thumb_html" value="none" id="thumb_html_1" <?php checked( 'none', $tptn_settings['thumb_html'], true ); ?> />
615
- <?php esc_html_e( 'No HTML or Style attributes', 'top-10' ); ?>
616
- </label>
617
- <br />
618
- </td>
619
- </tr>
620
- <tr><th scope="row"><label for="thumb_meta"><?php esc_html_e( 'Post thumbnail meta field name:', 'top-10' ); ?></label></th>
621
- <td>
622
- <input type="textbox" name="thumb_meta" id="thumb_meta" value="<?php echo esc_attr( stripslashes( $tptn_settings['thumb_meta'] ) ); ?>">
623
- <p class="description"><?php esc_html_e( 'The value of this field should contain the image source and is set in the <em>Add New Post</em> screen', 'top-10' ); ?></p>
624
- </td>
625
- </tr>
626
- <tr><th scope="row"><label for="scan_images"><?php esc_html_e( 'If the postmeta is not set, then should the plugin extract the first image from the post?', 'top-10' ); ?></label></th>
627
- <td>
628
- <input type="checkbox" name="scan_images" id="scan_images" <?php checked( true, $tptn_settings['scan_images'] ); ?> />
629
- <p class="description"><?php esc_html_e( 'This could slow down the loading of your page if the first image in the related posts is large in file-size', 'top-10' ); ?></p>
630
- </td>
631
- </tr>
632
- <tr><th scope="row"><label for="thumb_default_show"><?php esc_html_e( 'Use default thumbnail?', 'top-10' ); ?></label></th>
633
- <td>
634
- <input type="checkbox" name="thumb_default_show" id="thumb_default_show" <?php checked( true, $tptn_settings['thumb_default_show'] ); ?> />
635
- <p class="description"><?php esc_html_e( 'If checked, when no thumbnail is found, show a default one from the URL below. If not checked and no thumbnail is found, no image will be shown.', 'top-10' ); ?></p>
636
- </td>
637
- </tr>
638
- <tr><th scope="row"><label for="thumb_default"><?php esc_html_e( 'Default thumbnail:', 'top-10' ); ?></label></th>
639
- <td>
640
- <input type="textbox" name="thumb_default" id="thumb_default" value="<?php echo esc_attr( stripslashes( $tptn_settings['thumb_default'] ) ); ?>" style="width:100%"> <br />
641
- <?php if ( '' !== $tptn_settings['thumb_default'] ) { printf( "<img src='%s' style='max-width:200px' />", esc_url( $tptn_settings['thumb_default'] ) ); } ?>
642
- <p class="description"><?php esc_html_e( "The plugin will first check if the post contains a thumbnail. If it doesn't then it will check the meta field. If this is not available, then it will show the default image as specified above", 'top-10' ); ?></p>
643
- </td>
644
- </tr>
645
- <tr>
646
- <td scope="row" colspan="2">
647
- <input type="submit" name="tptn_save" id="tptn_thumbop_save" value="<?php esc_attr_e( 'Save Options', 'top-10' ); ?>" class="button button-primary" />
648
- </td>
649
- </tr>
650
-
651
- <?php
652
- /**
653
- * Fires after thumbnail options block.
654
- *
655
- * @since 2.0.0
656
- *
657
- * @param array $tptn_settings Top 10 settings array
658
- */
659
- do_action( 'tptn_admin_thumbnail_options_after', $tptn_settings );
660
- ?>
661
-
662
- </table>
663
- </div>
664
- </div>
665
- <div id="customcssdiv" class="postbox"><div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
666
- <h3 class='hndle'><span><?php esc_html_e( 'Styles', 'top-10' ); ?></span></h3>
667
- <div class="inside">
668
- <table class="form-table">
669
-
670
- <?php
671
- /**
672
- * Fires before custom styles options block.
673
- *
674
- * @since 2.0.0
675
- *
676
- * @param array $tptn_settings Top 10 settings array
677
- */
678
- do_action( 'tptn_admin_custom_styles_before', $tptn_settings );
679
- ?>
680
-
681
- <tr><th scope="row"><?php esc_html_e( 'Style of the popular posts:', 'top-10' ); ?></th>
682
- <td>
683
- <label>
684
- <input type="radio" name="tptn_styles" value="no_style" id="tptn_styles_1" <?php checked( 'no_style', $tptn_settings['tptn_styles'], true ); ?> /> <?php esc_html_e( 'No styles', 'top-10' ); ?>
685
- </label>
686
- <p class="description"><?php esc_html_e( 'Select this option if you plan to add your own styles', 'top-10' ); ?></p>
687
- <br />
688
-
689
- <label>
690
- <input type="radio" name="tptn_styles" value="left_thumbs" id="tptn_styles_0" <?php if ( $tptn_settings['include_default_style'] && ( 'left_thumbs' === $tptn_settings['tptn_styles'] ) ) { echo 'checked="checked"'; } ?> />
691
- <?php esc_html_e( 'Left Thumbnails', 'top-10' ); ?>
692
- </label>
693
- <p class="description"><img src="<?php echo esc_url( plugins_url( 'admin/images/tptn-left-thumbs.png', TOP_TEN_PLUGIN_FILE ) ); ?>" /></p>
694
- <p class="description"><?php esc_html_e( 'Enabling this option will set the post thumbnail to be before text. Disabling this option will not revert any settings.', 'top-10' ); ?></p>
695
- <p class="description"><?php printf( esc_html__( 'You can view the default style at %s', 'top-10' ), '<a href="https://github.com/WebberZone/top-10/blob/master/css/default-style.css" target="_blank">https://github.com/WebberZone/top-10/blob/master/css/default-style.css</a>' ); ?></p>
696
- <br />
697
-
698
- <label>
699
- <input type="radio" name="tptn_styles" value="text_only" id="tptn_styles_1" <?php checked( 'text_only', $tptn_settings['tptn_styles'], true ); ?> /> <?php esc_html_e( 'Text only', 'top-10' ); ?>
700
- </label>
701
- <p class="description"><?php esc_html_e( 'Enabling this option will disable thumbnails and no longer include the default style sheet included in the plugin.', 'top-10' ); ?></p>
702
-
703
- <?php
704
- /**
705
- * Fires after style checkboxes which allows an addon to add more styles.
706
- *
707
- * @since 2.2.0
708
- *
709
- * @param array $tptn_settings Top 10 settings array
710
- */
711
- do_action( 'tptn_admin_tptn_styles', $tptn_settings );
712
- ?>
713
-
714
- </td>
715
- </tr>
716
-
717
- <tr><th scope="row" colspan="2"><?php esc_html_e( 'Custom CSS to add to header:', 'top-10' ); ?></th>
718
- </tr>
719
- <tr>
720
- <td scope="row" colspan="2">
721
- <textarea name="custom_CSS" id="custom_CSS" rows="15" cols="80" style="width:100%"><?php echo esc_textarea( $tptn_settings['custom_CSS'] ); ?></textarea>
722
- <p class="description"><?php printf( esc_html__( 'Do not include %1$s tags. Check out the %2$s for available CSS classes to style.', 'top-10' ), '<code>style</code>', '<a href="http://wordpress.org/extend/plugins/top-10/faq/" target="_blank">FAQ</a>' ); ?></p>
723
- </td>
724
- </tr>
725
-
726
- <?php
727
- /**
728
- * Fires after custom styles options block.
729
- *
730
- * @since 2.0.0
731
- *
732
- * @param array $tptn_settings Top 10 settings array
733
- */
734
- do_action( 'tptn_admin_custom_styles_after', $tptn_settings );
735
- ?>
736
-
737
- </table>
738
- </div>
739
- </div>
740
- <p>
741
- <input type="submit" name="tptn_save" id="tptn_save" value="<?php esc_attr_e( 'Save Options', 'top-10' ); ?>" class="button button-primary" />
742
- <input type="submit" name="tptn_default" id="tptn_default" value="<?php esc_attr_e( 'Default Options', 'top-10' ); ?>" class="button button-secondary" onclick="if (!confirm('<?php esc_attr_e( 'Do you want to set options to Default?', 'top-10' ); ?>')) return false;" />
743
- </p>
744
- <?php wp_nonce_field( 'tptn-plugin-settings' ); ?>
745
- </form>
746
-
747
- <?php
748
- /**
749
- * Fires after all option blocks.
750
- *
751
- * @since 2.0.0
752
- *
753
- * @param array $tptn_settings Top 10 settings array
754
- */
755
- do_action( 'tptn_admin_options_after', $tptn_settings );
756
- ?>
757
-
758
- <hr class="clear" />
759
-
760
- <form method="post" id="tptn_maintenance_op" name="tptn_reset_options" onsubmit="return checkForm()">
761
- <div id="resetopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
762
- <h3 class='hndle'><span><?php esc_html_e( 'Maintenance', 'top-10' ); ?></span></h3>
763
- <div class="inside">
764
- <table class="form-table">
765
- <tr><td scope="row" colspan="2">
766
- <p class="description"><?php esc_html_e( 'Over time the Daily Top 10 database grows in size, which reduces the performance of the plugin. Cleaning the database at regular intervals could improve performance, especially on high traffic blogs. Enabling maintenance will automatically delete entries older than 90 days.', 'top-10' ); ?><br />
767
- <strong><?php esc_html_e( 'Note: When scheduled maintenance is enabled, WordPress will run the cron job everytime the job is rescheduled (i.e. you change the settings below).', 'top-10' ); ?></strong>
768
- </td>
769
- </tr>
770
- <tr><th scope="row"><label for="cron_on"><?php esc_html_e( 'Enable scheduled maintenance of daily tables:', 'top-10' ); ?></label></th>
771
- <td><input type="checkbox" name="cron_on" id="cron_on" <?php checked( true, $tptn_settings['cron_on'] ); ?> />
772
- </td>
773
- </tr>
774
- <tr><th scope="row"><label for="cron_hour"><?php esc_html_e( 'Time to run maintenance', 'top-10' ); ?></label></th>
775
- <td><input type="textbox" name="cron_hour" id="cron_hour" value="<?php echo esc_attr( stripslashes( $tptn_settings['cron_hour'] ) ); ?>" style="width:50px" /> <?php esc_html_e( 'hrs', 'top-10' ); ?> : <input type="textbox" name="cron_min" id="cron_min" value="<?php echo esc_attr( stripslashes( $tptn_settings['cron_min'] ) ); ?>" style="width:50px" /> <?php esc_html_e( 'min', 'top-10' ); ?></td>
776
- </tr>
777
- <tr><th scope="row"><label for="cron_recurrence"><?php esc_html_e( 'How often should the maintenance be run:', 'top-10' ); ?></label></th>
778
- <td>
779
- <label>
780
- <input type="radio" name="cron_recurrence" value="daily" id="cron_recurrence0" <?php checked( 'daily', $tptn_settings['cron_recurrence'], true ); ?> />
781
- <?php esc_html_e( 'Daily', 'top-10' ); ?></label>
782
- <br />
783
- <label>
784
- <input type="radio" name="cron_recurrence" value="weekly" id="cron_recurrence1" <?php checked( 'weekly', $tptn_settings['cron_recurrence'], true ); ?> />
785
- <?php esc_html_e( 'Weekly', 'top-10' ); ?></label>
786
- <br />
787
- <label>
788
- <input type="radio" name="cron_recurrence" value="fortnightly" id="cron_recurrence2" <?php checked( 'fortnightly', $tptn_settings['cron_recurrence'], true ); ?> />
789
- <?php esc_html_e( 'Fortnightly', 'top-10' ); ?></label>
790
- <br />
791
- <label>
792
- <input type="radio" name="cron_recurrence" value="monthly" id="cron_recurrence3" <?php checked( 'monthly', $tptn_settings['cron_recurrence'], true ); ?> />
793
- <?php esc_html_e( 'Monthly', 'top-10' ); ?></label>
794
- <br />
795
- </td>
796
- </tr>
797
- <tr><td scope="row" colspan="2">
798
- <?php
799
- if ( ( $tptn_settings['cron_on'] ) || wp_next_scheduled( 'tptn_cron_hook' ) ) {
800
- if ( wp_next_scheduled( 'tptn_cron_hook' ) ) {
801
- echo '<span style="color:#0c0">';
802
- printf( esc_html__( 'The cron job has been scheduled. Maintenance will run %s.', 'top-10' ), esc_html__( wp_get_schedule( 'tptn_cron_hook' ) ) );
803
- echo '</span>';
804
- } else {
805
- echo '<span style="color:#e00">';
806
- esc_html_e( 'The cron job is missing. Please resave this page to add the job', 'top-10' );
807
- echo '</span>';
808
- }
809
- } else {
810
- echo '<span style="color:#FFA500">';
811
- esc_html_e( 'Maintenance is turned off', 'top-10' );
812
- echo '</span>';
813
- }
814
- ?>
815
- </td></tr>
816
- </table>
817
- <input type="submit" name="tptn_mnts_save" id="tptn_mnts_save" value="<?php esc_html_e( 'Save Maintenance Options', 'top-10' ); ?>" class="button button-primary" />
818
- </div>
819
- </div>
820
- <?php wp_nonce_field( 'tptn-plugin-settings' ); ?>
821
- </form>
822
-
823
- <form method="post" id="tptn_reset_options" name="tptn_reset_options" onsubmit="return checkForm()">
824
- <div id="resetopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
825
- <h3 class='hndle'><span><?php esc_html_e( 'Reset count and other tools', 'top-10' ); ?></span></h3>
826
- <div class="inside">
827
- <p class="description">
828
- <?php esc_html_e( 'This cannot be reversed. Make sure that your database has been backed up before proceeding', 'top-10' ); ?>
829
- </p>
830
- <p>
831
- <input name="tptn_trunc_all" type="submit" id="tptn_trunc_all" value="<?php esc_attr_e( 'Reset Popular Posts', 'top-10' ); ?>" class="button button-secondary" style="color:#f00" onclick="if (!confirm('<?php esc_attr_e( 'Are you sure you want to reset the popular posts?', 'top-10' ); ?>')) return false;" />
832
- <input name="tptn_trunc_daily" type="submit" id="tptn_trunc_daily" value="<?php esc_attr_e( 'Reset Daily Popular Posts', 'top-10' ); ?>" class="button button-secondary" style="color:#f00" onclick="if (!confirm('<?php esc_attr_e( 'Are you sure you want to reset the daily popular posts?', 'top-10' ); ?>')) return false;" />
833
- </p>
834
- <p class="description">
835
- <?php esc_html_e( 'This will merge post counts for posts with table entries of 0 and 1', 'top-10' ); ?>
836
- </p>
837
- <p>
838
- <input name="tptn_merge_blogids" type="submit" id="tptn_merge_blogids" value="<?php esc_attr_e( 'Merge blog ID 0 and 1 post counts', 'top-10' ); ?>" class="button button-secondary" onclick="if (!confirm('<?php esc_attr_e( 'This will merge post counts for blog IDs 0 and 1. Proceed?', 'top-10' ); ?>')) return false;" />
839
- </p>
840
- <p class="description">
841
- <?php esc_html_e( 'In older versions, the plugin created entries with duplicate post IDs. Clicking the button below will merge these duplicate IDs', 'top-10' ); ?>
842
- </p>
843
- <p>
844
- <input name="tptn_clean_duplicates" type="submit" id="tptn_clean_duplicates" value="<?php esc_attr_e( 'Merge duplicates across blog IDs', 'top-10' ); ?>" class="button button-secondary" onclick="if (!confirm('<?php esc_attr_e( 'This will delete the duplicate entries in the tables. Proceed?', 'top-10' ); ?>')) return false;" />
845
- </p>
846
- </div>
847
- </div>
848
- <?php wp_nonce_field( 'tptn-plugin-settings' ); ?>
849
- </form>
850
-
851
- <?php
852
- /**
853
- * Only show the below options if it is multisite
854
- */
855
- if ( is_multisite() ) {
856
- ?>
857
-
858
- <form method="post" id="tptn_import_mu" name="tptn_import_mu" onsubmit="return checkForm()">
859
- <div id="resetopdiv" class="postbox"><div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'top-10' ); ?>"><br /></div>
860
- <h3 class='hndle'><span><?php esc_html_e( 'WordPress Multisite: Migrate Top 10 v1.x counts to 2.x', 'top-10' ); ?></span></h3>
861
- <div class="inside">
862
- <p class="description">
863
- <?php esc_html_e( "If you've been using Top 10 v1.x on multisite, you would have needed to activate the plugin independently for each site. This would have resulted in two tables being created for each site in the network.", 'top-10' ); ?>
864
- <?php esc_html_e( 'Top 10 v2.x onwards uses only a single table to record the count, keeping your database clean. You can use this tool to import the recorded counts from v1.x tables to the new v2.x table format.', 'top-10' ); ?>
865
- </p>
866
- <p class="description">
867
- <?php esc_html_e( 'If you do not see any tables below, then it means that either all data has already been imported or no relevant information has been found.', 'top-10' ); ?>
868
- </p>
869
- <p class="description">
870
- <strong style="color:#C00"><?php esc_html_e( 'After running the importer, please verify that all the counts have been successfully imported. Only then should you delete any old tables!', 'top-10' ); ?></strong>
871
- </p>
872
-
873
- <?php
874
- $top_ten_mu_tables_sel_blog_ids = get_site_option( 'top_ten_mu_tables_sel_blog_ids', array() );
875
- $top_ten_mu_tables_blog_ids = array();
876
- $top_ten_all_mu_tables = array();
877
-
878
- // Get all blogs in the network and activate plugin on each one.
879
- $blog_ids = $wpdb->get_col( "
880
- SELECT blog_id FROM $wpdb->blogs
881
- WHERE archived = '0' AND spam = '0' AND deleted = '0'
882
- " ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
883
- foreach ( $blog_ids as $blog_id ) {
884
- switch_to_blog( $blog_id );
885
- $top_ten_mu_table = $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "top_ten' " ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
886
-
887
- if ( ! empty( $top_ten_mu_table ) && ! is_main_site( $blog_id ) ) {
888
- $top_ten_mu_tables_blog_ids[] = $blog_id;
889
- $top_ten_all_mu_tables[ $top_ten_mu_table ][0] = $top_ten_mu_table;
890
- $top_ten_all_mu_tables[ $top_ten_mu_table ][1] = in_array( $blog_id, $top_ten_mu_tables_sel_blog_ids ) ? 1 : 0;
891
- $top_ten_all_mu_tables[ $top_ten_mu_table ][2] = $blog_id;
892
- }
893
- }
894
-
895
- // Switch back to the current blog
896
- restore_current_blog();
897
-
898
- if ( ! empty( $top_ten_all_mu_tables ) ) {
899
- ?>
900
-
901
- <table class="form-table">
902
- <tr>
903
- <th>
904
- <?php esc_html_e( 'Blog ID', 'top-10' ); ?>
905
- </th>
906
- <th>
907
- <?php esc_html_e( 'Status', 'top-10' ); ?>
908
- </th>
909
- <th>
910
- <?php esc_html_e( 'Select to import', 'top-10' ); ?>
911
- </th>
912
- </tr>
913
-
914
- <?php
915
- foreach ( $top_ten_all_mu_tables as $top_ten_all_mu_table ) {
916
- ?>
917
- <tr>
918
- <td>
919
- <?php
920
- esc_html_e( 'Blog #', 'top-10' );
921
- echo $top_ten_all_mu_table[2];
922
- echo ': ';
923
- echo get_blog_details( $top_ten_all_mu_table[2] )->blogname;
924
- ?>
925
- </td>
926
- <td>
927
- <?php
928
- if ( 0 == $top_ten_all_mu_table[1] ) {
929
- echo '<span style="color:#F00">';
930
- esc_html_e( 'Not imported', 'top-10' );
931
- echo '</span>';
932
- } else {
933
- echo '<span style="color:#0F0">';
934
- esc_html_e( 'Imported', 'top-10' );
935
- echo '</span>';
936
- }
937
- ?>
938
- </td>
939
- <td>
940
- <?php
941
- if ( 0 == $top_ten_all_mu_table[1] ) {
942
- echo '<input type="checkbox" name="top_ten_all_mu_tables[' . $top_ten_all_mu_table[0] . ']" value="' . $top_ten_all_mu_table[2] . '" checked="checked" />';
943
- } else {
944
- echo '<input type="checkbox" name="top_ten_all_mu_tables[' . $top_ten_all_mu_table[0] . ']" value="' . $top_ten_all_mu_table[2] . '" />';
945
- }
946
- ?>
947
- </td>
948
- </tr>
949
- <?php
950
- }
951
- ?>
952
- </table>
953
- <p>
954
- <input type="hidden" name="top_ten_mu_tables_blog_ids" value="<?php echo implode( ',', $top_ten_mu_tables_blog_ids ); ?>" />
955
- <input name="tptn_import" type="submit" id="tptn_import" value="<?php esc_attr_e( 'Begin import', 'top-10' ); ?>" class="button button-primary" />
956
- <input name="tptn_delete_selected_tables" type="submit" id="tptn_delete_selected_tables" value="<?php esc_attr_e( 'Delete selected tables', 'top-10' ); ?>" class="button button-secondary" style="color:#f00" />
957
- <input name="tptn_delete_imported_tables" type="submit" id="tptn_delete_imported_tables" value="<?php esc_attr_e( 'Delete all imported tables', 'top-10' ); ?>" class="button button-secondary" style="color:#f00" />
958
- </p>
959
- <?php
960
- } // End if.
961
- ?>
962
- </div>
963
- </div>
964
- <?php wp_nonce_field( 'tptn-plugin-settings' ); ?>
965
- </form>
966
- <?php
967
- }
968
- ?>
969
- </div><!-- /post-body-content -->
970
- <div id="postbox-container-1" class="postbox-container">
971
- <div id="side-sortables" class="meta-box-sortables ui-sortable">
972
- <?php tptn_admin_side(); ?>
973
- </div><!-- /side-sortables -->
974
- </div><!-- /postbox-container-1 -->
975
- </div><!-- /post-body -->
976
- <br class="clear" />
977
- </div><!-- /poststuff -->
978
- </div><!-- /wrap -->
979
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
changelog.txt CHANGED
@@ -1,5 +1,148 @@
1
  This file holds the archive of changelog entries
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 1.9.10.2 =
4
  * Fixed: Schedules were overwritten when activating the maintenance cron job
5
 
1
  This file holds the archive of changelog entries
2
 
3
+ = 2.3.2 =
4
+
5
+ * Bug fixes:
6
+ * Sanitized several unsanitized post and get requests
7
+
8
+ * Deprecated:
9
+ * External PHP file tracking option introduced in v2.3.0 in line with wordpress.org plugin repository listing requirements.
10
+
11
+ = 2.3.1 =
12
+
13
+ * Bug fixes:
14
+ * Potential CSRF issue fixed in admin area
15
+
16
+ = 2.3.0 =
17
+
18
+ * Features:
19
+ * Preliminary support for PolyLang
20
+ * Search box and post type filter added in Admin &raquo; View Popular Posts screen
21
+ * Link to Daily Popular posts screen under Top 10 menu in admin area
22
+ * `post_types` parameter now supports comma-separated list of post types. To fetch all built-in post types use 'all'
23
+ * New option to use the external and more efficient javascript file for tracking
24
+ * New function `tptn_add_tracker` to manually include the tracking code. This is useful if your theme doesn't have `the_content` function that Top 10 filters to add the tracker code
25
+
26
+ * Enhancements:
27
+ * Viewing drafts will no longer increment the counter
28
+ * When using the Left Thumbs style, each widget instance includes the CSS code to display the correct thumbnail size
29
+
30
+ * Bug fixes:
31
+ * Missing `DISTINCT` keyword in query resulting in duplicate entries in some cases
32
+ * PHP Notice in Widget on empty search and 404 pages
33
+ * Incorrect notice that Contextual Related Posts is installed on Edit Posts pages
34
+ * `tptn_show_daily_pop_posts()` without arguments did not display daily posts
35
+ * Using Exclude categories returned incorrect counts and excluded non-posts
36
+ * Incorrect count on the Admin &raquo; View Popular Posts screen causing incorrect pagination
37
+ * Incorrect thumbnail size being pulled out in some instances
38
+ * Multiple widget instances incorrectly used the same cache
39
+ * Incorrect text domain was initialised
40
+
41
+ = 2.2.4 =
42
+
43
+ * Enhancements:
44
+ * Changed text domain to `top-10` in advance of translate.wordpress.org translation system
45
+ * Improved support for WPML. If available, same language posts will be pulled by default. To restrict to the same language [add this code](https://gist.github.com/ajaydsouza/9b1bc56cec79295e784c) to your theme's functions.php file
46
+
47
+ = 2.2.3 =
48
+
49
+ * Bug fixes:
50
+ * Shortcode with "exclude_categories" argument works again
51
+
52
+ = 2.2.2 =
53
+
54
+ * Bug fixes:
55
+ * Fixed array declaration to support PHP < 5.4
56
+
57
+ = 2.2.0 =
58
+
59
+ * Features:
60
+ * Caching system using the Transients API. By default the cache is refreshed every hour
61
+ * Styles interface lets you select between No styles, Left Thumbs (previously the default style) and Text Only
62
+ * Option to limit posts only with a specified date range
63
+ * Option in Top 10 meta box to exclude display of popular posts in widget if needed
64
+ * Option in Top 10 meta box to exclude post from popular posts list
65
+ * Cleaner interface to view popular posts in the admin area
66
+
67
+ * Enhancements:
68
+ * `strict_limit` is true by default for `get_tptn_pop_posts()`
69
+ * Option to turn off the meta box for everyone or just non-admins
70
+ * Contributors & above can also update the visit count in the meta box if this is enabled for them
71
+ * Category exclusion now works via a filter function vs. multiple lookups, thereby reducing the number of database queries
72
+
73
+ * Bug fixes:
74
+ * Potential bug when the $wp variable was not detected in rare situations
75
+ * In rare cases category exclusion failed when `term_id` didn't match `term_taxonomy_id`
76
+
77
+ * Deprecated:
78
+ * `ald_tptn_rss`: Use `tptn_rss_filter` instead
79
+ * `ald_tptn_hook` deprecated and renamed to `tptn_cron_hook`
80
+ * `tptn_manage` and `tptn_manage_daily` which were used to render the admin popular posts screens
81
+
82
+ = 2.1.0 =
83
+
84
+ * Features:
85
+ * New: Button in Top 10 settings page to merge posts across blog ID 0 and 1
86
+ * New: Function & filter `get_tptn_pop_posts` that can be used to fetch the popular posts as an object or array. Perfect if you want to write custom code in your theme
87
+ * New: Support for WPML to return the correct language ID. Thanks to Tony Flags' <a href="https://wordpress.org/support/topic/top-10-and-languages-in-wpml?replies=11#post-6622085">code snippet</a>.
88
+ * New: Filter `tptn_list_count` to modify the formatted list count. See a <a href="https://gist.github.com/ajaydsouza/9f04c26814414a57fab4">working example</a>
89
+ * New: Post types can now be selected in the widget. This allows you to select top posts by post type
90
+
91
+ * Enhancements:
92
+ * Modified: Plugin will attempt to pull the correct size image when fetching the first image in a post
93
+ * Modified: Deprecated "Always display latest post count in the daily lists"
94
+ * Modified: timthumb has been deprecated. The script is no longer packaged within Top 10
95
+
96
+ * Bug fixes:
97
+ * Fixed: Bug in tracking code when not using Ajax
98
+ * Fixed: Bug in admin column did not check for the blog_id
99
+ * Fixed: Bug where default thumbnail location was not correctly saved
100
+ * Fixed: Incorrect thumbnail was pulled on attachment pages
101
+ * Fixed: blog_id column of the database is correctly initialised as `DEFAULT '1'`
102
+
103
+ = 2.0.3 =
104
+
105
+ * Features:
106
+ * New: Options to choose if you want to delete the Top 10 options and/or data when deleting the plugin
107
+
108
+ * Bug fixes:
109
+ * Fixed: Metabox update did not work properly in v2.0
110
+ * Fixed: Duplicate include files
111
+ * Modified: In the mySQL tables, the blog_id default value is set to 1
112
+
113
+ = 2.0.2 =
114
+
115
+ * Features:
116
+ * New: Option to display the daily posts count from midnight. This is enabled by default and mimics the original behaviour of the counter in Top 10 v1.x
117
+
118
+ * Enhancements:
119
+ * Modified: Posts are tracked hourly based on the time of the blog and not GMT. This was also the default behaviour of the counter in Top 10 v1.x
120
+
121
+ * Bug fixes:
122
+ * Fixed: Default thumbnail location saved correctly on the Settings page.
123
+
124
+ = 2.0.1 =
125
+
126
+ * Bug fixes
127
+ * 500/503 errors caused by 2.0.0
128
+
129
+ = 2.0.0 =
130
+
131
+ * Features:
132
+ * New: Multisite support. If you're using multisite and have previously activated Top 10 on individual blogs in the network, then head over to **Top 10 Settings** and import the counts from the old Top 10 1.x tables to the new Top 10 v2.0 tables
133
+ * New: Fully extendable lookup query for the top lists. Now you can create your own functions in functions.php or in addon plugins to modify the mySQL query
134
+ * New: Option to use any of the inbuilt thumbnail sizes or create your own custom image size. If a custom size is chosen, then the plugin uses `add_image_size` to register the custom size. You will need to resize your thumbnails after activating this option
135
+ * New: Actions and filters in the Top 10 Settings page and in the widget which allows for addons to add more settings
136
+
137
+ * Enhancements:
138
+ * Modified: Post tracking is now done on an hourly basis. Date limiting is also on an hourly basis. So, 1 day is actually the last 24 hours and not from midnight anymore!
139
+ * Modified: Update and View counts now use query variables instead of external JavaScript files. Check http://goo.gl/yemvyM for sample functions to restore the old method
140
+ * Modified: Activating the default styles option will automatically set the thumbnail width and height to 65px, disable author and excerpt and enable crop mode for the thumbnails
141
+
142
+ * Bug fixes:
143
+ * Fixed: Fix schedule overwrite for the cron job
144
+ * Fixed: Incorrect permission lookup in the metabox
145
+
146
  = 1.9.10.2 =
147
  * Fixed: Schedules were overwritten when activating the maintenance cron job
148
 
includes/activate-deactivate.php CHANGED
@@ -21,10 +21,12 @@ function tptn_activation_hook( $network_wide ) {
21
  if ( is_multisite() && $network_wide ) {
22
 
23
  // Get all blogs in the network and activate plugin on each one.
24
- $blog_ids = $wpdb->get_col( "
 
25
  SELECT blog_id FROM $wpdb->blogs
26
  WHERE archived = '0' AND spam = '0' AND deleted = '0'
27
- " ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
 
28
  foreach ( $blog_ids as $blog_id ) {
29
  switch_to_blog( $blog_id );
30
  tptn_single_activate();
@@ -48,12 +50,12 @@ register_activation_hook( TOP_TEN_PLUGIN_FILE, 'tptn_activation_hook' );
48
  function tptn_single_activate() {
49
  global $wpdb, $tptn_db_version;
50
 
51
- $tptn_settings = tptn_read_options();
52
 
53
- $table_name = $wpdb->base_prefix . 'top_ten';
54
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
55
 
56
- if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) {
57
 
58
  $sql = 'CREATE TABLE ' . $table_name . " (
59
  postnumber bigint(20) NOT NULL,
@@ -62,13 +64,13 @@ function tptn_single_activate() {
62
  PRIMARY KEY (postnumber, blog_id)
63
  );";
64
 
65
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
66
  dbDelta( $sql );
67
 
68
  add_site_option( 'tptn_db_version', $tptn_db_version );
69
  }
70
 
71
- if ( $wpdb->get_var( "show tables like '$table_name_daily'" ) != $table_name_daily ) {
72
 
73
  $sql = 'CREATE TABLE ' . $table_name_daily . " (
74
  postnumber bigint(20) NOT NULL,
@@ -78,7 +80,7 @@ function tptn_single_activate() {
78
  PRIMARY KEY (postnumber, dp_date, blog_id)
79
  );";
80
 
81
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
82
  dbDelta( $sql );
83
 
84
  add_site_option( 'tptn_db_version', $tptn_db_version );
@@ -95,23 +97,22 @@ function tptn_single_activate() {
95
 
96
  case '4.0':
97
  case 4.0:
98
- $wpdb->query( 'ALTER TABLE ' . $table_name . " CHANGE blog_id blog_id bigint(20) NOT NULL DEFAULT '1'" );
99
- $wpdb->query( 'ALTER TABLE ' . $table_name_daily . " CHANGE blog_id blog_id bigint(20) NOT NULL DEFAULT '1'" );
100
  break;
101
 
102
  default:
103
-
104
- $wpdb->query( 'ALTER TABLE ' . $table_name . ' MODIFY postnumber bigint(20) ' );
105
- $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' MODIFY postnumber bigint(20) ' );
106
- $wpdb->query( 'ALTER TABLE ' . $table_name . ' MODIFY cntaccess bigint(20) ' );
107
- $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' MODIFY cntaccess bigint(20) ' );
108
- $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' MODIFY dp_date DATETIME ' );
109
- $wpdb->query( 'ALTER TABLE ' . $table_name . ' DROP PRIMARY KEY, ADD PRIMARY KEY(postnumber, blog_id) ' );
110
- $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' DROP PRIMARY KEY, ADD PRIMARY KEY(postnumber, dp_date, blog_id) ' );
111
- $wpdb->query( 'ALTER TABLE ' . $table_name . " ADD blog_id bigint(20) NOT NULL DEFAULT '1'" );
112
- $wpdb->query( 'ALTER TABLE ' . $table_name_daily . " ADD blog_id bigint(20) NOT NULL DEFAULT '1'" );
113
- $wpdb->query( 'UPDATE ' . $table_name . ' SET blog_id = 1 WHERE blog_id = 0 ' );
114
- $wpdb->query( 'UPDATE ' . $table_name_daily . ' SET blog_id = 1 WHERE blog_id = 0 ' );
115
 
116
  }
117
 
@@ -165,7 +166,7 @@ add_filter( 'wpmu_drop_tables', 'tptn_on_delete_blog' );
165
  /**
166
  * Function to call install function if needed.
167
  *
168
- * @since 1.9
169
  */
170
  function tptn_update_db_check() {
171
  global $tptn_db_version, $network_wide;
21
  if ( is_multisite() && $network_wide ) {
22
 
23
  // Get all blogs in the network and activate plugin on each one.
24
+ $blog_ids = $wpdb->get_col(
25
+ "
26
  SELECT blog_id FROM $wpdb->blogs
27
  WHERE archived = '0' AND spam = '0' AND deleted = '0'
28
+ "
29
+ ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
30
  foreach ( $blog_ids as $blog_id ) {
31
  switch_to_blog( $blog_id );
32
  tptn_single_activate();
50
  function tptn_single_activate() {
51
  global $wpdb, $tptn_db_version;
52
 
53
+ $tptn_settings = tptn_get_settings();
54
 
55
+ $table_name = $wpdb->base_prefix . 'top_ten';
56
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
57
 
58
+ if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) { // WPCS: unprepared SQL OK.
59
 
60
  $sql = 'CREATE TABLE ' . $table_name . " (
61
  postnumber bigint(20) NOT NULL,
64
  PRIMARY KEY (postnumber, blog_id)
65
  );";
66
 
67
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
68
  dbDelta( $sql );
69
 
70
  add_site_option( 'tptn_db_version', $tptn_db_version );
71
  }
72
 
73
+ if ( $wpdb->get_var( "show tables like '$table_name_daily'" ) != $table_name_daily ) { // WPCS: unprepared SQL OK.
74
 
75
  $sql = 'CREATE TABLE ' . $table_name_daily . " (
76
  postnumber bigint(20) NOT NULL,
80
  PRIMARY KEY (postnumber, dp_date, blog_id)
81
  );";
82
 
83
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
84
  dbDelta( $sql );
85
 
86
  add_site_option( 'tptn_db_version', $tptn_db_version );
97
 
98
  case '4.0':
99
  case 4.0:
100
+ $wpdb->query( 'ALTER TABLE ' . $table_name . " CHANGE blog_id blog_id bigint(20) NOT NULL DEFAULT '1'" ); // WPCS: unprepared SQL OK.
101
+ $wpdb->query( 'ALTER TABLE ' . $table_name_daily . " CHANGE blog_id blog_id bigint(20) NOT NULL DEFAULT '1'" ); // WPCS: unprepared SQL OK.
102
  break;
103
 
104
  default:
105
+ $wpdb->query( 'ALTER TABLE ' . $table_name . ' MODIFY postnumber bigint(20) ' ); // WPCS: unprepared SQL OK.
106
+ $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' MODIFY postnumber bigint(20) ' ); // WPCS: unprepared SQL OK.
107
+ $wpdb->query( 'ALTER TABLE ' . $table_name . ' MODIFY cntaccess bigint(20) ' ); // WPCS: unprepared SQL OK.
108
+ $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' MODIFY cntaccess bigint(20) ' ); // WPCS: unprepared SQL OK.
109
+ $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' MODIFY dp_date DATETIME ' ); // WPCS: unprepared SQL OK.
110
+ $wpdb->query( 'ALTER TABLE ' . $table_name . ' DROP PRIMARY KEY, ADD PRIMARY KEY(postnumber, blog_id) ' ); // WPCS: unprepared SQL OK.
111
+ $wpdb->query( 'ALTER TABLE ' . $table_name_daily . ' DROP PRIMARY KEY, ADD PRIMARY KEY(postnumber, dp_date, blog_id) ' ); // WPCS: unprepared SQL OK.
112
+ $wpdb->query( 'ALTER TABLE ' . $table_name . " ADD blog_id bigint(20) NOT NULL DEFAULT '1'" ); // WPCS: unprepared SQL OK.
113
+ $wpdb->query( 'ALTER TABLE ' . $table_name_daily . " ADD blog_id bigint(20) NOT NULL DEFAULT '1'" ); // WPCS: unprepared SQL OK.
114
+ $wpdb->query( 'UPDATE ' . $table_name . ' SET blog_id = 1 WHERE blog_id = 0 ' ); // WPCS: unprepared SQL OK.
115
+ $wpdb->query( 'UPDATE ' . $table_name_daily . ' SET blog_id = 1 WHERE blog_id = 0 ' ); // WPCS: unprepared SQL OK.
 
116
 
117
  }
118
 
166
  /**
167
  * Function to call install function if needed.
168
  *
169
+ * @since 1.9
170
  */
171
  function tptn_update_db_check() {
172
  global $tptn_db_version, $network_wide;
{admin → includes/admin}/admin-columns.php RENAMED
@@ -17,23 +17,18 @@ if ( ! defined( 'WPINC' ) ) {
17
  /**
18
  * Add an extra column to the All Posts page to display the page views.
19
  *
20
- * @since 1.2
21
  *
22
- * @param array $cols Array of all columns on posts page.
23
- * @return array Modified array of columns.
24
  */
25
  function tptn_column( $cols ) {
26
- global $tptn_settings;
27
 
28
- if ( ( current_user_can( 'manage_options' ) ) || ( $tptn_settings['show_count_non_admins'] ) ) {
29
- if ( $tptn_settings['pv_in_admin'] ) {
30
  $cols['tptn_total'] = __( 'Total Views', 'top-10' );
31
- }
32
- if ( $tptn_settings['pv_in_admin'] ) {
33
  $cols['tptn_daily'] = __( "Today's Views", 'top-10' );
34
- }
35
- if ( $tptn_settings['pv_in_admin'] ) {
36
- $cols['tptn_both'] = __( 'Views', 'top-10' );
37
  }
38
  }
39
  return $cols;
@@ -45,71 +40,71 @@ add_filter( 'manage_pages_columns', 'tptn_column' );
45
  /**
46
  * Display page views for each column.
47
  *
48
- * @since 1.2
49
  *
50
- * @param string $column_name Name of the column.
51
- * @param int|string $id Post ID.
52
  */
53
  function tptn_value( $column_name, $id ) {
54
- global $wpdb, $tptn_settings;
55
 
56
  $blog_id = get_current_blog_id();
57
 
58
  // Add Total count.
59
- if ( ( 'tptn_total' === $column_name ) && ( $tptn_settings['pv_in_admin'] ) ) {
60
  $table_name = $wpdb->base_prefix . 'top_ten';
61
 
62
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
63
- $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->cntaccess : 0 ) );
64
  echo esc_html( $cntaccess );
65
  }
66
 
67
  // Now process daily count.
68
- if ( ( 'tptn_daily' === $column_name ) && ( $tptn_settings['pv_in_admin'] ) ) {
69
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
70
 
71
- $daily_range = $tptn_settings['daily_range'];
72
- $hour_range = $tptn_settings['hour_range'];
73
 
74
- if ( $tptn_settings['daily_midnight'] ) {
75
  $current_time = current_time( 'timestamp', 0 );
76
- $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
77
- $from_date = gmdate( 'Y-m-d 0' , $from_date );
78
  } else {
79
  $current_time = current_time( 'timestamp', 0 );
80
- $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
81
- $from_date = gmdate( 'Y-m-d H' , $from_date );
82
  }
83
 
84
- $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= '%s' AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
85
- $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
86
  echo esc_html( $cntaccess );
87
  }
88
 
89
  // Now process both.
90
- if ( ( 'tptn_both' === $column_name ) && ( $tptn_settings['pv_in_admin'] ) ) {
91
  $table_name = $wpdb->base_prefix . 'top_ten';
92
 
93
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
94
- $cntaccess = number_format_i18n( (($resultscount) ? $resultscount->cntaccess : 0) );
95
 
96
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
97
 
98
- $daily_range = $tptn_settings['daily_range'];
99
- $hour_range = $tptn_settings['hour_range'];
100
 
101
- if ( $tptn_settings['daily_midnight'] ) {
102
  $current_time = current_time( 'timestamp', 0 );
103
- $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
104
- $from_date = gmdate( 'Y-m-d 0' , $from_date );
105
  } else {
106
  $current_time = current_time( 'timestamp', 0 );
107
- $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
108
- $from_date = gmdate( 'Y-m-d H' , $from_date );
109
  }
110
 
111
- $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= '%s' AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
112
- $cntaccess .= ' / ' . number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
113
 
114
  echo esc_html( $cntaccess );
115
  }
@@ -121,15 +116,14 @@ add_action( 'manage_pages_custom_column', 'tptn_value', 10, 2 );
121
  /**
122
  * Register the columns as sortable.
123
  *
124
- * @since 1.9.8.2
125
  *
126
- * @param array $cols Array with column names.
127
- * @return array Filtered columns array
128
  */
129
  function tptn_column_register_sortable( $cols ) {
130
- $tptn_settings = tptn_read_options();
131
 
132
- if ( $tptn_settings['pv_in_admin'] ) {
133
  $cols['tptn_total'] = array( 'tptn_total', true );
134
  $cols['tptn_daily'] = array( 'tptn_daily', true );
135
  }
@@ -143,20 +137,19 @@ add_filter( 'manage_edit-page_sortable_columns', 'tptn_column_register_sortable'
143
  /**
144
  * Add custom post clauses to sort the columns.
145
  *
146
- * @since 1.9.8.2
147
  *
148
- * @param array $clauses Lookup clauses.
149
- * @param object $wp_query WP Query object.
150
- * @return array Filtered clauses
151
  */
152
  function tptn_column_clauses( $clauses, $wp_query ) {
153
  global $wpdb;
154
- $tptn_settings = tptn_read_options();
155
 
156
  if ( isset( $wp_query->query['orderby'] ) && 'tptn_total' === $wp_query->query['orderby'] ) {
157
 
158
- $table_name = $wpdb->base_prefix . 'top_ten';
159
- $clauses['join'] .= "LEFT OUTER JOIN {$table_name} ON {$wpdb->posts}.ID={$table_name}.postnumber";
160
  $clauses['orderby'] = 'cntaccess ';
161
  $clauses['orderby'] .= ( 'ASC' === strtoupper( $wp_query->get( 'order' ) ) ) ? 'ASC' : 'DESC';
162
  }
@@ -165,22 +158,22 @@ function tptn_column_clauses( $clauses, $wp_query ) {
165
 
166
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
167
 
168
- $daily_range = $tptn_settings['daily_range'];
169
- $hour_range = $tptn_settings['hour_range'];
170
 
171
- if ( $tptn_settings['daily_midnight'] ) {
172
  $current_time = current_time( 'timestamp', 0 );
173
- $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
174
- $from_date = gmdate( 'Y-m-d 0' , $from_date );
175
  } else {
176
  $current_time = current_time( 'timestamp', 0 );
177
- $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
178
- $from_date = gmdate( 'Y-m-d H' , $from_date );
179
  }
180
 
181
- $clauses['join'] .= "LEFT OUTER JOIN {$table_name} ON {$wpdb->posts}.ID={$table_name}.postnumber";
182
- $clauses['where'] .= " AND {$table_name}.dp_date >= '$from_date' ";
183
- $clauses['groupby'] = "{$table_name}.postnumber";
184
  $clauses['orderby'] = "SUM({$table_name}.cntaccess) ";
185
  $clauses['orderby'] .= ( 'ASC' === strtoupper( $wp_query->get( 'order' ) ) ) ? 'ASC' : 'DESC';
186
  }
@@ -193,7 +186,7 @@ add_filter( 'posts_clauses', 'tptn_column_clauses', 10, 2 );
193
  /**
194
  * Output CSS for width of new column.
195
  *
196
- * @since 1.2
197
  */
198
  function tptn_admin_css() {
199
  ?>
17
  /**
18
  * Add an extra column to the All Posts page to display the page views.
19
  *
20
+ * @since 1.2
21
  *
22
+ * @param array $cols Array of all columns on posts page.
23
+ * @return array Modified array of columns.
24
  */
25
  function tptn_column( $cols ) {
 
26
 
27
+ if ( ( current_user_can( 'manage_options' ) ) || ( tptn_get_option( 'show_count_non_admins' ) ) ) {
28
+ if ( tptn_get_option( 'pv_in_admin' ) ) {
29
  $cols['tptn_total'] = __( 'Total Views', 'top-10' );
 
 
30
  $cols['tptn_daily'] = __( "Today's Views", 'top-10' );
31
+ $cols['tptn_both'] = __( 'Views', 'top-10' );
 
 
32
  }
33
  }
34
  return $cols;
40
  /**
41
  * Display page views for each column.
42
  *
43
+ * @since 1.2
44
  *
45
+ * @param string $column_name Name of the column.
46
+ * @param int|string $id Post ID.
47
  */
48
  function tptn_value( $column_name, $id ) {
49
+ global $wpdb;
50
 
51
  $blog_id = get_current_blog_id();
52
 
53
  // Add Total count.
54
+ if ( ( 'tptn_total' === $column_name ) && ( tptn_get_option( 'pv_in_admin' ) ) ) {
55
  $table_name = $wpdb->base_prefix . 'top_ten';
56
 
57
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
58
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->cntaccess : 0 ) );
59
  echo esc_html( $cntaccess );
60
  }
61
 
62
  // Now process daily count.
63
+ if ( ( 'tptn_daily' === $column_name ) && ( tptn_get_option( 'pv_in_admin' ) ) ) {
64
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
65
 
66
+ $daily_range = tptn_get_option( 'daily_range' );
67
+ $hour_range = tptn_get_option( 'hour_range' );
68
 
69
+ if ( tptn_get_option( 'daily_midnight' ) ) {
70
  $current_time = current_time( 'timestamp', 0 );
71
+ $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
72
+ $from_date = gmdate( 'Y-m-d 0', $from_date );
73
  } else {
74
  $current_time = current_time( 'timestamp', 0 );
75
+ $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
76
+ $from_date = gmdate( 'Y-m-d H', $from_date );
77
  }
78
 
79
+ $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= %s AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
80
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
81
  echo esc_html( $cntaccess );
82
  }
83
 
84
  // Now process both.
85
+ if ( ( 'tptn_both' === $column_name ) && ( tptn_get_option( 'pv_in_admin' ) ) ) {
86
  $table_name = $wpdb->base_prefix . 'top_ten';
87
 
88
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
89
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->cntaccess : 0 ) );
90
 
91
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
92
 
93
+ $daily_range = tptn_get_option( 'daily_range' );
94
+ $hour_range = tptn_get_option( 'hour_range' );
95
 
96
+ if ( tptn_get_option( 'daily_midnight' ) ) {
97
  $current_time = current_time( 'timestamp', 0 );
98
+ $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
99
+ $from_date = gmdate( 'Y-m-d 0', $from_date );
100
  } else {
101
  $current_time = current_time( 'timestamp', 0 );
102
+ $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
103
+ $from_date = gmdate( 'Y-m-d H', $from_date );
104
  }
105
 
106
+ $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= %s AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
107
+ $cntaccess .= ' / ' . number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
108
 
109
  echo esc_html( $cntaccess );
110
  }
116
  /**
117
  * Register the columns as sortable.
118
  *
119
+ * @since 1.9.8.2
120
  *
121
+ * @param array $cols Array with column names.
122
+ * @return array Filtered columns array
123
  */
124
  function tptn_column_register_sortable( $cols ) {
 
125
 
126
+ if ( tptn_get_option( 'pv_in_admin' ) ) {
127
  $cols['tptn_total'] = array( 'tptn_total', true );
128
  $cols['tptn_daily'] = array( 'tptn_daily', true );
129
  }
137
  /**
138
  * Add custom post clauses to sort the columns.
139
  *
140
+ * @since 1.9.8.2
141
  *
142
+ * @param array $clauses Lookup clauses.
143
+ * @param object $wp_query WP Query object.
144
+ * @return array Filtered clauses
145
  */
146
  function tptn_column_clauses( $clauses, $wp_query ) {
147
  global $wpdb;
 
148
 
149
  if ( isset( $wp_query->query['orderby'] ) && 'tptn_total' === $wp_query->query['orderby'] ) {
150
 
151
+ $table_name = $wpdb->base_prefix . 'top_ten';
152
+ $clauses['join'] .= "LEFT OUTER JOIN {$table_name} ON {$wpdb->posts}.ID={$table_name}.postnumber";
153
  $clauses['orderby'] = 'cntaccess ';
154
  $clauses['orderby'] .= ( 'ASC' === strtoupper( $wp_query->get( 'order' ) ) ) ? 'ASC' : 'DESC';
155
  }
158
 
159
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
160
 
161
+ $daily_range = tptn_get_option( 'daily_range' );
162
+ $hour_range = tptn_get_option( 'hour_range' );
163
 
164
+ if ( tptn_get_option( 'daily_midnight' ) ) {
165
  $current_time = current_time( 'timestamp', 0 );
166
+ $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
167
+ $from_date = gmdate( 'Y-m-d 0', $from_date );
168
  } else {
169
  $current_time = current_time( 'timestamp', 0 );
170
+ $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
171
+ $from_date = gmdate( 'Y-m-d H', $from_date );
172
  }
173
 
174
+ $clauses['join'] .= "LEFT OUTER JOIN {$table_name} ON {$wpdb->posts}.ID={$table_name}.postnumber";
175
+ $clauses['where'] .= " AND {$table_name}.dp_date >= '$from_date' ";
176
+ $clauses['groupby'] = "{$table_name}.postnumber";
177
  $clauses['orderby'] = "SUM({$table_name}.cntaccess) ";
178
  $clauses['orderby'] .= ( 'ASC' === strtoupper( $wp_query->get( 'order' ) ) ) ? 'ASC' : 'DESC';
179
  }
186
  /**
187
  * Output CSS for width of new column.
188
  *
189
+ * @since 1.2
190
  */
191
  function tptn_admin_css() {
192
  ?>
{admin → includes/admin}/admin-dashboard.php RENAMED
@@ -20,31 +20,35 @@ if ( ! defined( 'WPINC' ) ) {
20
  /**
21
  * Create the Dashboard Widget and content of the Popular pages
22
  *
23
- * @since 1.3
24
  *
25
- * @param bool $daily Switch for Daily or Overall popular posts.
26
- * @param int $page Which page of the lists are we on.
27
- * @param int $limit Maximum number of posts per page.
28
- * @param bool $widget Is this a WordPress widget.
29
- * @return Formatted list of popular posts
30
  */
31
  function tptn_pop_display( $daily = false, $page = 0, $limit = false, $widget = false ) {
32
- global $wpdb, $tptn_settings;
33
 
34
  $table_name = $wpdb->base_prefix . 'top_ten';
35
  if ( $daily ) {
36
  $table_name .= '_daily'; // If we're viewing daily posts, set this to true.
37
  }
38
- if ( ! $limit ) { $limit = $tptn_settings['limit']; }
 
 
39
 
40
- $results = get_tptn_pop_posts( array(
41
- 'posts_only' => 1,
42
- 'strict_limit' => 1,
43
- 'is_widget' => 1,
44
- 'daily' => $daily,
45
- 'limit' => $limit,
46
- 'post_types' => 'all',
47
- ) );
 
 
48
 
49
  $output = '<div id="tptn_popular_posts' . ( $daily ? '_daily' : '' ) . '">';
50
 
@@ -69,6 +73,8 @@ function tptn_pop_display( $daily = false, $page = 0, $limit = false, $widget =
69
  $output .= '</p>';
70
 
71
  $output .= '<p style="text-align:center;border-top: #000 1px solid">';
 
 
72
  $output .= sprintf( __( 'Popular posts by <a href="%s" target="_blank">Top 10 plugin</a>', 'top-10' ), esc_url( 'https://webberzone.com/plugins/top-10/' ) );
73
  $output .= '</p>';
74
  $output .= '</div>';
@@ -76,7 +82,7 @@ function tptn_pop_display( $daily = false, $page = 0, $limit = false, $widget =
76
  /**
77
  * Filters the dashboard widget output
78
  *
79
- * @since 1.3
80
  *
81
  * @param string $output Text output
82
  * @param bool $daily Switch for Daily or Overall popular posts.
@@ -91,7 +97,7 @@ function tptn_pop_display( $daily = false, $page = 0, $limit = false, $widget =
91
  /**
92
  * Widget for Popular Posts.
93
  *
94
- * @since 1.1
95
  */
96
  function tptn_pop_dashboard() {
97
  echo tptn_pop_display( false, 0, 10, true ); // WPCS: XSS OK.
@@ -101,7 +107,7 @@ function tptn_pop_dashboard() {
101
  /**
102
  * Widget for Daily Popular Posts.
103
  *
104
- * @since 1.2
105
  */
106
  function tptn_pop_daily_dashboard() {
107
  echo tptn_pop_display( true, 0, 10, true ); // WPCS: XSS OK.
@@ -111,12 +117,11 @@ function tptn_pop_daily_dashboard() {
111
  /**
112
  * Function to add the widgets to the Dashboard.
113
  *
114
- * @since 1.1
115
  */
116
  function tptn_pop_dashboard_setup() {
117
- global $tptn_settings;
118
 
119
- if ( ( current_user_can( 'manage_options' ) ) || ( $tptn_settings['show_count_non_admins'] ) ) {
120
  wp_add_dashboard_widget(
121
  'tptn_pop_dashboard',
122
  __( 'Popular Posts', 'top-10' ),
20
  /**
21
  * Create the Dashboard Widget and content of the Popular pages
22
  *
23
+ * @since 1.3
24
  *
25
+ * @param bool $daily Switch for Daily or Overall popular posts.
26
+ * @param int $page Which page of the lists are we on.
27
+ * @param int $limit Maximum number of posts per page.
28
+ * @param bool $widget Is this a WordPress widget.
29
+ * @return Formatted list of popular posts
30
  */
31
  function tptn_pop_display( $daily = false, $page = 0, $limit = false, $widget = false ) {
32
+ global $wpdb;
33
 
34
  $table_name = $wpdb->base_prefix . 'top_ten';
35
  if ( $daily ) {
36
  $table_name .= '_daily'; // If we're viewing daily posts, set this to true.
37
  }
38
+ if ( ! $limit ) {
39
+ $limit = tptn_get_option( 'limit' );
40
+ }
41
 
42
+ $results = get_tptn_pop_posts(
43
+ array(
44
+ 'posts_only' => 1,
45
+ 'strict_limit' => 1,
46
+ 'is_widget' => 1,
47
+ 'daily' => $daily,
48
+ 'limit' => $limit,
49
+ 'post_types' => 'all',
50
+ )
51
+ );
52
 
53
  $output = '<div id="tptn_popular_posts' . ( $daily ? '_daily' : '' ) . '">';
54
 
73
  $output .= '</p>';
74
 
75
  $output .= '<p style="text-align:center;border-top: #000 1px solid">';
76
+
77
+ /* translators: 1: Top 10 page link. */
78
  $output .= sprintf( __( 'Popular posts by <a href="%s" target="_blank">Top 10 plugin</a>', 'top-10' ), esc_url( 'https://webberzone.com/plugins/top-10/' ) );
79
  $output .= '</p>';
80
  $output .= '</div>';
82
  /**
83
  * Filters the dashboard widget output
84
  *
85
+ * @since 1.3
86
  *
87
  * @param string $output Text output
88
  * @param bool $daily Switch for Daily or Overall popular posts.
97
  /**
98
  * Widget for Popular Posts.
99
  *
100
+ * @since 1.1
101
  */
102
  function tptn_pop_dashboard() {
103
  echo tptn_pop_display( false, 0, 10, true ); // WPCS: XSS OK.
107
  /**
108
  * Widget for Daily Popular Posts.
109
  *
110
+ * @since 1.2
111
  */
112
  function tptn_pop_daily_dashboard() {
113
  echo tptn_pop_display( true, 0, 10, true ); // WPCS: XSS OK.
117
  /**
118
  * Function to add the widgets to the Dashboard.
119
  *
120
+ * @since 1.1
121
  */
122
  function tptn_pop_dashboard_setup() {
 
123
 
124
+ if ( ( current_user_can( 'manage_options' ) ) || ( tptn_get_option( 'show_count_non_admins' ) ) ) {
125
  wp_add_dashboard_widget(
126
  'tptn_pop_dashboard',
127
  __( 'Popular Posts', 'top-10' ),
{admin → includes/admin}/admin-metabox.php RENAMED
@@ -19,31 +19,34 @@ if ( ! defined( 'WPINC' ) ) {
19
  /**
20
  * Function to add meta box in Write screens.
21
  *
22
- * @since 1.9.10
23
  *
24
- * @param text $post_type Post type.
25
- * @param object $post Post object.
26
  */
27
  function tptn_add_meta_box( $post_type, $post ) {
28
- global $tptn_settings;
29
 
30
  // If metaboxes are disabled, then exit.
31
- if ( ! $tptn_settings['show_metabox'] ) { return; }
 
 
32
 
33
  // If current user isn't an admin and we're restricting metaboxes to admins only, then exit.
34
- if ( ! current_user_can( 'manage_options' ) && $tptn_settings['show_metabox_admins'] ) { return; }
 
 
35
 
36
- $args = array(
37
- 'public' => true,
38
  );
39
  $post_types = get_post_types( $args );
40
 
41
  /**
42
  * Filter post types on which the meta box is displayed
43
  *
44
- * @since 2.2.0
45
  *
46
- * @param array $post_types Array of post types
47
  */
48
  $post_types = apply_filters( 'tptn_meta_box_post_types', $post_types );
49
 
@@ -59,16 +62,16 @@ function tptn_add_meta_box( $post_type, $post ) {
59
  );
60
  }
61
  }
62
- add_action( 'add_meta_boxes', 'tptn_add_meta_box' , 10, 2 );
63
 
64
 
65
  /**
66
  * Function to call the meta box.
67
  *
68
- * @since 1.9.10
69
  */
70
  function tptn_call_meta_box() {
71
- global $wpdb, $post, $tptn_settings;
72
 
73
  $table_name = $wpdb->base_prefix . 'top_ten';
74
 
@@ -76,12 +79,14 @@ function tptn_call_meta_box() {
76
  wp_nonce_field( 'tptn_meta_box', 'tptn_meta_box_nonce' );
77
 
78
  // Get the number of visits for the post being editted.
79
- $resultscount = $wpdb->get_row( $wpdb->prepare( // WPCS: unprepared SQL OK.
80
- "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d " ,
81
- $post->ID,
82
- get_current_blog_id()
83
- ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
84
- $total_count = $resultscount ? $resultscount->cntaccess : 0;
 
 
85
 
86
  // Get the post meta.
87
  $tptn_post_meta = get_post_meta( $post->ID, 'tptn_post_meta', true );
@@ -108,8 +113,8 @@ function tptn_call_meta_box() {
108
 
109
  <?php
110
 
111
- $results = get_post_meta( $post->ID, $tptn_settings['thumb_meta'], true );
112
- $value = ( $results ) ? $results : '';
113
  ?>
114
  <p>
115
  <label for="disable_here"><strong><?php esc_html_e( 'Disable Popular Posts display:', 'top-10' ); ?></strong></label>
@@ -127,14 +132,19 @@ function tptn_call_meta_box() {
127
 
128
  <p>
129
  <label for="thumb_meta"><strong><?php esc_html_e( 'Location of thumbnail:', 'top-10' ); ?></strong></label>
130
- <input type="text" id="thumb_meta" name="thumb_meta" value="<?php echo esc_url( $value ) ?>" style="width:100%" />
131
  <em><?php esc_html_e( "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This image will be used for the post. It will be resized to the thumbnail size set under Top 10 Settings &raquo; Thumbnail options.", 'top-10' ); ?></em>
132
- <em><?php esc_html_e( 'The URL above is saved in the meta field:', 'top-10' ); ?></em><strong><?php echo esc_attr( $tptn_settings['thumb_meta'] ); ?></strong>
133
  </p>
134
 
135
  <p>
136
  <?php if ( function_exists( 'crp_read_options' ) ) { ?>
137
- <em style="color:red"><?php printf( __( 'You have %1$s installed. If you are trying to modify the thumbnail, then you will need to make the same change in the %1$s meta box on this page.', 'top-10' ), 'Contextual Related Posts' ); // WPCS: XSS OK. ?></em>
 
 
 
 
 
138
  <?php } ?>
139
  </p>
140
 
@@ -149,19 +159,21 @@ function tptn_call_meta_box() {
149
  /**
150
  * Function to save the meta box.
151
  *
152
- * @since 1.9.10
153
  *
154
- * @param int $post_id Post ID.
155
  */
156
  function tptn_save_meta_box( $post_id ) {
157
- global $tptn_settings, $wpdb;
158
 
159
  $tptn_post_meta = array();
160
 
161
  $table_name = $wpdb->base_prefix . 'top_ten';
162
 
163
  // Bail if we're doing an auto save.
164
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; }
 
 
165
 
166
  // If our nonce isn't there, or we can't verify it, bail.
167
  if ( ! isset( $_POST['tptn_meta_box_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['tptn_meta_box_nonce'] ), 'tptn_meta_box' ) ) { // Input var okay.
@@ -176,22 +188,26 @@ function tptn_save_meta_box( $post_id ) {
176
  // Update the posts view count.
177
  if ( isset( $_POST['total_count'] ) ) { // Input var okay.
178
  $total_count = intval( $_POST['total_count'] ); // Input var okay.
179
- $blog_id = get_current_blog_id();
180
 
181
  if ( 0 === $total_count ) {
182
- $wpdb->query( $wpdb->prepare( // WPCS: unprepared SQL OK.
183
- "DELETE FROM {$table_name} WHERE postnumber = %d AND blog_id = %d",
184
- $post_id,
185
- $blog_id
186
- ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
 
 
187
  } else {
188
- $wpdb->query( $wpdb->prepare( // WPCS: unprepared SQL OK.
189
- "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES('%d', '%d', '%d') ON DUPLICATE KEY UPDATE cntaccess= %d ",
190
- $post_id,
191
- $total_count,
192
- $blog_id,
193
- $total_count
194
- ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
 
 
195
  }
196
  }
197
 
@@ -201,9 +217,9 @@ function tptn_save_meta_box( $post_id ) {
201
  }
202
 
203
  if ( ! empty( $thumb_meta ) ) {
204
- update_post_meta( $post_id, $tptn_settings['thumb_meta'], $thumb_meta );
205
  } else {
206
- delete_post_meta( $post_id, $tptn_settings['thumb_meta'] );
207
  }
208
 
209
  // Disable posts.
@@ -222,18 +238,18 @@ function tptn_save_meta_box( $post_id ) {
222
  /**
223
  * Filter the Top 10 Post meta variable which contains post-specific settings
224
  *
225
- * @since 2.2.0
226
  *
227
- * @param array $tptn_post_meta Top 10 post-specific settings
228
- * @param int $post_id Post ID
229
  */
230
  $tptn_post_meta = apply_filters( 'tptn_post_meta', $tptn_post_meta, $post_id );
231
 
232
  $tptn_post_meta_filtered = array_filter( $tptn_post_meta );
233
 
234
- /**** Now we can start saving ****/
235
- if ( empty( $tptn_post_meta_filtered ) ) { // Checks if all the array items are 0 or empty
236
- delete_post_meta( $post_id, 'tptn_post_meta' ); // Delete the post meta if no options are set
237
  } else {
238
  update_post_meta( $post_id, 'tptn_post_meta', $tptn_post_meta );
239
  }
@@ -241,12 +257,13 @@ function tptn_save_meta_box( $post_id ) {
241
  /**
242
  * Action triggered when saving Contextual Related Posts meta box settings
243
  *
244
- * @since 2.2
245
  *
246
- * @param int $post_id Post ID
247
  */
248
  do_action( 'tptn_save_meta_box', $post_id );
249
 
250
  }
251
  add_action( 'save_post', 'tptn_save_meta_box' );
 
252
 
19
  /**
20
  * Function to add meta box in Write screens.
21
  *
22
+ * @since 1.9.10
23
  *
24
+ * @param text $post_type Post type.
25
+ * @param object $post Post object.
26
  */
27
  function tptn_add_meta_box( $post_type, $post ) {
 
28
 
29
  // If metaboxes are disabled, then exit.
30
+ if ( ! tptn_get_option( 'show_metabox' ) ) {
31
+ return;
32
+ }
33
 
34
  // If current user isn't an admin and we're restricting metaboxes to admins only, then exit.
35
+ if ( ! current_user_can( 'manage_options' ) && tptn_get_option( 'show_metabox_admins' ) ) {
36
+ return;
37
+ }
38
 
39
+ $args = array(
40
+ 'public' => true,
41
  );
42
  $post_types = get_post_types( $args );
43
 
44
  /**
45
  * Filter post types on which the meta box is displayed
46
  *
47
+ * @since 2.2.0
48
  *
49
+ * @param array $post_types Array of post types
50
  */
51
  $post_types = apply_filters( 'tptn_meta_box_post_types', $post_types );
52
 
62
  );
63
  }
64
  }
65
+ add_action( 'add_meta_boxes', 'tptn_add_meta_box', 10, 2 );
66
 
67
 
68
  /**
69
  * Function to call the meta box.
70
  *
71
+ * @since 1.9.10
72
  */
73
  function tptn_call_meta_box() {
74
+ global $wpdb, $post;
75
 
76
  $table_name = $wpdb->base_prefix . 'top_ten';
77
 
79
  wp_nonce_field( 'tptn_meta_box', 'tptn_meta_box_nonce' );
80
 
81
  // Get the number of visits for the post being editted.
82
+ $resultscount = $wpdb->get_row(
83
+ $wpdb->prepare(
84
+ "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ",
85
+ $post->ID,
86
+ get_current_blog_id()
87
+ )
88
+ ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
89
+ $total_count = $resultscount ? $resultscount->cntaccess : 0;
90
 
91
  // Get the post meta.
92
  $tptn_post_meta = get_post_meta( $post->ID, 'tptn_post_meta', true );
113
 
114
  <?php
115
 
116
+ $results = get_post_meta( $post->ID, tptn_get_option( 'thumb_meta' ), true );
117
+ $value = ( $results ) ? $results : '';
118
  ?>
119
  <p>
120
  <label for="disable_here"><strong><?php esc_html_e( 'Disable Popular Posts display:', 'top-10' ); ?></strong></label>
132
 
133
  <p>
134
  <label for="thumb_meta"><strong><?php esc_html_e( 'Location of thumbnail:', 'top-10' ); ?></strong></label>
135
+ <input type="text" id="thumb_meta" name="thumb_meta" value="<?php echo esc_url( $value ); ?>" style="width:100%" />
136
  <em><?php esc_html_e( "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This image will be used for the post. It will be resized to the thumbnail size set under Top 10 Settings &raquo; Thumbnail options.", 'top-10' ); ?></em>
137
+ <em><?php esc_html_e( 'The URL above is saved in the meta field:', 'top-10' ); ?></em><strong><?php echo esc_attr( tptn_get_option( 'thumb_meta' ) ); ?></strong>
138
  </p>
139
 
140
  <p>
141
  <?php if ( function_exists( 'crp_read_options' ) ) { ?>
142
+ <em style="color:red">
143
+ <?php
144
+ /* translators: 1: Plugin name */
145
+ printf( __( 'You have %1$s installed. If you are trying to modify the thumbnail, then you will need to make the same change in the %1$s meta box on this page.', 'top-10' ), 'Contextual Related Posts' ); // WPCS: XSS OK.
146
+ ?>
147
+ </em>
148
  <?php } ?>
149
  </p>
150
 
159
  /**
160
  * Function to save the meta box.
161
  *
162
+ * @since 1.9.10
163
  *
164
+ * @param int $post_id Post ID.
165
  */
166
  function tptn_save_meta_box( $post_id ) {
167
+ global $wpdb;
168
 
169
  $tptn_post_meta = array();
170
 
171
  $table_name = $wpdb->base_prefix . 'top_ten';
172
 
173
  // Bail if we're doing an auto save.
174
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
175
+ return;
176
+ }
177
 
178
  // If our nonce isn't there, or we can't verify it, bail.
179
  if ( ! isset( $_POST['tptn_meta_box_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['tptn_meta_box_nonce'] ), 'tptn_meta_box' ) ) { // Input var okay.
188
  // Update the posts view count.
189
  if ( isset( $_POST['total_count'] ) ) { // Input var okay.
190
  $total_count = intval( $_POST['total_count'] ); // Input var okay.
191
+ $blog_id = get_current_blog_id();
192
 
193
  if ( 0 === $total_count ) {
194
+ $wpdb->query(
195
+ $wpdb->prepare(
196
+ "DELETE FROM {$table_name} WHERE postnumber = %d AND blog_id = %d",
197
+ $post_id,
198
+ $blog_id
199
+ )
200
+ ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
201
  } else {
202
+ $wpdb->query(
203
+ $wpdb->prepare(
204
+ "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES( %d, %d, %d ) ON DUPLICATE KEY UPDATE cntaccess= %d ",
205
+ $post_id,
206
+ $total_count,
207
+ $blog_id,
208
+ $total_count
209
+ )
210
+ ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
211
  }
212
  }
213
 
217
  }
218
 
219
  if ( ! empty( $thumb_meta ) ) {
220
+ update_post_meta( $post_id, tptn_get_option( 'thumb_meta' ), $thumb_meta );
221
  } else {
222
+ delete_post_meta( $post_id, tptn_get_option( 'thumb_meta' ) );
223
  }
224
 
225
  // Disable posts.
238
  /**
239
  * Filter the Top 10 Post meta variable which contains post-specific settings
240
  *
241
+ * @since 2.2.0
242
  *
243
+ * @param array $tptn_post_meta Top 10 post-specific settings
244
+ * @param int $post_id Post ID
245
  */
246
  $tptn_post_meta = apply_filters( 'tptn_post_meta', $tptn_post_meta, $post_id );
247
 
248
  $tptn_post_meta_filtered = array_filter( $tptn_post_meta );
249
 
250
+ /**** Now we can start saving */
251
+ if ( empty( $tptn_post_meta_filtered ) ) { // Checks if all the array items are 0 or empty.
252
+ delete_post_meta( $post_id, 'tptn_post_meta' ); // Delete the post meta if no options are set.
253
  } else {
254
  update_post_meta( $post_id, 'tptn_post_meta', $tptn_post_meta );
255
  }
257
  /**
258
  * Action triggered when saving Contextual Related Posts meta box settings
259
  *
260
+ * @since 2.2
261
  *
262
+ * @param int $post_id Post ID
263
  */
264
  do_action( 'tptn_save_meta_box', $post_id );
265
 
266
  }
267
  add_action( 'save_post', 'tptn_save_meta_box' );
268
+ add_action( 'edit_attachment', 'tptn_save_meta_box' );
269
 
includes/admin/admin.php ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The admin-specific functionality of the plugin.
4
+ *
5
+ * @link https://webberzone.com
6
+ * @since 2.5.0
7
+ *
8
+ * @package Top 10
9
+ * @subpackage Admin
10
+ */
11
+
12
+ // If this file is called directly, abort.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+
18
+ /**
19
+ * Creates the admin submenu pages under the Downloads menu and assigns their
20
+ * links to global variables
21
+ *
22
+ * @since 2.5.0
23
+ *
24
+ * @global $tptn_settings_page
25
+ * @return void
26
+ */
27
+ function tptn_add_admin_pages_links() {
28
+ global $tptn_settings_page, $tptn_settings_tools_help;
29
+
30
+ $tptn_settings_page = add_menu_page( esc_html__( 'Top 10 Settings', 'top-10' ), esc_html__( 'Top 10', 'top-10' ), 'manage_options', 'tptn_options_page', 'tptn_options_page', 'dashicons-editor-ol' );
31
+ add_action( "load-$tptn_settings_page", 'tptn_settings_help' ); // Load the settings contextual help.
32
+ add_action( "admin_head-$tptn_settings_page", 'tptn_adminhead' ); // Load the admin head.
33
+
34
+ $plugin_page = add_submenu_page( 'tptn_options_page', esc_html__( 'Top 10 Settings', 'top-10' ), esc_html__( 'Settings', 'top-10' ), 'manage_options', 'tptn_options_page', 'tptn_options_page' );
35
+ add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
36
+
37
+ $tptn_settings_tools_help = add_submenu_page( 'tptn_options_page', esc_html__( 'Top 10 Tools', 'top-10' ), esc_html__( 'Tools', 'top-10' ), 'manage_options', 'tptn_tools_page', 'tptn_tools_page' );
38
+ add_action( "load-$tptn_settings_tools_help", 'tptn_settings_tools_help' );
39
+ add_action( 'admin_head-' . $tptn_settings_tools_help, 'tptn_adminhead' );
40
+
41
+ // Initialise Top 10 Statistics pages.
42
+ $tptn_stats_screen = new Top_Ten_Statistics();
43
+
44
+ $plugin_page = add_submenu_page( 'tptn_options_page', __( 'Top 10 Popular Posts', 'top-10' ), __( 'Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts', array( $tptn_stats_screen, 'plugin_settings_page' ) );
45
+ add_action( "load-$plugin_page", array( $tptn_stats_screen, 'screen_option' ) );
46
+ add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
47
+
48
+ $plugin_page = add_submenu_page( 'tptn_options_page', __( 'Top 10 Daily Popular Posts', 'top-10' ), __( 'Daily Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts&orderby=daily_count&order=desc', array( $tptn_stats_screen, 'plugin_settings_page' ) );
49
+ add_action( "load-$plugin_page", array( $tptn_stats_screen, 'screen_option' ) );
50
+ add_action( 'admin_head-' . $plugin_page, 'tptn_adminhead' );
51
+
52
+ }
53
+ add_action( 'admin_menu', 'tptn_add_admin_pages_links' );
54
+
55
+
56
+ /**
57
+ * Function to add CSS and JS to the Admin header.
58
+ *
59
+ * @since 2.5.0
60
+ * @return void
61
+ */
62
+ function tptn_adminhead() {
63
+
64
+ wp_enqueue_script( 'jquery' );
65
+ wp_enqueue_script( 'jquery-ui-autocomplete' );
66
+ wp_enqueue_script( 'jquery-ui-tabs' );
67
+ wp_enqueue_script( 'plugin-install' );
68
+ add_thickbox();
69
+ ?>
70
+ <script type="text/javascript">
71
+ //<![CDATA[
72
+ // Function to clear the cache.
73
+ function clearCache() {
74
+ /**** since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php ****/
75
+ jQuery.post(ajaxurl, {
76
+ action: 'tptn_clear_cache'
77
+ }, function (response, textStatus, jqXHR) {
78
+ alert(response.message);
79
+ }, 'json');
80
+ }
81
+
82
+ // Function to add auto suggest.
83
+ jQuery(document).ready(function($) {
84
+ $.fn.tptnTagsSuggest = function( options ) {
85
+
86
+ var cache;
87
+ var last;
88
+ var $element = $( this );
89
+
90
+ var taxonomy = $element.attr( 'data-wp-taxonomy' ) || 'category';
91
+
92
+ function split( val ) {
93
+ return val.split( /,\s*/ );
94
+ }
95
+
96
+ function extractLast( term ) {
97
+ return split( term ).pop();
98
+ }
99
+
100
+ $element.on( "keydown", function( event ) {
101
+ // Don't navigate away from the field on tab when selecting an item.
102
+ if ( event.keyCode === $.ui.keyCode.TAB &&
103
+ $( this ).autocomplete( 'instance' ).menu.active ) {
104
+ event.preventDefault();
105
+ }
106
+ })
107
+ .autocomplete({
108
+ minLength: 2,
109
+ source: function( request, response ) {
110
+ var term;
111
+
112
+ if ( last === request.term ) {
113
+ response( cache );
114
+ return;
115
+ }
116
+
117
+ term = extractLast( request.term );
118
+
119
+ if ( last === request.term ) {
120
+ response( cache );
121
+ return;
122
+ }
123
+
124
+ $.ajax({
125
+ type: 'POST',
126
+ dataType: 'json',
127
+ url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
128
+ data: {
129
+ action: 'tptn_tag_search',
130
+ tax: taxonomy,
131
+ q: term
132
+ },
133
+ success: function( data ) {
134
+ cache = data;
135
+
136
+ response( data );
137
+ }
138
+ });
139
+
140
+ last = request.term;
141
+
142
+ },
143
+ search: function() {
144
+ // Custom minLength.
145
+ var term = extractLast( this.value );
146
+
147
+ if ( term.length < 2 ) {
148
+ return false;
149
+ }
150
+ },
151
+ focus: function( event, ui ) {
152
+ // Prevent value inserted on focus.
153
+ event.preventDefault();
154
+ },
155
+ select: function( event, ui ) {
156
+ var terms = split( this.value );
157
+
158
+ // Remove the last user input.
159
+ terms.pop();
160
+
161
+ // Add the selected item.
162
+ terms.push( ui.item.value );
163
+
164
+ // Add placeholder to get the comma-and-space at the end.
165
+ terms.push( "" );
166
+ this.value = terms.join( ", " );
167
+ return false;
168
+ }
169
+ });
170
+
171
+ };
172
+
173
+ $( '.category_autocomplete' ).each( function ( i, element ) {
174
+ $( element ).tptnTagsSuggest();
175
+ });
176
+
177
+ // Prompt the user when they leave the page without saving the form.
178
+ formmodified=0;
179
+
180
+ $('form *').change(function(){
181
+ formmodified=1;
182
+ });
183
+
184
+ window.onbeforeunload = confirmExit;
185
+
186
+ function confirmExit() {
187
+ if (formmodified == 1) {
188
+ return "<?php esc_html__( 'New information not saved. Do you wish to leave the page?', 'where-did-they-go-from-here' ); ?>";
189
+ }
190
+ }
191
+
192
+ $( "input[name='submit']" ).click( function() {
193
+ formmodified = 0;
194
+ });
195
+
196
+ $( function() {
197
+ $( "#post-body-content" ).tabs({
198
+ create: function( event, ui ) {
199
+ $( ui.tab.find("a") ).addClass( "nav-tab-active" );
200
+ },
201
+ activate: function( event, ui ) {
202
+ $( ui.oldTab.find("a") ).removeClass( "nav-tab-active" );
203
+ $( ui.newTab.find("a") ).addClass( "nav-tab-active" );
204
+ }
205
+ });
206
+ });
207
+
208
+ });
209
+
210
+ //]]>
211
+ </script>
212
+ <?php
213
+ }
214
+
215
+
216
+ /**
217
+ * Customise the taxonomy columns.
218
+ *
219
+ * @since 2.5.0
220
+ * @param array $columns Columns in the admin view.
221
+ * @return array Updated columns.
222
+ */
223
+ function tptn_tax_columns( $columns ) {
224
+
225
+ // Remove the description column.
226
+ unset( $columns['description'] );
227
+
228
+ $new_columns = array(
229
+ 'tax_id' => 'ID',
230
+ );
231
+
232
+ return array_merge( $columns, $new_columns );
233
+ }
234
+ add_filter( 'manage_edit-tptn_category_columns', 'tptn_tax_columns' );
235
+ add_filter( 'manage_edit-tptn_category_sortable_columns', 'tptn_tax_columns' );
236
+ add_filter( 'manage_edit-tptn_tag_columns', 'tptn_tax_columns' );
237
+ add_filter( 'manage_edit-tptn_tag_sortable_columns', 'tptn_tax_columns' );
238
+
239
+
240
+ /**
241
+ * Add taxonomy ID to the admin column.
242
+ *
243
+ * @since 2.5.0
244
+ *
245
+ * @param string $value Deprecated.
246
+ * @param string $name Name of the column.
247
+ * @param int|string $id Category ID.
248
+ * @return int|string
249
+ */
250
+ function tptn_tax_id( $value, $name, $id ) {
251
+ return 'tax_id' === $name ? $id : $value;
252
+ }
253
+ add_filter( 'manage_tptn_category_custom_column', 'tptn_tax_id', 10, 3 );
254
+ add_filter( 'manage_tptn_tag_custom_column', 'tptn_tax_id', 10, 3 );
255
+
256
+
257
+ /**
258
+ * Add rating links to the admin dashboard
259
+ *
260
+ * @since 2.5.0
261
+ *
262
+ * @param string $footer_text The existing footer text.
263
+ * @return string Updated Footer text
264
+ */
265
+ function tptn_admin_footer( $footer_text ) {
266
+
267
+ if ( get_current_screen()->parent_base === 'tptn_options_page' ) {
268
+
269
+ $text = sprintf(
270
+ /* translators: 1: Top 10 website, 2: Plugin reviews link. */
271
+ __( 'Thank you for using <a href="%1$s" target="_blank">Top 10</a>! Please <a href="%2$s" target="_blank">rate us</a> on <a href="%2$s" target="_blank">WordPress.org</a>', 'top-10' ),
272
+ 'https://webberzone.com/top-10',
273
+ 'https://wordpress.org/support/plugin/top-10/reviews/#new-post'
274
+ );
275
+
276
+ return str_replace( '</span>', '', $footer_text ) . ' | ' . $text . '</span>';
277
+
278
+ } else {
279
+
280
+ return $footer_text;
281
+
282
+ }
283
+ }
284
+ add_filter( 'admin_footer_text', 'tptn_admin_footer' );
285
+
286
+
287
+ /**
288
+ * Add CSS to Admin head
289
+ *
290
+ * @since 2.5.0
291
+ *
292
+ * return void
293
+ */
294
+ function tptn_admin_head() {
295
+ ?>
296
+ <style type="text/css" media="screen">
297
+ #dashboard_right_now .tptn-article-count:before {
298
+ content: "\f331";
299
+ }
300
+ </style>
301
+ <?php
302
+ }
303
+ add_filter( 'admin_head', 'tptn_admin_head' );
304
+
305
+ /**
306
+ * Adding WordPress plugin action links.
307
+ *
308
+ * @version 1.9.2
309
+ *
310
+ * @param array $links Action links.
311
+ * @return array Links array with our settings link added.
312
+ */
313
+ function tptn_plugin_actions_links( $links ) {
314
+
315
+ return array_merge(
316
+ array(
317
+ 'settings' => '<a href="' . admin_url( 'options-general.php?page=tptn_options_page' ) . '">' . __( 'Settings', 'top-10' ) . '</a>',
318
+ ),
319
+ $links
320
+ );
321
+
322
+ }
323
+ add_filter( 'plugin_action_links_' . plugin_basename( TOP_TEN_PLUGIN_FILE ), 'tptn_plugin_actions_links' );
324
+
325
+
326
+ /**
327
+ * Add links to the plugin action row.
328
+ *
329
+ * @since 1.5
330
+ *
331
+ * @param array $links Action links.
332
+ * @param array $file Plugin file name.
333
+ * @return array Links array with our links added
334
+ */
335
+ function tptn_plugin_actions( $links, $file ) {
336
+ $plugin = plugin_basename( TOP_TEN_PLUGIN_FILE );
337
+
338
+ if ( $file === $plugin ) {
339
+ $links[] = '<a href="https://wordpress.org/support/plugin/top-10/">' . __( 'Support', 'top-10' ) . '</a>';
340
+ $links[] = '<a href="https://ajaydsouza.com/donate/">' . __( 'Donate', 'top-10' ) . '</a>';
341
+ $links[] = '<a href="https://github.com/WebberZone/top-10">' . __( 'Contribute', 'top-10' ) . '</a>';
342
+ }
343
+ return $links;
344
+ }
345
+ add_filter( 'plugin_row_meta', 'tptn_plugin_actions', 10, 2 );
346
+
347
+
{admin → includes/admin}/cache.php RENAMED
@@ -8,16 +8,20 @@
8
  /**
9
  * Function to clear the Top 10 Cache with Ajax.
10
  *
11
- * @since 2.2.0
12
  */
13
  function tptn_ajax_clearcache() {
14
 
15
  tptn_cache_delete();
16
 
17
- exit( wp_json_encode( array(
18
- 'success' => 1,
19
- 'message' => __( 'Top 10 cache has been cleared', 'top-10' ),
20
- ) ) );
 
 
 
 
21
  }
22
  add_action( 'wp_ajax_tptn_clear_cache', 'tptn_ajax_clearcache' );
23
 
@@ -25,7 +29,7 @@ add_action( 'wp_ajax_tptn_clear_cache', 'tptn_ajax_clearcache' );
25
  /**
26
  * Get the default meta keys used for the cache
27
  *
28
- * @return array Transient meta keys
29
  */
30
  function tptn_cache_get_keys() {
31
 
@@ -45,9 +49,9 @@ function tptn_cache_get_keys() {
45
  /**
46
  * Filters the array containing the various cache keys.
47
  *
48
- * @since 1.9
49
  *
50
- * @param array $default_meta_keys Array of meta keys
51
  */
52
  return apply_filters( 'tptn_cache_keys', $meta_keys );
53
  }
@@ -56,7 +60,7 @@ function tptn_cache_get_keys() {
56
  /**
57
  * Delete the Top 10 cache.
58
  *
59
- * @param array $transients Array of transients to delete.
60
  */
61
  function tptn_cache_delete( $transients = array() ) {
62
 
8
  /**
9
  * Function to clear the Top 10 Cache with Ajax.
10
  *
11
+ * @since 2.2.0
12
  */
13
  function tptn_ajax_clearcache() {
14
 
15
  tptn_cache_delete();
16
 
17
+ exit(
18
+ wp_json_encode(
19
+ array(
20
+ 'success' => 1,
21
+ 'message' => __( 'Top 10 cache has been cleared', 'top-10' ),
22
+ )
23
+ )
24
+ );
25
  }
26
  add_action( 'wp_ajax_tptn_clear_cache', 'tptn_ajax_clearcache' );
27
 
29
  /**
30
  * Get the default meta keys used for the cache
31
  *
32
+ * @return array Transient meta keys
33
  */
34
  function tptn_cache_get_keys() {
35
 
49
  /**
50
  * Filters the array containing the various cache keys.
51
  *
52
+ * @since 1.9
53
  *
54
+ * @param array $default_meta_keys Array of meta keys
55
  */
56
  return apply_filters( 'tptn_cache_keys', $meta_keys );
57
  }
60
  /**
61
  * Delete the Top 10 cache.
62
  *
63
+ * @param array $transients Array of transients to delete.
64
  */
65
  function tptn_cache_delete( $transients = array() ) {
66
 
admin/class-stats.php → includes/admin/class-top-ten-statistics-table.php RENAMED
@@ -3,7 +3,7 @@
3
  * Top 10 Display statistics page.
4
  *
5
  * @package Top_Ten
6
- * @subpackage Top_Ten_Statistics
7
  * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
@@ -17,7 +17,7 @@ if ( ! defined( 'WPINC' ) ) {
17
 
18
 
19
  if ( ! class_exists( 'WP_List_Table' ) ) {
20
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
21
  }
22
 
23
  /**
@@ -31,10 +31,12 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
31
  * Class constructor.
32
  */
33
  public function __construct() {
34
- parent::__construct( array(
35
- 'singular' => __( 'popular_post', 'top-10' ), // Singular name of the listed records.
36
- 'plural' => __( 'popular_posts', 'top-10' ), // plural name of the listed records.
37
- ) );
 
 
38
  }
39
 
40
  /**
@@ -44,27 +46,27 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
44
  * @param int $page_number Page number.
45
  * @param array $args Array of arguments.
46
  *
47
- * @return array Array of popular posts
48
  */
49
  public static function get_popular_posts( $per_page = 5, $page_number = 1, $args = null ) {
50
 
51
- global $wpdb, $tptn_settings;
52
 
53
  $blog_id = get_current_blog_id();
54
 
55
- if ( $tptn_settings['daily_midnight'] ) {
56
  $current_time = current_time( 'timestamp', 0 );
57
- $from_date = $current_time - ( max( 0, ( $tptn_settings['daily_range'] - 1 ) ) * DAY_IN_SECONDS );
58
- $from_date = gmdate( 'Y-m-d 0' , $from_date );
59
  } else {
60
  $current_time = current_time( 'timestamp', 0 );
61
- $from_date = $current_time - ( $tptn_settings['daily_range'] * DAY_IN_SECONDS + $tptn_settings['hour_range'] * HOUR_IN_SECONDS );
62
- $from_date = gmdate( 'Y-m-d H' , $from_date );
63
  }
64
 
65
  /* Start creating the SQL */
66
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily AS ttd';
67
- $table_name = $wpdb->base_prefix . 'top_ten AS ttt';
68
 
69
  // Fields to return.
70
  $fields[] = 'ID';
@@ -78,28 +80,29 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
78
  $fields = implode( ', ', $fields );
79
 
80
  // Create the JOIN clause.
81
- $join = " INNER JOIN {$wpdb->posts} ON ttt.postnumber=ID ";
82
  $join .= $wpdb->prepare( // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
83
  " LEFT JOIN (
84
  SELECT * FROM {$table_name_daily}
85
- WHERE ttd.dp_date >= '%s'
86
  ) AS ttd
87
  ON ttt.postnumber=ttd.postnumber
88
- ", $from_date );
 
89
 
90
  // Create the base WHERE clause.
91
- $where = $wpdb->prepare( ' AND ttt.blog_id = %d ', $blog_id ); // Posts need to be from the current blog only.
92
  $where .= " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit') "; // Show published posts and attachments.
93
  $where .= " AND ($wpdb->posts.post_type <> 'revision' ) "; // No revisions.
94
 
95
  /* If search argument is set, do a search for it. */
96
  if ( isset( $args['search'] ) ) {
97
- $where .= $wpdb->prepare( " AND $wpdb->posts.post_title LIKE '%%%s%%' ", $args['search'] );
98
  }
99
 
100
  /* If post filter argument is set, do a search for it. */
101
  if ( isset( $args['post-type-filter'] ) && 'All' !== $args['post-type-filter'] ) {
102
- $where .= $wpdb->prepare( " AND $wpdb->posts.post_type = '%s' ", $args['post-type-filter'] );
103
  }
104
 
105
  // Create the base GROUP BY clause.
@@ -108,7 +111,7 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
108
  // Create the base ORDER BY clause.
109
  $orderby = ' total_count DESC ';
110
 
111
- if ( ! empty( $_REQUEST['orderby'] ) ) { // Input var okay.
112
  $orderby = sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) );
113
 
114
  if ( ! in_array( $orderby, array( 'title', 'daily_count', 'total_count' ) ) ) {
@@ -138,7 +141,7 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
138
 
139
  $sql = "SELECT $fields FROM {$table_name} $join WHERE 1=1 $where $groupby $orderby $limits";
140
 
141
- $result = $wpdb->get_results( $sql, 'ARRAY_A' );
142
 
143
  return $result;
144
 
@@ -155,12 +158,16 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
155
 
156
  $wpdb->delete(
157
  "{$wpdb->base_prefix}top_ten",
158
- array( 'postnumber' => $id ),
 
 
159
  array( '%d' )
160
  );
161
  $wpdb->delete(
162
  "{$wpdb->base_prefix}top_ten_daily",
163
- array( 'postnumber' => $id ),
 
 
164
  array( '%d' )
165
  );
166
  }
@@ -174,22 +181,24 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
174
  public static function record_count( $args = null ) {
175
  global $wpdb;
176
 
177
- $sql = $wpdb->prepare( "
 
178
  SELECT COUNT(*) FROM {$wpdb->base_prefix}top_ten as ttt
179
  INNER JOIN {$wpdb->posts} ON ttt.postnumber=ID
180
  WHERE blog_id=%d
181
  AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit')
182
- ", get_current_blog_id() );
 
183
 
184
  if ( isset( $args['search'] ) ) {
185
- $sql .= $wpdb->prepare( " AND $wpdb->posts.post_title LIKE '%%%s%%' ", $args['search'] );
186
  }
187
 
188
  if ( isset( $args['post-type-filter'] ) && 'All' !== $args['post-type-filter'] ) {
189
- $sql .= $wpdb->prepare( " AND $wpdb->posts.post_type = '%s' ", $args['post-type-filter'] );
190
  }
191
 
192
- return $wpdb->get_var( $sql );
193
  }
194
 
195
  /**
@@ -226,7 +235,7 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
226
  * @param array $item Current item.
227
  * @return string
228
  */
229
- function column_cb( $item ) {
230
  return sprintf(
231
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
232
  'bulk-delete',
@@ -240,18 +249,19 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
240
  * @param array $item Current item.
241
  * @return string
242
  */
243
- function column_title( $item ) {
244
 
245
  $delete_nonce = wp_create_nonce( 'tptn_delete_entry' );
246
 
247
  $actions = array(
248
- 'view' => sprintf( '<a href="%s" target="_blank">' . __( 'View', 'top-10' ) . '</a>', get_permalink( $item['ID'] ) ),
249
- 'edit' => sprintf( '<a href="%s">' . __( 'Edit', 'top-10' ) . '</a>', get_edit_post_link( $item['ID'] ) ),
250
  'delete' => sprintf( '<a href="?page=%s&action=%s&post=%s&_wpnonce=%s">' . __( 'Delete', 'top-10' ) . '</a>', esc_attr( $_REQUEST['page'] ), 'delete', absint( $item['ID'] ), $delete_nonce ),
251
  );
252
 
253
  // Return the title contents.
254
- return sprintf( '<a href="%4$s">%1$s</a> <span style="color:silver">(id:%2$s)</span>%3$s',
 
255
  $item['title'],
256
  $item['ID'],
257
  $this->row_actions( $actions ),
@@ -271,11 +281,12 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
271
 
272
  $t_time = get_the_time( __( 'Y/m/d g:i:s a', 'top-10' ) );
273
  $m_time = $item['post_date'];
274
- $time = get_post_time( 'G', true, $item['ID'] );
275
 
276
  $time_diff = time() - $time;
277
 
278
  if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
 
279
  $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
280
  } else {
281
  $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
@@ -294,11 +305,16 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
294
  $author_info = get_userdata( $item['post_author'] );
295
  $author_name = ( false === $author_info ) ? '' : ucwords( trim( stripslashes( $author_info->display_name ) ) );
296
 
297
- printf( '<a href="%s">%s</a>',
298
- esc_url( add_query_arg( array(
299
- 'post_type' => $item['post_type'],
300
- 'author' => ( false === $author_info ) ? 0 : $author_info->ID,
301
- ), 'edit.php' ) ),
 
 
 
 
 
302
  esc_html( $author_name )
303
  );
304
  }
@@ -308,15 +324,15 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
308
  *
309
  * @return array
310
  */
311
- function get_columns() {
312
  $columns = array(
313
- 'cb' => '<input type="checkbox" />',
314
- 'title' => __( 'Title', 'top-10' ),
315
- 'total_count' => __( 'Total visits', 'top-10' ),
316
- 'daily_count' => __( 'Daily visits', 'top-10' ),
317
- 'post_type' => __( 'Post type', 'top-10' ),
318
- 'author' => __( 'Author', 'top-10' ),
319
- 'date' => __( 'Date', 'top-10' ),
320
  );
321
 
322
  /**
@@ -324,7 +340,7 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
324
  *
325
  * @since 1.5.0
326
  *
327
- * @param array $columns An array of column names.
328
  */
329
  return apply_filters( 'manage_pop_posts_columns', $columns );
330
  }
@@ -336,7 +352,7 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
336
  */
337
  public function get_sortable_columns() {
338
  $sortable_columns = array(
339
- 'title' => array( 'title', false ),
340
  'total_count' => array( 'total_count', false ),
341
  'daily_count' => array( 'daily_count', false ),
342
  );
@@ -367,17 +383,19 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
367
  /** Process bulk action */
368
  $this->process_bulk_action();
369
 
370
- $per_page = $this->get_items_per_page( 'pop_posts_per_page', 20 );
371
 
372
  $current_page = $this->get_pagenum();
373
 
374
- $total_items = self::record_count( $args );
375
 
376
- $this->set_pagination_args( array(
377
- 'total_items' => $total_items, // WE have to calculate the total number of items
378
- 'per_page' => $per_page, // WE have to determine how many items to show on a page
379
- 'total_pages' => ceil( $total_items / $per_page ),// WE have to calculate the total number of pages
380
- ) );
 
 
381
 
382
  $this->items = self::get_popular_posts( $per_page, $current_page, $args );
383
  }
@@ -400,11 +418,11 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
400
 
401
  // If the delete bulk action is triggered.
402
  if ( ( isset( $_REQUEST['action'] ) && 'bulk-delete' === $_REQUEST['action'] )
403
- || ( isset( $_REQUEST['action2'] ) && 'bulk-delete' === $_REQUEST['action2'] )
404
  ) {
405
  $delete_ids = sanitize_text_field( wp_unslash( $_REQUEST['bulk-delete'] ) );
406
 
407
- // Loop over the array of record IDs and delete them,
408
  foreach ( $delete_ids as $id ) {
409
  self::delete_post_count( $id );
410
  }
@@ -421,8 +439,12 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
421
  <div class="alignleft actions">
422
  <?php
423
  if ( 'top' === $which ) {
424
- $post_types = get_post_types( array( 'public' => true ) );
425
- $all = array(
 
 
 
 
426
  'all' => 'All',
427
  );
428
  $post_types = $all + $post_types;
@@ -443,7 +465,11 @@ class Top_Ten_Statistics_Table extends WP_List_Table {
443
 
444
  echo '</select>';
445
 
446
- submit_button( __( 'Filter', 'top-10' ), 'button', 'filter_action', false, array( 'id' => 'top-10-query-submit' ) );
 
 
 
 
447
  }
448
  }
449
  ?>
@@ -459,11 +485,15 @@ class Top_Ten_Statistics {
459
 
460
  /**
461
  * Class instance.
 
 
462
  */
463
- static $instance;
464
 
465
  /**
466
  * WP_List_Table object.
 
 
467
  */
468
  public $pop_posts_obj;
469
 
@@ -482,7 +512,7 @@ class Top_Ten_Statistics {
482
  *
483
  * @param string $status Status of screen.
484
  * @param string $option Option name.
485
- * @param string $value Option value
486
  * @return string Value.
487
  */
488
  public static function set_screen( $status, $option, $value ) {
@@ -496,14 +526,14 @@ class Top_Ten_Statistics {
496
  $args = null;
497
  ?>
498
  <div class="wrap">
499
- <h1><?php printf( _x( '%s Popular Posts', 'Plugin name', 'top-10' ), 'Top 10' ); ?></h1>
500
 
501
  <div id="poststuff">
502
  <div id="post-body" class="metabox-holder columns-2">
503
  <div id="post-body-content">
504
  <div class="meta-box-sortables ui-sortable">
505
  <form method="get">
506
- <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ) ?>" />
507
  <?php
508
  // If this is a search?
509
  if ( isset( $_REQUEST['s'] ) ) {
@@ -525,7 +555,7 @@ class Top_Ten_Statistics {
525
  </div>
526
  <div id="postbox-container-1" class="postbox-container">
527
  <div id="side-sortables" class="meta-box-sortables ui-sortable">
528
- <?php tptn_admin_side(); ?>
529
  </div><!-- /side-sortables -->
530
  </div><!-- /postbox-container-1 -->
531
  </div><!-- /post-body -->
3
  * Top 10 Display statistics page.
4
  *
5
  * @package Top_Ten
6
+ * @subpackage Top_Ten_Statistics
7
  * @author Ajay D'Souza <me@ajaydsouza.com>
8
  * @license GPL-2.0+
9
  * @link https://webberzone.com
17
 
18
 
19
  if ( ! class_exists( 'WP_List_Table' ) ) {
20
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
21
  }
22
 
23
  /**
31
  * Class constructor.
32
  */
33
  public function __construct() {
34
+ parent::__construct(
35
+ array(
36
+ 'singular' => __( 'popular_post', 'top-10' ), // Singular name of the listed records.
37
+ 'plural' => __( 'popular_posts', 'top-10' ), // plural name of the listed records.
38
+ )
39
+ );
40
  }
41
 
42
  /**
46
  * @param int $page_number Page number.
47
  * @param array $args Array of arguments.
48
  *
49
+ * @return array Array of popular posts
50
  */
51
  public static function get_popular_posts( $per_page = 5, $page_number = 1, $args = null ) {
52
 
53
+ global $wpdb;
54
 
55
  $blog_id = get_current_blog_id();
56
 
57
+ if ( tptn_get_option( 'daily_midnight' ) ) {
58
  $current_time = current_time( 'timestamp', 0 );
59
+ $from_date = $current_time - ( max( 0, ( tptn_get_option( 'daily_range' ) - 1 ) ) * DAY_IN_SECONDS );
60
+ $from_date = gmdate( 'Y-m-d 0', $from_date );
61
  } else {
62
  $current_time = current_time( 'timestamp', 0 );
63
+ $from_date = $current_time - ( tptn_get_option( 'daily_range' ) * DAY_IN_SECONDS + tptn_get_option( 'hour_range' ) * HOUR_IN_SECONDS );
64
+ $from_date = gmdate( 'Y-m-d H', $from_date );
65
  }
66
 
67
  /* Start creating the SQL */
68
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily AS ttd';
69
+ $table_name = $wpdb->base_prefix . 'top_ten AS ttt';
70
 
71
  // Fields to return.
72
  $fields[] = 'ID';
80
  $fields = implode( ', ', $fields );
81
 
82
  // Create the JOIN clause.
83
+ $join = " INNER JOIN {$wpdb->posts} ON ttt.postnumber=ID ";
84
  $join .= $wpdb->prepare( // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
85
  " LEFT JOIN (
86
  SELECT * FROM {$table_name_daily}
87
+ WHERE ttd.dp_date >= %s
88
  ) AS ttd
89
  ON ttt.postnumber=ttd.postnumber
90
+ ", $from_date
91
+ );
92
 
93
  // Create the base WHERE clause.
94
+ $where = $wpdb->prepare( ' AND ttt.blog_id = %d ', $blog_id ); // Posts need to be from the current blog only.
95
  $where .= " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit') "; // Show published posts and attachments.
96
  $where .= " AND ($wpdb->posts.post_type <> 'revision' ) "; // No revisions.
97
 
98
  /* If search argument is set, do a search for it. */
99
  if ( isset( $args['search'] ) ) {
100
+ $where .= $wpdb->prepare( " AND $wpdb->posts.post_title LIKE %s ", '%' . $wpdb->esc_like( $args['search'] ) . '%' );
101
  }
102
 
103
  /* If post filter argument is set, do a search for it. */
104
  if ( isset( $args['post-type-filter'] ) && 'All' !== $args['post-type-filter'] ) {
105
+ $where .= $wpdb->prepare( " AND $wpdb->posts.post_type = %s ", $args['post-type-filter'] );
106
  }
107
 
108
  // Create the base GROUP BY clause.
111
  // Create the base ORDER BY clause.
112
  $orderby = ' total_count DESC ';
113
 
114
+ if ( ! empty( $_REQUEST['orderby'] ) ) { // WPCS: Input var okay.
115
  $orderby = sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) );
116
 
117
  if ( ! in_array( $orderby, array( 'title', 'daily_count', 'total_count' ) ) ) {
141
 
142
  $sql = "SELECT $fields FROM {$table_name} $join WHERE 1=1 $where $groupby $orderby $limits";
143
 
144
+ $result = $wpdb->get_results( $sql, 'ARRAY_A' ); // WPCS: Unprepared SQL OK.
145
 
146
  return $result;
147
 
158
 
159
  $wpdb->delete(
160
  "{$wpdb->base_prefix}top_ten",
161
+ array(
162
+ 'postnumber' => $id,
163
+ ),
164
  array( '%d' )
165
  );
166
  $wpdb->delete(
167
  "{$wpdb->base_prefix}top_ten_daily",
168
+ array(
169
+ 'postnumber' => $id,
170
+ ),
171
  array( '%d' )
172
  );
173
  }
181
  public static function record_count( $args = null ) {
182
  global $wpdb;
183
 
184
+ $sql = $wpdb->prepare(
185
+ "
186
  SELECT COUNT(*) FROM {$wpdb->base_prefix}top_ten as ttt
187
  INNER JOIN {$wpdb->posts} ON ttt.postnumber=ID
188
  WHERE blog_id=%d
189
  AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit')
190
+ ", get_current_blog_id()
191
+ );
192
 
193
  if ( isset( $args['search'] ) ) {
194
+ $sql .= $wpdb->prepare( " AND $wpdb->posts.post_title LIKE %s ", '%' . $wpdb->esc_like( $args['search'] ) . '%' );
195
  }
196
 
197
  if ( isset( $args['post-type-filter'] ) && 'All' !== $args['post-type-filter'] ) {
198
+ $sql .= $wpdb->prepare( " AND $wpdb->posts.post_type = %s ", $args['post-type-filter'] );
199
  }
200
 
201
+ return $wpdb->get_var( $sql ); // WPCS: Unprepared SQL OK.
202
  }
203
 
204
  /**
235
  * @param array $item Current item.
236
  * @return string
237
  */
238
+ public function column_cb( $item ) {
239
  return sprintf(
240
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
241
  'bulk-delete',
249
  * @param array $item Current item.
250
  * @return string
251
  */
252
+ public function column_title( $item ) {
253
 
254
  $delete_nonce = wp_create_nonce( 'tptn_delete_entry' );
255
 
256
  $actions = array(
257
+ 'view' => sprintf( '<a href="%s" target="_blank">' . __( 'View', 'top-10' ) . '</a>', get_permalink( $item['ID'] ) ),
258
+ 'edit' => sprintf( '<a href="%s">' . __( 'Edit', 'top-10' ) . '</a>', get_edit_post_link( $item['ID'] ) ),
259
  'delete' => sprintf( '<a href="?page=%s&action=%s&post=%s&_wpnonce=%s">' . __( 'Delete', 'top-10' ) . '</a>', esc_attr( $_REQUEST['page'] ), 'delete', absint( $item['ID'] ), $delete_nonce ),
260
  );
261
 
262
  // Return the title contents.
263
+ return sprintf(
264
+ '<a href="%4$s">%1$s</a> <span style="color:silver">(id:%2$s)</span>%3$s',
265
  $item['title'],
266
  $item['ID'],
267
  $this->row_actions( $actions ),
281
 
282
  $t_time = get_the_time( __( 'Y/m/d g:i:s a', 'top-10' ) );
283
  $m_time = $item['post_date'];
284
+ $time = get_post_time( 'G', true, $item['ID'] );
285
 
286
  $time_diff = time() - $time;
287
 
288
  if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
289
+ /* translators: 1. Human time difference. */
290
  $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
291
  } else {
292
  $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
305
  $author_info = get_userdata( $item['post_author'] );
306
  $author_name = ( false === $author_info ) ? '' : ucwords( trim( stripslashes( $author_info->display_name ) ) );
307
 
308
+ printf(
309
+ '<a href="%s">%s</a>',
310
+ esc_url(
311
+ add_query_arg(
312
+ array(
313
+ 'post_type' => $item['post_type'],
314
+ 'author' => ( false === $author_info ) ? 0 : $author_info->ID,
315
+ ), 'edit.php'
316
+ )
317
+ ),
318
  esc_html( $author_name )
319
  );
320
  }
324
  *
325
  * @return array
326
  */
327
+ public function get_columns() {
328
  $columns = array(
329
+ 'cb' => '<input type="checkbox" />',
330
+ 'title' => __( 'Title', 'top-10' ),
331
+ 'total_count' => __( 'Total visits', 'top-10' ),
332
+ 'daily_count' => __( 'Daily visits', 'top-10' ),
333
+ 'post_type' => __( 'Post type', 'top-10' ),
334
+ 'author' => __( 'Author', 'top-10' ),
335
+ 'date' => __( 'Date', 'top-10' ),
336
  );
337
 
338
  /**
340
  *
341
  * @since 1.5.0
342
  *
343
+ * @param array $columns An array of column names.
344
  */
345
  return apply_filters( 'manage_pop_posts_columns', $columns );
346
  }
352
  */
353
  public function get_sortable_columns() {
354
  $sortable_columns = array(
355
+ 'title' => array( 'title', false ),
356
  'total_count' => array( 'total_count', false ),
357
  'daily_count' => array( 'daily_count', false ),
358
  );
383
  /** Process bulk action */
384
  $this->process_bulk_action();
385
 
386
+ $per_page = $this->get_items_per_page( 'pop_posts_per_page', 20 );
387
 
388
  $current_page = $this->get_pagenum();
389
 
390
+ $total_items = self::record_count( $args );
391
 
392
+ $this->set_pagination_args(
393
+ array(
394
+ 'total_items' => $total_items, // WE have to calculate the total number of items.
395
+ 'per_page' => $per_page, // WE have to determine how many items to show on a page.
396
+ 'total_pages' => ceil( $total_items / $per_page ), // WE have to calculate the total number of pages.
397
+ )
398
+ );
399
 
400
  $this->items = self::get_popular_posts( $per_page, $current_page, $args );
401
  }
418
 
419
  // If the delete bulk action is triggered.
420
  if ( ( isset( $_REQUEST['action'] ) && 'bulk-delete' === $_REQUEST['action'] )
421
+ || ( isset( $_REQUEST['action2'] ) && 'bulk-delete' === $_REQUEST['action2'] )
422
  ) {
423
  $delete_ids = sanitize_text_field( wp_unslash( $_REQUEST['bulk-delete'] ) );
424
 
425
+ // Loop over the array of record IDs and delete them.
426
  foreach ( $delete_ids as $id ) {
427
  self::delete_post_count( $id );
428
  }
439
  <div class="alignleft actions">
440
  <?php
441
  if ( 'top' === $which ) {
442
+ $post_types = get_post_types(
443
+ array(
444
+ 'public' => true,
445
+ )
446
+ );
447
+ $all = array(
448
  'all' => 'All',
449
  );
450
  $post_types = $all + $post_types;
465
 
466
  echo '</select>';
467
 
468
+ submit_button(
469
+ __( 'Filter', 'top-10' ), 'button', 'filter_action', false, array(
470
+ 'id' => 'top-10-query-submit',
471
+ )
472
+ );
473
  }
474
  }
475
  ?>
485
 
486
  /**
487
  * Class instance.
488
+ *
489
+ * @var class Class instance.
490
  */
491
+ public static $instance;
492
 
493
  /**
494
  * WP_List_Table object.
495
+ *
496
+ * @var object WP_List_Table object.
497
  */
498
  public $pop_posts_obj;
499
 
512
  *
513
  * @param string $status Status of screen.
514
  * @param string $option Option name.
515
+ * @param string $value Option value.
516
  * @return string Value.
517
  */
518
  public static function set_screen( $status, $option, $value ) {
526
  $args = null;
527
  ?>
528
  <div class="wrap">
529
+ <h1><?php esc_html_e( 'Top 10 Popular Posts', 'top-10' ); ?></h1>
530
 
531
  <div id="poststuff">
532
  <div id="post-body" class="metabox-holder columns-2">
533
  <div id="post-body-content">
534
  <div class="meta-box-sortables ui-sortable">
535
  <form method="get">
536
+ <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
537
  <?php
538
  // If this is a search?
539
  if ( isset( $_REQUEST['s'] ) ) {
555
  </div>
556
  <div id="postbox-container-1" class="postbox-container">
557
  <div id="side-sortables" class="meta-box-sortables ui-sortable">
558
+ <?php include_once 'sidebar.php'; ?>
559
  </div><!-- /side-sortables -->
560
  </div><!-- /postbox-container-1 -->
561
  </div><!-- /post-body -->
includes/admin/help-tab.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Help tab.
4
+ *
5
+ * Functions to generated the help tab on the Settings page.
6
+ *
7
+ * @link https://webberzone.com
8
+ * @since 2.5.0
9
+ *
10
+ * @package Top 10
11
+ * @subpackage Admin/Help
12
+ */
13
+
14
+ // If this file is called directly, abort.
15
+ if ( ! defined( 'WPINC' ) ) {
16
+ die;
17
+ }
18
+
19
+ /**
20
+ * Generates the settings help page.
21
+ *
22
+ * @since 2.5.0
23
+ */
24
+ function tptn_settings_help() {
25
+ global $tptn_settings_page;
26
+
27
+ $screen = get_current_screen();
28
+
29
+ if ( $screen->id !== $tptn_settings_page ) {
30
+ return;
31
+ }
32
+
33
+ $screen->set_help_sidebar(
34
+ /* translators: 1: Support link. */
35
+ '<p>' . sprintf( __( 'For more information or how to get support visit the <a href="%1$s">WebberZone support site</a>.', 'top-10' ), esc_url( 'https://webberzone.com/support/' ) ) . '</p>' .
36
+ /* translators: 1: Forum link. */
37
+ '<p>' . sprintf( __( 'Support queries should be posted in the <a href="%1$s">WordPress.org support forums</a>.', 'top-10' ), esc_url( 'https://wordpress.org/support/plugin/top-10' ) ) . '</p>' .
38
+ '<p>' . sprintf(
39
+ /* translators: 1: Github Issues link, 2: Github page. */
40
+ __( '<a href="%1$s">Post an issue</a> on <a href="%2$s">GitHub</a> (bug reports only).', 'top-10' ),
41
+ esc_url( 'https://github.com/WebberZone/top-10/issues' ),
42
+ esc_url( 'https://github.com/WebberZone/top-10' )
43
+ ) . '</p>'
44
+ );
45
+
46
+ $screen->add_help_tab(
47
+ array(
48
+ 'id' => 'tptn-settings-general',
49
+ 'title' => __( 'General', 'top-10' ),
50
+ 'content' =>
51
+ '<p>' . __( 'This screen provides the basic settings for configuring Top 10.', 'top-10' ) . '</p>' .
52
+ '<p>' . __( 'Enable the trackers and cache, configure basic tracker settings and uninstall settings.', 'top-10' ) . '</p>',
53
+ )
54
+ );
55
+
56
+ $screen->add_help_tab(
57
+ array(
58
+ 'id' => 'tptn-settings-counter',
59
+ 'title' => __( 'Counter/Tracker', 'top-10' ),
60
+ 'content' =>
61
+ '<p>' . __( 'This screen provides settings to tweak the display counter and the tracker.', 'top-10' ) . '</p>' .
62
+ '<p>' . __( 'Choose where to display the counter and customize the text. Select the type of tracker and which user groups to track.', 'top-10' ) . '</p>',
63
+ )
64
+ );
65
+
66
+ $screen->add_help_tab(
67
+ array(
68
+ 'id' => 'tptn-settings-list',
69
+ 'title' => __( 'Posts list', 'top-10' ),
70
+ 'content' =>
71
+ '<p>' . __( 'This screen provides settings to tweak the output of the list of popular posts.', 'top-10' ) . '</p>' .
72
+ '<p>' . __( 'Set the number of posts, which categories or posts to exclude, customize what to display and specific basic HTML markup used to create the posts.', 'top-10' ) . '</p>',
73
+ )
74
+ );
75
+
76
+ $screen->add_help_tab(
77
+ array(
78
+ 'id' => 'tptn-settings-thumbnail',
79
+ 'title' => __( 'Thumbnail', 'top-10' ),
80
+ 'content' =>
81
+ '<p>' . __( 'This screen provides settings to tweak the thumbnail that can be displayed for each post in the list.', 'top-10' ) . '</p>' .
82
+ '<p>' . __( 'Set the location and size of the thumbnail. Additionally, you can choose additional sources for the thumbnail i.e. a meta field, first image or a default thumbnail when nothing is available.', 'top-10' ) . '</p>',
83
+ )
84
+ );
85
+
86
+ $screen->add_help_tab(
87
+ array(
88
+ 'id' => 'tptn-settings-styles',
89
+ 'title' => __( 'Styles', 'top-10' ),
90
+ 'content' =>
91
+ '<p>' . __( 'This screen provides options to control the look and feel of the popular posts list.', 'top-10' ) . '</p>' .
92
+ '<p>' . __( 'Choose for default set of styles or add your own custom CSS to tweak the display of the posts.', 'top-10' ) . '</p>',
93
+ )
94
+ );
95
+
96
+ $screen->add_help_tab(
97
+ array(
98
+ 'id' => 'tptn-settings-maintenance',
99
+ 'title' => __( 'Maintenance', 'top-10' ),
100
+ 'content' =>
101
+ '<p>' . __( 'This screen provides options to control the maintenance cron.', 'top-10' ) . '</p>' .
102
+ '<p>' . __( 'Choose how often to run maintenance and at what time of the day.', 'top-10' ) . '</p>',
103
+ )
104
+ );
105
+
106
+ do_action( 'tptn_settings_help', $screen );
107
+
108
+ }
109
+
110
+ /**
111
+ * Generates the Tools help page.
112
+ *
113
+ * @since 2.5.0
114
+ */
115
+ function tptn_settings_tools_help() {
116
+ global $tptn_settings_tools_help;
117
+
118
+ $screen = get_current_screen();
119
+
120
+ if ( $screen->id !== $tptn_settings_tools_help ) {
121
+ return;
122
+ }
123
+
124
+ $screen->set_help_sidebar(
125
+ /* translators: 1: Support link. */
126
+ '<p>' . sprintf( __( 'For more information or how to get support visit the <a href="%1$s">WebberZone support site</a>.', 'top-10' ), esc_url( 'https://webberzone.com/support/' ) ) . '</p>' .
127
+ /* translators: 1: Forum link. */
128
+ '<p>' . sprintf( __( 'Support queries should be posted in the <a href="%1$s">WordPress.org support forums</a>.', 'top-10' ), esc_url( 'https://wordpress.org/support/plugin/top-10' ) ) . '</p>' .
129
+ '<p>' . sprintf(
130
+ /* translators: 1: Github Issues link, 2: Github page. */
131
+ __( '<a href="%1$s">Post an issue</a> on <a href="%2$s">GitHub</a> (bug reports only).', 'top-10' ),
132
+ esc_url( 'https://github.com/WebberZone/top-10/issues' ),
133
+ esc_url( 'https://github.com/WebberZone/top-10' )
134
+ ) . '</p>'
135
+ );
136
+
137
+ $screen->add_help_tab(
138
+ array(
139
+ 'id' => 'tptn-settings-general',
140
+ 'title' => __( 'General', 'top-10' ),
141
+ 'content' =>
142
+ '<p>' . __( 'This screen provides some tools that help maintain certain features of Top 10.', 'top-10' ) . '</p>' .
143
+ '<p>' . __( 'Clear the cache, reset the popular posts tables plus some miscellaneous fixes for older versions of Top 10.', 'top-10' ) . '</p>',
144
+ )
145
+ );
146
+
147
+ do_action( 'tptn_settings_tools_help', $screen );
148
+ }
{admin → includes/admin}/images/fb.png RENAMED
File without changes
{admin → includes/admin}/images/index.php RENAMED
File without changes
{admin → includes/admin}/images/tptn-left-thumbs.png RENAMED
File without changes
{admin → includes/admin}/images/twitter.jpg RENAMED
File without changes
{admin → includes/admin}/index.php RENAMED
File without changes
includes/admin/register-settings.php ADDED
@@ -0,0 +1,1001 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Register settings.
4
+ *
5
+ * Functions to register, read, write and update settings.
6
+ * Portions of this code have been inspired by Easy Digital Downloads, WordPress Settings Sandbox, etc.
7
+ *
8
+ * @link https://webberzone.com
9
+ * @since 2.5.0
10
+ *
11
+ * @package Top 10
12
+ * @subpackage Admin/Register_Settings
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'WPINC' ) ) {
17
+ die;
18
+ }
19
+
20
+
21
+ /**
22
+ * Get an option
23
+ *
24
+ * Looks to see if the specified setting exists, returns default if not
25
+ *
26
+ * @since 2.5.0
27
+ *
28
+ * @param string $key Key of the option to fetch.
29
+ * @param mixed $default Default value to fetch if option is missing.
30
+ * @return mixed
31
+ */
32
+ function tptn_get_option( $key = '', $default = null ) {
33
+
34
+ global $tptn_settings;
35
+
36
+ if ( is_null( $default ) ) {
37
+ $default = tptn_get_default_option( $key );
38
+ }
39
+
40
+ $value = isset( $tptn_settings[ $key ] ) ? $tptn_settings[ $key ] : $default;
41
+
42
+ /**
43
+ * Filter the value for the option being fetched.
44
+ *
45
+ * @since 2.5.0
46
+ *
47
+ * @param mixed $value Value of the option
48
+ * @param mixed $key Name of the option
49
+ * @param mixed $default Default value
50
+ */
51
+ $value = apply_filters( 'tptn_get_option', $value, $key, $default );
52
+
53
+ /**
54
+ * Key specific filter for the value of the option being fetched.
55
+ *
56
+ * @since 2.5.0
57
+ *
58
+ * @param mixed $value Value of the option
59
+ * @param mixed $key Name of the option
60
+ * @param mixed $default Default value
61
+ */
62
+ return apply_filters( 'tptn_get_option_' . $key, $value, $key, $default );
63
+ }
64
+
65
+
66
+ /**
67
+ * Update an option
68
+ *
69
+ * Updates an tptn setting value in both the db and the global variable.
70
+ * Warning: Passing in an empty, false or null string value will remove
71
+ * the key from the tptn_options array.
72
+ *
73
+ * @since 2.5.0
74
+ *
75
+ * @param string $key The Key to update.
76
+ * @param string|bool|int $value The value to set the key to.
77
+ * @return boolean True if updated, false if not.
78
+ */
79
+ function tptn_update_option( $key = '', $value = false ) {
80
+
81
+ // If no key, exit.
82
+ if ( empty( $key ) ) {
83
+ return false;
84
+ }
85
+
86
+ // If no value, delete.
87
+ if ( empty( $value ) ) {
88
+ $remove_option = tptn_delete_option( $key );
89
+ return $remove_option;
90
+ }
91
+
92
+ // First let's grab the current settings.
93
+ $options = get_option( 'tptn_settings' );
94
+
95
+ /**
96
+ * Filters the value before it is updated
97
+ *
98
+ * @since 2.5.0
99
+ *
100
+ * @param string|bool|int $value The value to set the key to
101
+ * @param string $key The Key to update
102
+ */
103
+ $value = apply_filters( 'tptn_update_option', $value, $key );
104
+
105
+ // Next let's try to update the value.
106
+ $options[ $key ] = $value;
107
+ $did_update = update_option( 'tptn_settings', $options );
108
+
109
+ // If it updated, let's update the global variable.
110
+ if ( $did_update ) {
111
+ global $tptn_settings;
112
+ $tptn_settings[ $key ] = $value;
113
+ }
114
+ return $did_update;
115
+ }
116
+
117
+
118
+ /**
119
+ * Remove an option
120
+ *
121
+ * Removes an tptn setting value in both the db and the global variable.
122
+ *
123
+ * @since 2.5.0
124
+ *
125
+ * @param string $key The Key to update.
126
+ * @return boolean True if updated, false if not.
127
+ */
128
+ function tptn_delete_option( $key = '' ) {
129
+
130
+ // If no key, exit.
131
+ if ( empty( $key ) ) {
132
+ return false;
133
+ }
134
+
135
+ // First let's grab the current settings.
136
+ $options = get_option( 'tptn_settings' );
137
+
138
+ // Next let's try to update the value.
139
+ if ( isset( $options[ $key ] ) ) {
140
+ unset( $options[ $key ] );
141
+ }
142
+
143
+ $did_update = update_option( 'tptn_settings', $options );
144
+
145
+ // If it updated, let's update the global variable.
146
+ if ( $did_update ) {
147
+ global $tptn_settings;
148
+ $tptn_settings = $options;
149
+ }
150
+ return $did_update;
151
+ }
152
+
153
+
154
+ /**
155
+ * Register settings function
156
+ *
157
+ * @since 2.5.0
158
+ *
159
+ * @return void
160
+ */
161
+ function tptn_register_settings() {
162
+
163
+ if ( false === get_option( 'tptn_settings' ) ) {
164
+ add_option( 'tptn_settings', tptn_settings_defaults() );
165
+ }
166
+
167
+ foreach ( tptn_get_registered_settings() as $section => $settings ) {
168
+
169
+ add_settings_section(
170
+ 'tptn_settings_' . $section, // ID used to identify this section and with which to register options, e.g. tptn_settings_general.
171
+ __return_null(), // No title, we will handle this via a separate function.
172
+ '__return_false', // No callback function needed. We'll process this separately.
173
+ 'tptn_settings_' . $section // Page on which these options will be added.
174
+ );
175
+
176
+ foreach ( $settings as $setting ) {
177
+
178
+ $args = wp_parse_args(
179
+ $setting, array(
180
+ 'section' => $section,
181
+ 'id' => null,
182
+ 'name' => '',
183
+ 'desc' => '',
184
+ 'type' => null,
185
+ 'options' => '',
186
+ 'max' => null,
187
+ 'min' => null,
188
+ 'step' => null,
189
+ 'size' => null,
190
+ 'field_class' => '',
191
+ 'field_attributes' => '',
192
+ 'placeholder' => '',
193
+ )
194
+ );
195
+
196
+ add_settings_field(
197
+ 'tptn_settings[' . $args['id'] . ']', // ID of the settings field. We save it within the tptn_settings array.
198
+ $args['name'], // Label of the setting.
199
+ function_exists( 'tptn_' . $args['type'] . '_callback' ) ? 'tptn_' . $args['type'] . '_callback' : 'tptn_missing_callback', // Function to handle the setting.
200
+ 'tptn_settings_' . $section, // Page to display the setting. In our case it is the section as defined above.
201
+ 'tptn_settings_' . $section, // Name of the section.
202
+ $args
203
+ );
204
+ }
205
+ }
206
+
207
+ // Register the settings into the options table.
208
+ register_setting( 'tptn_settings', 'tptn_settings', 'tptn_settings_sanitize' );
209
+ }
210
+ add_action( 'admin_init', 'tptn_register_settings' );
211
+
212
+
213
+ /**
214
+ * Retrieve the array of plugin settings
215
+ *
216
+ * @since 2.5.0
217
+ *
218
+ * @return array Settings array
219
+ */
220
+ function tptn_get_registered_settings() {
221
+
222
+ $tptn_settings = array(
223
+ /*** General settings */
224
+ 'general' => apply_filters(
225
+ 'tptn_settings_general', array(
226
+ 'trackers' => array(
227
+ 'id' => 'trackers',
228
+ 'name' => esc_html__( 'Enable trackers', 'top-10' ),
229
+ /* translators: 1: Code. */
230
+ 'desc' => '',
231
+ 'type' => 'multicheck',
232
+ 'default' => array(
233
+ 'overall' => 'overall',
234
+ 'daily' => 'daily',
235
+ ),
236
+ 'options' => array(
237
+ 'overall' => esc_html__( 'Overall', 'top-10' ),
238
+ 'daily' => esc_html__( 'Daily', 'top-10' ),
239
+ ),
240
+ ),
241
+ 'cache' => array(
242
+ 'id' => 'cache',
243
+ 'name' => esc_html__( 'Enable cache', 'top-10' ),
244
+ 'desc' => esc_html__( 'If activated, Top 10 will use the Transients API to cache the popular posts output for 1 hour.', 'top-10' ),
245
+ 'type' => 'checkbox',
246
+ 'options' => false,
247
+ ),
248
+ 'cache_time' => array(
249
+ 'id' => 'cache_time',
250
+ 'name' => esc_html__( 'Time to cache', 'top-10' ),
251
+ 'desc' => esc_html__( 'Enter the number of seconds to cache the output.', 'top-10' ),
252
+ 'type' => 'text',
253
+ 'options' => HOUR_IN_SECONDS,
254
+ ),
255
+ 'daily_midnight' => array(
256
+ 'id' => 'daily_midnight',
257
+ 'name' => esc_html__( 'Start daily counts from midnight', 'top-10' ),
258
+ 'desc' => esc_html__( 'Daily counter will display number of visits from midnight. This option is checked by default and mimics the way most normal counters work. Turning this off will allow you to use the hourly setting in the next option.', 'top-10' ),
259
+ 'type' => 'checkbox',
260
+ 'options' => true,
261
+ ),
262
+ 'range_desc' => array(
263
+ 'id' => 'range_desc',
264
+ 'name' => '<strong>' . esc_html__( 'Default custom period range', 'top-10' ) . '</strong>',
265
+ 'desc' => esc_html__( 'The next two options allow you to set the default range for the custom period. This was previously called the daily range. This can be overridden in the widget.', 'top-10' ),
266
+ 'type' => 'descriptive_text',
267
+ ),
268
+ 'daily_range' => array(
269
+ 'id' => 'daily_range',
270
+ 'name' => esc_html__( 'Day(s)', 'top-10' ),
271
+ 'desc' => '',
272
+ 'type' => 'number',
273
+ 'options' => '1',
274
+ 'min' => '0',
275
+ 'size' => 'small',
276
+ ),
277
+ 'hour_range' => array(
278
+ 'id' => 'hour_range',
279
+ 'name' => esc_html__( 'Hour(s)', 'top-10' ),
280
+ 'desc' => '',
281
+ 'type' => 'number',
282
+ 'options' => '0',
283
+ 'min' => '0',
284
+ 'max' => '23',
285
+ 'size' => 'small',
286
+ ),
287
+ 'uninstall_clean_options' => array(
288
+ 'id' => 'uninstall_clean_options',
289
+ 'name' => esc_html__( 'Delete options on uninstall', 'top-10' ),
290
+ 'desc' => esc_html__( 'If this is checked, all settings related to Top 10 are removed from the database if you choose to uninstall/delete the plugin.', 'top-10' ),
291
+ 'type' => 'checkbox',
292
+ 'options' => true,
293
+ ),
294
+ 'uninstall_clean_tables' => array(
295
+ 'id' => 'uninstall_clean_tables',
296
+ 'name' => esc_html__( 'Delete counter data on uninstall', 'top-10' ),
297
+ 'desc' => esc_html__( 'If this is checked, the tables containing the counter statistics are removed from the database if you choose to uninstall/delete the plugin. Keep this unchecked if you choose to reinstall the plugin and do not want to lose your counter data.', 'top-10' ),
298
+ 'type' => 'checkbox',
299
+ 'options' => false,
300
+ ),
301
+ 'show_metabox' => array(
302
+ 'id' => 'show_metabox',
303
+ 'name' => esc_html__( 'Show metabox', 'top-10' ),
304
+ 'desc' => esc_html__( 'This will add the Top 10 metabox on Edit Posts or Add New Posts screens. Also applies to Pages and Custom Post Types.', 'top-10' ),
305
+ 'type' => 'checkbox',
306
+ 'options' => true,
307
+ ),
308
+ 'show_metabox_admins' => array(
309
+ 'id' => 'show_metabox_admins',
310
+ 'name' => esc_html__( 'Limit meta box to Admins only', 'top-10' ),
311
+ 'desc' => esc_html__( 'If selected, the meta box will be hidden from anyone who is not an Admin. By default, Contributors and above will be able to see the meta box. Applies only if the above option is selected.', 'top-10' ),
312
+ 'type' => 'checkbox',
313
+ 'options' => false,
314
+ ),
315
+ 'show_credit' => array(
316
+ 'id' => 'show_credit',
317
+ 'name' => esc_html__( 'Link to Top 10 plugin page', 'top-10' ),
318
+ 'desc' => esc_html__( 'A no-follow link to the plugin homepage will be added as the last item of the popular posts.', 'top-10' ),
319
+ 'type' => 'checkbox',
320
+ 'options' => false,
321
+ ),
322
+ )
323
+ ),
324
+ /*** Output settings */
325
+ 'counter' => apply_filters(
326
+ 'tptn_settings_counter', array(
327
+ 'add_to' => array(
328
+ 'id' => 'add_to',
329
+ 'name' => esc_html__( 'Display number of views on', 'top-10' ) . ':',
330
+ /* translators: 1: Code. */
331
+ 'desc' => sprintf( esc_html__( 'If you choose to disable this, please add %1$s to your template file where you want it displayed', 'top-10' ), "<code>&lt;?php if ( function_exists( 'echo_tptn_post_count' ) ) { echo_tptn_post_count(); } ?&gt;</code>" ),
332
+ 'type' => 'multicheck',
333
+ 'default' => array(
334
+ 'single' => 'single',
335
+ 'page' => 'page',
336
+ ),
337
+ 'options' => array(
338
+ 'single' => esc_html__( 'Posts', 'top-10' ),
339
+ 'page' => esc_html__( 'Pages', 'top-10' ),
340
+ 'home' => esc_html__( 'Home page', 'top-10' ),
341
+ 'feed' => esc_html__( 'Feeds', 'top-10' ),
342
+ 'category_archives' => esc_html__( 'Category archives', 'top-10' ),
343
+ 'tag_archives' => esc_html__( 'Tag archives', 'top-10' ),
344
+ 'other_archives' => esc_html__( 'Other archives', 'top-10' ),
345
+ ),
346
+ ),
347
+ 'count_disp_form' => array(
348
+ 'id' => 'count_disp_form',
349
+ 'name' => esc_html__( 'Format to display the post views', 'top-10' ),
350
+ /* translators: 1: Opening a tag, 2: Closing a tag, 3: Opening code tage, 4. Closing code tag. */
351
+ 'desc' => sprintf( esc_html__( 'Use %1$s to display the total count, %2$s for daily count and %3$s for overall counts across all posts. Default display is %4$s', 'top-10' ), '<code>%totalcount%</code>', '<code>%dailycount%</code>', '<code>%overallcount%</code>', '<code>(Visited %totalcount% times, %dailycount% visits today)</code>' ),
352
+ 'type' => 'textarea',
353
+ 'options' => '(Visited %totalcount% times, %dailycount% visits today)',
354
+ ),
355
+ 'count_disp_form_zero' => array(
356
+ 'id' => 'count_disp_form_zero',
357
+ 'name' => esc_html__( 'What do display when there are no visits?', 'top-10' ),
358
+ /* translators: 1: Opening a tag, 2: Closing a tag, 3: Opening code tage, 4. Closing code tag. */
359
+ 'desc' => esc_html__( "This text applies only when there are 0 hits for the post and it isn't a single page. e.g. if you display post views on the homepage or archives then this text will be used. To override this, just enter the same text as above option.", 'top-10' ),
360
+ 'type' => 'textarea',
361
+ 'options' => 'No visits yet',
362
+ ),
363
+ 'dynamic_post_count' => array(
364
+ 'id' => 'dynamic_post_count',
365
+ 'name' => esc_html__( 'Always display latest post count', 'top-10' ),
366
+ 'desc' => esc_html__( 'This option uses JavaScript and will increase your page load time. Turn this off if you are not using caching plugins or are OK with displaying older cached counts.', 'top-10' ),
367
+ 'type' => 'checkbox',
368
+ 'options' => false,
369
+ ),
370
+ 'tracker_type' => array(
371
+ 'id' => 'tracker_type',
372
+ 'name' => esc_html__( 'Tracker type', 'top-10' ),
373
+ 'desc' => '',
374
+ 'type' => 'radiodesc',
375
+ 'default' => 'query_based',
376
+ 'options' => tptn_get_tracker_types(),
377
+ ),
378
+ 'track_users' => array(
379
+ 'id' => 'track_users',
380
+ 'name' => esc_html__( 'Track user groups', 'top-10' ) . ':',
381
+ 'desc' => esc_html__( 'Uncheck above to disable tracking if the current user falls into any one of these groups.', 'top-10' ),
382
+ 'type' => 'multicheck',
383
+ 'default' => array(
384
+ 'editors' => 'editors',
385
+ 'admins' => 'admins',
386
+ ),
387
+ 'options' => array(
388
+ 'authors' => esc_html__( 'Authors', 'top-10' ),
389
+ 'editors' => esc_html__( 'Editors', 'top-10' ),
390
+ 'admins' => esc_html__( 'Admins', 'top-10' ),
391
+ ),
392
+ ),
393
+ 'logged_in' => array(
394
+ 'id' => 'logged_in',
395
+ 'name' => esc_html__( 'Track logged-in users', 'top-10' ),
396
+ 'desc' => esc_html__( 'Uncheck to stop tracking logged in users. Only logged out visitors will be tracked if this is disabled. Unchecking this will override the above setting.', 'top-10' ),
397
+ 'type' => 'checkbox',
398
+ 'options' => true,
399
+ ),
400
+ 'pv_in_admin' => array(
401
+ 'id' => 'pv_in_admin',
402
+ 'name' => esc_html__( 'Page views in admin', 'top-10' ),
403
+ 'desc' => esc_html__( "Adds three columns called Total Views, Today's Views and Views to All Posts and All Pages. You can selectively disable these by pulling down the Screen Options from the top right of the respective screens.", 'top-10' ),
404
+ 'type' => 'checkbox',
405
+ 'options' => true,
406
+ ),
407
+ 'show_count_non_admins' => array(
408
+ 'id' => 'show_count_non_admins',
409
+ 'name' => esc_html__( 'Show views to non-admins', 'top-10' ),
410
+ 'desc' => esc_html__( "If you disable this then non-admins won't see the above columns or view the independent pages with the top posts.", 'top-10' ),
411
+ 'type' => 'checkbox',
412
+ 'options' => true,
413
+ ),
414
+ )
415
+ ),
416
+ /*** List settings */
417
+ 'list' => apply_filters(
418
+ 'tptn_settings_list', array(
419
+ 'limit' => array(
420
+ 'id' => 'limit',
421
+ 'name' => esc_html__( 'Number of posts to display', 'top-10' ),
422
+ 'desc' => esc_html__( 'Maximum number of posts that will be displayed in the list. This option is used if you don not specify the number of posts in the widget or shortcodes', 'top-10' ),
423
+ 'type' => 'number',
424
+ 'options' => '10',
425
+ 'size' => 'small',
426
+ ),
427
+ 'how_old' => array(
428
+ 'id' => 'how_old',
429
+ 'name' => esc_html__( 'Published age of posts', 'top-10' ),
430
+ 'desc' => esc_html__( 'This options allows you to only show posts that have been published within the above day range. Applies to both overall posts and daily posts lists. e.g. 365 days will only show posts published in the last year in the popular posts lists. Enter 0 for no restriction.', 'top-10' ),
431
+ 'type' => 'number',
432
+ 'options' => '0',
433
+ ),
434
+ 'post_types' => array(
435
+ 'id' => 'post_types',
436
+ 'name' => esc_html__( 'Post types to include', 'top-10' ),
437
+ 'desc' => esc_html__( 'Select which post types you want to include in the list of posts. This field can be overridden using a comma separated list of post types when using the manual display.', 'top-10' ),
438
+ 'type' => 'posttypes',
439
+ 'options' => 'post',
440
+ ),
441
+ 'exclude_post_ids' => array(
442
+ 'id' => 'exclude_post_ids',
443
+ 'name' => esc_html__( 'Post/page IDs to exclude', 'top-10' ),
444
+ 'desc' => esc_html__( 'Comma-separated list of post or page IDs to exclude from the list. e.g. 188,320,500', 'top-10' ),
445
+ 'type' => 'numbercsv',
446
+ 'options' => '',
447
+ ),
448
+ 'exclude_cat_slugs' => array(
449
+ 'id' => 'exclude_cat_slugs',
450
+ 'name' => esc_html__( 'Exclude Categories', 'top-10' ),
451
+ 'desc' => esc_html__( 'Comma separated list of category slugs. The field above has an autocomplete so simply start typing in the starting letters and it will prompt you with options. Does not support custom taxonomies.', 'top-10' ),
452
+ 'type' => 'csv',
453
+ 'options' => '',
454
+ 'size' => 'large',
455
+ 'field_class' => 'category_autocomplete',
456
+ 'field_attributes' => array(
457
+ 'data-wp-taxonomy' => 'category',
458
+ ),
459
+ ),
460
+ 'exclude_categories' => array(
461
+ 'id' => 'exclude_categories',
462
+ 'name' => esc_html__( 'Exclude category IDs', 'top-10' ),
463
+ 'desc' => esc_html__( 'This is a readonly field that is automatically populated based on the above input when the settings are saved. These might differ from the IDs visible in the Categories page which use the term_id. Top 10 uses the term_taxonomy_id which is unique to this taxonomy.', 'top-10' ),
464
+ 'type' => 'text',
465
+ 'options' => '',
466
+ 'readonly' => true,
467
+ ),
468
+ 'customize_output_header' => array(
469
+ 'id' => 'customize_output_header',
470
+ 'name' => '<h3>' . esc_html__( 'Customize the output', 'top-10' ) . '</h3>',
471
+ 'desc' => '',
472
+ 'type' => 'header',
473
+ ),
474
+ 'title' => array(
475
+ 'id' => 'title',
476
+ 'name' => esc_html__( 'Heading of posts', 'top-10' ),
477
+ 'desc' => esc_html__( 'Displayed before the list of the posts as a the master heading', 'top-10' ),
478
+ 'type' => 'text',
479
+ 'options' => '<h3>' . esc_html__( 'Popular posts:', 'top-10' ) . '</h3>',
480
+ 'size' => 'large',
481
+ ),
482
+ 'title_daily' => array(
483
+ 'id' => 'title_daily',
484
+ 'name' => esc_html__( 'Heading of posts for daily/custom period lists', 'top-10' ),
485
+ 'desc' => esc_html__( 'Displayed before the list of the posts as a the master heading', 'top-10' ),
486
+ 'type' => 'text',
487
+ 'options' => '<h3>' . esc_html__( 'Currently trending:', 'top-10' ) . '</h3>',
488
+ 'size' => 'large',
489
+ ),
490
+ 'blank_output' => array(
491
+ 'id' => 'blank_output',
492
+ 'name' => esc_html__( 'Show when no posts are found', 'top-10' ),
493
+ /* translators: 1: Code. */
494
+ 'desc' => sprintf( esc_html__( 'If you choose to disable this, please add %1$s to your template file where you want it displayed', 'top-10' ), "<code>&lt;?php if ( function_exists( 'echo_wherego' ) ) { echo_wherego(); } ?&gt;</code>" ),
495
+ 'type' => 'radio',
496
+ 'default' => 'blank',
497
+ 'options' => array(
498
+ 'blank' => esc_html__( 'Blank output', 'top-10' ),
499
+ 'custom_text' => esc_html__( 'Display custom text', 'top-10' ),
500
+ ),
501
+ ),
502
+ 'blank_output_text' => array(
503
+ 'id' => 'blank_output_text',
504
+ 'name' => esc_html__( 'Custom text', 'top-10' ),
505
+ 'desc' => esc_html__( 'Enter the custom text that will be displayed if the second option is selected above', 'top-10' ),
506
+ 'type' => 'textarea',
507
+ 'options' => esc_html__( 'No top posts yet', 'top-10' ),
508
+ ),
509
+ 'show_excerpt' => array(
510
+ 'id' => 'show_excerpt',
511
+ 'name' => esc_html__( 'Show post excerpt', 'top-10' ),
512
+ 'desc' => '',
513
+ 'type' => 'checkbox',
514
+ 'options' => false,
515
+ ),
516
+ 'excerpt_length' => array(
517
+ 'id' => 'excerpt_length',
518
+ 'name' => esc_html__( 'Length of excerpt (in words)', 'top-10' ),
519
+ 'desc' => '',
520
+ 'type' => 'number',
521
+ 'options' => '10',
522
+ 'size' => 'small',
523
+ ),
524
+ 'show_date' => array(
525
+ 'id' => 'show_date',
526
+ 'name' => esc_html__( 'Show date', 'top-10' ),
527
+ 'desc' => '',
528
+ 'type' => 'checkbox',
529
+ 'options' => false,
530
+ ),
531
+ 'show_author' => array(
532
+ 'id' => 'show_author',
533
+ 'name' => esc_html__( 'Show author', 'top-10' ),
534
+ 'desc' => '',
535
+ 'type' => 'checkbox',
536
+ 'options' => false,
537
+ ),
538
+ 'disp_list_count' => array(
539
+ 'id' => 'disp_list_count',
540
+ 'name' => esc_html__( 'Show number of views', 'top-10' ),
541
+ 'desc' => '',
542
+ 'type' => 'checkbox',
543
+ 'options' => false,
544
+ ),
545
+ 'title_length' => array(
546
+ 'id' => 'title_length',
547
+ 'name' => esc_html__( 'Limit post title length (in characters)', 'top-10' ),
548
+ 'desc' => '',
549
+ 'type' => 'number',
550
+ 'options' => '60',
551
+ 'size' => 'small',
552
+ ),
553
+ 'link_new_window' => array(
554
+ 'id' => 'link_new_window',
555
+ 'name' => esc_html__( 'Open links in new window', 'top-10' ),
556
+ 'desc' => '',
557
+ 'type' => 'checkbox',
558
+ 'options' => false,
559
+ ),
560
+ 'link_nofollow' => array(
561
+ 'id' => 'link_nofollow',
562
+ 'name' => esc_html__( 'Add nofollow to links', 'top-10' ),
563
+ 'desc' => '',
564
+ 'type' => 'checkbox',
565
+ 'options' => false,
566
+ ),
567
+ 'exclude_on_post_ids' => array(
568
+ 'id' => 'exclude_on_post_ids',
569
+ 'name' => esc_html__( 'Exclude display on these post IDs', 'top-10' ),
570
+ 'desc' => esc_html__( 'Comma-separated list of post or page IDs to exclude displaying the top posts on. e.g. 188,320,500', 'top-10' ),
571
+ 'type' => 'numbercsv',
572
+ 'options' => '',
573
+ ),
574
+ 'html_wrapper_header' => array(
575
+ 'id' => 'html_wrapper_header',
576
+ 'name' => '<h3>' . esc_html__( 'HTML to display', 'top-10' ) . '</h3>',
577
+ 'desc' => '',
578
+ 'type' => 'header',
579
+ ),
580
+ 'before_list' => array(
581
+ 'id' => 'before_list',
582
+ 'name' => esc_html__( 'Before the list of posts', 'top-10' ),
583
+ 'desc' => '',
584
+ 'type' => 'text',
585
+ 'options' => '<ul>',
586
+ ),
587
+ 'after_list' => array(
588
+ 'id' => 'after_list',
589
+ 'name' => esc_html__( 'After the list of posts', 'top-10' ),
590
+ 'desc' => '',
591
+ 'type' => 'text',
592
+ 'options' => '</ul>',
593
+ ),
594
+ 'before_list_item' => array(
595
+ 'id' => 'before_list_item',
596
+ 'name' => esc_html__( 'Before each list item', 'top-10' ),
597
+ 'desc' => '',
598
+ 'type' => 'text',
599
+ 'options' => '<li>',
600
+ ),
601
+ 'after_list_item' => array(
602
+ 'id' => 'after_list_item',
603
+ 'name' => esc_html__( 'After each list item', 'top-10' ),
604
+ 'desc' => '',
605
+ 'type' => 'text',
606
+ 'options' => '</li>',
607
+ ),
608
+ )
609
+ ),
610
+ /*** Thumbnail settings */
611
+ 'thumbnail' => apply_filters(
612
+ 'tptn_settings_thumbnail', array(
613
+ 'post_thumb_op' => array(
614
+ 'id' => 'post_thumb_op',
615
+ 'name' => esc_html__( 'Location of the post thumbnail', 'top-10' ),
616
+ 'desc' => '',
617
+ 'type' => 'radio',
618
+ 'default' => 'text_only',
619
+ 'options' => array(
620
+ 'inline' => esc_html__( 'Display thumbnails inline with posts, before title', 'top-10' ),
621
+ 'after' => esc_html__( 'Display thumbnails inline with posts, after title', 'top-10' ),
622
+ 'thumbs_only' => esc_html__( 'Display only thumbnails, no text', 'top-10' ),
623
+ 'text_only' => esc_html__( 'Do not display thumbnails, only text', 'top-10' ),
624
+ ),
625
+ ),
626
+ 'thumb_size' => array(
627
+ 'id' => 'thumb_size',
628
+ 'name' => esc_html__( 'Thumbnail size', 'top-10' ),
629
+ /* translators: 1: OTF Regenerate plugin link, 2: Force regenerate plugin link. */
630
+ 'desc' => esc_html__( 'You can choose from existing image sizes above or create a custom size. If you have chosen Custom size above, then enter the width, height and crop settings below. For best results, use a cropped image. If you change the width and/or height below, existing images will not be automatically resized.' ) . '<br />' . sprintf( esc_html__( 'I recommend using %1$s or %2$s to regenerate all image sizes.', 'top-10' ), '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=otf-regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">OTF Regenerate Thumbnails</a>', '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550' ) ) . '" class="thickbox">Regenerate Thumbnails</a>' ),
631
+ 'type' => 'thumbsizes',
632
+ 'default' => 'tptn_thumbnail',
633
+ 'options' => tptn_get_all_image_sizes(),
634
+ ),
635
+ 'thumb_width' => array(
636
+ 'id' => 'thumb_width',
637
+ 'name' => esc_html__( 'Thumbnail width', 'top-10' ),
638
+ 'desc' => '',
639
+ 'type' => 'number',
640
+ 'options' => '250',
641
+ 'size' => 'small',
642
+ ),
643
+ 'thumb_height' => array(
644
+ 'id' => 'thumb_height',
645
+ 'name' => esc_html__( 'Thumbnail height', 'top-10' ),
646
+ 'desc' => '',
647
+ 'type' => 'number',
648
+ 'options' => '250',
649
+ 'size' => 'small',
650
+ ),
651
+ 'thumb_crop' => array(
652
+ 'id' => 'thumb_crop',
653
+ 'name' => esc_html__( 'Hard crop thumbnails', 'top-10' ),
654
+ 'desc' => esc_html__( 'Check this box to hard crop the thumbnails. i.e. force the width and height above vs. maintaining proportions.', 'top-10' ),
655
+ 'type' => 'checkbox',
656
+ 'options' => true,
657
+ ),
658
+ 'thumb_html' => array(
659
+ 'id' => 'thumb_html',
660
+ 'name' => esc_html__( 'Thumbnail size attributes', 'top-10' ),
661
+ 'desc' => '',
662
+ 'type' => 'radio',
663
+ 'default' => 'html',
664
+ 'options' => array(
665
+ /* translators: %s: Code. */
666
+ 'css' => sprintf( esc_html__( 'Use CSS to set the width and height: e.g. %s', 'top-10' ), '<code>style="max-width:250px;max-height:250px"</code>' ),
667
+ /* translators: %s: Code. */
668
+ 'html' => sprintf( esc_html__( 'Use HTML attributes to set the width and height: e.g. %s', 'top-10' ), '<code>width="250" height="250"</code>' ),
669
+ 'none' => esc_html__( 'No width or height set. You will need to use external styles to force any width or height of your choice.', 'top-10' ),
670
+ ),
671
+ ),
672
+ 'thumb_meta' => array(
673
+ 'id' => 'thumb_meta',
674
+ 'name' => esc_html__( 'Thumbnail meta field name', 'top-10' ),
675
+ 'desc' => esc_html__( 'The value of this field should contain the URL of the image and can be set in the metabox in the Edit Post screen', 'top-10' ),
676
+ 'type' => 'text',
677
+ 'options' => 'post-image',
678
+ ),
679
+ 'scan_images' => array(
680
+ 'id' => 'scan_images',
681
+ 'name' => esc_html__( 'Get first image', 'top-10' ),
682
+ 'desc' => esc_html__( 'The plugin will fetch the first image in the post content if this is enabled. This can slow down the loading of your page if the first image in the followed posts is large in file-size.', 'top-10' ),
683
+ 'type' => 'checkbox',
684
+ 'options' => true,
685
+ ),
686
+ 'thumb_default_show' => array(
687
+ 'id' => 'thumb_default_show',
688
+ 'name' => esc_html__( 'Use default thumbnail?', 'top-10' ),
689
+ 'desc' => esc_html__( 'If checked, when no thumbnail is found, show a default one from the URL below. If not checked and no thumbnail is found, no image will be shown.', 'top-10' ),
690
+ 'type' => 'checkbox',
691
+ 'options' => true,
692
+ ),
693
+ 'thumb_default' => array(
694
+ 'id' => 'thumb_default',
695
+ 'name' => esc_html__( 'Default thumbnail', 'top-10' ),
696
+ 'desc' => esc_html__( 'Enter the full URL of the image that you wish to display if no thumbnail is found. This image will be displayed below.', 'top-10' ),
697
+ 'type' => 'text',
698
+ 'options' => TOP_TEN_PLUGIN_URL . 'default.png',
699
+ 'size' => 'large',
700
+ ),
701
+ )
702
+ ),
703
+ /*** Styles settings */
704
+ 'styles' => apply_filters(
705
+ 'tptn_settings_styles', array(
706
+ 'tptn_styles' => array(
707
+ 'id' => 'tptn_styles',
708
+ 'name' => esc_html__( 'Popular posts style', 'top-10' ),
709
+ 'desc' => '',
710
+ 'type' => 'radiodesc',
711
+ 'default' => 'no_style',
712
+ 'options' => tptn_get_styles(),
713
+ ),
714
+ 'custom_CSS' => array(
715
+ 'id' => 'custom_CSS',
716
+ 'name' => esc_html__( 'Custom CSS', 'top-10' ),
717
+ /* translators: 1: Opening a tag, 2: Closing a tag, 3: Opening code tage, 4. Closing code tag. */
718
+ 'desc' => sprintf( esc_html__( 'Do not include %3$sstyle%4$s tags. Check out the %1$sFAQ%2$s for available CSS classes to style.', 'top-10' ), '<a href="' . esc_url( 'http://wordpress.org/plugins/top-10/faq/' ) . '" target="_blank">', '</a>', '<code>', '</code>' ),
719
+ 'type' => 'textarea',
720
+ 'options' => '',
721
+ ),
722
+ )
723
+ ),
724
+ /*** Maintenance settings */
725
+ 'maintenance' => apply_filters(
726
+ 'tptn_settings_maintenance', array(
727
+ 'cron_on' => array(
728
+ 'id' => 'cron_on',
729
+ 'name' => esc_html__( 'Enable scheduled maintenance', 'top-10' ),
730
+ 'desc' => esc_html__( 'Cleaning the database at regular intervals could improve performance, especially on high traffic blogs. Enabling maintenance will automatically delete entries older than 90 days in the daily tables.', 'top-10' ),
731
+ 'type' => 'checkbox',
732
+ 'options' => false,
733
+ ),
734
+ 'cron_range_desc' => array(
735
+ 'id' => 'cron_range_desc',
736
+ 'name' => '<strong>' . esc_html__( 'Time to run maintenance', 'top-10' ) . '</strong>',
737
+ 'desc' => esc_html__( 'The next two options allow you to set the time to run the cron.', 'top-10' ),
738
+ 'type' => 'descriptive_text',
739
+ ),
740
+ 'cron_hour' => array(
741
+ 'id' => 'cron_hour',
742
+ 'name' => esc_html__( 'Hour', 'top-10' ),
743
+ 'desc' => '',
744
+ 'type' => 'number',
745
+ 'options' => '0',
746
+ 'min' => '0',
747
+ 'max' => '23',
748
+ 'size' => 'small',
749
+ ),
750
+ 'cron_min' => array(
751
+ 'id' => 'cron_min',
752
+ 'name' => esc_html__( 'Minute', 'top-10' ),
753
+ 'desc' => '',
754
+ 'type' => 'number',
755
+ 'options' => '0',
756
+ 'min' => '0',
757
+ 'max' => '59',
758
+ 'size' => 'small',
759
+ ),
760
+ 'cron_recurrence' => array(
761
+ 'id' => 'cron_recurrence',
762
+ 'name' => esc_html__( 'Run maintenance', 'top-10' ),
763
+ 'desc' => '',
764
+ 'type' => 'radio',
765
+ 'default' => 'weekly',
766
+ 'options' => array(
767
+ 'daily' => esc_html__( 'Daily', 'top-10' ),
768
+ 'weekly' => esc_html__( 'Weekly', 'top-10' ),
769
+ 'fortnightly' => esc_html__( 'Fortnightly', 'top-10' ),
770
+ 'monthly' => esc_html__( 'Monthly', 'top-10' ),
771
+ ),
772
+ ),
773
+ )
774
+ ),
775
+ );
776
+
777
+ /**
778
+ * Filters the settings array
779
+ *
780
+ * @since 2.5.0
781
+ *
782
+ * @param array $tptn_setings Settings array
783
+ */
784
+ return apply_filters( 'tptn_registered_settings', $tptn_settings );
785
+
786
+ }
787
+
788
+
789
+
790
+ /**
791
+ * Flattens tptn_get_registered_settings() into $setting[id] => $setting[type] format.
792
+ *
793
+ * @since 2.5.0
794
+ *
795
+ * @return array Default settings
796
+ */
797
+ function tptn_get_registered_settings_types() {
798
+
799
+ $options = array();
800
+
801
+ // Populate some default values.
802
+ foreach ( tptn_get_registered_settings() as $tab => $settings ) {
803
+ foreach ( $settings as $option ) {
804
+ $options[ $option['id'] ] = $option['type'];
805
+ }
806
+ }
807
+
808
+ /**
809
+ * Filters the settings array.
810
+ *
811
+ * @since 2.5.0
812
+ *
813
+ * @param array $options Default settings.
814
+ */
815
+ return apply_filters( 'tptn_get_settings_types', $options );
816
+ }
817
+
818
+
819
+ /**
820
+ * Default settings.
821
+ *
822
+ * @since 2.5.0
823
+ *
824
+ * @return array Default settings
825
+ */
826
+ function tptn_settings_defaults() {
827
+
828
+ $options = array();
829
+
830
+ // Populate some default values.
831
+ foreach ( tptn_get_registered_settings() as $tab => $settings ) {
832
+ foreach ( $settings as $option ) {
833
+ // When checkbox is set to true, set this to 1.
834
+ if ( 'checkbox' === $option['type'] && ! empty( $option['options'] ) ) {
835
+ $options[ $option['id'] ] = 1;
836
+ } else {
837
+ $options[ $option['id'] ] = 0;
838
+ }
839
+ // If an option is set.
840
+ if ( in_array( $option['type'], array( 'textarea', 'text', 'csv', 'numbercsv', 'posttypes', 'number' ), true ) && isset( $option['options'] ) ) {
841
+ $options[ $option['id'] ] = $option['options'];
842
+ }
843
+ if ( in_array( $option['type'], array( 'multicheck', 'radio', 'select', 'radiodesc', 'thumbsizes' ), true ) && isset( $option['default'] ) ) {
844
+ $options[ $option['id'] ] = $option['default'];
845
+ }
846
+ }
847
+ }
848
+
849
+ $upgraded_settings = tptn_upgrade_settings();
850
+
851
+ if ( false !== $upgraded_settings ) {
852
+ $options = array_merge( $options, $upgraded_settings );
853
+ }
854
+
855
+ /**
856
+ * Filters the default settings array.
857
+ *
858
+ * @since 2.5.0
859
+ *
860
+ * @param array $options Default settings.
861
+ */
862
+ return apply_filters( 'tptn_settings_defaults', $options );
863
+ }
864
+
865
+
866
+ /**
867
+ * Get the default option for a specific key
868
+ *
869
+ * @since 2.5.0
870
+ *
871
+ * @param string $key Key of the option to fetch.
872
+ * @return mixed
873
+ */
874
+ function tptn_get_default_option( $key = '' ) {
875
+
876
+ $default_settings = tptn_settings_defaults();
877
+
878
+ if ( array_key_exists( $key, $default_settings ) ) {
879
+ return $default_settings[ $key ];
880
+ } else {
881
+ return false;
882
+ }
883
+
884
+ }
885
+
886
+
887
+ /**
888
+ * Reset settings.
889
+ *
890
+ * @since 2.5.0
891
+ *
892
+ * @return void
893
+ */
894
+ function tptn_settings_reset() {
895
+ delete_option( 'tptn_settings' );
896
+ }
897
+
898
+ /**
899
+ * Upgrade pre v2.5.0 settings.
900
+ *
901
+ * @since v2.5.0
902
+ * @return array Settings array
903
+ */
904
+ function tptn_upgrade_settings() {
905
+ $old_settings = get_option( 'ald_tptn_settings' );
906
+
907
+ if ( empty( $old_settings ) ) {
908
+ return false;
909
+ }
910
+
911
+ // Start will assigning all the old settings to the new settings and we will unset later on.
912
+ $settings = $old_settings;
913
+
914
+ // Convert the add_to_{x} to the new settings format.
915
+ $add_to = array(
916
+ 'single' => 'add_to_content',
917
+ 'page' => 'count_on_pages',
918
+ 'feed' => 'add_to_feed',
919
+ 'home' => 'add_to_home',
920
+ 'category_archives' => 'add_to_category_archives',
921
+ 'tag_archives' => 'add_to_tag_archives',
922
+ 'other_archives' => 'add_to_archives',
923
+ );
924
+
925
+ foreach ( $add_to as $newkey => $oldkey ) {
926
+ if ( $old_settings[ $oldkey ] ) {
927
+ $settings['add_to'][ $newkey ] = $newkey;
928
+ }
929
+ unset( $settings[ $oldkey ] );
930
+ }
931
+
932
+ // Convert the activate_overall and activate_daily to the new settings format.
933
+ $trackers = array(
934
+ 'overall' => 'activate_overall',
935
+ 'daily' => 'activate_daily',
936
+ );
937
+
938
+ foreach ( $trackers as $newkey => $oldkey ) {
939
+ if ( $old_settings[ $oldkey ] ) {
940
+ $settings['trackers'][ $newkey ] = $newkey;
941
+ }
942
+ unset( $settings[ $oldkey ] );
943
+ }
944
+
945
+ // Convert the track_{x} to the new settings format.
946
+ $track_users = array(
947
+ 'authors' => 'track_authors',
948
+ 'editors' => 'track_editors',
949
+ 'admins' => 'track_admins',
950
+ );
951
+
952
+ foreach ( $track_users as $newkey => $oldkey ) {
953
+ if ( $old_settings[ $oldkey ] ) {
954
+ $settings['track_users'][ $newkey ] = $newkey;
955
+ }
956
+ unset( $settings[ $oldkey ] );
957
+ }
958
+
959
+ // Convert 'blank_output' to the new format: true = 'blank' and false = 'custom_text'.
960
+ $settings['blank_output'] = ! empty( $old_settings['blank_output'] ) ? 'blank' : 'custom_text';
961
+
962
+ delete_option( 'ald_tptn_settings' );
963
+ return $settings;
964
+
965
+ }
966
+
967
+ /**
968
+ * Get the various styles.
969
+ *
970
+ * @since 2.5.0
971
+ * @return array Style options.
972
+ */
973
+ function tptn_get_styles() {
974
+
975
+ $styles = array(
976
+ array(
977
+ 'id' => 'no_style',
978
+ 'name' => esc_html__( 'No styles', 'top-10' ),
979
+ 'description' => esc_html__( 'Select this option if you plan to add your own styles', 'top-10' ) . '<br />',
980
+ ),
981
+ array(
982
+ 'id' => 'text_only',
983
+ 'name' => esc_html__( 'Text only', 'top-10' ),
984
+ 'description' => esc_html__( 'Disable thumbnails and no longer include the default style sheet included in the plugin', 'top-10' ) . '<br />',
985
+ ),
986
+ array(
987
+ 'id' => 'left_thumbs',
988
+ 'name' => esc_html__( 'Left thumbnails', 'top-10' ),
989
+ 'description' => '<br /><img src="' . esc_url( plugins_url( 'includes/admin/images/tptn-left-thumbs.png', TOP_TEN_PLUGIN_FILE ) ) . '" width="350" /> <br />' . esc_html__( 'Enabling this option will set the post thumbnail to be before text. Disabling this option will not revert any settings.', 'top-10' ),
990
+ ),
991
+ );
992
+
993
+ /**
994
+ * Filter the array containing the types of trackers to add your own.
995
+ *
996
+ * @since 2.5.0
997
+ *
998
+ * @param string $trackers Different trackers.
999
+ */
1000
+ return apply_filters( 'tptn_get_styles', $styles );
1001
+ }
includes/admin/save-settings.php ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Save settings.
4
+ *
5
+ * Functions to register, read, write and update settings.
6
+ * Portions of this code have been inspired by Easy Digital Downloads, WordPress Settings Sandbox, etc.
7
+ *
8
+ * @link https://webberzone.com
9
+ * @since 2.5.0
10
+ *
11
+ * @package Top 10
12
+ * @subpackage Admin/Save_Settings
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'WPINC' ) ) {
17
+ die;
18
+ }
19
+
20
+
21
+ /**
22
+ * Sanitize the form data being submitted.
23
+ *
24
+ * @since 2.5.0
25
+ * @param array $input Input unclean array.
26
+ * @return array Sanitized array
27
+ */
28
+ function tptn_settings_sanitize( $input = array() ) {
29
+
30
+ // First, we read the options collection.
31
+ global $tptn_settings;
32
+
33
+ // This should be set if a form is submitted, so let's save it in the $referrer variable.
34
+ if ( empty( $_POST['_wp_http_referer'] ) ) {
35
+ return $input;
36
+ }
37
+
38
+ parse_str( sanitize_text_field( wp_unslash( $_POST['_wp_http_referer'] ) ), $referrer ); // Input var okay.
39
+
40
+ // Get the various settings we've registered.
41
+ $settings = tptn_get_registered_settings();
42
+ $settings_types = tptn_get_registered_settings_types();
43
+
44
+ // Check if we need to set to defaults.
45
+ $reset = isset( $_POST['settings_reset'] );
46
+
47
+ if ( $reset ) {
48
+ tptn_settings_reset();
49
+ $tptn_settings = get_option( 'tptn_settings' );
50
+
51
+ add_settings_error( 'tptn-notices', '', __( 'Settings have been reset to their default values. Reload this page to view the updated settings', 'top-10' ), 'error' );
52
+
53
+ return $tptn_settings;
54
+ }
55
+
56
+ // Get the tab. This is also our settings' section.
57
+ $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
58
+
59
+ $input = $input ? $input : array();
60
+
61
+ /**
62
+ * Filter the settings for the tab. e.g. tptn_settings_general_sanitize.
63
+ *
64
+ * @since 2.5.0
65
+ * @param array $input Input unclean array
66
+ */
67
+ $input = apply_filters( 'tptn_settings_' . $tab . '_sanitize', $input );
68
+
69
+ // Create out output array by merging the existing settings with the ones submitted.
70
+ $output = array_merge( $tptn_settings, $input );
71
+
72
+ // Loop through each setting being saved and pass it through a sanitization filter.
73
+ foreach ( $settings_types as $key => $type ) {
74
+
75
+ /**
76
+ * Skip settings that are not really settings.
77
+ *
78
+ * @since 2.5.0
79
+ * @param array $non_setting_types Array of types which are not settings.
80
+ */
81
+ $non_setting_types = apply_filters( 'tptn_non_setting_types', array( 'header', 'descriptive_text' ) );
82
+
83
+ if ( in_array( $type, $non_setting_types, true ) ) {
84
+ continue;
85
+ }
86
+
87
+ if ( array_key_exists( $key, $output ) ) {
88
+
89
+ /**
90
+ * Field type filter.
91
+ *
92
+ * @since 2.5.0
93
+ * @param array $output[$key] Setting value.
94
+ * @param array $key Setting key.
95
+ */
96
+ $output[ $key ] = apply_filters( 'tptn_settings_sanitize_' . $type, $output[ $key ], $key );
97
+ }
98
+
99
+ /**
100
+ * Field type filter for a specific key.
101
+ *
102
+ * @since 2.5.0
103
+ * @param array $output[$key] Setting value.
104
+ * @param array $key Setting key.
105
+ */
106
+ $output[ $key ] = apply_filters( 'tptn_settings_sanitize' . $key, $output[ $key ], $key );
107
+
108
+ // Delete any key that is not present when we submit the input array.
109
+ if ( ! isset( $input[ $key ] ) ) {
110
+ unset( $output[ $key ] );
111
+ }
112
+ }
113
+
114
+ // Delete any settings that are no longer part of our registered settings.
115
+ if ( array_key_exists( $key, $output ) && ! array_key_exists( $key, $settings_types ) ) {
116
+ unset( $output[ $key ] );
117
+ }
118
+
119
+ add_settings_error( 'tptn-notices', '', __( 'Settings updated.', 'top-10' ), 'updated' );
120
+
121
+ /**
122
+ * Filter the settings array before it is returned.
123
+ *
124
+ * @since 2.5.0
125
+ * @param array $output Settings array.
126
+ * @param array $input Input settings array.
127
+ */
128
+ return apply_filters( 'tptn_settings_sanitize', $output, $input );
129
+
130
+ }
131
+
132
+
133
+ /**
134
+ * Sanitize text fields
135
+ *
136
+ * @since 2.5.0
137
+ *
138
+ * @param array $value The field value.
139
+ * @return string $value Sanitized value
140
+ */
141
+ function tptn_sanitize_text_field( $value ) {
142
+ return tptn_sanitize_textarea_field( $value );
143
+ }
144
+ add_filter( 'tptn_settings_sanitize_text', 'tptn_sanitize_text_field' );
145
+
146
+
147
+ /**
148
+ * Sanitize number fields
149
+ *
150
+ * @since 2.5.0
151
+ *
152
+ * @param array $value The field value.
153
+ * @return string $value Sanitized value
154
+ */
155
+ function tptn_sanitize_number_field( $value ) {
156
+ return filter_var( $value, FILTER_SANITIZE_NUMBER_INT );
157
+ }
158
+ add_filter( 'tptn_settings_sanitize_number', 'tptn_sanitize_number_field' );
159
+
160
+
161
+ /**
162
+ * Sanitize CSV fields
163
+ *
164
+ * @since 2.5.0
165
+ *
166
+ * @param array $value The field value.
167
+ * @return string $value Sanitized value
168
+ */
169
+ function tptn_sanitize_csv_field( $value ) {
170
+
171
+ return implode( ',', array_map( 'trim', explode( ',', sanitize_text_field( wp_unslash( $value ) ) ) ) );
172
+ }
173
+ add_filter( 'tptn_settings_sanitize_csv', 'tptn_sanitize_csv_field' );
174
+
175
+
176
+ /**
177
+ * Sanitize CSV fields which hold numbers e.g. IDs
178
+ *
179
+ * @since 2.5.0
180
+ *
181
+ * @param array $value The field value.
182
+ * @return string $value Sanitized value
183
+ */
184
+ function tptn_sanitize_numbercsv_field( $value ) {
185
+
186
+ return implode( ',', array_filter( array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $value ) ) ) ) ) );
187
+ }
188
+ add_filter( 'tptn_settings_sanitize_numbercsv', 'tptn_sanitize_numbercsv_field' );
189
+
190
+
191
+ /**
192
+ * Sanitize textarea fields
193
+ *
194
+ * @since 2.5.0
195
+ *
196
+ * @param array $value The field value.
197
+ * @return string $value Sanitized value
198
+ */
199
+ function tptn_sanitize_textarea_field( $value ) {
200
+
201
+ global $allowedposttags;
202
+
203
+ // We need more tags to allow for script and style.
204
+ $moretags = array(
205
+ 'script' => array(
206
+ 'type' => true,
207
+ 'src' => true,
208
+ 'async' => true,
209
+ 'defer' => true,
210
+ 'charset' => true,
211
+ 'lang' => true,
212
+ ),
213
+ 'style' => array(
214
+ 'type' => true,
215
+ 'media' => true,
216
+ 'scoped' => true,
217
+ 'lang' => true,
218
+ ),
219
+ 'link' => array(
220
+ 'rel' => true,
221
+ 'type' => true,
222
+ 'href' => true,
223
+ 'media' => true,
224
+ 'sizes' => true,
225
+ 'hreflang' => true,
226
+ ),
227
+ );
228
+
229
+ $allowedtags = array_merge( $allowedposttags, $moretags );
230
+
231
+ /**
232
+ * Filter allowed tags allowed when sanitizing text and textarea fields.
233
+ *
234
+ * @since 2.5.0
235
+ *
236
+ * @param array $allowedtags Allowed tags array.
237
+ * @param array $value The field value.
238
+ */
239
+ $allowedtags = apply_filters( 'tptn_sanitize_allowed_tags', $allowedtags, $value );
240
+
241
+ return wp_kses( wp_unslash( $value ), $allowedtags );
242
+
243
+ }
244
+ add_filter( 'tptn_settings_sanitize_textarea', 'tptn_sanitize_textarea_field' );
245
+
246
+
247
+ /**
248
+ * Sanitize checkbox fields
249
+ *
250
+ * @since 2.5.0
251
+ *
252
+ * @param array $value The field value.
253
+ * @return string|int $value Sanitized value
254
+ */
255
+ function tptn_sanitize_checkbox_field( $value ) {
256
+
257
+ $value = ( -1 === (int) $value ) ? 0 : 1;
258
+
259
+ return $value;
260
+ }
261
+ add_filter( 'tptn_settings_sanitize_checkbox', 'tptn_sanitize_checkbox_field' );
262
+
263
+
264
+ /**
265
+ * Sanitize post_types fields
266
+ *
267
+ * @since 2.5.0
268
+ *
269
+ * @param array $value The field value.
270
+ * @return string $value Sanitized value
271
+ */
272
+ function tptn_sanitize_posttypes_field( $value ) {
273
+
274
+ $post_types = is_array( $value ) ? array_map( 'sanitize_text_field', wp_unslash( $value ) ) : array( 'post', 'page' );
275
+
276
+ return implode( ',', $post_types );
277
+ }
278
+ add_filter( 'tptn_settings_sanitize_posttypes', 'tptn_sanitize_posttypes_field' );
279
+
280
+
281
+ /**
282
+ * Sanitize exclude_cat_slugs to save a new entry of exclude_categories
283
+ *
284
+ * @since 2.5.0
285
+ *
286
+ * @param array $settings Settings array.
287
+ * @return string $settings Sanitizied settings array.
288
+ */
289
+ function tptn_sanitize_exclude_cat( $settings ) {
290
+
291
+ if ( ! empty( $settings['exclude_cat_slugs'] ) ) {
292
+
293
+ $exclude_cat_slugs = explode( ',', $settings['exclude_cat_slugs'] );
294
+
295
+ foreach ( $exclude_cat_slugs as $cat_name ) {
296
+ $cat = get_term_by( 'name', $cat_name, 'category' );
297
+
298
+ // Fall back to slugs since that was the default format before v2.4.0.
299
+ if ( false === $cat ) {
300
+ $cat = get_term_by( 'slug', $cat_name, 'category' );
301
+ }
302
+ if ( isset( $cat->term_taxonomy_id ) ) {
303
+ $exclude_categories[] = $cat->term_taxonomy_id;
304
+ $exclude_categories_slugs[] = $cat->name;
305
+ }
306
+ }
307
+ $settings['exclude_categories'] = isset( $exclude_categories ) ? join( ',', $exclude_categories ) : '';
308
+ $settings['exclude_cat_slugs'] = isset( $exclude_categories_slugs ) ? join( ',', $exclude_categories_slugs ) : '';
309
+
310
+ }
311
+
312
+ return $settings;
313
+ }
314
+ add_filter( 'tptn_settings_sanitize', 'tptn_sanitize_exclude_cat' );
315
+
316
+
317
+ /**
318
+ * Enable/disable Top 10 cron on save.
319
+ *
320
+ * @since 2.5.0
321
+ *
322
+ * @param array $settings Settings array.
323
+ * @return string $settings Sanitizied settings array.
324
+ */
325
+ function tptn_sanitize_cron( $settings ) {
326
+
327
+ $settings['cron_hour'] = min( 23, absint( $settings['cron_hour'] ) );
328
+ $settings['cron_min'] = min( 59, absint( $settings['cron_min'] ) );
329
+
330
+ if ( ! empty( $settings['cron_on'] ) ) {
331
+ tptn_enable_run( $settings['cron_hour'], $settings['cron_min'], $settings['cron_recurrence'] );
332
+ } else {
333
+ tptn_disable_run();
334
+ }
335
+
336
+ return $settings;
337
+ }
338
+ add_filter( 'tptn_settings_sanitize', 'tptn_sanitize_cron' );
339
+
340
+
341
+ /**
342
+ * Delete cache when saving settings.
343
+ *
344
+ * @since 2.5.0
345
+ *
346
+ * @param array $settings Settings array.
347
+ * @return string $settings Sanitizied settings array.
348
+ */
349
+ function tptn_sanitize_cache( $settings ) {
350
+
351
+ // Delete the cache.
352
+ tptn_cache_delete();
353
+
354
+ return $settings;
355
+ }
356
+ add_filter( 'tptn_settings_sanitize', 'tptn_sanitize_cache' );
includes/admin/settings-page.php ADDED
@@ -0,0 +1,675 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Renders the settings page.
4
+ * Portions of this code have been inspired by Easy Digital Downloads, WordPress Settings Sandbox, etc.
5
+ *
6
+ * @link https://webberzone.com
7
+ * @since 2.5.0
8
+ *
9
+ * @package Top 10
10
+ * @subpackage Admin/Settings
11
+ */
12
+
13
+ // If this file is called directly, abort.
14
+ if ( ! defined( 'WPINC' ) ) {
15
+ die;
16
+ }
17
+
18
+
19
+ /**
20
+ * Render the settings page.
21
+ *
22
+ * @since 2.5.0
23
+ *
24
+ * @return void
25
+ */
26
+ function tptn_options_page() {
27
+ $active_tab = isset( $_GET['tab'] ) && array_key_exists( sanitize_key( wp_unslash( $_GET['tab'] ) ), tptn_get_settings_sections() ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'general'; // Input var okay.
28
+
29
+ ob_start();
30
+ ?>
31
+ <div class="wrap">
32
+ <h1><?php esc_html_e( 'Top 10 Settings', 'top-10' ); ?></h1>
33
+
34
+ <?php settings_errors(); ?>
35
+
36
+ <div id="poststuff">
37
+ <div id="post-body" class="metabox-holder columns-2">
38
+ <div id="post-body-content">
39
+
40
+ <ul class="nav-tab-wrapper" style="padding:0">
41
+ <?php
42
+ foreach ( tptn_get_settings_sections() as $tab_id => $tab_name ) {
43
+
44
+ $active = $active_tab === $tab_id ? ' ' : '';
45
+
46
+ echo '<li><a href="#' . esc_attr( $tab_id ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab ' . sanitize_html_class( $active ) . '">';
47
+ echo esc_html( $tab_name );
48
+ echo '</a></li>';
49
+
50
+ }
51
+ ?>
52
+ </ul>
53
+
54
+ <form method="post" action="options.php">
55
+
56
+ <?php settings_fields( 'tptn_settings' ); ?>
57
+
58
+ <?php foreach ( tptn_get_settings_sections() as $tab_id => $tab_name ) : ?>
59
+
60
+ <div id="<?php echo esc_attr( $tab_id ); ?>">
61
+ <table class="form-table">
62
+ <?php
63
+ do_settings_fields( 'tptn_settings_' . $tab_id, 'tptn_settings_' . $tab_id );
64
+ ?>
65
+ </table>
66
+ <p>
67
+ <?php
68
+ // Default submit button.
69
+ submit_button(
70
+ __( 'Save Changes', 'top-10' ),
71
+ 'primary',
72
+ 'submit',
73
+ false
74
+ );
75
+
76
+ echo '&nbsp;&nbsp;';
77
+
78
+ // Reset button.
79
+ $confirm = esc_js( __( 'Do you really want to reset all these settings to their default values?', 'top-10' ) );
80
+ submit_button(
81
+ __( 'Reset all settings', 'top-10' ),
82
+ 'secondary',
83
+ 'settings_reset',
84
+ false,
85
+ array(
86
+ 'onclick' => "return confirm('{$confirm}');",
87
+ )
88
+ );
89
+ ?>
90
+ </p>
91
+ </div><!-- /#tab_id-->
92
+
93
+ <?php endforeach; ?>
94
+
95
+ </form>
96
+
97
+ </div><!-- /#post-body-content -->
98
+
99
+ <div id="postbox-container-1" class="postbox-container">
100
+
101
+ <div id="side-sortables" class="meta-box-sortables ui-sortable">
102
+ <?php include_once 'sidebar.php'; ?>
103
+ </div><!-- /#side-sortables -->
104
+
105
+ </div><!-- /#postbox-container-1 -->
106
+ </div><!-- /#post-body -->
107
+ <br class="clear" />
108
+ </div><!-- /#poststuff -->
109
+
110
+ </div><!-- /.wrap -->
111
+
112
+ <?php
113
+ echo ob_get_clean(); // WPCS: XSS OK.
114
+ }
115
+
116
+ /**
117
+ * Array containing the settings' sections.
118
+ *
119
+ * @since 2.5.0
120
+ *
121
+ * @return array Settings array
122
+ */
123
+ function tptn_get_settings_sections() {
124
+ $tptn_settings_sections = array(
125
+ 'general' => __( 'General', 'top-10' ),
126
+ 'counter' => __( 'Counter/Tracker', 'top-10' ),
127
+ 'list' => __( 'Posts list', 'top-10' ),
128
+ 'thumbnail' => __( 'Thumbnail', 'top-10' ),
129
+ 'styles' => __( 'Styles', 'top-10' ),
130
+ 'maintenance' => __( 'Maintenance', 'top-10' ),
131
+ );
132
+
133
+ /**
134
+ * Filter the array containing the settings' sections.
135
+ *
136
+ * @since 2.5.0
137
+ *
138
+ * @param array $tptn_settings_sections Settings array
139
+ */
140
+ return apply_filters( 'tptn_settings_sections', $tptn_settings_sections );
141
+
142
+ }
143
+
144
+
145
+ /**
146
+ * Miscellaneous callback funcion
147
+ *
148
+ * @since 2.5.0
149
+ *
150
+ * @param array $args Arguments passed by the setting.
151
+ * @return void
152
+ */
153
+ function tptn_missing_callback( $args ) {
154
+ /* translators: %s: Setting ID. */
155
+ printf( esc_html__( 'The callback function used for the <strong>%s</strong> setting is missing.', 'top-10' ), esc_html( $args['id'] ) );
156
+ }
157
+
158
+
159
+ /**
160
+ * Header Callback
161
+ *
162
+ * Renders the header.
163
+ *
164
+ * @since 2.5.0
165
+ *
166
+ * @param array $args Arguments passed by the setting.
167
+ * @return void
168
+ */
169
+ function tptn_header_callback( $args ) {
170
+
171
+ $html = '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
172
+
173
+ /**
174
+ * After Settings Output filter
175
+ *
176
+ * @since 2.5.0
177
+ * @param string $html HTML string.
178
+ * @param array $args Arguments array.
179
+ */
180
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
181
+ }
182
+
183
+
184
+ /**
185
+ * Display text fields.
186
+ *
187
+ * @since 2.5.0
188
+ *
189
+ * @param array $args Array of arguments.
190
+ * @return void
191
+ */
192
+ function tptn_text_callback( $args ) {
193
+
194
+ // First, we read the options collection.
195
+ global $tptn_settings;
196
+
197
+ if ( isset( $tptn_settings[ $args['id'] ] ) ) {
198
+ $value = $tptn_settings[ $args['id'] ];
199
+ } else {
200
+ $value = isset( $args['options'] ) ? $args['options'] : '';
201
+ }
202
+
203
+ $size = sanitize_html_class( ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular' );
204
+
205
+ $class = sanitize_html_class( $args['field_class'] );
206
+
207
+ $disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : '';
208
+ $readonly = ( isset( $args['readonly'] ) && true === $args['readonly'] ) ? ' readonly="readonly"' : '';
209
+
210
+ $attributes = $disabled . $readonly;
211
+
212
+ foreach ( (array) $args['field_attributes'] as $attribute => $val ) {
213
+ $attributes .= sprintf( ' %1$s="%2$s"', $attribute, esc_attr( $val ) );
214
+ }
215
+
216
+ $html = sprintf( '<input type="text" id="tptn_settings[%1$s]" name="tptn_settings[%1$s]" class="%2$s" value="%3$s" %4$s />', sanitize_key( $args['id'] ), $class . ' ' . $size . '-text', esc_attr( stripslashes( $value ) ), $attributes );
217
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
218
+
219
+ /** This filter has been defined in settings-page.php */
220
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
221
+ }
222
+
223
+
224
+ /**
225
+ * Display csv fields.
226
+ *
227
+ * @since 2.5.0
228
+ *
229
+ * @param array $args Array of arguments.
230
+ * @return void
231
+ */
232
+ function tptn_csv_callback( $args ) {
233
+
234
+ tptn_text_callback( $args );
235
+ }
236
+
237
+
238
+ /**
239
+ * Display CSV fields of numbers.
240
+ *
241
+ * @since 2.5.0
242
+ *
243
+ * @param array $args Array of arguments.
244
+ * @return void
245
+ */
246
+ function tptn_numbercsv_callback( $args ) {
247
+
248
+ tptn_csv_callback( $args );
249
+ }
250
+
251
+
252
+ /**
253
+ * Display textarea.
254
+ *
255
+ * @since 2.5.0
256
+ *
257
+ * @param array $args Array of arguments.
258
+ * @return void
259
+ */
260
+ function tptn_textarea_callback( $args ) {
261
+
262
+ // First, we read the options collection.
263
+ global $tptn_settings;
264
+
265
+ if ( isset( $tptn_settings[ $args['id'] ] ) ) {
266
+ $value = $tptn_settings[ $args['id'] ];
267
+ } else {
268
+ $value = isset( $args['options'] ) ? $args['options'] : '';
269
+ }
270
+
271
+ $html = sprintf( '<textarea class="large-text" cols="50" rows="5" id="tptn_settings[%1$s]" name="tptn_settings[%1$s]">%2$s</textarea>', sanitize_key( $args['id'] ), esc_textarea( stripslashes( $value ) ) );
272
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
273
+
274
+ /** This filter has been defined in settings-page.php */
275
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
276
+ }
277
+
278
+
279
+ /**
280
+ * Display checboxes.
281
+ *
282
+ * @since 2.5.0
283
+ *
284
+ * @param array $args Array of arguments.
285
+ * @return void
286
+ */
287
+ function tptn_checkbox_callback( $args ) {
288
+
289
+ // First, we read the options collection.
290
+ global $tptn_settings;
291
+
292
+ $checked = ! empty( $tptn_settings[ $args['id'] ] ) ? checked( 1, $tptn_settings[ $args['id'] ], false ) : '';
293
+ $default = isset( $args['options'] ) ? $args['options'] : '';
294
+ $set = isset( $tptn_settings[ $args['id'] ] ) ? $tptn_settings[ $args['id'] ] : '';
295
+
296
+ $html = sprintf( '<input type="hidden" name="tptn_settings[%1$s]" value="-1" />', sanitize_key( $args['id'] ) );
297
+ $html .= sprintf( '<input type="checkbox" id="tptn_settings[%1$s]" name="tptn_settings[%1$s]" value="1" %2$s />', sanitize_key( $args['id'] ), $checked );
298
+ $html .= ( $set <> $default ) ? '<em style="color:orange"> ' . esc_html__( 'Modified from default setting', 'top-10' ) . '</em>' : '';
299
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
300
+
301
+ /** This filter has been defined in settings-page.php */
302
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
303
+ }
304
+
305
+
306
+ /**
307
+ * Multicheck Callback
308
+ *
309
+ * Renders multiple checkboxes.
310
+ *
311
+ * @since 2.5.0
312
+ *
313
+ * @param array $args Array of arguments.
314
+ * @return void
315
+ */
316
+ function tptn_multicheck_callback( $args ) {
317
+ global $tptn_settings;
318
+ $html = '';
319
+
320
+ if ( ! empty( $args['options'] ) ) {
321
+ $html .= sprintf( '<input type="hidden" name="tptn_settings[%1$s]" value="-1" />', $args['id'] );
322
+
323
+ foreach ( $args['options'] as $key => $option ) {
324
+ if ( isset( $tptn_settings[ $args['id'] ][ $key ] ) ) {
325
+ $enabled = $key;
326
+ } else {
327
+ $enabled = null;
328
+ }
329
+
330
+ $html .= sprintf( '<input name="tptn_settings[%1$s][%2$s]" id="tptn_settings[%1$s][%2$s]" type="checkbox" value="%3$s" %4$s /> ', sanitize_key( $args['id'] ), sanitize_key( $key ), esc_attr( $key ), checked( $key, $enabled, false ) );
331
+ $html .= sprintf( '<label for="tptn_settings[%1$s][%2$s]">%3$s</label> <br />', sanitize_key( $args['id'] ), sanitize_key( $key ), $option );
332
+ }
333
+
334
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
335
+ }
336
+
337
+ /** This filter has been defined in settings-page.php */
338
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
339
+ }
340
+
341
+
342
+ /**
343
+ * Radio Callback
344
+ *
345
+ * Renders radio boxes.
346
+ *
347
+ * @since 2.5.0
348
+ *
349
+ * @param array $args Array of arguments.
350
+ * @return void
351
+ */
352
+ function tptn_radio_callback( $args ) {
353
+ global $tptn_settings;
354
+ $html = '';
355
+
356
+ foreach ( $args['options'] as $key => $option ) {
357
+ $checked = false;
358
+
359
+ if ( isset( $tptn_settings[ $args['id'] ] ) && $tptn_settings[ $args['id'] ] === $key ) {
360
+ $checked = true;
361
+ } elseif ( isset( $args['default'] ) && $args['default'] === $key && ! isset( $tptn_settings[ $args['id'] ] ) ) {
362
+ $checked = true;
363
+ }
364
+
365
+ $html .= sprintf( '<input name="tptn_settings[%1$s]" id="tptn_settings[%1$s][%2$s]" type="radio" value="%2$s" %3$s /> ', sanitize_key( $args['id'] ), $key, checked( true, $checked, false ) );
366
+ $html .= sprintf( '<label for="tptn_settings[%1$s][%2$s]">%3$s</label> <br />', sanitize_key( $args['id'] ), $key, $option );
367
+ }
368
+
369
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
370
+
371
+ /** This filter has been defined in settings-page.php */
372
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
373
+ }
374
+
375
+
376
+ /**
377
+ * Radio callback with description.
378
+ *
379
+ * Renders radio boxes with each item having it separate description.
380
+ *
381
+ * @since 2.5.0
382
+ *
383
+ * @param array $args Array of arguments.
384
+ * @return void
385
+ */
386
+ function tptn_radiodesc_callback( $args ) {
387
+ global $tptn_settings;
388
+ $html = '';
389
+
390
+ foreach ( $args['options'] as $option ) {
391
+ $checked = false;
392
+
393
+ if ( isset( $tptn_settings[ $args['id'] ] ) && $tptn_settings[ $args['id'] ] === $option['id'] ) {
394
+ $checked = true;
395
+ } elseif ( isset( $args['default'] ) && $args['default'] === $option['id'] && ! isset( $tptn_settings[ $args['id'] ] ) ) {
396
+ $checked = true;
397
+ }
398
+
399
+ $html .= sprintf( '<input name="tptn_settings[%1$s]" id="tptn_settings[%1$s][%2$s]" type="radio" value="%2$s" %3$s /> ', sanitize_key( $args['id'] ), $option['id'], checked( true, $checked, false ) );
400
+ $html .= sprintf( '<label for="tptn_settings[%1$s][%2$s]">%3$s</label>', sanitize_key( $args['id'] ), $option['id'], $option['name'] );
401
+ $html .= ': <em>' . wp_kses_post( $option['description'] ) . '</em> <br />';
402
+ }
403
+
404
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
405
+
406
+ /** This filter has been defined in settings-page.php */
407
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
408
+ }
409
+
410
+
411
+ /**
412
+ * Callback for thumbnail sizes
413
+ *
414
+ * Renders list of radio boxes with various thumbnail sizes.
415
+ *
416
+ * @since 2.5.0
417
+ *
418
+ * @param array $args Array of arguments.
419
+ * @return void
420
+ */
421
+ function tptn_thumbsizes_callback( $args ) {
422
+ $html = '';
423
+
424
+ if ( ! isset( $args['options']['tptn_thumbnail'] ) ) {
425
+ $args['options']['tptn_thumbnail'] = array(
426
+ 'name' => 'tptn_thumbnail',
427
+ 'width' => tptn_get_option( 'thumb_width', 150 ),
428
+ 'height' => tptn_get_option( 'thumb_height', 150 ),
429
+ 'crop' => tptn_get_option( 'thumb_crop', true ),
430
+ );
431
+ }
432
+
433
+ foreach ( $args['options'] as $option ) {
434
+ $checked = false;
435
+
436
+ if ( isset( $tptn_settings[ $args['id'] ] ) && $tptn_settings[ $args['id'] ] === $option['name'] ) {
437
+ $checked = true;
438
+ } elseif ( isset( $args['default'] ) && $args['default'] === $option['name'] && ! isset( $tptn_settings[ $args['id'] ] ) ) {
439
+ $checked = true;
440
+ }
441
+
442
+ $html .= sprintf( '<input name="tptn_settings[%1$s]" id="tptn_settings[%1$s][%2$s]" type="radio" value="%2$s" %3$s /> ', sanitize_key( $args['id'] ), $option['name'], checked( true, $checked, false ) );
443
+ $html .= sprintf( '<label for="tptn_settings[%1$s][%2$s]">%3$s</label> <br />', sanitize_key( $args['id'] ), $option['name'], $option['name'] . ' (' . $option['width'] . 'x' . $option['height'] . ')' );
444
+ }
445
+
446
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
447
+
448
+ /** This filter has been defined in settings-page.php */
449
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
450
+ }
451
+
452
+
453
+ /**
454
+ * Number Callback
455
+ *
456
+ * Renders number fields.
457
+ *
458
+ * @since 2.5.0
459
+ *
460
+ * @param array $args Array of arguments.
461
+ * @return void
462
+ */
463
+ function tptn_number_callback( $args ) {
464
+ global $tptn_settings;
465
+
466
+ if ( isset( $tptn_settings[ $args['id'] ] ) ) {
467
+ $value = $tptn_settings[ $args['id'] ];
468
+ } else {
469
+ $value = isset( $args['options'] ) ? $args['options'] : '';
470
+ }
471
+
472
+ $max = isset( $args['max'] ) ? $args['max'] : 999999;
473
+ $min = isset( $args['min'] ) ? $args['min'] : 0;
474
+ $step = isset( $args['step'] ) ? $args['step'] : 1;
475
+
476
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
477
+
478
+ $html = sprintf( '<input type="number" step="%1$s" max="%2$s" min="%3$s" class="%4$s" id="tptn_settings[%5$s]" name="tptn_settings[%5$s]" value="%6$s"/>', esc_attr( $step ), esc_attr( $max ), esc_attr( $min ), sanitize_html_class( $size ) . '-text', sanitize_key( $args['id'] ), esc_attr( stripslashes( $value ) ) );
479
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
480
+
481
+ /** This filter has been defined in settings-page.php */
482
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
483
+ }
484
+
485
+
486
+ /**
487
+ * Select Callback
488
+ *
489
+ * Renders select fields.
490
+ *
491
+ * @since 2.5.0
492
+ *
493
+ * @param array $args Array of arguments.
494
+ * @return void
495
+ */
496
+ function tptn_select_callback( $args ) {
497
+ global $tptn_settings;
498
+
499
+ if ( isset( $tptn_settings[ $args['id'] ] ) ) {
500
+ $value = $tptn_settings[ $args['id'] ];
501
+ } else {
502
+ $value = isset( $args['default'] ) ? $args['default'] : '';
503
+ }
504
+
505
+ if ( isset( $args['chosen'] ) ) {
506
+ $chosen = 'class="tptn-chosen"';
507
+ } else {
508
+ $chosen = '';
509
+ }
510
+
511
+ $html = sprintf( '<select id="tptn_settings[%1$s]" name="tptn_settings[%1$s]" %2$s />', sanitize_key( $args['id'] ), $chosen );
512
+
513
+ foreach ( $args['options'] as $option => $name ) {
514
+ $html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', sanitize_key( $option ), selected( $option, $value, false ), $name );
515
+ }
516
+
517
+ $html .= '</select>';
518
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
519
+
520
+ /** This filter has been defined in settings-page.php */
521
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
522
+ }
523
+
524
+
525
+ /**
526
+ * Descriptive text callback.
527
+ *
528
+ * Renders descriptive text onto the settings field.
529
+ *
530
+ * @since 2.5.0
531
+ *
532
+ * @param array $args Array of arguments.
533
+ * @return void
534
+ */
535
+ function tptn_descriptive_text_callback( $args ) {
536
+ $html = '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
537
+
538
+ /** This filter has been defined in settings-page.php */
539
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
540
+ }
541
+
542
+
543
+ /**
544
+ * Display csv fields.
545
+ *
546
+ * @since 2.5.0
547
+ *
548
+ * @param array $args Array of arguments.
549
+ * @return void
550
+ */
551
+ function tptn_posttypes_callback( $args ) {
552
+
553
+ global $tptn_settings;
554
+ $html = '';
555
+
556
+ if ( isset( $tptn_settings[ $args['id'] ] ) ) {
557
+ $options = $tptn_settings[ $args['id'] ];
558
+ } else {
559
+ $options = isset( $args['options'] ) ? $args['options'] : '';
560
+ }
561
+
562
+ // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
563
+ if ( is_array( $options ) ) {
564
+ $post_types = $options;
565
+ } elseif ( ! is_array( $options ) && false === strpos( $options, '=' ) ) {
566
+ $post_types = explode( ',', $options );
567
+ } else {
568
+ parse_str( $options, $post_types );
569
+ }
570
+
571
+ $wp_post_types = get_post_types(
572
+ array(
573
+ 'public' => true,
574
+ )
575
+ );
576
+ $posts_types_inc = array_intersect( $wp_post_types, $post_types );
577
+
578
+ foreach ( $wp_post_types as $wp_post_type ) {
579
+
580
+ $html .= sprintf( '<input name="tptn_settings[%1$s][%2$s]" id="tptn_settings[%1$s][%2$s]" type="checkbox" value="%2$s" %3$s /> ', sanitize_key( $args['id'] ), esc_attr( $wp_post_type ), checked( true, in_array( $wp_post_type, $posts_types_inc, true ), false ) );
581
+ $html .= sprintf( '<label for="tptn_settings[%1$s][%2$s]">%2$s</label> <br />', sanitize_key( $args['id'] ), $wp_post_type );
582
+
583
+ }
584
+
585
+ $html .= '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
586
+
587
+ /** This filter has been defined in settings-page.php */
588
+ echo apply_filters( 'tptn_after_setting_output', $html, $args ); // WPCS: XSS OK.
589
+ }
590
+
591
+
592
+ /**
593
+ * Function to add an action to search for tags using Ajax.
594
+ *
595
+ * @since 2.1.0
596
+ *
597
+ * @return void
598
+ */
599
+ function tptn_tags_search() {
600
+
601
+ if ( ! isset( $_REQUEST['tax'] ) ) {
602
+ wp_die( 0 );
603
+ }
604
+
605
+ $taxonomy = sanitize_key( $_REQUEST['tax'] );
606
+ $tax = get_taxonomy( $taxonomy );
607
+ if ( ! $tax ) {
608
+ wp_die( 0 );
609
+ }
610
+
611
+ if ( ! current_user_can( $tax->cap->assign_terms ) ) {
612
+ wp_die( -1 );
613
+ }
614
+
615
+ $s = wp_unslash( $_REQUEST['q'] );
616
+
617
+ $comma = _x( ',', 'tag delimiter' );
618
+ if ( ',' !== $comma ) {
619
+ $s = str_replace( $comma, ',', $s );
620
+ }
621
+ if ( false !== strpos( $s, ',' ) ) {
622
+ $s = explode( ',', $s );
623
+ $s = $s[ count( $s ) - 1 ];
624
+ }
625
+ $s = trim( $s );
626
+
627
+ /** This filter has been defined in /wp-admin/includes/ajax-actions.php */
628
+ $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s );
629
+
630
+ /*
631
+ * Require $term_search_min_chars chars for matching (default: 2)
632
+ * ensure it's a non-negative, non-zero integer.
633
+ */
634
+ if ( ( 0 === $term_search_min_chars ) || ( strlen( $s ) < $term_search_min_chars ) ) {
635
+ wp_die();
636
+ }
637
+
638
+ $results = get_terms(
639
+ $taxonomy, array(
640
+ 'name__like' => $s,
641
+ 'fields' => 'names',
642
+ 'hide_empty' => false,
643
+ )
644
+ );
645
+
646
+ echo wp_json_encode( $results );
647
+ wp_die();
648
+
649
+ }
650
+ add_action( 'wp_ajax_nopriv_tptn_tag_search', 'tptn_tags_search' );
651
+ add_action( 'wp_ajax_tptn_tag_search', 'tptn_tags_search' );
652
+
653
+
654
+ /**
655
+ * Display the default thumbnail below the setting.
656
+ *
657
+ * @since 2.1.0
658
+ *
659
+ * @param string $html Current HTML.
660
+ * @param array $args Argument array of the setting.
661
+ * @return string
662
+ */
663
+ function tptn_admin_thumbnail( $html, $args ) {
664
+
665
+ $thumb_default = tptn_get_option( 'thumb_default' );
666
+
667
+ if ( 'thumb_default' === $args['id'] && '' !== $thumb_default ) {
668
+ $html .= '<br />';
669
+ $html .= sprintf( '<img src="%1$s" style="max-width:200px" title="%2$s" alt="%2$s" />', esc_attr( $thumb_default ), esc_html__( 'Default thumbnail', 'where-did-they-go-from-here' ) );
670
+ }
671
+
672
+ return $html;
673
+ }
674
+ add_filter( 'tptn_after_setting_output', 'tptn_admin_thumbnail', 10, 2 );
675
+
includes/admin/sidebar.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sidebar
4
+ *
5
+ * @link https://webberzone.com
6
+ * @since 2.5.0
7
+ *
8
+ * @package Top 10
9
+ * @subpackage Admin/Footer
10
+ */
11
+
12
+ ?>
13
+ <div class="postbox-container">
14
+ <div id="donatediv" class="postbox meta-box-sortables">
15
+ <h2 class='hndle'><span><?php esc_html_e( 'Support the development', 'top-10' ); ?></span></h3>
16
+ <div class="inside" style="text-align: center">
17
+ <div id="donate-form">
18
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
19
+ <input type="hidden" name="cmd" value="_xclick">
20
+ <input type="hidden" name="business" value="donate@ajaydsouza.com">
21
+ <input type="hidden" name="lc" value="IN">
22
+ <input type="hidden" name="item_name" value="<?php esc_html_e( 'Donation for Top 10', 'top-10' ); ?>">
23
+ <input type="hidden" name="item_number" value="crp_plugin_settings">
24
+ <strong><?php esc_html_e( 'Enter amount in USD', 'top-10' ); ?></strong>: <input name="amount" value="15.00" size="6" type="text"><br />
25
+ <input type="hidden" name="currency_code" value="USD">
26
+ <input type="hidden" name="button_subtype" value="services">
27
+ <input type="hidden" name="bn" value="PP-BuyNowBF:btn_donate_LG.gif:NonHosted">
28
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="<?php esc_html_e( 'Send your donation to the author of', 'top-10' ); ?> Top 10">
29
+ <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
30
+ </form>
31
+ </div>
32
+ <!-- /#donate-form -->
33
+ </div>
34
+ <!-- /.inside -->
35
+ </div>
36
+ <!-- /.postbox -->
37
+
38
+ <div id="qlinksdiv" class="postbox meta-box-sortables">
39
+ <h2 class='hndle metabox-holder'><span><?php esc_html_e( 'Quick links', 'top-10' ); ?></span></h3>
40
+ <div class="inside">
41
+ <div id="quick-links">
42
+ <ul>
43
+ <li>
44
+ <a href="https://webberzone.com/plugins/top-10/">
45
+ <?php esc_html_e( 'Top 10 plugin homepage', 'top-10' ); ?>
46
+ </a>
47
+ </li>
48
+ <li>
49
+ <a href="https://wordpress.org/plugins/top-10/faq/">
50
+ <?php esc_html_e( 'FAQ', 'top-10' ); ?>
51
+ </a>
52
+ </li>
53
+ <li>
54
+ <a href="http://wordpress.org/support/plugin/top-10">
55
+ <?php esc_html_e( 'Support', 'top-10' ); ?>
56
+ </a>
57
+ </li>
58
+ <li>
59
+ <a href="https://wordpress.org/support/view/plugin-reviews/top-10">
60
+ <?php esc_html_e( 'Reviews', 'top-10' ); ?>
61
+ </a>
62
+ </li>
63
+ <li>
64
+ <a href="https://github.com/WebberZone/top-10">
65
+ <?php esc_html_e( 'Github repository', 'top-10' ); ?>
66
+ </a>
67
+ </li>
68
+ <li>
69
+ <a href="https://webberzone.com/plugins/">
70
+ <?php esc_html_e( 'Other plugins', 'top-10' ); ?>
71
+ </a>
72
+ </li>
73
+ <li>
74
+ <a href="https://ajaydsouza.com/">
75
+ <?php esc_html_e( "Ajay's blog", 'top-10' ); ?>
76
+ </a>
77
+ </li>
78
+ </ul>
79
+ </div>
80
+ </div>
81
+ <!-- /.inside -->
82
+ </div>
83
+ <!-- /.postbox -->
84
+ </div>
85
+
86
+ <div class="postbox-container">
87
+ <div id="followdiv" class="postbox meta-box-sortables">
88
+ <h2 class='hndle'><span><?php esc_html_e( 'Follow me', 'add-to-all' ); ?></span></h3>
89
+ <div class="inside" style="text-align: center">
90
+ <a href="https://facebook.com/webberzone/" target="_blank"><img src="<?php echo esc_url( TOP_TEN_PLUGIN_URL . 'includes/admin/images/fb.png' ); ?>" width="100" height="100" /></a>
91
+ <a href="https://twitter.com/webberzonewp/" target="_blank"><img src="<?php echo esc_url( TOP_TEN_PLUGIN_URL . 'includes/admin/images/twitter.jpg' ); ?>" width="100" height="100" /></a>
92
+ </div>
93
+ <!-- /.inside -->
94
+ </div>
95
+ <!-- /.postbox -->
96
+ </div>
includes/admin/tools.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The admin-specific functionality of the plugin.
4
+ *
5
+ * @link https://webberzone.com
6
+ * @since 2.5.0
7
+ *
8
+ * @package Top 10
9
+ * @subpackage Admin/Tools
10
+ */
11
+
12
+ // If this file is called directly, abort.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+
18
+ /**
19
+ * Render the tools settings page.
20
+ *
21
+ * @since 2.5.0
22
+ *
23
+ * @return void
24
+ */
25
+ function tptn_tools_page() {
26
+
27
+ /* Truncate overall posts table */
28
+ if ( ( isset( $_POST['tptn_trunc_all'] ) ) && ( check_admin_referer( 'tptn-tools-settings' ) ) ) {
29
+ tptn_trunc_count( false );
30
+ add_settings_error( 'tptn-notices', '', esc_html__( 'Top 10 popular posts reset', 'top-10' ), 'error' );
31
+ }
32
+
33
+ /* Truncate daily posts table */
34
+ if ( ( isset( $_POST['tptn_trunc_daily'] ) ) && ( check_admin_referer( 'tptn-tools-settings' ) ) ) {
35
+ tptn_trunc_count( true );
36
+ add_settings_error( 'tptn-notices', '', esc_html__( 'Top 10 daily popular posts reset', 'top-10' ), 'error' );
37
+ }
38
+
39
+ /* Clean duplicates */
40
+ if ( ( isset( $_POST['tptn_clean_duplicates'] ) ) && ( check_admin_referer( 'tptn-tools-settings' ) ) ) {
41
+ tptn_clean_duplicates( true );
42
+ tptn_clean_duplicates( false );
43
+ add_settings_error( 'tptn-notices', '', esc_html__( 'Duplicate rows cleaned from the tables', 'top-10' ), 'error' );
44
+ }
45
+
46
+ /* Merge blog IDs */
47
+ if ( ( isset( $_POST['tptn_merge_blogids'] ) ) && ( check_admin_referer( 'tptn-tools-settings' ) ) ) {
48
+ tptn_merge_blogids( true );
49
+ tptn_merge_blogids( false );
50
+ add_settings_error( 'tptn-notices', '', esc_html__( 'Post counts across blog IDs 0 and 1 have been merged', 'top-10' ), 'error' );
51
+ }
52
+
53
+ ob_start();
54
+ ?>
55
+ <div class="wrap">
56
+ <h1><?php esc_html_e( 'Top 10 Tools', 'top-10' ); ?></h1>
57
+
58
+ <?php settings_errors(); ?>
59
+
60
+ <div id="poststuff">
61
+ <div id="post-body" class="metabox-holder columns-2">
62
+ <div id="post-body-content">
63
+
64
+ <form method="post" >
65
+
66
+ <h2 style="padding-left:0px"><?php esc_html_e( 'Clear cache', 'top-10' ); ?></h2>
67
+ <p>
68
+ <input type="button" name="cache_clear" id="cache_clear" value="<?php esc_attr_e( 'Clear cache', 'top-10' ); ?>" class="button button-secondary" onclick="return clearCache();" />
69
+ </p>
70
+ <p class="description">
71
+ <?php esc_html_e( 'Clear the Top 10 cache. This will also be cleared automatically when you save the settings page.', 'top-10' ); ?>
72
+ </p>
73
+
74
+ <h2 style="padding-left:0px"><?php esc_html_e( 'Reset database', 'top-10' ); ?></h2>
75
+ <p>
76
+ <input name="tptn_trunc_all" type="submit" id="tptn_trunc_all" value="<?php esc_attr_e( 'Reset Popular Posts Network-wide', 'top-10' ); ?>" class="button button-secondary" style="color:#f00" onclick="if (!confirm('<?php esc_attr_e( 'Are you sure you want to reset the popular posts?', 'top-10' ); ?>')) return false;" />
77
+ <input name="tptn_trunc_daily" type="submit" id="tptn_trunc_daily" value="<?php esc_attr_e( 'Reset Daily Popular Posts Network-wide', 'top-10' ); ?>" class="button button-secondary" style="color:#f00" onclick="if (!confirm('<?php esc_attr_e( 'Are you sure you want to reset the daily popular posts?', 'top-10' ); ?>')) return false;" />
78
+ </p>
79
+ <p class="description">
80
+ <?php esc_html_e( 'This will reset the Top 10 tables. If you are running Top 10 on multisite then it will delete the popular posts across the entire network. This cannot be reversed. Make sure that your database has been backed up before proceeding', 'top-10' ); ?>
81
+ </p>
82
+
83
+ <h2 style="padding-left:0px"><?php esc_html_e( 'Other tools', 'top-10' ); ?></h2>
84
+ <p>
85
+ <input name="tptn_merge_blogids" type="submit" id="tptn_merge_blogids" value="<?php esc_attr_e( 'Merge blog ID 0 and 1 post counts', 'top-10' ); ?>" class="button button-secondary" onclick="if (!confirm('<?php esc_attr_e( 'This will merge post counts for blog IDs 0 and 1. Proceed?', 'top-10' ); ?>')) return false;" />
86
+ </p>
87
+ <p class="description">
88
+ <?php esc_html_e( 'This will merge post counts for posts with table entries of 0 and 1', 'top-10' ); ?>
89
+ </p>
90
+ <p>
91
+ <input name="tptn_clean_duplicates" type="submit" id="tptn_clean_duplicates" value="<?php esc_attr_e( 'Merge duplicates across blog IDs', 'top-10' ); ?>" class="button button-secondary" onclick="if (!confirm('<?php esc_attr_e( 'This will delete the duplicate entries in the tables. Proceed?', 'top-10' ); ?>')) return false;" />
92
+ </p>
93
+ <p class="description">
94
+ <?php esc_html_e( 'In older versions, the plugin created entries with duplicate post IDs. Clicking the button below will merge these duplicate IDs', 'top-10' ); ?>
95
+ </p>
96
+ <?php wp_nonce_field( 'tptn-tools-settings' ); ?>
97
+ </form>
98
+
99
+ </div><!-- /#post-body-content -->
100
+
101
+ <div id="postbox-container-1" class="postbox-container">
102
+
103
+ <div id="side-sortables" class="meta-box-sortables ui-sortable">
104
+ <?php include_once 'sidebar.php'; ?>
105
+ </div><!-- /#side-sortables -->
106
+
107
+ </div><!-- /#postbox-container-1 -->
108
+ </div><!-- /#post-body -->
109
+ <br class="clear" />
110
+ </div><!-- /#poststuff -->
111
+
112
+ </div><!-- /.wrap -->
113
+
114
+ <?php
115
+ echo ob_get_clean(); // WPCS: XSS OK.
116
+ }
117
+
118
+ /**
119
+ * Function to delete all duplicate rows in the posts table.
120
+ *
121
+ * @since 1.6.2
122
+ *
123
+ * @param bool $daily Daily flag.
124
+ */
125
+ function tptn_clean_duplicates( $daily = false ) {
126
+ global $wpdb;
127
+
128
+ $table_name = $wpdb->base_prefix . 'top_ten';
129
+ if ( $daily ) {
130
+ $table_name .= '_daily';
131
+ }
132
+
133
+ $wpdb->query( 'CREATE TEMPORARY TABLE ' . $table_name . '_temp AS SELECT * FROM ' . $table_name . ' GROUP BY postnumber' ); // WPCS: unprepared SQL OK.
134
+ $wpdb->query( "TRUNCATE TABLE $table_name" ); // WPCS: unprepared SQL OK.
135
+ $wpdb->query( 'INSERT INTO ' . $table_name . ' SELECT * FROM ' . $table_name . '_temp' ); // WPCS: unprepared SQL OK.
136
+ }
137
+
138
+
139
+ /**
140
+ * Function to merge counts with post numbers of blog ID 0 and 1 respectively.
141
+ *
142
+ * @since 2.0.4
143
+ *
144
+ * @param bool $daily Daily flag.
145
+ */
146
+ function tptn_merge_blogids( $daily = false ) {
147
+ global $wpdb;
148
+
149
+ $table_name = $wpdb->base_prefix . 'top_ten';
150
+ if ( $daily ) {
151
+ $table_name .= '_daily';
152
+ }
153
+
154
+ if ( $daily ) {
155
+ $wpdb->query(
156
+ "
157
+ INSERT INTO `$table_name` (postnumber, cntaccess, dp_date, blog_id) (
158
+ SELECT
159
+ postnumber,
160
+ SUM(cntaccess) as sumCount,
161
+ dp_date,
162
+ 1
163
+ FROM `$table_name`
164
+ WHERE blog_ID IN (0,1)
165
+ GROUP BY postnumber, dp_date
166
+ ) ON DUPLICATE KEY UPDATE cntaccess = VALUES(cntaccess);
167
+ "
168
+ );
169
+ } else {
170
+ $wpdb->query(
171
+ "
172
+ INSERT INTO `$table_name` (postnumber, cntaccess, blog_id) (
173
+ SELECT
174
+ postnumber,
175
+ SUM(cntaccess) as sumCount,
176
+ 1
177
+ FROM `$table_name`
178
+ WHERE blog_ID IN (0,1)
179
+ GROUP BY postnumber
180
+ ) ON DUPLICATE KEY UPDATE cntaccess = VALUES(cntaccess);
181
+ "
182
+ );
183
+ }
184
+
185
+ $wpdb->query( "DELETE FROM $table_name WHERE blog_id = 0" ); // WPCS: unprepared SQL OK.
186
+ }
includes/counter.php CHANGED
@@ -8,30 +8,33 @@
8
  /**
9
  * Function to add the viewed count to the post content. Filters `the_content`.
10
  *
11
- * @since 1.0
12
- * @param string $content Post content.
13
- * @return string Filtered post content
14
  */
15
  function tptn_pc_content( $content ) {
16
- global $post, $tptn_settings;
17
 
18
- $exclude_on_post_ids = explode( ',', $tptn_settings['exclude_on_post_ids'] );
 
19
 
20
- if ( in_array( $post->ID, $exclude_on_post_ids ) ) {
21
- return $content; // Exit without adding related posts.
 
 
22
  }
23
 
24
- if ( ( is_single() ) && ( $tptn_settings['add_to_content'] ) ) {
25
  return $content . echo_tptn_post_count( 0 );
26
- } elseif ( ( is_page() ) && ( $tptn_settings['count_on_pages'] ) ) {
27
  return $content . echo_tptn_post_count( 0 );
28
- } elseif ( ( is_home() ) && ( $tptn_settings['add_to_home'] ) ) {
29
  return $content . echo_tptn_post_count( 0 );
30
- } elseif ( ( is_category() ) && ( $tptn_settings['add_to_category_archives'] ) ) {
31
  return $content . echo_tptn_post_count( 0 );
32
- } elseif ( ( is_tag() ) && ( $tptn_settings['add_to_tag_archives'] ) ) {
33
  return $content . echo_tptn_post_count( 0 );
34
- } elseif ( ( ( is_tax() ) || ( is_author() ) || ( is_date() ) ) && ( $tptn_settings['add_to_archives'] ) ) {
35
  return $content . echo_tptn_post_count( 0 );
36
  } else {
37
  return $content;
@@ -43,17 +46,19 @@ add_filter( 'the_content', 'tptn_pc_content' );
43
  /**
44
  * Filter to display the post count when viewing feeds.
45
  *
46
- * @since 1.9.8
47
  *
48
- * @param string $content Post content.
49
- * @return string Filtered post content
50
  */
51
  function tptn_rss_filter( $content ) {
52
- global $post, $tptn_settings;
53
 
54
  $id = intval( $post->ID );
55
 
56
- if ( $tptn_settings['add_to_feed'] ) {
 
 
57
  return $content . '<div class="tptn_counter" id="tptn_counter_' . $id . '">' . get_tptn_post_count( $id ) . '</div>';
58
  } else {
59
  return $content;
@@ -66,19 +71,19 @@ add_filter( 'the_content_feed', 'tptn_rss_filter' );
66
  /**
67
  * Function to manually display count.
68
  *
69
- * @since 1.0
70
- * @param int|boolean $echo Flag to echo the output.
71
- * @return string Formatted string if $echo is set to 0|false
72
  */
73
  function echo_tptn_post_count( $echo = 1 ) {
74
- global $post, $tptn_settings;
75
 
76
  $home_url = home_url( '/' );
77
 
78
  /**
79
  * Filter the script URL of the counter.
80
  *
81
- * @since 2.0
82
  */
83
  $home_url = apply_filters( 'tptn_view_counter_script_url', $home_url );
84
 
@@ -87,10 +92,10 @@ function echo_tptn_post_count( $echo = 1 ) {
87
 
88
  $id = intval( $post->ID );
89
 
90
- $nonce_action = 'tptn-nonce-' . $id ;
91
- $nonce = wp_create_nonce( $nonce_action );
92
 
93
- if ( $tptn_settings['dynamic_post_count'] ) {
94
  $output = '<div class="tptn_counter" id="tptn_counter_' . $id . '"><script type="text/javascript" data-cfasync="false" src="' . $home_url . '?top_ten_id=' . $id . '&amp;view_counter=1&amp;_wpnonce=' . $nonce . '"></script></div>';
95
  } else {
96
  $output = '<div class="tptn_counter" id="tptn_counter_' . $id . '">' . get_tptn_post_count( $id ) . '</div>';
@@ -99,14 +104,14 @@ function echo_tptn_post_count( $echo = 1 ) {
99
  /**
100
  * Filter the viewed count script
101
  *
102
- * @since 2.0.0
103
  *
104
- * @param string $output Counter viewed count code
105
  */
106
  $output = apply_filters( 'tptn_view_post_count', $output );
107
 
108
  if ( $echo ) {
109
- echo $output;
110
  } else {
111
  return $output;
112
  }
@@ -116,17 +121,16 @@ function echo_tptn_post_count( $echo = 1 ) {
116
  /**
117
  * Return the formatted post count for the supplied ID.
118
  *
119
- * @since 1.9.2
120
- * @param int|string $id Post ID.
121
- * @param int|string $blog_id Blog ID.
122
- * @return int|string Formatted post count
123
  */
124
  function get_tptn_post_count( $id = false, $blog_id = false ) {
125
- global $tptn_settings;
126
 
127
- $count_disp_form = stripslashes( $tptn_settings['count_disp_form'] );
128
- $count_disp_form_zero = stripslashes( $tptn_settings['count_disp_form_zero'] );
129
- $totalcntaccess = get_tptn_post_count_only( $id, 'total', $blog_id );
130
 
131
  if ( $id > 0 ) {
132
 
@@ -173,17 +177,17 @@ function get_tptn_post_count( $id = false, $blog_id = false ) {
173
  /**
174
  * Returns the post count.
175
  *
176
- * @since 1.9.8.5
177
  *
178
- * @param mixed $id Post ID.
179
- * @param string $count Which count to return? total, daily or overall.
180
  * @param bool $blog_id Blog ID.
181
- * @return int Post count
182
  */
183
  function get_tptn_post_count_only( $id = false, $count = 'total', $blog_id = false ) {
184
- global $wpdb, $tptn_settings;
185
 
186
- $table_name = $wpdb->base_prefix . 'top_ten';
187
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
188
 
189
  if ( empty( $blog_id ) ) {
@@ -193,29 +197,29 @@ function get_tptn_post_count_only( $id = false, $count = 'total', $blog_id = fal
193
  if ( $id > 0 ) {
194
  switch ( $count ) {
195
  case 'total':
196
- $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d " , $id, $blog_id ) );
197
- $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->cntaccess : 0 ) );
198
  break;
199
  case 'daily':
200
- $daily_range = $tptn_settings['daily_range'];
201
- $hour_range = $tptn_settings['hour_range'];
202
 
203
- if ( $tptn_settings['daily_midnight'] ) {
204
  $current_time = current_time( 'timestamp', 0 );
205
- $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
206
- $from_date = gmdate( 'Y-m-d 0' , $from_date );
207
  } else {
208
  $current_time = current_time( 'timestamp', 0 );
209
- $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
210
- $from_date = gmdate( 'Y-m-d H' , $from_date );
211
  }
212
 
213
- $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name_daily} WHERE postnumber = %d AND blog_id = %d AND dp_date >= '%s' GROUP BY postnumber ", array( $id, $blog_id, $from_date ) ) );
214
- $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
215
  break;
216
  case 'overall':
217
- $resultscount = $wpdb->get_row( 'SELECT SUM(cntaccess) as sum_count FROM ' . $table_name );
218
- $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
219
  break;
220
  }
221
  return apply_filters( 'tptn_post_count_only', $cntaccess );
8
  /**
9
  * Function to add the viewed count to the post content. Filters `the_content`.
10
  *
11
+ * @since 1.0
12
+ * @param string $content Post content.
13
+ * @return string Filtered post content
14
  */
15
  function tptn_pc_content( $content ) {
16
+ global $post;
17
 
18
+ $exclude_on_post_ids = explode( ',', tptn_get_option( 'exclude_on_post_ids' ) );
19
+ $add_to = tptn_get_option( 'add_to' );
20
 
21
+ if ( isset( $post ) ) {
22
+ if ( in_array( $post->ID, $exclude_on_post_ids ) ) {
23
+ return $content; // Exit without adding related posts.
24
+ }
25
  }
26
 
27
+ if ( ( is_single() ) && ! empty( $add_to['single'] ) ) {
28
  return $content . echo_tptn_post_count( 0 );
29
+ } elseif ( ( is_page() ) && ! empty( $add_to['page'] ) ) {
30
  return $content . echo_tptn_post_count( 0 );
31
+ } elseif ( ( is_home() ) && ! empty( $add_to['home'] ) ) {
32
  return $content . echo_tptn_post_count( 0 );
33
+ } elseif ( ( is_category() ) && ! empty( $add_to['category_archives'] ) ) {
34
  return $content . echo_tptn_post_count( 0 );
35
+ } elseif ( ( is_tag() ) && ! empty( $add_to['tag_archives'] ) ) {
36
  return $content . echo_tptn_post_count( 0 );
37
+ } elseif ( ( ( is_tax() ) || ( is_author() ) || ( is_date() ) ) && ! empty( $add_to['other_archives'] ) ) {
38
  return $content . echo_tptn_post_count( 0 );
39
  } else {
40
  return $content;
46
  /**
47
  * Filter to display the post count when viewing feeds.
48
  *
49
+ * @since 1.9.8
50
  *
51
+ * @param string $content Post content.
52
+ * @return string Filtered post content
53
  */
54
  function tptn_rss_filter( $content ) {
55
+ global $post;
56
 
57
  $id = intval( $post->ID );
58
 
59
+ $add_to = tptn_get_option( 'add_to' );
60
+
61
+ if ( $add_to['feed'] ) {
62
  return $content . '<div class="tptn_counter" id="tptn_counter_' . $id . '">' . get_tptn_post_count( $id ) . '</div>';
63
  } else {
64
  return $content;
71
  /**
72
  * Function to manually display count.
73
  *
74
+ * @since 1.0
75
+ * @param int|boolean $echo Flag to echo the output.
76
+ * @return string Formatted string if $echo is set to 0|false
77
  */
78
  function echo_tptn_post_count( $echo = 1 ) {
79
+ global $post;
80
 
81
  $home_url = home_url( '/' );
82
 
83
  /**
84
  * Filter the script URL of the counter.
85
  *
86
+ * @since 2.0
87
  */
88
  $home_url = apply_filters( 'tptn_view_counter_script_url', $home_url );
89
 
92
 
93
  $id = intval( $post->ID );
94
 
95
+ $nonce_action = 'tptn-nonce-' . $id;
96
+ $nonce = wp_create_nonce( $nonce_action );
97
 
98
+ if ( tptn_get_option( 'dynamic_post_count' ) ) {
99
  $output = '<div class="tptn_counter" id="tptn_counter_' . $id . '"><script type="text/javascript" data-cfasync="false" src="' . $home_url . '?top_ten_id=' . $id . '&amp;view_counter=1&amp;_wpnonce=' . $nonce . '"></script></div>';
100
  } else {
101
  $output = '<div class="tptn_counter" id="tptn_counter_' . $id . '">' . get_tptn_post_count( $id ) . '</div>';
104
  /**
105
  * Filter the viewed count script
106
  *
107
+ * @since 2.0.0
108
  *
109
+ * @param string $output Counter viewed count code
110
  */
111
  $output = apply_filters( 'tptn_view_post_count', $output );
112
 
113
  if ( $echo ) {
114
+ echo $output; // WPCS: XSS OK.
115
  } else {
116
  return $output;
117
  }
121
  /**
122
  * Return the formatted post count for the supplied ID.
123
  *
124
+ * @since 1.9.2
125
+ * @param int|string $id Post ID.
126
+ * @param int|string $blog_id Blog ID.
127
+ * @return int|string Formatted post count
128
  */
129
  function get_tptn_post_count( $id = false, $blog_id = false ) {
 
130
 
131
+ $count_disp_form = stripslashes( tptn_get_option( 'count_disp_form' ) );
132
+ $count_disp_form_zero = stripslashes( tptn_get_option( 'count_disp_form_zero' ) );
133
+ $totalcntaccess = get_tptn_post_count_only( $id, 'total', $blog_id );
134
 
135
  if ( $id > 0 ) {
136
 
177
  /**
178
  * Returns the post count.
179
  *
180
+ * @since 1.9.8.5
181
  *
182
+ * @param mixed $id Post ID.
183
+ * @param string $count Which count to return? total, daily or overall.
184
  * @param bool $blog_id Blog ID.
185
+ * @return int Post count
186
  */
187
  function get_tptn_post_count_only( $id = false, $count = 'total', $blog_id = false ) {
188
+ global $wpdb;
189
 
190
+ $table_name = $wpdb->base_prefix . 'top_ten';
191
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
192
 
193
  if ( empty( $blog_id ) ) {
197
  if ( $id > 0 ) {
198
  switch ( $count ) {
199
  case 'total':
200
+ $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // WPCS: unprepared SQL OK.
201
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->cntaccess : 0 ) );
202
  break;
203
  case 'daily':
204
+ $daily_range = tptn_get_option( 'daily_range' );
205
+ $hour_range = tptn_get_option( 'hour_range' );
206
 
207
+ if ( tptn_get_option( 'daily_midnight' ) ) {
208
  $current_time = current_time( 'timestamp', 0 );
209
+ $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
210
+ $from_date = gmdate( 'Y-m-d 0', $from_date );
211
  } else {
212
  $current_time = current_time( 'timestamp', 0 );
213
+ $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
214
+ $from_date = gmdate( 'Y-m-d H', $from_date );
215
  }
216
 
217
+ $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name_daily} WHERE postnumber = %d AND blog_id = %d AND dp_date >= %s GROUP BY postnumber ", array( $id, $blog_id, $from_date ) ) ); // WPCS: unprepared SQL OK.
218
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
219
  break;
220
  case 'overall':
221
+ $resultscount = $wpdb->get_row( 'SELECT SUM(cntaccess) as sum_count FROM ' . $table_name ); // WPCS: unprepared SQL OK.
222
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
223
  break;
224
  }
225
  return apply_filters( 'tptn_post_count_only', $cntaccess );
includes/cron.php CHANGED
@@ -8,21 +8,34 @@
8
  /**
9
  * Function to truncate daily run.
10
  *
11
- * @since 1.9.9.1
12
  */
13
  function tptn_cron() {
14
  global $wpdb;
15
 
16
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
17
 
 
 
 
 
 
 
 
 
 
 
 
18
  $current_time = current_time( 'timestamp', 0 );
19
- $from_date = strtotime( '-90 DAY' , $current_time );
20
- $from_date = gmdate( 'Y-m-d H' , $from_date );
21
 
22
- $resultscount = $wpdb->query( $wpdb->prepare( // WPCS: unprepared SQL OK.
23
- "DELETE FROM {$table_name_daily} WHERE dp_date <= '%s' ",
24
- $from_date
25
- ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
 
 
26
 
27
  }
28
  add_action( 'tptn_cron_hook', 'tptn_cron' );
@@ -31,10 +44,10 @@ add_action( 'tptn_cron_hook', 'tptn_cron' );
31
  /**
32
  * Function to enable run or actions.
33
  *
34
- * @since 1.9
35
- * @param int $hour Hour.
36
- * @param int $min Minute.
37
- * @param int $recurrence Frequency.
38
  */
39
  function tptn_enable_run( $hour, $min, $recurrence ) {
40
  // Invoke WordPress internal cron.
@@ -50,7 +63,7 @@ function tptn_enable_run( $hour, $min, $recurrence ) {
50
  /**
51
  * Function to disable daily run or actions.
52
  *
53
- * @since 1.9
54
  */
55
  function tptn_disable_run() {
56
  if ( wp_next_scheduled( 'tptn_cron_hook' ) ) {
@@ -64,26 +77,26 @@ if ( ! function_exists( 'ald_more_reccurences' ) ) :
64
  /**
65
  * Function to add weekly and fortnightly recurrences. Filters `cron_schedules`.
66
  *
67
- * @param array $schedules Array of existing schedules.
68
- * @return array Filtered array with new schedules
69
  */
70
  function ald_more_reccurences( $schedules ) {
71
  // Add a 'weekly' interval.
72
- $schedules['weekly'] = array(
73
  'interval' => WEEK_IN_SECONDS,
74
- 'display' => __( 'Once Weekly', 'top-10' ),
75
  );
76
  $schedules['fortnightly'] = array(
77
  'interval' => 2 * WEEK_IN_SECONDS,
78
- 'display' => __( 'Once Fortnightly', 'top-10' ),
79
  );
80
- $schedules['monthly'] = array(
81
  'interval' => 30 * DAY_IN_SECONDS,
82
- 'display' => __( 'Once Monthly', 'top-10' ),
83
  );
84
- $schedules['quarterly'] = array(
85
  'interval' => 90 * DAY_IN_SECONDS,
86
- 'display' => __( 'Once quarterly', 'top-10' ),
87
  );
88
  return $schedules;
89
  }
8
  /**
9
  * Function to truncate daily run.
10
  *
11
+ * @since 1.9.9.1
12
  */
13
  function tptn_cron() {
14
  global $wpdb;
15
 
16
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
17
 
18
+ $delete_from = 90;
19
+
20
+ /**
21
+ * Override maintenance day range.
22
+ *
23
+ * @since 2.5.0
24
+ *
25
+ * @param int $delete_from Number of days before which post data is deleted from daily tables.
26
+ */
27
+ $delete_from = apply_filters( 'tptn_maintenance_days', $delete_from );
28
+
29
  $current_time = current_time( 'timestamp', 0 );
30
+ $from_date = strtotime( "-{$delete_from} DAY", $current_time );
31
+ $from_date = gmdate( 'Y-m-d H', $from_date );
32
 
33
+ $resultscount = $wpdb->query(
34
+ $wpdb->prepare(
35
+ "DELETE FROM {$table_name_daily} WHERE dp_date <= %s ",
36
+ $from_date
37
+ )
38
+ ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
39
 
40
  }
41
  add_action( 'tptn_cron_hook', 'tptn_cron' );
44
  /**
45
  * Function to enable run or actions.
46
  *
47
+ * @since 1.9
48
+ * @param int $hour Hour.
49
+ * @param int $min Minute.
50
+ * @param int $recurrence Frequency.
51
  */
52
  function tptn_enable_run( $hour, $min, $recurrence ) {
53
  // Invoke WordPress internal cron.
63
  /**
64
  * Function to disable daily run or actions.
65
  *
66
+ * @since 1.9
67
  */
68
  function tptn_disable_run() {
69
  if ( wp_next_scheduled( 'tptn_cron_hook' ) ) {
77
  /**
78
  * Function to add weekly and fortnightly recurrences. Filters `cron_schedules`.
79
  *
80
+ * @param array $schedules Array of existing schedules.
81
+ * @return array Filtered array with new schedules
82
  */
83
  function ald_more_reccurences( $schedules ) {
84
  // Add a 'weekly' interval.
85
+ $schedules['weekly'] = array(
86
  'interval' => WEEK_IN_SECONDS,
87
+ 'display' => __( 'Once Weekly', 'top-10' ),
88
  );
89
  $schedules['fortnightly'] = array(
90
  'interval' => 2 * WEEK_IN_SECONDS,
91
+ 'display' => __( 'Once Fortnightly', 'top-10' ),
92
  );
93
+ $schedules['monthly'] = array(
94
  'interval' => 30 * DAY_IN_SECONDS,
95
+ 'display' => __( 'Once Monthly', 'top-10' ),
96
  );
97
+ $schedules['quarterly'] = array(
98
  'interval' => 90 * DAY_IN_SECONDS,
99
+ 'display' => __( 'Once quarterly', 'top-10' ),
100
  );
101
  return $schedules;
102
  }
includes/deprecated.php CHANGED
@@ -10,7 +10,7 @@
10
  /**
11
  * Holds the filesystem directory path (with trailing slash) for Top 10
12
  *
13
- * @since 1.5
14
  * @deprecated 2.3
15
  *
16
  * @var string
@@ -21,7 +21,7 @@ $tptn_path = plugin_dir_path( TOP_TEN_PLUGIN_FILE );
21
  /**
22
  * Holds the URL for Top 10
23
  *
24
- * @since 1.5
25
  * @deprecated 2.3
26
  *
27
  * @var string
@@ -32,11 +32,11 @@ $tptn_url = plugins_url() . '/' . plugin_basename( dirname( TOP_TEN_PLUGIN_FILE
32
  /**
33
  * Filter to add related posts to feeds.
34
  *
35
- * @since 1.9.8
36
- * @deprecated 2.2.0
37
  *
38
- * @param string $content Post content.
39
- * @return string Filtered post content
40
  */
41
  function ald_tptn_rss( $content ) {
42
 
@@ -49,23 +49,25 @@ function ald_tptn_rss( $content ) {
49
  /**
50
  * Function to update the post views for the current post. Filters `the_content`.
51
  *
52
- * @since 1.0
53
  *
54
  * @deprecated 2.4.0
55
  *
56
- * @param string $content Post content.
57
  */
58
  function tptn_add_viewed_count( $content = '' ) {
59
  global $post, $tptn_settings;
60
 
61
  _deprecated_function( __FUNCTION__, '2.4.0' );
62
 
63
- $home_url = home_url( '/' );
 
 
64
 
65
  /**
66
  * Filter the script URL of the counter.
67
  *
68
- * @since 2.0
69
  */
70
  $home_url = apply_filters( 'tptn_add_counter_script_url', $home_url );
71
 
@@ -74,29 +76,32 @@ function tptn_add_viewed_count( $content = '' ) {
74
 
75
  if ( is_singular() && 'draft' !== $post->post_status ) {
76
 
77
- $current_user = wp_get_current_user(); // Let's get the current user
78
- $post_author = ( $current_user->ID == $post->post_author ) ? true : false; // Is the current user the post author?
79
- $current_user_admin = ( current_user_can( 'manage_options' ) ) ? true : false; // Is the current user an admin?
80
- $current_user_editor = ( ( current_user_can( 'edit_others_posts' ) ) && ( ! current_user_can( 'manage_options' ) ) ) ? true : false; // Is the current user an editor?
81
 
82
  $include_code = true;
83
- if ( ( $post_author ) && ( ! $tptn_settings['track_authors'] ) ) {
84
  $include_code = false;
85
  }
86
- if ( ( $current_user_admin ) && ( ! $tptn_settings['track_admins'] ) ) {
87
  $include_code = false;
88
  }
89
- if ( ( $current_user_editor ) && ( ! $tptn_settings['track_editors'] ) ) {
 
 
 
90
  $include_code = false;
91
  }
92
 
93
  if ( $include_code ) {
94
 
95
- $output = '';
96
- $id = intval( $post->ID );
97
- $blog_id = get_current_blog_id();
98
- $activate_counter = $tptn_settings['activate_overall'] ? 1 : 0; // It's 1 if we're updating the overall count.
99
- $activate_counter = $activate_counter + ( $tptn_settings['activate_daily'] ? 10 : 0 ); // It's 10 if we're updating the daily count.
100
 
101
  if ( $activate_counter > 0 ) {
102
  $output = '
@@ -116,13 +121,13 @@ function tptn_add_viewed_count( $content = '' ) {
116
  /**
117
  * Filter the counter script
118
  *
119
- * @since 1.9.8.5
120
  *
121
- * @param string $output Counter script code
122
  */
123
  $output = apply_filters( 'tptn_viewed_count', $output );
124
 
125
- echo $output;
126
  }
127
  }
128
  }
@@ -143,10 +148,178 @@ function tptn_add_tracker( $echo = true ) {
143
  _deprecated_function( __FUNCTION__, '2.4.0' );
144
 
145
  if ( $echo ) {
146
- echo tptn_add_viewed_count( '' );
147
  } else {
148
  return tptn_add_viewed_count( '' );
149
  }
150
  }
151
 
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Holds the filesystem directory path (with trailing slash) for Top 10
12
  *
13
+ * @since 1.5
14
  * @deprecated 2.3
15
  *
16
  * @var string
21
  /**
22
  * Holds the URL for Top 10
23
  *
24
+ * @since 1.5
25
  * @deprecated 2.3
26
  *
27
  * @var string
32
  /**
33
  * Filter to add related posts to feeds.
34
  *
35
+ * @since 1.9.8
36
+ * @deprecated 2.2.0
37
  *
38
+ * @param string $content Post content.
39
+ * @return string Filtered post content
40
  */
41
  function ald_tptn_rss( $content ) {
42
 
49
  /**
50
  * Function to update the post views for the current post. Filters `the_content`.
51
  *
52
+ * @since 1.0
53
  *
54
  * @deprecated 2.4.0
55
  *
56
+ * @param string $content Post content.
57
  */
58
  function tptn_add_viewed_count( $content = '' ) {
59
  global $post, $tptn_settings;
60
 
61
  _deprecated_function( __FUNCTION__, '2.4.0' );
62
 
63
+ $home_url = home_url( '/' );
64
+ $track_users = tptn_get_option( 'track_users' );
65
+ $trackers = tptn_get_option( 'trackers' );
66
 
67
  /**
68
  * Filter the script URL of the counter.
69
  *
70
+ * @since 2.0
71
  */
72
  $home_url = apply_filters( 'tptn_add_counter_script_url', $home_url );
73
 
76
 
77
  if ( is_singular() && 'draft' !== $post->post_status ) {
78
 
79
+ $current_user = wp_get_current_user(); // Let's get the current user.
80
+ $post_author = ( $current_user->ID == $post->post_author ) ? true : false; // Is the current user the post author?
81
+ $current_user_admin = ( current_user_can( 'manage_options' ) ) ? true : false; // Is the current user an admin?
82
+ $current_user_editor = ( ( current_user_can( 'edit_others_posts' ) ) && ( ! current_user_can( 'manage_options' ) ) ) ? true : false; // Is the current user an editor?
83
 
84
  $include_code = true;
85
+ if ( ( $post_author ) && ( empty( $track_users['authors'] ) ) ) {
86
  $include_code = false;
87
  }
88
+ if ( ( $current_user_admin ) && ( empty( $track_users['admins'] ) ) ) {
89
  $include_code = false;
90
  }
91
+ if ( ( $current_user_editor ) && ( empty( $track_users['editors'] ) ) ) {
92
+ $include_code = false;
93
+ }
94
+ if ( ( $current_user->exists() ) && ( ! tptn_get_option( 'logged_in' ) ) ) {
95
  $include_code = false;
96
  }
97
 
98
  if ( $include_code ) {
99
 
100
+ $output = '';
101
+ $id = intval( $post->ID );
102
+ $blog_id = get_current_blog_id();
103
+ $activate_counter = ! empty( $trackers['overall'] ) ? 1 : 0; // It's 1 if we're updating the overall count.
104
+ $activate_counter = $activate_counter + ( ! empty( $trackers['daily'] ) ? 10 : 0 ); // It's 10 if we're updating the daily count.
105
 
106
  if ( $activate_counter > 0 ) {
107
  $output = '
121
  /**
122
  * Filter the counter script
123
  *
124
+ * @since 1.9.8.5
125
  *
126
+ * @param string $output Counter script code
127
  */
128
  $output = apply_filters( 'tptn_viewed_count', $output );
129
 
130
+ echo $output; // WPCS: XSS OK.
131
  }
132
  }
133
  }
148
  _deprecated_function( __FUNCTION__, '2.4.0' );
149
 
150
  if ( $echo ) {
151
+ echo tptn_add_viewed_count( '' ); // WPCS: XSS OK.
152
  } else {
153
  return tptn_add_viewed_count( '' );
154
  }
155
  }
156
 
157
 
158
+ /**
159
+ * Default Options.
160
+ *
161
+ * @since 1.0
162
+ *
163
+ * @deprecated 2.5.0
164
+ *
165
+ * @return array
166
+ */
167
+ function tptn_default_options() {
168
+
169
+ _deprecated_function( __FUNCTION__, '2.5.0' );
170
+
171
+ $title = __( '<h3>Popular Posts</h3>', 'top-10' );
172
+ $title_daily = __( '<h3>Daily Popular</h3>', 'top-10' );
173
+ $blank_output_text = __( 'No top posts yet', 'top-10' );
174
+ $thumb_default = plugins_url( 'default.png', __FILE__ );
175
+
176
+ // Get relevant post types.
177
+ $args = array(
178
+ 'public' => true,
179
+ '_builtin' => true,
180
+ );
181
+ $post_types = http_build_query( get_post_types( $args ), '', '&' );
182
+
183
+ $tptn_settings = array(
184
+
185
+ /* General options */
186
+ 'activate_daily' => true, // Activate the daily count.
187
+ 'activate_overall' => true, // Activate overall count.
188
+ 'cache' => false, // Enable Caching using Transienst API.
189
+ 'cache_time' => HOUR_IN_SECONDS, // Cache for 1 Hour.
190
+ 'daily_midnight' => true, // Start daily counts from midnight (default as old behaviour).
191
+ 'daily_range' => '1', // Daily Popular will contain posts of how many days?
192
+ 'hour_range' => '0', // Daily Popular will contain posts of how many hours?
193
+ 'uninstall_clean_options' => true, // Cleanup options.
194
+ 'uninstall_clean_tables' => false, // Cleanup tables.
195
+ 'show_metabox' => true, // Show metabox to admins.
196
+ 'show_metabox_admins' => false, // Limit to admins as well.
197
+ 'show_credit' => false, // Add link to plugin page of my blog in top posts list.
198
+
199
+ /* Counter and tracker options */
200
+ 'add_to_content' => true, // Add post count to content (only on single posts).
201
+ 'count_on_pages' => true, // Add post count to pages.
202
+ 'add_to_feed' => false, // Add post count to feed (full).
203
+ 'add_to_home' => false, // Add post count to home page.
204
+ 'add_to_category_archives' => false, // Add post count to category archives.
205
+ 'add_to_tag_archives' => false, // Add post count to tag archives.
206
+ 'add_to_archives' => false, // Add post count to other archives.
207
+
208
+ 'count_disp_form' => '(Visited %totalcount% times, %dailycount% visits today)', // Format to display the count.
209
+ 'count_disp_form_zero' => 'No visits yet', // What to display where there are no hits?
210
+ 'dynamic_post_count' => false, // Use JavaScript for displaying the post count.
211
+
212
+ 'tracker_type' => 'query_based', // Tracker type.
213
+ 'track_authors' => false, // Track Authors visits.
214
+ 'track_admins' => true, // Track Admin visits.
215
+ 'track_editors' => true, // Track Admin visits.
216
+ 'pv_in_admin' => true, // Add an extra column on edit posts/pages to display page views?
217
+ 'show_count_non_admins' => true, // Show counts to non-admins.
218
+
219
+ /* Popular post list options */
220
+ 'limit' => '10', // How many posts to display?
221
+ 'how_old' => '0', // How old posts? Default is no limit.
222
+ 'post_types' => $post_types, // WordPress custom post types.
223
+ 'exclude_categories' => '', // Exclude these categories.
224
+ 'exclude_cat_slugs' => '', // Exclude these categories (slugs).
225
+ 'exclude_post_ids' => '', // Comma separated list of page / post IDs that are to be excluded in the results.
226
+
227
+ 'title' => $title, // Title of Popular Posts.
228
+ 'title_daily' => $title_daily, // Title of Daily Popular.
229
+ 'blank_output' => false, // Blank output? Default is "blank Output test".
230
+ 'blank_output_text' => $blank_output_text, // Blank output text.
231
+
232
+ 'show_excerpt' => false, // Show description in list item.
233
+ 'excerpt_length' => '10', // Length of characters.
234
+ 'show_date' => false, // Show date in list item.
235
+ 'show_author' => false, // Show author in list item.
236
+ 'title_length' => '60', // Limit length of post title.
237
+ 'disp_list_count' => true, // Display count in popular lists?
238
+
239
+ 'link_new_window' => false, // Open links in new window.
240
+ 'link_nofollow' => false, // Add no-follow to links.
241
+ 'exclude_on_post_ids' => '', // Comma separate list of page/post IDs to not display related posts on.
242
+
243
+ // List HTML options.
244
+ 'before_list' => '<ul>', // Before the entire list.
245
+ 'after_list' => '</ul>', // After the entire list.
246
+ 'before_list_item' => '<li>', // Before each list item.
247
+ 'after_list_item' => '</li>', // After each list item.
248
+
249
+ /* Thumbnail options */
250
+ 'post_thumb_op' => 'text_only', // Display only text in posts.
251
+ 'thumb_size' => 'tptn_thumbnail', // Default thumbnail size.
252
+ 'thumb_width' => '150', // Max width of thumbnails.
253
+ 'thumb_height' => '150', // Max height of thumbnails.
254
+ 'thumb_crop' => true, // Crop mode. default is hard crop.
255
+ 'thumb_html' => 'html', // Use HTML or CSS for width and height of the thumbnail?
256
+
257
+ 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
258
+ 'scan_images' => true, // Scan post for images.
259
+ 'thumb_default' => $thumb_default, // Default thumbnail image.
260
+ 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
261
+
262
+ /* Custom styles */
263
+ 'custom_CSS' => '', // Custom CSS to style the output.
264
+ 'include_default_style' => false, // Include default Top 10 style.
265
+ 'tptn_styles' => 'no_style', // Defaault style is left thubnails.
266
+
267
+ /* Maintenance cron */
268
+ 'cron_on' => false, // Run cron daily?
269
+ 'cron_hour' => '0', // Cron Hour.
270
+ 'cron_min' => '0', // Cron Minute.
271
+ 'cron_recurrence' => 'weekly', // Frequency of cron.
272
+ );
273
+
274
+ /**
275
+ * Filters the default options array.
276
+ *
277
+ * @since 1.9.10.1
278
+ *
279
+ * @param array $tptn_settings Default options
280
+ */
281
+ return apply_filters( 'tptn_default_options', $tptn_settings );
282
+ }
283
+
284
+
285
+ /**
286
+ * Function to read options from the database.
287
+ *
288
+ * @since 1.0
289
+ *
290
+ * @deprecated 2.5.0
291
+ *
292
+ * @return array
293
+ */
294
+ function tptn_read_options() {
295
+
296
+ _deprecated_function( __FUNCTION__, '2.5.0', 'tptn_get_settings()' );
297
+
298
+ $tptn_settings_changed = false;
299
+
300
+ $defaults = tptn_default_options();
301
+
302
+ $tptn_settings = array_map( 'stripslashes', (array) get_option( 'ald_tptn_settings' ) );
303
+ unset( $tptn_settings[0] ); // Produced by the (array) casting when there's nothing in the DB.
304
+
305
+ foreach ( $defaults as $k => $v ) {
306
+ if ( ! isset( $tptn_settings[ $k ] ) ) {
307
+ $tptn_settings[ $k ] = $v;
308
+ $tptn_settings_changed = true;
309
+ }
310
+ }
311
+ if ( true === $tptn_settings_changed ) {
312
+ update_option( 'ald_tptn_settings', $tptn_settings );
313
+ }
314
+
315
+ /**
316
+ * Filters the options array.
317
+ *
318
+ * @since 1.9.10.1
319
+ *
320
+ * @param array $tptn_settings Options read from the database
321
+ */
322
+ return apply_filters( 'tptn_read_options', $tptn_settings );
323
+ }
324
+
325
+
includes/formatting.php CHANGED
@@ -8,11 +8,11 @@
8
  /**
9
  * Function to create an excerpt for the post.
10
  *
11
- * @since 1.6
12
- * @param int $id Post ID.
13
- * @param int|string $excerpt_length Length of the excerpt in words.
14
  * @param bool $use_excerpt Use Excerpt.
15
- * @return string Excerpt
16
  */
17
  function tptn_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
18
  $content = '';
@@ -34,12 +34,12 @@ function tptn_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
34
  /**
35
  * Filters excerpt generated by tptn.
36
  *
37
- * @since 1.9.10.1
38
  *
39
- * @param array $output Formatted excerpt
40
- * @param int $id Post ID
41
- * @param int $excerpt_length Length of the excerpt
42
- * @param boolean $use_excerpt Use the excerpt?
43
  */
44
  return apply_filters( 'tptn_excerpt', $output, $id, $excerpt_length, $use_excerpt );
45
  }
@@ -48,10 +48,10 @@ function tptn_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
48
  /**
49
  * Function to limit content by characters.
50
  *
51
- * @since 1.9.8
52
- * @param string $content Content to be used to make an excerpt.
53
- * @param int $no_of_char Maximum length of excerpt in characters.
54
- * @return string Formatted content.
55
  */
56
  function tptn_max_formatted_content( $content, $no_of_char = -1 ) {
57
  $content = strip_tags( $content );
@@ -70,12 +70,12 @@ function tptn_max_formatted_content( $content, $no_of_char = -1 ) {
70
  /**
71
  * Filters formatted content after cropping.
72
  *
73
- * @since 1.9.10.1
74
  *
75
- * @param string $content Formatted content
76
- * @param int $no_of_char Maximum length of excerpt in characters
77
  */
78
- return apply_filters( 'tptn_max_formatted_content' , $content, $no_of_char );
79
  }
80
 
81
 
8
  /**
9
  * Function to create an excerpt for the post.
10
  *
11
+ * @since 1.6
12
+ * @param int $id Post ID.
13
+ * @param int|string $excerpt_length Length of the excerpt in words.
14
  * @param bool $use_excerpt Use Excerpt.
15
+ * @return string Excerpt
16
  */
17
  function tptn_excerpt( $id, $excerpt_length = 0, $use_excerpt = true ) {
18
  $content = '';
34
  /**
35
  * Filters excerpt generated by tptn.
36
  *
37
+ * @since 1.9.10.1
38
  *
39
+ * @param array $output Formatted excerpt
40
+ * @param int $id Post ID
41
+ * @param int $excerpt_length Length of the excerpt
42
+ * @param boolean $use_excerpt Use the excerpt?
43
  */
44
  return apply_filters( 'tptn_excerpt', $output, $id, $excerpt_length, $use_excerpt );
45
  }
48
  /**
49
  * Function to limit content by characters.
50
  *
51
+ * @since 1.9.8
52
+ * @param string $content Content to be used to make an excerpt.
53
+ * @param int $no_of_char Maximum length of excerpt in characters.
54
+ * @return string Formatted content.
55
  */
56
  function tptn_max_formatted_content( $content, $no_of_char = -1 ) {
57
  $content = strip_tags( $content );
70
  /**
71
  * Filters formatted content after cropping.
72
  *
73
+ * @since 1.9.10.1
74
  *
75
+ * @param string $content Formatted content
76
+ * @param int $no_of_char Maximum length of excerpt in characters
77
  */
78
+ return apply_filters( 'tptn_max_formatted_content', $content, $no_of_char );
79
  }
80
 
81
 
includes/js/top-10-tracker.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function($){var data={'action':'tptn_tracker','top_ten_nonce':ajax_tptn_tracker.top_ten_nonce,'top_ten_id':ajax_tptn_tracker.top_ten_id,'top_ten_blog_id':ajax_tptn_tracker.top_ten_blog_id,'activate_counter':ajax_tptn_tracker.activate_counter};jQuery.post(ajax_tptn_tracker.ajax_url,data);});
1
+ jQuery(document).ready(function($){var data={'action':'tptn_tracker','top_ten_id':ajax_tptn_tracker.top_ten_id,'top_ten_blog_id':ajax_tptn_tracker.top_ten_blog_id,'activate_counter':ajax_tptn_tracker.activate_counter};jQuery.post(ajax_tptn_tracker.ajax_url,data);});
includes/l10n.php CHANGED
@@ -8,7 +8,7 @@
8
  /**
9
  * Function to load translation files.
10
  *
11
- * @since 1.9.10.1
12
  */
13
  function tptn_lang_init() {
14
  load_plugin_textdomain( 'top-10', false, dirname( plugin_basename( TOP_TEN_PLUGIN_FILE ) ) . '/languages/' );
@@ -19,9 +19,9 @@ add_action( 'plugins_loaded', 'tptn_lang_init' );
19
  /**
20
  * Fetch the post of the correct language.
21
  *
22
- * @since 2.1.0
23
  *
24
- * @param int $post_id Post ID.
25
  */
26
  function tptn_object_id_cur_lang( $post_id ) {
27
 
@@ -30,10 +30,10 @@ function tptn_object_id_cur_lang( $post_id ) {
30
  /**
31
  * Filter to modify if the original language ID is returned.
32
  *
33
- * @since 2.2.3
34
  *
35
- * @param bool $return_original_if_missing
36
- * @param int $post_id Post ID
37
  */
38
  $return_original_if_missing = apply_filters( 'tptn_wpml_return_original', $return_original_if_missing, $post_id );
39
 
@@ -48,9 +48,9 @@ function tptn_object_id_cur_lang( $post_id ) {
48
  /**
49
  * Filters object ID for current language (WPML).
50
  *
51
- * @since 2.1.0
52
  *
53
- * @param int $post_id Post ID
54
  */
55
  return apply_filters( 'tptn_object_id_cur_lang', $post_id );
56
  }
8
  /**
9
  * Function to load translation files.
10
  *
11
+ * @since 1.9.10.1
12
  */
13
  function tptn_lang_init() {
14
  load_plugin_textdomain( 'top-10', false, dirname( plugin_basename( TOP_TEN_PLUGIN_FILE ) ) . '/languages/' );
19
  /**
20
  * Fetch the post of the correct language.
21
  *
22
+ * @since 2.1.0
23
  *
24
+ * @param int $post_id Post ID.
25
  */
26
  function tptn_object_id_cur_lang( $post_id ) {
27
 
30
  /**
31
  * Filter to modify if the original language ID is returned.
32
  *
33
+ * @since 2.2.3
34
  *
35
+ * @param bool $return_original_if_missing
36
+ * @param int $post_id Post ID
37
  */
38
  $return_original_if_missing = apply_filters( 'tptn_wpml_return_original', $return_original_if_missing, $post_id );
39
 
48
  /**
49
  * Filters object ID for current language (WPML).
50
  *
51
+ * @since 2.1.0
52
  *
53
+ * @param int $post_id Post ID
54
  */
55
  return apply_filters( 'tptn_object_id_cur_lang', $post_id );
56
  }
includes/modules/class-top-10-widget.php DELETED
@@ -1,350 +0,0 @@
1
- <?php
2
- /**
3
- * Widget class.
4
- *
5
- * @package Top_Ten
6
- * @author Ajay D'Souza <me@ajaydsouza.com>
7
- * @license GPL-2.0+
8
- * @link https://webberzone.com
9
- * @copyright 2008-2016 Ajay D'Souza
10
- */
11
-
12
- // If this file is called directly, abort.
13
- if ( ! defined( 'WPINC' ) ) {
14
- die;
15
- }
16
-
17
- /**
18
- * Top 10 Widget.
19
- *
20
- * @extends WP_Widget
21
- */
22
- class Top_Ten_Widget extends WP_Widget {
23
-
24
- /**
25
- * Register widget with WordPress.
26
- */
27
- function __construct() {
28
- parent::__construct(
29
- 'widget_tptn_pop', // Base ID.
30
- __( 'Popular Posts [Top 10]', 'top-10' ), // Name.
31
- array(
32
- 'description' => __( 'Display popular posts', 'where-did-they-go-from-here' ),
33
- 'customize_selective_refresh' => true,
34
- )
35
- );
36
-
37
- add_action( 'wp_enqueue_scripts', array( $this, 'front_end_styles' ) );
38
-
39
- }
40
-
41
- /**
42
- * Back-end widget form.
43
- *
44
- * @see WP_Widget::form()
45
- *
46
- * @param array $instance Previously saved values from database.
47
- */
48
- function form( $instance ) {
49
- $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
50
- $limit = isset( $instance['limit'] ) ? esc_attr( $instance['limit'] ) : '';
51
- $offset = isset( $instance['offset'] ) ? esc_attr( $instance['offset'] ) : '';
52
- $disp_list_count = isset( $instance['disp_list_count'] ) ? esc_attr( $instance['disp_list_count'] ) : '';
53
- $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
54
- $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
55
- $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
56
- $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : 'text_only';
57
- $thumb_height = isset( $instance['thumb_height'] ) ? esc_attr( $instance['thumb_height'] ) : '';
58
- $thumb_width = isset( $instance['thumb_width'] ) ? esc_attr( $instance['thumb_width'] ) : '';
59
- $daily = isset( $instance['daily'] ) ? esc_attr( $instance['daily'] ) : 'overall';
60
- $daily_range = isset( $instance['daily_range'] ) ? esc_attr( $instance['daily_range'] ) : '';
61
- $hour_range = isset( $instance['hour_range'] ) ? esc_attr( $instance['hour_range'] ) : '';
62
-
63
- // Parse the Post types.
64
- $post_types = array();
65
- if ( isset( $instance['post_types'] ) ) {
66
- $post_types = $instance['post_types'];
67
- parse_str( $post_types, $post_types ); // Save post types in $post_types variable.
68
- }
69
- $wp_post_types = get_post_types( array(
70
- 'public' => true,
71
- ) );
72
- $posts_types_inc = array_intersect( $wp_post_types, $post_types );
73
-
74
- ?>
75
- <p>
76
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
77
- <?php esc_html_e( 'Title', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
78
- </label>
79
- </p>
80
- <p>
81
- <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>">
82
- <?php esc_html_e( 'No. of posts', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" />
83
- </label>
84
- </p>
85
- <p>
86
- <label for="<?php echo esc_attr( $this->get_field_id( 'offset' ) ); ?>">
87
- <?php esc_html_e( 'Offset', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'offset' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'offset' ) ); ?>" type="text" value="<?php echo esc_attr( $offset ); ?>" />
88
- </label>
89
- </p>
90
- <p>
91
- <select class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'daily' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'daily' ) ); ?>">
92
- <option value="overall" <?php selected( 'overall', $daily, true ); ?>><?php esc_html_e( 'Overall', 'top-10' ); ?></option>
93
- <option value="daily" <?php selected( 'daily', $daily, true ); ?>><?php esc_html_e( 'Custom time period (Enter below)', 'top-10' ); ?></option>
94
- </select>
95
- </p>
96
- <p>
97
- <?php esc_html_e( 'In days and hours (applies only to custom option above)', 'top-10' ); ?>:
98
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'daily_range' ) ); ?>">
99
- <input class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'daily_range' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'daily_range' ) ); ?>" type="text" value="<?php echo esc_attr( $daily_range ); ?>" /> <?php esc_html_e( 'days', 'top-10' ); ?>
100
- </label>
101
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'hour_range' ) ); ?>">
102
- <input class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'hour_range' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'hour_range' ) ); ?>" type="text" value="<?php echo esc_attr( $hour_range ); ?>" /> <?php esc_html_e( 'hours', 'top-10' ); ?>
103
- </label>
104
- </p>
105
- <p>
106
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'disp_list_count' ) ); ?>">
107
- <input id="<?php echo esc_attr_e( $this->get_field_id( 'disp_list_count' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'disp_list_count' ) ); ?>" type="checkbox" <?php if ( $disp_list_count ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( 'Show count?', 'top-10' ); ?>
108
- </label>
109
- </p>
110
- <p>
111
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'show_excerpt' ) ); ?>">
112
- <input id="<?php echo esc_attr_e( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'show_excerpt' ) ); ?>" type="checkbox" <?php if ( $show_excerpt ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( 'Show excerpt?', 'top-10' ); ?>
113
- </label>
114
- </p>
115
- <p>
116
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'show_author' ) ); ?>">
117
- <input id="<?php echo esc_attr_e( $this->get_field_id( 'show_author' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'show_author' ) ); ?>" type="checkbox" <?php if ( $show_author ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( 'Show author?', 'top-10' ); ?>
118
- </label>
119
- </p>
120
- <p>
121
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'show_date' ) ); ?>">
122
- <input id="<?php echo esc_attr_e( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'show_date' ) ); ?>" type="checkbox" <?php if ( $show_date ) { echo 'checked="checked"'; } ?> /> <?php esc_html_e( 'Show date?', 'top-10' ); ?>
123
- </label>
124
- </p>
125
- <p>
126
- <?php esc_html_e( 'Thumbnail options', 'top-10' ); ?>: <br />
127
- <select class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'post_thumb_op' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'post_thumb_op' ) ); ?>">
128
- <option value="inline" <?php selected( 'inline', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, before title','top-10' ); ?></option>
129
- <option value="after" <?php selected( 'after', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, after title','top-10' ); ?></option>
130
- <option value="thumbs_only" <?php selected( 'thumbs_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'Only thumbnails, no text','top-10' ); ?></option>
131
- <option value="text_only" <?php selected( 'text_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'No thumbnails, only text.','top-10' ); ?></option>
132
- </select>
133
- </p>
134
- <p>
135
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'thumb_height' ) ); ?>">
136
- <?php esc_html_e( 'Thumbnail height', 'top-10' ); ?>:
137
- <input class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'thumb_height' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'thumb_height' ) ); ?>" type="text" value="<?php echo esc_attr( $thumb_height ); ?>" />
138
- </label>
139
- </p>
140
- <p>
141
- <label for="<?php echo esc_attr_e( $this->get_field_id( 'thumb_width' ) ); ?>">
142
- <?php esc_html_e( 'Thumbnail width', 'top-10' ); ?>:
143
- <input class="widefat" id="<?php echo esc_attr_e( $this->get_field_id( 'thumb_width' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'thumb_width' ) ); ?>" type="text" value="<?php echo esc_attr( $thumb_width ); ?>" />
144
- </label>
145
- </p>
146
- <p><?php esc_html_e( 'Post types to include:', 'top-10' ); ?><br />
147
-
148
- <?php foreach ( $wp_post_types as $wp_post_type ) { ?>
149
-
150
- <label>
151
- <input id="<?php echo esc_attr_e( $this->get_field_id( 'post_types' ) ); ?>" name="<?php echo esc_attr_e( $this->get_field_name( 'post_types' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr_e( $wp_post_type ); ?>" <?php checked( true, in_array( $wp_post_type, $posts_types_inc, true ), true ); ?> />
152
- <?php echo esc_attr_e( $wp_post_type ); ?>
153
- </label>
154
- <br />
155
-
156
- <?php } ?>
157
- </p>
158
-
159
- <?php
160
- /**
161
- * Fires after Top 10 widget options.
162
- *
163
- * @since 2.0.0
164
- *
165
- * @param array $instance Widget options array
166
- */
167
- do_action( 'tptn_widget_options_after', $instance );
168
- ?>
169
-
170
- <?php
171
- } //ending form creation
172
-
173
- /**
174
- * Sanitize widget form values as they are saved.
175
- *
176
- * @see WP_Widget::update()
177
- *
178
- * @param array $new_instance Values just sent to be saved.
179
- * @param array $old_instance Previously saved values from database.
180
- *
181
- * @return array Updated safe values to be saved.
182
- */
183
- function update( $new_instance, $old_instance ) {
184
- $instance = $old_instance;
185
- $instance['title'] = strip_tags( $new_instance['title'] );
186
- $instance['limit'] = $new_instance['limit'];
187
- $instance['offset'] = $new_instance['offset'];
188
- $instance['daily'] = $new_instance['daily'];
189
- $instance['daily_range'] = strip_tags( $new_instance['daily_range'] );
190
- $instance['hour_range'] = strip_tags( $new_instance['hour_range'] );
191
- $instance['disp_list_count'] = isset( $new_instance['disp_list_count'] ) ? true : false;
192
- $instance['show_excerpt'] = isset( $new_instance['show_excerpt'] ) ? true : false;
193
- $instance['show_author'] = isset( $new_instance['show_author'] ) ? true : false;
194
- $instance['show_date'] = isset( $new_instance['show_date'] ) ? true : false;
195
- $instance['post_thumb_op'] = $new_instance['post_thumb_op'];
196
- $instance['thumb_height'] = $new_instance['thumb_height'];
197
- $instance['thumb_width'] = $new_instance['thumb_width'];
198
-
199
- // Process post types to be selected.
200
- $wp_post_types = get_post_types( array(
201
- 'public' => true,
202
- ) );
203
- $post_types = ( isset( $new_instance['post_types'] ) ) ? $new_instance['post_types'] : array();
204
- $post_types = array_intersect( $wp_post_types, $post_types );
205
- $instance['post_types'] = http_build_query( $post_types, '', '&' );
206
-
207
- /**
208
- * Filters Update widget options array.
209
- *
210
- * @since 2.0.0
211
- *
212
- * @param array $instance Widget options array
213
- */
214
- return apply_filters( 'tptn_widget_options_update' , $instance );
215
- } //ending update
216
-
217
- /**
218
- * Front-end display of widget.
219
- *
220
- * @see WP_Widget::widget()
221
- *
222
- * @param array $args Widget arguments.
223
- * @param array $instance Saved values from database.
224
- */
225
- function widget( $args, $instance ) {
226
- global $tptn_settings, $post;
227
-
228
- // Get the post meta.
229
- if ( isset( $post ) ) {
230
- $tptn_post_meta = get_post_meta( $post->ID, 'tptn_post_meta', true );
231
-
232
- if ( isset( $tptn_post_meta['disable_here'] ) && ( 1 == $tptn_post_meta['disable_here'] ) ) { return; }
233
- }
234
-
235
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? strip_tags( $tptn_settings['title'] ) : $instance['title'] );
236
-
237
- $limit = isset( $instance['limit'] ) ? $instance['limit'] : $tptn_settings['limit'];
238
- if ( empty( $limit ) ) {
239
- $limit = $tptn_settings['limit'];
240
- }
241
-
242
- $offset = isset( $instance['offset'] ) ? $instance['offset'] : 0;
243
- $daily_range = ( empty( $instance['daily_range'] ) ) ? $tptn_settings['daily_range'] : $instance['daily_range'];
244
- $hour_range = ( empty( $instance['hour_range'] ) ) ? $tptn_settings['hour_range'] : $instance['hour_range'];
245
-
246
- $daily = ( isset( $instance['daily'] ) && ( 'daily' === $instance['daily'] ) ) ? true : false;
247
-
248
- $output = $args['before_widget'];
249
- $output .= $args['before_title'] . $title . $args['after_title'];
250
-
251
- $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : 'text_only';
252
-
253
- $thumb_height = ( isset( $instance['thumb_height'] ) && '' !== $instance['thumb_height'] ) ? absint( $instance['thumb_height'] ) : $tptn_settings['thumb_height'];
254
- $thumb_width = ( isset( $instance['thumb_width'] ) && '' !== $instance['thumb_width'] ) ? absint( $instance['thumb_width'] ) : $tptn_settings['thumb_width'];
255
-
256
- $disp_list_count = isset( $instance['disp_list_count'] ) ? esc_attr( $instance['disp_list_count'] ) : '';
257
- $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
258
- $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
259
- $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
260
- $post_types = isset( $instance['post_types'] ) ? $instance['post_types'] : $tptn_settings['post_types'];
261
-
262
- $arguments = array(
263
- 'is_widget' => 1,
264
- 'instance_id' => $this->number,
265
- 'heading' => 0,
266
- 'limit' => $limit,
267
- 'offset' => $offset,
268
- 'daily' => $daily,
269
- 'daily_range' => $daily_range,
270
- 'hour_range' => $hour_range,
271
- 'show_excerpt' => $show_excerpt,
272
- 'show_author' => $show_author,
273
- 'show_date' => $show_date,
274
- 'post_thumb_op' => $post_thumb_op,
275
- 'thumb_height' => $thumb_height,
276
- 'thumb_width' => $thumb_width,
277
- 'disp_list_count' => $disp_list_count,
278
- 'post_types' => $post_types,
279
- );
280
-
281
- /**
282
- * Filters arguments passed to tptn_pop_posts for the widget.
283
- *
284
- * @since 2.0.0
285
- *
286
- * @param array $arguments Widget options array
287
- */
288
- $arguments = apply_filters( 'tptn_widget_options' , $arguments );
289
-
290
- $output .= tptn_pop_posts( $arguments );
291
-
292
- $output .= $args['after_widget'];
293
-
294
- echo $output; // WPCS: XSS OK.
295
-
296
- } //ending function widget
297
-
298
-
299
- /**
300
- * Add styles to the front end if the widget is active.
301
- *
302
- * @since 2.3.0
303
- */
304
- function front_end_styles() {
305
- global $tptn_settings;
306
-
307
- if ( ! 'left_thumbs' === $tptn_settings['tptn_styles'] ) {
308
- return;
309
- }
310
-
311
- // We need to process all instances because this function gets to run only once.
312
- $widget_settings = get_option( $this->option_name );
313
-
314
- foreach ( (array) $widget_settings as $instance => $options ) {
315
-
316
- // Identify instance.
317
- $widget_id = "{$this->id_base}-{$instance}";
318
-
319
- // Check if it's our instance.
320
- if ( ! is_active_widget( false, $widget_id, $this->id_base, true ) ) {
321
- continue; // Not active.
322
- }
323
-
324
- $thumb_height = ( isset( $options['thumb_height'] ) && '' !== $options['thumb_height'] ) ? absint( $options['thumb_height'] ) : $tptn_settings['thumb_height'];
325
- $thumb_width = ( isset( $options['thumb_width'] ) && '' !== $options['thumb_width'] ) ? absint( $options['thumb_width'] ) : $tptn_settings['thumb_width'];
326
-
327
- // Enqueue the custom css for the thumb width and height for this specific widget.
328
- $custom_css = "
329
- .tptn_posts_widget{$instance} img.tptn_thumb {
330
- width: {$thumb_width}px !important;
331
- height: {$thumb_height}px !important;
332
- }
333
- ";
334
-
335
- wp_add_inline_style( 'tptn-style-left-thumbs', $custom_css );
336
-
337
- }
338
-
339
- }
340
- }
341
-
342
-
343
- /**
344
- * Initialise the widget.
345
- */
346
- function tptn_register_widget() {
347
- register_widget( 'Top_Ten_Widget' );
348
- }
349
- add_action( 'widgets_init', 'tptn_register_widget', 1 );
350
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/modules/class-top-ten-count-widget.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget to display the overall count.
4
+ *
5
+ * @package Top_Ten
6
+ * @author Ajay D'Souza <me@ajaydsouza.com>
7
+ * @license GPL-2.0+
8
+ * @link https://webberzone.com
9
+ * @copyright 2008-2016 Ajay D'Souza
10
+ */
11
+
12
+ // If this file is called directly, abort.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+ /**
18
+ * Widget to display the overall count.
19
+ *
20
+ * @extends WP_Widget
21
+ */
22
+ class Top_Ten_Count_Widget extends WP_Widget {
23
+
24
+ /**
25
+ * Register widget with WordPress.
26
+ */
27
+ public function __construct() {
28
+ parent::__construct(
29
+ 'widget_tptn_count', // Base ID.
30
+ __( 'Overall count [Top 10]', 'top-10' ), // Name.
31
+ array(
32
+ 'description' => __( 'Display overall count', 'where-did-they-go-from-here' ),
33
+ 'customize_selective_refresh' => true,
34
+ 'classname' => 'tptn_posts_count_widget',
35
+ )
36
+ );
37
+
38
+ }
39
+
40
+ /**
41
+ * Back-end widget form.
42
+ *
43
+ * @see WP_Widget::form()
44
+ *
45
+ * @param array $instance Previously saved values from database.
46
+ */
47
+ public function form( $instance ) {
48
+ $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
49
+
50
+ ?>
51
+ <p>
52
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
53
+ <?php esc_html_e( 'Title', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
54
+ </label>
55
+ </p>
56
+
57
+ <?php
58
+ /**
59
+ * Fires after Top 10 widget options.
60
+ *
61
+ * @since 2.0.0
62
+ *
63
+ * @param array $instance Widget options array
64
+ */
65
+ do_action( 'tptn_widget_options_after', $instance );
66
+ ?>
67
+
68
+ <?php
69
+ } //ending form creation
70
+
71
+ /**
72
+ * Sanitize widget form values as they are saved.
73
+ *
74
+ * @see WP_Widget::update()
75
+ *
76
+ * @param array $new_instance Values just sent to be saved.
77
+ * @param array $old_instance Previously saved values from database.
78
+ *
79
+ * @return array Updated safe values to be saved.
80
+ */
81
+ public function update( $new_instance, $old_instance ) {
82
+ $instance = $old_instance;
83
+ $instance['title'] = strip_tags( $new_instance['title'] );
84
+
85
+ /**
86
+ * Filters Update widget options array.
87
+ *
88
+ * @since 2.0.0
89
+ *
90
+ * @param array $instance Widget options array
91
+ */
92
+ return apply_filters( 'tptn_widget_options_update', $instance );
93
+ } //ending update
94
+
95
+ /**
96
+ * Front-end display of widget.
97
+ *
98
+ * @see WP_Widget::widget()
99
+ *
100
+ * @param array $args Widget arguments.
101
+ * @param array $instance Saved values from database.
102
+ */
103
+ public function widget( $args, $instance ) {
104
+ global $wpdb;
105
+
106
+ $table_name = $wpdb->base_prefix . 'top_ten';
107
+
108
+ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] );
109
+
110
+ $resultscount = $wpdb->get_row( 'SELECT SUM(cntaccess) as sum_count FROM ' . $table_name ); // WPCS: unprepared SQL OK.
111
+ $cntaccess = number_format_i18n( ( ( $resultscount ) ? $resultscount->sum_count : 0 ) );
112
+
113
+ $output = $args['before_widget'];
114
+ $output .= $args['before_title'] . $title . $args['after_title'];
115
+
116
+ $output .= $cntaccess;
117
+
118
+ $output .= $args['after_widget'];
119
+
120
+ echo $output; // WPCS: XSS OK.
121
+
122
+ } //ending function widget
123
+
124
+ }
125
+
126
+
127
+ /**
128
+ * Initialise the widget.
129
+ */
130
+ function tptn_register_count_widget() {
131
+ register_widget( 'Top_Ten_Count_Widget' );
132
+ }
133
+ add_action( 'widgets_init', 'tptn_register_count_widget', 1 );
134
+
includes/modules/class-top-ten-widget.php ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget class.
4
+ *
5
+ * @package Top_Ten
6
+ * @author Ajay D'Souza <me@ajaydsouza.com>
7
+ * @license GPL-2.0+
8
+ * @link https://webberzone.com
9
+ * @copyright 2008-2016 Ajay D'Souza
10
+ */
11
+
12
+ // If this file is called directly, abort.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+ /**
18
+ * Top 10 Widget.
19
+ *
20
+ * @extends WP_Widget
21
+ */
22
+ class Top_Ten_Widget extends WP_Widget {
23
+
24
+ /**
25
+ * Register widget with WordPress.
26
+ */
27
+ public function __construct() {
28
+ parent::__construct(
29
+ 'widget_tptn_pop', // Base ID.
30
+ __( 'Popular Posts [Top 10]', 'top-10' ), // Name.
31
+ array(
32
+ 'description' => __( 'Display popular posts', 'where-did-they-go-from-here' ),
33
+ 'customize_selective_refresh' => true,
34
+ 'classname' => 'tptn_posts_list_widget',
35
+ )
36
+ );
37
+
38
+ add_action( 'wp_enqueue_scripts', array( $this, 'front_end_styles' ) );
39
+
40
+ }
41
+
42
+ /**
43
+ * Back-end widget form.
44
+ *
45
+ * @see WP_Widget::form()
46
+ *
47
+ * @param array $instance Previously saved values from database.
48
+ */
49
+ public function form( $instance ) {
50
+ $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
51
+ $limit = isset( $instance['limit'] ) ? esc_attr( $instance['limit'] ) : '';
52
+ $offset = isset( $instance['offset'] ) ? esc_attr( $instance['offset'] ) : '';
53
+ $disp_list_count = isset( $instance['disp_list_count'] ) ? esc_attr( $instance['disp_list_count'] ) : '';
54
+ $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
55
+ $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
56
+ $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
57
+ $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : 'text_only';
58
+ $thumb_height = isset( $instance['thumb_height'] ) ? esc_attr( $instance['thumb_height'] ) : '';
59
+ $thumb_width = isset( $instance['thumb_width'] ) ? esc_attr( $instance['thumb_width'] ) : '';
60
+ $daily = isset( $instance['daily'] ) ? esc_attr( $instance['daily'] ) : 'overall';
61
+ $daily_range = isset( $instance['daily_range'] ) ? esc_attr( $instance['daily_range'] ) : '';
62
+ $hour_range = isset( $instance['hour_range'] ) ? esc_attr( $instance['hour_range'] ) : '';
63
+
64
+ // Parse the Post types.
65
+ $post_types = array();
66
+ if ( isset( $instance['post_types'] ) ) {
67
+ $post_types = $instance['post_types'];
68
+ parse_str( $post_types, $post_types ); // Save post types in $post_types variable.
69
+ }
70
+ $wp_post_types = get_post_types(
71
+ array(
72
+ 'public' => true,
73
+ )
74
+ );
75
+ $posts_types_inc = array_intersect( $wp_post_types, $post_types );
76
+
77
+ ?>
78
+ <p>
79
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
80
+ <?php esc_html_e( 'Title', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
81
+ </label>
82
+ </p>
83
+ <p>
84
+ <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>">
85
+ <?php esc_html_e( 'No. of posts', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" />
86
+ </label>
87
+ </p>
88
+ <p>
89
+ <label for="<?php echo esc_attr( $this->get_field_id( 'offset' ) ); ?>">
90
+ <?php esc_html_e( 'Offset', 'top-10' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'offset' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'offset' ) ); ?>" type="text" value="<?php echo esc_attr( $offset ); ?>" />
91
+ </label>
92
+ </p>
93
+ <p>
94
+ <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'daily' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'daily' ) ); ?>">
95
+ <option value="overall" <?php selected( 'overall', $daily, true ); ?>><?php esc_html_e( 'Overall', 'top-10' ); ?></option>
96
+ <option value="daily" <?php selected( 'daily', $daily, true ); ?>><?php esc_html_e( 'Custom time period (Enter below)', 'top-10' ); ?></option>
97
+ </select>
98
+ </p>
99
+ <p>
100
+ <?php esc_html_e( 'In days and hours (applies only to custom option above)', 'top-10' ); ?>:
101
+ <label for="<?php echo esc_attr( $this->get_field_id( 'daily_range' ) ); ?>">
102
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'daily_range' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'daily_range' ) ); ?>" type="text" value="<?php echo esc_attr( $daily_range ); ?>" /> <?php esc_html_e( 'days', 'top-10' ); ?>
103
+ </label>
104
+ <label for="<?php echo esc_attr( $this->get_field_id( 'hour_range' ) ); ?>">
105
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'hour_range' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hour_range' ) ); ?>" type="text" value="<?php echo esc_attr( $hour_range ); ?>" /> <?php esc_html_e( 'hours', 'top-10' ); ?>
106
+ </label>
107
+ </p>
108
+ <p>
109
+ <label for="<?php echo esc_attr( $this->get_field_id( 'disp_list_count' ) ); ?>">
110
+ <input id="<?php echo esc_attr( $this->get_field_id( 'disp_list_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'disp_list_count' ) ); ?>" type="checkbox" <?php checked( true, $disp_list_count, true ); ?> /> <?php esc_html_e( 'Show count?', 'top-10' ); ?>
111
+ </label>
112
+ </p>
113
+ <p>
114
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>">
115
+ <input id="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpt' ) ); ?>" type="checkbox" <?php checked( true, $show_excerpt, true ); ?> /> <?php esc_html_e( 'Show excerpt?', 'top-10' ); ?>
116
+ </label>
117
+ </p>
118
+ <p>
119
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_author' ) ); ?>">
120
+ <input id="<?php echo esc_attr( $this->get_field_id( 'show_author' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_author' ) ); ?>" type="checkbox" <?php checked( true, $show_author, true ); ?> /> <?php esc_html_e( 'Show author?', 'top-10' ); ?>
121
+ </label>
122
+ </p>
123
+ <p>
124
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>">
125
+ <input id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" type="checkbox" <?php checked( true, $show_date, true ); ?> /> <?php esc_html_e( 'Show date?', 'top-10' ); ?>
126
+ </label>
127
+ </p>
128
+ <p>
129
+ <?php esc_html_e( 'Thumbnail options', 'top-10' ); ?>: <br />
130
+ <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'post_thumb_op' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'post_thumb_op' ) ); ?>">
131
+ <option value="inline" <?php selected( 'inline', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, before title', 'top-10' ); ?></option>
132
+ <option value="after" <?php selected( 'after', $post_thumb_op, true ); ?>><?php esc_html_e( 'Thumbnails inline, after title', 'top-10' ); ?></option>
133
+ <option value="thumbs_only" <?php selected( 'thumbs_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'Only thumbnails, no text', 'top-10' ); ?></option>
134
+ <option value="text_only" <?php selected( 'text_only', $post_thumb_op, true ); ?>><?php esc_html_e( 'No thumbnails, only text.', 'top-10' ); ?></option>
135
+ </select>
136
+ </p>
137
+ <p>
138
+ <label for="<?php echo esc_attr( $this->get_field_id( 'thumb_height' ) ); ?>">
139
+ <?php esc_html_e( 'Thumbnail height', 'top-10' ); ?>:
140
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'thumb_height' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_height' ) ); ?>" type="text" value="<?php echo esc_attr( $thumb_height ); ?>" />
141
+ </label>
142
+ </p>
143
+ <p>
144
+ <label for="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>">
145
+ <?php esc_html_e( 'Thumbnail width', 'top-10' ); ?>:
146
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_width' ) ); ?>" type="text" value="<?php echo esc_attr( $thumb_width ); ?>" />
147
+ </label>
148
+ </p>
149
+ <p><?php esc_html_e( 'Post types to include:', 'top-10' ); ?><br />
150
+
151
+ <?php foreach ( $wp_post_types as $wp_post_type ) { ?>
152
+
153
+ <label>
154
+ <input id="<?php echo esc_attr( $this->get_field_id( 'post_types' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'post_types' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $wp_post_type ); ?>" <?php checked( true, in_array( $wp_post_type, $posts_types_inc, true ), true ); ?> />
155
+ <?php echo esc_attr( $wp_post_type ); ?>
156
+ </label>
157
+ <br />
158
+
159
+ <?php } ?>
160
+ </p>
161
+
162
+ <?php
163
+ /**
164
+ * Fires after Top 10 widget options.
165
+ *
166
+ * @since 2.0.0
167
+ *
168
+ * @param array $instance Widget options array
169
+ */
170
+ do_action( 'tptn_widget_options_after', $instance );
171
+ ?>
172
+
173
+ <?php
174
+ } //ending form creation
175
+
176
+ /**
177
+ * Sanitize widget form values as they are saved.
178
+ *
179
+ * @see WP_Widget::update()
180
+ *
181
+ * @param array $new_instance Values just sent to be saved.
182
+ * @param array $old_instance Previously saved values from database.
183
+ *
184
+ * @return array Updated safe values to be saved.
185
+ */
186
+ public function update( $new_instance, $old_instance ) {
187
+ $instance = $old_instance;
188
+ $instance['title'] = strip_tags( $new_instance['title'] );
189
+ $instance['limit'] = $new_instance['limit'];
190
+ $instance['offset'] = $new_instance['offset'];
191
+ $instance['daily'] = $new_instance['daily'];
192
+ $instance['daily_range'] = strip_tags( $new_instance['daily_range'] );
193
+ $instance['hour_range'] = strip_tags( $new_instance['hour_range'] );
194
+ $instance['disp_list_count'] = isset( $new_instance['disp_list_count'] ) ? true : false;
195
+ $instance['show_excerpt'] = isset( $new_instance['show_excerpt'] ) ? true : false;
196
+ $instance['show_author'] = isset( $new_instance['show_author'] ) ? true : false;
197
+ $instance['show_date'] = isset( $new_instance['show_date'] ) ? true : false;
198
+ $instance['post_thumb_op'] = $new_instance['post_thumb_op'];
199
+ $instance['thumb_height'] = $new_instance['thumb_height'];
200
+ $instance['thumb_width'] = $new_instance['thumb_width'];
201
+
202
+ // Process post types to be selected.
203
+ $wp_post_types = get_post_types(
204
+ array(
205
+ 'public' => true,
206
+ )
207
+ );
208
+ $post_types = ( isset( $new_instance['post_types'] ) ) ? $new_instance['post_types'] : array();
209
+ $post_types = array_intersect( $wp_post_types, $post_types );
210
+ $instance['post_types'] = http_build_query( $post_types, '', '&' );
211
+
212
+ /**
213
+ * Filters Update widget options array.
214
+ *
215
+ * @since 2.0.0
216
+ *
217
+ * @param array $instance Widget options array
218
+ */
219
+ return apply_filters( 'tptn_widget_options_update', $instance );
220
+ } //ending update
221
+
222
+ /**
223
+ * Front-end display of widget.
224
+ *
225
+ * @see WP_Widget::widget()
226
+ *
227
+ * @param array $args Widget arguments.
228
+ * @param array $instance Saved values from database.
229
+ */
230
+ public function widget( $args, $instance ) {
231
+ global $post;
232
+
233
+ // Get the post meta.
234
+ if ( isset( $post ) ) {
235
+ $tptn_post_meta = get_post_meta( $post->ID, 'tptn_post_meta', true );
236
+
237
+ if ( isset( $tptn_post_meta['disable_here'] ) && ( $tptn_post_meta['disable_here'] ) ) {
238
+ return;
239
+ }
240
+ }
241
+
242
+ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? strip_tags( tptn_get_option( 'title' ) ) : $instance['title'] );
243
+
244
+ $limit = isset( $instance['limit'] ) ? $instance['limit'] : tptn_get_option( 'limit' );
245
+ if ( empty( $limit ) ) {
246
+ $limit = tptn_get_option( 'limit' );
247
+ }
248
+
249
+ $offset = isset( $instance['offset'] ) ? $instance['offset'] : 0;
250
+ $daily_range = ( empty( $instance['daily_range'] ) ) ? tptn_get_option( 'daily_range' ) : $instance['daily_range'];
251
+ $hour_range = ( empty( $instance['hour_range'] ) ) ? tptn_get_option( 'hour_range' ) : $instance['hour_range'];
252
+
253
+ $daily = ( isset( $instance['daily'] ) && ( 'daily' === $instance['daily'] ) ) ? true : false;
254
+
255
+ $output = $args['before_widget'];
256
+ $output .= $args['before_title'] . $title . $args['after_title'];
257
+
258
+ $post_thumb_op = isset( $instance['post_thumb_op'] ) ? esc_attr( $instance['post_thumb_op'] ) : 'text_only';
259
+
260
+ $thumb_height = ( isset( $instance['thumb_height'] ) && '' !== $instance['thumb_height'] ) ? absint( $instance['thumb_height'] ) : tptn_get_option( 'thumb_height' );
261
+ $thumb_width = ( isset( $instance['thumb_width'] ) && '' !== $instance['thumb_width'] ) ? absint( $instance['thumb_width'] ) : tptn_get_option( 'thumb_width' );
262
+
263
+ $disp_list_count = isset( $instance['disp_list_count'] ) ? esc_attr( $instance['disp_list_count'] ) : '';
264
+ $show_excerpt = isset( $instance['show_excerpt'] ) ? esc_attr( $instance['show_excerpt'] ) : '';
265
+ $show_author = isset( $instance['show_author'] ) ? esc_attr( $instance['show_author'] ) : '';
266
+ $show_date = isset( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
267
+ $post_types = isset( $instance['post_types'] ) ? $instance['post_types'] : tptn_get_option( 'post_types' );
268
+
269
+ $arguments = array(
270
+ 'is_widget' => 1,
271
+ 'instance_id' => $this->number,
272
+ 'heading' => 0,
273
+ 'limit' => $limit,
274
+ 'offset' => $offset,
275
+ 'daily' => $daily,
276
+ 'daily_range' => $daily_range,
277
+ 'hour_range' => $hour_range,
278
+ 'show_excerpt' => $show_excerpt,
279
+ 'show_author' => $show_author,
280
+ 'show_date' => $show_date,
281
+ 'post_thumb_op' => $post_thumb_op,
282
+ 'thumb_height' => $thumb_height,
283
+ 'thumb_width' => $thumb_width,
284
+ 'disp_list_count' => $disp_list_count,
285
+ 'post_types' => $post_types,
286
+ );
287
+
288
+ /**
289
+ * Filters arguments passed to tptn_pop_posts for the widget.
290
+ *
291
+ * @since 2.0.0
292
+ *
293
+ * @param array $arguments Widget options array
294
+ */
295
+ $arguments = apply_filters( 'tptn_widget_options', $arguments );
296
+
297
+ $output .= tptn_pop_posts( $arguments );
298
+
299
+ $output .= $args['after_widget'];
300
+
301
+ echo $output; // WPCS: XSS OK.
302
+
303
+ } //ending function widget
304
+
305
+
306
+ /**
307
+ * Add styles to the front end if the widget is active.
308
+ *
309
+ * @since 2.3.0
310
+ */
311
+ public function front_end_styles() {
312
+
313
+ if ( ! 'left_thumbs' === tptn_get_option( 'tptn_styles' ) ) {
314
+ return;
315
+ }
316
+
317
+ // We need to process all instances because this function gets to run only once.
318
+ $widget_settings = get_option( $this->option_name );
319
+
320
+ foreach ( (array) $widget_settings as $instance => $options ) {
321
+
322
+ // Identify instance.
323
+ $widget_id = "{$this->id_base}-{$instance}";
324
+
325
+ // Check if it's our instance.
326
+ if ( ! is_active_widget( false, $widget_id, $this->id_base, true ) ) {
327
+ continue; // Not active.
328
+ }
329
+
330
+ $thumb_height = ( isset( $options['thumb_height'] ) && '' !== $options['thumb_height'] ) ? absint( $options['thumb_height'] ) : tptn_get_option( 'thumb_height' );
331
+ $thumb_width = ( isset( $options['thumb_width'] ) && '' !== $options['thumb_width'] ) ? absint( $options['thumb_width'] ) : tptn_get_option( 'thumb_width' );
332
+
333
+ // Enqueue the custom css for the thumb width and height for this specific widget.
334
+ $custom_css = "
335
+ .tptn_posts_widget{$instance} img.tptn_thumb {
336
+ width: {$thumb_width}px !important;
337
+ height: {$thumb_height}px !important;
338
+ }
339
+ ";
340
+
341
+ wp_add_inline_style( 'tptn-style-left-thumbs', $custom_css );
342
+
343
+ }
344
+
345
+ }
346
+ }
347
+
348
+
349
+ /**
350
+ * Initialise the widget.
351
+ */
352
+ function tptn_register_widget() {
353
+ register_widget( 'Top_Ten_Widget' );
354
+ }
355
+ add_action( 'widgets_init', 'tptn_register_widget', 1 );
356
+
includes/modules/exclusions.php CHANGED
@@ -8,10 +8,10 @@
8
  /**
9
  * Function to filter exclude post IDs.
10
  *
11
- * @since 2.2.0
12
  *
13
- * @param array $exclude_post_ids Original excluded post IDs.
14
- * @return array Updated excluded post ID
15
  */
16
  function tptn_exclude_post_ids( $exclude_post_ids ) {
17
  global $wpdb;
@@ -21,9 +21,9 @@ function tptn_exclude_post_ids( $exclude_post_ids ) {
21
  $tptn_post_metas = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE `meta_key` = 'tptn_post_meta'", ARRAY_A );
22
 
23
  foreach ( $tptn_post_metas as $tptn_post_meta ) {
24
- $meta_value = unserialize( $tptn_post_meta['meta_value'] );
25
 
26
- if ( 1 == $meta_value['exclude_this_post'] ) {
27
  $exclude_post_ids[] = $tptn_post_meta['post_id'];
28
  }
29
  }
8
  /**
9
  * Function to filter exclude post IDs.
10
  *
11
+ * @since 2.2.0
12
  *
13
+ * @param array $exclude_post_ids Original excluded post IDs.
14
+ * @return array Updated excluded post ID
15
  */
16
  function tptn_exclude_post_ids( $exclude_post_ids ) {
17
  global $wpdb;
21
  $tptn_post_metas = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE `meta_key` = 'tptn_post_meta'", ARRAY_A );
22
 
23
  foreach ( $tptn_post_metas as $tptn_post_meta ) {
24
+ $meta_value = maybe_unserialize( $tptn_post_meta['meta_value'] );
25
 
26
+ if ( $meta_value['exclude_this_post'] ) {
27
  $exclude_post_ids[] = $tptn_post_meta['post_id'];
28
  }
29
  }
includes/modules/shortcode.php CHANGED
@@ -8,23 +8,25 @@
8
  /**
9
  * Creates a shortcode [tptn_list limit="5" heading="1" daily="0"].
10
  *
11
- * @since 1.9.9
12
- * @param array $atts Shortcode attributes.
13
- * @param string $content Content.
14
- * @return string Formatted list of posts generated by tptn_pop_posts
15
  */
16
  function tptn_shortcode( $atts, $content = null ) {
17
  global $tptn_settings;
18
 
19
- $atts = shortcode_atts( array_merge(
20
- $tptn_settings,
21
- array(
22
- 'heading' => 1,
23
- 'daily' => 0,
24
- 'is_shortcode' => 1,
25
- 'offset' => 0,
26
- )
27
- ), $atts, 'top-10' );
 
 
28
 
29
  return tptn_pop_posts( $atts );
30
  }
@@ -34,15 +36,17 @@ add_shortcode( 'tptn_list', 'tptn_shortcode' );
34
  /**
35
  * Creates a shortcode [tptn_views daily="0"].
36
  *
37
- * @since 1.9.9
38
- * @param array $atts Shortcode attributes.
39
- * @param string $content Content.
40
- * @return string Views of the post
41
  */
42
  function tptn_shortcode_views( $atts, $content = null ) {
43
- $a = shortcode_atts( array(
44
- 'daily' => '0',
45
- ), $atts );
 
 
46
 
47
  return get_tptn_post_count_only( get_the_ID(), ( $a['daily'] ? 'daily' : 'total' ) );
48
  }
8
  /**
9
  * Creates a shortcode [tptn_list limit="5" heading="1" daily="0"].
10
  *
11
+ * @since 1.9.9
12
+ * @param array $atts Shortcode attributes.
13
+ * @param string $content Content.
14
+ * @return string Formatted list of posts generated by tptn_pop_posts
15
  */
16
  function tptn_shortcode( $atts, $content = null ) {
17
  global $tptn_settings;
18
 
19
+ $atts = shortcode_atts(
20
+ array_merge(
21
+ $tptn_settings,
22
+ array(
23
+ 'heading' => 1,
24
+ 'daily' => 0,
25
+ 'is_shortcode' => 1,
26
+ 'offset' => 0,
27
+ )
28
+ ), $atts, 'top-10'
29
+ );
30
 
31
  return tptn_pop_posts( $atts );
32
  }
36
  /**
37
  * Creates a shortcode [tptn_views daily="0"].
38
  *
39
+ * @since 1.9.9
40
+ * @param array $atts Shortcode attributes.
41
+ * @param string $content Content.
42
+ * @return string Views of the post
43
  */
44
  function tptn_shortcode_views( $atts, $content = null ) {
45
+ $a = shortcode_atts(
46
+ array(
47
+ 'daily' => '0',
48
+ ), $atts
49
+ );
50
 
51
  return get_tptn_post_count_only( get_the_ID(), ( $a['daily'] ? 'daily' : 'total' ) );
52
  }
includes/modules/taxonomies.php CHANGED
@@ -15,15 +15,15 @@ if ( ! defined( 'WPINC' ) ) {
15
  *
16
  * @since 2.2.0
17
  *
18
- * @param mixed $join Join clause.
19
- * @return string Filtered JOIN clause
20
  */
21
  function tptn_exclude_categories_join( $join ) {
22
  global $wpdb, $tptn_settings;
23
 
24
- if ( '' !== $tptn_settings['exclude_categories'] ) {
25
 
26
- $sql = $join;
27
  $sql .= " LEFT JOIN $wpdb->term_relationships AS excat_tr ON ($wpdb->posts.ID = excat_tr.object_id) ";
28
  $sql .= " LEFT JOIN $wpdb->term_taxonomy AS excat_tt ON (excat_tr.term_taxonomy_id = excat_tt.term_taxonomy_id) ";
29
 
@@ -40,17 +40,17 @@ add_filter( 'tptn_posts_join', 'tptn_exclude_categories_join' );
40
  *
41
  * @since 2.2.0
42
  *
43
- * @param mixed $where WHERE clause.
44
- * @return string Filtered WHERE clause
45
  */
46
  function tptn_exclude_categories_where( $where ) {
47
  global $wpdb, $tptn_settings;
48
 
49
- if ( '' === $tptn_settings['exclude_categories'] ) {
50
  return $where;
51
  } else {
52
 
53
- $terms = $tptn_settings['exclude_categories'];
54
 
55
  $sql = $where;
56
 
@@ -72,15 +72,15 @@ add_filter( 'tptn_posts_where', 'tptn_exclude_categories_where' );
72
  *
73
  * @since 2.3.0
74
  *
75
- * @param mixed $groupby GROUP BY clause.
76
- * @return string Filtered GROUP BY clause
77
  */
78
  function tptn_exclude_categories_groupby( $groupby ) {
79
  global $tptn_settings;
80
 
81
- if ( '' !== $tptn_settings['exclude_categories'] && '' !== $groupby ) {
82
 
83
- $sql = $groupby;
84
  $sql .= ', excat_tt.term_taxonomy_id ';
85
 
86
  return $sql;
15
  *
16
  * @since 2.2.0
17
  *
18
+ * @param mixed $join Join clause.
19
+ * @return string Filtered JOIN clause
20
  */
21
  function tptn_exclude_categories_join( $join ) {
22
  global $wpdb, $tptn_settings;
23
 
24
+ if ( '' !== tptn_get_option( 'exclude_categories' ) ) {
25
 
26
+ $sql = $join;
27
  $sql .= " LEFT JOIN $wpdb->term_relationships AS excat_tr ON ($wpdb->posts.ID = excat_tr.object_id) ";
28
  $sql .= " LEFT JOIN $wpdb->term_taxonomy AS excat_tt ON (excat_tr.term_taxonomy_id = excat_tt.term_taxonomy_id) ";
29
 
40
  *
41
  * @since 2.2.0
42
  *
43
+ * @param mixed $where WHERE clause.
44
+ * @return string Filtered WHERE clause
45
  */
46
  function tptn_exclude_categories_where( $where ) {
47
  global $wpdb, $tptn_settings;
48
 
49
+ if ( '' === tptn_get_option( 'exclude_categories' ) ) {
50
  return $where;
51
  } else {
52
 
53
+ $terms = tptn_get_option( 'exclude_categories' );
54
 
55
  $sql = $where;
56
 
72
  *
73
  * @since 2.3.0
74
  *
75
+ * @param mixed $groupby GROUP BY clause.
76
+ * @return string Filtered GROUP BY clause
77
  */
78
  function tptn_exclude_categories_groupby( $groupby ) {
79
  global $tptn_settings;
80
 
81
+ if ( '' !== tptn_get_option( 'exclude_categories' ) && '' !== $groupby ) {
82
 
83
+ $sql = $groupby;
84
  $sql .= ', excat_tt.term_taxonomy_id ';
85
 
86
  return $sql;
includes/public/display-posts.php CHANGED
@@ -13,37 +13,37 @@ if ( ! defined( 'WPINC' ) ) {
13
  /**
14
  * Function to return formatted list of popular posts.
15
  *
16
- * @since 1.5
17
  *
18
- * @param mixed $args Arguments array
19
- * @return array|string Array of posts if posts_only = 0 or a formatted string if posts_only = 1
20
  */
21
  function tptn_pop_posts( $args ) {
22
  global $tptn_settings;
23
 
24
- // if set, save $exclude_categories
25
  if ( isset( $args['exclude_categories'] ) && '' != $args['exclude_categories'] ) {
26
- $exclude_categories = explode( ',', $args['exclude_categories'] );
27
  $args['strict_limit'] = false;
28
  }
29
 
30
  $defaults = array(
31
- 'daily' => false,
32
- 'is_widget' => false,
33
- 'instance_id' => 1,
34
  'is_shortcode' => false,
35
- 'is_manual' => false,
36
- 'echo' => false,
37
  'strict_limit' => false,
38
- 'posts_only' => false,
39
- 'heading' => 1,
40
- 'offset' => 0,
41
  );
42
 
43
- // Merge the $defaults array with the $tptn_settings array
44
- $defaults = array_merge( $defaults, $tptn_settings );
45
 
46
- // Parse incomming $args into an array and merge it with $defaults
47
  $args = wp_parse_args( $args, $defaults );
48
 
49
  $output = '';
@@ -51,16 +51,16 @@ function tptn_pop_posts( $args ) {
51
  /**
52
  * Fires before the output processing begins.
53
  *
54
- * @since 2.2.0
55
  *
56
- * @param string $output Formatted list of top posts
57
- * @param array $args Array of arguments
58
  */
59
  do_action( 'pre_tptn_pop_posts', $output, $args );
60
 
61
- // Check if the cache is enabled and if the output exists. If so, return the output
62
  if ( $args['cache'] && ! $args['posts_only'] ) {
63
- $cache_name = 'tptn';
64
  $cache_name .= $args['daily'] ? '_daily' : '_total';
65
  $cache_name .= $args['is_widget'] ? '_widget' . $args['instance_id'] : '';
66
  $cache_name .= $args['is_shortcode'] ? '_shortcode' : '';
@@ -73,30 +73,30 @@ function tptn_pop_posts( $args ) {
73
  /**
74
  * Filter the output
75
  *
76
- * @since 1.9.8.5
77
  *
78
- * @param string $output Formatted list of top posts
79
- * @param array $args Array of arguments
80
  */
81
  return apply_filters( 'tptn_pop_posts', $output, $args );
82
  }
83
  }
84
 
85
- // Get thumbnail size
86
  list( $args['thumb_width'], $args['thumb_height'] ) = tptn_get_thumb_size( $args );
87
 
88
- // Retrieve the popular posts
89
  $results = get_tptn_pop_posts( $args );
90
 
91
- if ( $args['posts_only'] ) { // Return the array of posts only if the variable is set
92
- _deprecated_argument( __FUNCTION__, '2.2.0', __( 'posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the posts only.', 'top-10' ) );
93
  return $results;
94
  }
95
 
96
  $counter = 0;
97
 
98
- $daily_class = $args['daily'] ? 'tptn_posts_daily ' : 'tptn_posts ';
99
- $widget_class = $args['is_widget'] ? ' tptn_posts_widget tptn_posts_widget' . $args['instance_id'] : '';
100
  $shortcode_class = $args['is_shortcode'] ? ' tptn_posts_shortcode' : '';
101
 
102
  $post_classes = $daily_class . $widget_class . $shortcode_class;
@@ -104,9 +104,9 @@ function tptn_pop_posts( $args ) {
104
  /**
105
  * Filter the classes added to the div wrapper of the Top 10.
106
  *
107
- * @since 2.1.0
108
  *
109
- * @param string $post_classes Post classes string.
110
  */
111
  $post_classes = apply_filters( 'tptn_post_class', $post_classes );
112
 
@@ -118,47 +118,49 @@ function tptn_pop_posts( $args ) {
118
 
119
  $output .= tptn_before_list( $args );
120
 
121
- // We need this for WPML support
122
  $processed_results = array();
123
 
124
  foreach ( $results as $result ) {
125
 
126
  /* Support WPML */
127
- $resultid = tptn_object_id_cur_lang( $result->ID );
128
 
129
  // If this is NULL or already processed ID or matches current post then skip processing this loop.
130
  if ( ! $resultid || in_array( $resultid, $processed_results ) ) {
131
- continue;
132
  }
133
 
134
- // Push the current ID into the array to ensure we're not repeating it
135
  array_push( $processed_results, $resultid );
136
 
137
- $sum_count = $result->sum_count; // Store the count. We'll need this later
138
 
139
  /**
140
  * Filter the post ID for each result. Allows a custom function to hook in and change the ID if needed.
141
  *
142
- * @since 1.9.8.5
143
  *
144
- * @param int $resultid ID of the post
145
  */
146
  $resultid = apply_filters( 'tptn_post_id', $resultid );
147
 
148
- $result = get_post( $resultid ); // Let's get the Post using the ID
149
 
150
- // Process the category exclusion if passed in the shortcode
151
  if ( isset( $exclude_categories ) ) {
152
 
153
- $categorys = get_the_category( $result->ID ); // Fetch categories of the plugin
154
 
155
- $p_in_c = false; // Variable to check if post exists in a particular category
156
- foreach ( $categorys as $cat ) { // Loop to check if post exists in excluded category
157
  $p_in_c = ( in_array( $cat->cat_ID, $exclude_categories ) ) ? true : false;
158
- if ( $p_in_c ) { break; // Skip loop execution and go to the next step
 
159
  }
160
  }
161
- if ( $p_in_c ) { continue; // Skip loop execution and go to the next step
 
162
  }
163
  }
164
 
@@ -185,11 +187,11 @@ function tptn_pop_posts( $args ) {
185
  /**
186
  * Filter the formatted list count text.
187
  *
188
- * @since 2.1.0
189
  *
190
- * @param string $tptn_list_count Formatted list count
191
- * @param int $sum_count Post count
192
- * @param object $result Post object
193
  */
194
  $tptn_list_count = apply_filters( 'tptn_list_count', $tptn_list_count, $sum_count, $result );
195
 
@@ -200,16 +202,16 @@ function tptn_pop_posts( $args ) {
200
  /**
201
  * Filter Formatted list item with link and and thumbnail.
202
  *
203
- * @since 2.2.0
204
  *
205
- * @param string $tptn_list
206
- * @param object $result Object of the current post result
207
- * @param array $args Array of arguments
208
  */
209
  $output .= apply_filters( 'tptn_list', $tptn_list, $result, $args );
210
 
211
- // Opening span created in tptn_list_link()
212
- if ( 'inline' == $args['post_thumb_op'] || 'text_only' == $args['post_thumb_op'] ) {
213
  $output .= '</span>';
214
  }
215
 
@@ -217,8 +219,8 @@ function tptn_pop_posts( $args ) {
217
 
218
  $counter++;
219
 
220
- if ( $counter == $args['limit'] ) {
221
- break; // End loop when related posts limit is reached
222
  }
223
  }
224
  if ( $args['show_credit'] ) {
@@ -226,6 +228,7 @@ function tptn_pop_posts( $args ) {
226
  $output .= tptn_before_list_item( $args, $result );
227
 
228
  $output .= sprintf(
 
229
  __( 'Popular posts by <a href="%1$s" rel="nofollow" %2$s>Top 10 plugin</a>', 'top-10' ),
230
  esc_url( 'https://webberzone.com/plugins/top-10/' ),
231
  tptn_link_attributes( $args, $result )
@@ -241,9 +244,9 @@ function tptn_pop_posts( $args ) {
241
  /**
242
  * Filter the clearfix div tag. This is included after the closing tag to clear any miscellaneous floating elements;
243
  *
244
- * @since 2.2.0
245
  *
246
- * @param string $clearfix Contains: <div style="clear:both"></div>
247
  */
248
  $output .= apply_filters( 'tptn_clearfix', $clearfix );
249
 
@@ -252,15 +255,15 @@ function tptn_pop_posts( $args ) {
252
  }
253
  $output .= '</div>';
254
 
255
- // Check if the cache is enabled and if the output exists. If so, return the output
256
  if ( $args['cache'] ) {
257
  /**
258
  * Filter the cache time which allows a function to override this
259
  *
260
- * @since 2.2.0
261
  *
262
- * @param int $args['cache_time'] Cache time in seconds
263
- * @param array $args Array of all the arguments
264
  */
265
  $cache_time = apply_filters( 'tptn_cache_time', $args['cache_time'], $args );
266
 
@@ -280,32 +283,32 @@ function tptn_pop_posts( $args ) {
280
  /**
281
  * Function to retrieve the popular posts.
282
  *
283
- * @since 2.1.0
284
  *
285
- * @param mixed $args Arguments list
286
  */
287
  function get_tptn_pop_posts( $args = array() ) {
288
  global $wpdb, $tptn_settings;
289
 
290
- // Initialise some variables
291
- $fields = array();
292
- $where = '';
293
- $join = '';
294
  $groupby = '';
295
  $orderby = '';
296
- $limits = '';
297
 
298
  $defaults = array(
299
- 'daily' => false,
300
  'strict_limit' => true,
301
- 'posts_only' => false,
302
- 'offset' => 0,
303
  );
304
 
305
- // Merge the $defaults array with the $tptn_settings array
306
- $defaults = array_merge( $defaults, $tptn_settings );
307
 
308
- // Parse incomming $args into an array and merge it with $defaults
309
  $args = wp_parse_args( $args, $defaults );
310
 
311
  if ( $args['daily'] ) {
@@ -314,33 +317,37 @@ function get_tptn_pop_posts( $args = array() ) {
314
  $table_name = $wpdb->base_prefix . 'top_ten';
315
  }
316
 
317
- $limit = ( $args['strict_limit'] ) ? $args['limit'] : ( $args['limit'] * 5 );
318
  $offset = isset( $args['offset'] ) ? $args['offset'] : 0;
319
 
320
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
321
- if ( ! empty( $args['post_types'] ) && false === strpos( $args['post_types'], '=' ) ) {
 
 
322
  $post_types = explode( ',', $args['post_types'] );
323
  } else {
324
- parse_str( $args['post_types'], $post_types ); // Save post types in $post_types variable
325
  }
326
 
327
- // If post_types is empty or if we want all the post types
328
  if ( empty( $post_types ) || 'all' === $args['post_types'] ) {
329
- $post_types = get_post_types( array(
330
- 'public' => true,
331
- ) );
 
 
332
  }
333
 
334
  $blog_id = get_current_blog_id();
335
 
336
  if ( $args['daily_midnight'] ) {
337
  $current_time = current_time( 'timestamp', 0 );
338
- $from_date = $current_time - ( max( 0, ( $args['daily_range'] - 1 ) ) * DAY_IN_SECONDS );
339
- $from_date = gmdate( 'Y-m-d 0' , $from_date );
340
  } else {
341
  $current_time = current_time( 'timestamp', 0 );
342
- $from_date = $current_time - ( $args['daily_range'] * DAY_IN_SECONDS + $args['hour_range'] * HOUR_IN_SECONDS );
343
- $from_date = gmdate( 'Y-m-d H' , $from_date );
344
  }
345
 
346
  /**
@@ -349,25 +356,25 @@ function get_tptn_pop_posts( $args = array() ) {
349
  * "SELECT $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"
350
  */
351
 
352
- // Fields to return
353
  $fields[] = 'ID';
354
  $fields[] = 'postnumber';
355
  $fields[] = ( $args['daily'] ) ? 'SUM(cntaccess) as sum_count' : 'cntaccess as sum_count';
356
 
357
  $fields = implode( ', ', $fields );
358
 
359
- // Create the JOIN clause
360
  $join = " INNER JOIN {$wpdb->posts} ON postnumber=ID ";
361
 
362
- // Create the base WHERE clause
363
- $where .= $wpdb->prepare( ' AND blog_id = %d ', $blog_id ); // Posts need to be from the current blog only
364
- $where .= " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit') "; // Show published posts and attachments
365
 
366
  if ( $args['daily'] ) {
367
- $where .= $wpdb->prepare( " AND dp_date >= '%s' ", $from_date ); // Only fetch posts that are tracked after this date
368
  }
369
 
370
- // Convert exclude post IDs string to array so it can be filtered
371
  $exclude_post_ids = explode( ',', $args['exclude_post_ids'] );
372
 
373
  /**
@@ -377,28 +384,28 @@ function get_tptn_pop_posts( $args = array() ) {
377
  */
378
  $exclude_post_ids = apply_filters( 'tptn_exclude_post_ids', $exclude_post_ids );
379
 
380
- // Convert it back to string
381
  $exclude_post_ids = implode( ',', array_filter( $exclude_post_ids ) );
382
 
383
  if ( '' != $exclude_post_ids ) {
384
  $where .= " AND $wpdb->posts.ID NOT IN ({$exclude_post_ids}) ";
385
  }
386
- $where .= " AND $wpdb->posts.post_type IN ('" . join( "', '", $post_types ) . "') "; // Array of post types
387
 
388
  // How old should the posts be?
389
  if ( $args['how_old'] ) {
390
- $where .= $wpdb->prepare( " AND $wpdb->posts.post_date > '%s' ", gmdate( 'Y-m-d H:m:s', $current_time - ( $args['how_old'] * DAY_IN_SECONDS ) ) );
391
  }
392
 
393
- // Create the base GROUP BY clause
394
  if ( $args['daily'] ) {
395
  $groupby = ' postnumber ';
396
  }
397
 
398
- // Create the base ORDER BY clause
399
  $orderby = ' sum_count DESC ';
400
 
401
- // Create the base LIMITS clause
402
  $limits .= $wpdb->prepare( ' LIMIT %d, %d ', $offset, $limit );
403
 
404
  /**
@@ -452,29 +459,29 @@ function get_tptn_pop_posts( $args = array() ) {
452
 
453
  $sql = "SELECT DISTINCT $fields FROM {$table_name} $join WHERE 1=1 $where $groupby $orderby $limits";
454
 
455
- if ( $args['posts_only'] ) { // Return the array of posts only if the variable is set
456
- $results = $wpdb->get_results( $sql, ARRAY_A );
457
 
458
  /**
459
  * Filter the array of top post IDs.
460
  *
461
- * @since 1.9.8.5
462
  *
463
- * @param array $tptn_pop_posts_array Posts array.
464
- * @param mixed $args Arguments list
465
  */
466
  return apply_filters( 'tptn_pop_posts_array', $results, $args );
467
  }
468
 
469
- $results = $wpdb->get_results( $sql );
470
 
471
  /**
472
  * Filter object containing post IDs of popular posts
473
  *
474
- * @since 2.1.0
475
  *
476
- * @param object $results Top 10 popular posts object
477
- * @param mixed $args Arguments list
478
  */
479
  return apply_filters( 'get_tptn_pop_posts', $results, $args );
480
  }
@@ -483,9 +490,9 @@ function get_tptn_pop_posts( $args = array() ) {
483
  /**
484
  * Function to echo popular posts.
485
  *
486
- * @since 1.0
487
  *
488
- * @param mixed $args Arguments list
489
  */
490
  function tptn_show_pop_posts( $args = null ) {
491
  if ( is_array( $args ) ) {
@@ -494,20 +501,20 @@ function tptn_show_pop_posts( $args = null ) {
494
  $args .= '&is_manual=1';
495
  }
496
 
497
- echo tptn_pop_posts( $args );
498
  }
499
 
500
 
501
  /**
502
  * Function to show daily popular posts.
503
  *
504
- * @since 1.2
505
  *
506
- * @param mixed $args Arguments list
507
  */
508
  function tptn_show_daily_pop_posts( $args = null ) {
509
  if ( is_array( $args ) || ! isset( $args ) ) {
510
- $args['daily'] = 1;
511
  $args['manual'] = 1;
512
  } else {
513
  $args .= '&daily=1&is_manual=1';
13
  /**
14
  * Function to return formatted list of popular posts.
15
  *
16
+ * @since 1.5
17
  *
18
+ * @param mixed $args Arguments array.
19
+ * @return array|string Array of posts if posts_only = 0 or a formatted string if posts_only = 1
20
  */
21
  function tptn_pop_posts( $args ) {
22
  global $tptn_settings;
23
 
24
+ // if set, save $exclude_categories.
25
  if ( isset( $args['exclude_categories'] ) && '' != $args['exclude_categories'] ) {
26
+ $exclude_categories = explode( ',', $args['exclude_categories'] );
27
  $args['strict_limit'] = false;
28
  }
29
 
30
  $defaults = array(
31
+ 'daily' => false,
32
+ 'is_widget' => false,
33
+ 'instance_id' => 1,
34
  'is_shortcode' => false,
35
+ 'is_manual' => false,
36
+ 'echo' => false,
37
  'strict_limit' => false,
38
+ 'posts_only' => false,
39
+ 'heading' => 1,
40
+ 'offset' => 0,
41
  );
42
 
43
+ // Merge the $defaults array with the $tptn_settings array.
44
+ $defaults = array_merge( $defaults, tptn_settings_defaults(), $tptn_settings );
45
 
46
+ // Parse incomming $args into an array and merge it with $defaults.
47
  $args = wp_parse_args( $args, $defaults );
48
 
49
  $output = '';
51
  /**
52
  * Fires before the output processing begins.
53
  *
54
+ * @since 2.2.0
55
  *
56
+ * @param string $output Formatted list of top posts
57
+ * @param array $args Array of arguments
58
  */
59
  do_action( 'pre_tptn_pop_posts', $output, $args );
60
 
61
+ // Check if the cache is enabled and if the output exists. If so, return the output.
62
  if ( $args['cache'] && ! $args['posts_only'] ) {
63
+ $cache_name = 'tptn';
64
  $cache_name .= $args['daily'] ? '_daily' : '_total';
65
  $cache_name .= $args['is_widget'] ? '_widget' . $args['instance_id'] : '';
66
  $cache_name .= $args['is_shortcode'] ? '_shortcode' : '';
73
  /**
74
  * Filter the output
75
  *
76
+ * @since 1.9.8.5
77
  *
78
+ * @param string $output Formatted list of top posts
79
+ * @param array $args Array of arguments
80
  */
81
  return apply_filters( 'tptn_pop_posts', $output, $args );
82
  }
83
  }
84
 
85
+ // Get thumbnail size.
86
  list( $args['thumb_width'], $args['thumb_height'] ) = tptn_get_thumb_size( $args );
87
 
88
+ // Retrieve the popular posts.
89
  $results = get_tptn_pop_posts( $args );
90
 
91
+ if ( $args['posts_only'] ) { // Return the array of posts only if the variable is set.
92
+ _deprecated_argument( __FUNCTION__, '2.2.0', esc_html__( 'posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the posts only.', 'top-10' ) );
93
  return $results;
94
  }
95
 
96
  $counter = 0;
97
 
98
+ $daily_class = $args['daily'] ? 'tptn_posts_daily ' : 'tptn_posts ';
99
+ $widget_class = $args['is_widget'] ? ' tptn_posts_widget tptn_posts_widget' . $args['instance_id'] : '';
100
  $shortcode_class = $args['is_shortcode'] ? ' tptn_posts_shortcode' : '';
101
 
102
  $post_classes = $daily_class . $widget_class . $shortcode_class;
104
  /**
105
  * Filter the classes added to the div wrapper of the Top 10.
106
  *
107
+ * @since 2.1.0
108
  *
109
+ * @param string $post_classes Post classes string.
110
  */
111
  $post_classes = apply_filters( 'tptn_post_class', $post_classes );
112
 
118
 
119
  $output .= tptn_before_list( $args );
120
 
121
+ // We need this for WPML support.
122
  $processed_results = array();
123
 
124
  foreach ( $results as $result ) {
125
 
126
  /* Support WPML */
127
+ $resultid = tptn_object_id_cur_lang( $result->ID );
128
 
129
  // If this is NULL or already processed ID or matches current post then skip processing this loop.
130
  if ( ! $resultid || in_array( $resultid, $processed_results ) ) {
131
+ continue;
132
  }
133
 
134
+ // Push the current ID into the array to ensure we're not repeating it.
135
  array_push( $processed_results, $resultid );
136
 
137
+ $sum_count = $result->sum_count; // Store the count. We'll need this later.
138
 
139
  /**
140
  * Filter the post ID for each result. Allows a custom function to hook in and change the ID if needed.
141
  *
142
+ * @since 1.9.8.5
143
  *
144
+ * @param int $resultid ID of the post
145
  */
146
  $resultid = apply_filters( 'tptn_post_id', $resultid );
147
 
148
+ $result = get_post( $resultid ); // Let's get the Post using the ID.
149
 
150
+ // Process the category exclusion if passed in the shortcode.
151
  if ( isset( $exclude_categories ) ) {
152
 
153
+ $categorys = get_the_category( $result->ID ); // Fetch categories of the plugin.
154
 
155
+ $p_in_c = false; // Variable to check if post exists in a particular category.
156
+ foreach ( $categorys as $cat ) { // Loop to check if post exists in excluded category.
157
  $p_in_c = ( in_array( $cat->cat_ID, $exclude_categories ) ) ? true : false;
158
+ if ( $p_in_c ) {
159
+ break; // Skip loop execution and go to the next step.
160
  }
161
  }
162
+ if ( $p_in_c ) {
163
+ continue; // Skip loop execution and go to the next step.
164
  }
165
  }
166
 
187
  /**
188
  * Filter the formatted list count text.
189
  *
190
+ * @since 2.1.0
191
  *
192
+ * @param string $tptn_list_count Formatted list count
193
+ * @param int $sum_count Post count
194
+ * @param object $result Post object
195
  */
196
  $tptn_list_count = apply_filters( 'tptn_list_count', $tptn_list_count, $sum_count, $result );
197
 
202
  /**
203
  * Filter Formatted list item with link and and thumbnail.
204
  *
205
+ * @since 2.2.0
206
  *
207
+ * @param string $tptn_list
208
+ * @param object $result Object of the current post result
209
+ * @param array $args Array of arguments
210
  */
211
  $output .= apply_filters( 'tptn_list', $tptn_list, $result, $args );
212
 
213
+ // Opening span created in tptn_list_link().
214
+ if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
215
  $output .= '</span>';
216
  }
217
 
219
 
220
  $counter++;
221
 
222
+ if ( $counter === $args['limit'] ) {
223
+ break; // End loop when related posts limit is reached.
224
  }
225
  }
226
  if ( $args['show_credit'] ) {
228
  $output .= tptn_before_list_item( $args, $result );
229
 
230
  $output .= sprintf(
231
+ /* translators: 1. Top 10 plugin page link, 2. Link attributes. */
232
  __( 'Popular posts by <a href="%1$s" rel="nofollow" %2$s>Top 10 plugin</a>', 'top-10' ),
233
  esc_url( 'https://webberzone.com/plugins/top-10/' ),
234
  tptn_link_attributes( $args, $result )
244
  /**
245
  * Filter the clearfix div tag. This is included after the closing tag to clear any miscellaneous floating elements;
246
  *
247
+ * @since 2.2.0
248
  *
249
+ * @param string $clearfix Contains: <div style="clear:both"></div>
250
  */
251
  $output .= apply_filters( 'tptn_clearfix', $clearfix );
252
 
255
  }
256
  $output .= '</div>';
257
 
258
+ // Check if the cache is enabled and if the output exists. If so, return the output.
259
  if ( $args['cache'] ) {
260
  /**
261
  * Filter the cache time which allows a function to override this
262
  *
263
+ * @since 2.2.0
264
  *
265
+ * @param int $args['cache_time'] Cache time in seconds
266
+ * @param array $args Array of all the arguments
267
  */
268
  $cache_time = apply_filters( 'tptn_cache_time', $args['cache_time'], $args );
269
 
283
  /**
284
  * Function to retrieve the popular posts.
285
  *
286
+ * @since 2.1.0
287
  *
288
+ * @param mixed $args Arguments list.
289
  */
290
  function get_tptn_pop_posts( $args = array() ) {
291
  global $wpdb, $tptn_settings;
292
 
293
+ // Initialise some variables.
294
+ $fields = array();
295
+ $where = '';
296
+ $join = '';
297
  $groupby = '';
298
  $orderby = '';
299
+ $limits = '';
300
 
301
  $defaults = array(
302
+ 'daily' => false,
303
  'strict_limit' => true,
304
+ 'posts_only' => false,
305
+ 'offset' => 0,
306
  );
307
 
308
+ // Merge the $defaults array with the $tptn_settings array.
309
+ $defaults = array_merge( $defaults, tptn_settings_defaults(), $tptn_settings );
310
 
311
+ // Parse incomming $args into an array and merge it with $defaults.
312
  $args = wp_parse_args( $args, $defaults );
313
 
314
  if ( $args['daily'] ) {
317
  $table_name = $wpdb->base_prefix . 'top_ten';
318
  }
319
 
320
+ $limit = ( $args['strict_limit'] ) ? $args['limit'] : ( $args['limit'] * 5 );
321
  $offset = isset( $args['offset'] ) ? $args['offset'] : 0;
322
 
323
  // If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
324
+ if ( ! empty( $args['post_types'] ) && is_array( $args['post_types'] ) ) {
325
+ $post_types = $args['post_types'];
326
+ } elseif ( ! empty( $args['post_types'] ) && false === strpos( $args['post_types'], '=' ) ) {
327
  $post_types = explode( ',', $args['post_types'] );
328
  } else {
329
+ parse_str( $args['post_types'], $post_types ); // Save post types in $post_types variable.
330
  }
331
 
332
+ // If post_types is empty or if we want all the post types.
333
  if ( empty( $post_types ) || 'all' === $args['post_types'] ) {
334
+ $post_types = get_post_types(
335
+ array(
336
+ 'public' => true,
337
+ )
338
+ );
339
  }
340
 
341
  $blog_id = get_current_blog_id();
342
 
343
  if ( $args['daily_midnight'] ) {
344
  $current_time = current_time( 'timestamp', 0 );
345
+ $from_date = $current_time - ( max( 0, ( $args['daily_range'] - 1 ) ) * DAY_IN_SECONDS );
346
+ $from_date = gmdate( 'Y-m-d 0', $from_date );
347
  } else {
348
  $current_time = current_time( 'timestamp', 0 );
349
+ $from_date = $current_time - ( $args['daily_range'] * DAY_IN_SECONDS + $args['hour_range'] * HOUR_IN_SECONDS );
350
+ $from_date = gmdate( 'Y-m-d H', $from_date );
351
  }
352
 
353
  /**
356
  * "SELECT $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"
357
  */
358
 
359
+ // Fields to return.
360
  $fields[] = 'ID';
361
  $fields[] = 'postnumber';
362
  $fields[] = ( $args['daily'] ) ? 'SUM(cntaccess) as sum_count' : 'cntaccess as sum_count';
363
 
364
  $fields = implode( ', ', $fields );
365
 
366
+ // Create the JOIN clause.
367
  $join = " INNER JOIN {$wpdb->posts} ON postnumber=ID ";
368
 
369
+ // Create the base WHERE clause.
370
+ $where .= $wpdb->prepare( ' AND blog_id = %d ', $blog_id ); // Posts need to be from the current blog only.
371
+ $where .= " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit') "; // Show published posts and attachments.
372
 
373
  if ( $args['daily'] ) {
374
+ $where .= $wpdb->prepare( ' AND dp_date >= %s ', $from_date ); // Only fetch posts that are tracked after this date.
375
  }
376
 
377
+ // Convert exclude post IDs string to array so it can be filtered.
378
  $exclude_post_ids = explode( ',', $args['exclude_post_ids'] );
379
 
380
  /**
384
  */
385
  $exclude_post_ids = apply_filters( 'tptn_exclude_post_ids', $exclude_post_ids );
386
 
387
+ // Convert it back to string.
388
  $exclude_post_ids = implode( ',', array_filter( $exclude_post_ids ) );
389
 
390
  if ( '' != $exclude_post_ids ) {
391
  $where .= " AND $wpdb->posts.ID NOT IN ({$exclude_post_ids}) ";
392
  }
393
+ $where .= " AND $wpdb->posts.post_type IN ('" . join( "', '", $post_types ) . "') "; // Array of post types.
394
 
395
  // How old should the posts be?
396
  if ( $args['how_old'] ) {
397
+ $where .= $wpdb->prepare( " AND $wpdb->posts.post_date > %s ", gmdate( 'Y-m-d H:m:s', $current_time - ( $args['how_old'] * DAY_IN_SECONDS ) ) );
398
  }
399
 
400
+ // Create the base GROUP BY clause.
401
  if ( $args['daily'] ) {
402
  $groupby = ' postnumber ';
403
  }
404
 
405
+ // Create the base ORDER BY clause.
406
  $orderby = ' sum_count DESC ';
407
 
408
+ // Create the base LIMITS clause.
409
  $limits .= $wpdb->prepare( ' LIMIT %d, %d ', $offset, $limit );
410
 
411
  /**
459
 
460
  $sql = "SELECT DISTINCT $fields FROM {$table_name} $join WHERE 1=1 $where $groupby $orderby $limits";
461
 
462
+ if ( $args['posts_only'] ) { // Return the array of posts only if the variable is set.
463
+ $results = $wpdb->get_results( $sql, ARRAY_A ); // WPCS: unprepared SQL OK.
464
 
465
  /**
466
  * Filter the array of top post IDs.
467
  *
468
+ * @since 1.9.8.5
469
  *
470
+ * @param array $tptn_pop_posts_array Posts array.
471
+ * @param mixed $args Arguments list
472
  */
473
  return apply_filters( 'tptn_pop_posts_array', $results, $args );
474
  }
475
 
476
+ $results = $wpdb->get_results( $sql ); // WPCS: unprepared SQL OK.
477
 
478
  /**
479
  * Filter object containing post IDs of popular posts
480
  *
481
+ * @since 2.1.0
482
  *
483
+ * @param object $results Top 10 popular posts object
484
+ * @param mixed $args Arguments list
485
  */
486
  return apply_filters( 'get_tptn_pop_posts', $results, $args );
487
  }
490
  /**
491
  * Function to echo popular posts.
492
  *
493
+ * @since 1.0
494
  *
495
+ * @param mixed $args Arguments list.
496
  */
497
  function tptn_show_pop_posts( $args = null ) {
498
  if ( is_array( $args ) ) {
501
  $args .= '&is_manual=1';
502
  }
503
 
504
+ echo tptn_pop_posts( $args ); // WPCS: XSS OK.
505
  }
506
 
507
 
508
  /**
509
  * Function to show daily popular posts.
510
  *
511
+ * @since 1.2
512
  *
513
+ * @param mixed $args Arguments list.
514
  */
515
  function tptn_show_daily_pop_posts( $args = null ) {
516
  if ( is_array( $args ) || ! isset( $args ) ) {
517
+ $args['daily'] = 1;
518
  $args['manual'] = 1;
519
  } else {
520
  $args .= '&daily=1&is_manual=1';
includes/public/media.php CHANGED
@@ -5,7 +5,6 @@
5
  * @package Top_Ten
6
  */
7
 
8
-
9
  /**
10
  * Add custom image size of thumbnail. Filters `init`.
11
  *
@@ -18,11 +17,11 @@ function tptn_add_image_sizes() {
18
  $tptn_settings['thumb_size'] = 'tptn_thumbnail';
19
  }
20
 
21
- // Add image sizes if 'tptn_thumbnail' is selected or the selected thumbnail size is no longer valid
22
- if ( 'tptn_thumbnail' == $tptn_settings['thumb_size'] ) {
23
- $width = empty( $tptn_settings['thumb_width'] ) ? 150 : $tptn_settings['thumb_width'];
24
- $height = empty( $tptn_settings['thumb_height'] ) ? 150 : $tptn_settings['thumb_height'];
25
- $crop = isset( $tptn_settings['thumb_crop'] ) ? $tptn_settings['thumb_crop'] : true;
26
 
27
  add_image_size( 'tptn_thumbnail', $width, $height, $crop );
28
  }
@@ -33,38 +32,38 @@ add_action( 'init', 'tptn_add_image_sizes' );
33
  /**
34
  * Function to get the post thumbnail.
35
  *
36
- * @since 1.8
37
- * @param array $args Query string of options related to thumbnails
38
- * @return string Image tag
39
  */
40
  function tptn_get_the_post_thumbnail( $args = array() ) {
41
 
42
  $defaults = array(
43
- 'postid' => '',
44
- 'thumb_height' => '150', // Max height of thumbnails
45
- 'thumb_width' => '150', // Max width of thumbnails
46
- 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image
47
- 'thumb_html' => 'html', // HTML / CSS for width and height attributes
48
- 'thumb_default' => '', // Default thumbnail image
49
- 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all)
50
- 'scan_images' => false, // Scan post for images
51
- 'class' => 'tptn_thumb', // Class of the thumbnail
52
  );
53
 
54
- // Parse incomming $args into an array and merge it with $defaults
55
  $args = wp_parse_args( $args, $defaults );
56
 
57
- // Issue notice for deprecated arguments
58
  if ( isset( $args['thumb_timthumb'] ) ) {
59
- _deprecated_argument( __FUNCTION__, '2.1', __( 'thumb_timthumb argument has been deprecated', 'top-10' ) );
60
  }
61
 
62
  if ( isset( $args['thumb_timthumb_q'] ) ) {
63
- _deprecated_argument( __FUNCTION__, '2.1', __( 'thumb_timthumb_q argument has been deprecated', 'top-10' ) );
64
  }
65
 
66
  if ( isset( $args['filter'] ) ) {
67
- _deprecated_argument( __FUNCTION__, '2.1', __( 'filter argument has been deprecated', 'top-10' ) );
68
  }
69
 
70
  if ( is_int( $args['postid'] ) ) {
@@ -78,21 +77,21 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
78
  /**
79
  * Filters the title and alt message for thumbnails.
80
  *
81
- * @since 2.3.0
82
  *
83
- * @param string $post_title Post tile used as thumbnail alt and title
84
- * @param object $result Post Object
85
  */
86
  $post_title = apply_filters( 'tptn_thumb_title', $post_title, $result );
87
 
88
- $output = '';
89
  $postimage = '';
90
- $pick = '';
91
 
92
- // Let's start fetching the thumbnail. First place to look is in the post meta defined in the Settings page
93
  if ( ! $postimage ) {
94
- $postimage = get_post_meta( $result->ID, $args['thumb_meta'], true ); // Check the post meta first
95
- $pick = 'meta';
96
  if ( $postimage ) {
97
  $postimage_id = tptn_get_attachment_id_from_url( $postimage );
98
 
@@ -104,7 +103,7 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
104
  }
105
  }
106
 
107
- // If there is no thumbnail found, check the post thumbnail
108
  if ( ! $postimage ) {
109
  if ( false != get_post_thumbnail_id( $result->ID ) ) {
110
  $postthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $result->ID ), array( $args['thumb_width'], $args['thumb_height'] ) );
@@ -113,10 +112,10 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
113
  $pick = 'featured';
114
  }
115
 
116
- // If there is no thumbnail found, fetch the first image in the post, if enabled
117
  if ( ! $postimage && $args['scan_images'] ) {
118
  preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $result->post_content, $matches );
119
- if ( isset( $matches[1][0] ) && $matches[1][0] ) { // any image there?
120
  $postimage = $matches[1][0]; // we need the first one only!
121
  }
122
  $pick = 'first';
@@ -131,25 +130,25 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
131
  }
132
  }
133
 
134
- // If there is no thumbnail found, fetch the first child image
135
  if ( ! $postimage ) {
136
- $postimage = tptn_get_first_image( $result->ID, $args['thumb_width'], $args['thumb_height'] ); // Get the first image
137
- $pick = 'firstchild';
138
  }
139
 
140
- // If no other thumbnail set, try to get the custom video thumbnail set by the Video Thumbnails plugin
141
  if ( ! $postimage ) {
142
  $postimage = get_post_meta( $result->ID, '_video_thumbnail', true );
143
- $pick = 'video_thumb';
144
  }
145
 
146
- // If no thumb found and settings permit, use default thumb
147
  if ( ! $postimage && $args['thumb_default_show'] ) {
148
  $postimage = $args['thumb_default'];
149
- $pick = 'default_thumb';
150
  }
151
 
152
- // Hopefully, we've found a thumbnail by now. If so, run it through the custom filter, check for SSL and create the image tag
153
  if ( $postimage ) {
154
 
155
  /**
@@ -158,36 +157,36 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
158
  * Use this filter to modify the thumbnail URL that is automatically created
159
  * Before v2.1 this was used for cropping the post image using timthumb
160
  *
161
- * @since 2.1.0
162
  *
163
- * @param string $postimage URL of the thumbnail image
164
- * @param int $thumb_width Thumbnail width
165
- * @param int $thumb_height Thumbnail height
166
- * @param object $result Post Object
167
  */
168
  $postimage = apply_filters( 'tptn_thumb_url', $postimage, $args['thumb_width'], $args['thumb_height'], $result );
169
 
170
  /* Backward compatibility */
171
- $thumb_timthumb = false;
172
  $thumb_timthumb_q = 75;
173
 
174
  /**
175
  * Filters the thumbnail image URL.
176
  *
177
  * @since 1.8.10
178
- * @deprecated 2.1.0 Use tptn_thumb_url instead.
179
  *
180
- * @param string $postimage URL of the thumbnail image
181
- * @param int $thumb_width Thumbnail width
182
- * @param int $thumb_height Thumbnail height
183
- * @param boolean $thumb_timthumb Enable timthumb?
184
- * @param int $thumb_timthumb_q Quality of timthumb thumbnail.
185
- * @param object $result Post Object
186
  */
187
  $postimage = apply_filters( 'tptn_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
188
 
189
  if ( is_ssl() ) {
190
- $postimage = preg_replace( '~http://~', 'https://', $postimage );
191
  }
192
 
193
  if ( 'css' == $args['thumb_html'] ) {
@@ -201,9 +200,9 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
201
  /**
202
  * Filters the thumbnail HTML and allows a filter function to add any more HTML if needed.
203
  *
204
- * @since 2.2.0
205
  *
206
- * @param string $thumb_html Thumbnail HTML
207
  */
208
  $thumb_html = apply_filters( 'tptn_thumb_html', $thumb_html );
209
 
@@ -212,9 +211,9 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
212
  /**
213
  * Filters the thumbnail classes and allows a filter function to add any more classes if needed.
214
  *
215
- * @since 2.2.0
216
  *
217
- * @param string $thumb_html Thumbnail HTML
218
  */
219
  $class = apply_filters( 'tptn_thumb_class', $class );
220
 
@@ -224,10 +223,10 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
224
  /**
225
  * Filters post thumbnail created for Top 10.
226
  *
227
- * @since 1.9.10.1
228
  *
229
- * @param array $output Formatted output
230
- * @param array $args Argument list
231
  */
232
  return apply_filters( 'tptn_get_the_post_thumbnail', $output, $args );
233
  }
@@ -236,18 +235,20 @@ function tptn_get_the_post_thumbnail( $args = array() ) {
236
  /**
237
  * Get the first child image in the post.
238
  *
239
- * @since 1.9.8
240
- * @param mixed $postID Post ID
241
- * @return string Location of thumbnail
 
 
242
  */
243
  function tptn_get_first_image( $postID, $thumb_width, $thumb_height ) {
244
  $args = array(
245
- 'numberposts' => 1,
246
- 'order' => 'ASC',
247
  'post_mime_type' => 'image',
248
- 'post_parent' => $postID,
249
- 'post_status' => null,
250
- 'post_type' => 'attachment',
251
  );
252
 
253
  $attachments = get_children( $args );
@@ -259,10 +260,10 @@ function tptn_get_first_image( $postID, $thumb_width, $thumb_height ) {
259
  /**
260
  * Filters first child attachment from the post.
261
  *
262
- * @since 1.9.10.1
263
  *
264
- * @param array $image_attributes[0] URL of the image
265
- * @param int $postID Post ID
266
  */
267
  return apply_filters( 'tptn_get_first_image', $image_attributes[0] );
268
  }
@@ -277,8 +278,8 @@ function tptn_get_first_image( $postID, $thumb_width, $thumb_height ) {
277
  *
278
  * @since 2.1
279
  *
280
- * @param string $attachment_url Attachment URL
281
- * @return int Attachment ID
282
  */
283
  function tptn_get_attachment_id_from_url( $attachment_url = '' ) {
284
 
@@ -290,20 +291,20 @@ function tptn_get_attachment_id_from_url( $attachment_url = '' ) {
290
  return;
291
  }
292
 
293
- // Get the upload directory paths
294
  $upload_dir_paths = wp_upload_dir();
295
 
296
- // Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image
297
  if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) {
298
 
299
- // If this is the URL of an auto-generated thumbnail, get the URL of the original image
300
  $attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url );
301
 
302
- // Remove the upload path base directory from the attachment URL
303
  $attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
304
 
305
- // Finally, run a custom database query to get the attachment ID from the modified attachment URL
306
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) );
307
 
308
  }
309
 
@@ -312,8 +313,8 @@ function tptn_get_attachment_id_from_url( $attachment_url = '' ) {
312
  *
313
  * @since 2.1
314
  *
315
- * @param int Attachment ID
316
- * @param string $attachment_url Attachment URL
317
  */
318
  return apply_filters( 'tptn_get_attachment_id_from_url', $attachment_id, $attachment_url );
319
  }
@@ -322,28 +323,28 @@ function tptn_get_attachment_id_from_url( $attachment_url = '' ) {
322
  /**
323
  * Function to get the correct height and width of the thumbnail.
324
  *
325
- * @since 2.2.0
326
  *
327
- * @param array Array of arguments
328
- * @return array Width and height
329
  */
330
  function tptn_get_thumb_size( $args ) {
331
 
332
- // Get thumbnail size
333
  $tptn_thumb_size = tptn_get_all_image_sizes( $args['thumb_size'] );
334
 
335
  if ( isset( $tptn_thumb_size['width'] ) ) {
336
- $thumb_width = $tptn_thumb_size['width'];
337
  $thumb_height = $tptn_thumb_size['height'];
338
  }
339
 
340
  if ( empty( $thumb_width ) || ( $args['is_widget'] && $thumb_width != $args['thumb_width'] ) ) {
341
- $thumb_width = $args['thumb_width'];
342
  $args['thumb_html'] = 'css';
343
  }
344
 
345
  if ( empty( $thumb_height ) || ( $args['is_widget'] && $thumb_height != $args['thumb_height'] ) ) {
346
- $thumb_height = $args['thumb_height'];
347
  $args['thumb_html'] = 'css';
348
  }
349
 
@@ -352,10 +353,10 @@ function tptn_get_thumb_size( $args ) {
352
  /**
353
  * Filter array of thumbnail size.
354
  *
355
- * @since 2.2.0
356
  *
357
- * @param array $thumb_size Array with width and height of thumbnail
358
- * @param array $args Array of arguments
359
  */
360
  return apply_filters( 'tptn_get_thumb_size', $thumb_size, $args );
361
 
@@ -365,9 +366,9 @@ function tptn_get_thumb_size( $args ) {
365
  /**
366
  * Get all image sizes.
367
  *
368
- * @since 2.0.0
369
- * @param string $size Get specific image size
370
- * @return array Image size names along with width, height and crop setting
371
  */
372
  function tptn_get_all_image_sizes( $size = '' ) {
373
  global $_wp_additional_image_sizes;
@@ -378,21 +379,21 @@ function tptn_get_all_image_sizes( $size = '' ) {
378
  foreach ( $intermediate_image_sizes as $_size ) {
379
  if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
380
 
381
- $sizes[ $_size ]['name'] = $_size;
382
- $sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
383
  $sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
384
- $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
385
 
386
- if ( ( 0 == $sizes[ $_size ]['width'] ) && ( 0 == $sizes[ $_size ]['height'] ) ) {
387
- unset( $sizes[ $_size ] );
388
- }
389
  } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
390
 
391
  $sizes[ $_size ] = array(
392
- 'name' => $_size,
393
- 'width' => $_wp_additional_image_sizes[ $_size ]['width'],
394
  'height' => $_wp_additional_image_sizes[ $_size ]['height'],
395
- 'crop' => (bool) $_wp_additional_image_sizes[ $_size ]['crop'],
396
  );
397
  }
398
  }
@@ -409,9 +410,9 @@ function tptn_get_all_image_sizes( $size = '' ) {
409
  /**
410
  * Filters array of image sizes.
411
  *
412
- * @since 2.0.0
413
  *
414
- * @param array $sizes Image sizes
415
  */
416
  return apply_filters( 'tptn_get_all_image_sizes', $sizes );
417
  }
5
  * @package Top_Ten
6
  */
7
 
 
8
  /**
9
  * Add custom image size of thumbnail. Filters `init`.
10
  *
17
  $tptn_settings['thumb_size'] = 'tptn_thumbnail';
18
  }
19
 
20
+ // Add image sizes if 'tptn_thumbnail' is selected or the selected thumbnail size is no longer valid.
21
+ if ( 'tptn_thumbnail' === tptn_get_option( 'thumb_size' ) ) {
22
+ $width = tptn_get_option( 'thumb_width', 150 );
23
+ $height = tptn_get_option( 'thumb_height', 150 );
24
+ $crop = tptn_get_option( 'thumb_crop', true );
25
 
26
  add_image_size( 'tptn_thumbnail', $width, $height, $crop );
27
  }
32
  /**
33
  * Function to get the post thumbnail.
34
  *
35
+ * @since 1.8
36
+ * @param array $args Query string of options related to thumbnails.
37
+ * @return string Image tag
38
  */
39
  function tptn_get_the_post_thumbnail( $args = array() ) {
40
 
41
  $defaults = array(
42
+ 'postid' => '',
43
+ 'thumb_height' => '150', // Max height of thumbnails.
44
+ 'thumb_width' => '150', // Max width of thumbnails.
45
+ 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
46
+ 'thumb_html' => 'html', // HTML / CSS for width and height attributes.
47
+ 'thumb_default' => '', // Default thumbnail image.
48
+ 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
49
+ 'scan_images' => false, // Scan post for images.
50
+ 'class' => 'tptn_thumb', // Class of the thumbnail.
51
  );
52
 
53
+ // Parse incomming $args into an array and merge it with $defaults.
54
  $args = wp_parse_args( $args, $defaults );
55
 
56
+ // Issue notice for deprecated arguments.
57
  if ( isset( $args['thumb_timthumb'] ) ) {
58
+ _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'thumb_timthumb argument has been deprecated', 'top-10' ) );
59
  }
60
 
61
  if ( isset( $args['thumb_timthumb_q'] ) ) {
62
+ _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'thumb_timthumb_q argument has been deprecated', 'top-10' ) );
63
  }
64
 
65
  if ( isset( $args['filter'] ) ) {
66
+ _deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'filter argument has been deprecated', 'top-10' ) );
67
  }
68
 
69
  if ( is_int( $args['postid'] ) ) {
77
  /**
78
  * Filters the title and alt message for thumbnails.
79
  *
80
+ * @since 2.3.0
81
  *
82
+ * @param string $post_title Post tile used as thumbnail alt and title
83
+ * @param object $result Post Object
84
  */
85
  $post_title = apply_filters( 'tptn_thumb_title', $post_title, $result );
86
 
87
+ $output = '';
88
  $postimage = '';
89
+ $pick = '';
90
 
91
+ // Let's start fetching the thumbnail. First place to look is in the post meta defined in the Settings page.
92
  if ( ! $postimage ) {
93
+ $postimage = get_post_meta( $result->ID, $args['thumb_meta'], true ); // Check the post meta first.
94
+ $pick = 'meta';
95
  if ( $postimage ) {
96
  $postimage_id = tptn_get_attachment_id_from_url( $postimage );
97
 
103
  }
104
  }
105
 
106
+ // If there is no thumbnail found, check the post thumbnail.
107
  if ( ! $postimage ) {
108
  if ( false != get_post_thumbnail_id( $result->ID ) ) {
109
  $postthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $result->ID ), array( $args['thumb_width'], $args['thumb_height'] ) );
112
  $pick = 'featured';
113
  }
114
 
115
+ // If there is no thumbnail found, fetch the first image in the post, if enabled.
116
  if ( ! $postimage && $args['scan_images'] ) {
117
  preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $result->post_content, $matches );
118
+ if ( isset( $matches[1][0] ) && $matches[1][0] ) { // any image there?
119
  $postimage = $matches[1][0]; // we need the first one only!
120
  }
121
  $pick = 'first';
130
  }
131
  }
132
 
133
+ // If there is no thumbnail found, fetch the first child image.
134
  if ( ! $postimage ) {
135
+ $postimage = tptn_get_first_image( $result->ID, $args['thumb_width'], $args['thumb_height'] ); // Get the first image.
136
+ $pick = 'firstchild';
137
  }
138
 
139
+ // If no other thumbnail set, try to get the custom video thumbnail set by the Video Thumbnails plugin.
140
  if ( ! $postimage ) {
141
  $postimage = get_post_meta( $result->ID, '_video_thumbnail', true );
142
+ $pick = 'video_thumb';
143
  }
144
 
145
+ // If no thumb found and settings permit, use default thumb.
146
  if ( ! $postimage && $args['thumb_default_show'] ) {
147
  $postimage = $args['thumb_default'];
148
+ $pick = 'default_thumb';
149
  }
150
 
151
+ // Hopefully, we've found a thumbnail by now. If so, run it through the custom filter, check for SSL and create the image tag.
152
  if ( $postimage ) {
153
 
154
  /**
157
  * Use this filter to modify the thumbnail URL that is automatically created
158
  * Before v2.1 this was used for cropping the post image using timthumb
159
  *
160
+ * @since 2.1.0
161
  *
162
+ * @param string $postimage URL of the thumbnail image
163
+ * @param int $thumb_width Thumbnail width
164
+ * @param int $thumb_height Thumbnail height
165
+ * @param object $result Post Object
166
  */
167
  $postimage = apply_filters( 'tptn_thumb_url', $postimage, $args['thumb_width'], $args['thumb_height'], $result );
168
 
169
  /* Backward compatibility */
170
+ $thumb_timthumb = false;
171
  $thumb_timthumb_q = 75;
172
 
173
  /**
174
  * Filters the thumbnail image URL.
175
  *
176
  * @since 1.8.10
177
+ * @deprecated 2.1.0 Use tptn_thumb_url instead.
178
  *
179
+ * @param string $postimage URL of the thumbnail image
180
+ * @param int $thumb_width Thumbnail width
181
+ * @param int $thumb_height Thumbnail height
182
+ * @param boolean $thumb_timthumb Enable timthumb?
183
+ * @param int $thumb_timthumb_q Quality of timthumb thumbnail.
184
+ * @param object $result Post Object
185
  */
186
  $postimage = apply_filters( 'tptn_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
187
 
188
  if ( is_ssl() ) {
189
+ $postimage = preg_replace( '~http://~', 'https://', $postimage );
190
  }
191
 
192
  if ( 'css' == $args['thumb_html'] ) {
200
  /**
201
  * Filters the thumbnail HTML and allows a filter function to add any more HTML if needed.
202
  *
203
+ * @since 2.2.0
204
  *
205
+ * @param string $thumb_html Thumbnail HTML
206
  */
207
  $thumb_html = apply_filters( 'tptn_thumb_html', $thumb_html );
208
 
211
  /**
212
  * Filters the thumbnail classes and allows a filter function to add any more classes if needed.
213
  *
214
+ * @since 2.2.0
215
  *
216
+ * @param string $thumb_html Thumbnail HTML
217
  */
218
  $class = apply_filters( 'tptn_thumb_class', $class );
219
 
223
  /**
224
  * Filters post thumbnail created for Top 10.
225
  *
226
+ * @since 1.9.10.1
227
  *
228
+ * @param array $output Formatted output
229
+ * @param array $args Argument list
230
  */
231
  return apply_filters( 'tptn_get_the_post_thumbnail', $output, $args );
232
  }
235
  /**
236
  * Get the first child image in the post.
237
  *
238
+ * @since 1.9.8
239
+ * @param mixed $postID Post ID.
240
+ * @param int $thumb_width Thumb width.
241
+ * @param int $thumb_height Thumb height.
242
+ * @return string Location of thumbnail
243
  */
244
  function tptn_get_first_image( $postID, $thumb_width, $thumb_height ) {
245
  $args = array(
246
+ 'numberposts' => 1,
247
+ 'order' => 'ASC',
248
  'post_mime_type' => 'image',
249
+ 'post_parent' => $postID,
250
+ 'post_status' => null,
251
+ 'post_type' => 'attachment',
252
  );
253
 
254
  $attachments = get_children( $args );
260
  /**
261
  * Filters first child attachment from the post.
262
  *
263
+ * @since 1.9.10.1
264
  *
265
+ * @param array $image_attributes[0] URL of the image
266
+ * @param int $postID Post ID
267
  */
268
  return apply_filters( 'tptn_get_first_image', $image_attributes[0] );
269
  }
278
  *
279
  * @since 2.1
280
  *
281
+ * @param string $attachment_url Attachment URL.
282
+ * @return int Attachment ID
283
  */
284
  function tptn_get_attachment_id_from_url( $attachment_url = '' ) {
285
 
291
  return;
292
  }
293
 
294
+ // Get the upload directory paths.
295
  $upload_dir_paths = wp_upload_dir();
296
 
297
+ // Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image.
298
  if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) {
299
 
300
+ // If this is the URL of an auto-generated thumbnail, get the URL of the original image.
301
  $attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url );
302
 
303
+ // Remove the upload path base directory from the attachment URL.
304
  $attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
305
 
306
+ // Finally, run a custom database query to get the attachment ID from the modified attachment URL.
307
+ $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = %s AND wposts.post_type = 'attachment'", $attachment_url ) );
308
 
309
  }
310
 
313
  *
314
  * @since 2.1
315
  *
316
+ * @param int Attachment ID
317
+ * @param string $attachment_url Attachment URL
318
  */
319
  return apply_filters( 'tptn_get_attachment_id_from_url', $attachment_id, $attachment_url );
320
  }
323
  /**
324
  * Function to get the correct height and width of the thumbnail.
325
  *
326
+ * @since 2.2.0
327
  *
328
+ * @param array $args Array of arguments.
329
+ * @return array Width and height
330
  */
331
  function tptn_get_thumb_size( $args ) {
332
 
333
+ // Get thumbnail size.
334
  $tptn_thumb_size = tptn_get_all_image_sizes( $args['thumb_size'] );
335
 
336
  if ( isset( $tptn_thumb_size['width'] ) ) {
337
+ $thumb_width = $tptn_thumb_size['width'];
338
  $thumb_height = $tptn_thumb_size['height'];
339
  }
340
 
341
  if ( empty( $thumb_width ) || ( $args['is_widget'] && $thumb_width != $args['thumb_width'] ) ) {
342
+ $thumb_width = $args['thumb_width'];
343
  $args['thumb_html'] = 'css';
344
  }
345
 
346
  if ( empty( $thumb_height ) || ( $args['is_widget'] && $thumb_height != $args['thumb_height'] ) ) {
347
+ $thumb_height = $args['thumb_height'];
348
  $args['thumb_html'] = 'css';
349
  }
350
 
353
  /**
354
  * Filter array of thumbnail size.
355
  *
356
+ * @since 2.2.0
357
  *
358
+ * @param array $thumb_size Array with width and height of thumbnail
359
+ * @param array $args Array of arguments
360
  */
361
  return apply_filters( 'tptn_get_thumb_size', $thumb_size, $args );
362
 
366
  /**
367
  * Get all image sizes.
368
  *
369
+ * @since 2.0.0
370
+ * @param string $size Get specific image size.
371
+ * @return array Image size names along with width, height and crop setting
372
  */
373
  function tptn_get_all_image_sizes( $size = '' ) {
374
  global $_wp_additional_image_sizes;
379
  foreach ( $intermediate_image_sizes as $_size ) {
380
  if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
381
 
382
+ $sizes[ $_size ]['name'] = $_size;
383
+ $sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
384
  $sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
385
+ $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
386
 
387
+ if ( ( 0 == $sizes[ $_size ]['width'] ) && ( 0 == $sizes[ $_size ]['height'] ) ) {
388
+ unset( $sizes[ $_size ] );
389
+ }
390
  } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
391
 
392
  $sizes[ $_size ] = array(
393
+ 'name' => $_size,
394
+ 'width' => $_wp_additional_image_sizes[ $_size ]['width'],
395
  'height' => $_wp_additional_image_sizes[ $_size ]['height'],
396
+ 'crop' => (bool) $_wp_additional_image_sizes[ $_size ]['crop'],
397
  );
398
  }
399
  }
410
  /**
411
  * Filters array of image sizes.
412
  *
413
+ * @since 2.0.0
414
  *
415
+ * @param array $sizes Image sizes
416
  */
417
  return apply_filters( 'tptn_get_all_image_sizes', $sizes );
418
  }
includes/public/output-generator.php CHANGED
@@ -17,10 +17,11 @@ if ( ! defined( 'WPINC' ) ) {
17
  /**
18
  * Returns the link attributes.
19
  *
20
- * @since 2.2.0
21
  *
22
- * @param array $args Array of arguments
23
- * @return string Space separated list of link attributes
 
24
  */
25
  function tptn_link_attributes( $args, $result ) {
26
 
@@ -29,21 +30,21 @@ function tptn_link_attributes( $args, $result ) {
29
  $target_attribute = ( $args['link_new_window'] ) ? ' target="_blank" ' : ' ';
30
 
31
  $link_attributes = array(
32
- 'rel_attribute' => $rel_attribute,
33
  'target_attribute' => $target_attribute,
34
  );
35
 
36
  /**
37
  * Filter the title of the popular posts list
38
  *
39
- * @since 2.2.0
40
  *
41
- * @param array $link_attributes Array of link attributes
42
- * @param array $args Array of arguments
43
  */
44
  $link_attributes = apply_filters( 'tptn_link_attributes', $link_attributes, $args, $result );
45
 
46
- // Convert it to a string
47
  $link_attributes = implode( ' ', $link_attributes );
48
 
49
  return $link_attributes;
@@ -54,10 +55,10 @@ function tptn_link_attributes( $args, $result ) {
54
  /**
55
  * Returns the heading of the popular posts.
56
  *
57
- * @since 2.2.0
58
  *
59
- * @param array $args Array of arguments
60
- * @return string Space separated list of link attributes
61
  */
62
  function tptn_heading_title( $args ) {
63
 
@@ -70,10 +71,10 @@ function tptn_heading_title( $args ) {
70
  /**
71
  * Filter the title of the Top posts.
72
  *
73
- * @since 1.9.5
74
  *
75
- * @param string $title Title/heading of the popular posts list
76
- * @param array $args Array of arguments
77
  */
78
  return apply_filters( 'tptn_heading_title', $title, $args );
79
  }
@@ -82,10 +83,10 @@ function tptn_heading_title( $args ) {
82
  /**
83
  * Returns the opening tag of the popular posts list.
84
  *
85
- * @since 2.2.0
86
  *
87
- * @param array $args Array of arguments
88
- * @return string Space separated list of link attributes
89
  */
90
  function tptn_before_list( $args ) {
91
 
@@ -94,10 +95,10 @@ function tptn_before_list( $args ) {
94
  /**
95
  * Filter the opening tag of the popular posts list
96
  *
97
- * @since 1.9.10.1
98
  *
99
- * @param string $before_list Opening tag set in the Settings Page
100
- * @param array $args Array of arguments
101
  */
102
  return apply_filters( 'tptn_before_list', $before_list, $args );
103
 
@@ -107,10 +108,10 @@ function tptn_before_list( $args ) {
107
  /**
108
  * Returns the closing tag of the popular posts list.
109
  *
110
- * @since 2.2.0
111
  *
112
- * @param array $args Array of arguments
113
- * @return string Space separated list of link attributes
114
  */
115
  function tptn_after_list( $args ) {
116
 
@@ -119,10 +120,10 @@ function tptn_after_list( $args ) {
119
  /**
120
  * Filter the closing tag of the popular posts list
121
  *
122
- * @since 1.9.10.1
123
  *
124
- * @param string $after_list Closing tag set in the Settings Page
125
- * @param array $args Array of arguments
126
  */
127
  return apply_filters( 'tptn_after_list', $after_list, $args );
128
 
@@ -132,11 +133,11 @@ function tptn_after_list( $args ) {
132
  /**
133
  * Returns the opening tag of each list item.
134
  *
135
- * @since 2.2.0
136
  *
137
- * @param array $args Array of arguments
138
- * @param object $result Object of the current post result
139
- * @return string Space separated list of link attributes
140
  */
141
  function tptn_before_list_item( $args, $result ) {
142
 
@@ -145,11 +146,11 @@ function tptn_before_list_item( $args, $result ) {
145
  /**
146
  * Filter the opening tag of each list item.
147
  *
148
- * @since 1.9.10.1
149
  *
150
- * @param string $before_list_item Tag before each list item. Can be defined in the Settings page.
151
- * @param object $result Object of the current post result
152
- * @param array $args Array of arguments
153
  */
154
  return apply_filters( 'tptn_before_list_item', $before_list_item, $result, $args );
155
 
@@ -159,11 +160,11 @@ function tptn_before_list_item( $args, $result ) {
159
  /**
160
  * Returns the closing tag of each list item.
161
  *
162
- * @since 2.2.0
163
  *
164
- * @param array $args Array of arguments
165
- * @param object $result Object of the current post result
166
- * @return string Space separated list of link attributes
167
  */
168
  function tptn_after_list_item( $args, $result ) {
169
 
@@ -172,13 +173,13 @@ function tptn_after_list_item( $args, $result ) {
172
  /**
173
  * Filter the closing tag of each list item.
174
  *
175
- * @since 1.9.10.1
176
  *
177
- * @param string $after_list_item Tag after each list item. Can be defined in the Settings page.
178
- * @param object $result Object of the current post result
179
- * @param array $args Array of arguments
180
  */
181
- return apply_filters( 'tptn_after_list_item', $after_list_item, $result, $args ); // Pass the post object to the filter
182
 
183
  }
184
 
@@ -186,24 +187,24 @@ function tptn_after_list_item( $args, $result ) {
186
  /**
187
  * Returns the title of each list item.
188
  *
189
- * @since 2.2.0
190
  *
191
- * @param array $args Array of arguments
192
- * @param object $result Object of the current post result
193
- * @return string Space separated list of link attributes
194
  */
195
  function tptn_post_title( $args, $result ) {
196
 
197
- $title = tptn_max_formatted_content( get_the_title( $result->ID ), $args['title_length'] ); // Get the post title and crop it if needed
198
 
199
  /**
200
  * Filter the post title of each list item.
201
  *
202
- * @since 2.0.0
203
  *
204
- * @param string $title Title of the post.
205
- * @param object $result Object of the current post result
206
- * @param array $args Array of arguments
207
  */
208
  return apply_filters( 'tptn_post_title', $title, $result, $args );
209
 
@@ -213,11 +214,11 @@ function tptn_post_title( $args, $result ) {
213
  /**
214
  * Returns the author of each list item.
215
  *
216
- * @since 2.2.0
217
  *
218
- * @param array $args Array of arguments
219
- * @param object $result Object of the current post result
220
- * @return string Space separated list of link attributes
221
  */
222
  function tptn_author( $args, $result ) {
223
 
@@ -228,10 +229,10 @@ function tptn_author( $args, $result ) {
228
  /**
229
  * Filter the author name.
230
  *
231
- * @since 1.9.1
232
  *
233
- * @param string $author_name Proper name of the post author.
234
- * @param object $author_info WP_User object of the post author
235
  */
236
  $author_name = apply_filters( 'tptn_author_name', $author_name, $author_info );
237
 
@@ -244,12 +245,12 @@ function tptn_author( $args, $result ) {
244
  /**
245
  * Filter the text with the author details.
246
  *
247
- * @since 2.0.0
248
  *
249
- * @param string $tptn_author Formatted string with author details and link
250
- * @param object $author_info WP_User object of the post author
251
- * @param object $result Object of the current post result
252
- * @param array $args Array of arguments
253
  */
254
  return apply_filters( 'tptn_author', $tptn_author, $author_info, $result, $args );
255
 
@@ -259,57 +260,59 @@ function tptn_author( $args, $result ) {
259
  /**
260
  * Returns the formatted list item with link and and thumbnail for each list item.
261
  *
262
- * @since 2.2.0
263
  *
264
- * @param array $args Array of arguments
265
- * @param object $result Object of the current post result
266
- * @return string Space separated list of link attributes
267
  */
268
  function tptn_list_link( $args, $result ) {
269
 
270
- $output = '';
271
- $title = tptn_post_title( $args, $result );
272
  $link_attributes = tptn_link_attributes( $args, $result );
273
 
274
- if ( 'after' == $args['post_thumb_op'] ) {
275
- $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link
276
- $output .= '<span class="tptn_title">' . $title . '</span>'; // Add title if post thumbnail is to be displayed after
277
- $output .= '</a>'; // Close the link
278
  }
279
 
280
- if ( 'inline' == $args['post_thumb_op'] || 'after' == $args['post_thumb_op'] || 'thumbs_only' == $args['post_thumb_op'] ) {
281
- $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link
282
-
283
- $output .= tptn_get_the_post_thumbnail( array(
284
- 'postid' => $result,
285
- 'thumb_height' => $args['thumb_height'],
286
- 'thumb_width' => $args['thumb_width'],
287
- 'thumb_meta' => $args['thumb_meta'],
288
- 'thumb_html' => $args['thumb_html'],
289
- 'thumb_default' => $args['thumb_default'],
290
- 'thumb_default_show' => $args['thumb_default_show'],
291
- 'scan_images' => $args['scan_images'],
292
- 'class' => 'tptn_thumb',
293
- ) );
294
-
295
- $output .= '</a>'; // Close the link
 
 
296
  }
297
 
298
- if ( 'inline' == $args['post_thumb_op'] || 'text_only' == $args['post_thumb_op'] ) {
299
  $output .= '<span class="tptn_after_thumb">';
300
- $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link
301
- $output .= '<span class="tptn_title">' . $title . '</span>'; // Add title when required by settings
302
- $output .= '</a>'; // Close the link
303
  }
304
 
305
  /**
306
  * Filter Formatted list item with link and and thumbnail.
307
  *
308
- * @since 2.2.0
309
  *
310
- * @param string $output Formatted list item with link and and thumbnail
311
- * @param object $result Object of the current post result
312
- * @param array $args Array of arguments
313
  */
314
  return apply_filters( 'tptn_list_link', $output, $result, $args );
315
 
17
  /**
18
  * Returns the link attributes.
19
  *
20
+ * @since 2.2.0
21
  *
22
+ * @param array $args Array of arguments.
23
+ * @param object $result Result object.
24
+ * @return string Space separated list of link attributes
25
  */
26
  function tptn_link_attributes( $args, $result ) {
27
 
30
  $target_attribute = ( $args['link_new_window'] ) ? ' target="_blank" ' : ' ';
31
 
32
  $link_attributes = array(
33
+ 'rel_attribute' => $rel_attribute,
34
  'target_attribute' => $target_attribute,
35
  );
36
 
37
  /**
38
  * Filter the title of the popular posts list
39
  *
40
+ * @since 2.2.0
41
  *
42
+ * @param array $link_attributes Array of link attributes
43
+ * @param array $args Array of arguments
44
  */
45
  $link_attributes = apply_filters( 'tptn_link_attributes', $link_attributes, $args, $result );
46
 
47
+ // Convert it to a string.
48
  $link_attributes = implode( ' ', $link_attributes );
49
 
50
  return $link_attributes;
55
  /**
56
  * Returns the heading of the popular posts.
57
  *
58
+ * @since 2.2.0
59
  *
60
+ * @param array $args Array of arguments.
61
+ * @return string Space separated list of link attributes
62
  */
63
  function tptn_heading_title( $args ) {
64
 
71
  /**
72
  * Filter the title of the Top posts.
73
  *
74
+ * @since 1.9.5
75
  *
76
+ * @param string $title Title/heading of the popular posts list
77
+ * @param array $args Array of arguments
78
  */
79
  return apply_filters( 'tptn_heading_title', $title, $args );
80
  }
83
  /**
84
  * Returns the opening tag of the popular posts list.
85
  *
86
+ * @since 2.2.0
87
  *
88
+ * @param array $args Array of arguments.
89
+ * @return string Space separated list of link attributes
90
  */
91
  function tptn_before_list( $args ) {
92
 
95
  /**
96
  * Filter the opening tag of the popular posts list
97
  *
98
+ * @since 1.9.10.1
99
  *
100
+ * @param string $before_list Opening tag set in the Settings Page
101
+ * @param array $args Array of arguments
102
  */
103
  return apply_filters( 'tptn_before_list', $before_list, $args );
104
 
108
  /**
109
  * Returns the closing tag of the popular posts list.
110
  *
111
+ * @since 2.2.0
112
  *
113
+ * @param array $args Array of arguments.
114
+ * @return string Space separated list of link attributes
115
  */
116
  function tptn_after_list( $args ) {
117
 
120
  /**
121
  * Filter the closing tag of the popular posts list
122
  *
123
+ * @since 1.9.10.1
124
  *
125
+ * @param string $after_list Closing tag set in the Settings Page
126
+ * @param array $args Array of arguments
127
  */
128
  return apply_filters( 'tptn_after_list', $after_list, $args );
129
 
133
  /**
134
  * Returns the opening tag of each list item.
135
  *
136
+ * @since 2.2.0
137
  *
138
+ * @param array $args Array of arguments.
139
+ * @param object $result Object of the current post result.
140
+ * @return string Space separated list of link attributes
141
  */
142
  function tptn_before_list_item( $args, $result ) {
143
 
146
  /**
147
  * Filter the opening tag of each list item.
148
  *
149
+ * @since 1.9.10.1
150
  *
151
+ * @param string $before_list_item Tag before each list item. Can be defined in the Settings page.
152
+ * @param object $result Object of the current post result
153
+ * @param array $args Array of arguments
154
  */
155
  return apply_filters( 'tptn_before_list_item', $before_list_item, $result, $args );
156
 
160
  /**
161
  * Returns the closing tag of each list item.
162
  *
163
+ * @since 2.2.0
164
  *
165
+ * @param array $args Array of arguments.
166
+ * @param object $result Object of the current post result.
167
+ * @return string Space separated list of link attributes
168
  */
169
  function tptn_after_list_item( $args, $result ) {
170
 
173
  /**
174
  * Filter the closing tag of each list item.
175
  *
176
+ * @since 1.9.10.1
177
  *
178
+ * @param string $after_list_item Tag after each list item. Can be defined in the Settings page.
179
+ * @param object $result Object of the current post result
180
+ * @param array $args Array of arguments
181
  */
182
+ return apply_filters( 'tptn_after_list_item', $after_list_item, $result, $args ); // Pass the post object to the filter.
183
 
184
  }
185
 
187
  /**
188
  * Returns the title of each list item.
189
  *
190
+ * @since 2.2.0
191
  *
192
+ * @param array $args Array of arguments.
193
+ * @param object $result Object of the current post result.
194
+ * @return string Space separated list of link attributes
195
  */
196
  function tptn_post_title( $args, $result ) {
197
 
198
+ $title = tptn_max_formatted_content( get_the_title( $result->ID ), $args['title_length'] ); // Get the post title and crop it if needed.
199
 
200
  /**
201
  * Filter the post title of each list item.
202
  *
203
+ * @since 2.0.0
204
  *
205
+ * @param string $title Title of the post.
206
+ * @param object $result Object of the current post result
207
+ * @param array $args Array of arguments
208
  */
209
  return apply_filters( 'tptn_post_title', $title, $result, $args );
210
 
214
  /**
215
  * Returns the author of each list item.
216
  *
217
+ * @since 2.2.0
218
  *
219
+ * @param array $args Array of arguments.
220
+ * @param object $result Object of the current post result.
221
+ * @return string Space separated list of link attributes
222
  */
223
  function tptn_author( $args, $result ) {
224
 
229
  /**
230
  * Filter the author name.
231
  *
232
+ * @since 1.9.1
233
  *
234
+ * @param string $author_name Proper name of the post author.
235
+ * @param object $author_info WP_User object of the post author
236
  */
237
  $author_name = apply_filters( 'tptn_author_name', $author_name, $author_info );
238
 
245
  /**
246
  * Filter the text with the author details.
247
  *
248
+ * @since 2.0.0
249
  *
250
+ * @param string $tptn_author Formatted string with author details and link
251
+ * @param object $author_info WP_User object of the post author
252
+ * @param object $result Object of the current post result
253
+ * @param array $args Array of arguments
254
  */
255
  return apply_filters( 'tptn_author', $tptn_author, $author_info, $result, $args );
256
 
260
  /**
261
  * Returns the formatted list item with link and and thumbnail for each list item.
262
  *
263
+ * @since 2.2.0
264
  *
265
+ * @param array $args Array of arguments.
266
+ * @param object $result Object of the current post result.
267
+ * @return string Space separated list of link attributes
268
  */
269
  function tptn_list_link( $args, $result ) {
270
 
271
+ $output = '';
272
+ $title = tptn_post_title( $args, $result );
273
  $link_attributes = tptn_link_attributes( $args, $result );
274
 
275
+ if ( 'after' === $args['post_thumb_op'] ) {
276
+ $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link.
277
+ $output .= '<span class="tptn_title">' . $title . '</span>'; // Add title if post thumbnail is to be displayed after.
278
+ $output .= '</a>'; // Close the link.
279
  }
280
 
281
+ if ( 'inline' === $args['post_thumb_op'] || 'after' === $args['post_thumb_op'] || 'thumbs_only' === $args['post_thumb_op'] ) {
282
+ $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link.
283
+
284
+ $output .= tptn_get_the_post_thumbnail(
285
+ array(
286
+ 'postid' => $result,
287
+ 'thumb_height' => $args['thumb_height'],
288
+ 'thumb_width' => $args['thumb_width'],
289
+ 'thumb_meta' => $args['thumb_meta'],
290
+ 'thumb_html' => $args['thumb_html'],
291
+ 'thumb_default' => $args['thumb_default'],
292
+ 'thumb_default_show' => $args['thumb_default_show'],
293
+ 'scan_images' => $args['scan_images'],
294
+ 'class' => 'tptn_thumb',
295
+ )
296
+ );
297
+
298
+ $output .= '</a>'; // Close the link.
299
  }
300
 
301
+ if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
302
  $output .= '<span class="tptn_after_thumb">';
303
+ $output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link.
304
+ $output .= '<span class="tptn_title">' . $title . '</span>'; // Add title when required by settings.
305
+ $output .= '</a>'; // Close the link.
306
  }
307
 
308
  /**
309
  * Filter Formatted list item with link and and thumbnail.
310
  *
311
+ * @since 2.2.0
312
  *
313
+ * @param string $output Formatted list item with link and and thumbnail
314
+ * @param object $result Object of the current post result
315
+ * @param array $args Array of arguments
316
  */
317
  return apply_filters( 'tptn_list_link', $output, $result, $args );
318
 
includes/public/styles.php CHANGED
@@ -5,18 +5,16 @@
5
  * @package Top_Ten
6
  */
7
 
8
-
9
  /**
10
  * Function to add CSS to header.
11
  *
12
- * @since 1.9
13
  */
14
  function tptn_header() {
15
- global $tptn_settings;
16
 
17
- $tptn_custom_CSS = stripslashes( $tptn_settings['custom_CSS'] );
18
 
19
- // Add CSS to header
20
  if ( '' != $tptn_custom_CSS ) {
21
  echo '<style type="text/css">' . $tptn_custom_CSS . '</style>';
22
  }
@@ -28,16 +26,18 @@ add_action( 'wp_head', 'tptn_header' );
28
  * Enqueue styles.
29
  */
30
  function tptn_heading_styles() {
31
- global $tptn_settings;
32
 
33
- if ( 'left_thumbs' == $tptn_settings['tptn_styles'] ) {
34
  wp_register_style( 'tptn-style-left-thumbs', plugins_url( 'css/default-style.css', TOP_TEN_PLUGIN_FILE ) );
35
  wp_enqueue_style( 'tptn-style-left-thumbs' );
36
 
 
 
 
37
  $custom_css = "
38
  img.tptn_thumb {
39
- width: {$tptn_settings['thumb_width']}px !important;
40
- height: {$tptn_settings['thumb_height']}px !important;
41
  }
42
  ";
43
 
5
  * @package Top_Ten
6
  */
7
 
 
8
  /**
9
  * Function to add CSS to header.
10
  *
11
+ * @since 1.9
12
  */
13
  function tptn_header() {
 
14
 
15
+ $tptn_custom_CSS = stripslashes( tptn_get_option( 'custom_CSS' ) );
16
 
17
+ // Add CSS to header.
18
  if ( '' != $tptn_custom_CSS ) {
19
  echo '<style type="text/css">' . $tptn_custom_CSS . '</style>';
20
  }
26
  * Enqueue styles.
27
  */
28
  function tptn_heading_styles() {
 
29
 
30
+ if ( 'left_thumbs' === tptn_get_option( 'tptn_styles' ) ) {
31
  wp_register_style( 'tptn-style-left-thumbs', plugins_url( 'css/default-style.css', TOP_TEN_PLUGIN_FILE ) );
32
  wp_enqueue_style( 'tptn-style-left-thumbs' );
33
 
34
+ $width = tptn_get_option( 'thumb_width' );
35
+ $height = tptn_get_option( 'thumb_height' );
36
+
37
  $custom_css = "
38
  img.tptn_thumb {
39
+ width: {$width}px !important;
40
+ height: {$height}px !important;
41
  }
42
  ";
43
 
includes/tracker.php CHANGED
@@ -12,34 +12,40 @@
12
  * @return void
13
  */
14
  function tptn_enqueue_scripts() {
15
- global $post, $tptn_settings;
 
 
 
16
 
17
  if ( is_singular() && 'draft' !== $post->post_status && ! is_customize_preview() ) {
18
 
19
- $current_user = wp_get_current_user(); // Let's get the current user
20
- $post_author = ( $current_user->ID === $post->post_author ) ? true : false; // Is the current user the post author?
21
- $current_user_admin = ( current_user_can( 'manage_options' ) ) ? true : false; // Is the current user an admin?
22
- $current_user_editor = ( ( current_user_can( 'edit_others_posts' ) ) && ( ! current_user_can( 'manage_options' ) ) ) ? true : false; // Is the current user an editor?
23
 
24
  $include_code = true;
25
- if ( ( $post_author ) && ( ! $tptn_settings['track_authors'] ) ) {
 
 
 
26
  $include_code = false;
27
  }
28
- if ( ( $current_user_admin ) && ( ! $tptn_settings['track_admins'] ) ) {
29
  $include_code = false;
30
  }
31
- if ( ( $current_user_editor ) && ( ! $tptn_settings['track_editors'] ) ) {
32
  $include_code = false;
33
  }
34
 
35
  if ( $include_code ) {
36
 
37
- $id = absint( $post->ID );
38
- $blog_id = get_current_blog_id();
39
- $activate_counter = $tptn_settings['activate_overall'] ? 1 : 0; // It's 1 if we're updating the overall count.
40
- $activate_counter = $activate_counter + ( $tptn_settings['activate_daily'] ? 10 : 0 ); // It's 10 if we're updating the daily count.
41
 
42
- if ( 'query_based' === $tptn_settings['tracker_type'] ) {
43
  $home_url = home_url( '/' );
44
  } else {
45
  $home_url = admin_url( 'admin-ajax.php' );
@@ -51,7 +57,7 @@ function tptn_enqueue_scripts() {
51
  * Other tracker types can override the URL processed by the jQuery.post request
52
  * The corresponding tracker can use the below variables or append their own to $ajax_tptn_tracker
53
  *
54
- * @since 2.0
55
  */
56
  $home_url = apply_filters( 'tptn_add_counter_script_url', $home_url );
57
 
@@ -59,12 +65,11 @@ function tptn_enqueue_scripts() {
59
  $home_url = strtok( $home_url, '?' );
60
 
61
  $ajax_tptn_tracker = array(
62
- 'ajax_url' => $home_url,
63
- 'top_ten_nonce' => wp_create_nonce( 'tptn-tracker-nonce' ),
64
- 'top_ten_id' => $id,
65
- 'top_ten_blog_id' => $blog_id,
66
  'activate_counter' => $activate_counter,
67
- 'tptn_rnd' => wp_rand( 1, time() ),
68
  );
69
 
70
  /**
@@ -88,10 +93,10 @@ add_action( 'wp_enqueue_scripts', 'tptn_enqueue_scripts' );
88
  /**
89
  * Function to add additional queries to query_vars.
90
  *
91
- * @since 2.0.0
92
  *
93
- * @param array $vars Query variables array.
94
- * @return array $Query variables array with Top 10 parameters appended
95
  */
96
  function tptn_query_vars( $vars ) {
97
  // Add these to the list of queryvars that WP gathers.
@@ -108,9 +113,9 @@ add_filter( 'query_vars', 'tptn_query_vars' );
108
  /**
109
  * Parses the WordPress object to update/display the count.
110
  *
111
- * @since 2.0.0
112
  *
113
- * @param object $wp WordPress object.
114
  */
115
  function tptn_parse_request( $wp ) {
116
  global $wpdb;
@@ -123,21 +128,21 @@ function tptn_parse_request( $wp ) {
123
  return;
124
  }
125
 
126
- $table_name = $wpdb->base_prefix . 'top_ten';
127
  $top_ten_daily = $wpdb->base_prefix . 'top_ten_daily';
128
- $str = '';
129
 
130
- if ( array_key_exists( 'top_ten_id', $wp->query_vars ) && array_key_exists( 'activate_counter', $wp->query_vars ) && '' !== $wp->query_vars['top_ten_id'] ) {
131
 
132
- $id = absint( $wp->query_vars['top_ten_id'] );
133
- $blog_id = absint( $wp->query_vars['top_ten_blog_id'] );
134
  $activate_counter = absint( $wp->query_vars['activate_counter'] );
135
 
136
  if ( $id > 0 ) {
137
 
138
  if ( ( 1 === $activate_counter ) || ( 11 === $activate_counter ) ) {
139
 
140
- $tt = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES('%d', '1', '%d') ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
141
 
142
  $str .= ( false === $tt ) ? 'tte' : 'tt' . $tt;
143
  }
@@ -146,7 +151,7 @@ function tptn_parse_request( $wp ) {
146
 
147
  $current_date = gmdate( 'Y-m-d H', current_time( 'timestamp', 0 ) );
148
 
149
- $ttd = $wpdb->query( $wpdb->prepare( "INSERT INTO {$top_ten_daily} (postnumber, cntaccess, dp_date, blog_id) VALUES('%d', '1', '%s', '%d' ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $current_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
150
 
151
  $str .= ( false === $ttd ) ? ' ttde' : ' ttd' . $ttd;
152
  }
@@ -194,24 +199,19 @@ function tptn_tracker_parser() {
194
 
195
  global $wpdb;
196
 
197
- // Check for the nonce and exit if failed.
198
- if ( isset( $_POST['top_ten_nonce'] ) && ! wp_verify_nonce( sanitize_key( $_POST['top_ten_nonce'] ), 'tptn-tracker-nonce' ) ) { // Input var okay.
199
- wp_die( esc_html__( 'Top 10: Security check failed', 'top-10' ) );
200
- }
201
-
202
- $table_name = $wpdb->base_prefix . 'top_ten';
203
  $top_ten_daily = $wpdb->base_prefix . 'top_ten_daily';
204
- $str = '';
205
 
206
- $id = isset( $_POST['top_ten_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_id'] ) ) ) : 0; // Input var okay.
207
- $blog_id = isset( $_POST['top_ten_blog_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_blog_id'] ) ) ) : 0; // Input var okay.
208
  $activate_counter = isset( $_POST['activate_counter'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['activate_counter'] ) ) ) : 0; // Input var okay.
209
 
210
  if ( $id > 0 ) {
211
 
212
  if ( ( 1 === $activate_counter ) || ( 11 === $activate_counter ) ) {
213
 
214
- $tt = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES('%d', '1', '%d') ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
215
 
216
  $str .= ( false === $tt ) ? 'tte' : 'tt' . $tt;
217
  }
@@ -220,7 +220,7 @@ function tptn_tracker_parser() {
220
 
221
  $current_date = gmdate( 'Y-m-d H', current_time( 'timestamp', 0 ) );
222
 
223
- $ttd = $wpdb->query( $wpdb->prepare( "INSERT INTO {$top_ten_daily} (postnumber, cntaccess, dp_date, blog_id) VALUES('%d', '1', '%s', '%d' ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $current_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
224
 
225
  $str .= ( false === $ttd ) ? ' ttde' : ' ttd' . $ttd;
226
  }
@@ -244,13 +244,13 @@ function tptn_get_tracker_types() {
244
 
245
  $trackers = array(
246
  array(
247
- 'id' => 'query_based',
248
- 'name' => __( 'Query variable based', 'top-10' ),
249
  'description' => __( 'Uses query variables to record visits', 'top-10' ),
250
  ),
251
  array(
252
- 'id' => 'ajaxurl',
253
- 'name' => __( 'Ajaxurl based', 'top-10' ),
254
  'description' => __( 'Uses admin-ajax.php which is inbuilt within WordPress to process the tracker', 'top-10' ),
255
  ),
256
  );
12
  * @return void
13
  */
14
  function tptn_enqueue_scripts() {
15
+ global $post, $ajax_tptn_tracker;
16
+
17
+ $track_users = tptn_get_option( 'track_users' );
18
+ $trackers = tptn_get_option( 'trackers' );
19
 
20
  if ( is_singular() && 'draft' !== $post->post_status && ! is_customize_preview() ) {
21
 
22
+ $current_user = wp_get_current_user(); // Let's get the current user.
23
+ $post_author = ( $current_user->ID === $post->post_author ) ? true : false; // Is the current user the post author?
24
+ $current_user_admin = ( current_user_can( 'manage_options' ) ) ? true : false; // Is the current user an admin?
25
+ $current_user_editor = ( ( current_user_can( 'edit_others_posts' ) ) && ( ! current_user_can( 'manage_options' ) ) ) ? true : false; // Is the current user an editor?
26
 
27
  $include_code = true;
28
+ if ( ( $post_author ) && ( empty( $track_users['authors'] ) ) ) {
29
+ $include_code = false;
30
+ }
31
+ if ( ( $current_user_admin ) && ( empty( $track_users['admins'] ) ) ) {
32
  $include_code = false;
33
  }
34
+ if ( ( $current_user_editor ) && ( empty( $track_users['editors'] ) ) ) {
35
  $include_code = false;
36
  }
37
+ if ( ( $current_user->exists() ) && ( ! tptn_get_option( 'logged_in' ) ) ) {
38
  $include_code = false;
39
  }
40
 
41
  if ( $include_code ) {
42
 
43
+ $id = absint( $post->ID );
44
+ $blog_id = get_current_blog_id();
45
+ $activate_counter = ! empty( $trackers['overall'] ) ? 1 : 0; // It's 1 if we're updating the overall count.
46
+ $activate_counter = $activate_counter + ( ! empty( $trackers['daily'] ) ? 10 : 0 ); // It's 10 if we're updating the daily count.
47
 
48
+ if ( 'query_based' === tptn_get_option( 'tracker_type' ) ) {
49
  $home_url = home_url( '/' );
50
  } else {
51
  $home_url = admin_url( 'admin-ajax.php' );
57
  * Other tracker types can override the URL processed by the jQuery.post request
58
  * The corresponding tracker can use the below variables or append their own to $ajax_tptn_tracker
59
  *
60
+ * @since 2.0
61
  */
62
  $home_url = apply_filters( 'tptn_add_counter_script_url', $home_url );
63
 
65
  $home_url = strtok( $home_url, '?' );
66
 
67
  $ajax_tptn_tracker = array(
68
+ 'ajax_url' => $home_url,
69
+ 'top_ten_id' => $id,
70
+ 'top_ten_blog_id' => $blog_id,
 
71
  'activate_counter' => $activate_counter,
72
+ 'tptn_rnd' => wp_rand( 1, time() ),
73
  );
74
 
75
  /**
93
  /**
94
  * Function to add additional queries to query_vars.
95
  *
96
+ * @since 2.0.0
97
  *
98
+ * @param array $vars Query variables array.
99
+ * @return array $Query variables array with Top 10 parameters appended
100
  */
101
  function tptn_query_vars( $vars ) {
102
  // Add these to the list of queryvars that WP gathers.
113
  /**
114
  * Parses the WordPress object to update/display the count.
115
  *
116
+ * @since 2.0.0
117
  *
118
+ * @param object $wp WordPress object.
119
  */
120
  function tptn_parse_request( $wp ) {
121
  global $wpdb;
128
  return;
129
  }
130
 
131
+ $table_name = $wpdb->base_prefix . 'top_ten';
132
  $top_ten_daily = $wpdb->base_prefix . 'top_ten_daily';
133
+ $str = '';
134
 
135
+ if ( array_key_exists( 'top_ten_id', $wp->query_vars ) && array_key_exists( 'activate_counter', $wp->query_vars ) && '' !== $wp->query_vars['top_ten_id'] ) {
136
 
137
+ $id = absint( $wp->query_vars['top_ten_id'] );
138
+ $blog_id = absint( $wp->query_vars['top_ten_blog_id'] );
139
  $activate_counter = absint( $wp->query_vars['activate_counter'] );
140
 
141
  if ( $id > 0 ) {
142
 
143
  if ( ( 1 === $activate_counter ) || ( 11 === $activate_counter ) ) {
144
 
145
+ $tt = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES( %d, '1', %d ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
146
 
147
  $str .= ( false === $tt ) ? 'tte' : 'tt' . $tt;
148
  }
151
 
152
  $current_date = gmdate( 'Y-m-d H', current_time( 'timestamp', 0 ) );
153
 
154
+ $ttd = $wpdb->query( $wpdb->prepare( "INSERT INTO {$top_ten_daily} (postnumber, cntaccess, dp_date, blog_id) VALUES( %d, '1', %s, %d ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $current_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
155
 
156
  $str .= ( false === $ttd ) ? ' ttde' : ' ttd' . $ttd;
157
  }
199
 
200
  global $wpdb;
201
 
202
+ $table_name = $wpdb->base_prefix . 'top_ten';
 
 
 
 
 
203
  $top_ten_daily = $wpdb->base_prefix . 'top_ten_daily';
204
+ $str = '';
205
 
206
+ $id = isset( $_POST['top_ten_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_id'] ) ) ) : 0; // Input var okay.
207
+ $blog_id = isset( $_POST['top_ten_blog_id'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['top_ten_blog_id'] ) ) ) : 0; // Input var okay.
208
  $activate_counter = isset( $_POST['activate_counter'] ) ? absint( sanitize_text_field( wp_unslash( $_POST['activate_counter'] ) ) ) : 0; // Input var okay.
209
 
210
  if ( $id > 0 ) {
211
 
212
  if ( ( 1 === $activate_counter ) || ( 11 === $activate_counter ) ) {
213
 
214
+ $tt = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (postnumber, cntaccess, blog_id) VALUES( %d, '1', %d ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
215
 
216
  $str .= ( false === $tt ) ? 'tte' : 'tt' . $tt;
217
  }
220
 
221
  $current_date = gmdate( 'Y-m-d H', current_time( 'timestamp', 0 ) );
222
 
223
+ $ttd = $wpdb->query( $wpdb->prepare( "INSERT INTO {$top_ten_daily} (postnumber, cntaccess, dp_date, blog_id) VALUES( %d, '1', %s, %d ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ", $id, $current_date, $blog_id ) ); // DB call ok; no-cache ok; WPCS: unprepared SQL OK.
224
 
225
  $str .= ( false === $ttd ) ? ' ttde' : ' ttd' . $ttd;
226
  }
244
 
245
  $trackers = array(
246
  array(
247
+ 'id' => 'query_based',
248
+ 'name' => __( 'Query variable based', 'top-10' ),
249
  'description' => __( 'Uses query variables to record visits', 'top-10' ),
250
  ),
251
  array(
252
+ 'id' => 'ajaxurl',
253
+ 'name' => __( 'Ajaxurl based', 'top-10' ),
254
  'description' => __( 'Uses admin-ajax.php which is inbuilt within WordPress to process the tracker', 'top-10' ),
255
  ),
256
  );
languages/top-10-en_US.mo CHANGED
Binary file
languages/top-10-en_US.po CHANGED
@@ -2,297 +2,1307 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Top 10\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2016-09-22 16:25+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
8
- "Language-Team: Ajay DSouza <me@ajaydsouza.com>\n"
9
  "Language: en_US\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Poedit-KeywordsList: __;_e;_c;__ngettext\n"
 
14
  "X-Poedit-Basepath: ..\n"
15
- "X-Generator: Poedit 1.8.9\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
  "X-Poedit-SearchPath-0: .\n"
19
- "X-Poedit-SearchPathExcluded-0: ../admin/wick\n"
20
 
21
- #: admin/admin-columns.php:30
22
  msgid "Total Views"
23
  msgstr ""
24
 
25
- #: admin/admin-columns.php:33
26
  msgid "Today's Views"
27
  msgstr ""
28
 
29
- #: admin/admin-columns.php:36
30
  msgid "Views"
31
  msgstr ""
32
 
33
- #: admin/admin-dashboard.php:64
34
  msgid "View all daily popular posts"
35
  msgstr ""
36
 
37
- #: admin/admin-dashboard.php:66
38
  msgid "View all popular posts"
39
  msgstr ""
40
 
41
- #: admin/admin-dashboard.php:72
42
  #, php-format
43
  msgid "Popular posts by <a href=\"%s\" target=\"_blank\">Top 10 plugin</a>"
44
  msgstr ""
45
 
46
- #: admin/admin-dashboard.php:122 admin/class-stats.php:539
 
47
  msgid "Popular Posts"
48
  msgstr ""
49
 
50
- #: admin/admin-dashboard.php:127 admin/admin.php:461
51
  msgid "Daily Popular Posts"
52
  msgstr ""
53
 
54
- #: admin/admin-metabox.php:137
55
- #, php-format
 
 
 
56
  msgid ""
57
- "You have %1$s installed. If you are trying to modify the thumbnail, then you "
58
- "will need to make the same change in the %1$s meta box on this page."
59
  msgstr ""
60
 
61
- #: admin/admin.php:199
62
- msgid "Options saved successfully. If enabled, the cache has been cleared."
63
  msgstr ""
64
 
65
- #: admin/admin.php:202
66
  msgid ""
67
- "Left Thumbnails style selected. Post thumbnail location set to Inline before "
68
- "text."
69
  msgstr ""
70
 
71
- #: admin/admin.php:205
72
- msgid "Text Only style selected. Thumbnails will not be displayed."
73
  msgstr ""
74
 
75
- #: admin/admin.php:208
76
- #, php-format
77
- msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %1$d."
 
78
  msgstr ""
79
 
80
- #: admin/admin.php:223
81
- msgid "Options set to Default."
82
  msgstr ""
83
 
84
- #: admin/admin.php:230
85
- msgid "Top 10 popular posts reset"
 
 
 
86
  msgstr ""
87
 
88
- #: admin/admin.php:237
89
- msgid "Top 10 daily popular posts reset"
90
  msgstr ""
91
 
92
- #: admin/admin.php:245
93
- msgid "Duplicate rows cleaned from tables"
 
 
 
94
  msgstr ""
95
 
96
- #: admin/admin.php:253
97
- msgid "Post counts across blog IDs 0 and 1 have been merged"
 
98
  msgstr ""
99
 
100
- #: admin/admin.php:266
101
- msgid "Scheduled maintenance enabled / modified"
102
  msgstr ""
103
 
104
- #: admin/admin.php:270
105
- msgid "Scheduled maintenance disabled"
106
  msgstr ""
107
 
108
- #: admin/admin.php:308
109
- msgid "Counts from selected sites have been imported."
110
  msgstr ""
111
 
112
- #: admin/admin.php:333
113
- msgid ""
114
- "Selected tables have been deleted. Note that only imported tables have been "
115
- "deleted."
116
  msgstr ""
117
 
118
- #: admin/admin.php:449 admin/admin.php:452
119
- msgid "Top 10 Settings"
120
  msgstr ""
121
 
122
- #: admin/admin.php:449
123
- msgid "Top 10"
124
  msgstr ""
125
 
126
- #: admin/admin.php:457
127
- msgid "View Popular Posts"
128
  msgstr ""
129
 
130
- #: admin/admin.php:564
131
- msgid "Settings"
 
 
 
 
132
  msgstr ""
133
 
134
- #: admin/admin.php:586
135
  msgid "Support"
136
  msgstr ""
137
 
138
- #: admin/admin.php:587
139
  msgid "Donate"
140
  msgstr ""
141
 
142
- #: admin/admin.php:588
143
  msgid "Contribute"
144
  msgstr ""
145
 
146
- #: admin/cache.php:19
147
  msgid "Top 10 cache has been cleared"
148
  msgstr ""
149
 
150
- #: admin/class-stats.php:35
151
  msgid "popular_post"
152
  msgstr ""
153
 
154
- #: admin/class-stats.php:36
155
  msgid "popular_posts"
156
  msgstr ""
157
 
158
- #: admin/class-stats.php:243
 
 
 
 
159
  msgid "View"
160
  msgstr ""
161
 
162
- #: admin/class-stats.php:244
163
  msgid "Edit"
164
  msgstr ""
165
 
166
- #: admin/class-stats.php:245
167
  msgid "Delete"
168
  msgstr ""
169
 
170
- #: admin/class-stats.php:267
171
  msgid "Y/m/d g:i:s a"
172
  msgstr ""
173
 
174
- #: admin/class-stats.php:274
175
  #, php-format
176
  msgid "%s ago"
177
  msgstr ""
178
 
179
- #: admin/class-stats.php:276
180
  msgid "Y/m/d"
181
  msgstr ""
182
 
183
- #: admin/class-stats.php:309
 
 
184
  msgid "Title"
185
  msgstr ""
186
 
187
- #: admin/class-stats.php:310
188
  msgid "Total visits"
189
  msgstr ""
190
 
191
- #: admin/class-stats.php:311
192
  msgid "Daily visits"
193
  msgstr ""
194
 
195
- #: admin/class-stats.php:312
196
  msgid "Post type"
197
  msgstr ""
198
 
199
- #: admin/class-stats.php:313
200
  msgid "Author"
201
  msgstr ""
202
 
203
- #: admin/class-stats.php:314
204
  msgid "Date"
205
  msgstr ""
206
 
207
- #: admin/class-stats.php:348
208
  msgid "Delete Count"
209
  msgstr ""
210
 
211
- #: admin/class-stats.php:441
 
 
 
 
212
  msgid "Filter"
213
  msgstr ""
214
 
215
- #: admin/class-stats.php:514
216
  msgid "Search Table"
217
  msgstr ""
218
 
219
- #: includes/cron.php:74
220
- msgid "Once Weekly"
 
 
 
221
  msgstr ""
222
 
223
- #: includes/cron.php:78
224
- msgid "Once Fortnightly"
 
 
 
225
  msgstr ""
226
 
227
- #: includes/cron.php:82
228
- msgid "Once Monthly"
 
 
 
229
  msgstr ""
230
 
231
- #: includes/cron.php:86
232
- msgid "Once quarterly"
 
233
  msgstr ""
234
 
235
- #: includes/modules/class-top-10-widget.php:30
236
- msgid "Popular Posts [Top 10]"
237
  msgstr ""
238
 
239
- #: includes/modules/class-top-10-widget.php:32
240
- msgid "Display popular posts"
 
 
241
  msgstr ""
242
 
243
- #: includes/public/display-posts.php:92
 
 
 
 
244
  msgid ""
245
- "posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the "
246
- "posts only."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  msgstr ""
248
 
249
- #: includes/public/display-posts.php:229
 
 
 
 
 
 
 
 
 
 
 
250
  #, php-format
251
  msgid ""
252
- "Popular posts by <a href=\"%1$s\" rel=\"nofollow\" %2$s>Top 10 plugin</a>"
 
253
  msgstr ""
254
 
255
- #: includes/public/media.php:60
256
- msgid "thumb_timthumb argument has been deprecated"
257
  msgstr ""
258
 
259
- #: includes/public/media.php:64
260
- msgid "thumb_timthumb_q argument has been deprecated"
261
  msgstr ""
262
 
263
- #: includes/public/media.php:68
264
- msgid "filter argument has been deprecated"
265
  msgstr ""
266
 
267
- #: includes/public/output-generator.php:238
268
- msgid " by "
269
  msgstr ""
270
 
271
- #: includes/tracker.php:248
272
- msgid "Query variable based"
273
  msgstr ""
274
 
275
- #: includes/tracker.php:249
276
- msgid "Uses query variables to record visits"
277
  msgstr ""
278
 
279
- #: includes/tracker.php:253
280
- msgid "Ajaxurl based"
281
  msgstr ""
282
 
283
- #: includes/tracker.php:254
 
 
 
 
 
284
  msgid ""
285
- "Uses admin-ajax.php which is inbuilt within WordPress to process the tracker"
 
286
  msgstr ""
287
 
288
- #: top-10.php:94
289
- msgid "<h3>Popular Posts</h3>"
290
  msgstr ""
291
 
292
- #: top-10.php:95
293
- msgid "<h3>Daily Popular</h3>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  msgstr ""
295
 
296
- #: top-10.php:96
297
  msgid "No top posts yet"
298
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  msgstr ""
3
  "Project-Id-Version: Top 10\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2017-11-18 11:05+0000\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
8
+ "Language-Team: WebberZone <plugins@webberzone.com>\n"
9
  "Language: en_US\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e;_c;__ngettext;esc_html__;esc_attr__;esc_html_e;"
14
+ "esc_attr_e\n"
15
  "X-Poedit-Basepath: ..\n"
16
+ "X-Generator: Poedit 2.0.4\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "X-Poedit-SearchPath-0: .\n"
 
20
 
21
+ #: includes/admin/admin-columns.php:29
22
  msgid "Total Views"
23
  msgstr ""
24
 
25
+ #: includes/admin/admin-columns.php:30
26
  msgid "Today's Views"
27
  msgstr ""
28
 
29
+ #: includes/admin/admin-columns.php:31
30
  msgid "Views"
31
  msgstr ""
32
 
33
+ #: includes/admin/admin-dashboard.php:68
34
  msgid "View all daily popular posts"
35
  msgstr ""
36
 
37
+ #: includes/admin/admin-dashboard.php:70
38
  msgid "View all popular posts"
39
  msgstr ""
40
 
41
+ #: includes/admin/admin-dashboard.php:78
42
  #, php-format
43
  msgid "Popular posts by <a href=\"%s\" target=\"_blank\">Top 10 plugin</a>"
44
  msgstr ""
45
 
46
+ #: includes/admin/admin-dashboard.php:127 includes/admin/admin.php:44
47
+ #: includes/admin/class-top-ten-statistics-table.php:574
48
  msgid "Popular Posts"
49
  msgstr ""
50
 
51
+ #: includes/admin/admin-dashboard.php:132 includes/admin/admin.php:48
52
  msgid "Daily Popular Posts"
53
  msgstr ""
54
 
55
+ #: includes/admin/admin-metabox.php:109
56
+ msgid "Visit count:"
57
+ msgstr ""
58
+
59
+ #: includes/admin/admin-metabox.php:111
60
  msgid ""
61
+ "Enter a number above to update the visit count. Leaving the above box blank "
62
+ "will set the count to zero"
63
  msgstr ""
64
 
65
+ #: includes/admin/admin-metabox.php:120
66
+ msgid "Disable Popular Posts display:"
67
  msgstr ""
68
 
69
+ #: includes/admin/admin-metabox.php:123
70
  msgid ""
71
+ "If this is checked, then Top 10 will not display the popular posts widgets "
72
+ "when viewing this post."
73
  msgstr ""
74
 
75
+ #: includes/admin/admin-metabox.php:127
76
+ msgid "Exclude this post from the popular posts list:"
77
  msgstr ""
78
 
79
+ #: includes/admin/admin-metabox.php:130
80
+ msgid ""
81
+ "If this is checked, then this post will be excluded from the popular posts "
82
+ "list."
83
  msgstr ""
84
 
85
+ #: includes/admin/admin-metabox.php:134
86
+ msgid "Location of thumbnail:"
87
  msgstr ""
88
 
89
+ #: includes/admin/admin-metabox.php:136
90
+ msgid ""
91
+ "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
92
+ "image will be used for the post. It will be resized to the thumbnail size "
93
+ "set under Top 10 Settings &raquo; Thumbnail options."
94
  msgstr ""
95
 
96
+ #: includes/admin/admin-metabox.php:137
97
+ msgid "The URL above is saved in the meta field:"
98
  msgstr ""
99
 
100
+ #: includes/admin/admin-metabox.php:145
101
+ #, php-format
102
+ msgid ""
103
+ "You have %1$s installed. If you are trying to modify the thumbnail, then you "
104
+ "will need to make the same change in the %1$s meta box on this page."
105
  msgstr ""
106
 
107
+ #: includes/admin/admin.php:30 includes/admin/admin.php:34
108
+ #: includes/admin/settings-page.php:32
109
+ msgid "Top 10 Settings"
110
  msgstr ""
111
 
112
+ #: includes/admin/admin.php:30
113
+ msgid "Top 10"
114
  msgstr ""
115
 
116
+ #: includes/admin/admin.php:34 includes/admin/admin.php:317
117
+ msgid "Settings"
118
  msgstr ""
119
 
120
+ #: includes/admin/admin.php:37 includes/admin/tools.php:56
121
+ msgid "Top 10 Tools"
122
  msgstr ""
123
 
124
+ #: includes/admin/admin.php:37
125
+ msgid "Tools"
 
 
126
  msgstr ""
127
 
128
+ #: includes/admin/admin.php:44
129
+ msgid "Top 10 Popular Posts"
130
  msgstr ""
131
 
132
+ #: includes/admin/admin.php:48
133
+ msgid "Top 10 Daily Popular Posts"
134
  msgstr ""
135
 
136
+ #: includes/admin/admin.php:188
137
+ msgid "New information not saved. Do you wish to leave the page?"
138
  msgstr ""
139
 
140
+ #: includes/admin/admin.php:271
141
+ #, php-format
142
+ msgid ""
143
+ "Thank you for using <a href=\"%1$s\" target=\"_blank\">Top 10</a>! Please <a "
144
+ "href=\"%2$s\" target=\"_blank\">rate us</a> on <a href=\"%2$s\" target="
145
+ "\"_blank\">WordPress.org</a>"
146
  msgstr ""
147
 
148
+ #: includes/admin/admin.php:339 includes/admin/sidebar.php:55
149
  msgid "Support"
150
  msgstr ""
151
 
152
+ #: includes/admin/admin.php:340
153
  msgid "Donate"
154
  msgstr ""
155
 
156
+ #: includes/admin/admin.php:341
157
  msgid "Contribute"
158
  msgstr ""
159
 
160
+ #: includes/admin/cache.php:21
161
  msgid "Top 10 cache has been cleared"
162
  msgstr ""
163
 
164
+ #: includes/admin/class-top-ten-statistics-table.php:36
165
  msgid "popular_post"
166
  msgstr ""
167
 
168
+ #: includes/admin/class-top-ten-statistics-table.php:37
169
  msgid "popular_posts"
170
  msgstr ""
171
 
172
+ #: includes/admin/class-top-ten-statistics-table.php:208
173
+ msgid "No popular posts available."
174
+ msgstr ""
175
+
176
+ #: includes/admin/class-top-ten-statistics-table.php:257
177
  msgid "View"
178
  msgstr ""
179
 
180
+ #: includes/admin/class-top-ten-statistics-table.php:258
181
  msgid "Edit"
182
  msgstr ""
183
 
184
+ #: includes/admin/class-top-ten-statistics-table.php:259
185
  msgid "Delete"
186
  msgstr ""
187
 
188
+ #: includes/admin/class-top-ten-statistics-table.php:282
189
  msgid "Y/m/d g:i:s a"
190
  msgstr ""
191
 
192
+ #: includes/admin/class-top-ten-statistics-table.php:290
193
  #, php-format
194
  msgid "%s ago"
195
  msgstr ""
196
 
197
+ #: includes/admin/class-top-ten-statistics-table.php:292
198
  msgid "Y/m/d"
199
  msgstr ""
200
 
201
+ #: includes/admin/class-top-ten-statistics-table.php:330
202
+ #: includes/modules/class-top-ten-count-widget.php:53
203
+ #: includes/modules/class-top-ten-widget.php:80
204
  msgid "Title"
205
  msgstr ""
206
 
207
+ #: includes/admin/class-top-ten-statistics-table.php:331
208
  msgid "Total visits"
209
  msgstr ""
210
 
211
+ #: includes/admin/class-top-ten-statistics-table.php:332
212
  msgid "Daily visits"
213
  msgstr ""
214
 
215
+ #: includes/admin/class-top-ten-statistics-table.php:333
216
  msgid "Post type"
217
  msgstr ""
218
 
219
+ #: includes/admin/class-top-ten-statistics-table.php:334
220
  msgid "Author"
221
  msgstr ""
222
 
223
+ #: includes/admin/class-top-ten-statistics-table.php:335
224
  msgid "Date"
225
  msgstr ""
226
 
227
+ #: includes/admin/class-top-ten-statistics-table.php:369
228
  msgid "Delete Count"
229
  msgstr ""
230
 
231
+ #: includes/admin/class-top-ten-statistics-table.php:413
232
+ msgid "Are you sure you want to do this"
233
+ msgstr ""
234
+
235
+ #: includes/admin/class-top-ten-statistics-table.php:469
236
  msgid "Filter"
237
  msgstr ""
238
 
239
+ #: includes/admin/class-top-ten-statistics-table.php:549
240
  msgid "Search Table"
241
  msgstr ""
242
 
243
+ #: includes/admin/help-tab.php:35 includes/admin/help-tab.php:126
244
+ #, php-format
245
+ msgid ""
246
+ "For more information or how to get support visit the <a href=\"%1$s"
247
+ "\">WebberZone support site</a>."
248
  msgstr ""
249
 
250
+ #: includes/admin/help-tab.php:37 includes/admin/help-tab.php:128
251
+ #, php-format
252
+ msgid ""
253
+ "Support queries should be posted in the <a href=\"%1$s\">WordPress.org "
254
+ "support forums</a>."
255
  msgstr ""
256
 
257
+ #: includes/admin/help-tab.php:40 includes/admin/help-tab.php:131
258
+ #, php-format
259
+ msgid ""
260
+ "<a href=\"%1$s\">Post an issue</a> on <a href=\"%2$s\">GitHub</a> (bug "
261
+ "reports only)."
262
  msgstr ""
263
 
264
+ #: includes/admin/help-tab.php:49 includes/admin/help-tab.php:140
265
+ #: includes/admin/settings-page.php:125
266
+ msgid "General"
267
  msgstr ""
268
 
269
+ #: includes/admin/help-tab.php:51
270
+ msgid "This screen provides the basic settings for configuring Top 10."
271
  msgstr ""
272
 
273
+ #: includes/admin/help-tab.php:52
274
+ msgid ""
275
+ "Enable the trackers and cache, configure basic tracker settings and "
276
+ "uninstall settings."
277
  msgstr ""
278
 
279
+ #: includes/admin/help-tab.php:59 includes/admin/settings-page.php:126
280
+ msgid "Counter/Tracker"
281
+ msgstr ""
282
+
283
+ #: includes/admin/help-tab.php:61
284
  msgid ""
285
+ "This screen provides settings to tweak the display counter and the tracker."
286
+ msgstr ""
287
+
288
+ #: includes/admin/help-tab.php:62
289
+ msgid ""
290
+ "Choose where to display the counter and customize the text. Select the type "
291
+ "of tracker and which user groups to track."
292
+ msgstr ""
293
+
294
+ #: includes/admin/help-tab.php:69 includes/admin/settings-page.php:127
295
+ msgid "Posts list"
296
+ msgstr ""
297
+
298
+ #: includes/admin/help-tab.php:71
299
+ msgid ""
300
+ "This screen provides settings to tweak the output of the list of popular "
301
+ "posts."
302
+ msgstr ""
303
+
304
+ #: includes/admin/help-tab.php:72
305
+ msgid ""
306
+ "Set the number of posts, which categories or posts to exclude, customize "
307
+ "what to display and specific basic HTML markup used to create the posts."
308
+ msgstr ""
309
+
310
+ #: includes/admin/help-tab.php:79 includes/admin/settings-page.php:128
311
+ msgid "Thumbnail"
312
+ msgstr ""
313
+
314
+ #: includes/admin/help-tab.php:81
315
+ msgid ""
316
+ "This screen provides settings to tweak the thumbnail that can be displayed "
317
+ "for each post in the list."
318
+ msgstr ""
319
+
320
+ #: includes/admin/help-tab.php:82
321
+ msgid ""
322
+ "Set the location and size of the thumbnail. Additionally, you can choose "
323
+ "additional sources for the thumbnail i.e. a meta field, first image or a "
324
+ "default thumbnail when nothing is available."
325
+ msgstr ""
326
+
327
+ #: includes/admin/help-tab.php:89 includes/admin/settings-page.php:129
328
+ msgid "Styles"
329
+ msgstr ""
330
+
331
+ #: includes/admin/help-tab.php:91
332
+ msgid ""
333
+ "This screen provides options to control the look and feel of the popular "
334
+ "posts list."
335
+ msgstr ""
336
+
337
+ #: includes/admin/help-tab.php:92
338
+ msgid ""
339
+ "Choose for default set of styles or add your own custom CSS to tweak the "
340
+ "display of the posts."
341
+ msgstr ""
342
+
343
+ #: includes/admin/help-tab.php:99 includes/admin/settings-page.php:130
344
+ msgid "Maintenance"
345
+ msgstr ""
346
+
347
+ #: includes/admin/help-tab.php:101
348
+ msgid "This screen provides options to control the maintenance cron."
349
+ msgstr ""
350
+
351
+ #: includes/admin/help-tab.php:102
352
+ msgid "Choose how often to run maintenance and at what time of the day."
353
+ msgstr ""
354
+
355
+ #: includes/admin/help-tab.php:142
356
+ msgid ""
357
+ "This screen provides some tools that help maintain certain features of Top "
358
+ "10."
359
+ msgstr ""
360
+
361
+ #: includes/admin/help-tab.php:143
362
+ msgid ""
363
+ "Clear the cache, reset the popular posts tables plus some miscellaneous "
364
+ "fixes for older versions of Top 10."
365
+ msgstr ""
366
+
367
+ #: includes/admin/register-settings.php:228
368
+ msgid "Enable trackers"
369
+ msgstr ""
370
+
371
+ #: includes/admin/register-settings.php:237
372
+ #: includes/modules/class-top-ten-widget.php:95
373
+ msgid "Overall"
374
+ msgstr ""
375
+
376
+ #: includes/admin/register-settings.php:238
377
+ #: includes/admin/register-settings.php:767
378
+ msgid "Daily"
379
+ msgstr ""
380
+
381
+ #: includes/admin/register-settings.php:243
382
+ msgid "Enable cache"
383
+ msgstr ""
384
+
385
+ #: includes/admin/register-settings.php:244
386
+ msgid ""
387
+ "If activated, Top 10 will use the Transients API to cache the popular posts "
388
+ "output for 1 hour."
389
+ msgstr ""
390
+
391
+ #: includes/admin/register-settings.php:250
392
+ msgid "Time to cache"
393
+ msgstr ""
394
+
395
+ #: includes/admin/register-settings.php:251
396
+ msgid "Enter the number of seconds to cache the output."
397
+ msgstr ""
398
+
399
+ #: includes/admin/register-settings.php:257
400
+ msgid "Start daily counts from midnight"
401
+ msgstr ""
402
+
403
+ #: includes/admin/register-settings.php:258
404
+ msgid ""
405
+ "Daily counter will display number of visits from midnight. This option is "
406
+ "checked by default and mimics the way most normal counters work. Turning "
407
+ "this off will allow you to use the hourly setting in the next option."
408
+ msgstr ""
409
+
410
+ #: includes/admin/register-settings.php:264
411
+ msgid "Default custom period range"
412
+ msgstr ""
413
+
414
+ #: includes/admin/register-settings.php:265
415
+ msgid ""
416
+ "The next two options allow you to set the default range for the custom "
417
+ "period. This was previously called the daily range. This can be overridden "
418
+ "in the widget."
419
+ msgstr ""
420
+
421
+ #: includes/admin/register-settings.php:270
422
+ msgid "Day(s)"
423
+ msgstr ""
424
+
425
+ #: includes/admin/register-settings.php:279
426
+ msgid "Hour(s)"
427
+ msgstr ""
428
+
429
+ #: includes/admin/register-settings.php:289
430
+ msgid "Delete options on uninstall"
431
+ msgstr ""
432
+
433
+ #: includes/admin/register-settings.php:290
434
+ msgid ""
435
+ "If this is checked, all settings related to Top 10 are removed from the "
436
+ "database if you choose to uninstall/delete the plugin."
437
+ msgstr ""
438
+
439
+ #: includes/admin/register-settings.php:296
440
+ msgid "Delete counter data on uninstall"
441
+ msgstr ""
442
+
443
+ #: includes/admin/register-settings.php:297
444
+ msgid ""
445
+ "If this is checked, the tables containing the counter statistics are removed "
446
+ "from the database if you choose to uninstall/delete the plugin. Keep this "
447
+ "unchecked if you choose to reinstall the plugin and do not want to lose your "
448
+ "counter data."
449
+ msgstr ""
450
+
451
+ #: includes/admin/register-settings.php:303
452
+ msgid "Show metabox"
453
+ msgstr ""
454
+
455
+ #: includes/admin/register-settings.php:304
456
+ msgid ""
457
+ "This will add the Top 10 metabox on Edit Posts or Add New Posts screens. "
458
+ "Also applies to Pages and Custom Post Types."
459
+ msgstr ""
460
+
461
+ #: includes/admin/register-settings.php:310
462
+ msgid "Limit meta box to Admins only"
463
+ msgstr ""
464
+
465
+ #: includes/admin/register-settings.php:311
466
+ msgid ""
467
+ "If selected, the meta box will be hidden from anyone who is not an Admin. By "
468
+ "default, Contributors and above will be able to see the meta box. Applies "
469
+ "only if the above option is selected."
470
+ msgstr ""
471
+
472
+ #: includes/admin/register-settings.php:317
473
+ msgid "Link to Top 10 plugin page"
474
  msgstr ""
475
 
476
+ #: includes/admin/register-settings.php:318
477
+ msgid ""
478
+ "A no-follow link to the plugin homepage will be added as the last item of "
479
+ "the popular posts."
480
+ msgstr ""
481
+
482
+ #: includes/admin/register-settings.php:329
483
+ msgid "Display number of views on"
484
+ msgstr ""
485
+
486
+ #: includes/admin/register-settings.php:331
487
+ #: includes/admin/register-settings.php:494
488
  #, php-format
489
  msgid ""
490
+ "If you choose to disable this, please add %1$s to your template file where "
491
+ "you want it displayed"
492
  msgstr ""
493
 
494
+ #: includes/admin/register-settings.php:338
495
+ msgid "Posts"
496
  msgstr ""
497
 
498
+ #: includes/admin/register-settings.php:339
499
+ msgid "Pages"
500
  msgstr ""
501
 
502
+ #: includes/admin/register-settings.php:340
503
+ msgid "Home page"
504
  msgstr ""
505
 
506
+ #: includes/admin/register-settings.php:341
507
+ msgid "Feeds"
508
  msgstr ""
509
 
510
+ #: includes/admin/register-settings.php:342
511
+ msgid "Category archives"
512
  msgstr ""
513
 
514
+ #: includes/admin/register-settings.php:343
515
+ msgid "Tag archives"
516
  msgstr ""
517
 
518
+ #: includes/admin/register-settings.php:344
519
+ msgid "Other archives"
520
  msgstr ""
521
 
522
+ #: includes/admin/register-settings.php:349
523
+ msgid "Format to display the post views"
524
+ msgstr ""
525
+
526
+ #: includes/admin/register-settings.php:351
527
+ #, php-format
528
  msgid ""
529
+ "Use %1$s to display the total count, %2$s for daily count and %3$s for "
530
+ "overall counts across all posts. Default display is %4$s"
531
  msgstr ""
532
 
533
+ #: includes/admin/register-settings.php:357
534
+ msgid "What do display when there are no visits?"
535
  msgstr ""
536
 
537
+ #: includes/admin/register-settings.php:359
538
+ msgid ""
539
+ "This text applies only when there are 0 hits for the post and it isn't a "
540
+ "single page. e.g. if you display post views on the homepage or archives then "
541
+ "this text will be used. To override this, just enter the same text as above "
542
+ "option."
543
+ msgstr ""
544
+
545
+ #: includes/admin/register-settings.php:365
546
+ msgid "Always display latest post count"
547
+ msgstr ""
548
+
549
+ #: includes/admin/register-settings.php:366
550
+ msgid ""
551
+ "This option uses JavaScript and will increase your page load time. Turn this "
552
+ "off if you are not using caching plugins or are OK with displaying older "
553
+ "cached counts."
554
+ msgstr ""
555
+
556
+ #: includes/admin/register-settings.php:372
557
+ msgid "Tracker type"
558
+ msgstr ""
559
+
560
+ #: includes/admin/register-settings.php:380
561
+ msgid "Track user groups"
562
+ msgstr ""
563
+
564
+ #: includes/admin/register-settings.php:381
565
+ msgid ""
566
+ "Uncheck above to disable tracking if the current user falls into any one of "
567
+ "these groups."
568
+ msgstr ""
569
+
570
+ #: includes/admin/register-settings.php:388
571
+ msgid "Authors"
572
+ msgstr ""
573
+
574
+ #: includes/admin/register-settings.php:389
575
+ msgid "Editors"
576
+ msgstr ""
577
+
578
+ #: includes/admin/register-settings.php:390
579
+ msgid "Admins"
580
+ msgstr ""
581
+
582
+ #: includes/admin/register-settings.php:395
583
+ msgid "Track logged-in users"
584
+ msgstr ""
585
+
586
+ #: includes/admin/register-settings.php:396
587
+ msgid ""
588
+ "Uncheck to stop tracking logged in users. Only logged out visitors will be "
589
+ "tracked if this is disabled. Unchecking this will override the above setting."
590
+ msgstr ""
591
+
592
+ #: includes/admin/register-settings.php:402
593
+ msgid "Page views in admin"
594
+ msgstr ""
595
+
596
+ #: includes/admin/register-settings.php:403
597
+ msgid ""
598
+ "Adds three columns called Total Views, Today's Views and Views to All Posts "
599
+ "and All Pages. You can selectively disable these by pulling down the Screen "
600
+ "Options from the top right of the respective screens."
601
+ msgstr ""
602
+
603
+ #: includes/admin/register-settings.php:409
604
+ msgid "Show views to non-admins"
605
+ msgstr ""
606
+
607
+ #: includes/admin/register-settings.php:410
608
+ msgid ""
609
+ "If you disable this then non-admins won't see the above columns or view the "
610
+ "independent pages with the top posts."
611
+ msgstr ""
612
+
613
+ #: includes/admin/register-settings.php:421
614
+ msgid "Number of posts to display"
615
+ msgstr ""
616
+
617
+ #: includes/admin/register-settings.php:422
618
+ msgid ""
619
+ "Maximum number of posts that will be displayed in the list. This option is "
620
+ "used if you don not specify the number of posts in the widget or shortcodes"
621
+ msgstr ""
622
+
623
+ #: includes/admin/register-settings.php:429
624
+ msgid "Published age of posts"
625
+ msgstr ""
626
+
627
+ #: includes/admin/register-settings.php:430
628
+ msgid ""
629
+ "This options allows you to only show posts that have been published within "
630
+ "the above day range. Applies to both overall posts and daily posts lists. e."
631
+ "g. 365 days will only show posts published in the last year in the popular "
632
+ "posts lists. Enter 0 for no restriction."
633
+ msgstr ""
634
+
635
+ #: includes/admin/register-settings.php:436
636
+ msgid "Post types to include"
637
+ msgstr ""
638
+
639
+ #: includes/admin/register-settings.php:437
640
+ msgid ""
641
+ "Select which post types you want to include in the list of posts. This field "
642
+ "can be overridden using a comma separated list of post types when using the "
643
+ "manual display."
644
+ msgstr ""
645
+
646
+ #: includes/admin/register-settings.php:443
647
+ msgid "Post/page IDs to exclude"
648
+ msgstr ""
649
+
650
+ #: includes/admin/register-settings.php:444
651
+ msgid ""
652
+ "Comma-separated list of post or page IDs to exclude from the list. e.g. "
653
+ "188,320,500"
654
+ msgstr ""
655
+
656
+ #: includes/admin/register-settings.php:450
657
+ msgid "Exclude Categories"
658
+ msgstr ""
659
+
660
+ #: includes/admin/register-settings.php:451
661
+ msgid ""
662
+ "Comma separated list of category slugs. The field above has an autocomplete "
663
+ "so simply start typing in the starting letters and it will prompt you with "
664
+ "options. Does not support custom taxonomies."
665
+ msgstr ""
666
+
667
+ #: includes/admin/register-settings.php:462
668
+ msgid "Exclude category IDs"
669
+ msgstr ""
670
+
671
+ #: includes/admin/register-settings.php:463
672
+ msgid ""
673
+ "This is a readonly field that is automatically populated based on the above "
674
+ "input when the settings are saved. These might differ from the IDs visible "
675
+ "in the Categories page which use the term_id. Top 10 uses the "
676
+ "term_taxonomy_id which is unique to this taxonomy."
677
+ msgstr ""
678
+
679
+ #: includes/admin/register-settings.php:470
680
+ msgid "Customize the output"
681
+ msgstr ""
682
+
683
+ #: includes/admin/register-settings.php:476
684
+ msgid "Heading of posts"
685
+ msgstr ""
686
+
687
+ #: includes/admin/register-settings.php:477
688
+ #: includes/admin/register-settings.php:485
689
+ msgid "Displayed before the list of the posts as a the master heading"
690
+ msgstr ""
691
+
692
+ #: includes/admin/register-settings.php:479
693
+ msgid "Popular posts:"
694
+ msgstr ""
695
+
696
+ #: includes/admin/register-settings.php:484
697
+ msgid "Heading of posts for daily/custom period lists"
698
+ msgstr ""
699
+
700
+ #: includes/admin/register-settings.php:487
701
+ msgid "Currently trending:"
702
+ msgstr ""
703
+
704
+ #: includes/admin/register-settings.php:492
705
+ msgid "Show when no posts are found"
706
+ msgstr ""
707
+
708
+ #: includes/admin/register-settings.php:498
709
+ msgid "Blank output"
710
+ msgstr ""
711
+
712
+ #: includes/admin/register-settings.php:499
713
+ msgid "Display custom text"
714
+ msgstr ""
715
+
716
+ #: includes/admin/register-settings.php:504
717
+ msgid "Custom text"
718
+ msgstr ""
719
+
720
+ #: includes/admin/register-settings.php:505
721
+ msgid ""
722
+ "Enter the custom text that will be displayed if the second option is "
723
+ "selected above"
724
  msgstr ""
725
 
726
+ #: includes/admin/register-settings.php:507 includes/deprecated.php:173
727
  msgid "No top posts yet"
728
  msgstr ""
729
+
730
+ #: includes/admin/register-settings.php:511
731
+ msgid "Show post excerpt"
732
+ msgstr ""
733
+
734
+ #: includes/admin/register-settings.php:518
735
+ msgid "Length of excerpt (in words)"
736
+ msgstr ""
737
+
738
+ #: includes/admin/register-settings.php:526
739
+ msgid "Show date"
740
+ msgstr ""
741
+
742
+ #: includes/admin/register-settings.php:533
743
+ msgid "Show author"
744
+ msgstr ""
745
+
746
+ #: includes/admin/register-settings.php:540
747
+ msgid "Show number of views"
748
+ msgstr ""
749
+
750
+ #: includes/admin/register-settings.php:547
751
+ msgid "Limit post title length (in characters)"
752
+ msgstr ""
753
+
754
+ #: includes/admin/register-settings.php:555
755
+ msgid "Open links in new window"
756
+ msgstr ""
757
+
758
+ #: includes/admin/register-settings.php:562
759
+ msgid "Add nofollow to links"
760
+ msgstr ""
761
+
762
+ #: includes/admin/register-settings.php:569
763
+ msgid "Exclude display on these post IDs"
764
+ msgstr ""
765
+
766
+ #: includes/admin/register-settings.php:570
767
+ msgid ""
768
+ "Comma-separated list of post or page IDs to exclude displaying the top posts "
769
+ "on. e.g. 188,320,500"
770
+ msgstr ""
771
+
772
+ #: includes/admin/register-settings.php:576
773
+ msgid "HTML to display"
774
+ msgstr ""
775
+
776
+ #: includes/admin/register-settings.php:582
777
+ msgid "Before the list of posts"
778
+ msgstr ""
779
+
780
+ #: includes/admin/register-settings.php:589
781
+ msgid "After the list of posts"
782
+ msgstr ""
783
+
784
+ #: includes/admin/register-settings.php:596
785
+ msgid "Before each list item"
786
+ msgstr ""
787
+
788
+ #: includes/admin/register-settings.php:603
789
+ msgid "After each list item"
790
+ msgstr ""
791
+
792
+ #: includes/admin/register-settings.php:615
793
+ msgid "Location of the post thumbnail"
794
+ msgstr ""
795
+
796
+ #: includes/admin/register-settings.php:620
797
+ msgid "Display thumbnails inline with posts, before title"
798
+ msgstr ""
799
+
800
+ #: includes/admin/register-settings.php:621
801
+ msgid "Display thumbnails inline with posts, after title"
802
+ msgstr ""
803
+
804
+ #: includes/admin/register-settings.php:622
805
+ msgid "Display only thumbnails, no text"
806
+ msgstr ""
807
+
808
+ #: includes/admin/register-settings.php:623
809
+ msgid "Do not display thumbnails, only text"
810
+ msgstr ""
811
+
812
+ #: includes/admin/register-settings.php:628
813
+ msgid "Thumbnail size"
814
+ msgstr ""
815
+
816
+ #: includes/admin/register-settings.php:630
817
+ msgid ""
818
+ "You can choose from existing image sizes above or create a custom size. If "
819
+ "you have chosen Custom size above, then enter the width, height and crop "
820
+ "settings below. For best results, use a cropped image. If you change the "
821
+ "width and/or height below, existing images will not be automatically resized."
822
+ msgstr ""
823
+
824
+ #: includes/admin/register-settings.php:630
825
+ #, php-format
826
+ msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
827
+ msgstr ""
828
+
829
+ #: includes/admin/register-settings.php:637
830
+ #: includes/modules/class-top-ten-widget.php:145
831
+ msgid "Thumbnail width"
832
+ msgstr ""
833
+
834
+ #: includes/admin/register-settings.php:645
835
+ #: includes/modules/class-top-ten-widget.php:139
836
+ msgid "Thumbnail height"
837
+ msgstr ""
838
+
839
+ #: includes/admin/register-settings.php:653
840
+ msgid "Hard crop thumbnails"
841
+ msgstr ""
842
+
843
+ #: includes/admin/register-settings.php:654
844
+ msgid ""
845
+ "Check this box to hard crop the thumbnails. i.e. force the width and height "
846
+ "above vs. maintaining proportions."
847
+ msgstr ""
848
+
849
+ #: includes/admin/register-settings.php:660
850
+ msgid "Thumbnail size attributes"
851
+ msgstr ""
852
+
853
+ #: includes/admin/register-settings.php:666
854
+ #, php-format
855
+ msgid "Use CSS to set the width and height: e.g. %s"
856
+ msgstr ""
857
+
858
+ #: includes/admin/register-settings.php:668
859
+ #, php-format
860
+ msgid "Use HTML attributes to set the width and height: e.g. %s"
861
+ msgstr ""
862
+
863
+ #: includes/admin/register-settings.php:669
864
+ msgid ""
865
+ "No width or height set. You will need to use external styles to force any "
866
+ "width or height of your choice."
867
+ msgstr ""
868
+
869
+ #: includes/admin/register-settings.php:674
870
+ msgid "Thumbnail meta field name"
871
+ msgstr ""
872
+
873
+ #: includes/admin/register-settings.php:675
874
+ msgid ""
875
+ "The value of this field should contain the URL of the image and can be set "
876
+ "in the metabox in the Edit Post screen"
877
+ msgstr ""
878
+
879
+ #: includes/admin/register-settings.php:681
880
+ msgid "Get first image"
881
+ msgstr ""
882
+
883
+ #: includes/admin/register-settings.php:682
884
+ msgid ""
885
+ "The plugin will fetch the first image in the post content if this is "
886
+ "enabled. This can slow down the loading of your page if the first image in "
887
+ "the followed posts is large in file-size."
888
+ msgstr ""
889
+
890
+ #: includes/admin/register-settings.php:688
891
+ msgid "Use default thumbnail?"
892
+ msgstr ""
893
+
894
+ #: includes/admin/register-settings.php:689
895
+ msgid ""
896
+ "If checked, when no thumbnail is found, show a default one from the URL "
897
+ "below. If not checked and no thumbnail is found, no image will be shown."
898
+ msgstr ""
899
+
900
+ #: includes/admin/register-settings.php:695
901
+ #: includes/admin/settings-page.php:669
902
+ msgid "Default thumbnail"
903
+ msgstr ""
904
+
905
+ #: includes/admin/register-settings.php:696
906
+ msgid ""
907
+ "Enter the full URL of the image that you wish to display if no thumbnail is "
908
+ "found. This image will be displayed below."
909
+ msgstr ""
910
+
911
+ #: includes/admin/register-settings.php:708
912
+ msgid "Popular posts style"
913
+ msgstr ""
914
+
915
+ #: includes/admin/register-settings.php:716
916
+ msgid "Custom CSS"
917
+ msgstr ""
918
+
919
+ #: includes/admin/register-settings.php:718
920
+ #, php-format
921
+ msgid ""
922
+ "Do not include %3$sstyle%4$s tags. Check out the %1$sFAQ%2$s for available "
923
+ "CSS classes to style."
924
+ msgstr ""
925
+
926
+ #: includes/admin/register-settings.php:729
927
+ msgid "Enable scheduled maintenance"
928
+ msgstr ""
929
+
930
+ #: includes/admin/register-settings.php:730
931
+ msgid ""
932
+ "Cleaning the database at regular intervals could improve performance, "
933
+ "especially on high traffic blogs. Enabling maintenance will automatically "
934
+ "delete entries older than 90 days in the daily tables."
935
+ msgstr ""
936
+
937
+ #: includes/admin/register-settings.php:736
938
+ msgid "Time to run maintenance"
939
+ msgstr ""
940
+
941
+ #: includes/admin/register-settings.php:737
942
+ msgid "The next two options allow you to set the time to run the cron."
943
+ msgstr ""
944
+
945
+ #: includes/admin/register-settings.php:742
946
+ msgid "Hour"
947
+ msgstr ""
948
+
949
+ #: includes/admin/register-settings.php:752
950
+ msgid "Minute"
951
+ msgstr ""
952
+
953
+ #: includes/admin/register-settings.php:762
954
+ msgid "Run maintenance"
955
+ msgstr ""
956
+
957
+ #: includes/admin/register-settings.php:768
958
+ msgid "Weekly"
959
+ msgstr ""
960
+
961
+ #: includes/admin/register-settings.php:769
962
+ msgid "Fortnightly"
963
+ msgstr ""
964
+
965
+ #: includes/admin/register-settings.php:770
966
+ msgid "Monthly"
967
+ msgstr ""
968
+
969
+ #: includes/admin/register-settings.php:978
970
+ msgid "No styles"
971
+ msgstr ""
972
+
973
+ #: includes/admin/register-settings.php:979
974
+ msgid "Select this option if you plan to add your own styles"
975
+ msgstr ""
976
+
977
+ #: includes/admin/register-settings.php:983
978
+ msgid "Text only"
979
+ msgstr ""
980
+
981
+ #: includes/admin/register-settings.php:984
982
+ msgid ""
983
+ "Disable thumbnails and no longer include the default style sheet included in "
984
+ "the plugin"
985
+ msgstr ""
986
+
987
+ #: includes/admin/register-settings.php:988
988
+ msgid "Left thumbnails"
989
+ msgstr ""
990
+
991
+ #: includes/admin/register-settings.php:989
992
+ msgid ""
993
+ "Enabling this option will set the post thumbnail to be before text. "
994
+ "Disabling this option will not revert any settings."
995
+ msgstr ""
996
+
997
+ #: includes/admin/save-settings.php:51
998
+ msgid ""
999
+ "Settings have been reset to their default values. Reload this page to view "
1000
+ "the updated settings"
1001
+ msgstr ""
1002
+
1003
+ #: includes/admin/save-settings.php:119
1004
+ msgid "Settings updated."
1005
+ msgstr ""
1006
+
1007
+ #: includes/admin/settings-page.php:70
1008
+ msgid "Save Changes"
1009
+ msgstr ""
1010
+
1011
+ #: includes/admin/settings-page.php:79
1012
+ msgid "Do you really want to reset all these settings to their default values?"
1013
+ msgstr ""
1014
+
1015
+ #: includes/admin/settings-page.php:81
1016
+ msgid "Reset all settings"
1017
+ msgstr ""
1018
+
1019
+ #: includes/admin/settings-page.php:155
1020
+ #, php-format
1021
+ msgid ""
1022
+ "The callback function used for the <strong>%s</strong> setting is missing."
1023
+ msgstr ""
1024
+
1025
+ #: includes/admin/settings-page.php:298
1026
+ msgid "Modified from default setting"
1027
+ msgstr ""
1028
+
1029
+ #: includes/admin/sidebar.php:15
1030
+ msgid "Support the development"
1031
+ msgstr ""
1032
+
1033
+ #: includes/admin/sidebar.php:22
1034
+ msgid "Donation for Top 10"
1035
+ msgstr ""
1036
+
1037
+ #: includes/admin/sidebar.php:24
1038
+ msgid "Enter amount in USD"
1039
+ msgstr ""
1040
+
1041
+ #: includes/admin/sidebar.php:28
1042
+ msgid "Send your donation to the author of"
1043
+ msgstr ""
1044
+
1045
+ #: includes/admin/sidebar.php:39
1046
+ msgid "Quick links"
1047
+ msgstr ""
1048
+
1049
+ #: includes/admin/sidebar.php:45
1050
+ msgid "Top 10 plugin homepage"
1051
+ msgstr ""
1052
+
1053
+ #: includes/admin/sidebar.php:50
1054
+ msgid "FAQ"
1055
+ msgstr ""
1056
+
1057
+ #: includes/admin/sidebar.php:60
1058
+ msgid "Reviews"
1059
+ msgstr ""
1060
+
1061
+ #: includes/admin/sidebar.php:65
1062
+ msgid "Github repository"
1063
+ msgstr ""
1064
+
1065
+ #: includes/admin/sidebar.php:70
1066
+ msgid "Other plugins"
1067
+ msgstr ""
1068
+
1069
+ #: includes/admin/sidebar.php:75
1070
+ msgid "Ajay's blog"
1071
+ msgstr ""
1072
+
1073
+ #: includes/admin/sidebar.php:88
1074
+ msgid "Follow me"
1075
+ msgstr ""
1076
+
1077
+ #: includes/admin/tools.php:30
1078
+ msgid "Top 10 popular posts reset"
1079
+ msgstr ""
1080
+
1081
+ #: includes/admin/tools.php:36
1082
+ msgid "Top 10 daily popular posts reset"
1083
+ msgstr ""
1084
+
1085
+ #: includes/admin/tools.php:43
1086
+ msgid "Duplicate rows cleaned from the tables"
1087
+ msgstr ""
1088
+
1089
+ #: includes/admin/tools.php:50
1090
+ msgid "Post counts across blog IDs 0 and 1 have been merged"
1091
+ msgstr ""
1092
+
1093
+ #: includes/admin/tools.php:66 includes/admin/tools.php:68
1094
+ msgid "Clear cache"
1095
+ msgstr ""
1096
+
1097
+ #: includes/admin/tools.php:71
1098
+ msgid ""
1099
+ "Clear the Top 10 cache. This will also be cleared automatically when you "
1100
+ "save the settings page."
1101
+ msgstr ""
1102
+
1103
+ #: includes/admin/tools.php:74
1104
+ msgid "Reset database"
1105
+ msgstr ""
1106
+
1107
+ #: includes/admin/tools.php:76
1108
+ msgid "Reset Popular Posts Network-wide"
1109
+ msgstr ""
1110
+
1111
+ #: includes/admin/tools.php:76
1112
+ msgid "Are you sure you want to reset the popular posts?"
1113
+ msgstr ""
1114
+
1115
+ #: includes/admin/tools.php:77
1116
+ msgid "Reset Daily Popular Posts Network-wide"
1117
+ msgstr ""
1118
+
1119
+ #: includes/admin/tools.php:77
1120
+ msgid "Are you sure you want to reset the daily popular posts?"
1121
+ msgstr ""
1122
+
1123
+ #: includes/admin/tools.php:80
1124
+ msgid ""
1125
+ "This will reset the Top 10 tables. If you are running Top 10 on multisite "
1126
+ "then it will delete the popular posts across the entire network. This cannot "
1127
+ "be reversed. Make sure that your database has been backed up before "
1128
+ "proceeding"
1129
+ msgstr ""
1130
+
1131
+ #: includes/admin/tools.php:83
1132
+ msgid "Other tools"
1133
+ msgstr ""
1134
+
1135
+ #: includes/admin/tools.php:85
1136
+ msgid "Merge blog ID 0 and 1 post counts"
1137
+ msgstr ""
1138
+
1139
+ #: includes/admin/tools.php:85
1140
+ msgid "This will merge post counts for blog IDs 0 and 1. Proceed?"
1141
+ msgstr ""
1142
+
1143
+ #: includes/admin/tools.php:88
1144
+ msgid "This will merge post counts for posts with table entries of 0 and 1"
1145
+ msgstr ""
1146
+
1147
+ #: includes/admin/tools.php:91
1148
+ msgid "Merge duplicates across blog IDs"
1149
+ msgstr ""
1150
+
1151
+ #: includes/admin/tools.php:91
1152
+ msgid "This will delete the duplicate entries in the tables. Proceed?"
1153
+ msgstr ""
1154
+
1155
+ #: includes/admin/tools.php:94
1156
+ msgid ""
1157
+ "In older versions, the plugin created entries with duplicate post IDs. "
1158
+ "Clicking the button below will merge these duplicate IDs"
1159
+ msgstr ""
1160
+
1161
+ #: includes/cron.php:87
1162
+ msgid "Once Weekly"
1163
+ msgstr ""
1164
+
1165
+ #: includes/cron.php:91
1166
+ msgid "Once Fortnightly"
1167
+ msgstr ""
1168
+
1169
+ #: includes/cron.php:95
1170
+ msgid "Once Monthly"
1171
+ msgstr ""
1172
+
1173
+ #: includes/cron.php:99
1174
+ msgid "Once quarterly"
1175
+ msgstr ""
1176
+
1177
+ #: includes/deprecated.php:171
1178
+ msgid "<h3>Popular Posts</h3>"
1179
+ msgstr ""
1180
+
1181
+ #: includes/deprecated.php:172
1182
+ msgid "<h3>Daily Popular</h3>"
1183
+ msgstr ""
1184
+
1185
+ #: includes/modules/class-top-ten-count-widget.php:30
1186
+ msgid "Overall count [Top 10]"
1187
+ msgstr ""
1188
+
1189
+ #: includes/modules/class-top-ten-count-widget.php:32
1190
+ msgid "Display overall count"
1191
+ msgstr ""
1192
+
1193
+ #: includes/modules/class-top-ten-widget.php:30
1194
+ msgid "Popular Posts [Top 10]"
1195
+ msgstr ""
1196
+
1197
+ #: includes/modules/class-top-ten-widget.php:32
1198
+ msgid "Display popular posts"
1199
+ msgstr ""
1200
+
1201
+ #: includes/modules/class-top-ten-widget.php:85
1202
+ msgid "No. of posts"
1203
+ msgstr ""
1204
+
1205
+ #: includes/modules/class-top-ten-widget.php:90
1206
+ msgid "Offset"
1207
+ msgstr ""
1208
+
1209
+ #: includes/modules/class-top-ten-widget.php:96
1210
+ msgid "Custom time period (Enter below)"
1211
+ msgstr ""
1212
+
1213
+ #: includes/modules/class-top-ten-widget.php:100
1214
+ msgid "In days and hours (applies only to custom option above)"
1215
+ msgstr ""
1216
+
1217
+ #: includes/modules/class-top-ten-widget.php:102
1218
+ msgid "days"
1219
+ msgstr ""
1220
+
1221
+ #: includes/modules/class-top-ten-widget.php:105
1222
+ msgid "hours"
1223
+ msgstr ""
1224
+
1225
+ #: includes/modules/class-top-ten-widget.php:110
1226
+ msgid "Show count?"
1227
+ msgstr ""
1228
+
1229
+ #: includes/modules/class-top-ten-widget.php:115
1230
+ msgid "Show excerpt?"
1231
+ msgstr ""
1232
+
1233
+ #: includes/modules/class-top-ten-widget.php:120
1234
+ msgid "Show author?"
1235
+ msgstr ""
1236
+
1237
+ #: includes/modules/class-top-ten-widget.php:125
1238
+ msgid "Show date?"
1239
+ msgstr ""
1240
+
1241
+ #: includes/modules/class-top-ten-widget.php:129
1242
+ msgid "Thumbnail options"
1243
+ msgstr ""
1244
+
1245
+ #: includes/modules/class-top-ten-widget.php:131
1246
+ msgid "Thumbnails inline, before title"
1247
+ msgstr ""
1248
+
1249
+ #: includes/modules/class-top-ten-widget.php:132
1250
+ msgid "Thumbnails inline, after title"
1251
+ msgstr ""
1252
+
1253
+ #: includes/modules/class-top-ten-widget.php:133
1254
+ msgid "Only thumbnails, no text"
1255
+ msgstr ""
1256
+
1257
+ #: includes/modules/class-top-ten-widget.php:134
1258
+ msgid "No thumbnails, only text."
1259
+ msgstr ""
1260
+
1261
+ #: includes/modules/class-top-ten-widget.php:149
1262
+ msgid "Post types to include:"
1263
+ msgstr ""
1264
+
1265
+ #: includes/public/display-posts.php:92
1266
+ msgid ""
1267
+ "posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the "
1268
+ "posts only."
1269
+ msgstr ""
1270
+
1271
+ #: includes/public/display-posts.php:232
1272
+ #, php-format
1273
+ msgid ""
1274
+ "Popular posts by <a href=\"%1$s\" rel=\"nofollow\" %2$s>Top 10 plugin</a>"
1275
+ msgstr ""
1276
+
1277
+ #: includes/public/media.php:58
1278
+ msgid "thumb_timthumb argument has been deprecated"
1279
+ msgstr ""
1280
+
1281
+ #: includes/public/media.php:62
1282
+ msgid "thumb_timthumb_q argument has been deprecated"
1283
+ msgstr ""
1284
+
1285
+ #: includes/public/media.php:66
1286
+ msgid "filter argument has been deprecated"
1287
+ msgstr ""
1288
+
1289
+ #: includes/public/output-generator.php:240
1290
+ msgid " by "
1291
+ msgstr ""
1292
+
1293
+ #: includes/tracker.php:248
1294
+ msgid "Query variable based"
1295
+ msgstr ""
1296
+
1297
+ #: includes/tracker.php:249
1298
+ msgid "Uses query variables to record visits"
1299
+ msgstr ""
1300
+
1301
+ #: includes/tracker.php:253
1302
+ msgid "Ajaxurl based"
1303
+ msgstr ""
1304
+
1305
+ #: includes/tracker.php:254
1306
+ msgid ""
1307
+ "Uses admin-ajax.php which is inbuilt within WordPress to process the tracker"
1308
+ msgstr ""
languages/top-10-en_US.pot CHANGED
@@ -3,296 +3,1307 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Top 10\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2016-09-22 16:24+0100\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
9
- "Language-Team: Ajay DSouza <me@ajaydsouza.com>\n"
10
- "Language: en\n"
11
  "MIME-Version: 1.0\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
13
  "Content-Transfer-Encoding: 8bit\n"
14
- "X-Poedit-KeywordsList: __;_e;_c;__ngettext\n"
 
15
  "X-Poedit-Basepath: ..\n"
16
- "X-Generator: Poedit 1.8.9\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
 
18
  "X-Poedit-SearchPath-0: .\n"
19
- "X-Poedit-SearchPathExcluded-0: ../admin/wick\n"
20
 
21
- #: admin/admin-columns.php:30
22
  msgid "Total Views"
23
  msgstr ""
24
 
25
- #: admin/admin-columns.php:33
26
  msgid "Today's Views"
27
  msgstr ""
28
 
29
- #: admin/admin-columns.php:36
30
  msgid "Views"
31
  msgstr ""
32
 
33
- #: admin/admin-dashboard.php:64
34
  msgid "View all daily popular posts"
35
  msgstr ""
36
 
37
- #: admin/admin-dashboard.php:66
38
  msgid "View all popular posts"
39
  msgstr ""
40
 
41
- #: admin/admin-dashboard.php:72
42
  #, php-format
43
  msgid "Popular posts by <a href=\"%s\" target=\"_blank\">Top 10 plugin</a>"
44
  msgstr ""
45
 
46
- #: admin/admin-dashboard.php:122 admin/class-stats.php:539
 
47
  msgid "Popular Posts"
48
  msgstr ""
49
 
50
- #: admin/admin-dashboard.php:127 admin/admin.php:461
51
  msgid "Daily Popular Posts"
52
  msgstr ""
53
 
54
- #: admin/admin-metabox.php:137
55
- #, php-format
 
 
 
56
  msgid ""
57
- "You have %1$s installed. If you are trying to modify the thumbnail, then you "
58
- "will need to make the same change in the %1$s meta box on this page."
59
  msgstr ""
60
 
61
- #: admin/admin.php:199
62
- msgid "Options saved successfully. If enabled, the cache has been cleared."
63
  msgstr ""
64
 
65
- #: admin/admin.php:202
66
  msgid ""
67
- "Left Thumbnails style selected. Post thumbnail location set to Inline before "
68
- "text."
69
  msgstr ""
70
 
71
- #: admin/admin.php:205
72
- msgid "Text Only style selected. Thumbnails will not be displayed."
73
  msgstr ""
74
 
75
- #: admin/admin.php:208
76
- #, php-format
77
- msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %1$d."
 
78
  msgstr ""
79
 
80
- #: admin/admin.php:223
81
- msgid "Options set to Default."
82
  msgstr ""
83
 
84
- #: admin/admin.php:230
85
- msgid "Top 10 popular posts reset"
 
 
 
86
  msgstr ""
87
 
88
- #: admin/admin.php:237
89
- msgid "Top 10 daily popular posts reset"
90
  msgstr ""
91
 
92
- #: admin/admin.php:245
93
- msgid "Duplicate rows cleaned from tables"
 
 
 
94
  msgstr ""
95
 
96
- #: admin/admin.php:253
97
- msgid "Post counts across blog IDs 0 and 1 have been merged"
 
98
  msgstr ""
99
 
100
- #: admin/admin.php:266
101
- msgid "Scheduled maintenance enabled / modified"
102
  msgstr ""
103
 
104
- #: admin/admin.php:270
105
- msgid "Scheduled maintenance disabled"
106
  msgstr ""
107
 
108
- #: admin/admin.php:308
109
- msgid "Counts from selected sites have been imported."
110
  msgstr ""
111
 
112
- #: admin/admin.php:333
113
- msgid ""
114
- "Selected tables have been deleted. Note that only imported tables have been "
115
- "deleted."
116
  msgstr ""
117
 
118
- #: admin/admin.php:449 admin/admin.php:452
119
- msgid "Top 10 Settings"
120
  msgstr ""
121
 
122
- #: admin/admin.php:449
123
- msgid "Top 10"
124
  msgstr ""
125
 
126
- #: admin/admin.php:457
127
- msgid "View Popular Posts"
128
  msgstr ""
129
 
130
- #: admin/admin.php:564
131
- msgid "Settings"
 
 
 
 
132
  msgstr ""
133
 
134
- #: admin/admin.php:586
135
  msgid "Support"
136
  msgstr ""
137
 
138
- #: admin/admin.php:587
139
  msgid "Donate"
140
  msgstr ""
141
 
142
- #: admin/admin.php:588
143
  msgid "Contribute"
144
  msgstr ""
145
 
146
- #: admin/cache.php:19
147
  msgid "Top 10 cache has been cleared"
148
  msgstr ""
149
 
150
- #: admin/class-stats.php:35
151
  msgid "popular_post"
152
  msgstr ""
153
 
154
- #: admin/class-stats.php:36
155
  msgid "popular_posts"
156
  msgstr ""
157
 
158
- #: admin/class-stats.php:243
 
 
 
 
159
  msgid "View"
160
  msgstr ""
161
 
162
- #: admin/class-stats.php:244
163
  msgid "Edit"
164
  msgstr ""
165
 
166
- #: admin/class-stats.php:245
167
  msgid "Delete"
168
  msgstr ""
169
 
170
- #: admin/class-stats.php:267
171
  msgid "Y/m/d g:i:s a"
172
  msgstr ""
173
 
174
- #: admin/class-stats.php:274
175
  #, php-format
176
  msgid "%s ago"
177
  msgstr ""
178
 
179
- #: admin/class-stats.php:276
180
  msgid "Y/m/d"
181
  msgstr ""
182
 
183
- #: admin/class-stats.php:309
 
 
184
  msgid "Title"
185
  msgstr ""
186
 
187
- #: admin/class-stats.php:310
188
  msgid "Total visits"
189
  msgstr ""
190
 
191
- #: admin/class-stats.php:311
192
  msgid "Daily visits"
193
  msgstr ""
194
 
195
- #: admin/class-stats.php:312
196
  msgid "Post type"
197
  msgstr ""
198
 
199
- #: admin/class-stats.php:313
200
  msgid "Author"
201
  msgstr ""
202
 
203
- #: admin/class-stats.php:314
204
  msgid "Date"
205
  msgstr ""
206
 
207
- #: admin/class-stats.php:348
208
  msgid "Delete Count"
209
  msgstr ""
210
 
211
- #: admin/class-stats.php:441
 
 
 
 
212
  msgid "Filter"
213
  msgstr ""
214
 
215
- #: admin/class-stats.php:514
216
  msgid "Search Table"
217
  msgstr ""
218
 
219
- #: includes/cron.php:74
220
- msgid "Once Weekly"
 
 
 
221
  msgstr ""
222
 
223
- #: includes/cron.php:78
224
- msgid "Once Fortnightly"
 
 
 
225
  msgstr ""
226
 
227
- #: includes/cron.php:82
228
- msgid "Once Monthly"
 
 
 
229
  msgstr ""
230
 
231
- #: includes/cron.php:86
232
- msgid "Once quarterly"
 
233
  msgstr ""
234
 
235
- #: includes/modules/class-top-10-widget.php:30
236
- msgid "Popular Posts [Top 10]"
237
  msgstr ""
238
 
239
- #: includes/modules/class-top-10-widget.php:32
240
- msgid "Display popular posts"
 
 
241
  msgstr ""
242
 
243
- #: includes/public/display-posts.php:92
 
 
 
 
244
  msgid ""
245
- "posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the "
246
- "posts only."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  msgstr ""
248
 
249
- #: includes/public/display-posts.php:229
 
 
 
 
 
 
 
 
 
 
 
250
  #, php-format
251
  msgid ""
252
- "Popular posts by <a href=\"%1$s\" rel=\"nofollow\" %2$s>Top 10 plugin</a>"
 
253
  msgstr ""
254
 
255
- #: includes/public/media.php:60
256
- msgid "thumb_timthumb argument has been deprecated"
257
  msgstr ""
258
 
259
- #: includes/public/media.php:64
260
- msgid "thumb_timthumb_q argument has been deprecated"
261
  msgstr ""
262
 
263
- #: includes/public/media.php:68
264
- msgid "filter argument has been deprecated"
265
  msgstr ""
266
 
267
- #: includes/public/output-generator.php:238
268
- msgid " by "
269
  msgstr ""
270
 
271
- #: includes/tracker.php:248
272
- msgid "Query variable based"
273
  msgstr ""
274
 
275
- #: includes/tracker.php:249
276
- msgid "Uses query variables to record visits"
277
  msgstr ""
278
 
279
- #: includes/tracker.php:253
280
- msgid "Ajaxurl based"
281
  msgstr ""
282
 
283
- #: includes/tracker.php:254
 
 
 
 
 
284
  msgid ""
285
- "Uses admin-ajax.php which is inbuilt within WordPress to process the tracker"
 
286
  msgstr ""
287
 
288
- #: top-10.php:94
289
- msgid "<h3>Popular Posts</h3>"
290
  msgstr ""
291
 
292
- #: top-10.php:95
293
- msgid "<h3>Daily Popular</h3>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  msgstr ""
295
 
296
- #: top-10.php:96
297
  msgid "No top posts yet"
298
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  msgstr ""
4
  "Project-Id-Version: Top 10\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2017-11-18 11:06+0000\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
9
+ "Language-Team: WebberZone <plugins@webberzone.com>\n"
10
+ "Language: en_US\n"
11
  "MIME-Version: 1.0\n"
12
  "Content-Type: text/plain; charset=UTF-8\n"
13
  "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Poedit-KeywordsList: __;_e;_c;__ngettext;esc_html__;esc_attr__;esc_html_e;"
15
+ "esc_attr_e\n"
16
  "X-Poedit-Basepath: ..\n"
17
+ "X-Generator: Poedit 2.0.4\n"
18
  "X-Poedit-SourceCharset: UTF-8\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
  "X-Poedit-SearchPath-0: .\n"
 
21
 
22
+ #: includes/admin/admin-columns.php:29
23
  msgid "Total Views"
24
  msgstr ""
25
 
26
+ #: includes/admin/admin-columns.php:30
27
  msgid "Today's Views"
28
  msgstr ""
29
 
30
+ #: includes/admin/admin-columns.php:31
31
  msgid "Views"
32
  msgstr ""
33
 
34
+ #: includes/admin/admin-dashboard.php:68
35
  msgid "View all daily popular posts"
36
  msgstr ""
37
 
38
+ #: includes/admin/admin-dashboard.php:70
39
  msgid "View all popular posts"
40
  msgstr ""
41
 
42
+ #: includes/admin/admin-dashboard.php:78
43
  #, php-format
44
  msgid "Popular posts by <a href=\"%s\" target=\"_blank\">Top 10 plugin</a>"
45
  msgstr ""
46
 
47
+ #: includes/admin/admin-dashboard.php:127 includes/admin/admin.php:44
48
+ #: includes/admin/class-top-ten-statistics-table.php:574
49
  msgid "Popular Posts"
50
  msgstr ""
51
 
52
+ #: includes/admin/admin-dashboard.php:132 includes/admin/admin.php:48
53
  msgid "Daily Popular Posts"
54
  msgstr ""
55
 
56
+ #: includes/admin/admin-metabox.php:109
57
+ msgid "Visit count:"
58
+ msgstr ""
59
+
60
+ #: includes/admin/admin-metabox.php:111
61
  msgid ""
62
+ "Enter a number above to update the visit count. Leaving the above box blank "
63
+ "will set the count to zero"
64
  msgstr ""
65
 
66
+ #: includes/admin/admin-metabox.php:120
67
+ msgid "Disable Popular Posts display:"
68
  msgstr ""
69
 
70
+ #: includes/admin/admin-metabox.php:123
71
  msgid ""
72
+ "If this is checked, then Top 10 will not display the popular posts widgets "
73
+ "when viewing this post."
74
  msgstr ""
75
 
76
+ #: includes/admin/admin-metabox.php:127
77
+ msgid "Exclude this post from the popular posts list:"
78
  msgstr ""
79
 
80
+ #: includes/admin/admin-metabox.php:130
81
+ msgid ""
82
+ "If this is checked, then this post will be excluded from the popular posts "
83
+ "list."
84
  msgstr ""
85
 
86
+ #: includes/admin/admin-metabox.php:134
87
+ msgid "Location of thumbnail:"
88
  msgstr ""
89
 
90
+ #: includes/admin/admin-metabox.php:136
91
+ msgid ""
92
+ "Enter the full URL to the image (JPG, PNG or GIF) you'd like to use. This "
93
+ "image will be used for the post. It will be resized to the thumbnail size "
94
+ "set under Top 10 Settings &raquo; Thumbnail options."
95
  msgstr ""
96
 
97
+ #: includes/admin/admin-metabox.php:137
98
+ msgid "The URL above is saved in the meta field:"
99
  msgstr ""
100
 
101
+ #: includes/admin/admin-metabox.php:145
102
+ #, php-format
103
+ msgid ""
104
+ "You have %1$s installed. If you are trying to modify the thumbnail, then you "
105
+ "will need to make the same change in the %1$s meta box on this page."
106
  msgstr ""
107
 
108
+ #: includes/admin/admin.php:30 includes/admin/admin.php:34
109
+ #: includes/admin/settings-page.php:32
110
+ msgid "Top 10 Settings"
111
  msgstr ""
112
 
113
+ #: includes/admin/admin.php:30
114
+ msgid "Top 10"
115
  msgstr ""
116
 
117
+ #: includes/admin/admin.php:34 includes/admin/admin.php:317
118
+ msgid "Settings"
119
  msgstr ""
120
 
121
+ #: includes/admin/admin.php:37 includes/admin/tools.php:56
122
+ msgid "Top 10 Tools"
123
  msgstr ""
124
 
125
+ #: includes/admin/admin.php:37
126
+ msgid "Tools"
 
 
127
  msgstr ""
128
 
129
+ #: includes/admin/admin.php:44
130
+ msgid "Top 10 Popular Posts"
131
  msgstr ""
132
 
133
+ #: includes/admin/admin.php:48
134
+ msgid "Top 10 Daily Popular Posts"
135
  msgstr ""
136
 
137
+ #: includes/admin/admin.php:188
138
+ msgid "New information not saved. Do you wish to leave the page?"
139
  msgstr ""
140
 
141
+ #: includes/admin/admin.php:271
142
+ #, php-format
143
+ msgid ""
144
+ "Thank you for using <a href=\"%1$s\" target=\"_blank\">Top 10</a>! Please <a "
145
+ "href=\"%2$s\" target=\"_blank\">rate us</a> on <a href=\"%2$s\" target="
146
+ "\"_blank\">WordPress.org</a>"
147
  msgstr ""
148
 
149
+ #: includes/admin/admin.php:339 includes/admin/sidebar.php:55
150
  msgid "Support"
151
  msgstr ""
152
 
153
+ #: includes/admin/admin.php:340
154
  msgid "Donate"
155
  msgstr ""
156
 
157
+ #: includes/admin/admin.php:341
158
  msgid "Contribute"
159
  msgstr ""
160
 
161
+ #: includes/admin/cache.php:21
162
  msgid "Top 10 cache has been cleared"
163
  msgstr ""
164
 
165
+ #: includes/admin/class-top-ten-statistics-table.php:36
166
  msgid "popular_post"
167
  msgstr ""
168
 
169
+ #: includes/admin/class-top-ten-statistics-table.php:37
170
  msgid "popular_posts"
171
  msgstr ""
172
 
173
+ #: includes/admin/class-top-ten-statistics-table.php:208
174
+ msgid "No popular posts available."
175
+ msgstr ""
176
+
177
+ #: includes/admin/class-top-ten-statistics-table.php:257
178
  msgid "View"
179
  msgstr ""
180
 
181
+ #: includes/admin/class-top-ten-statistics-table.php:258
182
  msgid "Edit"
183
  msgstr ""
184
 
185
+ #: includes/admin/class-top-ten-statistics-table.php:259
186
  msgid "Delete"
187
  msgstr ""
188
 
189
+ #: includes/admin/class-top-ten-statistics-table.php:282
190
  msgid "Y/m/d g:i:s a"
191
  msgstr ""
192
 
193
+ #: includes/admin/class-top-ten-statistics-table.php:290
194
  #, php-format
195
  msgid "%s ago"
196
  msgstr ""
197
 
198
+ #: includes/admin/class-top-ten-statistics-table.php:292
199
  msgid "Y/m/d"
200
  msgstr ""
201
 
202
+ #: includes/admin/class-top-ten-statistics-table.php:330
203
+ #: includes/modules/class-top-ten-count-widget.php:53
204
+ #: includes/modules/class-top-ten-widget.php:80
205
  msgid "Title"
206
  msgstr ""
207
 
208
+ #: includes/admin/class-top-ten-statistics-table.php:331
209
  msgid "Total visits"
210
  msgstr ""
211
 
212
+ #: includes/admin/class-top-ten-statistics-table.php:332
213
  msgid "Daily visits"
214
  msgstr ""
215
 
216
+ #: includes/admin/class-top-ten-statistics-table.php:333
217
  msgid "Post type"
218
  msgstr ""
219
 
220
+ #: includes/admin/class-top-ten-statistics-table.php:334
221
  msgid "Author"
222
  msgstr ""
223
 
224
+ #: includes/admin/class-top-ten-statistics-table.php:335
225
  msgid "Date"
226
  msgstr ""
227
 
228
+ #: includes/admin/class-top-ten-statistics-table.php:369
229
  msgid "Delete Count"
230
  msgstr ""
231
 
232
+ #: includes/admin/class-top-ten-statistics-table.php:413
233
+ msgid "Are you sure you want to do this"
234
+ msgstr ""
235
+
236
+ #: includes/admin/class-top-ten-statistics-table.php:469
237
  msgid "Filter"
238
  msgstr ""
239
 
240
+ #: includes/admin/class-top-ten-statistics-table.php:549
241
  msgid "Search Table"
242
  msgstr ""
243
 
244
+ #: includes/admin/help-tab.php:35 includes/admin/help-tab.php:126
245
+ #, php-format
246
+ msgid ""
247
+ "For more information or how to get support visit the <a href=\"%1$s"
248
+ "\">WebberZone support site</a>."
249
  msgstr ""
250
 
251
+ #: includes/admin/help-tab.php:37 includes/admin/help-tab.php:128
252
+ #, php-format
253
+ msgid ""
254
+ "Support queries should be posted in the <a href=\"%1$s\">WordPress.org "
255
+ "support forums</a>."
256
  msgstr ""
257
 
258
+ #: includes/admin/help-tab.php:40 includes/admin/help-tab.php:131
259
+ #, php-format
260
+ msgid ""
261
+ "<a href=\"%1$s\">Post an issue</a> on <a href=\"%2$s\">GitHub</a> (bug "
262
+ "reports only)."
263
  msgstr ""
264
 
265
+ #: includes/admin/help-tab.php:49 includes/admin/help-tab.php:140
266
+ #: includes/admin/settings-page.php:125
267
+ msgid "General"
268
  msgstr ""
269
 
270
+ #: includes/admin/help-tab.php:51
271
+ msgid "This screen provides the basic settings for configuring Top 10."
272
  msgstr ""
273
 
274
+ #: includes/admin/help-tab.php:52
275
+ msgid ""
276
+ "Enable the trackers and cache, configure basic tracker settings and "
277
+ "uninstall settings."
278
  msgstr ""
279
 
280
+ #: includes/admin/help-tab.php:59 includes/admin/settings-page.php:126
281
+ msgid "Counter/Tracker"
282
+ msgstr ""
283
+
284
+ #: includes/admin/help-tab.php:61
285
  msgid ""
286
+ "This screen provides settings to tweak the display counter and the tracker."
287
+ msgstr ""
288
+
289
+ #: includes/admin/help-tab.php:62
290
+ msgid ""
291
+ "Choose where to display the counter and customize the text. Select the type "
292
+ "of tracker and which user groups to track."
293
+ msgstr ""
294
+
295
+ #: includes/admin/help-tab.php:69 includes/admin/settings-page.php:127
296
+ msgid "Posts list"
297
+ msgstr ""
298
+
299
+ #: includes/admin/help-tab.php:71
300
+ msgid ""
301
+ "This screen provides settings to tweak the output of the list of popular "
302
+ "posts."
303
+ msgstr ""
304
+
305
+ #: includes/admin/help-tab.php:72
306
+ msgid ""
307
+ "Set the number of posts, which categories or posts to exclude, customize "
308
+ "what to display and specific basic HTML markup used to create the posts."
309
+ msgstr ""
310
+
311
+ #: includes/admin/help-tab.php:79 includes/admin/settings-page.php:128
312
+ msgid "Thumbnail"
313
+ msgstr ""
314
+
315
+ #: includes/admin/help-tab.php:81
316
+ msgid ""
317
+ "This screen provides settings to tweak the thumbnail that can be displayed "
318
+ "for each post in the list."
319
+ msgstr ""
320
+
321
+ #: includes/admin/help-tab.php:82
322
+ msgid ""
323
+ "Set the location and size of the thumbnail. Additionally, you can choose "
324
+ "additional sources for the thumbnail i.e. a meta field, first image or a "
325
+ "default thumbnail when nothing is available."
326
+ msgstr ""
327
+
328
+ #: includes/admin/help-tab.php:89 includes/admin/settings-page.php:129
329
+ msgid "Styles"
330
+ msgstr ""
331
+
332
+ #: includes/admin/help-tab.php:91
333
+ msgid ""
334
+ "This screen provides options to control the look and feel of the popular "
335
+ "posts list."
336
+ msgstr ""
337
+
338
+ #: includes/admin/help-tab.php:92
339
+ msgid ""
340
+ "Choose for default set of styles or add your own custom CSS to tweak the "
341
+ "display of the posts."
342
+ msgstr ""
343
+
344
+ #: includes/admin/help-tab.php:99 includes/admin/settings-page.php:130
345
+ msgid "Maintenance"
346
+ msgstr ""
347
+
348
+ #: includes/admin/help-tab.php:101
349
+ msgid "This screen provides options to control the maintenance cron."
350
+ msgstr ""
351
+
352
+ #: includes/admin/help-tab.php:102
353
+ msgid "Choose how often to run maintenance and at what time of the day."
354
+ msgstr ""
355
+
356
+ #: includes/admin/help-tab.php:142
357
+ msgid ""
358
+ "This screen provides some tools that help maintain certain features of Top "
359
+ "10."
360
+ msgstr ""
361
+
362
+ #: includes/admin/help-tab.php:143
363
+ msgid ""
364
+ "Clear the cache, reset the popular posts tables plus some miscellaneous "
365
+ "fixes for older versions of Top 10."
366
+ msgstr ""
367
+
368
+ #: includes/admin/register-settings.php:228
369
+ msgid "Enable trackers"
370
+ msgstr ""
371
+
372
+ #: includes/admin/register-settings.php:237
373
+ #: includes/modules/class-top-ten-widget.php:95
374
+ msgid "Overall"
375
+ msgstr ""
376
+
377
+ #: includes/admin/register-settings.php:238
378
+ #: includes/admin/register-settings.php:767
379
+ msgid "Daily"
380
+ msgstr ""
381
+
382
+ #: includes/admin/register-settings.php:243
383
+ msgid "Enable cache"
384
+ msgstr ""
385
+
386
+ #: includes/admin/register-settings.php:244
387
+ msgid ""
388
+ "If activated, Top 10 will use the Transients API to cache the popular posts "
389
+ "output for 1 hour."
390
+ msgstr ""
391
+
392
+ #: includes/admin/register-settings.php:250
393
+ msgid "Time to cache"
394
+ msgstr ""
395
+
396
+ #: includes/admin/register-settings.php:251
397
+ msgid "Enter the number of seconds to cache the output."
398
+ msgstr ""
399
+
400
+ #: includes/admin/register-settings.php:257
401
+ msgid "Start daily counts from midnight"
402
+ msgstr ""
403
+
404
+ #: includes/admin/register-settings.php:258
405
+ msgid ""
406
+ "Daily counter will display number of visits from midnight. This option is "
407
+ "checked by default and mimics the way most normal counters work. Turning "
408
+ "this off will allow you to use the hourly setting in the next option."
409
+ msgstr ""
410
+
411
+ #: includes/admin/register-settings.php:264
412
+ msgid "Default custom period range"
413
+ msgstr ""
414
+
415
+ #: includes/admin/register-settings.php:265
416
+ msgid ""
417
+ "The next two options allow you to set the default range for the custom "
418
+ "period. This was previously called the daily range. This can be overridden "
419
+ "in the widget."
420
+ msgstr ""
421
+
422
+ #: includes/admin/register-settings.php:270
423
+ msgid "Day(s)"
424
+ msgstr ""
425
+
426
+ #: includes/admin/register-settings.php:279
427
+ msgid "Hour(s)"
428
+ msgstr ""
429
+
430
+ #: includes/admin/register-settings.php:289
431
+ msgid "Delete options on uninstall"
432
+ msgstr ""
433
+
434
+ #: includes/admin/register-settings.php:290
435
+ msgid ""
436
+ "If this is checked, all settings related to Top 10 are removed from the "
437
+ "database if you choose to uninstall/delete the plugin."
438
+ msgstr ""
439
+
440
+ #: includes/admin/register-settings.php:296
441
+ msgid "Delete counter data on uninstall"
442
+ msgstr ""
443
+
444
+ #: includes/admin/register-settings.php:297
445
+ msgid ""
446
+ "If this is checked, the tables containing the counter statistics are removed "
447
+ "from the database if you choose to uninstall/delete the plugin. Keep this "
448
+ "unchecked if you choose to reinstall the plugin and do not want to lose your "
449
+ "counter data."
450
+ msgstr ""
451
+
452
+ #: includes/admin/register-settings.php:303
453
+ msgid "Show metabox"
454
+ msgstr ""
455
+
456
+ #: includes/admin/register-settings.php:304
457
+ msgid ""
458
+ "This will add the Top 10 metabox on Edit Posts or Add New Posts screens. "
459
+ "Also applies to Pages and Custom Post Types."
460
+ msgstr ""
461
+
462
+ #: includes/admin/register-settings.php:310
463
+ msgid "Limit meta box to Admins only"
464
+ msgstr ""
465
+
466
+ #: includes/admin/register-settings.php:311
467
+ msgid ""
468
+ "If selected, the meta box will be hidden from anyone who is not an Admin. By "
469
+ "default, Contributors and above will be able to see the meta box. Applies "
470
+ "only if the above option is selected."
471
+ msgstr ""
472
+
473
+ #: includes/admin/register-settings.php:317
474
+ msgid "Link to Top 10 plugin page"
475
  msgstr ""
476
 
477
+ #: includes/admin/register-settings.php:318
478
+ msgid ""
479
+ "A no-follow link to the plugin homepage will be added as the last item of "
480
+ "the popular posts."
481
+ msgstr ""
482
+
483
+ #: includes/admin/register-settings.php:329
484
+ msgid "Display number of views on"
485
+ msgstr ""
486
+
487
+ #: includes/admin/register-settings.php:331
488
+ #: includes/admin/register-settings.php:494
489
  #, php-format
490
  msgid ""
491
+ "If you choose to disable this, please add %1$s to your template file where "
492
+ "you want it displayed"
493
  msgstr ""
494
 
495
+ #: includes/admin/register-settings.php:338
496
+ msgid "Posts"
497
  msgstr ""
498
 
499
+ #: includes/admin/register-settings.php:339
500
+ msgid "Pages"
501
  msgstr ""
502
 
503
+ #: includes/admin/register-settings.php:340
504
+ msgid "Home page"
505
  msgstr ""
506
 
507
+ #: includes/admin/register-settings.php:341
508
+ msgid "Feeds"
509
  msgstr ""
510
 
511
+ #: includes/admin/register-settings.php:342
512
+ msgid "Category archives"
513
  msgstr ""
514
 
515
+ #: includes/admin/register-settings.php:343
516
+ msgid "Tag archives"
517
  msgstr ""
518
 
519
+ #: includes/admin/register-settings.php:344
520
+ msgid "Other archives"
521
  msgstr ""
522
 
523
+ #: includes/admin/register-settings.php:349
524
+ msgid "Format to display the post views"
525
+ msgstr ""
526
+
527
+ #: includes/admin/register-settings.php:351
528
+ #, php-format
529
  msgid ""
530
+ "Use %1$s to display the total count, %2$s for daily count and %3$s for "
531
+ "overall counts across all posts. Default display is %4$s"
532
  msgstr ""
533
 
534
+ #: includes/admin/register-settings.php:357
535
+ msgid "What do display when there are no visits?"
536
  msgstr ""
537
 
538
+ #: includes/admin/register-settings.php:359
539
+ msgid ""
540
+ "This text applies only when there are 0 hits for the post and it isn't a "
541
+ "single page. e.g. if you display post views on the homepage or archives then "
542
+ "this text will be used. To override this, just enter the same text as above "
543
+ "option."
544
+ msgstr ""
545
+
546
+ #: includes/admin/register-settings.php:365
547
+ msgid "Always display latest post count"
548
+ msgstr ""
549
+
550
+ #: includes/admin/register-settings.php:366
551
+ msgid ""
552
+ "This option uses JavaScript and will increase your page load time. Turn this "
553
+ "off if you are not using caching plugins or are OK with displaying older "
554
+ "cached counts."
555
+ msgstr ""
556
+
557
+ #: includes/admin/register-settings.php:372
558
+ msgid "Tracker type"
559
+ msgstr ""
560
+
561
+ #: includes/admin/register-settings.php:380
562
+ msgid "Track user groups"
563
+ msgstr ""
564
+
565
+ #: includes/admin/register-settings.php:381
566
+ msgid ""
567
+ "Uncheck above to disable tracking if the current user falls into any one of "
568
+ "these groups."
569
+ msgstr ""
570
+
571
+ #: includes/admin/register-settings.php:388
572
+ msgid "Authors"
573
+ msgstr ""
574
+
575
+ #: includes/admin/register-settings.php:389
576
+ msgid "Editors"
577
+ msgstr ""
578
+
579
+ #: includes/admin/register-settings.php:390
580
+ msgid "Admins"
581
+ msgstr ""
582
+
583
+ #: includes/admin/register-settings.php:395
584
+ msgid "Track logged-in users"
585
+ msgstr ""
586
+
587
+ #: includes/admin/register-settings.php:396
588
+ msgid ""
589
+ "Uncheck to stop tracking logged in users. Only logged out visitors will be "
590
+ "tracked if this is disabled. Unchecking this will override the above setting."
591
+ msgstr ""
592
+
593
+ #: includes/admin/register-settings.php:402
594
+ msgid "Page views in admin"
595
+ msgstr ""
596
+
597
+ #: includes/admin/register-settings.php:403
598
+ msgid ""
599
+ "Adds three columns called Total Views, Today's Views and Views to All Posts "
600
+ "and All Pages. You can selectively disable these by pulling down the Screen "
601
+ "Options from the top right of the respective screens."
602
+ msgstr ""
603
+
604
+ #: includes/admin/register-settings.php:409
605
+ msgid "Show views to non-admins"
606
+ msgstr ""
607
+
608
+ #: includes/admin/register-settings.php:410
609
+ msgid ""
610
+ "If you disable this then non-admins won't see the above columns or view the "
611
+ "independent pages with the top posts."
612
+ msgstr ""
613
+
614
+ #: includes/admin/register-settings.php:421
615
+ msgid "Number of posts to display"
616
+ msgstr ""
617
+
618
+ #: includes/admin/register-settings.php:422
619
+ msgid ""
620
+ "Maximum number of posts that will be displayed in the list. This option is "
621
+ "used if you don not specify the number of posts in the widget or shortcodes"
622
+ msgstr ""
623
+
624
+ #: includes/admin/register-settings.php:429
625
+ msgid "Published age of posts"
626
+ msgstr ""
627
+
628
+ #: includes/admin/register-settings.php:430
629
+ msgid ""
630
+ "This options allows you to only show posts that have been published within "
631
+ "the above day range. Applies to both overall posts and daily posts lists. e."
632
+ "g. 365 days will only show posts published in the last year in the popular "
633
+ "posts lists. Enter 0 for no restriction."
634
+ msgstr ""
635
+
636
+ #: includes/admin/register-settings.php:436
637
+ msgid "Post types to include"
638
+ msgstr ""
639
+
640
+ #: includes/admin/register-settings.php:437
641
+ msgid ""
642
+ "Select which post types you want to include in the list of posts. This field "
643
+ "can be overridden using a comma separated list of post types when using the "
644
+ "manual display."
645
+ msgstr ""
646
+
647
+ #: includes/admin/register-settings.php:443
648
+ msgid "Post/page IDs to exclude"
649
+ msgstr ""
650
+
651
+ #: includes/admin/register-settings.php:444
652
+ msgid ""
653
+ "Comma-separated list of post or page IDs to exclude from the list. e.g. "
654
+ "188,320,500"
655
+ msgstr ""
656
+
657
+ #: includes/admin/register-settings.php:450
658
+ msgid "Exclude Categories"
659
+ msgstr ""
660
+
661
+ #: includes/admin/register-settings.php:451
662
+ msgid ""
663
+ "Comma separated list of category slugs. The field above has an autocomplete "
664
+ "so simply start typing in the starting letters and it will prompt you with "
665
+ "options. Does not support custom taxonomies."
666
+ msgstr ""
667
+
668
+ #: includes/admin/register-settings.php:462
669
+ msgid "Exclude category IDs"
670
+ msgstr ""
671
+
672
+ #: includes/admin/register-settings.php:463
673
+ msgid ""
674
+ "This is a readonly field that is automatically populated based on the above "
675
+ "input when the settings are saved. These might differ from the IDs visible "
676
+ "in the Categories page which use the term_id. Top 10 uses the "
677
+ "term_taxonomy_id which is unique to this taxonomy."
678
+ msgstr ""
679
+
680
+ #: includes/admin/register-settings.php:470
681
+ msgid "Customize the output"
682
+ msgstr ""
683
+
684
+ #: includes/admin/register-settings.php:476
685
+ msgid "Heading of posts"
686
+ msgstr ""
687
+
688
+ #: includes/admin/register-settings.php:477
689
+ #: includes/admin/register-settings.php:485
690
+ msgid "Displayed before the list of the posts as a the master heading"
691
+ msgstr ""
692
+
693
+ #: includes/admin/register-settings.php:479
694
+ msgid "Popular posts:"
695
+ msgstr ""
696
+
697
+ #: includes/admin/register-settings.php:484
698
+ msgid "Heading of posts for daily/custom period lists"
699
+ msgstr ""
700
+
701
+ #: includes/admin/register-settings.php:487
702
+ msgid "Currently trending:"
703
+ msgstr ""
704
+
705
+ #: includes/admin/register-settings.php:492
706
+ msgid "Show when no posts are found"
707
+ msgstr ""
708
+
709
+ #: includes/admin/register-settings.php:498
710
+ msgid "Blank output"
711
+ msgstr ""
712
+
713
+ #: includes/admin/register-settings.php:499
714
+ msgid "Display custom text"
715
+ msgstr ""
716
+
717
+ #: includes/admin/register-settings.php:504
718
+ msgid "Custom text"
719
+ msgstr ""
720
+
721
+ #: includes/admin/register-settings.php:505
722
+ msgid ""
723
+ "Enter the custom text that will be displayed if the second option is "
724
+ "selected above"
725
  msgstr ""
726
 
727
+ #: includes/admin/register-settings.php:507 includes/deprecated.php:173
728
  msgid "No top posts yet"
729
  msgstr ""
730
+
731
+ #: includes/admin/register-settings.php:511
732
+ msgid "Show post excerpt"
733
+ msgstr ""
734
+
735
+ #: includes/admin/register-settings.php:518
736
+ msgid "Length of excerpt (in words)"
737
+ msgstr ""
738
+
739
+ #: includes/admin/register-settings.php:526
740
+ msgid "Show date"
741
+ msgstr ""
742
+
743
+ #: includes/admin/register-settings.php:533
744
+ msgid "Show author"
745
+ msgstr ""
746
+
747
+ #: includes/admin/register-settings.php:540
748
+ msgid "Show number of views"
749
+ msgstr ""
750
+
751
+ #: includes/admin/register-settings.php:547
752
+ msgid "Limit post title length (in characters)"
753
+ msgstr ""
754
+
755
+ #: includes/admin/register-settings.php:555
756
+ msgid "Open links in new window"
757
+ msgstr ""
758
+
759
+ #: includes/admin/register-settings.php:562
760
+ msgid "Add nofollow to links"
761
+ msgstr ""
762
+
763
+ #: includes/admin/register-settings.php:569
764
+ msgid "Exclude display on these post IDs"
765
+ msgstr ""
766
+
767
+ #: includes/admin/register-settings.php:570
768
+ msgid ""
769
+ "Comma-separated list of post or page IDs to exclude displaying the top posts "
770
+ "on. e.g. 188,320,500"
771
+ msgstr ""
772
+
773
+ #: includes/admin/register-settings.php:576
774
+ msgid "HTML to display"
775
+ msgstr ""
776
+
777
+ #: includes/admin/register-settings.php:582
778
+ msgid "Before the list of posts"
779
+ msgstr ""
780
+
781
+ #: includes/admin/register-settings.php:589
782
+ msgid "After the list of posts"
783
+ msgstr ""
784
+
785
+ #: includes/admin/register-settings.php:596
786
+ msgid "Before each list item"
787
+ msgstr ""
788
+
789
+ #: includes/admin/register-settings.php:603
790
+ msgid "After each list item"
791
+ msgstr ""
792
+
793
+ #: includes/admin/register-settings.php:615
794
+ msgid "Location of the post thumbnail"
795
+ msgstr ""
796
+
797
+ #: includes/admin/register-settings.php:620
798
+ msgid "Display thumbnails inline with posts, before title"
799
+ msgstr ""
800
+
801
+ #: includes/admin/register-settings.php:621
802
+ msgid "Display thumbnails inline with posts, after title"
803
+ msgstr ""
804
+
805
+ #: includes/admin/register-settings.php:622
806
+ msgid "Display only thumbnails, no text"
807
+ msgstr ""
808
+
809
+ #: includes/admin/register-settings.php:623
810
+ msgid "Do not display thumbnails, only text"
811
+ msgstr ""
812
+
813
+ #: includes/admin/register-settings.php:628
814
+ msgid "Thumbnail size"
815
+ msgstr ""
816
+
817
+ #: includes/admin/register-settings.php:630
818
+ msgid ""
819
+ "You can choose from existing image sizes above or create a custom size. If "
820
+ "you have chosen Custom size above, then enter the width, height and crop "
821
+ "settings below. For best results, use a cropped image. If you change the "
822
+ "width and/or height below, existing images will not be automatically resized."
823
+ msgstr ""
824
+
825
+ #: includes/admin/register-settings.php:630
826
+ #, php-format
827
+ msgid "I recommend using %1$s or %2$s to regenerate all image sizes."
828
+ msgstr ""
829
+
830
+ #: includes/admin/register-settings.php:637
831
+ #: includes/modules/class-top-ten-widget.php:145
832
+ msgid "Thumbnail width"
833
+ msgstr ""
834
+
835
+ #: includes/admin/register-settings.php:645
836
+ #: includes/modules/class-top-ten-widget.php:139
837
+ msgid "Thumbnail height"
838
+ msgstr ""
839
+
840
+ #: includes/admin/register-settings.php:653
841
+ msgid "Hard crop thumbnails"
842
+ msgstr ""
843
+
844
+ #: includes/admin/register-settings.php:654
845
+ msgid ""
846
+ "Check this box to hard crop the thumbnails. i.e. force the width and height "
847
+ "above vs. maintaining proportions."
848
+ msgstr ""
849
+
850
+ #: includes/admin/register-settings.php:660
851
+ msgid "Thumbnail size attributes"
852
+ msgstr ""
853
+
854
+ #: includes/admin/register-settings.php:666
855
+ #, php-format
856
+ msgid "Use CSS to set the width and height: e.g. %s"
857
+ msgstr ""
858
+
859
+ #: includes/admin/register-settings.php:668
860
+ #, php-format
861
+ msgid "Use HTML attributes to set the width and height: e.g. %s"
862
+ msgstr ""
863
+
864
+ #: includes/admin/register-settings.php:669
865
+ msgid ""
866
+ "No width or height set. You will need to use external styles to force any "
867
+ "width or height of your choice."
868
+ msgstr ""
869
+
870
+ #: includes/admin/register-settings.php:674
871
+ msgid "Thumbnail meta field name"
872
+ msgstr ""
873
+
874
+ #: includes/admin/register-settings.php:675
875
+ msgid ""
876
+ "The value of this field should contain the URL of the image and can be set "
877
+ "in the metabox in the Edit Post screen"
878
+ msgstr ""
879
+
880
+ #: includes/admin/register-settings.php:681
881
+ msgid "Get first image"
882
+ msgstr ""
883
+
884
+ #: includes/admin/register-settings.php:682
885
+ msgid ""
886
+ "The plugin will fetch the first image in the post content if this is "
887
+ "enabled. This can slow down the loading of your page if the first image in "
888
+ "the followed posts is large in file-size."
889
+ msgstr ""
890
+
891
+ #: includes/admin/register-settings.php:688
892
+ msgid "Use default thumbnail?"
893
+ msgstr ""
894
+
895
+ #: includes/admin/register-settings.php:689
896
+ msgid ""
897
+ "If checked, when no thumbnail is found, show a default one from the URL "
898
+ "below. If not checked and no thumbnail is found, no image will be shown."
899
+ msgstr ""
900
+
901
+ #: includes/admin/register-settings.php:695
902
+ #: includes/admin/settings-page.php:669
903
+ msgid "Default thumbnail"
904
+ msgstr ""
905
+
906
+ #: includes/admin/register-settings.php:696
907
+ msgid ""
908
+ "Enter the full URL of the image that you wish to display if no thumbnail is "
909
+ "found. This image will be displayed below."
910
+ msgstr ""
911
+
912
+ #: includes/admin/register-settings.php:708
913
+ msgid "Popular posts style"
914
+ msgstr ""
915
+
916
+ #: includes/admin/register-settings.php:716
917
+ msgid "Custom CSS"
918
+ msgstr ""
919
+
920
+ #: includes/admin/register-settings.php:718
921
+ #, php-format
922
+ msgid ""
923
+ "Do not include %3$sstyle%4$s tags. Check out the %1$sFAQ%2$s for available "
924
+ "CSS classes to style."
925
+ msgstr ""
926
+
927
+ #: includes/admin/register-settings.php:729
928
+ msgid "Enable scheduled maintenance"
929
+ msgstr ""
930
+
931
+ #: includes/admin/register-settings.php:730
932
+ msgid ""
933
+ "Cleaning the database at regular intervals could improve performance, "
934
+ "especially on high traffic blogs. Enabling maintenance will automatically "
935
+ "delete entries older than 90 days in the daily tables."
936
+ msgstr ""
937
+
938
+ #: includes/admin/register-settings.php:736
939
+ msgid "Time to run maintenance"
940
+ msgstr ""
941
+
942
+ #: includes/admin/register-settings.php:737
943
+ msgid "The next two options allow you to set the time to run the cron."
944
+ msgstr ""
945
+
946
+ #: includes/admin/register-settings.php:742
947
+ msgid "Hour"
948
+ msgstr ""
949
+
950
+ #: includes/admin/register-settings.php:752
951
+ msgid "Minute"
952
+ msgstr ""
953
+
954
+ #: includes/admin/register-settings.php:762
955
+ msgid "Run maintenance"
956
+ msgstr ""
957
+
958
+ #: includes/admin/register-settings.php:768
959
+ msgid "Weekly"
960
+ msgstr ""
961
+
962
+ #: includes/admin/register-settings.php:769
963
+ msgid "Fortnightly"
964
+ msgstr ""
965
+
966
+ #: includes/admin/register-settings.php:770
967
+ msgid "Monthly"
968
+ msgstr ""
969
+
970
+ #: includes/admin/register-settings.php:978
971
+ msgid "No styles"
972
+ msgstr ""
973
+
974
+ #: includes/admin/register-settings.php:979
975
+ msgid "Select this option if you plan to add your own styles"
976
+ msgstr ""
977
+
978
+ #: includes/admin/register-settings.php:983
979
+ msgid "Text only"
980
+ msgstr ""
981
+
982
+ #: includes/admin/register-settings.php:984
983
+ msgid ""
984
+ "Disable thumbnails and no longer include the default style sheet included in "
985
+ "the plugin"
986
+ msgstr ""
987
+
988
+ #: includes/admin/register-settings.php:988
989
+ msgid "Left thumbnails"
990
+ msgstr ""
991
+
992
+ #: includes/admin/register-settings.php:989
993
+ msgid ""
994
+ "Enabling this option will set the post thumbnail to be before text. "
995
+ "Disabling this option will not revert any settings."
996
+ msgstr ""
997
+
998
+ #: includes/admin/save-settings.php:51
999
+ msgid ""
1000
+ "Settings have been reset to their default values. Reload this page to view "
1001
+ "the updated settings"
1002
+ msgstr ""
1003
+
1004
+ #: includes/admin/save-settings.php:119
1005
+ msgid "Settings updated."
1006
+ msgstr ""
1007
+
1008
+ #: includes/admin/settings-page.php:70
1009
+ msgid "Save Changes"
1010
+ msgstr ""
1011
+
1012
+ #: includes/admin/settings-page.php:79
1013
+ msgid "Do you really want to reset all these settings to their default values?"
1014
+ msgstr ""
1015
+
1016
+ #: includes/admin/settings-page.php:81
1017
+ msgid "Reset all settings"
1018
+ msgstr ""
1019
+
1020
+ #: includes/admin/settings-page.php:155
1021
+ #, php-format
1022
+ msgid ""
1023
+ "The callback function used for the <strong>%s</strong> setting is missing."
1024
+ msgstr ""
1025
+
1026
+ #: includes/admin/settings-page.php:298
1027
+ msgid "Modified from default setting"
1028
+ msgstr ""
1029
+
1030
+ #: includes/admin/sidebar.php:15
1031
+ msgid "Support the development"
1032
+ msgstr ""
1033
+
1034
+ #: includes/admin/sidebar.php:22
1035
+ msgid "Donation for Top 10"
1036
+ msgstr ""
1037
+
1038
+ #: includes/admin/sidebar.php:24
1039
+ msgid "Enter amount in USD"
1040
+ msgstr ""
1041
+
1042
+ #: includes/admin/sidebar.php:28
1043
+ msgid "Send your donation to the author of"
1044
+ msgstr ""
1045
+
1046
+ #: includes/admin/sidebar.php:39
1047
+ msgid "Quick links"
1048
+ msgstr ""
1049
+
1050
+ #: includes/admin/sidebar.php:45
1051
+ msgid "Top 10 plugin homepage"
1052
+ msgstr ""
1053
+
1054
+ #: includes/admin/sidebar.php:50
1055
+ msgid "FAQ"
1056
+ msgstr ""
1057
+
1058
+ #: includes/admin/sidebar.php:60
1059
+ msgid "Reviews"
1060
+ msgstr ""
1061
+
1062
+ #: includes/admin/sidebar.php:65
1063
+ msgid "Github repository"
1064
+ msgstr ""
1065
+
1066
+ #: includes/admin/sidebar.php:70
1067
+ msgid "Other plugins"
1068
+ msgstr ""
1069
+
1070
+ #: includes/admin/sidebar.php:75
1071
+ msgid "Ajay's blog"
1072
+ msgstr ""
1073
+
1074
+ #: includes/admin/sidebar.php:88
1075
+ msgid "Follow me"
1076
+ msgstr ""
1077
+
1078
+ #: includes/admin/tools.php:30
1079
+ msgid "Top 10 popular posts reset"
1080
+ msgstr ""
1081
+
1082
+ #: includes/admin/tools.php:36
1083
+ msgid "Top 10 daily popular posts reset"
1084
+ msgstr ""
1085
+
1086
+ #: includes/admin/tools.php:43
1087
+ msgid "Duplicate rows cleaned from the tables"
1088
+ msgstr ""
1089
+
1090
+ #: includes/admin/tools.php:50
1091
+ msgid "Post counts across blog IDs 0 and 1 have been merged"
1092
+ msgstr ""
1093
+
1094
+ #: includes/admin/tools.php:66 includes/admin/tools.php:68
1095
+ msgid "Clear cache"
1096
+ msgstr ""
1097
+
1098
+ #: includes/admin/tools.php:71
1099
+ msgid ""
1100
+ "Clear the Top 10 cache. This will also be cleared automatically when you "
1101
+ "save the settings page."
1102
+ msgstr ""
1103
+
1104
+ #: includes/admin/tools.php:74
1105
+ msgid "Reset database"
1106
+ msgstr ""
1107
+
1108
+ #: includes/admin/tools.php:76
1109
+ msgid "Reset Popular Posts Network-wide"
1110
+ msgstr ""
1111
+
1112
+ #: includes/admin/tools.php:76
1113
+ msgid "Are you sure you want to reset the popular posts?"
1114
+ msgstr ""
1115
+
1116
+ #: includes/admin/tools.php:77
1117
+ msgid "Reset Daily Popular Posts Network-wide"
1118
+ msgstr ""
1119
+
1120
+ #: includes/admin/tools.php:77
1121
+ msgid "Are you sure you want to reset the daily popular posts?"
1122
+ msgstr ""
1123
+
1124
+ #: includes/admin/tools.php:80
1125
+ msgid ""
1126
+ "This will reset the Top 10 tables. If you are running Top 10 on multisite "
1127
+ "then it will delete the popular posts across the entire network. This cannot "
1128
+ "be reversed. Make sure that your database has been backed up before "
1129
+ "proceeding"
1130
+ msgstr ""
1131
+
1132
+ #: includes/admin/tools.php:83
1133
+ msgid "Other tools"
1134
+ msgstr ""
1135
+
1136
+ #: includes/admin/tools.php:85
1137
+ msgid "Merge blog ID 0 and 1 post counts"
1138
+ msgstr ""
1139
+
1140
+ #: includes/admin/tools.php:85
1141
+ msgid "This will merge post counts for blog IDs 0 and 1. Proceed?"
1142
+ msgstr ""
1143
+
1144
+ #: includes/admin/tools.php:88
1145
+ msgid "This will merge post counts for posts with table entries of 0 and 1"
1146
+ msgstr ""
1147
+
1148
+ #: includes/admin/tools.php:91
1149
+ msgid "Merge duplicates across blog IDs"
1150
+ msgstr ""
1151
+
1152
+ #: includes/admin/tools.php:91
1153
+ msgid "This will delete the duplicate entries in the tables. Proceed?"
1154
+ msgstr ""
1155
+
1156
+ #: includes/admin/tools.php:94
1157
+ msgid ""
1158
+ "In older versions, the plugin created entries with duplicate post IDs. "
1159
+ "Clicking the button below will merge these duplicate IDs"
1160
+ msgstr ""
1161
+
1162
+ #: includes/cron.php:87
1163
+ msgid "Once Weekly"
1164
+ msgstr ""
1165
+
1166
+ #: includes/cron.php:91
1167
+ msgid "Once Fortnightly"
1168
+ msgstr ""
1169
+
1170
+ #: includes/cron.php:95
1171
+ msgid "Once Monthly"
1172
+ msgstr ""
1173
+
1174
+ #: includes/cron.php:99
1175
+ msgid "Once quarterly"
1176
+ msgstr ""
1177
+
1178
+ #: includes/deprecated.php:171
1179
+ msgid "<h3>Popular Posts</h3>"
1180
+ msgstr ""
1181
+
1182
+ #: includes/deprecated.php:172
1183
+ msgid "<h3>Daily Popular</h3>"
1184
+ msgstr ""
1185
+
1186
+ #: includes/modules/class-top-ten-count-widget.php:30
1187
+ msgid "Overall count [Top 10]"
1188
+ msgstr ""
1189
+
1190
+ #: includes/modules/class-top-ten-count-widget.php:32
1191
+ msgid "Display overall count"
1192
+ msgstr ""
1193
+
1194
+ #: includes/modules/class-top-ten-widget.php:30
1195
+ msgid "Popular Posts [Top 10]"
1196
+ msgstr ""
1197
+
1198
+ #: includes/modules/class-top-ten-widget.php:32
1199
+ msgid "Display popular posts"
1200
+ msgstr ""
1201
+
1202
+ #: includes/modules/class-top-ten-widget.php:85
1203
+ msgid "No. of posts"
1204
+ msgstr ""
1205
+
1206
+ #: includes/modules/class-top-ten-widget.php:90
1207
+ msgid "Offset"
1208
+ msgstr ""
1209
+
1210
+ #: includes/modules/class-top-ten-widget.php:96
1211
+ msgid "Custom time period (Enter below)"
1212
+ msgstr ""
1213
+
1214
+ #: includes/modules/class-top-ten-widget.php:100
1215
+ msgid "In days and hours (applies only to custom option above)"
1216
+ msgstr ""
1217
+
1218
+ #: includes/modules/class-top-ten-widget.php:102
1219
+ msgid "days"
1220
+ msgstr ""
1221
+
1222
+ #: includes/modules/class-top-ten-widget.php:105
1223
+ msgid "hours"
1224
+ msgstr ""
1225
+
1226
+ #: includes/modules/class-top-ten-widget.php:110
1227
+ msgid "Show count?"
1228
+ msgstr ""
1229
+
1230
+ #: includes/modules/class-top-ten-widget.php:115
1231
+ msgid "Show excerpt?"
1232
+ msgstr ""
1233
+
1234
+ #: includes/modules/class-top-ten-widget.php:120
1235
+ msgid "Show author?"
1236
+ msgstr ""
1237
+
1238
+ #: includes/modules/class-top-ten-widget.php:125
1239
+ msgid "Show date?"
1240
+ msgstr ""
1241
+
1242
+ #: includes/modules/class-top-ten-widget.php:129
1243
+ msgid "Thumbnail options"
1244
+ msgstr ""
1245
+
1246
+ #: includes/modules/class-top-ten-widget.php:131
1247
+ msgid "Thumbnails inline, before title"
1248
+ msgstr ""
1249
+
1250
+ #: includes/modules/class-top-ten-widget.php:132
1251
+ msgid "Thumbnails inline, after title"
1252
+ msgstr ""
1253
+
1254
+ #: includes/modules/class-top-ten-widget.php:133
1255
+ msgid "Only thumbnails, no text"
1256
+ msgstr ""
1257
+
1258
+ #: includes/modules/class-top-ten-widget.php:134
1259
+ msgid "No thumbnails, only text."
1260
+ msgstr ""
1261
+
1262
+ #: includes/modules/class-top-ten-widget.php:149
1263
+ msgid "Post types to include:"
1264
+ msgstr ""
1265
+
1266
+ #: includes/public/display-posts.php:92
1267
+ msgid ""
1268
+ "posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the "
1269
+ "posts only."
1270
+ msgstr ""
1271
+
1272
+ #: includes/public/display-posts.php:232
1273
+ #, php-format
1274
+ msgid ""
1275
+ "Popular posts by <a href=\"%1$s\" rel=\"nofollow\" %2$s>Top 10 plugin</a>"
1276
+ msgstr ""
1277
+
1278
+ #: includes/public/media.php:58
1279
+ msgid "thumb_timthumb argument has been deprecated"
1280
+ msgstr ""
1281
+
1282
+ #: includes/public/media.php:62
1283
+ msgid "thumb_timthumb_q argument has been deprecated"
1284
+ msgstr ""
1285
+
1286
+ #: includes/public/media.php:66
1287
+ msgid "filter argument has been deprecated"
1288
+ msgstr ""
1289
+
1290
+ #: includes/public/output-generator.php:240
1291
+ msgid " by "
1292
+ msgstr ""
1293
+
1294
+ #: includes/tracker.php:248
1295
+ msgid "Query variable based"
1296
+ msgstr ""
1297
+
1298
+ #: includes/tracker.php:249
1299
+ msgid "Uses query variables to record visits"
1300
+ msgstr ""
1301
+
1302
+ #: includes/tracker.php:253
1303
+ msgid "Ajaxurl based"
1304
+ msgstr ""
1305
+
1306
+ #: includes/tracker.php:254
1307
+ msgid ""
1308
+ "Uses admin-ajax.php which is inbuilt within WordPress to process the tracker"
1309
+ msgstr ""
languages/top-10-fa_IR.mo DELETED
Binary file
languages/top-10-fa_IR.po DELETED
@@ -1,310 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Top 10\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2017-01-03 10:39+0330\n"
6
- "PO-Revision-Date: \n"
7
- "Language-Team: Ajay DSouza <me@ajaydsouza.com>\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "X-Poedit-KeywordsList: __;_e;_c;__ngettext\n"
12
- "X-Poedit-Basepath: ..\n"
13
- "X-Generator: Poedit 1.8.11\n"
14
- "X-Poedit-SourceCharset: UTF-8\n"
15
- "Last-Translator: \n"
16
- "Plural-Forms: nplurals=1; plural=0;\n"
17
- "Language: fa_IR\n"
18
- "X-Poedit-SearchPath-0: .\n"
19
- "X-Poedit-SearchPathExcluded-0: ../admin/wick\n"
20
-
21
- #: admin/admin-columns.php:30
22
- msgid "Total Views"
23
- msgstr "مجموع بازدید"
24
-
25
- #: admin/admin-columns.php:33
26
- msgid "Today's Views"
27
- msgstr "بازدید امروز"
28
-
29
- #: admin/admin-columns.php:36
30
- msgid "Views"
31
- msgstr "بازدیدها"
32
-
33
- #: admin/admin-dashboard.php:64
34
- msgid "View all daily popular posts"
35
- msgstr "نمایش همه پست‌های محبوب امروز"
36
-
37
- #: admin/admin-dashboard.php:66
38
- msgid "View all popular posts"
39
- msgstr "نمایش همه پست‌های محبوب"
40
-
41
- #: admin/admin-dashboard.php:72
42
- #, php-format
43
- msgid "Popular posts by <a href=\"%s\" target=\"_blank\">Top 10 plugin</a>"
44
- msgstr "مطالب محبوب توسط <a href=\"%s\" target=\"_blank\"> افزونه Top 10 </a>"
45
-
46
- #: admin/admin-dashboard.php:122 admin/class-stats.php:539
47
- msgid "Popular Posts"
48
- msgstr "مطالب محبوب"
49
-
50
- #: admin/admin-dashboard.php:127 admin/admin.php:461
51
- msgid "Daily Popular Posts"
52
- msgstr "مطالب محبوب امروز"
53
-
54
- #: admin/admin-metabox.php:137
55
- #, php-format
56
- msgid ""
57
- "You have %1$s installed. If you are trying to modify the thumbnail, then you "
58
- "will need to make the same change in the %1$s meta box on this page."
59
- msgstr ""
60
- "شما %1$s نصب کرده‌اید. اگر سعی دارید تصاویر بندانگشتی را ویرایش کنید, "
61
- "بنابراین لازم است همان تغییر را در %1$s متاباکس را در آن صفحه انجام دهید."
62
-
63
- #: admin/admin.php:199
64
- msgid "Options saved successfully. If enabled, the cache has been cleared."
65
- msgstr "تنظیمات با موفقیت ذخیره شد. اگر فعال شود، کَش پاک خواهد شد."
66
-
67
- #: admin/admin.php:202
68
- msgid ""
69
- "Left Thumbnails style selected. Post thumbnail location set to Inline before "
70
- "text."
71
- msgstr ""
72
- "استایل تصاویر بندانگشتی سمت چپ انتخاب شد. مکان تصویر بندانگشتی مطلب به صورت "
73
- "خطی پیش از متن تنظیم شد."
74
-
75
- #: admin/admin.php:205
76
- msgid "Text Only style selected. Thumbnails will not be displayed."
77
- msgstr "استایل فقط متن انتخاب شد. تصاویر بندانگشتی نمایش داده نخواهد شد."
78
-
79
- #: admin/admin.php:208
80
- #, php-format
81
- msgid "Pre-built thumbnail size selected. Thumbnail set to %1$d x %1$d."
82
- msgstr ""
83
- "سایز تصویر بندانگشتی ازپیش‌ساخته‌شده انتخاب شد. اندازه تصویر بندانگشتی %1$d x "
84
- "%1$d است."
85
-
86
- #: admin/admin.php:223
87
- msgid "Options set to Default."
88
- msgstr "تنظیمات پیش‌فرض فعال شد."
89
-
90
- #: admin/admin.php:230
91
- msgid "Top 10 popular posts reset"
92
- msgstr "ریست کردن مطالب محبوب Top 10"
93
-
94
- #: admin/admin.php:237
95
- msgid "Top 10 daily popular posts reset"
96
- msgstr "ریست کردن مطالب محبوب روزانه Top 10"
97
-
98
- #: admin/admin.php:245
99
- msgid "Duplicate rows cleaned from tables"
100
- msgstr "ردیف‌های تکراری از جدول‌ها حذف شد."
101
-
102
- #: admin/admin.php:253
103
- msgid "Post counts across blog IDs 0 and 1 have been merged"
104
- msgstr "شمارش مطلب در تمام آی‌دی‌های ۰ و ۱ ادغام شده‌اند."
105
-
106
- #: admin/admin.php:266
107
- msgid "Scheduled maintenance enabled / modified"
108
- msgstr "نگهداری برنامه فعال شد/ اصلاح شد."
109
-
110
- #: admin/admin.php:270
111
- msgid "Scheduled maintenance disabled"
112
- msgstr "نگهداری برنامه غیرفعال شد."
113
-
114
- #: admin/admin.php:308
115
- msgid "Counts from selected sites have been imported."
116
- msgstr "شمارش از سایت‌های منتخب وارد شد."
117
-
118
- #: admin/admin.php:333
119
- msgid ""
120
- "Selected tables have been deleted. Note that only imported tables have been "
121
- "deleted."
122
- msgstr ""
123
- "جدول‌های منتخب حذف شده‌اند. توجه داشته باشید که فقط جدول‌های واردشده حذف شده‌اند."
124
-
125
- #: admin/admin.php:449 admin/admin.php:452
126
- msgid "Top 10 Settings"
127
- msgstr "تنظیمات Top 10"
128
-
129
- #: admin/admin.php:449
130
- msgid "Top 10"
131
- msgstr "تاپ۱۰"
132
-
133
- #: admin/admin.php:457
134
- msgid "View Popular Posts"
135
- msgstr "نمایش مطالب محبوب"
136
-
137
- #: admin/admin.php:564
138
- msgid "Settings"
139
- msgstr "تنظیمات"
140
-
141
- #: admin/admin.php:586
142
- msgid "Support"
143
- msgstr "پشتیبانی"
144
-
145
- #: admin/admin.php:587
146
- msgid "Donate"
147
- msgstr "مشارکت مالی"
148
-
149
- #: admin/admin.php:588
150
- msgid "Contribute"
151
- msgstr "همکاری"
152
-
153
- #: admin/cache.php:19
154
- msgid "Top 10 cache has been cleared"
155
- msgstr "کش Top 10 پاک شده است."
156
-
157
- #: admin/class-stats.php:35
158
- msgid "popular_post"
159
- msgstr "پست_محبوب"
160
-
161
- #: admin/class-stats.php:36
162
- msgid "popular_posts"
163
- msgstr "پست_های_محبوب"
164
-
165
- #: admin/class-stats.php:243
166
- msgid "View"
167
- msgstr "نمایش"
168
-
169
- #: admin/class-stats.php:244
170
- msgid "Edit"
171
- msgstr "ویرایش"
172
-
173
- #: admin/class-stats.php:245
174
- msgid "Delete"
175
- msgstr "حذف"
176
-
177
- #: admin/class-stats.php:267
178
- msgid "Y/m/d g:i:s a"
179
- msgstr "Y/m/d g:i:s a"
180
-
181
- #: admin/class-stats.php:274
182
- #, php-format
183
- msgid "%s ago"
184
- msgstr "%s پیش"
185
-
186
- #: admin/class-stats.php:276
187
- msgid "Y/m/d"
188
- msgstr "Y/m/d"
189
-
190
- #: admin/class-stats.php:309
191
- msgid "Title"
192
- msgstr "عنوان"
193
-
194
- #: admin/class-stats.php:310
195
- msgid "Total visits"
196
- msgstr "مجموع نمایش‌ها"
197
-
198
- #: admin/class-stats.php:311
199
- msgid "Daily visits"
200
- msgstr "نمایش‌های روزانه"
201
-
202
- #: admin/class-stats.php:312
203
- msgid "Post type"
204
- msgstr "نوع مطلب"
205
-
206
- #: admin/class-stats.php:313
207
- msgid "Author"
208
- msgstr "نویسنده"
209
-
210
- #: admin/class-stats.php:314
211
- msgid "Date"
212
- msgstr "تاریخ"
213
-
214
- #: admin/class-stats.php:348
215
- msgid "Delete Count"
216
- msgstr "حذف شمارش"
217
-
218
- #: admin/class-stats.php:441
219
- msgid "Filter"
220
- msgstr "فیلتر"
221
-
222
- #: admin/class-stats.php:514
223
- msgid "Search Table"
224
- msgstr "فیلتر"
225
-
226
- #: includes/cron.php:74
227
- msgid "Once Weekly"
228
- msgstr "یک‌بار در هفته"
229
-
230
- #: includes/cron.php:78
231
- msgid "Once Fortnightly"
232
- msgstr "یک‌بار در دوهفته"
233
-
234
- #: includes/cron.php:82
235
- msgid "Once Monthly"
236
- msgstr "یک‌بار ماهانه"
237
-
238
- #: includes/cron.php:86
239
- msgid "Once quarterly"
240
- msgstr "سه‌ماه یک بار"
241
-
242
- #: includes/modules/class-top-10-widget.php:30
243
- msgid "Popular Posts [Top 10]"
244
- msgstr "مطالب محبوب [Top 10]"
245
-
246
- #: includes/modules/class-top-10-widget.php:32
247
- msgid "Display popular posts"
248
- msgstr "نمایش مطالب محبوب"
249
-
250
- #: includes/public/display-posts.php:92
251
- msgid ""
252
- "posts_only argument has been deprecated. Use get_tptn_pop_posts() to get the "
253
- "posts only."
254
- msgstr ""
255
- "شناسه posts_only از رده خارج شده است . فقط از get_tptn_pop_posts() برای "
256
- "دریافت پست‌ها استفاده کنید."
257
-
258
- #: includes/public/display-posts.php:229
259
- #, php-format
260
- msgid ""
261
- "Popular posts by <a href=\"%1$s\" rel=\"nofollow\" %2$s>Top 10 plugin</a>"
262
- msgstr ""
263
- "مطالب محبوب توسط <a href=\"%1$s\" rel=\"nofollow\" %2$s>افزونه تاپ۱۰</a>"
264
-
265
- #: includes/public/media.php:60
266
- msgid "thumb_timthumb argument has been deprecated"
267
- msgstr "شناسه thumb_timthumb از رده خارج شده است"
268
-
269
- #: includes/public/media.php:64
270
- msgid "thumb_timthumb_q argument has been deprecated"
271
- msgstr "شناسه thumb_timthumb_q از رده خارج شده است"
272
-
273
- #: includes/public/media.php:68
274
- msgid "filter argument has been deprecated"
275
- msgstr "شناسه filter از رده خارج شده است"
276
-
277
- #: includes/public/output-generator.php:238
278
- msgid " by "
279
- msgstr "به‌وسیله"
280
-
281
- #: includes/tracker.php:248
282
- msgid "Query variable based"
283
- msgstr "براساس مقدار کوئری"
284
-
285
- #: includes/tracker.php:249
286
- msgid "Uses query variables to record visits"
287
- msgstr "برای ذخیره نمایش‌ها از مقدار کوئری استفاده می‌کند"
288
-
289
- #: includes/tracker.php:253
290
- msgid "Ajaxurl based"
291
- msgstr "براساس نشانی ای‌جکس"
292
-
293
- #: includes/tracker.php:254
294
- msgid ""
295
- "Uses admin-ajax.php which is inbuilt within WordPress to process the tracker"
296
- msgstr ""
297
- "از admin-ajax.php که توسط وردپرس نوشته شده است برای کنترل پیگیری‌کننده "
298
- "استفاده می‌کند"
299
-
300
- #: top-10.php:94
301
- msgid "<h3>Popular Posts</h3>"
302
- msgstr "<h3>مطالب محبوب</h3>"
303
-
304
- #: top-10.php:95
305
- msgid "<h3>Daily Popular</h3>"
306
- msgstr "<h3>محبوب‌های روزانه</h3>"
307
-
308
- #: top-10.php:96
309
- msgid "No top posts yet"
310
- msgstr "هنوز مطلب محبوبی وجود ندارد"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: webberzone, Ajay
4
  Donate link: https://ajaydsouza.com/donate/
5
  Stable tag: trunk
6
  Requires at least: 4.1
7
- Tested up to: 4.7
8
  License: GPLv2 or later
9
 
10
  Track daily and total visits on your blog posts. Display the count as well as popular and trending posts.
@@ -13,9 +13,9 @@ Track daily and total visits on your blog posts. Display the count as well as po
13
 
14
  WordPress doesn't have an in-built system to track page views or displaying popular posts. [Top 10](https://webberzone.com/plugins/top-10/) is an easy to use, yet, powerful WordPress plugin that will count the number of page views of your posts, pages and any custom post types. You can then display the page view counts as well as display your most popular posts.
15
 
16
- Top 10 will add a widget that you can use to display the popular posts list.
17
 
18
- Although several similar plugins exist today, Top 10 is one of the most feature rich popular post plugins with support for thumbnails, shortcodes, widgets, custom post types and CSS styles. The inbuilt caching system also helps reduce server load by caching your popular posts output. The tracking uses ajax and is thus compatible with most popular caching plugins.
19
 
20
  Top 10 also has powerful API and is fully extendable with WordPress actions and filters to allow you easily extend the code base to add new features or tweak existing ones.
21
 
@@ -46,7 +46,7 @@ Top 10 is available for [translation directly on WordPress.org](https://translat
46
  = Contribute =
47
 
48
  Top 10 is also available on [Github](https://github.com/ajaydsouza/top-10)
49
- So, if you've got some cool feature that you'd like to implement into the plugin or a bug you've been able to fix, consider forking the project and sending me a pull request.
50
 
51
 
52
  == Screenshots ==
@@ -59,9 +59,8 @@ So, if you've got some cool feature that you'd like to implement into the plugin
59
  6. Top 10 options - Maintenance
60
  7. Top 10 widget options
61
  8. Top 10 Meta box on the Edit Post screen
62
- 9. WordPress Multisite: Import Top 10 v1.x counts
63
- 10. Reset count and tools
64
- 11. Top 10 - Popular posts view in Admin
65
 
66
  == Installation ==
67
 
@@ -88,7 +87,8 @@ So, if you've got some cool feature that you'd like to implement into the plugin
88
 
89
  == Frequently Asked Questions ==
90
 
91
- If your question isn't listed here, please create a new post at the [WordPress.org support forum](http://wordpress.org/support/plugin/top-10). It is the fastest way to get support as I monitor the forums regularly. I also provide [premium *paid* support via email](https://webberzone.com/support/).
 
92
 
93
 
94
  = How can I customise the output? =
@@ -119,7 +119,7 @@ The main CSS classes include:
119
 
120
  *daily* : If set to 1, then the shortcode will return the daily popular posts list
121
 
122
- In addition to these attributes, the shortcode can take all the options as attributes. To see the detailed list take a look at the function `tptn_default_options()` in **top-10.php** file
123
 
124
 
125
  `[tptn_views]` lets you display the number of visits. The plugin takes one optional attribute `daily` as follows:
@@ -165,6 +165,25 @@ add_filter( 'manage_edit-projects_sortable_columns', 'tptn_column_register_sorta
165
 
166
  == Changelog ==
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  = 2.4.4 =
169
 
170
  * Enhancements:
@@ -207,155 +226,12 @@ add_filter( 'manage_edit-projects_sortable_columns', 'tptn_column_register_sorta
207
  * `tptn_add_tracker` and `tptn_add_viewed_count` have been deprecated. These should no longer be needed with the new tracker option.
208
  * wick script in Settings page which was used for fetching category slugs. You should now use the category name (prompted automatically). Slugs will be automatically converted into names.
209
 
210
- = 2.3.2 =
211
-
212
- * Bug fixes:
213
- * Sanitized several unsanitized post and get requests
214
-
215
- * Deprecated:
216
- * External PHP file tracking option introduced in v2.3.0 in line with wordpress.org plugin repository listing requirements.
217
-
218
- = 2.3.1 =
219
-
220
- * Bug fixes:
221
- * Potential CSRF issue fixed in admin area
222
-
223
- = 2.3.0 =
224
-
225
- * Features:
226
- * Preliminary support for PolyLang
227
- * Search box and post type filter added in Admin &raquo; View Popular Posts screen
228
- * Link to Daily Popular posts screen under Top 10 menu in admin area
229
- * `post_types` parameter now supports comma-separated list of post types. To fetch all built-in post types use 'all'
230
- * New option to use the external and more efficient javascript file for tracking
231
- * New function `tptn_add_tracker` to manually include the tracking code. This is useful if your theme doesn't have `the_content` function that Top 10 filters to add the tracker code
232
-
233
- * Enhancements:
234
- * Viewing drafts will no longer increment the counter
235
- * When using the Left Thumbs style, each widget instance includes the CSS code to display the correct thumbnail size
236
-
237
- * Bug fixes:
238
- * Missing `DISTINCT` keyword in query resulting in duplicate entries in some cases
239
- * PHP Notice in Widget on empty search and 404 pages
240
- * Incorrect notice that Contextual Related Posts is installed on Edit Posts pages
241
- * `tptn_show_daily_pop_posts()` without arguments did not display daily posts
242
- * Using Exclude categories returned incorrect counts and excluded non-posts
243
- * Incorrect count on the Admin &raquo; View Popular Posts screen causing incorrect pagination
244
- * Incorrect thumbnail size being pulled out in some instances
245
- * Multiple widget instances incorrectly used the same cache
246
- * Incorrect text domain was initialised
247
-
248
- = 2.2.4 =
249
-
250
- * Enhancements:
251
- * Changed text domain to `top-10` in advance of translate.wordpress.org translation system
252
- * Improved support for WPML. If available, same language posts will be pulled by default. To restrict to the same language [add this code](https://gist.github.com/ajaydsouza/9b1bc56cec79295e784c) to your theme's functions.php file
253
-
254
- = 2.2.3 =
255
-
256
- * Bug fixes:
257
- * Shortcode with "exclude_categories" argument works again
258
-
259
- = 2.2.2 =
260
-
261
- * Bug fixes:
262
- * Fixed array declaration to support PHP < 5.4
263
-
264
- = 2.2.0 =
265
-
266
- * Features:
267
- * Caching system using the Transients API. By default the cache is refreshed every hour
268
- * Styles interface lets you select between No styles, Left Thumbs (previously the default style) and Text Only
269
- * Option to limit posts only with a specified date range
270
- * Option in Top 10 meta box to exclude display of popular posts in widget if needed
271
- * Option in Top 10 meta box to exclude post from popular posts list
272
- * Cleaner interface to view popular posts in the admin area
273
-
274
- * Enhancements:
275
- * `strict_limit` is true by default for `get_tptn_pop_posts()`
276
- * Option to turn off the meta box for everyone or just non-admins
277
- * Contributors & above can also update the visit count in the meta box if this is enabled for them
278
- * Category exclusion now works via a filter function vs. multiple lookups, thereby reducing the number of database queries
279
-
280
- * Bug fixes:
281
- * Potential bug when the $wp variable was not detected in rare situations
282
- * In rare cases category exclusion failed when `term_id` didn't match `term_taxonomy_id`
283
-
284
- * Deprecated:
285
- * `ald_tptn_rss`: Use `tptn_rss_filter` instead
286
- * `ald_tptn_hook` deprecated and renamed to `tptn_cron_hook`
287
- * `tptn_manage` and `tptn_manage_daily` which were used to render the admin popular posts screens
288
-
289
- = 2.1.0 =
290
-
291
- * Features:
292
- * New: Button in Top 10 settings page to merge posts across blog ID 0 and 1
293
- * New: Function & filter `get_tptn_pop_posts` that can be used to fetch the popular posts as an object or array. Perfect if you want to write custom code in your theme
294
- * New: Support for WPML to return the correct language ID. Thanks to Tony Flags' <a href="https://wordpress.org/support/topic/top-10-and-languages-in-wpml?replies=11#post-6622085">code snippet</a>.
295
- * New: Filter `tptn_list_count` to modify the formatted list count. See a <a href="https://gist.github.com/ajaydsouza/9f04c26814414a57fab4">working example</a>
296
- * New: Post types can now be selected in the widget. This allows you to select top posts by post type
297
-
298
- * Enhancements:
299
- * Modified: Plugin will attempt to pull the correct size image when fetching the first image in a post
300
- * Modified: Deprecated "Always display latest post count in the daily lists"
301
- * Modified: timthumb has been deprecated. The script is no longer packaged within Top 10
302
-
303
- * Bug fixes:
304
- * Fixed: Bug in tracking code when not using Ajax
305
- * Fixed: Bug in admin column did not check for the blog_id
306
- * Fixed: Bug where default thumbnail location was not correctly saved
307
- * Fixed: Incorrect thumbnail was pulled on attachment pages
308
- * Fixed: blog_id column of the database is correctly initialised as `DEFAULT '1'`
309
-
310
- = 2.0.3 =
311
-
312
- * Features:
313
- * New: Options to choose if you want to delete the Top 10 options and/or data when deleting the plugin
314
-
315
- * Bug fixes:
316
- * Fixed: Metabox update did not work properly in v2.0
317
- * Fixed: Duplicate include files
318
- * Modified: In the mySQL tables, the blog_id default value is set to 1
319
-
320
- = 2.0.2 =
321
-
322
- * Features:
323
- * New: Option to display the daily posts count from midnight. This is enabled by default and mimics the original behaviour of the counter in Top 10 v1.x
324
-
325
- * Enhancements:
326
- * Modified: Posts are tracked hourly based on the time of the blog and not GMT. This was also the default behaviour of the counter in Top 10 v1.x
327
-
328
- * Bug fixes:
329
- * Fixed: Default thumbnail location saved correctly on the Settings page.
330
-
331
- = 2.0.1 =
332
-
333
- * Bug fixes
334
- * 500/503 errors caused by 2.0.0
335
-
336
- = 2.0.0 =
337
-
338
- * Features:
339
- * New: Multisite support. If you're using multisite and have previously activated Top 10 on individual blogs in the network, then head over to **Top 10 Settings** and import the counts from the old Top 10 1.x tables to the new Top 10 v2.0 tables
340
- * New: Fully extendable lookup query for the top lists. Now you can create your own functions in functions.php or in addon plugins to modify the mySQL query
341
- * New: Option to use any of the inbuilt thumbnail sizes or create your own custom image size. If a custom size is chosen, then the plugin uses `add_image_size` to register the custom size. You will need to resize your thumbnails after activating this option
342
- * New: Actions and filters in the Top 10 Settings page and in the widget which allows for addons to add more settings
343
-
344
- * Enhancements:
345
- * Modified: Post tracking is now done on an hourly basis. Date limiting is also on an hourly basis. So, 1 day is actually the last 24 hours and not from midnight anymore!
346
- * Modified: Update and View counts now use query variables instead of external JavaScript files. Check http://goo.gl/yemvyM for sample functions to restore the old method
347
- * Modified: Activating the default styles option will automatically set the thumbnail width and height to 65px, disable author and excerpt and enable crop mode for the thumbnails
348
-
349
- * Bug fixes:
350
- * Fixed: Fix schedule overwrite for the cron job
351
- * Fixed: Incorrect permission lookup in the metabox
352
-
353
  For previous changelog entries, please refer to the separate changelog.txt file
354
 
355
 
356
  == Upgrade Notice ==
357
 
358
- = 2.4.0 =
359
- * Major release. New features and several bug fixes and a new tracker. Please do verify your settings after the upgrade.
360
  Check the Changelog for more details
361
 
4
  Donate link: https://ajaydsouza.com/donate/
5
  Stable tag: trunk
6
  Requires at least: 4.1
7
+ Tested up to: 4.9
8
  License: GPLv2 or later
9
 
10
  Track daily and total visits on your blog posts. Display the count as well as popular and trending posts.
13
 
14
  WordPress doesn't have an in-built system to track page views or displaying popular posts. [Top 10](https://webberzone.com/plugins/top-10/) is an easy to use, yet, powerful WordPress plugin that will count the number of page views of your posts, pages and any custom post types. You can then display the page view counts as well as display your most popular posts.
15
 
16
+ Top 10 adds two widgets that you can use to display a list of popular posts and the counta cross all your blog posts.
17
 
18
+ Although several similar plugins exist today, Top 10 is one of the most feature-rich popular post plugins with support for thumbnails, shortcodes, widgets, custom post types and CSS styles. The inbuilt caching system also helps reduce server load by caching your popular posts output. The tracking uses ajax and is thus compatible with most popular caching plugins.
19
 
20
  Top 10 also has powerful API and is fully extendable with WordPress actions and filters to allow you easily extend the code base to add new features or tweak existing ones.
21
 
46
  = Contribute =
47
 
48
  Top 10 is also available on [Github](https://github.com/ajaydsouza/top-10)
49
+ So, if you've got some cool feature that you'd like to implement into the plugin or a bug you've been able to fix, consider forking the project and sending me a pull request. Please don't use that for support requests.
50
 
51
 
52
  == Screenshots ==
59
  6. Top 10 options - Maintenance
60
  7. Top 10 widget options
61
  8. Top 10 Meta box on the Edit Post screen
62
+ 9. Reset count and tools
63
+ 10. Top 10 - Popular posts view in Admin
 
64
 
65
  == Installation ==
66
 
87
 
88
  == Frequently Asked Questions ==
89
 
90
+ Check out the [FAQ on the plugin page](http://wordpress.org/plugins/top-10/faq/) and the [FAQ on the WebberZone knowledgebase](https://webberzone.com/support/section/top-10/).
91
+ It is the fastest way to get support as I monitor the forums regularly. I also provide [premium *paid* support via email](https://webberzone.com/support/).
92
 
93
 
94
  = How can I customise the output? =
119
 
120
  *daily* : If set to 1, then the shortcode will return the daily popular posts list
121
 
122
+ In addition to these attributes, the shortcode can take all the options as attributes. To see the detailed list take a look at the function `tptn_register_settings()` in **includes/admin/register-settings**
123
 
124
 
125
  `[tptn_views]` lets you display the number of visits. The plugin takes one optional attribute `daily` as follows:
165
 
166
  == Changelog ==
167
 
168
+ = 2.5.0 =
169
+
170
+ * Features:
171
+ * Upgrade old options to Settings API
172
+ * New widget to display the overall count i.e. visits across all your site posts
173
+ * Added a filter to override the number of days that maintenance considers to delete the database entries
174
+ * New option to disable tracking for logged in users. Find "Track logged-in users" under the "Counter/Tracker" tab in the settings screen
175
+
176
+ * Enhancements:
177
+ * Make $ajax_tptn_tracker global. Contributed by [@pkirk](https://github.com/pkirk)
178
+
179
+ * Bug fixes:
180
+ * Make sure that $post object is available in `tptn_pc_content` filter. Contributed by [@mtws](https://github.com/mtws)
181
+ * When editing Attachment post types, metabox should now save correctly
182
+ * Disable `top_ten_nonce` as it wasn't needed for front-end users and conflicted with caching plugins
183
+
184
+ * Deprecated:
185
+ * `tptn_default_options` (no replacement) and `tptn_read_options` (Use `tptn_get_settings` instead)
186
+
187
  = 2.4.4 =
188
 
189
  * Enhancements:
226
  * `tptn_add_tracker` and `tptn_add_viewed_count` have been deprecated. These should no longer be needed with the new tracker option.
227
  * wick script in Settings page which was used for fetching category slugs. You should now use the category name (prompted automatically). Slugs will be automatically converted into names.
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  For previous changelog entries, please refer to the separate changelog.txt file
230
 
231
 
232
  == Upgrade Notice ==
233
 
234
+ = 2.5.0 =
235
+ * Major release! Brand new settings interface so please do verify your settings after the upgrade. Several new features and bug fixes.
236
  Check the Changelog for more details
237
 
top-10.php CHANGED
@@ -11,16 +11,16 @@
11
  * @copyright 2008-2016 Ajay D'Souza
12
  *
13
  * @wordpress-plugin
14
- * Plugin Name: Top 10
15
- * Plugin URI: https://webberzone.com/plugins/top-10/
16
- * Description: Count daily and total visits per post and display the most popular posts based on the number of views
17
- * Version: 2.4.4
18
- * Author: Ajay D'Souza
19
- * Author URI: https://webberzone.com
20
- * License: GPL-2.0+
21
- * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
22
- * Text Domain: top-10
23
- * Domain Path: /languages
24
  * GitHub Plugin URI: https://github.com/WebberZone/top-10/
25
  */
26
 
@@ -67,7 +67,7 @@ if ( ! defined( 'TOP_TEN_PLUGIN_FILE' ) ) {
67
  /**
68
  * Global variable holding the current database version of Top 10
69
  *
70
- * @since 1.0
71
  *
72
  * @var string
73
  */
@@ -78,176 +78,45 @@ $tptn_db_version = '5.0';
78
  /**
79
  * Global variable holding the current settings for Top 10
80
  *
81
- * @since 1.9.3
82
  *
83
  * @var array
84
  */
85
  global $tptn_settings;
86
- $tptn_settings = tptn_read_options();
87
 
88
 
89
  /**
90
- * Default Options.
91
- */
92
- function tptn_default_options() {
93
-
94
- $title = __( '<h3>Popular Posts</h3>', 'top-10' );
95
- $title_daily = __( '<h3>Daily Popular</h3>', 'top-10' );
96
- $blank_output_text = __( 'No top posts yet', 'top-10' );
97
- $thumb_default = plugins_url( 'default.png' , __FILE__ );
98
-
99
- // Get relevant post types.
100
- $args = array(
101
- 'public' => true,
102
- '_builtin' => true,
103
- );
104
- $post_types = http_build_query( get_post_types( $args ), '', '&' );
105
-
106
- $tptn_settings = array(
107
-
108
- /* General options */
109
- 'activate_daily' => true, // Activate the daily count
110
- 'activate_overall' => true, // Activate overall count.
111
- 'cache' => false, // Enable Caching using Transienst API.
112
- 'cache_time' => HOUR_IN_SECONDS, // Cache for 1 Hour.
113
- 'daily_midnight' => true, // Start daily counts from midnight (default as old behaviour).
114
- 'daily_range' => '1', // Daily Popular will contain posts of how many days?
115
- 'hour_range' => '0', // Daily Popular will contain posts of how many hours?
116
- 'uninstall_clean_options' => true, // Cleanup options.
117
- 'uninstall_clean_tables' => false, // Cleanup tables.
118
- 'show_metabox' => true, // Show metabox to admins.
119
- 'show_metabox_admins' => false, // Limit to admins as well.
120
- 'show_credit' => false, // Add link to plugin page of my blog in top posts list.
121
-
122
- /* Counter and tracker options */
123
- 'add_to_content' => true, // Add post count to content (only on single posts).
124
- 'count_on_pages' => true, // Add post count to pages.
125
- 'add_to_feed' => false, // Add post count to feed (full).
126
- 'add_to_home' => false, // Add post count to home page.
127
- 'add_to_category_archives' => false, // Add post count to category archives.
128
- 'add_to_tag_archives' => false, // Add post count to tag archives.
129
- 'add_to_archives' => false, // Add post count to other archives.
130
-
131
- 'count_disp_form' => '(Visited %totalcount% times, %dailycount% visits today)', // Format to display the count.
132
- 'count_disp_form_zero' => 'No visits yet', // What to display where there are no hits?
133
- 'dynamic_post_count' => false, // Use JavaScript for displaying the post count.
134
-
135
- 'tracker_type' => 'query_based', // Tracker type.
136
- 'track_authors' => false, // Track Authors visits.
137
- 'track_admins' => true, // Track Admin visits.
138
- 'track_editors' => true, // Track Admin visits.
139
- 'pv_in_admin' => true, // Add an extra column on edit posts/pages to display page views?
140
- 'show_count_non_admins' => true, // Show counts to non-admins.
141
-
142
- /* Popular post list options */
143
- 'limit' => '10', // How many posts to display?
144
- 'how_old' => '0', // How old posts? Default is no limit.
145
- 'post_types' => $post_types, // WordPress custom post types.
146
- 'exclude_categories' => '', // Exclude these categories.
147
- 'exclude_cat_slugs' => '', // Exclude these categories (slugs).
148
- 'exclude_post_ids' => '', // Comma separated list of page / post IDs that are to be excluded in the results.
149
-
150
- 'title' => $title, // Title of Popular Posts.
151
- 'title_daily' => $title_daily, // Title of Daily Popular.
152
- 'blank_output' => false, // Blank output? Default is "blank Output test".
153
- 'blank_output_text' => $blank_output_text, // Blank output text.
154
-
155
- 'show_excerpt' => false, // Show description in list item.
156
- 'excerpt_length' => '10', // Length of characters.
157
- 'show_date' => false, // Show date in list item.
158
- 'show_author' => false, // Show author in list item.
159
- 'title_length' => '60', // Limit length of post title.
160
- 'disp_list_count' => true, // Display count in popular lists?
161
-
162
- 'link_new_window' => false, // Open links in new window.
163
- 'link_nofollow' => false, // Add no-follow to links.
164
- 'exclude_on_post_ids' => '', // Comma separate list of page/post IDs to not display related posts on.
165
-
166
- // List HTML options.
167
- 'before_list' => '<ul>', // Before the entire list.
168
- 'after_list' => '</ul>', // After the entire list.
169
- 'before_list_item' => '<li>', // Before each list item.
170
- 'after_list_item' => '</li>', // After each list item.
171
-
172
- /* Thumbnail options */
173
- 'post_thumb_op' => 'text_only', // Display only text in posts.
174
- 'thumb_size' => 'tptn_thumbnail', // Default thumbnail size.
175
- 'thumb_width' => '150', // Max width of thumbnails.
176
- 'thumb_height' => '150', // Max height of thumbnails.
177
- 'thumb_crop' => true, // Crop mode. default is hard crop.
178
- 'thumb_html' => 'html', // Use HTML or CSS for width and height of the thumbnail?
179
-
180
- 'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
181
- 'scan_images' => true, // Scan post for images.
182
- 'thumb_default' => $thumb_default, // Default thumbnail image.
183
- 'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
184
-
185
- /* Custom styles */
186
- 'custom_CSS' => '', // Custom CSS to style the output.
187
- 'include_default_style' => false, // Include default Top 10 style.
188
- 'tptn_styles' => 'no_style', // Defaault style is left thubnails.
189
-
190
- /* Maintenance cron */
191
- 'cron_on' => false, // Run cron daily?
192
- 'cron_hour' => '0', // Cron Hour.
193
- 'cron_min' => '0', // Cron Minute.
194
- 'cron_recurrence' => 'weekly', // Frequency of cron.
195
- );
196
-
197
- /**
198
- * Filters the default options array.
199
- *
200
- * @since 1.9.10.1
201
- *
202
- * @param array $tptn_settings Default options
203
- */
204
- return apply_filters( 'tptn_default_options', $tptn_settings );
205
- }
206
-
207
-
208
- /**
209
- * Function to read options from the database.
210
  *
211
- * @access public
212
- * @return array
213
  */
214
- function tptn_read_options() {
215
-
216
- $tptn_settings_changed = false;
217
-
218
- $defaults = tptn_default_options();
219
 
220
- $tptn_settings = array_map( 'stripslashes', (array) get_option( 'ald_tptn_settings' ) );
221
- unset( $tptn_settings[0] ); // Produced by the (array) casting when there's nothing in the DB.
222
-
223
- foreach ( $defaults as $k => $v ) {
224
- if ( ! isset( $tptn_settings[ $k ] ) ) {
225
- $tptn_settings[ $k ] = $v;
226
- $tptn_settings_changed = true;
227
- }
228
- }
229
- if ( true === $tptn_settings_changed ) {
230
- update_option( 'ald_tptn_settings', $tptn_settings );
231
- }
232
 
233
  /**
234
- * Filters the options array.
235
  *
236
- * @since 1.9.10.1
237
  *
238
- * @param array $tptn_settings Options read from the database
 
239
  */
240
- return apply_filters( 'tptn_read_options', $tptn_settings );
241
  }
242
 
243
 
244
  /**
245
  * Function to delete all rows in the posts table.
246
  *
247
- * @since 1.3
248
- * @param bool $daily Daily flag.
249
  */
250
- function tptn_trunc_count( $daily = false ) {
251
  global $wpdb;
252
 
253
  $table_name = $wpdb->base_prefix . 'top_ten';
@@ -256,58 +125,60 @@ function tptn_trunc_count( $daily = false ) {
256
  }
257
 
258
  $sql = "TRUNCATE TABLE $table_name";
259
- $wpdb->query( $sql );
260
  }
261
 
262
 
263
  /*
264
- ----------------------------------------------------------------------------*
265
  * Top 10 modules
266
  *---------------------------------------------------------------------------*
267
  */
268
 
269
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/activate-deactivate.php' );
270
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/public/display-posts.php' );
271
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/public/styles.php' );
272
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/public/output-generator.php' );
273
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/public/media.php' );
274
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/l10n.php' );
275
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/counter.php' );
276
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/tracker.php' );
277
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/cron.php' );
278
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/formatting.php' );
279
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/modules/shortcode.php' );
280
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/modules/exclusions.php' );
281
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/modules/taxonomies.php' );
282
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/modules/class-top-10-widget.php' );
 
 
283
 
284
 
285
  /*
286
- ----------------------------------------------------------------------------*
287
  * Dashboard and Administrative Functionality
288
  *---------------------------------------------------------------------------*
289
  */
290
 
291
  if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
292
 
293
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/admin.php' );
294
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/admin-metabox.php' );
295
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/admin-columns.php' );
296
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/admin-dashboard.php' );
297
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/class-stats.php' );
298
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/cache.php' );
 
 
 
 
299
 
300
  } // End admin.inc
301
 
302
  /*
303
- ----------------------------------------------------------------------------*
304
  * Deprecated functions
305
  *---------------------------------------------------------------------------*
306
  */
307
 
308
- require_once( TOP_TEN_PLUGIN_DIR . 'includes/deprecated.php' );
309
-
310
- if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
311
 
312
- require_once( TOP_TEN_PLUGIN_DIR . 'admin/deprecated.php' );
313
- }
11
  * @copyright 2008-2016 Ajay D'Souza
12
  *
13
  * @wordpress-plugin
14
+ * Plugin Name: Top 10
15
+ * Plugin URI: https://webberzone.com/plugins/top-10/
16
+ * Description: Count daily and total visits per post and display the most popular posts based on the number of views
17
+ * Version: 2.5.0
18
+ * Author: Ajay D'Souza
19
+ * Author URI: https://webberzone.com
20
+ * License: GPL-2.0+
21
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
22
+ * Text Domain: top-10
23
+ * Domain Path: /languages
24
  * GitHub Plugin URI: https://github.com/WebberZone/top-10/
25
  */
26
 
67
  /**
68
  * Global variable holding the current database version of Top 10
69
  *
70
+ * @since 1.0
71
  *
72
  * @var string
73
  */
78
  /**
79
  * Global variable holding the current settings for Top 10
80
  *
81
+ * @since 1.9.3
82
  *
83
  * @var array
84
  */
85
  global $tptn_settings;
86
+ $tptn_settings = tptn_get_settings();
87
 
88
 
89
  /**
90
+ * Get Settings.
91
+ *
92
+ * Retrieves all plugin settings
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  *
94
+ * @since 2.5.0
95
+ * @return array Top 10 settings
96
  */
97
+ function tptn_get_settings() {
 
 
 
 
98
 
99
+ $settings = get_option( 'tptn_settings' );
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  /**
102
+ * Settings array
103
  *
104
+ * Retrieves all plugin settings
105
  *
106
+ * @since 1.2.0
107
+ * @param array $settings Settings array
108
  */
109
+ return apply_filters( 'tptn_get_settings', $settings );
110
  }
111
 
112
 
113
  /**
114
  * Function to delete all rows in the posts table.
115
  *
116
+ * @since 1.3
117
+ * @param bool $daily Daily flag.
118
  */
119
+ function tptn_trunc_count( $daily = true ) {
120
  global $wpdb;
121
 
122
  $table_name = $wpdb->base_prefix . 'top_ten';
125
  }
126
 
127
  $sql = "TRUNCATE TABLE $table_name";
128
+ $wpdb->query( $sql ); // WPCS: unprepared SQL OK.
129
  }
130
 
131
 
132
  /*
133
+ *---------------------------------------------------------------------------*
134
  * Top 10 modules
135
  *---------------------------------------------------------------------------*
136
  */
137
 
138
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/register-settings.php';
139
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/activate-deactivate.php';
140
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/public/display-posts.php';
141
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/public/styles.php';
142
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/public/output-generator.php';
143
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/public/media.php';
144
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/l10n.php';
145
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/counter.php';
146
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/tracker.php';
147
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/cron.php';
148
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/formatting.php';
149
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/modules/shortcode.php';
150
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/modules/exclusions.php';
151
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/modules/taxonomies.php';
152
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/modules/class-top-ten-widget.php';
153
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/modules/class-top-ten-count-widget.php';
154
 
155
 
156
  /*
157
+ *---------------------------------------------------------------------------*
158
  * Dashboard and Administrative Functionality
159
  *---------------------------------------------------------------------------*
160
  */
161
 
162
  if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
163
 
164
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/admin.php';
165
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/settings-page.php';
166
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/save-settings.php';
167
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/help-tab.php';
168
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/tools.php';
169
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/admin-metabox.php';
170
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/admin-columns.php';
171
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/admin-dashboard.php';
172
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/class-top-ten-statistics-table.php';
173
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/admin/cache.php';
174
 
175
  } // End admin.inc
176
 
177
  /*
178
+ *---------------------------------------------------------------------------*
179
  * Deprecated functions
180
  *---------------------------------------------------------------------------*
181
  */
182
 
183
+ require_once TOP_TEN_PLUGIN_DIR . 'includes/deprecated.php';
 
 
184
 
 
 
uninstall.php CHANGED
@@ -8,27 +8,28 @@
8
  * @link https://webberzone.com
9
  * @copyright 2008-2016 Ajay D'Souza
10
  */
 
11
  // If this file is called directly, abort.
12
  if ( ! defined( 'WPINC' ) ) {
13
  die;
14
  }
15
 
16
- global $wpdb;
17
 
18
- $tptn_settings = get_option( 'ald_tptn_settings' );
19
 
20
- if ( true == $tptn_settings['uninstall_clean_tables'] ) {
21
 
22
- $table_name = $wpdb->base_prefix . 'top_ten';
23
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
24
 
25
- $wpdb->query( "DROP TABLE $table_name" );
26
- $wpdb->query( "DROP TABLE $table_name_daily" );
27
  delete_option( 'tptn_db_version' );
28
 
29
  }
30
 
31
- if ( true == $tptn_settings['uninstall_clean_options'] ) {
32
 
33
  if ( wp_next_scheduled( 'tptn_cron_hook' ) ) {
34
  wp_clear_scheduled_hook( 'tptn_cron_hook' );
8
  * @link https://webberzone.com
9
  * @copyright 2008-2016 Ajay D'Souza
10
  */
11
+
12
  // If this file is called directly, abort.
13
  if ( ! defined( 'WPINC' ) ) {
14
  die;
15
  }
16
 
17
+ global $wpdb;
18
 
19
+ $tptn_settings = get_option( 'ald_tptn_settings' );
20
 
21
+ if ( $tptn_settings['uninstall_clean_tables'] ) {
22
 
23
+ $table_name = $wpdb->base_prefix . 'top_ten';
24
  $table_name_daily = $wpdb->base_prefix . 'top_ten_daily';
25
 
26
+ $wpdb->query( "DROP TABLE $table_name" ); // WPCS: unprepared SQL OK.
27
+ $wpdb->query( "DROP TABLE $table_name_daily" ); // WPCS: unprepared SQL OK.
28
  delete_option( 'tptn_db_version' );
29
 
30
  }
31
 
32
+ if ( $tptn_settings['uninstall_clean_options'] ) {
33
 
34
  if ( wp_next_scheduled( 'tptn_cron_hook' ) ) {
35
  wp_clear_scheduled_hook( 'tptn_cron_hook' );