This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roi-hunter-easy-for-woocommerce.php
128 lines (95 loc) · 4.39 KB
/
roi-hunter-easy-for-woocommerce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*
Plugin Name: ROI Hunter Easy for WooCommerce
Description: Turn visitors into customers.
Version: 1.0.9
Author: ROI Hunter Easy
Author URI: https://easy.roihunter.com
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'RH_EASY_DIR', plugin_dir_path( __FILE__ ) );
define( 'RH_EASY_URL', plugin_dir_url( __FILE__ ) );
define( 'RH_EASY_BASENAME', plugin_basename( __FILE__ ) );
define( 'RH_EASY_VERSION', '1.0.9' );
define( 'RH_EASY_FRONTEND_URL', 'https://goostav-fe.roihunter.com/' );
define( 'RH_EASY_MIN_WC_VERSION', '3.4.0');
/**
* Localize plugin
*/
add_action( 'init', 'roi_hunter_easy_localize_plugin' );
function roi_hunter_easy_localize_plugin() {
load_plugin_textdomain( 'roi-hunter-easy', false, RH_EASY_DIR . 'languages/' );
}
/**
* Load plugin and check if WooCommerce is active.
*/
add_action( 'plugins_loaded', 'roi_hunter_easy_plugin_init' );
function roi_hunter_easy_plugin_init() {
// If WooCommerce is NOT active, if not correct version or not pretty permalinks or old PHP version
if ( ! class_exists( 'woocommerce' ) || ! get_option('permalink_structure') || ( class_exists( 'woocommerce' ) && version_compare( wc()->version, RH_EASY_MIN_WC_VERSION, '<' ) ) || version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
add_action( 'admin_init', 'roi_hunter_easy_deactivate' );
add_action( 'admin_notices', 'roi_hunter_easy_admin_notice' );
return;
}
// Classes
require_once( RH_EASY_DIR . 'includes/class-rh-easy-helper.php' );
require_once( RH_EASY_DIR . 'includes/class-rh-easy-fb-pixel.php' );
require_once( RH_EASY_DIR . 'includes/class-rh-easy-google-remarketing.php' );
// Endpoints
require_once( RH_EASY_DIR . 'includes/rest-api-endpoints.php' );
// Scripts
require_once( RH_EASY_DIR . 'includes/enqueue_scripts.php' );
require_once( RH_EASY_DIR . 'includes/ajax.php' );
// Admin
require_once( RH_EASY_DIR . 'includes/admin/settings.php' );
require_once( RH_EASY_DIR . 'includes/admin/plugin-settings-link.php' );
require_once( RH_EASY_DIR . 'includes/admin/rating.php' );
}
/**
* The code that runs during plugin activation.
* This action is documented in includes/activation.php
*/
function activate_roi_hunter_easy() {
require_once( RH_EASY_DIR . 'includes/activation.php' );
}
register_activation_hook( __FILE__, 'activate_roi_hunter_easy' );
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/deactivation.php
*/
function deactivate_roi_hunter_easy() {
require_once ( RH_EASY_DIR . 'includes/deactivation.php' );
}
register_deactivation_hook( __FILE__, 'deactivate_roi_hunter_easy' );
/**
* Deactivate the Child Plugin
*/
function roi_hunter_easy_deactivate() {
deactivate_plugins( RH_EASY_BASENAME );
}
/**
* Throw an Alert to tell the Admin why it didn't activate
*/
function roi_hunter_easy_admin_notice() {
$roi_hunter_easy_plugin = esc_html( __( 'ROI Hunter Easy', 'roi-hunter-easy' ) );
$woocommerce_plugin = esc_html( __( 'WooCommerce', 'roi-hunter-easy' ) );
$error = '<div class="error">';
if ( ! class_exists( 'woocommerce' ) ) {
$error .= '<p>' . sprintf( __( '%1$s requires %2$s version %3$s. Please activate/install %2$s before activation of %1$s. ', 'roi-hunter-easy' ), $roi_hunter_easy_plugin, $woocommerce_plugin, RH_EASY_MIN_WC_VERSION ) . '</p>';
} elseif ( version_compare( wc()->version, RH_EASY_MIN_WC_VERSION, '<' ) ) {
$error .= '<p>' . sprintf( __( '%1$s requires %2$s version %3$s. Please upgrade %2$s at least to version %3$s before activation of %1$s. ', 'roi-hunter-easy' ), $roi_hunter_easy_plugin, $woocommerce_plugin, RH_EASY_MIN_WC_VERSION ) . '</p>';
}
if ( ! get_option('permalink_structure') ) {
$error .= '<p>' . sprintf( __( '%1$s requires pretty permalinks enabled. Please enable pretty permalinks in your settings before activation of %1$s. <b>WARNING: In order to not to loose SEO of your page redirect all old URL to the new ones using your .htaccess and Redirect 301 rules.</b>', 'roi-hunter-easy' ), $roi_hunter_easy_plugin ) . '</p>';
}
if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
$error .= '<p>' . sprintf( __( '%1$s requires at least PHP 5.3. Contact your hosting provider for more support.</b>', 'roi-hunter-easy' ), $roi_hunter_easy_plugin ) . '</p>';
}
$error .= __('The plugin has been deactivated.', 'roi-hunter-easy' ) . '</div>';
echo $error;
if ( isset( $_GET['activate'] ) )
unset( $_GET['activate'] );
}