Admin
1 year ago
Blocks
11 months ago
Caches
11 months ago
Caching
1 year ago
Checkout
1 year ago
Database
1 year ago
Enums
1 year ago
Internal
11 months ago
LayoutTemplates
2 years ago
Proxies
2 years ago
StoreApi
3 months ago
Utilities
1 year ago
Autoloader.php
1 year ago
Container.php
1 year ago
Deprecated.php
1 year ago
Packages.php
1 year ago
Autoloader.php
76 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Includes the composer Autoloader used for packages and classes in the src/ directory. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce; |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * Autoloader class. |
| 12 | * |
| 13 | * @since 3.7.0 |
| 14 | */ |
| 15 | class Autoloader { |
| 16 | |
| 17 | /** |
| 18 | * Static-only class. |
| 19 | */ |
| 20 | private function __construct() {} |
| 21 | |
| 22 | /** |
| 23 | * Require the autoloader and return the result. |
| 24 | * |
| 25 | * If the autoloader is not present, let's log the failure and display a nice admin notice. |
| 26 | * |
| 27 | * @return boolean |
| 28 | */ |
| 29 | public static function init() { |
| 30 | $autoloader = dirname( __DIR__ ) . '/vendor/autoload_packages.php'; |
| 31 | |
| 32 | if ( ! is_readable( $autoloader ) ) { |
| 33 | self::missing_autoloader(); |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | $autoloader_result = require $autoloader; |
| 38 | if ( ! $autoloader_result ) { |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | return $autoloader_result; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * If the autoloader is missing, add an admin notice. |
| 47 | */ |
| 48 | protected static function missing_autoloader() { |
| 49 | if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
| 50 | // This message is not translated as at this point it's too early to load translations. |
| 51 | error_log( // phpcs:ignore |
| 52 | 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' ) |
| 53 | ); |
| 54 | } |
| 55 | add_action( |
| 56 | 'admin_notices', |
| 57 | function() { |
| 58 | ?> |
| 59 | <div class="notice notice-error"> |
| 60 | <p> |
| 61 | <?php |
| 62 | printf( |
| 63 | /* translators: 1: is a link to a support document. 2: closing link */ |
| 64 | 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' ), |
| 65 | '<a href="' . esc_url( 'https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment' ) . '" target="_blank" rel="noopener noreferrer">', |
| 66 | '</a>' |
| 67 | ); |
| 68 | ?> |
| 69 | </p> |
| 70 | </div> |
| 71 | <?php |
| 72 | } |
| 73 | ); |
| 74 | } |
| 75 | } |
| 76 |