PluginProbe
WebberZone Top 10 — Popular Posts / 4.5.2
WebberZone Top 10 — Popular Posts v4.5.2
4.5.2 4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 All 118 releases
← All changes | includes/admin/class-settings.php +443 -54 4.3.4 → 4.5.2 View file →
@@ -21,12 +21,13 @@
21 21
22 22 /**
23 23 * Class to register the settings.
24 24 *
25 - * @since 3.3.0
25 + * @since 3.3.0
26 26 */
27 27 class Settings {
28 28
29 +
29 30 /**
30 31 * Settings API.
31 32 *
32 33 * @since 3.3.0
@@ -98,13 +99,14 @@
98 99 * @since 3.3.0
99 100 */
100 101 public function initialise_settings() {
101 102 $props = array(
102 - 'default_tab' => 'general',
103 + 'default_tab' => 'features',
103 104 'help_sidebar' => $this->get_help_sidebar(),
104 105 'help_tabs' => $this->get_help_tabs(),
105 106 'admin_footer_text' => $this->get_admin_footer_text(),
106 107 'menus' => $this->get_menus(),
108 + 'version' => TOP_TEN_VERSION,
107 109 );
108 110
109 111 $args = array(
110 112 'props' => $props,
@@ -131,9 +133,15 @@
131 133 'success_message' => esc_html__( 'Settings updated.', 'top-10' ),
132 134 'save_changes' => esc_html__( 'Save Changes', 'top-10' ),
133 135 'reset_settings' => esc_html__( 'Reset all settings', 'top-10' ),
134 136 'reset_button_confirm' => esc_html__( 'Do you really want to reset all these settings to their default values?', 'top-10' ),
135 - 'checkbox_modified' => esc_html__( 'Modified from default setting', 'top-10' ),
137 + 'modified_field' => esc_html__( 'Modified from default setting', 'top-10' ),
138 + 'modified_legend' => esc_html__( 'Setting modified from its default value', 'top-10' ),
139 + 'default_label' => esc_html__( 'Default', 'top-10' ),
140 + 'default_none' => esc_html__( 'None', 'top-10' ),
141 + 'repeater_move_up' => esc_html__( 'Move item up', 'top-10' ),
142 + 'repeater_move_down' => esc_html__( 'Move item down', 'top-10' ),
143 + 'repeater_remove_item' => esc_html__( 'Remove item', 'top-10' ),
136 144 );
137 145
138 146 /**
139 147 * Filter the array containing the settings' sections.
@@ -174,8 +182,9 @@
174 182 * @return array Settings array
175 183 */
176 184 public static function get_settings_sections() {
177 185 $settings_sections = array(
186 + 'features' => __( 'Features', 'top-10' ),
178 187 'general' => __( 'General', 'top-10' ),
179 188 'counter' => __( 'Counter/Tracker', 'top-10' ),
180 189 'list' => __( 'Posts list', 'top-10' ),
181 190 'thumbnail' => __( 'Thumbnail', 'top-10' ),
@@ -195,8 +204,159 @@
195 204 }
196 205
197 206
198 207 /**
208 + * Raw defaults for every registered setting, keyed by option ID.
209 + *
210 + * Must exactly match what `tptn_settings_defaults()` computes from
211 + * {@see self::get_registered_settings()}, but without building the full
212 + * (translated) field definitions. Values are pre-normalized: checkboxes are
213 + * `1`/`0`, not `true`/`false`. Computed defaults (e.g. `thumb_default`) are
214 + * represented as `''` here since their real value cannot be known statically.
215 + *
216 + * @since 4.4.2
217 + *
218 + * @return array<string, mixed> Default value for every option ID.
219 + */
220 + public static function get_defaults() {
221 + return array(
222 + 'features_header' => '',
223 + 'features_display_header' => '',
224 + 'features_performance_header' => '',
225 + 'enable_blocks' => 1,
226 + 'enable_legacy_widgets' => 1,
227 + 'enable_rest_api' => 1,
228 + 'enable_query_block' => 1,
229 + 'enable_featured_image_block' => 1,
230 + 'enable_popular_posts_pro_block' => 1,
231 + 'enable_page_builders' => 1,
232 + 'enable_popular_authors' => 1,
233 + 'features_tracking_header' => '',
234 + 'enable_feed' => 1,
235 + 'enable_fast_tracker' => 1,
236 + 'enable_sitewide_tracking' => 1,
237 + 'features_data_header' => '',
238 + 'enable_daily_table_rollup' => 1,
239 + 'features_admin_header' => '',
240 + 'features_api_header' => '',
241 + 'enable_pro_dashboard_widgets' => 1,
242 + 'enable_lazy_load' => 1,
243 + 'cache' => 1,
244 + 'cache_time' => HOUR_IN_SECONDS,
245 + 'lazy_load' => 0,
246 + 'uninstall_clean_options' => 1,
247 + 'uninstall_clean_tables' => 0,
248 + 'show_credit' => 0,
249 + 'admin_header' => '',
250 + 'show_metabox' => 1,
251 + 'show_metabox_admins' => 0,
252 + 'pv_in_admin' => 1,
253 + 'admin_column_post_types' => 'post,page',
254 + 'show_count_non_admins' => 1,
255 + 'show_dashboard_to_roles' => 'administrator',
256 + 'show_admin_bar' => 1,
257 + 'query_optimization' => '',
258 + 'max_execution_time' => 3000,
259 + 'counter_header' => '',
260 + 'add_to' => 'single,page',
261 + 'count_disp_form' => 'Visited %totalcount% times, %dailycount% visit(s) today',
262 + 'count_disp_form_zero' => 'No visits yet',
263 + 'number_format_count' => 1,
264 + 'number_format_style' => 'full',
265 + 'daily_midnight' => 1,
266 + 'range_desc' => '',
267 + 'daily_range' => '1',
268 + 'hour_range' => '0',
269 + 'dynamic_post_count' => 0,
270 + 'exclude_on_post_ids' => '',
271 + 'tracker_header' => '',
272 + 'trackers' => 'overall,daily',
273 + 'tracker_type' => 'query_based',
274 + 'tracking_method' => 'funnel',
275 + 'tracker_all_pages' => 0,
276 + 'track_sitewide' => 0,
277 + 'track_feed_views' => 0,
278 + 'track_users' => 'authors,editors,admins',
279 + 'logged_in' => 1,
280 + 'no_bots' => 0,
281 + 'debug_mode' => 0,
282 + 'use_global_settings' => 0,
283 + 'limit' => '10',
284 + 'how_old' => '0',
285 + 'post_types' => 'post',
286 + 'exclusion_header' => '',
287 + 'exclude_front' => 0,
288 + 'exclude_current_post' => 0,
289 + 'exclude_post_ids' => '',
290 + 'exclude_cat_slugs' => '',
291 + 'exclude_categories' => '',
292 + 'exclude_terms_include_parents' => 'none',
293 + 'exclude_on_cat_slugs' => '',
294 + 'customize_output_header' => '',
295 + 'title' => '<h3>Popular posts:</h3>',
296 + 'title_daily' => '<h3>Currently trending:</h3>',
297 + 'blank_output' => 'blank',
298 + 'blank_output_text' => 'No top posts yet',
299 + 'show_excerpt' => 0,
300 + 'excerpt_length' => '10',
301 + 'show_date' => 0,
302 + 'show_author' => 0,
303 + 'disp_list_count' => 0,
304 + 'show_ratings' => '',
305 + 'title_length' => '60',
306 + 'link_new_window' => 0,
307 + 'link_nofollow' => 0,
308 + 'html_wrapper_header' => '',
309 + 'before_list' => '<ul>',
310 + 'after_list' => '</ul>',
311 + 'before_list_item' => '<li>',
312 + 'after_list_item' => '</li>',
313 + 'post_thumb_op' => 'text_only',
314 + 'thumb_size' => 'tptn_thumbnail',
315 + 'thumb_width' => '250',
316 + 'thumb_height' => '250',
317 + 'thumb_crop' => 1,
318 + 'thumb_create_sizes' => 1,
319 + 'thumb_html' => 'html',
320 + 'thumb_meta' => 'post-image',
321 + 'scan_images' => 1,
322 + 'thumb_default_show' => 1,
323 + 'thumb_default' => '',
324 + 'tptn_styles' => 'no_style',
325 + 'custom_css' => '',
326 + 'cron_on' => 0,
327 + 'maintenance_days' => 0,
328 + 'log_retention_days' => 0,
329 + 'cron_range_desc' => '',
330 + 'cron_hour' => '0',
331 + 'cron_min' => '0',
332 + 'cron_recurrence' => 'weekly',
333 + 'feed_permalink_overall' => 'popular-posts',
334 + 'feed_permalink_daily' => 'popular-posts-daily',
335 + 'feed_limit' => '10',
336 + 'feed_daily_range' => '1',
337 + 'feed_category_slugs' => '',
338 + 'wzpa_number' => 10,
339 + 'wzpa_daily_range' => 1,
340 + 'wzpa_hour_range' => 0,
341 + 'wzpa_optioncount' => 0,
342 + 'wzpa_show_postcount' => 0,
343 + 'wzpa_show_fullname' => 0,
344 + 'wzpa_show_avatar' => 0,
345 + 'wzpa_exclude_admin' => 0,
346 + 'wzpa_post_type' => 'post',
347 + 'wzpa_cache' => 1,
348 + 'wzpa_styles_desc' => '',
349 + 'wzpa_styles' => 'no_style',
350 + 'wzpa_html_wrapper_header' => '',
351 + 'wzpa_before_list' => '<ul>',
352 + 'wzpa_after_list' => '</ul>',
353 + 'wzpa_before_list_item' => '<li>',
354 + 'wzpa_after_list_item' => '</li>',
355 + );
356 + }
357 +
358 + /**
199 359 * Retrieve the array of plugin settings
200 360 *
201 361 * @since 3.3.0
202 362 *
@@ -245,8 +405,16 @@
245 405 'desc' => esc_html__( 'Enter the number of seconds to cache the output.', 'top-10' ),
246 406 'type' => 'text',
247 407 'default' => HOUR_IN_SECONDS,
248 408 ),
409 + 'lazy_load' => array(
410 + 'id' => 'lazy_load',
411 + 'name' => esc_html__( 'Lazy load popular posts', 'top-10' ),
412 + 'desc' => esc_html__( 'Load popular posts using JavaScript when the list is about to enter the viewport. This speeds up initial page loads and lets full-page caches serve fresh lists. Search engines may not index links loaded this way. Applies to content, shortcodes, widgets and the Popular Posts block. Use lazy_load="0" in the shortcode or block attributes to disable it per instance. Not applied on feeds or AMP pages.', 'top-10' ),
413 + 'type' => 'checkbox',
414 + 'default' => false,
415 + 'pro' => true,
416 + ),
249 417 'uninstall_clean_options' => array(
250 418 'id' => 'uninstall_clean_options',
251 419 'name' => esc_html__( 'Delete options on uninstall', 'top-10' ),
252 420 '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' ),
@@ -409,8 +577,19 @@
409 577 'desc' => esc_html__( 'Activating this option will convert the post counts into a number format based on the locale', 'top-10' ),
410 578 'type' => 'checkbox',
411 579 'default' => true,
412 580 ),
581 + 'number_format_style' => array(
582 + 'id' => 'number_format_style',
583 + 'name' => esc_html__( 'Number format style', 'top-10' ),
584 + 'desc' => esc_html__( 'Select Abbreviated to display large view counts in a compact form, e.g. 1.2k or 3.4M, wherever counts are displayed. Full displays the complete number.', 'top-10' ),
585 + 'type' => 'select',
586 + 'default' => 'full',
587 + 'options' => array(
588 + 'full' => esc_html__( 'Full', 'top-10' ),
589 + 'abbreviated' => esc_html__( 'Abbreviated (1.2k, 3.4M)', 'top-10' ),
590 + ),
591 + ),
413 592 'daily_midnight' => array(
414 593 'id' => 'daily_midnight',
415 594 'name' => esc_html__( 'Start daily counts at midnight', 'top-10' ),
416 595 'desc' => esc_html__( 'The daily counter displays visits starting at midnight. This option is enabled by default, similar to most standard counters. If you disable this option, you can use the hourly setting in the next option.', 'top-10' ),
@@ -496,8 +675,16 @@
496 675 'desc' => esc_html__( 'This will load the tracker js on all pages. Helpful if you are running minification/concatenation plugins.', 'top-10' ),
497 676 'type' => 'checkbox',
498 677 'default' => false,
499 678 ),
679 + 'track_sitewide' => array(
680 + 'id' => 'track_sitewide',
681 + 'name' => esc_html__( 'Track site-wide views', 'top-10' ),
682 + 'desc' => esc_html__( 'Track views for the front page, posts page, archives, and search results in addition to individual posts and pages. Site-wide contexts use fixed reserved IDs in the shared Top 10 tables: front page = PHP_INT_MAX; home page = PHP_INT_MAX - 1; search = PHP_INT_MAX - 2; category = PHP_INT_MAX - 4; tag = PHP_INT_MAX - 5; taxonomy = PHP_INT_MAX - 6; author = PHP_INT_MAX - 7; post type archive = PHP_INT_MAX - 8; date archive = PHP_INT_MAX - 9; archive = PHP_INT_MAX - 10; other = PHP_INT_MAX - 11. These IDs are the same on every site and counts remain separate by site (blog ID).', 'top-10' ),
683 + 'type' => 'checkbox',
684 + 'default' => false,
685 + 'pro' => true,
686 + ),
500 687 'track_feed_views' => array(
501 688 'id' => 'track_feed_views',
502 689 'name' => esc_html__( 'Track feed views', 'top-10' ),
503 690 'desc' => esc_html__( 'Count post views from RSS/Atom feed readers via a tracking pixel. Views are added to the post\'s regular view count. Note: some feed readers block remote images by default; views are only counted when the reader loads images.', 'top-10' ),
@@ -737,8 +924,20 @@
737 924 'desc' => '',
738 925 'type' => 'checkbox',
739 926 'default' => false,
740 927 ),
928 + 'show_ratings' => array(
929 + 'id' => 'show_ratings',
930 + 'name' => esc_html__( 'Show WP-PostRatings rating', 'top-10' ),
931 + 'desc' => esc_html__( 'Display the rating from the WP-PostRatings plugin with each post in the list. This option only takes effect when the WP-PostRatings plugin is active. The Star rating output, including the text shown alongside the stars, comes from the "Ratings Voted Text" template which you can edit under WP-PostRatings » Settings » Templates.', 'top-10' ),
932 + 'type' => 'select',
933 + 'default' => '',
934 + 'options' => array(
935 + '' => esc_html__( 'Do not display', 'top-10' ),
936 + 'stars' => esc_html__( 'Star rating', 'top-10' ),
937 + 'score' => esc_html__( 'Average score, e.g. 4.25', 'top-10' ),
938 + ),
939 + ),
741 940 'title_length' => array(
742 941 'id' => 'title_length',
743 942 'name' => esc_html__( 'Limit post title length (in characters)', 'top-10' ),
744 943 'desc' => '',
@@ -906,14 +1105,15 @@
906 1105 'type' => 'checkbox',
907 1106 'default' => true,
908 1107 ),
909 1108 'thumb_default' => array(
910 - 'id' => 'thumb_default',
911 - 'name' => esc_html__( 'Default thumbnail', 'top-10' ),
912 - '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' ),
913 - 'type' => 'file',
914 - 'default' => Display::get_default_thumbnail(),
915 - 'size' => 'large',
1109 + 'id' => 'thumb_default',
1110 + 'name' => esc_html__( 'Default thumbnail', 'top-10' ),
1111 + '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' ),
1112 + 'type' => 'file',
1113 + 'default' => Display::get_default_thumbnail(),
1114 + 'size' => 'large',
1115 + 'modified_indicator' => false,
916 1116 ),
917 1117 );
918 1118
919 1119 /**
@@ -947,9 +1147,9 @@
947 1147 'custom_css' => array(
948 1148 'id' => 'custom_css',
949 1149 'name' => esc_html__( 'Custom CSS', 'top-10' ),
950 1150 'desc' => sprintf(
951 - /* translators: 1: Opening a tag, 2: Closing a tag, 3: Opening code tage, 4. Closing code tag. */
1151 + /* translators: 1: Opening a tag, 2: Closing a tag, 3: Opening code tage, 4. Closing code tag. */
952 1152 esc_html__( 'Do not include %3$sstyle%4$s tags. Check out %1$sthis article%2$s for available CSS classes to style.', 'top-10' ),
953 1153 '<a href="' . esc_url( 'https://webberzone.com/support/knowledgebase/using-and-customising-top-10/' ) . '" target="_blank">',
954 1154 '</a>',
955 1155 '<code>',
@@ -984,10 +1184,11 @@
984 1184 'cron_on' => array(
985 1185 'id' => 'cron_on',
986 1186 'name' => esc_html__( 'Enable scheduled maintenance', 'top-10' ),
987 1187 'desc' => sprintf(
988 - /* translators: 1: Constant holding number of days data is stored. */
1188 + /* translators: 1: Constant holding number of days data is stored. */
989 1189 esc_html__( 'Regularly cleaning the database can enhance performance, especially for high-traffic blogs. Enabling maintenance will automatically delete entries older than %s days from the daily tables.', 'top-10' ),
1190 + /** This filter is documented in includes/admin/class-cron.php */
990 1191 '<strong>' . (int) apply_filters( 'tptn_maintenance_days', TOP_TEN_STORE_DATA ) . '</strong>'
991 1192 ),
992 1193 'type' => 'checkbox',
993 1194 'default' => false,
@@ -995,9 +1196,9 @@
995 1196 'maintenance_days' => array(
996 1197 'id' => 'maintenance_days',
997 1198 'name' => esc_html__( 'Daily table retention period', 'top-10' ),
998 1199 'desc' => sprintf(
999 - /* translators: 1: Constant holding number of days data is stored. */
1200 + /* translators: 1: Constant holding number of days data is stored. */
1000 1201 esc_html__( 'Enter the number of days to retain data in the daily tables before scheduled maintenance removes older entries. Enter 0 to use the default value of %s days.', 'top-10' ),
1001 1202 '<strong>' . TOP_TEN_STORE_DATA . '</strong>'
1002 1203 ),
1003 1204 'type' => 'number',
@@ -1009,9 +1210,9 @@
1009 1210 'log_retention_days' => array(
1010 1211 'id' => 'log_retention_days',
1011 1212 'name' => esc_html__( 'Visits log retention period', 'top-10' ),
1012 1213 'desc' => sprintf(
1013 - /* translators: 1: Default number of days for visits log retention. */
1214 + /* translators: 1: Default number of days for visits log retention. */
1014 1215 esc_html__( 'Enter the number of days to retain raw visit rows in the visits log table. The log stores one row per visit and grows faster than the daily table, so a shorter window is recommended. Enter 0 to use the default value of %s days.', 'top-10' ),
1015 1216 '<strong>' . TOP_TEN_LOG_STORE_DATA . '</strong>'
1016 1217 ),
1017 1218 'type' => 'number',
@@ -1140,11 +1341,185 @@
1140 1341 return apply_filters( self::$prefix . '_settings_feed', $settings );
1141 1342 }
1142 1343
1143 1344 /**
1345 + * Retrieve the array of Features settings
1346 + *
1347 + * All features are enabled by default. Disabling a feature stops its
1348 + * classes from being loaded on any request.
1349 + *
1350 + * @since 4.4.0
1351 + *
1352 + * @return array Features settings array
1353 + */
1354 + public static function settings_features() {
1355 + $settings = array(
1356 + 'features_header' => array(
1357 + 'id' => 'features_header',
1358 + 'name' => '<h3>' . esc_html__( 'Features', 'top-10' ) . '</h3>',
1359 + 'desc' => esc_html__( 'Turn off any features you do not use and the plugin will not load their code. All features are enabled by default. Blocks that are disabled will render as empty on the front end and show an unavailable notice in the block editor.', 'top-10' ),
1360 + 'type' => 'header',
1361 + ),
1362 + 'features_display_header' => array(
1363 + 'id' => 'features_display_header',
1364 + 'name' => '<h3>' . esc_html__( 'Content and display', 'top-10' ) . '</h3>',
1365 + 'desc' => esc_html__( 'Control the blocks, widgets, page builders, and author tools registered by Top 10.', 'top-10' ),
1366 + 'type' => 'header',
1367 + ),
1368 + 'enable_blocks' => array(
1369 + 'id' => 'enable_blocks',
1370 + 'name' => esc_html__( 'Popular Posts and Post Count blocks', 'top-10' ),
1371 + 'desc' => esc_html__( 'Registers the free Popular Posts and Post Count blocks for the block editor.', 'top-10' ),
1372 + 'type' => 'checkbox',
1373 + 'default' => 1,
1374 + ),
1375 + 'enable_legacy_widgets' => array(
1376 + 'id' => 'enable_legacy_widgets',
1377 + 'name' => esc_html__( 'Legacy widgets', 'top-10' ),
1378 + 'desc' => esc_html__( 'Registers the classic Popular Posts and Views Count widgets. Disable this if you use blocks instead of classic widgets.', 'top-10' ),
1379 + 'type' => 'checkbox',
1380 + 'default' => 1,
1381 + ),
1382 + 'enable_query_block' => array(
1383 + 'id' => 'enable_query_block',
1384 + 'name' => esc_html__( 'Query block', 'top-10' ),
1385 + 'desc' => esc_html__( 'Registers the Top 10 Query block and the pre-built block patterns.', 'top-10' ),
1386 + 'type' => 'checkbox',
1387 + 'default' => 1,
1388 + 'pro' => true,
1389 + ),
1390 + 'enable_featured_image_block' => array(
1391 + 'id' => 'enable_featured_image_block',
1392 + 'name' => esc_html__( 'Featured Image block', 'top-10' ),
1393 + 'desc' => esc_html__( 'Extends the core Featured Image block with Top 10 options.', 'top-10' ),
1394 + 'type' => 'checkbox',
1395 + 'default' => 1,
1396 + 'pro' => true,
1397 + ),
1398 + 'enable_popular_posts_pro_block' => array(
1399 + 'id' => 'enable_popular_posts_pro_block',
1400 + 'name' => esc_html__( 'Popular Posts Pro block', 'top-10' ),
1401 + 'desc' => esc_html__( 'Registers the Popular Posts Pro block for the block editor.', 'top-10' ),
1402 + 'type' => 'checkbox',
1403 + 'default' => 1,
1404 + 'pro' => true,
1405 + ),
1406 + 'enable_page_builders' => array(
1407 + 'id' => 'enable_page_builders',
1408 + 'name' => esc_html__( 'Page builder integrations', 'top-10' ),
1409 + 'desc' => esc_html__( 'Registers the Popular Posts elements for Elementor, Bricks Builder, and WPBakery Page Builder.', 'top-10' ),
1410 + 'type' => 'checkbox',
1411 + 'default' => 1,
1412 + 'pro' => true,
1413 + ),
1414 + 'enable_popular_authors' => array(
1415 + 'id' => 'enable_popular_authors',
1416 + 'name' => esc_html__( 'Popular Authors', 'top-10' ),
1417 + 'desc' => esc_html__( 'Enables the Popular Authors blocks, shortcodes, widgets and settings.', 'top-10' ),
1418 + 'type' => 'checkbox',
1419 + 'default' => 1,
1420 + 'pro' => true,
1421 + ),
1422 + 'features_performance_header' => array(
1423 + 'id' => 'features_performance_header',
1424 + 'name' => '<h3>' . esc_html__( 'Performance', 'top-10' ) . '</h3>',
1425 + 'desc' => esc_html__( 'Control optional output performance modules.', 'top-10' ),
1426 + 'type' => 'header',
1427 + ),
1428 + 'enable_lazy_load' => array(
1429 + 'id' => 'enable_lazy_load',
1430 + 'name' => esc_html__( 'Lazy-load module', 'top-10' ),
1431 + 'desc' => esc_html__( 'Loads the lazy-loading module and its REST endpoint. Disable this to remove lazy-loading support, including per-shortcode and per-block lazy_load overrides. Requires REST API endpoints to be enabled.', 'top-10' ),
1432 + 'type' => 'checkbox',
1433 + 'default' => 1,
1434 + 'pro' => true,
1435 + ),
1436 + 'features_tracking_header' => array(
1437 + 'id' => 'features_tracking_header',
1438 + 'name' => '<h3>' . esc_html__( 'Tracking and feeds', 'top-10' ) . '</h3>',
1439 + 'desc' => esc_html__( 'Control how Top 10 records views and provides popular posts feeds.', 'top-10' ),
1440 + 'type' => 'header',
1441 + ),
1442 + 'enable_feed' => array(
1443 + 'id' => 'enable_feed',
1444 + 'name' => esc_html__( 'Popular posts feeds', 'top-10' ),
1445 + 'desc' => esc_html__( 'Adds custom RSS feeds for overall and daily popular posts. The feed settings are on the Feed tab.', 'top-10' ),
1446 + 'type' => 'checkbox',
1447 + 'default' => 1,
1448 + ),
1449 + 'enable_fast_tracker' => array(
1450 + 'id' => 'enable_fast_tracker',
1451 + 'name' => esc_html__( 'Fast and High-traffic trackers', 'top-10' ),
1452 + 'desc' => esc_html__( 'Adds the Fast tracker and High-traffic tracker options to the Tracker type setting. If this is disabled while one of these trackers is in use, the tracker type will be reset to the default.', 'top-10' ),
1453 + 'type' => 'checkbox',
1454 + 'default' => 1,
1455 + 'pro' => true,
1456 + ),
1457 + 'enable_sitewide_tracking' => array(
1458 + 'id' => 'enable_sitewide_tracking',
1459 + 'name' => esc_html__( 'Site-wide tracking', 'top-10' ),
1460 + 'desc' => esc_html__( 'Enables the site-wide tracking feature. When enabled, turn on Track site-wide views under Counter/Tracker to count front pages, posts pages, archives, and searches.', 'top-10' ),
1461 + 'type' => 'checkbox',
1462 + 'default' => 1,
1463 + 'pro' => true,
1464 + ),
1465 + 'features_data_header' => array(
1466 + 'id' => 'features_data_header',
1467 + 'name' => '<h3>' . esc_html__( 'Data and maintenance', 'top-10' ) . '</h3>',
1468 + 'desc' => esc_html__( 'Control tools that manage and reduce stored view data.', 'top-10' ),
1469 + 'type' => 'header',
1470 + ),
1471 + 'enable_daily_table_rollup' => array(
1472 + 'id' => 'enable_daily_table_rollup',
1473 + 'name' => esc_html__( 'Daily table size reduction', 'top-10' ),
1474 + 'desc' => esc_html__( 'Enables the Reduce Daily Table Size tool and the wp top10 db rollup command for combining older hourly records.', 'top-10' ),
1475 + 'type' => 'checkbox',
1476 + 'default' => 1,
1477 + 'pro' => true,
1478 + ),
1479 + 'features_admin_header' => array(
1480 + 'id' => 'features_admin_header',
1481 + 'name' => '<h3>' . esc_html__( 'Administration', 'top-10' ) . '</h3>',
1482 + 'desc' => esc_html__( 'Control additional Top 10 administration features.', 'top-10' ),
1483 + 'type' => 'header',
1484 + ),
1485 + 'enable_pro_dashboard_widgets' => array(
1486 + 'id' => 'enable_pro_dashboard_widgets',
1487 + 'name' => esc_html__( 'Pro dashboard widgets', 'top-10' ),
1488 + 'desc' => esc_html__( 'Adds the enhanced Top 10 Pro widgets to the WordPress dashboard.', 'top-10' ),
1489 + 'type' => 'checkbox',
1490 + 'default' => 1,
1491 + 'pro' => true,
1492 + ),
1493 + 'features_api_header' => array(
1494 + 'id' => 'features_api_header',
1495 + 'name' => '<h3>' . esc_html__( 'API integrations', 'top-10' ) . '</h3>',
1496 + 'desc' => esc_html__( 'Control the Top 10 REST API endpoints used by integrations, tracking, blocks, and lazy loading.', 'top-10' ),
1497 + 'type' => 'header',
1498 + ),
1499 + 'enable_rest_api' => array(
1500 + 'id' => 'enable_rest_api',
1501 + 'name' => esc_html__( 'REST API endpoints', 'top-10' ),
1502 + 'desc' => esc_html__( 'Registers the top-10/v1 endpoints for popular posts, tracking, counters, blocks, and lazy loading. Keep enabled if your tracker type is REST-based or if your integrations or blocks use these endpoints.', 'top-10' ),
1503 + 'type' => 'checkbox',
1504 + 'default' => 1,
1505 + ),
1506 + );
1507 +
1508 + /**
1509 + * Filters the Features settings array
1510 + *
1511 + * @since 4.4.0
1512 + *
1513 + * @param array $settings Features settings array
1514 + */
1515 + return apply_filters( self::$prefix . '_settings_features', $settings );
1516 + }
1517 +
1518 + /**
1144 1519 * Get the various styles.
1145 1520 *
1146 - * @since 2.5.0
1521 + * @since 2.5.0
1147 1522 * @return array Style options.
1148 1523 */
1149 1524 public static function get_styles() {
1150 1525 $styles = array(
@@ -1179,9 +1554,9 @@
1179 1554 * Get User Roles.
1180 1555 *
1181 1556 * @since 4.0.0
1182 1557 *
1183 - * @param array $remove_roles Roles to remove.
1558 + * @param array $remove_roles Roles to remove.
1184 1559 * @return array User roles in the format 'role' => 'name'.
1185 1560 */
1186 1561 public static function get_user_roles( $remove_roles = array() ) {
1187 1562 // Get the global $wp_roles object using the wp_roles() function.
@@ -1222,9 +1597,9 @@
1222 1597 * Adding WordPress plugin action links.
1223 1598 *
1224 1599 * @since 3.3.0
1225 1600 *
1226 - * @param array $links Array of links.
1601 + * @param array $links Array of links.
1227 1602 * @return array
1228 1603 */
1229 1604 public function plugin_actions_links( $links ) {
1230 1605
@@ -1240,10 +1615,10 @@
1240 1615 * Add meta links on Plugins page.
1241 1616 *
1242 1617 * @since 3.3.0
1243 1618 *
1244 - * @param array $links Array of Links.
1245 - * @param string $file Current file.
1619 + * @param array $links Array of Links.
1620 + * @param string $file Current file.
1246 1621 * @return array
1247 1622 */
1248 1623 public function plugin_row_meta( $links, $file ) {
1249 1624
@@ -1265,18 +1640,18 @@
1265 1640 * @since 1.8.0
1266 1641 */
1267 1642 public function get_help_sidebar() {
1268 1643 $help_sidebar =
1269 - /* translators: 1: Plugin support site link. */
1270 - '<p>' . sprintf( __( 'For more information or how to get support visit the <a href="%s">support site</a>.', 'top-10' ), esc_url( 'https://webberzone.com/support/' ) ) . '</p>' .
1271 - /* translators: 1: WordPress.org support forums link. */
1272 - '<p>' . sprintf( __( 'Support queries should be posted in the <a href="%s">WordPress.org support forums</a>.', 'top-10' ), esc_url( 'https://wordpress.org/support/plugin/top-10' ) ) . '</p>' .
1273 - '<p>' . sprintf(
1274 - /* translators: 1: Github issues link, 2: Github plugin page link. */
1275 - __( '<a href="%1$s">Post an issue</a> on <a href="%2$s">GitHub</a> (bug reports only).', 'top-10' ),
1276 - esc_url( 'https://github.com/ajaydsouza/top-10/issues' ),
1277 - esc_url( 'https://github.com/ajaydsouza/top-10' )
1278 - ) . '</p>';
1644 + /* translators: 1: Plugin support site link. */
1645 + '<p>' . sprintf( __( 'For more information or how to get support visit the <a href="%s">support site</a>.', 'top-10' ), esc_url( 'https://webberzone.com/support/' ) ) . '</p>' .
1646 + /* translators: 1: WordPress.org support forums link. */
1647 + '<p>' . sprintf( __( 'Support queries should be posted in the <a href="%s">WordPress.org support forums</a>.', 'top-10' ), esc_url( 'https://wordpress.org/support/plugin/top-10' ) ) . '</p>' .
1648 + '<p>' . sprintf(
1649 + /* translators: 1: Github issues link, 2: Github plugin page link. */
1650 + __( '<a href="%1$s">Post an issue</a> on <a href="%2$s">GitHub</a> (bug reports only).', 'top-10' ),
1651 + esc_url( 'https://github.com/ajaydsouza/top-10/issues' ),
1652 + esc_url( 'https://github.com/ajaydsouza/top-10' )
1653 + ) . '</p>';
1279 1654
1280 1655 /**
1281 1656 * Filter to modify the help sidebar content.
1282 1657 *
@@ -1298,9 +1673,9 @@
1298 1673 'id' => 'tptn-settings-general-help',
1299 1674 'title' => esc_html__( 'General', 'top-10' ),
1300 1675 'content' =>
1301 1676 '<p><strong>' . esc_html__( 'This tab provides global settings for how Top 10 works across your site.', 'top-10' ) . '</strong></p>' .
1302 - '<p>' . esc_html__( 'Configure caching, uninstall behaviour, admin columns, the dashboard, and other high-level options. You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'top-10' ) . '</p>',
1677 + '<p>' . esc_html__( 'Configure caching, uninstall behaviour, admin columns, the dashboard, and other high-level options. You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'top-10' ) . '</p>',
1303 1678 ),
1304 1679 array(
1305 1680 'id' => 'tptn-settings-counter-help',
1306 1681 'title' => esc_html__( 'Counter / Tracker', 'top-10' ),
@@ -1305,9 +1680,9 @@
1305 1680 'id' => 'tptn-settings-counter-help',
1306 1681 'title' => esc_html__( 'Counter / Tracker', 'top-10' ),
1307 1682 'content' =>
1308 1683 '<p><strong>' . esc_html__( 'This tab controls how Top 10 tracks and displays view counts.', 'top-10' ) . '</strong></p>' .
1309 - '<p>' . esc_html__( 'Choose where to display view counts, how they are formatted, which visits are tracked, and how the tracker works (REST API, query variables, or Ajax).', 'top-10' ) . '</p>',
1684 + '<p>' . esc_html__( 'Choose where to display view counts, how they are formatted, which visits are tracked, and how the tracker works (REST API, query variables, or Ajax).', 'top-10' ) . '</p>',
1310 1685 ),
1311 1686 array(
1312 1687 'id' => 'tptn-settings-list-help',
1313 1688 'title' => esc_html__( 'Posts list', 'top-10' ),
@@ -1312,9 +1687,9 @@
1312 1687 'id' => 'tptn-settings-list-help',
1313 1688 'title' => esc_html__( 'Posts list', 'top-10' ),
1314 1689 'content' =>
1315 1690 '<p><strong>' . esc_html__( 'This tab controls the popular posts list output.', 'top-10' ) . '</strong></p>' .
1316 - '<p>' . esc_html__( 'Configure the number of posts, age of posts, post types, exclusions, and what information is shown (title, date, author, views, excerpts, and HTML wrappers).', 'top-10' ) . '</p>',
1691 + '<p>' . esc_html__( 'Configure the number of posts, age of posts, post types, exclusions, and what information is shown (title, date, author, views, excerpts, and HTML wrappers).', 'top-10' ) . '</p>',
1317 1692 ),
1318 1693 array(
1319 1694 'id' => 'tptn-settings-thumbnail-help',
1320 1695 'title' => esc_html__( 'Thumbnail', 'top-10' ),
@@ -1319,9 +1694,9 @@
1319 1694 'id' => 'tptn-settings-thumbnail-help',
1320 1695 'title' => esc_html__( 'Thumbnail', 'top-10' ),
1321 1696 'content' =>
1322 1697 '<p><strong>' . esc_html__( 'This tab manages thumbnail settings for the popular posts list.', 'top-10' ) . '</strong></p>' .
1323 - '<p>' . esc_html__( 'Choose whether thumbnails are displayed, select the image size, configure custom dimensions, cropping, the default thumbnail, and fallback behaviour when no thumbnail is found.', 'top-10' ) . '</p>',
1698 + '<p>' . esc_html__( 'Choose whether thumbnails are displayed, select the image size, configure custom dimensions, cropping, the default thumbnail, and fallback behaviour when no thumbnail is found.', 'top-10' ) . '</p>',
1324 1699 ),
1325 1700 array(
1326 1701 'id' => 'tptn-settings-styles-help',
1327 1702 'title' => esc_html__( 'Styles', 'top-10' ),
@@ -1326,9 +1701,9 @@
1326 1701 'id' => 'tptn-settings-styles-help',
1327 1702 'title' => esc_html__( 'Styles', 'top-10' ),
1328 1703 'content' =>
1329 1704 '<p><strong>' . esc_html__( 'This tab controls how the popular posts list is styled.', 'top-10' ) . '</strong></p>' .
1330 - '<p>' . esc_html__( 'Select a built-in style or disable styles if you want to fully control the look using your own CSS.', 'top-10' ) . '</p>',
1705 + '<p>' . esc_html__( 'Select a built-in style or disable styles if you want to fully control the look using your own CSS.', 'top-10' ) . '</p>',
1331 1706 ),
1332 1707 array(
1333 1708 'id' => 'tptn-settings-maintenance-help',
1334 1709 'title' => esc_html__( 'Maintenance', 'top-10' ),
@@ -1333,9 +1708,9 @@
1333 1708 'id' => 'tptn-settings-maintenance-help',
1334 1709 'title' => esc_html__( 'Maintenance', 'top-10' ),
1335 1710 'content' =>
1336 1711 '<p><strong>' . esc_html__( 'This tab handles tools and maintenance-related options.', 'top-10' ) . '</strong></p>' .
1337 - '<p>' . esc_html__( 'Use this screen to reset settings, clear cached popular posts, and manage database-related options such as pruning or rebuilding counts.', 'top-10' ) . '</p>',
1712 + '<p>' . esc_html__( 'Use this screen to reset settings, clear cached popular posts, and manage database-related options such as pruning or rebuilding counts.', 'top-10' ) . '</p>',
1338 1713 ),
1339 1714 array(
1340 1715 'id' => 'tptn-settings-feed-help',
1341 1716 'title' => esc_html__( 'Feed', 'top-10' ),
@@ -1340,9 +1715,9 @@
1340 1715 'id' => 'tptn-settings-feed-help',
1341 1716 'title' => esc_html__( 'Feed', 'top-10' ),
1342 1717 'content' =>
1343 1718 '<p><strong>' . esc_html__( 'This tab controls how Top 10 content appears in your site feed.', 'top-10' ) . '</strong></p>' .
1344 - '<p>' . esc_html__( 'Configure copyright text and additional HTML that is added before or after the content in your feeds.', 'top-10' ) . '</p>',
1719 + '<p>' . esc_html__( 'Configure copyright text and additional HTML that is added before or after the content in your feeds.', 'top-10' ) . '</p>',
1345 1720 ),
1346 1721 );
1347 1722
1348 1723 /**
@@ -1357,9 +1732,9 @@
1357 1732
1358 1733 /**
1359 1734 * Function returns the different types of trackers.
1360 1735 *
1361 - * @since 3.3.0
1736 + * @since 3.3.0
1362 1737 * @return array Tracker types.
1363 1738 */
1364 1739 public static function get_tracker_types() {
1365 1740
@@ -1393,9 +1768,9 @@
1393 1768
1394 1769 /**
1395 1770 * Function returns the different tracking methods.
1396 1771 *
1397 - * @since 4.3.3
1772 + * @since 4.3.3
1398 1773 * @return array Tracking methods.
1399 1774 */
1400 1775 public static function get_tracking_methods() {
1401 1776
@@ -1431,9 +1806,9 @@
1431 1806 * @since 2.0.0
1432 1807 */
1433 1808 public static function get_admin_footer_text() {
1434 1809 return sprintf(
1435 - /* translators: 1: Opening achor tag with Plugin page link, 2: Closing anchor tag, 3: Opening anchor tag with review link. */
1810 + /* translators: 1: Opening achor tag with Plugin page link, 2: Closing anchor tag, 3: Opening anchor tag with review link. */
1436 1811 __( 'Thank you for using %1$sWebberZone Top 10%2$s! Please %3$srate us%2$s on WordPress.org', 'top-10' ),
1437 1812 '<a href="https://webberzone.com/plugins/top-10/" target="_blank">',
1438 1813 '</a>',
1439 1814 '<a href="https://wordpress.org/support/plugin/top-10/reviews/#new-post" target="_blank">'
@@ -1514,15 +1889,15 @@
1514 1889 // Overwrite settings based on selected style; guard against missing keys on reset.
1515 1890 $style = $settings['tptn_styles'] ?? '';
1516 1891
1517 1892 $inline_thumb_styles = array(
1518 - 'left_thumbs' => esc_html__( 'Note: Thumbnail location can only be Inline or Thumbnails only when the Popular posts style is set to Left thumbnails. You can change the style in the Styles tab.', 'top-10' ),
1519 - 'grid_thumbs' => esc_html__( 'Note: Thumbnail location can only be Inline or Thumbnails only when the Popular posts style is set to Grid thumbnails. You can change the style in the Styles tab.', 'top-10' ),
1893 + 'left_thumbs' => esc_html__( 'Note: Thumbnail location can only be Inline, After, or Thumbnails only when the Popular posts style is set to Left thumbnails. You can change the style in the Styles tab.', 'top-10' ),
1894 + 'grid_thumbs' => esc_html__( 'Note: Thumbnail location can only be Inline, After, or Thumbnails only when the Popular posts style is set to Grid thumbnails. You can change the style in the Styles tab.', 'top-10' ),
1520 1895 );
1521 1896
1522 1897 if ( array_key_exists( $style, $inline_thumb_styles ) ) {
1523 1898 $post_thumb_op = $settings['post_thumb_op'] ?? '';
1524 - if ( 'inline' !== $post_thumb_op && 'thumbs_only' !== $post_thumb_op ) {
1899 + if ( 'inline' !== $post_thumb_op && 'after' !== $post_thumb_op && 'thumbs_only' !== $post_thumb_op ) {
1525 1900 $settings['post_thumb_op'] = 'inline';
1526 1901 }
1527 1902
1528 1903 add_settings_error(
@@ -1543,8 +1918,20 @@
1543 1918 'warning'
1544 1919 );
1545 1920 }
1546 1921
1922 + // If the fast/high-traffic trackers are disabled, reset the tracker type to the default.
1923 + if ( isset( $settings['enable_fast_tracker'] ) && empty( $settings['enable_fast_tracker'] ) && isset( $settings['tracker_type'] ) && in_array( $settings['tracker_type'], array( 'fast_tracker', 'high_traffic_tracker' ), true ) ) {
1924 + $settings['tracker_type'] = 'query_based';
1925 +
1926 + add_settings_error(
1927 + self::$prefix . '-notices',
1928 + '',
1929 + esc_html__( 'Note: Tracker type has been reset to the default as the Fast and High-traffic trackers feature is disabled.', 'top-10' ),
1930 + 'warning'
1931 + );
1932 + }
1933 +
1547 1934 // Delete the cache.
1548 1935 \WebberZone\Top_Ten\Util\Cache::delete();
1549 1936
1550 1937 return $settings;
@@ -1599,13 +1986,13 @@
1599 1986 public static function settings_page_header() {
1600 1987 global $tptn_freemius;
1601 1988 ?>
1602 1989 <p>
1603 - <?php if ( ! $tptn_freemius->is_paying() ) { ?>
1990 + <?php if ( ! $tptn_freemius->is_paying() ) { ?>
1604 1991 <a class="tptn_button tptn_button_gold" href="<?php echo esc_url( $tptn_freemius->get_upgrade_url() ); ?>">
1605 - <?php esc_html_e( 'Upgrade to Pro', 'top-10' ); ?>
1992 + <?php esc_html_e( 'Upgrade to Pro', 'top-10' ); ?>
1606 1993 </a>
1607 - <?php } ?>
1994 + <?php } ?>
1608 1995 </p>
1609 1996
1610 1997 <?php
1611 1998 }
@@ -1612,10 +1999,10 @@
1612 1999
1613 2000 /**
1614 2001 * Updated the settings fields to display a pro version link.
1615 2002 *
1616 - * @param string $output Settings field HTML.
1617 - * @param array $args Settings field arguments.
2003 + * @param string $output Settings field HTML.
2004 + * @param array $args Settings field arguments.
1618 2005 * @return string Updated HTML.
1619 2006 */
1620 2007 public static function after_setting_output( $output, $args ) {
1621 2008 if ( isset( $args['pro'] ) && $args['pro'] ) {
@@ -1697,9 +2084,9 @@
1697 2084 if ( false !== strpos( $search_term, ',' ) ) {
1698 2085 $search_term = explode( ',', $search_term );
1699 2086 $search_term = $search_term[ count( $search_term ) - 1 ];
1700 2087 }
1701 - $search_term = trim( $search_term );
2088 + $search_term = trim( $search_term, " \t\n\r\0\x0B" );
1702 2089
1703 2090 if ( 'public_taxonomies' === $endpoint ) {
1704 2091 $taxonomies = (array) get_taxonomies( array( 'public' => true ), 'objects' );
1705 2092 $taxonomy = array();
@@ -1734,15 +2121,17 @@
1734 2121 wp_send_json_error( 'Insufficient permissions' );
1735 2122 }
1736 2123 }
1737 2124
1738 - /** This filter has been defined in /wp-admin/includes/ajax-actions.php */
2125 + /**
2126 + * This filter has been defined in /wp-admin/includes/ajax-actions.php
2127 +*/
1739 2128 $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $search_term );
1740 2129
1741 2130 /*
1742 - * Require $term_search_min_chars chars for matching (default: 2)
1743 - * ensure it's a non-negative, non-zero integer.
1744 - */
2131 + * Require $term_search_min_chars chars for matching (default: 2)
2132 + * ensure it's a non-negative, non-zero integer.
2133 + */
1745 2134 if ( ( 0 === $term_search_min_chars ) || ( strlen( $search_term ) < $term_search_min_chars ) ) {
1746 2135 wp_send_json_success( array() );
1747 2136 }
1748 2137
@@ -1770,10 +2159,10 @@
1770 2159 * Get field attributes for Tom Select taxonomy search fields.
1771 2160 *
1772 2161 * @since 4.2.0
1773 2162 *
1774 - * @param string $taxonomy The taxonomy to search.
1775 - * @param array $ts_config Optional Tom Select configuration.
2163 + * @param string $taxonomy The taxonomy to search.
2164 + * @param array $ts_config Optional Tom Select configuration.
1776 2165 * @return array Field attributes array.
1777 2166 */
1778 2167 private static function get_taxonomy_search_field_attributes( $taxonomy, $ts_config = array() ) {
1779 2168 $attributes = array(
@@ -1794,9 +2183,9 @@
1794 2183 * Get field attributes for Tom Select meta key search fields.
1795 2184 *
1796 2185 * @since 4.2.0
1797 2186 *
1798 - * @param array $ts_config Optional Tom Select configuration.
2187 + * @param array $ts_config Optional Tom Select configuration.
1799 2188 * @return array Field attributes array.
1800 2189 */
1801 2190 private static function get_meta_keys_search_field_attributes( $ts_config = array() ) {
1802 2191 $attributes = array(