You are here

function _modernizr_sanitize_callback in Modernizr 7.3

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

Helper function to sanitize yepnope() 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 556
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;
}