File tree Expand file tree Collapse file tree 4 files changed +57
-29
lines changed
Expand file tree Collapse file tree 4 files changed +57
-29
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import _import from 'eslint-plugin-import';
2121import prettier from 'eslint-plugin-prettier' ;
2222import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' ;
2323import testingLibrary from 'eslint-plugin-testing-library' ;
24- import vitest from 'eslint-plugin-vitest ' ;
24+ import vitest from '@vitest/ eslint-plugin' ;
2525import deprecation from 'eslint-plugin-deprecation' ;
2626// import nextPlugin from '@next/eslint-plugin-next';
2727import pluginQuery from '@tanstack/eslint-plugin-query' ;
Original file line number Diff line number Diff line change @@ -564,14 +564,45 @@ function ajax_wto_options(): void {
564564add_action ( 'wp_ajax_wto_options ' , 'ajax_wto_options ' );
565565add_action ( 'wp_ajax_nopriv_wto_options ' , 'ajax_wto_options ' );
566566
567+ /**
568+ * Sanitizes the enabled taxonomies setting.
569+ *
570+ * @param mixed $value The value to sanitize.
571+ * @return array<string> Sanitized array of taxonomy names.
572+ */
573+ function wpto_sanitize_enabled_taxonomies ( $ value ): array {
574+ if ( ! is_array ( $ value ) ) {
575+ return array ();
576+ }
577+
578+ $ sanitized = array ();
579+ foreach ( $ value as $ taxonomy ) {
580+ $ taxonomy = wpto_cast_mixed_to_string ( $ taxonomy );
581+ // Ensure the taxonomy exists and is registered.
582+ if ( taxonomy_exists ( sanitize_key ( $ taxonomy ) ) ) {
583+ $ sanitized [] = sanitize_key ( $ taxonomy );
584+ }
585+ }
586+
587+ return $ sanitized ;
588+ }
589+
567590/**
568591 * Registers the plugin settings.
569592 * This function registers settings that can be configured from the plugin's options page.
570593 *
571594 * @return void
572595 */
573596function register_wpto_settings (): void {
574- register_setting ( 'wpto-settings-group ' , 'wpto_enabled_taxonomies ' );
597+ register_setting (
598+ 'wpto-settings-group ' ,
599+ 'wpto_enabled_taxonomies ' ,
600+ array (
601+ 'type ' => 'array ' ,
602+ 'sanitize_callback ' => 'wpto_sanitize_enabled_taxonomies ' ,
603+ 'default ' => array (),
604+ )
605+ );
575606}
576607
577608/**
Original file line number Diff line number Diff line change 3737 "@types/webpack-bundle-analyzer" : " ^4.7.0" ,
3838 "@typescript-eslint/eslint-plugin" : " ^6.21.0" ,
3939 "@typescript-eslint/parser" : " ^6.21.0" ,
40+ "@vitest/eslint-plugin" : " ^1.1.25" ,
4041 "css-loader" : " ^7.1.2" ,
4142 "eslint" : " ^8.57.1" ,
4243 "eslint-config-airbnb" : " ^19.0.4" ,
5455 "eslint-plugin-testing-library" : " ^7.1.1" ,
5556 "eslint-plugin-tsdoc" : " ^0.2.17" ,
5657 "eslint-plugin-unused-imports" : " ^3.2.0" ,
57- "eslint-plugin-vitest" : " ^0.5.4" ,
5858 "eslint-rspack-plugin" : " ^4.2.1" ,
5959 "fork-ts-checker-notifier-webpack-plugin" : " ^9.0.0" ,
6060 "fork-ts-checker-webpack-plugin" : " ^9.0.2" ,
You can’t perform that action at this time.
0 commit comments