You are here

function breakpoints_flush_caches in Breakpoints 7

Implements hook_flush_caches().

File

./breakpoints.module, line 947
Breakpoints @todo: provide button to reload breakpoints from theme

Code

function breakpoints_flush_caches() {
  if (variable_get('breakpoints_flush_caches_disabled', FALSE)) {
    return;
  }

  // hook_flush_caches gets invoked with both drupal_flush_all_caches and system_cron
  // To avoid frequent menu/theme flushes, we must backtrace caller.
  $backtrace = debug_backtrace();
  if (isset($backtrace[3]) && $backtrace[3]['function'] == 'drupal_flush_all_caches' && empty($backtrace[3]['args'])) {
    $themes = list_themes();
    foreach ($themes as $theme_key => $theme) {
      if ($theme->status) {
        $group = breakpoints_breakpoint_group_load($theme_key);
        if ($group) {
          breakpoints_breakpoints_group_reload($group, FALSE);
        }
        else {
          breakpoints_themes_enabled(array(
            $theme_key,
          ), FALSE);
        }
      }
    }
  }
}