Making WordPress.org


Ignore:
Timestamp:
08/12/2024 03:47:32 AM (8 months ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@b10e40b

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php

    r13873 r13963  
    2525 */
    2626add_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' );
    2927
    3028/**
     
    419417
    420418/**
    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 /**
    452419 * Register the learning duration block.
    453420 */
Note: See TracChangeset for help on using the changeset viewer.