You are here

function _modernizr_sanitize_callback in Modernizr 8

Same name and namespace in other branches
  1. 7.3 modernizr.module \_modernizr_sanitize_callback()

Helper function to sanitize Modernizr.load() callbacks

1 call to _modernizr_sanitize_callback()
modernizr_load_data in ./modernizr.module
A function to generate the load data from the current themes.

File

./modernizr.module, line 419
Main module file for Modernizr

Code

function _modernizr_sanitize_callback($callback) {
  global $base_url;
  $output = '';
  $function_regex = '/^function(\\s)*\\(\\)(\\s)*\\{(.*)\\}$/';

  // Save the people who don't wrap their code in anonymous functions.
  // Yes, an extra semi-colon has been added for safety :)
  $output = preg_match($function_regex, $callback) ? $callback : 'function(){' . $callback . ';}';
  return $output;
}