| 1 |
<?php |
| 2 |
|
| 3 |
namespace Hostinger; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || exit; |
| 6 |
|
| 7 |
class Hooks { |
| 8 |
|
| 9 |
public function __construct() { |
| 10 |
add_action( 'init', array( $this, 'check_url_and_flush_rules' ) ); |
| 11 |
} |
| 12 |
|
| 13 |
public function check_url_and_flush_rules() { |
| 14 |
if ( defined( 'DOING_AJAX' ) && \DOING_AJAX ) { |
| 15 |
return false; |
| 16 |
} |
| 17 |
|
| 18 |
$current_url = home_url( add_query_arg( null, null ) ); |
| 19 |
$url_components = wp_parse_url( $current_url ); |
| 20 |
|
| 21 |
if ( isset( $url_components['query'] ) ) { |
| 22 |
parse_str( $url_components['query'], $params ); |
| 23 |
|
| 24 |
if ( isset( $params['app_name'] ) ) { |
| 25 |
$app_name = sanitize_text_field( $params['app_name'] ); |
| 26 |
|
| 27 |
if ( $app_name === 'Omnisend App' ) { |
| 28 |
if ( function_exists( 'flush_rewrite_rules' ) ) { |
| 29 |
flush_rewrite_rules(); |
| 30 |
} |
| 31 |
|
| 32 |
if ( has_action( 'litespeed_purge_all' ) ) { |
| 33 |
do_action( 'litespeed_purge_all' ); |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
} |
| 41 |
|