| @@ -10,21 +10,20 @@ | ||
| 10 | 10 | add_action( 'init', array( $this, 'check_url_and_flush_rules' ) ); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public function check_url_and_flush_rules() { |
| 14 | - $https = isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; | |
| 15 | - $host = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ); | |
| 16 | - $request_uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ); | |
| 14 | + if ( defined( 'DOING_AJAX' ) && \DOING_AJAX ) { | |
| 15 | + return false; | |
| 16 | + } | |
| 17 | 17 | |
| 18 | - $current_url = $https . "://" . $host . $request_uri; | |
| 19 | - $url_components = parse_url( $current_url ); | |
| 18 | + $current_url = home_url( add_query_arg( null, null ) ); | |
| 19 | + $url_components = wp_parse_url( $current_url ); | |
| 20 | 20 | |
| 21 | 21 | if ( isset( $url_components['query'] ) ) { |
| 22 | 22 | parse_str( $url_components['query'], $params ); |
| 23 | 23 | |
| 24 | 24 | if ( isset( $params['app_name'] ) ) { |
| 25 | - $app_name = sanitize_text_field( urldecode( $params['app_name'] ) ); | |
| 26 | - $app_name = str_replace( '+', ' ', $app_name ); | |
| 25 | + $app_name = sanitize_text_field( $params['app_name'] ); | |
| 27 | 26 | |
| 28 | 27 | if ( $app_name === 'Omnisend App' ) { |
| 29 | 28 | if ( function_exists( 'flush_rewrite_rules' ) ) { |
| 30 | 29 | flush_rewrite_rules(); |