PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.6.9
EmailKit – Email Customizer for WooCommerce & WP v1.6.9
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / Dependency.php

Dependency.php in EmailKit – Email Customizer for WooCommerce & WP 1.6.9, at includes/Admin/Dependency.php

101 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EmailKit\Admin;
3
4 use EmailKit;
5
6 defined("ABSPATH") || exit;
7
8 class Dependency {
9
10 const INACTIVE = 'inactive';
11 const ACTIVE = 'active';
12 const NEED_INSTALL = 'install';
13
14
15 public static function check(string $plugin) {
16
17
18 $dependency = self::dependency_list($plugin);
19 if($dependency){
20 if(!empty($dependency['status']) && $dependency['status'] == self::INACTIVE) {
21 return $dependency['active'];
22 } else if(!empty($dependency['status']) && $dependency['status'] == self::NEED_INSTALL) {
23 return $dependency['install'];
24 }
25 }
26
27 return true;
28 }
29
30
31 public static function dependency_list(string $dependency = ''): array {
32
33
34 if(!function_exists('is_plugin_active')){
35 // Include necessary WordPress files
36 require_once ABSPATH . 'wp-admin/includes/plugin.php';
37
38 }
39
40 $dependency_list = [
41 'wordpress' => [
42 'status' => self::ACTIVE, // by default wordpress is active
43 'install' => [
44 'label' => '',
45 'url' => '',
46 ],
47 'active' => [
48 'label' => '',
49 'url' => '',
50 ]
51 ],
52 'saved-templates' => [
53 'status' => self::ACTIVE, // save templates have dependency
54 'install' => [
55 'label' => '',
56 'url' => '',
57 ],
58 'active' => [
59 'label' => '',
60 'url' => '',
61 ]
62 ],
63 'woocommerce' => [
64 'status' => (file_exists(WP_PLUGIN_DIR.'/woocommerce/woocommerce.php') ? (is_plugin_active('woocommerce/woocommerce.php') == false ? self::INACTIVE : self::ACTIVE) : self::NEED_INSTALL),
65 'install' => [
66 'label' => esc_html__('Install WooCommerce', 'emailkit'),
67 // 'url' => wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce'),
68 'url' => self_admin_url('plugin-install.php?s=woocommerce&tab=search&type=term'),
69 ],
70 'active' => [
71 'label' => esc_html__('Activate WooCommerce', 'emailkit'),
72 'url' => ('plugins.php?plugin=woocommerce'),
73 ]
74 ],
75 'metform' => [
76 'status' => (file_exists(WP_PLUGIN_DIR.'/metform/metform.php') ? (is_plugin_active('metform/metform.php') == false ? self::INACTIVE : self::ACTIVE) : self::NEED_INSTALL),
77 'install' => [
78 'label' => esc_html__('Install Metform', 'emailkit'),
79 'url' => self_admin_url('plugin-install.php?s=metform&tab=search&type=term'),
80 ],
81 'active' => [
82 'label' => esc_html__('Activate Metform', 'emailkit'),
83 'url' => ('plugins.php?plugin=metform'),
84 ]
85 ],
86 'popupkit' => [
87 'status' => (file_exists(WP_PLUGIN_DIR.'/popup-builder-block/popup-builder-block.php') ? (is_plugin_active('popup-builder-block/popup-builder-block.php') == false ? self::INACTIVE : self::ACTIVE) : self::NEED_INSTALL),
88 'install' => [
89 'label' => esc_html__('Install PopupKit', 'emailkit'),
90 'url' => self_admin_url('plugin-install.php?s=popupkit&tab=search&type=term'),
91 ],
92 'active' => [
93 'label' => esc_html__('Activate PopupKit', 'emailkit'),
94 'url' => ('plugins.php?plugin=popup-builder-block'),
95 ]
96 ],
97 ];
98
99 return $dependency_list[$dependency] ?? [];
100 }
101 }