You are here

function context_reaction_theme_custom_theme in Context Reaction: Theme 7

Implements hook_custom_theme().

Test a few of the context conditions and execute the plugin if it is matched.

Return value

string | null String of the theme to

See also

hook_custom_theme()

File

./context_reaction_theme.module, line 20
This module enables a context reaction to alter the active theme.

Code

function context_reaction_theme_custom_theme() {

  // Initiate core conditions here to trigger all contexts with an active_theme
  // reaction and core conditions only.
  if ($plugin = context_get_plugin('condition', 'path')) {
    $plugin
      ->execute();
  }
  if ($plugin = context_get_plugin('condition', 'language')) {
    global $language;
    $plugin
      ->execute($language->language);
  }
  if ($plugin = context_get_plugin('condition', 'user')) {
    global $user;
    $plugin
      ->execute($user);
  }

  // @todo: write a module_implements hook to allow custom conditions here?
  // Check for the active theme reaction.
  if ($plugin = context_get_plugin('reaction', 'active_theme')) {
    if ($custom_theme = $plugin
      ->execute()) {

      // return the theme name!
      return $custom_theme;
    }
  }
}