PluginProbe
Hostinger Tools / 3.0.3
Hostinger Tools v3.0.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 / Helper.php

Helper.php in Hostinger Tools 3.0.3, at includes/Helper.php

76 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hostinger;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Helper {
8 public const HOSTINGER_FREE_SUBDOMAIN_URL = 'hostingersite.com';
9 public const HOSTINGER_PAGE = '/wp-admin/admin.php?page=hostinger';
10 public const CLIENT_WOO_COMPLETED_ACTIONS = 'woocommerce_task_list_tracked_completed_tasks';
11 private const PROMOTIONAL_LINKS = array(
12 'fr_FR' => 'https://www.hostinger.fr/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
13 'es_ES' => 'https://www.hostinger.es/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
14 'ar' => 'https://www.hostinger.ae/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
15 'zh_CN' => 'https://www.hostinger.com.hk/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
16 'id_ID' => 'https://www.hostinger.co.id/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
17 'lt_LT' => 'https://www.hostinger.lt/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
18 'pt_PT' => 'https://www.hostinger.pt/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
19 'uk' => 'https://www.hostinger.com.ua/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
20 'tr_TR' => 'https://www.hostinger.com.tr/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
21 'en_US' => 'https://www.hostinger.com/cpanel-login?r=%2Fjump-to%2Fnew-panel%2Fsection%2Freferrals&utm_source=Banner&utm_medium=HostingerWPplugin',
22 );
23
24 private const HPANEL_DOMAIN_URL = 'https://hpanel.hostinger.com/websites/';
25
26 /**
27 *
28 * Check if plugin is active
29 *
30 * @since 1.0.0
31 * @access public
32 */
33 public static function is_plugin_active( $plugin_slug ): bool {
34 $active_plugins = (array) get_option( 'active_plugins', array() );
35 foreach ( $active_plugins as $active_plugin ) {
36 if ( strpos( $active_plugin, $plugin_slug . '.php' ) !== false ) {
37 return true;
38 }
39 }
40
41 return false;
42 }
43
44 public function is_preview_domain( $headers = null ): bool {
45 // @codeCoverageIgnoreStart
46 if ($headers === null && function_exists('getallheaders')) {
47 $headers = getallheaders();
48 }
49 // @codeCoverageIgnoreEnd
50 if ( isset( $headers['X-Preview-Indicator'] ) && $headers['X-Preview-Indicator'] ) {
51 return true;
52 }
53
54 return false;
55 }
56
57 public static function woocommerce_onboarding_choice(): bool {
58 return (bool) get_option( 'hostinger_woo_onboarding_choice', false );
59 }
60
61 public static function generate_bypass_code( $length ) {
62 $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
63 $code = '';
64 $max_index = strlen( $characters ) - 1;
65
66 for ( $i = 0; $i < $length; $i++ ) {
67 $random_index = wp_rand( 0, $max_index );
68 $code .= $characters[ $random_index ];
69 }
70
71 return $code;
72 }
73 }
74
75 $hostinger_helper = new Helper();
76