| @@ -1,12 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | /** |
| 4 | 3 | * Plugin Name: Hostinger |
| 5 | 4 | * Plugin URI: https://hostinger.com |
| 6 | 5 | * Description: Hostinger WordPress plugin. |
| 7 | - * Version: 1.9.1 | |
| 8 | - * Requires at least: 5.6 | |
| 6 | + * Version: 2.2.2 | |
| 7 | + * Requires at least: 5.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,14 +12,19 @@ | ||
| 13 | 12 | * Author URI: https://www.hostinger.com |
| 14 | 13 | * Text Domain: hostinger |
| 15 | 14 | * Domain Path: /languages |
| 16 | 15 | * |
| 16 | + * @package Hostinger | |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | +use Hostinger\Hostinger; | |
| 20 | +use Hostinger\Activator; | |
| 21 | +use Hostinger\Deactivator; | |
| 22 | + | |
| 19 | 23 | defined( 'ABSPATH' ) || exit; |
| 20 | 24 | |
| 21 | 25 | if ( ! defined( 'HOSTINGER_VERSION' ) ) { |
| 22 | - define( 'HOSTINGER_VERSION', '1.9.1' ); | |
| 26 | + define( 'HOSTINGER_VERSION', '2.2.2' ); | |
| 23 | 27 | } |
| 24 | 28 | |
| 25 | 29 | if ( ! defined( 'HOSTINGER_ABSPATH' ) ) { |
| 26 | 30 | define( 'HOSTINGER_ABSPATH', plugin_dir_path( __FILE__ ) ); |
| @@ -38,15 +42,15 @@ | ||
| 38 | 42 | define( 'HOSTINGER_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' ); |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | 45 | if ( ! defined( 'HOSTINGER_WP_CONFIG_PATH' ) ) { |
| 42 | - define( 'HOSTINGER_WP_CONFIG_PATH', ABSPATH . '/.private/config.json' ); | |
| 46 | + define( 'HOSTINGER_WP_CONFIG_PATH', ABSPATH . '.private/config.json' ); | |
| 43 | 47 | } |
| 44 | 48 | |
| 45 | 49 | if ( ! defined( 'HOSTINGER_WP_TOKEN' ) ) { |
| 46 | - $path = explode('/', __DIR__); | |
| 47 | - $serverRootPath = '/' . $path[1] . '/' . $path[2]; | |
| 48 | - define( 'HOSTINGER_WP_TOKEN', $serverRootPath . '/.api_token' ); | |
| 50 | + $hostinger_dir_parts = explode( '/', __DIR__ ); | |
| 51 | + $hostinger_server_root_path = '/' . $hostinger_dir_parts[1] . '/' . $hostinger_dir_parts[2]; | |
| 52 | + define( 'HOSTINGER_WP_TOKEN', $hostinger_server_root_path . '/.api_token' ); | |
| 49 | 53 | } |
| 50 | 54 | |
| 51 | 55 | if ( ! defined( 'HOSTINGER_REST_URI' ) ) { |
| 52 | 56 | define( 'HOSTINGER_REST_URI', 'https://rest-hosting.hostinger.com' ); |
| @@ -51,20 +55,30 @@ | ||
| 51 | 55 | if ( ! defined( 'HOSTINGER_REST_URI' ) ) { |
| 52 | 56 | define( 'HOSTINGER_REST_URI', 'https://rest-hosting.hostinger.com' ); |
| 53 | 57 | } |
| 54 | 58 | |
| 55 | -function activate_hostinger(): void { | |
| 56 | - require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-activator.php'; | |
| 57 | - Hostinger_Activator::activate(); | |
| 59 | +$vendor_file = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; | |
| 60 | + | |
| 61 | +if ( file_exists( $vendor_file ) ) { | |
| 62 | + require_once $vendor_file; | |
| 58 | 63 | } |
| 59 | 64 | |
| 60 | -function deactivate_hostinger(): void { | |
| 61 | - require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-deactivator.php'; | |
| 62 | - Hostinger_Deactivator::deactivate(); | |
| 65 | +/** | |
| 66 | + * Plugin activation hook. | |
| 67 | + */ | |
| 68 | +function hostinger_activate(): void { | |
| 69 | + Activator::activate(); | |
| 63 | 70 | } |
| 64 | 71 | |
| 65 | -register_activation_hook( __FILE__, 'activate_hostinger' ); | |
| 66 | -register_deactivation_hook( __FILE__, 'deactivate_hostinger' ); | |
| 67 | -require_once HOSTINGER_ABSPATH . 'includes/class-hostinger.php'; | |
| 72 | +/** | |
| 73 | + * Plugin deactivation hook. | |
| 74 | + */ | |
| 75 | +function hostinger_deactivate(): void { | |
| 76 | + Deactivator::deactivate(); | |
| 77 | +} | |
| 68 | 78 | |
| 69 | -$plugin = new Hostinger(); | |
| 70 | -$plugin->run(); | |
| 79 | +register_activation_hook( __FILE__, 'hostinger_activate' ); | |
| 80 | +register_deactivation_hook( __FILE__, 'hostinger_deactivate' ); | |
| 81 | + | |
| 82 | + | |
| 83 | +$hostinger = new Hostinger(); | |
| 84 | +$hostinger->run(); | |