From f28eb59ef70065c85cca92ac9af95115de7b6c69 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Tue, 7 Oct 2025 14:32:59 +0200 Subject: [PATCH 1/3] fix plugin filter --- src/class-rest.php | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/class-rest.php b/src/class-rest.php index 58aeed8..9310487 100644 --- a/src/class-rest.php +++ b/src/class-rest.php @@ -254,7 +254,14 @@ public function get_unused_options() { // Find unused autoloaded option names. $autoload_option_keys = array_fill_keys( $autoloaded_option_names, true ); $unused_keys = array_diff_key( $autoload_option_keys, $used_options ); - $total_unused = count( $unused_keys ); + + // Apply source filter to unused keys if specified. + $filter_by_source = isset( $_GET['columns'][2]['search']['value'] ) ? trim( \sanitize_text_field( \wp_unslash( $_GET['columns'][2]['search']['value'] ) ) ) : ''; + if ( '' !== $filter_by_source ) { + $unused_keys = $this->filter_by_source( $unused_keys, $filter_by_source ); + } + + $total_unused = count( $unused_keys ); // Sort order. [ $order_column, $order_dir ] = $this->get_sort_params(); @@ -359,6 +366,12 @@ public function get_used_not_autoloaded_options() { // Find used options that are not autoloaded. $non_autoloaded_used_keys = array_diff_key( $used_options, $autoload_option_keys ); + // Filter by source (plugin). + $filter_by_source = isset( $_GET['columns'][2]['search']['value'] ) ? trim( \sanitize_text_field( \wp_unslash( $_GET['columns'][2]['search']['value'] ) ) ) : ''; + if ( '' !== $filter_by_source ) { + $non_autoloaded_used_keys = $this->filter_by_source( $non_autoloaded_used_keys, $filter_by_source ); + } + // Search. $search = isset( $_GET['search']['value'] ) ? trim( \sanitize_text_field( \wp_unslash( $_GET['search']['value'] ) ) ) : ''; if ( '' !== $search ) { @@ -477,6 +490,12 @@ public function get_options_that_do_not_exist() { // Get used options that are not autoloaded. $non_autoloaded_keys = array_diff_key( $used_options, $autoload_option_keys ); + // Filter by source (plugin). + $filter_by_source = isset( $_GET['columns'][1]['search']['value'] ) ? trim( \sanitize_text_field( \wp_unslash( $_GET['columns'][1]['search']['value'] ) ) ) : ''; + if ( '' !== $filter_by_source ) { + $non_autoloaded_keys = $this->filter_by_source( $non_autoloaded_keys, $filter_by_source ); + } + // Search. $search = isset( $_GET['search']['value'] ) ? trim( \sanitize_text_field( \wp_unslash( $_GET['search']['value'] ) ) ) : ''; if ( '' !== $search ) { @@ -791,4 +810,28 @@ private function get_length( $value ) { private function get_plugin_name( $option ) { return $this->map_plugin_to_options->get_plugin_name( $option ); } + + /** + * Filter options array by source (plugin) name. + * + * @param array $options_array The options array to filter. + * @param string $filter_term The filter term to match against plugin names. + * + * @return array The filtered options array. + */ + private function filter_by_source( array $options_array, string $filter_term ): array { + + if ( ! $filter_term ) { + return $options_array; + } + + return array_filter( + $options_array, + function ( $option_name ) use ( $filter_term ) { + $plugin_name = $this->get_plugin_name( $option_name ); + return false !== stripos( $plugin_name, $filter_term ); + }, + ARRAY_FILTER_USE_KEY + ); + } } From 8061bee2b43ecbb1f77923a8ab122904e67e6fae Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Tue, 7 Oct 2025 14:35:54 +0200 Subject: [PATCH 2/3] changelog --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 5986911..1a0eb9d 100644 --- a/readme.txt +++ b/readme.txt @@ -57,6 +57,7 @@ Please do a pull request via GitHub on [this file](https://github.com/Emilia-Cap = 1.5.1 = * Add "select all" checkbox. +* Fix table filtering by Source column. = 1.5.0 = From 9c68a90f3aac2ee5ce149ed170343ecd19060af2 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Wed, 8 Oct 2025 15:00:54 +0200 Subject: [PATCH 3/3] set max-width for source select specifically --- css/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/css/style.css b/css/style.css index 3763811..5baaa58 100644 --- a/css/style.css +++ b/css/style.css @@ -22,6 +22,10 @@ .aaa_option_table select { max-width: 20% !important; } +/* Overrider for the Source