You are here

function skinr_current_theme in Skinr 8.2

Same name and namespace in other branches
  1. 6.2 skinr.module \skinr_current_theme()
  2. 6 skinr.module \skinr_current_theme()
  3. 7.2 skinr.module \skinr_current_theme()

Helper function to retrieve the current theme.

Parameters

$exclude_admin_theme: Optional. Set to TRUE to exclude the admin theme from possible themes to return.

Return value

The current theme name.

See also

drupal_theme_initialize()

11 calls to skinr_current_theme()
DefaultController::skinr_test_skinr_current_theme in tests/modules/skinr_test/src/Controller/DefaultController.php
DefaultController::skinr_test_skinr_current_theme_admin_exclude in tests/modules/skinr_test/src/Controller/DefaultController.php
skinr_context_ui_admin_list_subform in skinr_context/skinr_context_ui.admin.inc
Overrides skinr_ui_admin_skins().
skinr_context_ui_filters in skinr_context/skinr_context_ui.admin.inc
List skinr administration filters that can be applied.
skinr_context_ui_form_submit in skinr_context/skinr_context_ui.module
Form submission handler for skinr_context_form_alter().

... See full list

File

./skinr.module, line 1089
Handles core Skinr functionality.

Code

function skinr_current_theme($exclude_admin_theme = FALSE) {
  global $user;

  // Drupal core, and modules such as themkey and og_theme, set the theme
  // through hook_custom_theme() or hook_menu() using 'theme callback', which
  // are all picked up by menu_get_custom_theme().
  $theme = \Drupal::theme()
    ->getActiveTheme()
    ->getName();
  if (!$theme) {
    dpm('Empty theme!');
  }
  return $theme;
  if ($exclude_admin_theme) {

    // @todo See https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/drupal_theme_initialize/8
    $theme_handler = \Drupal::service('theme_handler');
    $themes = $theme_handler
      ->listInfo();

    // Determine the active theme for the theme negotiator service. This includes
    // the default theme as well as really specific ones like the ajax base theme.
    $route_match = \Drupal::routeMatch();
    $theme = \Drupal::service('theme.negotiator')
      ->determineActiveTheme($route_match);

    // If no theme could be negotiated, or if the negotiated theme is not within
    // the list of enabled themes, fall back to the default theme output of core
    // and modules (similar to Stark, but without a theme extension at all). This
    // is possible, because _drupal_theme_initialize() always loads the Twig theme
    // engine.
    if (!$theme || !isset($themes[$theme])) {
      $theme = 'core';
    }
  }
  return $theme;
}