PluginProbe
Hostinger Tools / 1.8.3
Hostinger Tools v1.8.3
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
hostinger / includes / class-hostinger-helper.php

class-hostinger-helper.php in Hostinger Tools 1.8.3, at includes/class-hostinger-helper.php

69 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 class Hostinger_Helper {
6
7 /**
8 *
9 * Check if plugin is active
10 *
11 * @since 1.0.0
12 * @access public
13 */
14 public static function is_plugin_active( $plugin_slug ): bool {
15 $active_plugins = (array) get_option( 'active_plugins', array() );
16 foreach ( $active_plugins as $active_plugin ) {
17 if ( strpos( $active_plugin, $plugin_slug . '.php' ) !== false ) {
18 return true;
19 }
20 }
21
22 return false;
23 }
24
25 public static function get_api_token(): string {
26 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
27 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
28
29 $api_token = '';
30 $token_path = HOSTINGER_WP_TOKEN;
31 $filesystem = new WP_Filesystem_Direct( true );
32 $token_file = $filesystem->get_contents( $token_path );
33
34 if ( file_exists( $token_path ) && ! empty( $token_file ) ) {
35 $api_token = $token_file;
36 }
37
38 return $api_token;
39 }
40
41 /**
42 *
43 * Get the host info (domain, subdomain, subdirectory)
44 *
45 * @since 1.7.0
46 * @access public
47 */
48
49 public function get_host_info(): string {
50 $host = sanitize_text_field( $_SERVER['HTTP_HOST'] ?? '' );
51 $site_url = get_site_url();
52 $site_url = preg_replace( '#^https?://#', '', $site_url );
53
54 if ( ! empty( $site_url ) && ! empty( $host ) && strpos( $site_url, $host ) === 0 ) {
55 if ( $site_url === $host ) {
56 return $host;
57 } else {
58 return substr( $site_url, strlen( $host ) + 1 );
59 }
60 }
61
62 return $host;
63 }
64
65
66 }
67
68 $hostiner_helper = new Hostinger_Helper();
69