PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.4
ShopBuilder – WooCommerce Builder For Elementor v3.2.4
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Controllers / Dependencies.php

Dependencies.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.4, at app/Controllers/Dependencies.php

137 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RadiusTheme\SB\Controllers;
4
5 use RadiusTheme\SB\Helpers\Fns;
6 use RadiusTheme\SB\Traits\SingletonTrait;
7
8 // Do not allow directly accessing this file.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit( 'This script cannot be accessed directly.' );
11 }
12
13
14 class Dependencies {
15
16 const MINIMUM_PHP_VERSION = '7.4';
17
18 const PLUGIN_NAME = 'ShopBuilder - Woocommerce Builder for Elementor';
19
20 use SingletonTrait;
21
22 /**
23 * @var array
24 */
25 private $missing = [];
26 /**
27 * @var bool
28 */
29 private $allOk = true;
30
31 /**
32 * @return bool
33 */
34 public function check() {
35
36 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
37 add_action( 'admin_notices', [ $this, 'minimum_php_version' ] );
38 $this->allOk = false;
39 }
40
41 if ( ! function_exists( 'is_plugin_active' ) ) {
42 include_once ABSPATH . 'wp-admin/includes/plugin.php';
43 }
44 if ( ! function_exists( 'wp_create_nonce' ) ) {
45 require_once ABSPATH . 'wp-includes/pluggable.php';
46 }
47
48 // Check WooCommerce.
49 $woocommerce = 'woocommerce/woocommerce.php';
50 if ( ! is_plugin_active( $woocommerce ) ) {
51 if ( $this->is_plugins_installed( $woocommerce ) ) {
52 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $woocommerce . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $woocommerce );
53 $message = sprintf(
54 '<strong>%s</strong> requires <strong>WooCommerce</strong> plugin to be active. Please activate WooCommerce to continue.',
55 esc_html( self::PLUGIN_NAME ),
56 );
57 $button_text = 'Activate WooCommerce';
58 } else {
59 $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
60 $message = sprintf(
61 '<strong>%s</strong> requires <strong>WooCommerce</strong> plugin to be active. Please activate WooCommerce to continue.',
62 esc_html( self::PLUGIN_NAME ),
63 );
64 $button_text = 'Install WooCommerce';
65 }
66 $this->missing['woocommerce'] = [
67 'name' => 'WooCommerce',
68 'slug' => 'woocommerce',
69 'file_name' => $woocommerce,
70 'url' => $activation_url,
71 'message' => $message,
72 'button_txt' => $button_text,
73 ];
74 $this->allOk = false;
75 }
76
77 if ( ! empty( $this->missing ) ) {
78 add_action( 'admin_notices', [ $this, '_missing_plugins_warning' ] );
79 }
80
81 return $this->allOk;
82 }
83
84 /**
85 * Admin Notice For Required PHP Version
86 */
87 public function minimum_php_version() {
88 // Protect plugin Activation with error.
89 if ( isset( $_GET['activate'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
90 unset( $_GET['activate'] );
91 }
92 $message = sprintf(
93 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
94 esc_html( '"%1$s" requires "%2$s" version %3$s or greater.' ),
95 '<strong>ShopBuilder</strong>',
96 '<strong>PHP</strong>',
97 self::MINIMUM_PHP_VERSION
98 );
99 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', wp_kses_post( $message ) );
100 }
101
102 /**
103 * Adds admin notice.
104 */
105 public function _missing_plugins_warning() {
106 $missingPlugins = '';
107 $counter = 0;
108 foreach ( $this->missing as $plugin ) {
109 $counter++;
110 if ( $counter == count( $this->missing ) ) {
111 $sep = '';
112 } elseif ( $counter == count( $this->missing ) - 1 ) {
113 $sep = ' and ';
114 } else {
115 $sep = ', ';
116 }
117 if ( current_user_can( 'activate_plugins' ) ) {
118 $button = ! empty( $plugin['url'] ) ? '<p><a href="' . esc_url( $plugin['url'] ) . '" class="button-primary">' . esc_html( $plugin['button_txt'] ) . '</a></p>' : '';
119 printf( '<div class="error"><p>%1$s</p>%2$s</div>', $plugin['message'], $button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
120 } else {
121 $missingPlugins .= '<strong>' . esc_html( $plugin['name'] ) . '</strong>' . $sep;
122 }
123 }
124 }
125
126 /**
127 * @param $plugin_file_path
128 *
129 * @return bool
130 */
131 public function is_plugins_installed( $plugin_file_path = null ) {
132 $installed_plugins_list = get_plugins();
133
134 return isset( $installed_plugins_list[ $plugin_file_path ] );
135 }
136 }
137