AI
1 year ago
AIContent
1 year ago
Assets
1 year ago
BlockTypes
8 months ago
Domain
10 months ago
Images
1 year ago
Integrations
2 years ago
Patterns
11 months ago
Payments
1 year ago
Registry
2 years ago
Shipping
11 months ago
Templates
9 months ago
Utils
9 months ago
Assets.php
2 years ago
AssetsController.php
10 months ago
BlockPatterns.php
11 months ago
BlockTemplatesController.php
8 months ago
BlockTemplatesRegistry.php
9 months ago
BlockTypesController.php
9 months ago
InboxNotifications.php
2 years ago
Installer.php
1 year ago
Library.php
2 years ago
Options.php
2 years ago
Package.php
1 year ago
QueryFilters.php
9 months ago
TemplateOptions.php
1 year ago
Assets.php
96 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\Blocks; |
| 3 | |
| 4 | use Automattic\WooCommerce\Blocks\Package; |
| 5 | use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi; |
| 6 | |
| 7 | /** |
| 8 | * Assets class. |
| 9 | * |
| 10 | * @deprecated 5.0.0 This class will be removed in a future release. This has been replaced by AssetsController. |
| 11 | * @internal |
| 12 | */ |
| 13 | class Assets { |
| 14 | |
| 15 | /** |
| 16 | * Initialize class features on init. |
| 17 | * |
| 18 | * @since 2.5.0 |
| 19 | * @deprecated 5.0.0 |
| 20 | */ |
| 21 | public static function init() { |
| 22 | _deprecated_function( 'Assets::init', '5.0.0' ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Register block scripts & styles. |
| 27 | * |
| 28 | * @since 2.5.0 |
| 29 | * @deprecated 5.0.0 |
| 30 | */ |
| 31 | public static function register_assets() { |
| 32 | _deprecated_function( 'Assets::register_assets', '5.0.0' ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Register the vendors style file. We need to do it after the other files |
| 37 | * because we need to check if `wp-edit-post` has been enqueued. |
| 38 | * |
| 39 | * @deprecated 5.0.0 |
| 40 | */ |
| 41 | public static function enqueue_scripts() { |
| 42 | _deprecated_function( 'Assets::enqueue_scripts', '5.0.0' ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Add body classes. |
| 47 | * |
| 48 | * @deprecated 5.0.0 |
| 49 | * @param array $classes Array of CSS classnames. |
| 50 | * @return array Modified array of CSS classnames. |
| 51 | */ |
| 52 | public static function add_theme_body_class( $classes = [] ) { |
| 53 | _deprecated_function( 'Assets::add_theme_body_class', '5.0.0' ); |
| 54 | return $classes; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Add theme class to admin body. |
| 59 | * |
| 60 | * @deprecated 5.0.0 |
| 61 | * @param array $classes String with the CSS classnames. |
| 62 | * @return array Modified string of CSS classnames. |
| 63 | */ |
| 64 | public static function add_theme_admin_body_class( $classes = '' ) { |
| 65 | _deprecated_function( 'Assets::add_theme_admin_body_class', '5.0.0' ); |
| 66 | return $classes; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Adds a redirect field to the login form so blocks can redirect users after login. |
| 71 | * |
| 72 | * @deprecated 5.0.0 |
| 73 | */ |
| 74 | public static function redirect_to_field() { |
| 75 | _deprecated_function( 'Assets::redirect_to_field', '5.0.0' ); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Queues a block script in the frontend. |
| 80 | * |
| 81 | * @since 2.3.0 |
| 82 | * @since 2.6.0 Changed $name to $script_name and added $handle argument. |
| 83 | * @since 2.9.0 Made it so scripts are not loaded in admin pages. |
| 84 | * @deprecated 4.5.0 Block types register the scripts themselves. |
| 85 | * |
| 86 | * @param string $script_name Name of the script used to identify the file inside build folder. |
| 87 | * @param string $handle Optional. Provided if the handle should be different than the script name. `wc-` prefix automatically added. |
| 88 | * @param array $dependencies Optional. An array of registered script handles this script depends on. Default empty array. |
| 89 | */ |
| 90 | public static function register_block_script( $script_name, $handle = '', $dependencies = [] ) { |
| 91 | _deprecated_function( 'register_block_script', '4.5.0' ); |
| 92 | $asset_api = Package::container()->get( AssetApi::class ); |
| 93 | $asset_api->register_block_script( $script_name, $handle, $dependencies ); |
| 94 | } |
| 95 | } |
| 96 |