unprefix / unprefix-scripts
此软件包已被 废弃 且不再维护。没有建议的替代软件包。
一个小型库,用于在WordPress中注册和排队脚本。
3.0.0
2017-07-31 22:24 UTC
Requires
- php: >=5.6.0
Requires (Dev)
- brain/monkey: ^1.4
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2020-02-27 17:57:23 UTC
README
Unprefix Scripts
一个小型库,用于在WordPress中注册和排队脚本。
还可以注销脚本和样式,并本地化变量,以便从每个js文件中访问它们。
示例
$lists = [ 'scripts => [ // Modernizr. 'modernizr' => [ 'modernizr', Plugin::getPluginDirUrl('/assets/js/vendor/modernizr.min.js'), array(), '3.3.1', true, function () { return true; }, function () { return true; }, ], ], 'styles' => [ // Select2. 'select2' => [ 'select2', Plugin::getPluginDirUrl('/assets/css/vendor/select2.min.css'), array(), '', 'screen', function () { return true; }, function () { return true; }, ], ], ]; $unRegisterScriptsList = [ 'styles' => [ [ 'handle' => 'script-handle', 'condition' => function() { // ... condition } ], ], 'scripts => [ [ 'handle' => 'script-handle', 'condition' => function() { // ... condition } ], ] ]; $localizedList = [ 'localized' => [ [ 'handle' => is_admin() ? 'admin' : 'front', 'name' => 'handlename', [ 'lang' => get_bloginfo('language'), 'date_format' => get_option('date_format'), 'time_format' => get_option('time_format'), ], ], ] ]; // Create the Instances. $scripts = new ScriptsFacade($lists); $unRegister = new UnRegister($unRegisterScriptsList); $localizedScripts = new LocalizeScripts($localizedList); // Register the scripts. add_action('enqueue_scripts', [$unRegister, 'unRegister'], 10); add_action('enqueue_scripts', [$scripts, 'register'], 20); add_action('enqueue_scripts', [$scripts, 'enqueuer'], 30); add_action('enqueue_scripts', [$localizedScripts, 'localizeScripts'], 40);