/**
  * Registers script.
  * Available options:
  *   * version - Wordpress script version number
  *   * in_footer - is this script required to add to the footer?
  *
  * Proper locations: 'admin', 'frontend'
  *
  * @param string $location Location to load script on.
  * @param string $handle Handle name.
  * @param bool $src Source file.
  * @param array $dependencies List of dependencies to the script.
  * @param array $options List of options.
  */
 function jrto_register_script($location, $handle, $src, array $dependencies = array(), array $options = array())
 {
     if (class_exists('Jigoshop\\RoundTrip\\Optimizer')) {
         /** @noinspection PhpUndefinedNamespaceInspection */
         /** @noinspection PhpUndefinedClassInspection */
         Jigoshop\RoundTrip\Optimizer\Helper\Script::register($location, $handle, $src, $dependencies, $options);
     } else {
         $action = $location == 'admin' ? 'admin' : 'wp';
         add_action($action . '_enqueue_scripts', function () use($handle, $src, $dependencies, $options) {
             $page = isset($options['page']) ? (array) $options['page'] : array('all');
             if (is_jigoshop_page($page)) {
                 $version = isset($options['version']) ? $options['version'] : false;
                 $footer = isset($options['in_footer']) ? $options['in_footer'] : false;
                 wp_register_script($handle, $src, $dependencies, $version, $footer);
             }
         }, 10);
     }
 }
Exemple #2
0
function jigoshop_remove_style($handle, array $options = array())
{
    $page = isset($options['page']) ? (array) $options['page'] : array('all');
    if (is_jigoshop_page($page)) {
        wp_deregister_style($handle);
    }
}