| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Block and style registration functions. | |
| 3 | + * Block functions specific for the Gutenberg editor plugin. | |
| 4 | 4 | * |
| 5 | 5 | * @package gutenberg |
| 6 | 6 | */ |
| 7 | 7 | |
| @@ -20,25 +20,17 @@ | ||
| 20 | 20 | 'freeform', |
| 21 | 21 | 'code', |
| 22 | 22 | 'column', |
| 23 | 23 | 'columns', |
| 24 | - 'comments-query-loop', | |
| 25 | - 'cover', | |
| 26 | - 'gallery', | |
| 24 | + 'comments', | |
| 27 | 25 | 'group', |
| 28 | - 'heading', | |
| 29 | 26 | 'html', |
| 30 | - 'home-link', | |
| 31 | - 'image', | |
| 32 | 27 | 'list', |
| 28 | + 'list-item', | |
| 33 | 29 | 'media-text', |
| 34 | 30 | 'missing', |
| 35 | 31 | 'more', |
| 36 | - 'navigation-area', | |
| 37 | - 'navigation-link', | |
| 38 | - 'navigation-submenu', | |
| 39 | 32 | 'nextpage', |
| 40 | - 'pattern', | |
| 41 | 33 | 'paragraph', |
| 42 | 34 | 'preformatted', |
| 43 | 35 | 'pullquote', |
| 44 | 36 | 'quote', |
| @@ -45,9 +37,9 @@ | ||
| 45 | 37 | 'separator', |
| 46 | 38 | 'social-links', |
| 47 | 39 | 'spacer', |
| 48 | 40 | 'table', |
| 49 | - // 'table-of-contents', | |
| 41 | + 'table-of-contents', | |
| 50 | 42 | 'text-columns', |
| 51 | 43 | 'verse', |
| 52 | 44 | 'video', |
| 53 | 45 | 'embed', |
| @@ -53,11 +45,13 @@ | ||
| 53 | 45 | 'embed', |
| 54 | 46 | ), |
| 55 | 47 | 'block_names' => array( |
| 56 | 48 | 'archives.php' => 'core/archives', |
| 49 | + 'avatar.php' => 'core/avatar', | |
| 57 | 50 | 'block.php' => 'core/block', |
| 58 | 51 | 'calendar.php' => 'core/calendar', |
| 59 | 52 | 'categories.php' => 'core/categories', |
| 53 | + 'cover.php' => 'core/cover', | |
| 60 | 54 | 'comment-author-avatar.php' => 'core/comment-author-avatar', |
| 61 | 55 | 'comment-author-name.php' => 'core/comment-author-name', |
| 62 | 56 | 'comment-content.php' => 'core/comment-content', |
| 63 | 57 | 'comment-date.php' => 'core/comment-date', |
| @@ -67,17 +61,19 @@ | ||
| 67 | 61 | 'comments-pagination.php' => 'core/comments-pagination', |
| 68 | 62 | 'comments-pagination-next.php' => 'core/comments-pagination-next', |
| 69 | 63 | 'comments-pagination-numbers.php' => 'core/comments-pagination-numbers', |
| 70 | 64 | 'comments-pagination-previous.php' => 'core/comments-pagination-previous', |
| 65 | + 'comments-title.php' => 'core/comments-title', | |
| 66 | + 'comments.php' => 'core/comments', | |
| 71 | 67 | 'file.php' => 'core/file', |
| 72 | 68 | 'home-link.php' => 'core/home-link', |
| 73 | 69 | 'image.php' => 'core/image', |
| 74 | 70 | 'gallery.php' => 'core/gallery', |
| 71 | + 'heading.php' => 'core/heading', | |
| 75 | 72 | 'latest-comments.php' => 'core/latest-comments', |
| 76 | 73 | 'latest-posts.php' => 'core/latest-posts', |
| 77 | 74 | 'loginout.php' => 'core/loginout', |
| 78 | 75 | 'navigation.php' => 'core/navigation', |
| 79 | - 'navigation-area.php' => 'core/navigation-area', | |
| 80 | 76 | 'navigation-link.php' => 'core/navigation-link', |
| 81 | 77 | 'navigation-submenu.php' => 'core/navigation-submenu', |
| 82 | 78 | 'page-list.php' => 'core/page-list', |
| 83 | 79 | 'pattern.php' => 'core/pattern', |
| @@ -84,9 +80,8 @@ | ||
| 84 | 80 | 'post-author.php' => 'core/post-author', |
| 85 | 81 | 'post-author-name.php' => 'core/post-author-name', |
| 86 | 82 | 'post-author-biography.php' => 'core/post-author-biography', |
| 87 | 83 | 'post-comment.php' => 'core/post-comment', |
| 88 | - 'post-comments.php' => 'core/post-comments', | |
| 89 | 84 | 'post-comments-count.php' => 'core/post-comments-count', |
| 90 | 85 | 'post-comments-form.php' => 'core/post-comments-form', |
| 91 | 86 | 'post-comments-link.php' => 'core/post-comments-link', |
| 92 | 87 | 'post-content.php' => 'core/post-content', |
| @@ -97,8 +92,9 @@ | ||
| 97 | 92 | 'post-terms.php' => 'core/post-terms', |
| 98 | 93 | 'post-title.php' => 'core/post-title', |
| 99 | 94 | 'query.php' => 'core/query', |
| 100 | 95 | 'post-template.php' => 'core/post-template', |
| 96 | + 'query-no-results.php' => 'core/query-no-results', | |
| 101 | 97 | 'query-pagination.php' => 'core/query-pagination', |
| 102 | 98 | 'query-pagination-next.php' => 'core/query-pagination-next', |
| 103 | 99 | 'query-pagination-numbers.php' => 'core/query-pagination-numbers', |
| 104 | 100 | 'query-pagination-previous.php' => 'core/query-pagination-previous', |
| @@ -110,9 +106,8 @@ | ||
| 110 | 106 | 'social-link.php' => 'core/social-link', |
| 111 | 107 | 'site-logo.php' => 'core/site-logo', |
| 112 | 108 | 'site-tagline.php' => 'core/site-tagline', |
| 113 | 109 | 'site-title.php' => 'core/site-title', |
| 114 | - // 'table-of-contents.php' => 'core/table-of-contents', | |
| 115 | 110 | 'tag-cloud.php' => 'core/tag-cloud', |
| 116 | 111 | 'template-part.php' => 'core/template-part', |
| 117 | 112 | 'term-description.php' => 'core/term-description', |
| 118 | 113 | ), |
| @@ -147,9 +142,9 @@ | ||
| 147 | 142 | // WordPress core. In this place we should rather use filter |
| 148 | 143 | // to replace paths with overrides defined by the plugin. |
| 149 | 144 | $metadata = json_decode( file_get_contents( $block_json_file ), true ); |
| 150 | 145 | if ( ! is_array( $metadata ) || ! $metadata['name'] ) { |
| 151 | - return false; | |
| 146 | + continue; | |
| 152 | 147 | } |
| 153 | 148 | |
| 154 | 149 | if ( $registry->is_registered( $metadata['name'] ) ) { |
| 155 | 150 | $registry->unregister( $metadata['name'] ); |
| @@ -160,9 +155,9 @@ | ||
| 160 | 155 | } |
| 161 | 156 | |
| 162 | 157 | foreach ( $block_names as $file => $sub_block_names ) { |
| 163 | 158 | if ( ! file_exists( $blocks_dir . $file ) ) { |
| 164 | - return; | |
| 159 | + continue; | |
| 165 | 160 | } |
| 166 | 161 | |
| 167 | 162 | $sub_block_names_normalized = is_string( $sub_block_names ) ? array( $sub_block_names ) : $sub_block_names; |
| 168 | 163 | foreach ( $sub_block_names_normalized as $block_name ) { |
| @@ -194,18 +189,19 @@ | ||
| 194 | 189 | $block_name = str_replace( 'core/', '', $block_name ); |
| 195 | 190 | |
| 196 | 191 | // When in production, use the plugin's version as the default asset version; |
| 197 | 192 | // else (for development or test) default to use the current time. |
| 198 | - $default_version = defined( 'GUTENBERG_VERSION' ) && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? GUTENBERG_VERSION : time(); | |
| 193 | + $default_version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time(); | |
| 199 | 194 | |
| 200 | - $style_path = "build/block-library/blocks/$block_name/style.css"; | |
| 201 | - $editor_style_path = "build/block-library/blocks/$block_name/style-editor.css"; | |
| 195 | + $style_path = "build/block-library/blocks/$block_name/"; | |
| 196 | + $stylesheet_url = gutenberg_url( $style_path . 'style.css' ); | |
| 197 | + $stylesheet_path = gutenberg_dir_path() . $style_path . ( is_rtl() ? 'style-rtl.css' : 'style.css' ); | |
| 202 | 198 | |
| 203 | - if ( file_exists( gutenberg_dir_path() . $style_path ) ) { | |
| 199 | + if ( file_exists( $stylesheet_path ) ) { | |
| 204 | 200 | wp_deregister_style( "wp-block-{$block_name}" ); |
| 205 | 201 | wp_register_style( |
| 206 | 202 | "wp-block-{$block_name}", |
| 207 | - gutenberg_url( $style_path ), | |
| 203 | + $stylesheet_url, | |
| 208 | 204 | array(), |
| 209 | 205 | $default_version |
| 210 | 206 | ); |
| 211 | 207 | wp_style_add_data( "wp-block-{$block_name}", 'rtl', 'replace' ); |
| @@ -210,11 +206,11 @@ | ||
| 210 | 206 | ); |
| 211 | 207 | wp_style_add_data( "wp-block-{$block_name}", 'rtl', 'replace' ); |
| 212 | 208 | |
| 213 | 209 | // Add a reference to the stylesheet's path to allow calculations for inlining styles in `wp_head`. |
| 214 | - wp_style_add_data( "wp-block-{$block_name}", 'path', gutenberg_dir_path() . $style_path ); | |
| 210 | + wp_style_add_data( "wp-block-{$block_name}", 'path', $stylesheet_path ); | |
| 215 | 211 | } else { |
| 216 | - wp_register_style( "wp-block-{$block_name}", false ); | |
| 212 | + wp_register_style( "wp-block-{$block_name}", false, array() ); | |
| 217 | 213 | } |
| 218 | 214 | |
| 219 | 215 | // If the current theme supports wp-block-styles, dequeue the full stylesheet |
| 220 | 216 | // and instead attach each block's theme-styles to their block styles stylesheet. |
| @@ -240,9 +236,9 @@ | ||
| 240 | 236 | |
| 241 | 237 | // If the file exists, enqueue it. |
| 242 | 238 | if ( file_exists( gutenberg_dir_path() . $theme_style_path ) ) { |
| 243 | 239 | |
| 244 | - if ( file_exists( gutenberg_dir_path() . $style_path ) ) { | |
| 240 | + if ( file_exists( $stylesheet_path ) ) { | |
| 245 | 241 | // If there is a main stylesheet for this block, append the theme styles to main styles. |
| 246 | 242 | wp_add_inline_style( |
| 247 | 243 | "wp-block-{$block_name}", |
| 248 | 244 | file_get_contents( gutenberg_dir_path() . $theme_style_path ) |
| @@ -259,8 +255,9 @@ | ||
| 259 | 255 | } |
| 260 | 256 | } |
| 261 | 257 | } |
| 262 | 258 | |
| 259 | + $editor_style_path = "build/block-library/blocks/$block_name/style-editor.css"; | |
| 263 | 260 | if ( file_exists( gutenberg_dir_path() . $editor_style_path ) ) { |
| 264 | 261 | wp_deregister_style( "wp-block-{$block_name}-editor" ); |
| 265 | 262 | wp_register_style( |
| 266 | 263 | "wp-block-{$block_name}-editor", |
| @@ -273,48 +270,8 @@ | ||
| 273 | 270 | wp_register_style( "wp-block-{$block_name}-editor", false ); |
| 274 | 271 | } |
| 275 | 272 | } |
| 276 | 273 | |
| 277 | -if ( ! function_exists( '_wp_normalize_relative_css_links' ) ) { | |
| 278 | - /** | |
| 279 | - * Make URLs relative to the WordPress installation. | |
| 280 | - * | |
| 281 | - * @since 5.8.2 | |
| 282 | - * | |
| 283 | - * @param string $css The CSS to make URLs relative to the WordPress installation. | |
| 284 | - * @param string $stylesheet_url The URL to the stylesheet. | |
| 285 | - * | |
| 286 | - * @return string The CSS with URLs made relative to the WordPress installation. | |
| 287 | - */ | |
| 288 | - function _wp_normalize_relative_css_links( $css, $stylesheet_url ) { | |
| 289 | - $has_src_results = preg_match_all( '#url\s*\(\s*[\'"]?\s*([^\'"\)]+)#', $css, $src_results ); | |
| 290 | - if ( $has_src_results ) { | |
| 291 | - // Loop through the URLs to find relative ones. | |
| 292 | - foreach ( $src_results[1] as $src_index => $src_result ) { | |
| 293 | - // Skip if this is an absolute URL. | |
| 294 | - if ( 0 === strpos( $src_result, 'http' ) || 0 === strpos( $src_result, '//' ) ) { | |
| 295 | - continue; | |
| 296 | - } | |
| 297 | - | |
| 298 | - // Build the absolute URL. | |
| 299 | - $absolute_url = dirname( $stylesheet_url ) . '/' . $src_result; | |
| 300 | - $absolute_url = str_replace( '/./', '/', $absolute_url ); | |
| 301 | - // Convert to URL related to the site root. | |
| 302 | - $relative_url = wp_make_link_relative( $absolute_url ); | |
| 303 | - | |
| 304 | - // Replace the URL in the CSS. | |
| 305 | - $css = str_replace( | |
| 306 | - $src_results[0][ $src_index ], | |
| 307 | - str_replace( $src_result, $relative_url, $src_results[0][ $src_index ] ), | |
| 308 | - $css | |
| 309 | - ); | |
| 310 | - } | |
| 311 | - } | |
| 312 | - | |
| 313 | - return $css; | |
| 314 | - } | |
| 315 | -} | |
| 316 | - | |
| 317 | 274 | /** |
| 318 | 275 | * Complements the implementation of block type `core/social-icon`, whether it |
| 319 | 276 | * be provided by core or the plugin, with derived block types for each |
| 320 | 277 | * "service" (WordPress, Twitter, etc.) supported by Social Links. |
| @@ -322,9 +279,9 @@ | ||
| 322 | 279 | * This ensures backwards compatibility for any users running the Gutenberg |
| 323 | 280 | * plugin who have used Social Links prior to their conversion to block |
| 324 | 281 | * variations. |
| 325 | 282 | * |
| 326 | - * This shim is INTENTIONALLY left out of core, as Social Links haven't yet | |
| 283 | + * This shim is INTENTIONALLY left out of core, as Social Links have never | |
| 327 | 284 | * landed there. |
| 328 | 285 | * |
| 329 | 286 | * @see https://github.com/WordPress/gutenberg/pull/19887 |
| 330 | 287 | */ |
| @@ -394,200 +351,4 @@ | ||
| 394 | 351 | } |
| 395 | 352 | } |
| 396 | 353 | |
| 397 | 354 | add_action( 'init', 'gutenberg_register_legacy_social_link_blocks' ); |
| 398 | - | |
| 399 | -/** | |
| 400 | - * Checks whether the current block type supports the feature requested. | |
| 401 | - * | |
| 402 | - * @param WP_Block_Type $block_type Block type to check for support. | |
| 403 | - * @param array $feature Path of the feature to check support for. | |
| 404 | - * @param mixed $default Fallback value for feature support, defaults to false. | |
| 405 | - * | |
| 406 | - * @return boolean Whether or not the feature is supported. | |
| 407 | - */ | |
| 408 | -function gutenberg_block_has_support( $block_type, $feature, $default = false ) { | |
| 409 | - $block_support = $default; | |
| 410 | - if ( $block_type && property_exists( $block_type, 'supports' ) ) { | |
| 411 | - $block_support = _wp_array_get( $block_type->supports, $feature, $default ); | |
| 412 | - } | |
| 413 | - | |
| 414 | - return true === $block_support || is_array( $block_support ); | |
| 415 | -} | |
| 416 | - | |
| 417 | -/** | |
| 418 | - * Updates the shape of supports for declaring fontSize and lineHeight. | |
| 419 | - * | |
| 420 | - * @param array $metadata Metadata for registering a block type. | |
| 421 | - * @return array Metadata for registering a block type with the supports shape updated. | |
| 422 | - */ | |
| 423 | -function gutenberg_migrate_old_typography_shape( $metadata ) { | |
| 424 | - // Temporarily disable migrations from core blocks to avoid warnings on versions older than 5.8. | |
| 425 | - if ( isset( $metadata['supports'] ) && false === strpos( $metadata['file'], '/wp-includes/blocks/' ) ) { | |
| 426 | - $typography_keys = array( | |
| 427 | - '__experimentalFontFamily', | |
| 428 | - '__experimentalFontStyle', | |
| 429 | - '__experimentalFontWeight', | |
| 430 | - '__experimentalLetterSpacing', | |
| 431 | - '__experimentalTextDecoration', | |
| 432 | - '__experimentalTextTransform', | |
| 433 | - 'fontSize', | |
| 434 | - 'lineHeight', | |
| 435 | - ); | |
| 436 | - foreach ( $typography_keys as $typography_key ) { | |
| 437 | - $support_for_key = _wp_array_get( $metadata['supports'], array( $typography_key ), null ); | |
| 438 | - if ( null !== $support_for_key ) { | |
| 439 | - trigger_error( | |
| 440 | - /* translators: %1$s: Block type, %2$s: typography supports key e.g: fontSize, lineHeight etc... */ | |
| 441 | - sprintf( __( 'Block %1$s is declaring %2$s support on block.json under supports.%2$s. %2$s support is now declared under supports.typography.%2$s.', 'gutenberg' ), $metadata['name'], $typography_key ), | |
| 442 | - headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE | |
| 443 | - ); | |
| 444 | - _wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key ); | |
| 445 | - unset( $metadata['supports'][ $typography_key ] ); | |
| 446 | - } | |
| 447 | - } | |
| 448 | - } | |
| 449 | - return $metadata; | |
| 450 | -} | |
| 451 | - | |
| 452 | -if ( ! function_exists( 'wp_migrate_old_typography_shape' ) ) { | |
| 453 | - add_filter( 'block_type_metadata', 'gutenberg_migrate_old_typography_shape' ); | |
| 454 | -} | |
| 455 | - | |
| 456 | -if ( ! function_exists( 'wp_enqueue_block_style' ) ) { | |
| 457 | - /** | |
| 458 | - * Enqueue a stylesheet for a specific block. | |
| 459 | - * | |
| 460 | - * If the theme has opted-in to separate-styles loading, | |
| 461 | - * then the stylesheet will be enqueued on-render, | |
| 462 | - * otherwise when the block inits. | |
| 463 | - * | |
| 464 | - * @param string $block_name The block-name, including namespace. | |
| 465 | - * @param array $args An array of arguments [handle,src,deps,ver,media]. | |
| 466 | - * | |
| 467 | - * @return void | |
| 468 | - */ | |
| 469 | - function wp_enqueue_block_style( $block_name, $args ) { | |
| 470 | - $args = wp_parse_args( | |
| 471 | - $args, | |
| 472 | - array( | |
| 473 | - 'handle' => '', | |
| 474 | - 'src' => '', | |
| 475 | - 'deps' => array(), | |
| 476 | - 'ver' => false, | |
| 477 | - 'media' => 'all', | |
| 478 | - ) | |
| 479 | - ); | |
| 480 | - | |
| 481 | - /** | |
| 482 | - * Callback function to register and enqueue styles. | |
| 483 | - * | |
| 484 | - * @param string $content When the callback is used for the render_block filter, | |
| 485 | - * the content needs to be returned so the function parameter | |
| 486 | - * is to ensure the content exists. | |
| 487 | - * @return string Block content. | |
| 488 | - */ | |
| 489 | - $callback = static function( $content ) use ( $args ) { | |
| 490 | - // Register the stylesheet. | |
| 491 | - if ( ! empty( $args['src'] ) ) { | |
| 492 | - wp_register_style( $args['handle'], $args['src'], $args['deps'], $args['ver'], $args['media'] ); | |
| 493 | - } | |
| 494 | - | |
| 495 | - // Add `path` data if provided. | |
| 496 | - if ( isset( $args['path'] ) ) { | |
| 497 | - wp_style_add_data( $args['handle'], 'path', $args['path'] ); | |
| 498 | - | |
| 499 | - // Get the RTL file path. | |
| 500 | - $rtl_file_path = str_replace( '.css', '-rtl.css', $args['path'] ); | |
| 501 | - | |
| 502 | - // Add RTL stylesheet. | |
| 503 | - if ( file_exists( $rtl_file_path ) ) { | |
| 504 | - wp_style_add_data( $args['handle'], 'rtl', 'replace' ); | |
| 505 | - | |
| 506 | - if ( is_rtl() ) { | |
| 507 | - wp_style_add_data( $args['handle'], 'path', $rtl_file_path ); | |
| 508 | - } | |
| 509 | - } | |
| 510 | - } | |
| 511 | - | |
| 512 | - // Enqueue the stylesheet. | |
| 513 | - wp_enqueue_style( $args['handle'] ); | |
| 514 | - | |
| 515 | - return $content; | |
| 516 | - }; | |
| 517 | - | |
| 518 | - $hook = did_action( 'wp_enqueue_scripts' ) ? 'wp_footer' : 'wp_enqueue_scripts'; | |
| 519 | - if ( wp_should_load_separate_core_block_assets() ) { | |
| 520 | - /** | |
| 521 | - * Callback function to register and enqueue styles. | |
| 522 | - * | |
| 523 | - * @param string $content The block content. | |
| 524 | - * @param array $block The full block, including name and attributes. | |
| 525 | - * @return string Block content. | |
| 526 | - */ | |
| 527 | - $callback_separate = static function( $content, $block ) use ( $block_name, $callback ) { | |
| 528 | - if ( ! empty( $block['blockName'] ) && $block_name === $block['blockName'] ) { | |
| 529 | - return $callback( $content ); | |
| 530 | - } | |
| 531 | - return $content; | |
| 532 | - }; | |
| 533 | - | |
| 534 | - /* | |
| 535 | - * The filter's callback here is an anonymous function because | |
| 536 | - * using a named function in this case is not possible. | |
| 537 | - * | |
| 538 | - * The function cannot be unhooked, however, users are still able | |
| 539 | - * to dequeue the stylesheets registered/enqueued by the callback | |
| 540 | - * which is why in this case, using an anonymous function | |
| 541 | - * was deemed acceptable. | |
| 542 | - */ | |
| 543 | - add_filter( 'render_block', $callback_separate, 10, 2 ); | |
| 544 | - return; | |
| 545 | - } | |
| 546 | - | |
| 547 | - /* | |
| 548 | - * The filter's callback here is an anonymous function because | |
| 549 | - * using a named function in this case is not possible. | |
| 550 | - * | |
| 551 | - * The function cannot be unhooked, however, users are still able | |
| 552 | - * to dequeue the stylesheets registered/enqueued by the callback | |
| 553 | - * which is why in this case, using an anonymous function | |
| 554 | - * was deemed acceptable. | |
| 555 | - */ | |
| 556 | - add_filter( $hook, $callback ); | |
| 557 | - | |
| 558 | - // Enqueue assets in the editor. | |
| 559 | - add_action( 'enqueue_block_assets', $callback ); | |
| 560 | - } | |
| 561 | -} | |
| 562 | - | |
| 563 | -/** | |
| 564 | - * Allow multiple block styles. | |
| 565 | - * | |
| 566 | - * @param array $metadata Metadata for registering a block type. | |
| 567 | - * | |
| 568 | - * @return array | |
| 569 | - */ | |
| 570 | -function gutenberg_multiple_block_styles( $metadata ) { | |
| 571 | - foreach ( array( 'style', 'editorStyle' ) as $key ) { | |
| 572 | - if ( ! empty( $metadata[ $key ] ) && is_array( $metadata[ $key ] ) ) { | |
| 573 | - $default_style = array_shift( $metadata[ $key ] ); | |
| 574 | - foreach ( $metadata[ $key ] as $handle ) { | |
| 575 | - $args = array( 'handle' => $handle ); | |
| 576 | - if ( 0 === strpos( $handle, 'file:' ) && isset( $metadata['file'] ) ) { | |
| 577 | - $style_path = remove_block_asset_path_prefix( $handle ); | |
| 578 | - $args = array( | |
| 579 | - 'handle' => sanitize_key( "{$metadata['name']}-{$style_path}" ), | |
| 580 | - 'src' => plugins_url( $style_path, $metadata['file'] ), | |
| 581 | - ); | |
| 582 | - } | |
| 583 | - | |
| 584 | - wp_enqueue_block_style( $metadata['name'], $args ); | |
| 585 | - } | |
| 586 | - | |
| 587 | - // Only return the 1st item in the array. | |
| 588 | - $metadata[ $key ] = $default_style; | |
| 589 | - } | |
| 590 | - } | |
| 591 | - return $metadata; | |
| 592 | -} | |
| 593 | -add_filter( 'block_type_metadata', 'gutenberg_multiple_block_styles' ); | |