| @@ -78,9 +78,10 @@ | ||
| 78 | 78 | ] |
| 79 | 79 | ); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - /*** | |
| 82 | + | |
| 83 | + /** | |
| 83 | 84 | * |
| 84 | 85 | * @return mixed |
| 85 | 86 | */ |
| 86 | 87 | public function admin_bar_menu_action() { |
| @@ -89,12 +90,14 @@ | ||
| 89 | 90 | } |
| 90 | 91 | if ( ! current_user_can( 'manage_options' ) ) { |
| 91 | 92 | return; |
| 92 | 93 | } |
| 94 | + | |
| 93 | 95 | $clear_cache = sanitize_text_field( wp_unslash( $_GET['rtsb_clear_cache'] ?? '' ) ); |
| 94 | 96 | if ( empty( $clear_cache ) ) { |
| 95 | 97 | return; |
| 96 | 98 | } |
| 99 | + | |
| 97 | 100 | switch ( $clear_cache ) { |
| 98 | 101 | case 'all': |
| 99 | 102 | Cache::clear_all_cache(); |
| 100 | 103 | break; |
| @@ -106,16 +109,18 @@ | ||
| 106 | 109 | break; |
| 107 | 110 | } |
| 108 | 111 | // Set the notice flag. |
| 109 | 112 | set_transient( 'rtsb_cache_cleared_notice', true, 30 ); |
| 110 | - | |
| 111 | - $ref_pram = wp_parse_url( wp_get_referer() ); | |
| 112 | - $path = $ref_pram['path'] ?? '/'; | |
| 113 | - parse_str( ( $ref_pram['query'] ?? '' ), $query_array ); | |
| 114 | - $the_query_arg = add_query_arg( $query_array, home_url( $path ) ); | |
| 115 | - $params[] = '_wpnonce'; | |
| 116 | - $redirect_url = urldecode( remove_query_arg( $params, $the_query_arg ) ); | |
| 117 | - wp_safe_redirect( $redirect_url ); | |
| 113 | + $referrer = wp_get_referer(); // Get the referrer URL. | |
| 114 | + if ( $referrer ) { | |
| 115 | + // Rebuild the URL with the original path and query string. | |
| 116 | + $redirect_url = $referrer; | |
| 117 | + // Redirect to the referrer URL with its query string intact. | |
| 118 | + wp_safe_redirect( $redirect_url ); | |
| 119 | + exit; | |
| 120 | + } | |
| 121 | + // Fallback: if referrer is not available, redirect to home_url(). | |
| 122 | + wp_safe_redirect( home_url() ); | |
| 118 | 123 | exit; |
| 119 | 124 | } |
| 120 | 125 | |
| 121 | 126 | /** |