| @@ -78,10 +78,9 @@ | ||
| 78 | 78 | ] |
| 79 | 79 | ); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - | |
| 83 | - /** | |
| 82 | + /*** | |
| 84 | 83 | * |
| 85 | 84 | * @return mixed |
| 86 | 85 | */ |
| 87 | 86 | public function admin_bar_menu_action() { |
| @@ -90,14 +89,12 @@ | ||
| 90 | 89 | } |
| 91 | 90 | if ( ! current_user_can( 'manage_options' ) ) { |
| 92 | 91 | return; |
| 93 | 92 | } |
| 94 | - | |
| 95 | 93 | $clear_cache = sanitize_text_field( wp_unslash( $_GET['rtsb_clear_cache'] ?? '' ) ); |
| 96 | 94 | if ( empty( $clear_cache ) ) { |
| 97 | 95 | return; |
| 98 | 96 | } |
| 99 | - | |
| 100 | 97 | switch ( $clear_cache ) { |
| 101 | 98 | case 'all': |
| 102 | 99 | Cache::clear_all_cache(); |
| 103 | 100 | break; |
| @@ -109,18 +106,16 @@ | ||
| 109 | 106 | break; |
| 110 | 107 | } |
| 111 | 108 | // Set the notice flag. |
| 112 | 109 | set_transient( 'rtsb_cache_cleared_notice', true, 30 ); |
| 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() ); | |
| 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 ); | |
| 123 | 118 | exit; |
| 124 | 119 | } |
| 125 | 120 | |
| 126 | 121 | /** |