woocommerce/woocommerce.php

62 lines
1.6 KiB
PHP
Raw Normal View History

2011-08-10 17:11:11 +00:00
<?php
2012-03-20 13:22:35 +00:00
/**
* Plugin Name: WooCommerce
2016-07-05 22:52:16 +00:00
* Plugin URI: https://woocommerce.com/
* Description: An eCommerce toolkit that helps you sell anything. Beautifully.
* Version: 4.5.0-rc.1
2017-02-09 17:08:39 +00:00
* Author: Automattic
* Author URI: https://woocommerce.com
2012-03-20 13:22:35 +00:00
* Text Domain: woocommerce
* Domain Path: /i18n/languages/
2020-05-27 22:44:30 +00:00
* Requires at least: 5.2
2020-05-27 12:58:41 +00:00
* Requires PHP: 7.0
2012-08-07 08:38:08 +00:00
*
2012-03-20 13:22:35 +00:00
* @package WooCommerce
*/
2019-01-23 16:19:40 +00:00
defined( 'ABSPATH' ) || exit;
2011-08-10 17:11:11 +00:00
if ( ! defined( 'WC_PLUGIN_FILE' ) ) {
define( 'WC_PLUGIN_FILE', __FILE__ );
}
2020-04-07 00:07:33 +00:00
// Load core packages and the autoloader.
require __DIR__ . '/src/Autoloader.php';
require __DIR__ . '/src/Packages.php';
2020-04-07 00:07:33 +00:00
if ( ! \Automattic\WooCommerce\Autoloader::init() ) {
return;
}
2020-04-07 00:07:33 +00:00
\Automattic\WooCommerce\Packages::init();
// Include the main WooCommerce class.
if ( ! class_exists( 'WooCommerce', false ) ) {
include_once dirname( WC_PLUGIN_FILE ) . '/includes/class-woocommerce.php';
}
// Initialize dependency injection.
Changes in the overall organization of the dependency injection: - The `Container` class now implements `Psr\Container\ContainerInterface` (and registers itself as such), holding a private instance of the real container. This way it's a read-only container from the point of view of plugins (which should use their own containers, but can still use this to get WooCommerce classes). - All registrations are now done in the `Container` constructor via service providers. - The container instance is now held in a global variable, set in `woocommerce.php` - Added the `wc_get_container` function for old code. - Added the `AbstractServiceProvider` class, which inherits with the corresponding League's class and adds some utility methods, most notably `add/shareWithAutoArguments`. - Added the `ActionsProxy` and `LegacyProxy` classes, they are registered via a dedicated service provider. - `WC_Queue_Interface` is no longer resolvable via the container (which is for classes inside `src` only). - All the method names in the new classes have the format `fooBarFizz` to be PSR4 compliant, so the MethodNameInvalid error has been disabled in phpcs.xml for the `src` directory. - Introduced the `@public` annotation for public API classes (classes that plugins can use and whose backwards compatibility we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now. - Removed the hack for the autoloader as now it doesn't work anyway. For the changes in this branch to work, now WP_DEBUG must be false.
2020-06-18 12:15:08 +00:00
$GLOBALS['wc_container'] = new Automattic\WooCommerce\Container();
/**
2019-01-23 16:19:40 +00:00
* Returns the main instance of WC.
*
* @since 2.1
2013-09-25 13:10:40 +00:00
* @return WooCommerce
*/
2019-02-18 11:55:36 +00:00
function WC() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
return WooCommerce::instance();
}
2011-12-08 12:50:50 +00:00
Changes in the overall organization of the dependency injection: - The `Container` class now implements `Psr\Container\ContainerInterface` (and registers itself as such), holding a private instance of the real container. This way it's a read-only container from the point of view of plugins (which should use their own containers, but can still use this to get WooCommerce classes). - All registrations are now done in the `Container` constructor via service providers. - The container instance is now held in a global variable, set in `woocommerce.php` - Added the `wc_get_container` function for old code. - Added the `AbstractServiceProvider` class, which inherits with the corresponding League's class and adds some utility methods, most notably `add/shareWithAutoArguments`. - Added the `ActionsProxy` and `LegacyProxy` classes, they are registered via a dedicated service provider. - `WC_Queue_Interface` is no longer resolvable via the container (which is for classes inside `src` only). - All the method names in the new classes have the format `fooBarFizz` to be PSR4 compliant, so the MethodNameInvalid error has been disabled in phpcs.xml for the `src` directory. - Introduced the `@public` annotation for public API classes (classes that plugins can use and whose backwards compatibility we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now. - Removed the hack for the autoloader as now it doesn't work anyway. For the changes in this branch to work, now WP_DEBUG must be false.
2020-06-18 12:15:08 +00:00
/**
* Returns the WooCommerce PSR11-compatible object container.
* Code in the `includes` directory should use the container to get instances of classes in the `src` directory.
*
* @return \Psr\Container\ContainerInterface The WooCommerce PSR11 container.
*/
function wc_get_container() : \Psr\Container\ContainerInterface {
Changes in the overall organization of the dependency injection: - The `Container` class now implements `Psr\Container\ContainerInterface` (and registers itself as such), holding a private instance of the real container. This way it's a read-only container from the point of view of plugins (which should use their own containers, but can still use this to get WooCommerce classes). - All registrations are now done in the `Container` constructor via service providers. - The container instance is now held in a global variable, set in `woocommerce.php` - Added the `wc_get_container` function for old code. - Added the `AbstractServiceProvider` class, which inherits with the corresponding League's class and adds some utility methods, most notably `add/shareWithAutoArguments`. - Added the `ActionsProxy` and `LegacyProxy` classes, they are registered via a dedicated service provider. - `WC_Queue_Interface` is no longer resolvable via the container (which is for classes inside `src` only). - All the method names in the new classes have the format `fooBarFizz` to be PSR4 compliant, so the MethodNameInvalid error has been disabled in phpcs.xml for the `src` directory. - Introduced the `@public` annotation for public API classes (classes that plugins can use and whose backwards compatibility we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now. - Removed the hack for the autoloader as now it doesn't work anyway. For the changes in this branch to work, now WP_DEBUG must be false.
2020-06-18 12:15:08 +00:00
return $GLOBALS['wc_container'];
}
// Global for backwards compatibility.
2018-11-08 10:59:07 +00:00
$GLOBALS['woocommerce'] = WC();