/**
  * 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('FFLCommerce\\RoundTrip\\Optimizer')) {
         /** @noinspection PhpUndefinedNamespaceInspection */
         /** @noinspection PhpUndefinedClassInspection */
         FFLCommerce\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_fflcommerce_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);
     }
 }
예제 #2
0
function fflcommerce_remove_style($handle, array $options = array())
{
    $page = isset($options['page']) ? (array) $options['page'] : array('all');
    if (is_fflcommerce_page($page)) {
        wp_deregister_style($handle);
    }
}