PluginProbe
Hostinger Tools / 3.0.58
Hostinger Tools v3.0.58
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 / hostinger.php

hostinger.php in Hostinger Tools 3.0.58, at hostinger.php

152 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Hostinger Tools
4 * Plugin URI: https://hostinger.com
5 * Description: Hostinger WordPress plugin.
6 * Version: 3.0.58
7 * Requires at least: 5.5
8 * Tested up to: 6.9
9 * Requires PHP: 8.1
10 * Author: Hostinger
11 * License: GPL v3
12 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
13 * Author URI: https://www.hostinger.com
14 * Text Domain: hostinger
15 * Domain Path: /languages
16 *
17 * @package Hostinger
18 */
19
20 use Hostinger\Hostinger;
21 use Hostinger\Activator;
22 use Hostinger\Deactivator;
23 use Hostinger\WpMenuManager\Manager;
24
25 defined( 'ABSPATH' ) || exit;
26
27 if ( ! defined( 'HOSTINGER_VERSION' ) ) {
28 define( 'HOSTINGER_VERSION', '3.0.58' );
29 }
30
31 if ( ! defined( 'HOSTINGER_ABSPATH' ) ) {
32 define( 'HOSTINGER_ABSPATH', plugin_dir_path( __FILE__ ) );
33 }
34
35 if ( ! defined( 'HOSTINGER_PLUGIN_FILE' ) ) {
36 define( 'HOSTINGER_PLUGIN_FILE', __FILE__ );
37 }
38
39 if ( ! defined( 'HOSTINGER_PLUGIN_URL' ) ) {
40 define( 'HOSTINGER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41 }
42
43 if ( ! defined( 'HOSTINGER_ASSETS_URL' ) ) {
44 define( 'HOSTINGER_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
45 }
46
47 if ( ! defined( 'HOSTINGER_VUE_ASSETS_URL' ) ) {
48 define( 'HOSTINGER_VUE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'vue-frontend/dist' );
49 }
50
51 if ( ! defined( 'HOSTINGER_WP_CONFIG_PATH' ) ) {
52 define( 'HOSTINGER_WP_CONFIG_PATH', ABSPATH . '.private/config.json' );
53 }
54
55 if ( ! defined( 'HOSTINGER_WP_TOKEN' ) ) {
56 $hostinger_dir_parts = explode( '/', __DIR__ );
57 $hostinger_server_root_path = '/' . $hostinger_dir_parts[1] . '/' . $hostinger_dir_parts[2];
58 define( 'HOSTINGER_WP_TOKEN', $hostinger_server_root_path . '/.api_token' );
59 }
60
61 if ( ! defined( 'HOSTINGER_REST_URI' ) ) {
62 define( 'HOSTINGER_REST_URI', 'https://rest-hosting.hostinger.com' );
63 }
64
65 if ( ! defined( 'HOSTINGER_PLUGIN_SETTINGS_OPTION' ) ) {
66 define( 'HOSTINGER_PLUGIN_SETTINGS_OPTION', 'hostinger_tools' );
67 }
68
69 if ( ! defined( 'HOSTINGER_PLUGIN_REST_API_BASE' ) ) {
70 define( 'HOSTINGER_PLUGIN_REST_API_BASE', 'hostinger-tools-plugin/v1' );
71 }
72
73 if ( ! defined( 'HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION' ) ) {
74 define( 'HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION', '8.1' );
75 }
76
77 if ( ! version_compare( phpversion(), HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION, '>=' ) ) {
78 add_action(
79 'admin_notices',
80 function () {
81 ?>
82 <div class="notice notice-error is-dismissible hts-theme-settings">
83 <p>
84 <?php /* translators: %s: PHP version */ ?>
85 <strong><?php echo esc_html__( 'Attention:', 'hostinger' ); ?></strong> <?php printf( wp_kses( 'The Hostinger plugin requires minimum PHP version of <b>%s</b>.', 'hostinger' ), esc_html( HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION ) ); ?>
86 </p>
87 <p>
88 <?php /* translators: %s: PHP version */ ?>
89 <?php printf( wp_kses( 'You are running <b>%s</b> PHP version.', 'hostinger' ), esc_html( phpversion() ) ); ?>
90 </p>
91 </div>
92 <?php
93 }
94 );
95
96 return;
97 }
98
99 $vendor_file = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload_packages.php';
100
101 if ( file_exists( $vendor_file ) ) {
102 require_once $vendor_file;
103 } else {
104 return;
105 }
106
107 // Action Scheduler should be loaded before plugins_loaded hook.
108 $action_scheduler = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'woocommerce' . DIRECTORY_SEPARATOR . 'action-scheduler' . DIRECTORY_SEPARATOR . 'action-scheduler.php';
109 if ( file_exists( $action_scheduler ) ) {
110 require_once $action_scheduler;
111 }
112
113 /**
114 * Plugin activation hook.
115 */
116 function hostinger_activate(): void {
117 Activator::activate();
118 }
119
120 /**
121 * Plugin deactivation hook.
122 */
123 function hostinger_deactivate(): void {
124 Deactivator::deactivate();
125 }
126
127 register_activation_hook( __FILE__, 'hostinger_activate' );
128 register_deactivation_hook( __FILE__, 'hostinger_deactivate' );
129
130 if ( ! function_exists( 'hostinger_load_menus' ) ) {
131 function hostinger_load_menus(): void {
132 $manager = Manager::getInstance();
133 $manager->boot();
134 }
135 }
136
137 if ( ! has_action( 'plugins_loaded', 'hostinger_load_menus' ) ) {
138 add_action( 'plugins_loaded', 'hostinger_load_menus' );
139 }
140
141
142 function load_plugin() {
143 if ( class_exists( 'Hostinger\Hostinger' ) ) {
144 $hostinger = new Hostinger();
145 $hostinger->run();
146 }
147 }
148 add_action( 'plugins_loaded', 'load_plugin' );
149
150
151
152