Admin
1 year ago
BatchProcessing
1 year ago
ComingSoon
1 year ago
CostOfGoodsSold
1 year ago
DataStores
1 year ago
DependencyManagement
1 year ago
Features
1 year ago
Font
2 years ago
Integrations
1 year ago
Logging
1 year ago
Orders
1 year ago
ProductAttributesLookup
1 year ago
ProductDownloads
1 year ago
ProductImage
1 year ago
ReceiptRendering
1 year ago
Settings
1 year ago
Traits
1 year ago
TransientFiles
1 year ago
Utilities
1 year ago
WCCom
2 years ago
AssignDefaultCategory.php
1 year ago
BrandingController.php
1 year ago
Brands.php
1 year ago
DownloadPermissionsAdjuster.php
3 years 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
4 years ago
Brands.php
67 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 ( wc_current_theme_is_fse_theme() ) { |
| 34 | include_once WC_ABSPATH . 'includes/blocks/class-wc-brands-block-templates.php'; |
| 35 | include_once WC_ABSPATH . 'includes/blocks/class-wc-brands-block-template-utils-duplicated.php'; |
| 36 | } |
| 37 | |
| 38 | if ( is_admin() ) { |
| 39 | include_once WC_ABSPATH . 'includes/admin/class-wc-admin-brands.php'; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * As of WooCommerce 9.6, Brands is enabled for all users. |
| 45 | * |
| 46 | * @return bool |
| 47 | */ |
| 48 | public static function is_enabled() { |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * If WooCommerce Brands gets activated forcibly, without WooCommerce active (e.g. via '--skip-plugins'), |
| 54 | * remove WooCommerce Brands initialization functions early on in the 'plugins_loaded' timeline. |
| 55 | */ |
| 56 | public static function prepare() { |
| 57 | |
| 58 | if ( ! self::is_enabled() ) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | if ( function_exists( 'wc_brands_init' ) ) { |
| 63 | remove_action( 'plugins_loaded', 'wc_brands_init', 1 ); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 |