You are here

function gutenberg_theme_suggestions_gutenberg_block in Gutenberg 8.2

Implements hook_theme_suggestions_HOOK().

File

./gutenberg.module, line 107
Provides integration with the Gutenberg editor.

Code

function gutenberg_theme_suggestions_gutenberg_block(array $variables) {
  $block_name = str_replace('-', '_', $variables['block_name']);
  $block_parts = explode('/', $block_name);
  $suggestions = [];
  $base_hook = 'gutenberg_block__';
  $suggestions[] = $base_hook . $block_parts[0];
  if (count($block_parts) === 2) {

    // namespace/blockname format.
    $suggestions[] = $base_hook . $block_parts[0] . '__' . $block_parts[1];
  }
  return $suggestions;
}