2019-07-01 12:52:44 +00:00
|
|
|
<?php
|
|
|
|
namespace Automattic\WooCommerce\Blocks;
|
|
|
|
|
2020-04-27 15:51:50 +00:00
|
|
|
use Automattic\WooCommerce\Blocks\Package;
|
2020-07-07 08:15:46 +00:00
|
|
|
use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi;
|
2020-04-27 15:51:50 +00:00
|
|
|
|
2019-07-01 12:52:44 +00:00
|
|
|
/**
|
|
|
|
* Assets class.
|
2020-09-07 18:01:07 +00:00
|
|
|
*
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0 This class will be removed in a future release. This has been replaced by AssetsController.
|
2020-09-07 18:01:07 +00:00
|
|
|
* @internal
|
2019-07-01 12:52:44 +00:00
|
|
|
*/
|
|
|
|
class Assets {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize class features on init.
|
2019-09-23 18:07:13 +00:00
|
|
|
*
|
2019-11-19 17:20:22 +00:00
|
|
|
* @since 2.5.0
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0
|
2019-07-01 12:52:44 +00:00
|
|
|
*/
|
|
|
|
public static function init() {
|
2021-04-28 16:15:39 +00:00
|
|
|
_deprecated_function( 'Assets::init', '5.0.0' );
|
2019-07-01 12:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register block scripts & styles.
|
2019-09-23 18:07:13 +00:00
|
|
|
*
|
2019-11-19 17:20:22 +00:00
|
|
|
* @since 2.5.0
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0
|
2019-07-01 12:52:44 +00:00
|
|
|
*/
|
|
|
|
public static function register_assets() {
|
2021-04-28 16:15:39 +00:00
|
|
|
_deprecated_function( 'Assets::register_assets', '5.0.0' );
|
2019-08-27 15:25:32 +00:00
|
|
|
}
|
2019-08-22 20:56:47 +00:00
|
|
|
|
2021-03-02 14:53:23 +00:00
|
|
|
/**
|
|
|
|
* Register the vendors style file. We need to do it after the other files
|
|
|
|
* because we need to check if `wp-edit-post` has been enqueued.
|
2021-04-26 09:37:10 +00:00
|
|
|
*
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0
|
2021-03-02 14:53:23 +00:00
|
|
|
*/
|
|
|
|
public static function enqueue_scripts() {
|
2021-04-28 16:15:39 +00:00
|
|
|
_deprecated_function( 'Assets::enqueue_scripts', '5.0.0' );
|
2021-03-02 14:53:23 +00:00
|
|
|
}
|
|
|
|
|
2019-07-01 12:52:44 +00:00
|
|
|
/**
|
|
|
|
* Add body classes.
|
|
|
|
*
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0
|
2019-07-01 12:52:44 +00:00
|
|
|
* @param array $classes Array of CSS classnames.
|
|
|
|
* @return array Modified array of CSS classnames.
|
|
|
|
*/
|
2019-08-27 15:25:32 +00:00
|
|
|
public static function add_theme_body_class( $classes = [] ) {
|
2021-04-28 16:15:39 +00:00
|
|
|
_deprecated_function( 'Assets::add_theme_body_class', '5.0.0' );
|
2019-07-01 12:52:44 +00:00
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
|
2020-05-21 17:09:50 +00:00
|
|
|
/**
|
|
|
|
* Add theme class to admin body.
|
|
|
|
*
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0
|
2020-05-21 17:09:50 +00:00
|
|
|
* @param array $classes String with the CSS classnames.
|
|
|
|
* @return array Modified string of CSS classnames.
|
|
|
|
*/
|
|
|
|
public static function add_theme_admin_body_class( $classes = '' ) {
|
2021-04-28 16:15:39 +00:00
|
|
|
_deprecated_function( 'Assets::add_theme_admin_body_class', '5.0.0' );
|
2020-05-21 17:09:50 +00:00
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
|
2021-02-15 16:46:02 +00:00
|
|
|
/**
|
|
|
|
* Adds a redirect field to the login form so blocks can redirect users after login.
|
2019-07-01 12:52:44 +00:00
|
|
|
*
|
2021-04-28 16:15:39 +00:00
|
|
|
* @deprecated 5.0.0
|
2019-07-01 12:52:44 +00:00
|
|
|
*/
|
2021-04-26 09:37:10 +00:00
|
|
|
public static function redirect_to_field() {
|
2021-04-28 16:15:39 +00:00
|
|
|
_deprecated_function( 'Assets::redirect_to_field', '5.0.0' );
|
2019-07-01 12:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-07 08:15:46 +00:00
|
|
|
* Queues a block script in the frontend.
|
2019-07-22 09:36:51 +00:00
|
|
|
*
|
|
|
|
* @since 2.3.0
|
2020-05-27 15:20:35 +00:00
|
|
|
* @since 2.6.0 Changed $name to $script_name and added $handle argument.
|
2020-07-07 08:15:46 +00:00
|
|
|
* @since 2.9.0 Made it so scripts are not loaded in admin pages.
|
2021-02-17 13:18:35 +00:00
|
|
|
* @deprecated 4.5.0 Block types register the scripts themselves.
|
2019-07-22 09:36:51 +00:00
|
|
|
*
|
2020-01-10 14:37:27 +00:00
|
|
|
* @param string $script_name Name of the script used to identify the file inside build folder.
|
|
|
|
* @param string $handle Optional. Provided if the handle should be different than the script name. `wc-` prefix automatically added.
|
|
|
|
* @param array $dependencies Optional. An array of registered script handles this script depends on. Default empty array.
|
2019-07-22 09:36:51 +00:00
|
|
|
*/
|
2020-01-10 14:37:27 +00:00
|
|
|
public static function register_block_script( $script_name, $handle = '', $dependencies = [] ) {
|
2021-02-17 13:18:35 +00:00
|
|
|
_deprecated_function( 'register_block_script', '4.5.0' );
|
2020-07-07 08:15:46 +00:00
|
|
|
$asset_api = Package::container()->get( AssetApi::class );
|
|
|
|
$asset_api->register_block_script( $script_name, $handle, $dependencies );
|
2019-07-22 09:36:51 +00:00
|
|
|
}
|
2019-07-01 12:52:44 +00:00
|
|
|
}
|