Abilities
4 weeks ago
AbilitiesApi
7 months ago
AddressProvider
7 months ago
Admin
2 weeks ago
Agentic
7 months ago
Api
4 weeks ago
BatchProcessing
4 weeks ago
CLI
5 months ago
Caches
4 months ago
ComingSoon
9 months ago
CostOfGoodsSold
9 months ago
Customers
9 months ago
DataStores
4 weeks ago
DependencyManagement
5 months ago
Email
4 weeks ago
EmailEditor
4 weeks ago
Features
4 weeks ago
Integrations
7 months ago
Jetpack
5 months ago
Logging
2 months ago
MCP
4 weeks ago
OrderReviews
4 weeks ago
Orders
4 weeks ago
ProductAttributes
4 weeks ago
ProductAttributesLookup
4 weeks ago
ProductDownloads
5 months ago
ProductFeed
1 week ago
ProductFilters
4 weeks ago
ProductImage
1 year ago
PushNotifications
4 weeks ago
ReceiptRendering
2 months ago
RestApi
4 weeks ago
Settings
1 year ago
ShopperLists
2 weeks ago
StockNotifications
4 weeks ago
Traits
4 months ago
TransientFiles
4 weeks ago
Utilities
4 weeks ago
VariationGallery
4 weeks ago
WCCom
2 years ago
AssignDefaultCategory.php
1 year ago
Brands.php
11 months ago
DownloadPermissionsAdjuster.php
2 months ago
McStats.php
1 year ago
OrderCouponDataMigrator.php
1 year ago
RegisterHooksInterface.php
1 year ago
RestApiControllerBase.php
1 year ago
RestApiParameterUtil.php
2 years ago
RestockRefundedItemsAdjuster.php
2 months ago
Brands.php
62 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Brands class file. |
| 4 | */ |
| 5 | |
| 6 | declare( strict_types = 1); |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Internal; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * Class to initiate Brands functionality in core. |
| 14 | */ |
| 15 | class Brands { |
| 16 | |
| 17 | /** |
| 18 | * Class initialization |
| 19 | * |
| 20 | * @internal |
| 21 | */ |
| 22 | final public static function init() { |
| 23 | |
| 24 | if ( ! self::is_enabled() ) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | include_once WC_ABSPATH . 'includes/class-wc-brands.php'; |
| 29 | include_once WC_ABSPATH . 'includes/class-wc-brands-coupons.php'; |
| 30 | include_once WC_ABSPATH . 'includes/class-wc-brands-brand-settings-manager.php'; |
| 31 | include_once WC_ABSPATH . 'includes/wc-brands-functions.php'; |
| 32 | |
| 33 | if ( is_admin() ) { |
| 34 | include_once WC_ABSPATH . 'includes/admin/class-wc-admin-brands.php'; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * As of WooCommerce 9.6, Brands is enabled for all users. |
| 40 | * |
| 41 | * @return bool |
| 42 | */ |
| 43 | public static function is_enabled() { |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * If WooCommerce Brands gets activated forcibly, without WooCommerce active (e.g. via '--skip-plugins'), |
| 49 | * remove WooCommerce Brands initialization functions early on in the 'plugins_loaded' timeline. |
| 50 | */ |
| 51 | public static function prepare() { |
| 52 | |
| 53 | if ( ! self::is_enabled() ) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | if ( function_exists( 'wc_brands_init' ) ) { |
| 58 | remove_action( 'plugins_loaded', 'wc_brands_init', 1 ); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 |