hostinger-reach
Last commit date
frontend
3 days ago
languages
3 weeks ago
src
3 days ago
templates
8 months ago
vendor
3 days ago
changelog.txt
3 days ago
composer.json
1 month ago
hostinger-reach.php
3 days ago
package.json
3 days ago
readme.txt
3 days ago
hostinger-reach.php
99 lines
| 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.6.0 |
| 7 | * Author: Hostinger |
| 8 | * Requires PHP: 8.1 |
| 9 | * Requires at least: 6.0 |
| 10 | * Tested up to: 7.0 |
| 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.6.0' ); |
| 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 | |
| 70 | if ( file_exists( $vendor_file ) ) { |
| 71 | require_once $vendor_file; |
| 72 | } |
| 73 | |
| 74 | if ( class_exists( 'Hostinger\Reach\Setup\Activator' ) ) { |
| 75 | new Activator( __FILE__ ); |
| 76 | } |
| 77 | |
| 78 | if ( ! function_exists( 'hostinger_load_menus' ) ) { |
| 79 | function hostinger_load_menus(): void { |
| 80 | $manager = Manager::getInstance(); |
| 81 | $manager->boot(); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if ( ! has_action( 'plugins_loaded', 'hostinger_load_menus' ) ) { |
| 86 | add_action( 'plugins_loaded', 'hostinger_load_menus' ); |
| 87 | } |
| 88 | |
| 89 | if ( ! function_exists( 'hostinger_add_surveys' ) ) { |
| 90 | function hostinger_add_surveys(): void { |
| 91 | $surveys = Loader::getInstance(); |
| 92 | $surveys->boot(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | if ( ! empty( $_SERVER['H_PLATFORM'] ) && ! has_action( 'plugins_loaded', 'hostinger_add_surveys' ) ) { |
| 97 | add_action( 'plugins_loaded', 'hostinger_add_surveys' ); |
| 98 | } |
| 99 |