diff --git a/core/includes/theme.inc b/core/includes/theme.inc index e3964d7..6d3b8ee 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -455,6 +455,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { 'render element' => TRUE, 'pattern' => TRUE, 'base hook' => TRUE, + 'original module' => NULL, ); $module_list = array_keys(Drupal::moduleHandler()->getModuleList()); @@ -501,6 +502,12 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { if (isset($cache[$hook])) { $result[$hook] += array_intersect_key($cache[$hook], $hook_defaults); } + // If this is the first implementation of this theme hook by a module, + // keep track of the module name in the registry so it can be available + // to theme() even if other modules and themes implement the same hook. + else if ($type == 'module') { + $result[$hook]['original module'] = $name; + } // The following apply only to theming hooks implemented as templates. if (isset($info['template'])) { @@ -1002,25 +1009,27 @@ function theme($hook, $variables = array()) { 'theme_hook_original' => $original_hook, ); - // Set base hook for use with suggestions alter hooks. This way if e.g. - // '#theme' => 'node__article' is called, we run - // hook_theme_suggestions_node_alter() rather than + // Set base hook for later use. This way if e.g. '#theme' => 'node__article' + // is called, we run hook_theme_suggestions_node_alter() rather than // hook_theme_suggestions_node__article_alter(), and also pass in the base // hook as the last parameter to the suggestions alter hooks. if (isset($info['base hook'])) { - $suggestions_base_hook = $info['base hook']; + $base_theme_hook = $info['base hook']; } else { - $suggestions_base_hook = $hook; + $base_theme_hook = $hook; } - // Invoke theme hook suggestion alter hooks. - $suggestions = array(); - $suggestion_hooks = array( - 'theme_suggestions', - 'theme_suggestions_' . $suggestions_base_hook, - ); - Drupal::moduleHandler()->alter($suggestion_hooks, $suggestions, $variables, $suggestions_base_hook); + // Invoke theme suggestion hook for the module originally defining the theme + // hook. + if (isset($info['original module'])) { + $suggestions = (array) Drupal::moduleHandler()->invoke($info['original module'], 'theme_suggestions_' . $base_theme_hook, array($variables)); + } + else { + $suggestions = array(); + } + // Allow theme suggestions to be altered. + Drupal::moduleHandler()->alter('theme_suggestions_' . $base_theme_hook, $suggestions, $variables); // Check if each suggestion exists in the theme registry, and if so, // use it instead of the hook that theme() was called with. For example, a @@ -1120,6 +1129,8 @@ function theme($hook, $variables = array()) { if (isset($info['path'])) { $template_file = $info['path'] . '/' . $template_file; } + // Add the theme suggestions to the variables array just before rendering + // the template for backwards compatibility with template engines. $variables['theme_hook_suggestions'] = $suggestions; $output = $render_function($template_file, $variables); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index f810f82..e13078a 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -492,9 +492,11 @@ function block_rebuild() { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function block_theme_suggestions_block_alter(array &$suggestions, array $variables) { +function block_theme_suggestions_block(array $variables) { + $suggestions = array(); + $suggestions[] = 'block__' . $variables['elements']['#configuration']['module']; // Hyphens (-) and underscores (_) play a special role in theme suggestions. // Theme suggestions should only contain underscores, because within @@ -518,6 +520,8 @@ function block_theme_suggestions_block_alter(array &$suggestions, array $variabl $machine_name = array_pop($config_id); $suggestions[] = 'block__' . $machine_name; } + + return $suggestions; } /** diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php index 1bfcc62..c98bdcb 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockPreprocessUnitTest.php @@ -48,6 +48,7 @@ function testBlockClasses() { $variables['elements']['#configuration'] = $block->getPlugin()->getConfiguration(); $variables['elements']['#plugin_id'] = $block->get('plugin'); $variables['elements']['content'] = array(); + // Test adding a class to the block content. $variables['content_attributes']['class'][] = 'test-class'; template_preprocess_block($variables); $this->assertEqual($variables['content_attributes']['class'], array('test-class', 'content'), 'Default .content class added to block content_attributes'); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php index f6335b7..f311f19 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase; /** - * Unit tests for block_theme_suggestions_block_alter(). + * Unit tests for block_theme_suggestions_block(). */ class BlockTemplateSuggestionsUnitTest extends WebTestBase { @@ -24,13 +24,13 @@ class BlockTemplateSuggestionsUnitTest extends WebTestBase { public static function getInfo() { return array( 'name' => 'Block template suggestions', - 'description' => 'Test the block_theme_suggestions_block_alter() function.', + 'description' => 'Test the block_theme_suggestions_block() function.', 'group' => 'Block', ); } /** - * Tests template suggestions from block_theme_suggestions_block_alter(). + * Tests template suggestions from block_theme_suggestions_block(). */ function testBlockThemeHookSuggestions() { // Define a block with a derivative to be preprocessed, which includes both @@ -43,13 +43,12 @@ function testBlockThemeHookSuggestions() { 'id' => \Drupal::config('system.theme')->get('default') . '.machinename', )); - $suggestions = array(); $variables = array(); $variables['elements']['#block'] = $block; $variables['elements']['#configuration'] = $block->getPlugin()->getConfiguration(); $variables['elements']['#plugin_id'] = $block->get('plugin'); $variables['elements']['content'] = array(); - block_theme_suggestions_block_alter($suggestions, $variables); + $suggestions = block_theme_suggestions_block($variables); $this->assertEqual($suggestions, array('block__system', 'block__system_menu_block', 'block__system_menu_block__menu_admin', 'block__machinename')); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 182da56..bb207b8 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -899,15 +899,18 @@ function field_page_build(&$page) { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function field_theme_suggestions_field_alter(array &$suggestions, array $variables) { +function field_theme_suggestions_field(array $variables) { + $suggestions = array(); $element = $variables['element']; $suggestions[] = 'field__' . $element['#field_type']; $suggestions[] = 'field__' . $element['#field_name']; $suggestions[] = 'field__' . $element['#bundle']; $suggestions[] = 'field__' . $element['#field_name'] . '__' . $element['#bundle']; + + return $suggestions; } /** diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 4c0733c..328f463 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -956,9 +956,11 @@ function forum_preprocess_block(&$variables) { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function forum_theme_suggestions_forums_alter(array &$suggestions, array $variables) { +function forum_theme_suggestions_forums(array $variables) { + $suggestions = array(); + // Provide separate template suggestions based on what's being output. Topic // ID is also accounted for. Check both variables to be safe then the inverse. // Forums with topic IDs take precedence. @@ -975,6 +977,8 @@ function forum_theme_suggestions_forums_alter(array &$suggestions, array $variab else { $suggestions[] = 'forums__' . $variables['tid']; } + + return $suggestions; } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 43425bc..c255852 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -667,13 +667,16 @@ function node_preprocess_block(&$variables) { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function node_theme_suggestions_node_alter(array &$suggestions, array $variables) { +function node_theme_suggestions_node(array $variables) { + $suggestions = array(); $node = $variables['elements']['#node']; $suggestions[] = 'node__' . $node->bundle(); $suggestions[] = 'node__' . $node->id(); + + return $suggestions; } /** diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 0ca1d8f..4ec0be4 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -75,10 +75,10 @@ function search_view($module = NULL, $keys = '') { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function search_theme_suggestions_search_results_alter(array &$suggestions, array $variables) { - $suggestions[] = 'search_results__' . $variables['module']; +function search_theme_suggestions_search_results(array $variables) { + return array('search_results__' . $variables['module']); } /** @@ -111,10 +111,10 @@ function template_preprocess_search_results(&$variables) { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function search_theme_suggestions_search_result_alter(array &$suggestions, array $variables) { - $suggestions[] = 'search_result__' . $variables['module']; +function search_theme_suggestions_search_result(array $variables) { + return array('search_result__' . $variables['module']); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php index 7faa77c..7e2636c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php @@ -35,6 +35,23 @@ function setUp() { } /** + * Tests that hooks to provide theme suggestions work. + */ + function testTemplateSuggestions() { + $this->drupalGet('theme-test/suggestion-provided'); + $this->assertText('Template for testing suggestions provided by the module declaring the theme hook.'); + + // Enable test_theme, it contains a template suggested by theme_test.module + // in theme_test_theme_suggestions_theme_test_suggestion_provided(). + config('system.theme') + ->set('default', 'test_theme') + ->save(); + + $this->drupalGet('theme-test/suggestion-provided'); + $this->assertText('Template overridden based on suggestion provided by the module declaring the theme hook.'); + } + + /** * Tests that theme suggestion alter hooks work for templates. */ function testTemplateSuggestionsAlter() { @@ -59,13 +76,17 @@ function testTemplateSuggestionsAlter() { * Tests that theme suggestion alter hooks work for specific theme calls. */ function testSpecificSuggestionsAlter() { + // Test that the default template is rendered. + $this->drupalGet('theme-test/specific-suggestion-alter'); + $this->assertText('Template for testing specific theme calls.'); + config('system.theme') ->set('default', 'test_theme') ->save(); // Test a specific theme call similar to '#theme' => 'node__article'. $this->drupalGet('theme-test/specific-suggestion-alter'); - $this->assertText('Template for testing specific theme calls.'); + $this->assertText('Template matching the specific theme call.'); // Ensure that the base hook is used to determine the suggestion alter hook. module_enable(array('theme_suggestions_test')); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2c1a4de..9728efb 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -957,23 +957,25 @@ function system_menu() { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function system_theme_suggestions_html_alter(array &$suggestions, array $variables) { - $suggestions = array_merge($suggestions, theme_get_suggestions(arg(), 'html')); +function system_theme_suggestions_html(array $variables) { + return theme_get_suggestions(arg(), 'html'); } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function system_theme_suggestions_page_alter(array &$suggestions, array $variables) { - $suggestions = array_merge($suggestions, theme_get_suggestions(arg(), 'page')); +function system_theme_suggestions_page(array $variables) { + return theme_get_suggestions(arg(), 'page'); } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function system_theme_suggestions_maintenance_page_alter(array &$suggestions, array $variables) { +function system_theme_suggestions_maintenance_page(array $variables) { + $suggestions = array(); + // Dead databases will show error messages so supplying this template will // allow themers to override the page and the content completely. $offline = defined('MAINTENANCE_MODE'); @@ -987,15 +989,19 @@ function system_theme_suggestions_maintenance_page_alter(array &$suggestions, ar if ($offline) { $suggestions[] = 'maintenance_page__offline'; } + + return $suggestions; } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function system_theme_suggestions_region_alter(array &$suggestions, array $variables) { +function system_theme_suggestions_region(array $variables) { + $suggestions = array(); if (!empty($variables['elements']['#region'])) { $suggestions[] = 'region__' . $variables['elements']['#region']; } + return $suggestions; } /** diff --git a/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module b/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module index 58f9cdb..9ecaeeb 100644 --- a/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module +++ b/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module @@ -22,6 +22,6 @@ function theme_suggestions_test_theme_suggestions_theme_test_function_suggestion /** * Implements hook_theme_suggestions_HOOK_alter(). */ -function theme_suggestions_test_theme_suggestions_theme_test_specific_suggestions_alter(array &$suggestions, array $variables, $hook) { - $suggestions[] = $hook . '__variant__foo'; +function theme_suggestions_test_theme_suggestions_theme_test_specific_suggestions_alter(array &$suggestions, array $variables) { + $suggestions[] = 'theme_test_specific_suggestions__' . 'variant__foo'; } diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php index add8edd..027eddc 100644 --- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php +++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php @@ -34,6 +34,13 @@ function functionTemplateOverridden() { /** * Menu callback for testing suggestion alter hooks with template files. */ + function suggestionProvided() { + return array('#theme' => 'theme_test_suggestion_provided'); + } + + /** + * Menu callback for testing suggestion alter hooks with template files. + */ function suggestionAlter() { return array('#theme' => 'theme_test_suggestions'); } diff --git a/core/modules/system/tests/modules/theme_test/templates/theme-test-suggestions--specific.html.twig b/core/modules/system/tests/modules/theme_test/templates/theme-test-specific-suggestions.html.twig similarity index 100% rename from core/modules/system/tests/modules/theme_test/templates/theme-test-suggestions--specific.html.twig rename to core/modules/system/tests/modules/theme_test/templates/theme-test-specific-suggestions.html.twig diff --git a/core/modules/system/tests/modules/theme_test/templates/theme-test-suggestion-provided.html.twig b/core/modules/system/tests/modules/theme_test/templates/theme-test-suggestion-provided.html.twig new file mode 100644 index 0000000..c9d96dd --- /dev/null +++ b/core/modules/system/tests/modules/theme_test/templates/theme-test-suggestion-provided.html.twig @@ -0,0 +1,2 @@ +{# Output for Theme API test #} +Template for testing suggestions provided by the module declaring the theme hook. diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 96ae2b1..712340b 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -14,6 +14,10 @@ function theme_test_theme($existing, $type, $theme, $path) { $items['theme_test_template_test_2'] = array( 'template' => 'theme_test.template_test', ); + $items['theme_test_suggestion_provided'] = array( + 'template' => 'theme-test-suggestion-provided', + 'variables' => array(), + ); $items['theme_test_specific_suggestions'] = array( 'template' => 'theme-test-specific-suggestions', 'variables' => array(), @@ -63,18 +67,6 @@ function theme_test_menu() { 'theme callback' => '_theme_custom_theme', 'type' => MENU_CALLBACK, ); - $items['theme-test/suggestion-alter'] = array( - 'title' => 'Test suggestion alter hook for template files', - 'route_name' => 'suggestion_alter', - ); - $items['theme-test/specific-suggestion-alter'] = array( - 'title' => 'Test suggestion alter hook for specific theme suggestions', - 'route_name' => 'specific_suggestion_alter', - ); - $items['theme-test/function-suggestion-alter'] = array( - 'title' => 'Test suggestion alter hook for theme functions', - 'route_name' => 'function_suggestion_alter', - ); $items['theme-test/alter'] = array( 'title' => 'Suggestion', 'page callback' => '_theme_test_alter', @@ -234,3 +226,10 @@ function theme_theme_test_render_element_children($variables) { function theme_theme_test_function_suggestions($variables) { return 'Original theme function.'; } + +/** + * Implements hook_theme_suggestions_HOOK(). + */ +function theme_test_theme_suggestions_theme_test_suggestion_provided(array $variables) { + return array('theme_test_suggestion_provided__' . 'foo'); +} diff --git a/core/modules/system/tests/modules/theme_test/theme_test.routing.yml b/core/modules/system/tests/modules/theme_test/theme_test.routing.yml index 1f3d8af..5441828 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.routing.yml +++ b/core/modules/system/tests/modules/theme_test/theme_test.routing.yml @@ -10,6 +10,12 @@ suggestion_alter: _content: '\Drupal\theme_test\ThemeTestController::suggestionAlter' requirements: _permission: 'access content' +suggestion_provided: + pattern: '/theme-test/suggestion-provided' + defaults: + _content: '\Drupal\theme_test\ThemeTestController::suggestionProvided' + requirements: + _permission: 'access content' specific_suggestion_alter: pattern: '/theme-test/specific-suggestion-alter' defaults: diff --git a/core/modules/system/tests/themes/test_theme/templates/theme-test-specific-suggestions--variant.html.twig b/core/modules/system/tests/themes/test_theme/templates/theme-test-specific-suggestions--variant.html.twig index 6e112fd..66edf9a 100644 --- a/core/modules/system/tests/themes/test_theme/templates/theme-test-specific-suggestions--variant.html.twig +++ b/core/modules/system/tests/themes/test_theme/templates/theme-test-specific-suggestions--variant.html.twig @@ -1,2 +1,2 @@ {# Output for Theme API test #} -Template for testing specific theme calls. +Template matching the specific theme call. diff --git a/core/modules/system/tests/themes/test_theme/templates/theme-test-suggestion-provided--foo.html.twig b/core/modules/system/tests/themes/test_theme/templates/theme-test-suggestion-provided--foo.html.twig new file mode 100644 index 0000000..eec7992 --- /dev/null +++ b/core/modules/system/tests/themes/test_theme/templates/theme-test-suggestion-provided--foo.html.twig @@ -0,0 +1,2 @@ +{# Output for Theme API test #} +Template overridden based on suggestion provided by the module declaring the theme hook. diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 4ee2afb..34758da 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -158,28 +158,51 @@ function hook_preprocess_HOOK(&$variables) { } /** - * Alters theme suggestions. + * Provides alternate named suggestions for a specific theme hook. * - * Provide alternative theme function or template suggestions for theme hooks. + * This hook allows the module implementing hook_theme() for a theme hook to + * provide alternative theme function or template name suggestions. This hook is + * only invoked for the first module implementing hook_theme() for a theme hook. + * + * HOOK is the least-specific version of the hook being called. For example, if + * '#theme' => 'node__article' is called, then node_theme_suggestions_node() + * will be invoked, not node_theme_suggestions_node__article(). The specific + * hook called (in this case 'node__article') is available in + * $variables['theme_hook_original']. + * + * @todo Add @code sample. * - * @param array $suggestions - * An array of theme suggestions. * @param array $variables * An array of variables passed to the theme hook. Note that this hook is * invoked before any preprocessing. - * @param string $hook - * The theme hook being called. + * + * @return array + * An array of theme suggestions. * * @see hook_theme_suggestions_HOOK_alter() */ -function hook_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { - if ($hook == 'node') { - $suggestions[] = 'node__' . $variables['elements']['#langcode']; - } +function hook_theme_suggestions_HOOK(array $variables) { + $suggestions = array(); + + $suggestions[] = 'node__' . $variables['elements']['#langcode']; + + return $suggestions; } /** - * Alters theme suggestions for a specific theme hook. + * Alters named suggestions for a specific theme hook. + * + * This hook allows any module or theme to provide altenative theme function or + * template name suggestions and reorder or remove suggestions provided by + * hook_theme_suggestions_HOOK() or by earlier invocations of this hook. + * + * HOOK is the least-specific version of the hook being called. For example, if + * '#theme' => 'node__article' is called, then node_theme_suggestions_node() + * will be invoked, not node_theme_suggestions_node__article(). The specific + * hook called (in this case 'node__article') is available in + * $variables['theme_hook_original']. + * + * @todo Add @code sample. * * @param array $suggestions * An array of theme suggestions. @@ -187,7 +210,7 @@ function hook_theme_suggestions_alter(array &$suggestions, array $variables, $ho * An array of variables passed to the theme hook. Note that this hook is * invoked before any preprocessing. * - * @see hook_theme_suggestions_alter() + * @see hook_theme_suggestions_HOOK() */ function hook_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) { if (empty($variables['header'])) { diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 28ed893..1420479 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -435,13 +435,17 @@ function taxonomy_term_view_multiple(array $terms, $view_mode = 'full', $langcod } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function taxonomy_theme_suggestions_taxonomy_term_alter(array &$suggestions, array $variables) { +function taxonomy_theme_suggestions_taxonomy_term(array $variables) { + $suggestions = array(); + $term = $variables['elements']['#term']; $suggestions[] = 'taxonomy_term__' . $term->bundle(); $suggestions[] = 'taxonomy_term__' . $term->id(); + + return $suggestions; } /** diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index 059ace5..ad0fffa 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -486,8 +486,8 @@ function template_preprocess_views_ui_view_preview_section(&$variables) { } /** - * Implements hook_theme_suggestions_HOOK_alter(). + * Implements hook_theme_suggestions_HOOK(). */ -function views_ui_theme_suggestions_views_ui_view_preview_section_alter(array &$suggestions, array $variables) { - $suggestions[] = 'views_ui_view_preview_section__' . $variables['section']; +function views_ui_theme_suggestions_views_ui_view_preview_section(array $variables) { + return array('views_ui_view_preview_section__' . $variables['section']); }