PluginProbe
Hostinger Tools / 3.0.0
Hostinger Tools v3.0.0
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.0, at hostinger.php

134 lines 3.7 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.0
7 * Requires at least: 5.5
8 * Requires PHP: 8.0
9 * Author: Hostinger
10 * License: GPL v3
11 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
12 * Author URI: https://www.hostinger.com
13 * Text Domain: hostinger
14 * Domain Path: /languages
15 *
16 * @package Hostinger
17 */
18
19 use Hostinger\Hostinger;
20 use Hostinger\Activator;
21 use Hostinger\Deactivator;
22 use Hostinger\WpMenuManager\Manager;
23
24 defined( 'ABSPATH' ) || exit;
25
26 if ( ! defined( 'HOSTINGER_VERSION' ) ) {
27 define( 'HOSTINGER_VERSION', '3.0.0' );
28 }
29
30 if ( ! defined( 'HOSTINGER_ABSPATH' ) ) {
31 define( 'HOSTINGER_ABSPATH', plugin_dir_path( __FILE__ ) );
32 }
33
34 if ( ! defined( 'HOSTINGER_PLUGIN_FILE' ) ) {
35 define( 'HOSTINGER_PLUGIN_FILE', __FILE__ );
36 }
37
38 if ( ! defined( 'HOSTINGER_PLUGIN_URL' ) ) {
39 define( 'HOSTINGER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
40 }
41
42 if ( ! defined( 'HOSTINGER_ASSETS_URL' ) ) {
43 define( 'HOSTINGER_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
44 }
45
46 if ( ! defined( 'HOSTINGER_VUE_ASSETS_URL' ) ) {
47 define( 'HOSTINGER_VUE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'vue-frontend/dist' );
48 }
49
50 if ( ! defined( 'HOSTINGER_WP_CONFIG_PATH' ) ) {
51 define( 'HOSTINGER_WP_CONFIG_PATH', ABSPATH . '.private/config.json' );
52 }
53
54 if ( ! defined( 'HOSTINGER_WP_TOKEN' ) ) {
55 $hostinger_dir_parts = explode( '/', __DIR__ );
56 $hostinger_server_root_path = '/' . $hostinger_dir_parts[1] . '/' . $hostinger_dir_parts[2];
57 define( 'HOSTINGER_WP_TOKEN', $hostinger_server_root_path . '/.api_token' );
58 }
59
60 if ( ! defined( 'HOSTINGER_REST_URI' ) ) {
61 define( 'HOSTINGER_REST_URI', 'https://rest-hosting.hostinger.com' );
62 }
63
64 if ( ! defined( 'HOSTINGER_PLUGIN_SETTINGS_OPTION' ) ) {
65 define( 'HOSTINGER_PLUGIN_SETTINGS_OPTION', 'hostinger_tools' );
66 }
67
68 if ( ! defined( 'HOSTINGER_PLUGIN_REST_API_BASE' ) ) {
69 define( 'HOSTINGER_PLUGIN_REST_API_BASE', 'hostinger-tools-plugin/v1' );
70 }
71
72 if ( ! defined( 'HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION' ) ) {
73 define( 'HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION', '8.0' );
74 }
75
76 if ( ! version_compare( phpversion(), HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION, '>=' ) ) {
77
78 add_action( 'admin_notices', function() {
79 ?>
80 <div class="notice notice-error is-dismissible hts-theme-settings">
81 <p>
82 <?php /* translators: %s: PHP version */ ?>
83 <strong><?php echo __( 'Attention:', 'hostinger' ); ?></strong> <?php echo sprintf( __( 'The Hostinger plugin requires minimum PHP version of <b>%s</b>. ', 'hostinger' ), HOSTINGER_PLUGIN_MINIMUM_PHP_VERSION ); ?>
84 </p>
85 <p>
86 <?php /* translators: %s: PHP version */ ?>
87 <?php echo sprintf( __( 'You are running <b>%s</b> PHP version.', 'hostinger' ), phpversion() ); ?>
88 </p>
89 </div>
90 <?php
91 }
92 );
93
94 return;
95 }
96
97 $vendor_file = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
98
99 if ( file_exists( $vendor_file ) ) {
100 require_once $vendor_file;
101 }
102
103 /**
104 * Plugin activation hook.
105 */
106 function hostinger_activate(): void {
107 Activator::activate();
108 }
109
110 /**
111 * Plugin deactivation hook.
112 */
113 function hostinger_deactivate(): void {
114 Deactivator::deactivate();
115 }
116
117 register_activation_hook( __FILE__, 'hostinger_activate' );
118 register_deactivation_hook( __FILE__, 'hostinger_deactivate' );
119
120 if( !function_exists('hostinger_load_menus') ) {
121 function hostinger_load_menus(): void
122 {
123 $manager = Manager::getInstance();
124 $manager->boot();
125 }
126 }
127
128 if ( ! has_action( 'plugins_loaded', 'hostinger_load_menus' ) ) {
129 add_action('plugins_loaded', 'hostinger_load_menus');
130 }
131
132 $hostinger = new Hostinger();
133 $hostinger->run();
134