-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoosupercharge.php
120 lines (107 loc) · 3.27 KB
/
woosupercharge.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
<?php
/**
* Plugin Name: WooSupercharge
* Description: WooSupercharge is a powerful WooCommerce plugin that enhances your online store with advanced display features. It's designed to provide a seamless and dynamic user experience by incorporating a add to cart notification popup.
* Requires at least: 5.6
* Requires PHP: 7.4
* Version: 2.0
* Author: Jawad Malik
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: woosupercharge
*
* @package woosupercharge
*/
namespace JawadMalik\Woosupercharge;
use JawadMalik\Woosupercharge\Settings;
use JawadMalik\Woosupercharge\Woosupercharge;
use JawadMalik\Woosupercharge\Helpers;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'WOOSUPERCHARGE_VERSION', '2.0' );
define( 'WOOSUPERCHARGE_CHECK_MINIMUM_PHP', '7.4' );
define( 'WOOSUPERCHARGE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'WOOSUPERCHARGE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Check for supported PHP version.
if ( version_compare( phpversion(), WOOSUPERCHARGE_CHECK_MINIMUM_PHP, '<' ) ) {
add_action( 'admin_notices', __NAMESPACE__ . '\\woosupercharge_check_display_php_version_notice' );
return;
}
// Check Composer autoloader exists.
if ( ! file_exists( WOOSUPERCHARGE_PLUGIN_DIR . 'vendor/autoload.php' ) ) {
add_action( 'admin_notices', __NAMESPACE__ . '\\woosupercharge_check_display_composer_autoload_notice' );
return;
}
// include autoloader from composer.
require_once __DIR__ . '/vendor/autoload.php';
// Check Woocommerce is active.
if ( ! Helpers::is_woocommerce_active() ) {
add_action( 'admin_notices', __NAMESPACE__ . '\\woocommerce_not_active_notice' );
return;
}
/**
* Displays admin notice about unmet PHP version requirement.
*
* @since 2.0
*/
function woosupercharge_check_display_php_version_notice(): void {
echo '<div class="notice notice-error"><p>';
printf(
/* translators: 1: required version, 2: currently used version */
esc_html__( 'Woosupercharge requires at least PHP version %1$s. Your site is currently running on PHP %2$s.', 'woosupercharge' ),
esc_html( WOOSUPERCHARGE_CHECK_MINIMUM_PHP ),
esc_html( phpversion() )
);
echo '</p></div>';
}
/**
* Displays admin notice about missing Composer autoload files.
*
* @since 2.0
*/
function woosupercharge_check_display_composer_autoload_notice(): void {
echo '<div class="notice notice-error"><p>';
printf(
/* translators: composer command. */
esc_html__( 'Your installation of the Woosupercharge plugin is incomplete. Please run %s.', 'woosupercharge' ),
'<code>composer install</code>'
);
echo '</p></div>';
}
/**
* Displays admin notice about missing Composer autoload files.
*
* @since 2.0
*/
function woocommerce_not_active_notice(): void {
echo '<div class="notice notice-error"><p>';
printf(
esc_html__( 'Woosupercharge is meant to be used with WooCommerce. Plz make sure Woocommerce is active.', 'woosupercharge' ),
);
echo '</p></div>';
}
/**
* Setup plugin.
*
* @since 2.0
*/
add_action(
'woosupercharge',
function ( Woosupercharge $plugin ) {
$plugin->setup();
}
);
/**
* Start Plugin
*
* @since 2.0
* @param Woosupercharge $plugin
*/
do_action(
'woosupercharge',
new Woosupercharge(
new Settings(),
WOOSUPERCHARGE_VERSION
)
);