PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.4.0
EmailKit – Email Customizer for WooCommerce & WP v1.4.0
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.4.0, at includes/Admin/Dependency.php

77 lines 2.5 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 $dependency = self::dependency_list($plugin);
18
19 if($dependency['status'] == self::INACTIVE) {
20 return $dependency['active'];
21 } else if($dependency['status'] == self::NEED_INSTALL) {
22 return $dependency['install'];
23 }
24 return true;
25 }
26
27
28 public static function dependency_list(string $dependency = ''): array {
29
30
31 if(!function_exists('is_plugin_active')){
32 // Include necessary WordPress files
33 require_once ABSPATH . 'wp-admin/includes/plugin.php';
34 require_once ABSPATH . 'wp-includes/class-wp.php'; // Adjust the path if necessary
35
36 }
37
38 $dependency_list = [
39 'wordpress' => [
40 'status' => self::ACTIVE, // by default wordpress is active
41 'install' => [
42 'label' => '',
43 'url' => '',
44 ],
45 'active' => [
46 'label' => '',
47 'url' => '',
48 ]
49 ],
50 'saved-templates' => [
51 'status' => self::ACTIVE, // save templates have dependency
52 'install' => [
53 'label' => '',
54 'url' => '',
55 ],
56 'active' => [
57 'label' => '',
58 'url' => '',
59 ]
60 ],
61 'woocommerce' => [
62 'status' => (file_exists(WP_PLUGIN_DIR.'/woocommerce/woocommerce.php') ? (is_plugin_active('woocommerce/woocommerce.php') == false ? self::INACTIVE : self::ACTIVE) : self::NEED_INSTALL),
63 'install' => [
64 'label' => esc_html__('Install WooCommerce', 'emailkit'),
65 // 'url' => wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce'),
66 'url' => self_admin_url('plugin-install.php?s=woocommerce&tab=search&type=term'),
67 ],
68 'active' => [
69 'label' => esc_html__('Activate WooCommerce', 'emailkit'),
70 'url' => ('plugins.php?plugin=woocommerce'),
71 ]
72 ],
73 ];
74
75 return $dependency_list[$dependency] ?? [];
76 }
77 }