| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Hostinger Reach |
| 4 |
* Plugin URI: https://hostinger.com |
| 5 |
* Description: Integrate your WordPress site with Hostinger Reach. |
| 6 |
* Version: 1.2.1 |
| 7 |
* Author: Hostinger |
| 8 |
* Requires PHP: 8.0 |
| 9 |
* Requires at least: 6.0 |
| 10 |
* Tested up to: 6.8 |
| 11 |
* Author URI: https://www.hostinger.com/email-marketing |
| 12 |
* License: GPL-2.0+ |
| 13 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 14 |
* Text Domain: hostinger-reach |
| 15 |
* Domain Path: /languages |
| 16 |
* |
| 17 |
* @package HostingerReach |
| 18 |
*/ |
| 19 |
|
| 20 |
use Hostinger\Reach\Setup\Activator; |
| 21 |
use Hostinger\WpMenuManager\Manager; |
| 22 |
use Hostinger\Surveys\Loader; |
| 23 |
|
| 24 |
if ( ! defined( 'ABSPATH' ) ) { |
| 25 |
die; |
| 26 |
} |
| 27 |
|
| 28 |
define( 'HOSTINGER_REACH_PLUGIN_VERSION', '1.2.1' ); |
| 29 |
define( 'HOSTINGER_REACH_DB_VERSION', '1.2.1' ); |
| 30 |
define( 'HOSTINGER_REACH_MINIMUM_PHP_VERSION', '8.0' ); |
| 31 |
define( 'HOSTINGER_REACH_PLUGIN_FILE', __FILE__ ); |
| 32 |
define( 'HOSTINGER_REACH_PLUGIN_SLUG', basename( __FILE__, '.php' ) ); |
| 33 |
define( 'HOSTINGER_REACH_PLUGIN_URL', plugin_dir_url( HOSTINGER_REACH_PLUGIN_FILE ) ); |
| 34 |
define( 'HOSTINGER_REACH_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 35 |
define( 'HOSTINGER_REACH_PLUGIN_REST_API_BASE', 'hostinger-reach/v1' ); |
| 36 |
define( 'HOSTINGER_REACH_REST_URI', 'https://reach.hostinger.com' ); |
| 37 |
define( 'HOSTINGER_REACH_DEFAULT_CONTACT_LIST', 'WordPress' ); |
| 38 |
define( 'HOSTINGER_INTEGRATIONS_SUPPORTED', true ); |
| 39 |
define( 'HOSTINGER_REACH_DEFAULT_ABANDONED_CART_THRESHOLD', 4 * HOUR_IN_SECONDS ); |
| 40 |
|
| 41 |
$hostinger_dir_parts = explode( '/', __DIR__ ); |
| 42 |
$hostinger_server_root_path = '/' . $hostinger_dir_parts[1] . '/' . $hostinger_dir_parts[2]; |
| 43 |
define( 'HOSTINGER_REACH_WP_TOKEN', $hostinger_server_root_path . '/.api_token' ); |
| 44 |
|
| 45 |
if ( ! version_compare( phpversion(), HOSTINGER_REACH_MINIMUM_PHP_VERSION, '>=' ) ) { |
| 46 |
add_action( |
| 47 |
'admin_notices', |
| 48 |
function (): void { |
| 49 |
?> |
| 50 |
<div class="notice notice-error is-dismissible hts-theme-settings"> |
| 51 |
<p> |
| 52 |
<strong><?php echo esc_html( __( 'Attention:', 'hostinger-reach' ) ); ?></strong> |
| 53 |
<?php /* translators: %s: PHP version */ ?> |
| 54 |
<?php echo esc_html( sprintf( __( 'Hostinger Reach requires minimum PHP version of <b>%s</b>. ', 'hostinger-reach' ), HOSTINGER_REACH_MINIMUM_PHP_VERSION ) ); ?> |
| 55 |
</p> |
| 56 |
<p> |
| 57 |
<?php /* translators: %s: PHP version */ ?> |
| 58 |
<?php echo esc_html( sprintf( __( 'You are running <b>%s</b> PHP version.', 'hostinger-reach' ), phpversion() ) ); ?> |
| 59 |
</p> |
| 60 |
</div> |
| 61 |
<?php |
| 62 |
} |
| 63 |
); |
| 64 |
|
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
$vendor_file = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload_packages.php'; |
| 69 |
$composer_autoload = __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; |
| 70 |
|
| 71 |
if ( file_exists( $vendor_file ) ) { |
| 72 |
require_once $vendor_file; |
| 73 |
} |
| 74 |
|
| 75 |
if ( file_exists( $composer_autoload ) ) { |
| 76 |
require_once $composer_autoload; |
| 77 |
} |
| 78 |
|
| 79 |
if ( class_exists( 'Hostinger\Reach\Setup\Activator' ) ) { |
| 80 |
new Activator( __FILE__ ); |
| 81 |
} |
| 82 |
|
| 83 |
if ( ! function_exists( 'hostinger_load_menus' ) ) { |
| 84 |
function hostinger_load_menus(): void { |
| 85 |
$manager = Manager::getInstance(); |
| 86 |
$manager->boot(); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
if ( ! has_action( 'plugins_loaded', 'hostinger_load_menus' ) ) { |
| 91 |
add_action( 'plugins_loaded', 'hostinger_load_menus' ); |
| 92 |
} |
| 93 |
|
| 94 |
if ( ! function_exists( 'hostinger_add_surveys' ) ) { |
| 95 |
function hostinger_add_surveys(): void { |
| 96 |
$surveys = Loader::getInstance(); |
| 97 |
$surveys->boot(); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if ( ! empty( $_SERVER['H_PLATFORM'] ) && ! has_action( 'plugins_loaded', 'hostinger_add_surveys' ) ) { |
| 102 |
add_action( 'plugins_loaded', 'hostinger_add_surveys' ); |
| 103 |
} |
| 104 |
|