File tree Expand file tree Collapse file tree 1 file changed +10
-16
lines changed
plugins/wpgraphql-logging/assets/js/settings Expand file tree Collapse file tree 1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change 1- // Add this to your admin JavaScript file
21document . addEventListener ( 'DOMContentLoaded' , function ( ) {
3-
4- const sanitizationMethodSelect = document . querySelector ( "#data_sanitization_method" ) ;
5- if ( ! sanitizationMethodSelect || sanitizationMethodSelect . length === 0 ) {
2+ const sanitizationMethodSelect = document . querySelector ( "#data_sanitization_method" ) ;
3+ if ( ! sanitizationMethodSelect ) {
64 return ;
75 }
86
97 function toggleCustomFields ( ) {
10- const isCustom = sanitizationMethodSelect . value === 'custom' ;
8+ const isCustom = sanitizationMethodSelect . value === 'custom' ;
9+ const customElements = document . querySelectorAll ( '.wpgraphql-logging-custom' ) ;
1110
12- if ( isCustom ) {
13- document . querySelectorAll ( '.wpgraphql-logging-custom' ) . forEach ( ( el ) => {
11+ customElements . forEach ( ( el ) => {
12+ if ( isCustom ) {
1413 el . classList . add ( 'block' ) ;
15- } ) ;
16- } else {
17- document . querySelectorAll ( '.wpgraphql-logging-custom' ) . forEach ( ( el ) => {
14+ } else {
1815 el . classList . remove ( 'block' ) ;
19- } ) ;
20- }
21- }
16+ }
17+ } ) ;
18+ }
2219
23- // Initial check on page load
2420 toggleCustomFields ( ) ;
25-
26- // Listen for changes
2721 sanitizationMethodSelect . addEventListener ( 'change' , toggleCustomFields ) ;
2822} ) ;
You can’t perform that action at this time.
0 commit comments