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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Packages.php
woocommerce / src Last commit date
Admin 1 year ago Blocks 2 years ago Caches 3 years ago Caching 2 years ago Checkout 3 years ago Database 2 years ago Internal 1 year ago LayoutTemplates 2 years ago Proxies 2 years ago StoreApi 5 months ago Utilities 2 years ago Autoloader.php 5 years ago Container.php 2 years ago Packages.php 2 years ago
Packages.php
204 lines
1 <?php
2 /**
3 * Loads WooCommerce packages from the /packages directory. These are packages developed outside of core.
4 */
5
6 namespace Automattic\WooCommerce;
7
8 use Automattic\Jetpack\Constants;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Packages class.
14 *
15 * @since 3.7.0
16 */
17 class Packages {
18
19 /**
20 * Static-only class.
21 */
22 private function __construct() {}
23
24 /**
25 * Array of package names and their main package classes. Once a package has been merged into WooCommerce
26 * directly it should be removed from here and added to the merged packages array.
27 *
28 * @var array Key is the package name/directory, value is the main package class which handles init.
29 */
30 protected static $packages = array();
31
32 /**
33 * Array of package names and their main package classes.
34 *
35 * One a package has been merged into WooCommerce Core it should be moved fron the package list and placed in
36 * this list. This will ensure that the feature plugin is disabled as well as provide the class to handle
37 * initialization for the now-merged feature plugin.
38 *
39 * Once a package has been merged into WooCommerce Core it should have its slug added here. This will ensure
40 * that we deactivate the feature plugin automaticatlly to prevent any problems caused by conflicts between
41 * the two versions caused by them both being active.
42 *
43 * @var array Key is the package name/directory, value is the main package class which handles init.
44 */
45 protected static $merged_packages = array(
46 'woocommerce-admin' => '\\Automattic\\WooCommerce\\Admin\\Composer\\Package',
47 'woocommerce-gutenberg-products-block' => '\\Automattic\\WooCommerce\\Blocks\\Package',
48 );
49
50 /**
51 * Init the package loader.
52 *
53 * @since 3.7.0
54 */
55 public static function init() {
56 add_action( 'plugins_loaded', array( __CLASS__, 'on_init' ) );
57 }
58
59 /**
60 * Callback for WordPress init hook.
61 */
62 public static function on_init() {
63 self::deactivate_merged_packages();
64 self::initialize_packages();
65 }
66
67 /**
68 * Checks a package exists by looking for it's directory.
69 *
70 * @param string $package Package name.
71 * @return boolean
72 */
73 public static function package_exists( $package ) {
74 return file_exists( dirname( __DIR__ ) . '/packages/' . $package );
75 }
76
77 /**
78 * Deactivates merged feature plugins.
79 *
80 * Once a feature plugin is merged into WooCommerce Core it should be deactivated. This method will
81 * ensure that a plugin gets deactivated. Note that for the first request it will still be active,
82 * and as such, there may be some odd behavior. This is unlikely to cause any issues though
83 * because it will be deactivated on the request that updates or activates WooCommerce.
84 */
85 protected static function deactivate_merged_packages() {
86 // Developers may need to be able to run merged feature plugins alongside merged packages for testing purposes.
87 if ( Constants::is_true( 'WC_ALLOW_MERGED_FEATURE_PLUGINS' ) ) {
88 return;
89 }
90
91 // Scroll through all of the active plugins and disable them if they're merged packages.
92 $active_plugins = get_option( 'active_plugins', array() );
93 // Deactivate the plugin if possible so that there are no conflicts.
94 foreach ( $active_plugins as $active_plugin_path ) {
95 $plugin_file = basename( plugin_basename( $active_plugin_path ), '.php' );
96 if ( ! isset( self::$merged_packages[ $plugin_file ] ) ) {
97 continue;
98 }
99
100 require_once ABSPATH . 'wp-admin/includes/plugin.php';
101
102 // Make sure to display a message informing the user that the plugin has been deactivated.
103 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $active_plugin_path );
104 deactivate_plugins( $active_plugin_path );
105 add_action(
106 'admin_notices',
107 function() use ( $plugin_data ) {
108 echo '<div class="error"><p>';
109 printf(
110 /* translators: %s: is referring to the plugin's name. */
111 esc_html__( 'The %1$s plugin has been deactivated as the latest improvements are now included with the %2$s plugin.', 'woocommerce' ),
112 '<code>' . esc_html( $plugin_data['Name'] ) . '</code>',
113 '<code>WooCommerce</code>'
114 );
115 echo '</p></div>';
116 }
117 );
118 }
119 }
120
121 /**
122 * Loads packages after plugins_loaded hook.
123 *
124 * Each package should include an init file which loads the package so it can be used by core.
125 */
126 protected static function initialize_packages() {
127 foreach ( self::$merged_packages as $package_name => $package_class ) {
128 call_user_func( array( $package_class, 'init' ) );
129 }
130
131 foreach ( self::$packages as $package_name => $package_class ) {
132 if ( ! self::package_exists( $package_name ) ) {
133 self::missing_package( $package_name );
134 continue;
135 }
136 call_user_func( array( $package_class, 'init' ) );
137 }
138
139 // Proxies "activated_plugin" hook for embedded packages listen on WC plugin activation
140 // https://github.com/woocommerce/woocommerce/issues/28697.
141 if ( is_admin() ) {
142 $activated_plugin = get_transient( 'woocommerce_activated_plugin' );
143 if ( $activated_plugin ) {
144 delete_transient( 'woocommerce_activated_plugin' );
145
146 /**
147 * WooCommerce is activated hook.
148 *
149 * @since 5.0.0
150 * @param bool $activated_plugin Activated plugin path,
151 * generally woocommerce/woocommerce.php.
152 */
153 do_action( 'woocommerce_activated_plugin', $activated_plugin );
154 }
155 }
156 }
157
158 /**
159 * If a package is missing, add an admin notice.
160 *
161 * @param string $package Package name.
162 */
163 protected static function missing_package( $package ) {
164 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
165 error_log( // phpcs:ignore
166 sprintf(
167 /* Translators: %s package name. */
168 esc_html__( 'Missing the WooCommerce %s package', 'woocommerce' ),
169 '<code>' . esc_html( $package ) . '</code>'
170 ) . ' - ' . esc_html__( 'Your installation of WooCommerce is incomplete. If you installed WooCommerce from GitHub, please refer to this document to set up your development environment: https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment', 'woocommerce' )
171 );
172 }
173 add_action(
174 'admin_notices',
175 function() use ( $package ) {
176 ?>
177 <div class="notice notice-error">
178 <p>
179 <strong>
180 <?php
181 printf(
182 /* Translators: %s package name. */
183 esc_html__( 'Missing the WooCommerce %s package', 'woocommerce' ),
184 '<code>' . esc_html( $package ) . '</code>'
185 );
186 ?>
187 </strong>
188 <br>
189 <?php
190 printf(
191 /* translators: 1: is a link to a support document. 2: closing link */
192 esc_html__( 'Your installation of WooCommerce is incomplete. If you installed WooCommerce from GitHub, %1$splease refer to this document%2$s to set up your development environment.', 'woocommerce' ),
193 '<a href="' . esc_url( 'https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment' ) . '" target="_blank" rel="noopener noreferrer">',
194 '</a>'
195 );
196 ?>
197 </p>
198 </div>
199 <?php
200 }
201 );
202 }
203 }
204