You are here

function fontyourface_ajax_render_alter in @font-your-face 7.2

Implements hook_ajax_render_alter(). Adds CSS for fonts loaded via AJAX.

File

./fontyourface.module, line 719

Code

function fontyourface_ajax_render_alter(&$commands) {

  // Clear out any non-font CSS so it doesn't get re-added.
  drupal_static_reset('drupal_add_css');

  // Get all the CSS that would otherwise be added in preprocess_html functions.
  $vars = array();
  fontyourface_preprocess_html($vars);
  foreach (module_implements('fontyourface_info') as $provider) {
    $function = $provider . '_preprocess_html';
    if (function_exists($function)) {
      $function($vars);
    }

    // if
  }

  // foreach
  // Add AJAX command to prepend the CSS to <head>.
  if (isset($vars['styles'])) {
    $commands[] = ajax_command_prepend('head', $vars['styles']);
  }

  // if
}