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 +486 -55 4.3.0 → 4.5.2 View file →
@@ -10,8 +10,9 @@
10 10 use WebberZone\Top_Ten\Admin\Settings\Settings_API;
11 11 use WebberZone\Top_Ten\Admin\Settings\Settings_Sanitize;
12 12 use WebberZone\Top_Ten\Frontend\Display;
13 13 use WebberZone\Top_Ten\Frontend\Media_Handler;
14 +use WebberZone\Top_Ten\Util\Helpers;
14 15 use WebberZone\Top_Ten\Util\Hook_Registry;
15 16
16 17 // If this file is called directly, abort.
17 18 if ( ! defined( 'WPINC' ) ) {
@@ -20,12 +21,13 @@
20 21
21 22 /**
22 23 * Class to register the settings.
23 24 *
24 - * @since 3.3.0
25 + * @since 3.3.0
25 26 */
26 27 class Settings {
27 28
29 +
28 30 /**
29 31 * Settings API.
30 32 *
31 33 * @since 3.3.0
@@ -97,13 +99,14 @@
97 99 * @since 3.3.0
98 100 */
99 101 public function initialise_settings() {
100 102 $props = array(
101 - 'default_tab' => 'general',
103 + 'default_tab' => 'features',
102 104 'help_sidebar' => $this->get_help_sidebar(),
103 105 'help_tabs' => $this->get_help_tabs(),
104 106 'admin_footer_text' => $this->get_admin_footer_text(),
105 107 'menus' => $this->get_menus(),
108 + 'version' => TOP_TEN_VERSION,
106 109 );
107 110
108 111 $args = array(
109 112 'props' => $props,
@@ -130,9 +133,15 @@
130 133 'success_message' => esc_html__( 'Settings updated.', 'top-10' ),
131 134 'save_changes' => esc_html__( 'Save Changes', 'top-10' ),
132 135 'reset_settings' => esc_html__( 'Reset all settings', 'top-10' ),
133 136 'reset_button_confirm' => esc_html__( 'Do you really want to reset all these settings to their default values?', 'top-10' ),
134 - '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' ),
135 144 );
136 145
137 146 /**
138 147 * Filter the array containing the settings' sections.
@@ -173,8 +182,9 @@
173 182 * @return array Settings array
174 183 */
175 184 public static function get_settings_sections() {
176 185 $settings_sections = array(
186 + 'features' => __( 'Features', 'top-10' ),
177 187 'general' => __( 'General', 'top-10' ),
178 188 'counter' => __( 'Counter/Tracker', 'top-10' ),
179 189 'list' => __( 'Posts list', 'top-10' ),
180 190 'thumbnail' => __( 'Thumbnail', 'top-10' ),
@@ -194,8 +204,159 @@
194 204 }
195 205
196 206
197 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 + /**
198 359 * Retrieve the array of plugin settings
199 360 *
200 361 * @since 3.3.0
201 362 *
@@ -244,8 +405,16 @@
244 405 'desc' => esc_html__( 'Enter the number of seconds to cache the output.', 'top-10' ),
245 406 'type' => 'text',
246 407 'default' => HOUR_IN_SECONDS,
247 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 + ),
248 417 'uninstall_clean_options' => array(
249 418 'id' => 'uninstall_clean_options',
250 419 'name' => esc_html__( 'Delete options on uninstall', 'top-10' ),
251 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' ),
@@ -288,9 +457,10 @@
288 457 ),
289 458 'pv_in_admin' => array(
290 459 'id' => 'pv_in_admin',
291 460 'name' => esc_html__( 'Display admin columns', 'top-10' ),
292 - 'desc' => esc_html__( "Adds three columns called Total Views, Today's Views and Views. You can selectively disable these by pulling down the Screen Options from the top right of the respective screens.", 'top-10' ),
461 + /* translators: %s: Custom period label (e.g. Daily, Custom (7 days)). */
462 + 'desc' => sprintf( esc_html__( 'Adds three columns called Total Views, %s Views and Views. You can selectively disable these by pulling down the Screen Options from the top right of the respective screens.', 'top-10' ), Helpers::get_daily_range_label() ),
293 463 'type' => 'checkbox',
294 464 'default' => true,
295 465 ),
296 466 'admin_column_post_types' => array(
@@ -407,8 +577,19 @@
407 577 'desc' => esc_html__( 'Activating this option will convert the post counts into a number format based on the locale', 'top-10' ),
408 578 'type' => 'checkbox',
409 579 'default' => true,
410 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 + ),
411 592 'daily_midnight' => array(
412 593 'id' => 'daily_midnight',
413 594 'name' => esc_html__( 'Start daily counts at midnight', 'top-10' ),
414 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' ),
@@ -479,8 +660,16 @@
479 660 'type' => 'radiodesc',
480 661 'default' => 'query_based',
481 662 'options' => self::get_tracker_types(),
482 663 ),
664 + 'tracking_method' => array(
665 + 'id' => 'tracking_method',
666 + 'name' => esc_html__( 'Tracking method', 'top-10' ),
667 + 'desc' => esc_html__( 'Funnel tracking buffers views in a staging table that is merged into the count tables by a background job every few minutes and is recommended for most sites. Switch to Legacy tracking if view counts are not updating on your site, e.g. when WP-Cron is disabled or unreliable. Legacy tracking does not populate the visits log table.', 'top-10' ),
668 + 'type' => 'radiodesc',
669 + 'default' => 'funnel',
670 + 'options' => self::get_tracking_methods(),
671 + ),
483 672 'tracker_all_pages' => array(
484 673 'id' => 'tracker_all_pages',
485 674 'name' => esc_html__( 'Load tracker on all pages', 'top-10' ),
486 675 'desc' => esc_html__( 'This will load the tracker js on all pages. Helpful if you are running minification/concatenation plugins.', 'top-10' ),
@@ -486,8 +675,16 @@
486 675 'desc' => esc_html__( 'This will load the tracker js on all pages. Helpful if you are running minification/concatenation plugins.', 'top-10' ),
487 676 'type' => 'checkbox',
488 677 'default' => false,
489 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 + ),
490 687 'track_feed_views' => array(
491 688 'id' => 'track_feed_views',
492 689 'name' => esc_html__( 'Track feed views', 'top-10' ),
493 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' ),
@@ -727,8 +924,20 @@
727 924 'desc' => '',
728 925 'type' => 'checkbox',
729 926 'default' => false,
730 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 + ),
731 940 'title_length' => array(
732 941 'id' => 'title_length',
733 942 'name' => esc_html__( 'Limit post title length (in characters)', 'top-10' ),
734 943 'desc' => '',
@@ -896,14 +1105,15 @@
896 1105 'type' => 'checkbox',
897 1106 'default' => true,
898 1107 ),
899 1108 'thumb_default' => array(
900 - 'id' => 'thumb_default',
901 - 'name' => esc_html__( 'Default thumbnail', 'top-10' ),
902 - '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' ),
903 - 'type' => 'file',
904 - 'default' => Display::get_default_thumbnail(),
905 - '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,
906 1116 ),
907 1117 );
908 1118
909 1119 /**
@@ -937,9 +1147,9 @@
937 1147 'custom_css' => array(
938 1148 'id' => 'custom_css',
939 1149 'name' => esc_html__( 'Custom CSS', 'top-10' ),
940 1150 'desc' => sprintf(
941 - /* 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. */
942 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' ),
943 1153 '<a href="' . esc_url( 'https://webberzone.com/support/knowledgebase/using-and-customising-top-10/' ) . '" target="_blank">',
944 1154 '</a>',
945 1155 '<code>',
@@ -974,10 +1184,11 @@
974 1184 'cron_on' => array(
975 1185 'id' => 'cron_on',
976 1186 'name' => esc_html__( 'Enable scheduled maintenance', 'top-10' ),
977 1187 'desc' => sprintf(
978 - /* translators: 1: Constant holding number of days data is stored. */
1188 + /* translators: 1: Constant holding number of days data is stored. */
979 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 */
980 1191 '<strong>' . (int) apply_filters( 'tptn_maintenance_days', TOP_TEN_STORE_DATA ) . '</strong>'
981 1192 ),
982 1193 'type' => 'checkbox',
983 1194 'default' => false,
@@ -985,9 +1196,9 @@
985 1196 'maintenance_days' => array(
986 1197 'id' => 'maintenance_days',
987 1198 'name' => esc_html__( 'Daily table retention period', 'top-10' ),
988 1199 'desc' => sprintf(
989 - /* translators: 1: Constant holding number of days data is stored. */
1200 + /* translators: 1: Constant holding number of days data is stored. */
990 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' ),
991 1202 '<strong>' . TOP_TEN_STORE_DATA . '</strong>'
992 1203 ),
993 1204 'type' => 'number',
@@ -999,9 +1210,9 @@
999 1210 'log_retention_days' => array(
1000 1211 'id' => 'log_retention_days',
1001 1212 'name' => esc_html__( 'Visits log retention period', 'top-10' ),
1002 1213 'desc' => sprintf(
1003 - /* translators: 1: Default number of days for visits log retention. */
1214 + /* translators: 1: Default number of days for visits log retention. */
1004 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' ),
1005 1216 '<strong>' . TOP_TEN_LOG_STORE_DATA . '</strong>'
1006 1217 ),
1007 1218 'type' => 'number',
@@ -1081,9 +1292,10 @@
1081 1292 'size' => 'large',
1082 1293 ),
1083 1294 'feed_permalink_daily' => array(
1084 1295 'id' => 'feed_permalink_daily',
1085 - 'name' => esc_html__( 'Permalink - Daily', 'top-10' ),
1296 + /* translators: %s: Custom period label (e.g. Daily, Custom (7 days)). */
1297 + 'name' => sprintf( esc_html__( 'Permalink - %s', 'top-10' ), Helpers::get_daily_range_label( (int) \tptn_get_option( 'feed_daily_range', 1 ) ) ),
1086 1298 /* translators: 1: Opening link tag, 2: Closing link tag. */
1087 1299 'desc' => sprintf( esc_html__( 'This will set the path of the custom feed generated by the plugin for daily/custom period popular posts. You might need to %1$srefresh your permalinks%2$s when changing this option.', 'top-10' ), '<a href="' . admin_url( 'options-permalink.php' ) . '" target="_blank">', '</a>' ),
1088 1300 'type' => 'text',
1089 1301 'default' => 'popular-posts-daily',
@@ -1129,11 +1341,185 @@
1129 1341 return apply_filters( self::$prefix . '_settings_feed', $settings );
1130 1342 }
1131 1343
1132 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 + /**
1133 1519 * Get the various styles.
1134 1520 *
1135 - * @since 2.5.0
1521 + * @since 2.5.0
1136 1522 * @return array Style options.
1137 1523 */
1138 1524 public static function get_styles() {
1139 1525 $styles = array(
@@ -1168,9 +1554,9 @@
1168 1554 * Get User Roles.
1169 1555 *
1170 1556 * @since 4.0.0
1171 1557 *
1172 - * @param array $remove_roles Roles to remove.
1558 + * @param array $remove_roles Roles to remove.
1173 1559 * @return array User roles in the format 'role' => 'name'.
1174 1560 */
1175 1561 public static function get_user_roles( $remove_roles = array() ) {
1176 1562 // Get the global $wp_roles object using the wp_roles() function.
@@ -1211,9 +1597,9 @@
1211 1597 * Adding WordPress plugin action links.
1212 1598 *
1213 1599 * @since 3.3.0
1214 1600 *
1215 - * @param array $links Array of links.
1601 + * @param array $links Array of links.
1216 1602 * @return array
1217 1603 */
1218 1604 public function plugin_actions_links( $links ) {
1219 1605
@@ -1229,10 +1615,10 @@
1229 1615 * Add meta links on Plugins page.
1230 1616 *
1231 1617 * @since 3.3.0
1232 1618 *
1233 - * @param array $links Array of Links.
1234 - * @param string $file Current file.
1619 + * @param array $links Array of Links.
1620 + * @param string $file Current file.
1235 1621 * @return array
1236 1622 */
1237 1623 public function plugin_row_meta( $links, $file ) {
1238 1624
@@ -1254,18 +1640,18 @@
1254 1640 * @since 1.8.0
1255 1641 */
1256 1642 public function get_help_sidebar() {
1257 1643 $help_sidebar =
1258 - /* translators: 1: Plugin support site link. */
1259 - '<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>' .
1260 - /* translators: 1: WordPress.org support forums link. */
1261 - '<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>' .
1262 - '<p>' . sprintf(
1263 - /* translators: 1: Github issues link, 2: Github plugin page link. */
1264 - __( '<a href="%1$s">Post an issue</a> on <a href="%2$s">GitHub</a> (bug reports only).', 'top-10' ),
1265 - esc_url( 'https://github.com/ajaydsouza/top-10/issues' ),
1266 - esc_url( 'https://github.com/ajaydsouza/top-10' )
1267 - ) . '</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>';
1268 1654
1269 1655 /**
1270 1656 * Filter to modify the help sidebar content.
1271 1657 *
@@ -1287,9 +1673,9 @@
1287 1673 'id' => 'tptn-settings-general-help',
1288 1674 'title' => esc_html__( 'General', 'top-10' ),
1289 1675 'content' =>
1290 1676 '<p><strong>' . esc_html__( 'This tab provides global settings for how Top 10 works across your site.', 'top-10' ) . '</strong></p>' .
1291 - '<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>',
1292 1678 ),
1293 1679 array(
1294 1680 'id' => 'tptn-settings-counter-help',
1295 1681 'title' => esc_html__( 'Counter / Tracker', 'top-10' ),
@@ -1294,9 +1680,9 @@
1294 1680 'id' => 'tptn-settings-counter-help',
1295 1681 'title' => esc_html__( 'Counter / Tracker', 'top-10' ),
1296 1682 'content' =>
1297 1683 '<p><strong>' . esc_html__( 'This tab controls how Top 10 tracks and displays view counts.', 'top-10' ) . '</strong></p>' .
1298 - '<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>',
1299 1685 ),
1300 1686 array(
1301 1687 'id' => 'tptn-settings-list-help',
1302 1688 'title' => esc_html__( 'Posts list', 'top-10' ),
@@ -1301,9 +1687,9 @@
1301 1687 'id' => 'tptn-settings-list-help',
1302 1688 'title' => esc_html__( 'Posts list', 'top-10' ),
1303 1689 'content' =>
1304 1690 '<p><strong>' . esc_html__( 'This tab controls the popular posts list output.', 'top-10' ) . '</strong></p>' .
1305 - '<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>',
1306 1692 ),
1307 1693 array(
1308 1694 'id' => 'tptn-settings-thumbnail-help',
1309 1695 'title' => esc_html__( 'Thumbnail', 'top-10' ),
@@ -1308,9 +1694,9 @@
1308 1694 'id' => 'tptn-settings-thumbnail-help',
1309 1695 'title' => esc_html__( 'Thumbnail', 'top-10' ),
1310 1696 'content' =>
1311 1697 '<p><strong>' . esc_html__( 'This tab manages thumbnail settings for the popular posts list.', 'top-10' ) . '</strong></p>' .
1312 - '<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>',
1313 1699 ),
1314 1700 array(
1315 1701 'id' => 'tptn-settings-styles-help',
1316 1702 'title' => esc_html__( 'Styles', 'top-10' ),
@@ -1315,9 +1701,9 @@
1315 1701 'id' => 'tptn-settings-styles-help',
1316 1702 'title' => esc_html__( 'Styles', 'top-10' ),
1317 1703 'content' =>
1318 1704 '<p><strong>' . esc_html__( 'This tab controls how the popular posts list is styled.', 'top-10' ) . '</strong></p>' .
1319 - '<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>',
1320 1706 ),
1321 1707 array(
1322 1708 'id' => 'tptn-settings-maintenance-help',
1323 1709 'title' => esc_html__( 'Maintenance', 'top-10' ),
@@ -1322,9 +1708,9 @@
1322 1708 'id' => 'tptn-settings-maintenance-help',
1323 1709 'title' => esc_html__( 'Maintenance', 'top-10' ),
1324 1710 'content' =>
1325 1711 '<p><strong>' . esc_html__( 'This tab handles tools and maintenance-related options.', 'top-10' ) . '</strong></p>' .
1326 - '<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>',
1327 1713 ),
1328 1714 array(
1329 1715 'id' => 'tptn-settings-feed-help',
1330 1716 'title' => esc_html__( 'Feed', 'top-10' ),
@@ -1329,9 +1715,9 @@
1329 1715 'id' => 'tptn-settings-feed-help',
1330 1716 'title' => esc_html__( 'Feed', 'top-10' ),
1331 1717 'content' =>
1332 1718 '<p><strong>' . esc_html__( 'This tab controls how Top 10 content appears in your site feed.', 'top-10' ) . '</strong></p>' .
1333 - '<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>',
1334 1720 ),
1335 1721 );
1336 1722
1337 1723 /**
@@ -1346,9 +1732,9 @@
1346 1732
1347 1733 /**
1348 1734 * Function returns the different types of trackers.
1349 1735 *
1350 - * @since 3.3.0
1736 + * @since 3.3.0
1351 1737 * @return array Tracker types.
1352 1738 */
1353 1739 public static function get_tracker_types() {
1354 1740
@@ -1379,11 +1765,42 @@
1379 1765 */
1380 1766 return apply_filters( self::$prefix . '_get_tracker_types', $trackers );
1381 1767 }
1382 1768
1769 + /**
1770 + * Function returns the different tracking methods.
1771 + *
1772 + * @since 4.3.3
1773 + * @return array Tracking methods.
1774 + */
1775 + public static function get_tracking_methods() {
1383 1776
1777 + $methods = array(
1778 + array(
1779 + 'id' => 'funnel',
1780 + 'name' => __( 'Funnel tracking', 'top-10' ),
1781 + 'description' => __( 'Views are buffered and merged into the count tables every few minutes (default)', 'top-10' ),
1782 + ),
1783 + array(
1784 + 'id' => 'legacy',
1785 + 'name' => __( 'Legacy tracking', 'top-10' ),
1786 + 'description' => __( 'Views are written directly to the count tables on every visit (behaviour of versions before 4.3)', 'top-10' ),
1787 + ),
1788 + );
1384 1789
1790 + /**
1791 + * Filter the array containing the tracking methods.
1792 + *
1793 + * @since 4.3.3
1794 + *
1795 + * @param array $methods Tracking methods.
1796 + */
1797 + return apply_filters( self::$prefix . '_get_tracking_methods', $methods );
1798 + }
1385 1799
1800 +
1801 +
1802 +
1386 1803 /**
1387 1804 * Add footer text on the plugin page.
1388 1805 *
1389 1806 * @since 2.0.0
@@ -1389,9 +1806,9 @@
1389 1806 * @since 2.0.0
1390 1807 */
1391 1808 public static function get_admin_footer_text() {
1392 1809 return sprintf(
1393 - /* 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. */
1394 1811 __( 'Thank you for using %1$sWebberZone Top 10%2$s! Please %3$srate us%2$s on WordPress.org', 'top-10' ),
1395 1812 '<a href="https://webberzone.com/plugins/top-10/" target="_blank">',
1396 1813 '</a>',
1397 1814 '<a href="https://wordpress.org/support/plugin/top-10/reviews/#new-post" target="_blank">'
@@ -1472,15 +1889,15 @@
1472 1889 // Overwrite settings based on selected style; guard against missing keys on reset.
1473 1890 $style = $settings['tptn_styles'] ?? '';
1474 1891
1475 1892 $inline_thumb_styles = array(
1476 - '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' ),
1477 - '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' ),
1478 1895 );
1479 1896
1480 1897 if ( array_key_exists( $style, $inline_thumb_styles ) ) {
1481 1898 $post_thumb_op = $settings['post_thumb_op'] ?? '';
1482 - 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 ) {
1483 1900 $settings['post_thumb_op'] = 'inline';
1484 1901 }
1485 1902
1486 1903 add_settings_error(
@@ -1501,8 +1918,20 @@
1501 1918 'warning'
1502 1919 );
1503 1920 }
1504 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 +
1505 1934 // Delete the cache.
1506 1935 \WebberZone\Top_Ten\Util\Cache::delete();
1507 1936
1508 1937 return $settings;
@@ -1557,13 +1986,13 @@
1557 1986 public static function settings_page_header() {
1558 1987 global $tptn_freemius;
1559 1988 ?>
1560 1989 <p>
1561 - <?php if ( ! $tptn_freemius->is_paying() ) { ?>
1990 + <?php if ( ! $tptn_freemius->is_paying() ) { ?>
1562 1991 <a class="tptn_button tptn_button_gold" href="<?php echo esc_url( $tptn_freemius->get_upgrade_url() ); ?>">
1563 - <?php esc_html_e( 'Upgrade to Pro', 'top-10' ); ?>
1992 + <?php esc_html_e( 'Upgrade to Pro', 'top-10' ); ?>
1564 1993 </a>
1565 - <?php } ?>
1994 + <?php } ?>
1566 1995 </p>
1567 1996
1568 1997 <?php
1569 1998 }
@@ -1570,10 +1999,10 @@
1570 1999
1571 2000 /**
1572 2001 * Updated the settings fields to display a pro version link.
1573 2002 *
1574 - * @param string $output Settings field HTML.
1575 - * @param array $args Settings field arguments.
2003 + * @param string $output Settings field HTML.
2004 + * @param array $args Settings field arguments.
1576 2005 * @return string Updated HTML.
1577 2006 */
1578 2007 public static function after_setting_output( $output, $args ) {
1579 2008 if ( isset( $args['pro'] ) && $args['pro'] ) {
@@ -1655,9 +2084,9 @@
1655 2084 if ( false !== strpos( $search_term, ',' ) ) {
1656 2085 $search_term = explode( ',', $search_term );
1657 2086 $search_term = $search_term[ count( $search_term ) - 1 ];
1658 2087 }
1659 - $search_term = trim( $search_term );
2088 + $search_term = trim( $search_term, " \t\n\r\0\x0B" );
1660 2089
1661 2090 if ( 'public_taxonomies' === $endpoint ) {
1662 2091 $taxonomies = (array) get_taxonomies( array( 'public' => true ), 'objects' );
1663 2092 $taxonomy = array();
@@ -1692,15 +2121,17 @@
1692 2121 wp_send_json_error( 'Insufficient permissions' );
1693 2122 }
1694 2123 }
1695 2124
1696 - /** 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 +*/
1697 2128 $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $search_term );
1698 2129
1699 2130 /*
1700 - * Require $term_search_min_chars chars for matching (default: 2)
1701 - * ensure it's a non-negative, non-zero integer.
1702 - */
2131 + * Require $term_search_min_chars chars for matching (default: 2)
2132 + * ensure it's a non-negative, non-zero integer.
2133 + */
1703 2134 if ( ( 0 === $term_search_min_chars ) || ( strlen( $search_term ) < $term_search_min_chars ) ) {
1704 2135 wp_send_json_success( array() );
1705 2136 }
1706 2137
@@ -1728,10 +2159,10 @@
1728 2159 * Get field attributes for Tom Select taxonomy search fields.
1729 2160 *
1730 2161 * @since 4.2.0
1731 2162 *
1732 - * @param string $taxonomy The taxonomy to search.
1733 - * @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.
1734 2165 * @return array Field attributes array.
1735 2166 */
1736 2167 private static function get_taxonomy_search_field_attributes( $taxonomy, $ts_config = array() ) {
1737 2168 $attributes = array(
@@ -1752,9 +2183,9 @@
1752 2183 * Get field attributes for Tom Select meta key search fields.
1753 2184 *
1754 2185 * @since 4.2.0
1755 2186 *
1756 - * @param array $ts_config Optional Tom Select configuration.
2187 + * @param array $ts_config Optional Tom Select configuration.
1757 2188 * @return array Field attributes array.
1758 2189 */
1759 2190 private static function get_meta_keys_search_field_attributes( $ts_config = array() ) {
1760 2191 $attributes = array(