| @@ -1,11 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class Hostinger_Helper { |
| 4 | 4 | public const HOSTINGER_FREE_SUBDOMAIN_URL = 'hostingersite.com'; |
| 5 | - public const HOSTINGER_PAGE = [ | |
| 6 | - '/wp-admin/admin.php?page=hostinger' | |
| 7 | - ]; | |
| 5 | + public const HOSTINGER_PAGE = '/wp-admin/admin.php?page=hostinger'; | |
| 8 | 6 | |
| 9 | 7 | /** |
| 10 | 8 | * |
| 11 | 9 | * Check if plugin is active |
| @@ -77,8 +75,13 @@ | ||
| 77 | 75 | return ! empty( $site_url ) && strpos( $site_url, self::HOSTINGER_FREE_SUBDOMAIN_URL ) !== false; |
| 78 | 76 | } |
| 79 | 77 | |
| 80 | 78 | public function is_hostinger_admin_page(): bool { |
| 79 | + | |
| 80 | + if( ! isset( $_SERVER['REQUEST_URI'] ) ) { | |
| 81 | + return false; | |
| 82 | + } | |
| 83 | + | |
| 81 | 84 | $current_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
| 82 | 85 | |
| 83 | 86 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 84 | 87 | return false; |
| @@ -87,15 +90,26 @@ | ||
| 87 | 90 | if ( isset( $current_uri ) && strpos( $current_uri, '/wp-json/' ) !== false ) { |
| 88 | 91 | return false; |
| 89 | 92 | } |
| 90 | 93 | |
| 91 | - if ( in_array( $current_uri, self::HOSTINGER_PAGE ) ) { | |
| 94 | + if ( strpos( $current_uri, self::HOSTINGER_PAGE ) !== false ) { | |
| 92 | 95 | return true; |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | return false; |
| 99 | + } | |
| 96 | 100 | |
| 101 | + /** | |
| 102 | + * | |
| 103 | + * Error log | |
| 104 | + * | |
| 105 | + * @since 1.9.6 | |
| 106 | + * @access public | |
| 107 | + */ | |
| 108 | + public function error_log( string $message ): void { | |
| 109 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) { | |
| 110 | + error_log( print_r( $message, true ) ); | |
| 111 | + } | |
| 97 | 112 | } |
| 98 | - | |
| 99 | 113 | } |
| 100 | 114 | |
| 101 | -$hostiner_helper = new Hostinger_Helper(); | |
| 115 | +$hostinger_helper = new Hostinger_Helper(); | |