Changeset 46111
- Timestamp:
- 09/14/2019 06:20:58 PM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r45393 r46111 357 357 return has_blocks( $content ) ? 1 : 0; 358 358 } 359 360 /** 361 * Registers a new block style. 362 * 363 * @since 5.3.0 364 * 365 * @param string $block_name Block type name including namespace. 366 * @param array $style_properties Array containing the properties of the style name, label, style (name of the stylesheet to be enqueued), inline_style (string containing the CSS to be added). 367 * 368 * @return boolean True if the block style was registered with success and false otherwise. 369 */ 370 function register_block_style( $block_name, $style_properties ) { 371 return WP_Block_Styles_Registry::get_instance()->register( $block_name, $style_properties ); 372 } 373 374 /** 375 * Unregisters a block style. 376 * 377 * @since 5.3.0 378 * 379 * @param string $block_name Block type name including namespace. 380 * @param array $block_style_name Block style name. 381 * 382 * @return boolean True if the block style was unregistered with success and false otherwise. 383 */ 384 function unregister_block_style( $block_name, $block_style_name ) { 385 return WP_Block_Styles_Registry::get_instance()->unregister( $block_name, $block_style_name ); 386 } -
trunk/src/wp-includes/default-filters.php
r46066 r46111 502 502 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); 503 503 add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); 504 add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 ); 505 add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' ); 504 506 505 507 add_action( 'wp_default_styles', 'wp_default_styles' ); -
trunk/src/wp-includes/script-loader.php
r46095 r46111 2781 2781 } 2782 2782 } 2783 2784 /** 2785 * Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend. 2786 * 2787 * @since 5.3.0 2788 */ 2789 function enqueue_block_styles_assets() { 2790 $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); 2791 2792 foreach ( $block_styles as $styles ) { 2793 foreach ( $styles as $style_properties ) { 2794 if ( isset( $style_properties['style_handle'] ) ) { 2795 wp_enqueue_style( $style_properties['style_handle'] ); 2796 } 2797 if ( isset( $style_properties['inline_style'] ) ) { 2798 wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] ); 2799 } 2800 } 2801 } 2802 } 2803 2804 /** 2805 * Function responsible for enqueuing the assets required for block styles functionality on the editor. 2806 * 2807 * @since 5.3.0 2808 */ 2809 function enqueue_editor_block_styles_assets() { 2810 $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); 2811 2812 $register_script_lines = array( '( function() {' ); 2813 foreach ( $block_styles as $block_name => $styles ) { 2814 foreach ( $styles as $style_properties ) { 2815 $register_script_lines[] = sprintf( 2816 ' wp.blocks.registerBlockStyle( \'%s\', %s );', 2817 $block_name, 2818 wp_json_encode( 2819 array( 2820 'name' => $style_properties['name'], 2821 'label' => $style_properties['label'], 2822 ) 2823 ) 2824 ); 2825 } 2826 } 2827 $register_script_lines[] = '} )();'; 2828 $inline_script = implode( "\n", $register_script_lines ); 2829 2830 wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true ); 2831 wp_add_inline_script( 'wp-block-styles', $inline_script ); 2832 wp_enqueue_script( 'wp-block-styles' ); 2833 } -
trunk/src/wp-settings.php
r45739 r46111 257 257 require( ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php' ); 258 258 require( ABSPATH . WPINC . '/class-wp-block-type.php' ); 259 require( ABSPATH . WPINC . '/class-wp-block-styles-registry.php' ); 259 260 require( ABSPATH . WPINC . '/class-wp-block-type-registry.php' ); 260 261 require( ABSPATH . WPINC . '/class-wp-block-parser.php' );
Note: See TracChangeset
for help on using the changeset viewer.