Changeset 13963 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
- Timestamp:
- 08/12/2024 03:47:32 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
r13873 r13963 25 25 */ 26 26 add_action( 'init', __NAMESPACE__ . '\register_types' ); 27 add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_block_style_assets' );28 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_block_style_assets' );29 27 30 28 /** … … 419 417 420 418 /** 421 * Enqueue scripts and stylesheets for custom block styles.422 *423 * @throws Error If the build files are not found.424 */425 function enqueue_block_style_assets() {426 if ( is_admin() ) {427 $script_asset_path = get_build_path() . 'block-styles.asset.php';428 if ( ! file_exists( $script_asset_path ) ) {429 throw new Error(430 'You need to run `npm start` or `npm run build` for block styles first.'431 );432 }433 434 $script_asset = require $script_asset_path;435 wp_enqueue_script(436 'wporg-learn-block-styles',437 get_build_url() . 'block-styles.js',438 $script_asset['dependencies'],439 $script_asset['version']440 );441 }442 443 wp_enqueue_style(444 'wporg-learn-block-styles',445 get_build_url() . 'style-block-styles.css',446 array(),447 filemtime( get_build_path() . 'style-block-styles.css' )448 );449 }450 451 /**452 419 * Register the learning duration block. 453 420 */
Note: See TracChangeset
for help on using the changeset viewer.