PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.4
ShopBuilder – WooCommerce Builder For Elementor v2.6.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 2.6.4, at app/Controllers/Dependencies.php

171 lines 5.7 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 private $missing = [];
23 /**
24 * @var bool
25 */
26 private $allOk = true;
27
28 /**
29 * @return bool
30 */
31 public function check() {
32
33 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
34 add_action( 'admin_notices', [ $this, 'minimum_php_version' ] );
35 $this->allOk = false;
36 }
37
38 if ( ! function_exists( 'is_plugin_active' ) ) {
39 include_once ABSPATH . 'wp-admin/includes/plugin.php';
40 }
41 if ( ! function_exists( 'wp_create_nonce' ) ) {
42 require_once ABSPATH . 'wp-includes/pluggable.php';
43 }
44
45 // Check WooCommerce.
46 $woocommerce = 'woocommerce/woocommerce.php';
47 if ( ! is_plugin_active( $woocommerce ) ) {
48 if ( $this->is_plugins_installed( $woocommerce ) ) {
49 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $woocommerce . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $woocommerce );
50 $message = sprintf(
51 '<strong>%s</strong> %s <strong>%s</strong> %s',
52 esc_html( self::PLUGIN_NAME ),
53 esc_html__( 'requires', 'shopbuilder' ),
54 esc_html__( 'WooCommerce', 'shopbuilder' ),
55 esc_html__( 'plugin to be active. Please activate WooCommerce to continue.', 'shopbuilder' )
56 );
57 $button_text = esc_html__( 'Activate WooCommerce', 'shopbuilder' );
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> %s <strong>%s</strong> %s',
62 esc_html( self::PLUGIN_NAME ),
63 esc_html__( 'requires', 'shopbuilder' ),
64 esc_html__( 'WooCommerce', 'shopbuilder' ),
65 esc_html__( 'plugin to be installed and activated. Please install WooCommerce to continue.', 'shopbuilder' )
66 );
67 $button_text = esc_html__( 'Install WooCommerce', 'shopbuilder' );
68 }
69 $this->missing['woocommerce'] = [
70 'name' => 'WooCommerce',
71 'slug' => 'woocommerce',
72 'file_name' => $woocommerce,
73 'url' => $activation_url,
74 'message' => $message,
75 'button_txt' => $button_text,
76 ];
77 $this->allOk = false;
78 }
79
80 $elementor = 'elementor/elementor.php';
81
82 /*
83 if ( ! is_plugin_active( $elementor ) ) {
84 $message = sprintf(
85 '<strong>%s</strong> %s',
86 esc_html__( 'ShopBuilder - WooCommerce Builder for Elementor:', 'shopbuilder' ),
87 esc_html__( 'Elementor plugin is optional. Please install Elementor if you want to build WooCommerce pages using Elementor.', 'shopbuilder' )
88 );
89 if ( $this->is_plugins_installed( $elementor ) ) {
90 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $elementor . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $elementor );
91 $button_text = esc_html__( 'Activate Elementor', 'shopbuilder' );
92 } else {
93 $activation_url = wp_nonce_url(
94 self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ),
95 'install-plugin_elementor'
96 );
97 $button_text = esc_html__( 'Install Elementor', 'shopbuilder' );
98 }
99 $this->missing['elementor'] = [
100 'name' => 'Elementor',
101 'slug' => 'elementor',
102 'file_name' => $elementor,
103 'url' => '',
104 'message' => $message . ' <a href="' . esc_url( $activation_url ) . '" > ' . esc_html( $button_text ) . '</a>',
105 'button_txt' => '',
106 ];
107 }
108 */
109
110 if ( ! empty( $this->missing ) ) {
111 add_action( 'admin_notices', [ $this, '_missing_plugins_warning' ] );
112 }
113
114 return $this->allOk;
115 }
116
117 /**
118 * Admin Notice For Required PHP Version
119 */
120 public function minimum_php_version() {
121 // Protect plugin Activation with error.
122 if ( isset( $_GET['activate'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
123 unset( $_GET['activate'] );
124 }
125 $message = sprintf(
126 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
127 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'shopbuilder' ),
128 '<strong>' . esc_html__( 'ShopBuilder', 'shopbuilder' ) . '</strong>',
129 '<strong>' . esc_html__( 'PHP', 'shopbuilder' ) . '</strong>',
130 self::MINIMUM_PHP_VERSION
131 );
132 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', wp_kses_post( $message ) );
133 }
134
135 /**
136 * Adds admin notice.
137 */
138 public function _missing_plugins_warning() {
139 $missingPlugins = '';
140 $counter = 0;
141 foreach ( $this->missing as $plugin ) {
142 $counter++;
143 if ( $counter == count( $this->missing ) ) {
144 $sep = '';
145 } elseif ( $counter == count( $this->missing ) - 1 ) {
146 $sep = ' ' . esc_html__( 'and', 'shopbuilder' ) . ' ';
147 } else {
148 $sep = ', ';
149 }
150 if ( current_user_can( 'activate_plugins' ) ) {
151 $button = ! empty($plugin['url'] ) ? '<p><a href="' . esc_url( $plugin['url'] ) . '" class="button-primary">'. esc_html( $plugin['button_txt'] ) . '</a></p>' : '';
152 // $plugin['message'] Already used escaping function
153 printf( '<div class="error"><p>%1$s</p>%2$s</div>', $plugin['message'], $button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
154 } else {
155 $missingPlugins .= '<strong>' . esc_html( $plugin['name'] ) . '</strong>' . $sep;
156 }
157 }
158 }
159
160 /**
161 * @param $plugin_file_path
162 *
163 * @return bool
164 */
165 public function is_plugins_installed( $plugin_file_path = null ) {
166 $installed_plugins_list = get_plugins();
167
168 return isset( $installed_plugins_list[ $plugin_file_path ] );
169 }
170 }
171