@@ -128,7 +128,7 @@ public function process_bulk_action(): void {
128128
129129 $ nonce_action = 'bulk- ' . $ this ->_args ['plural ' ];
130130 $ nonce_value = $ _REQUEST ['_wpnonce ' ] ?? '' ;
131-
131+
132132 $ nonce = is_string ( $ nonce_value ) ? $ nonce_value : '' ;
133133
134134 $ nonce_result = wp_verify_nonce ( $ nonce , $ nonce_action );
@@ -156,42 +156,44 @@ public function process_bulk_action(): void {
156156 $ deleted_count = $ count_before_delete ;
157157 }
158158
159- if ( $ deleted_count > 0 ) {
160- $ preserved_filters = [] ;
161- $ filter_keys = [ ' level_filter ' , ' start_date ' , ' end_date ' ];
159+ if ( $ deleted_count <= 0 ) {
160+ return ;
161+ }
162162
163- foreach ( $ filter_keys as $ key ) {
164- $ value = $ _REQUEST [ $ key ] ?? null ;
165- if ( ! empty ( $ value ) && is_string ( $ value ) ) {
166- $ preserved_filters [ $ key ] = sanitize_text_field ( wp_unslash ( $ value ) );
167- }
168- }
163+ $ preserved_filters = [];
164+ $ filter_keys = [ 'level_filter ' , 'start_date ' , 'end_date ' ];
169165
170- $ redirect_url = remove_query_arg ( [ 'action ' , 'action2 ' , 'log ' , '_wpnonce ' ] );
171- $ redirect_url = add_query_arg (
172- array_merge (
173- [ 'deleted_count ' => $ deleted_count ],
174- $ preserved_filters
175- ),
176- $ redirect_url
177- );
178-
179- if ( ! headers_sent () ) {
180- wp_safe_redirect ( esc_url_raw ( $ redirect_url ) );
181- exit ;
182- } else {
183- echo '<meta http-equiv="refresh" content="0;url= ' . esc_url ( $ redirect_url ) . '"> ' ;
184- printf (
185- '<div class="notice notice-success"><p>%s <a href="%s">%s</a></p></div> ' ,
186- esc_html__ ( 'Logs deleted successfully. ' , 'wpgraphql-logging ' ),
187- esc_url ( $ redirect_url ),
188- esc_html__ ( 'Return to Logs ' , 'wpgraphql-logging ' )
189- );
190- exit ;
166+ foreach ( $ filter_keys as $ key ) {
167+ $ value = $ _REQUEST [ $ key ] ?? null ;
168+ if ( ! empty ( $ value ) && is_string ( $ value ) ) {
169+ $ preserved_filters [ $ key ] = sanitize_text_field ( wp_unslash ( $ value ) );
191170 }
192171 }
172+
173+ $ redirect_url = remove_query_arg ( [ 'action ' , 'action2 ' , 'log ' , '_wpnonce ' ] );
174+ $ redirect_url = add_query_arg (
175+ array_merge (
176+ [ 'deleted_count ' => $ deleted_count ],
177+ $ preserved_filters
178+ ),
179+ $ redirect_url
180+ );
181+
182+ if ( ! headers_sent () ) {
183+ wp_safe_redirect ( esc_url_raw ( $ redirect_url ) );
184+ exit ;
185+ }
186+
187+ echo '<meta http-equiv="refresh" content="0;url= ' . esc_url ( $ redirect_url ) . '"> ' ;
188+ printf (
189+ '<div class="notice notice-success"><p>%s <a href="%s">%s</a></p></div> ' ,
190+ esc_html__ ( 'Logs deleted successfully. ' , 'wpgraphql-logging ' ),
191+ esc_url ( $ redirect_url ),
192+ esc_html__ ( 'Return to Logs ' , 'wpgraphql-logging ' )
193+ );
194+ exit ;
193195 }
194-
196+
195197 /**
196198 * Get the columns for the logs table.
197199 *
@@ -475,7 +477,7 @@ protected function display_tablenav( $which ): void {
475477 <div class="alignleft actions bulkactions">
476478 <?php $ this ->bulk_actions ( $ which_position ); ?>
477479 </div>
478-
480+
479481 <?php
480482 $ this ->extra_tablenav ( $ which );
481483 $ this ->pagination ( $ which_position );
0 commit comments