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