Checkout
5 years ago
Internal
4 years ago
Proxies
5 years ago
Utilities
5 years ago
Autoloader.php
5 years ago
Container.php
4 years ago
Packages.php
5 years ago
Autoloader.php
75 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 | error_log( // phpcs:ignore |
| 51 | 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' ) |
| 52 | ); |
| 53 | } |
| 54 | add_action( |
| 55 | 'admin_notices', |
| 56 | function() { |
| 57 | ?> |
| 58 | <div class="notice notice-error"> |
| 59 | <p> |
| 60 | <?php |
| 61 | printf( |
| 62 | /* translators: 1: is a link to a support document. 2: closing link */ |
| 63 | 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' ), |
| 64 | '<a href="' . esc_url( 'https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment' ) . '" target="_blank" rel="noopener noreferrer">', |
| 65 | '</a>' |
| 66 | ); |
| 67 | ?> |
| 68 | </p> |
| 69 | </div> |
| 70 | <?php |
| 71 | } |
| 72 | ); |
| 73 | } |
| 74 | } |
| 75 |