https://github.com/xwp/wp-qunit-print-script-dependencies
QUnit Print Script Dependencies WP-CLI Command
https://github.com/xwp/wp-qunit-print-script-dependencies
Last synced: 3 months ago
JSON representation
QUnit Print Script Dependencies WP-CLI Command
- Host: GitHub
- URL: https://github.com/xwp/wp-qunit-print-script-dependencies
- Owner: xwp
- Created: 2016-05-19T20:41:31.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-08T17:13:16.000Z (over 9 years ago)
- Last Synced: 2025-01-15T12:16:36.262Z (12 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# QUnit Print Script Dependencies WP-CLI Command
Print dependencies for scripts to be tested and then add into a QUnit HTML test runner file ([see where in the main WP Core QUnit test suite](https://github.com/xwp/wordpress-develop/blob/63755028e8340445ed6062eeba4fa82e3087e433/tests/qunit/index.html#L6-L13), for example).
Uses `wp_print_scripts()` and will include any attached script data or before/after inline scripts. This eliminates a lot of tedious effort
to code up these script tags by hand.
## Examples
Print dependencies for `wp-a11y`:
```
$ wp qunit-print-script-dependencies wp-a11y
```
Print dependencies for `wp-util`:
```
$ wp qunit-print-script-dependencies wp-util
/* <![CDATA[ */
var _wpUtilSettings = {"ajax":{"url":"\/wp-admin\/admin-ajax.php"}};
/* ]]> */
```
Print dependencies for `wp-util` and `media-models` with overridden base URL.
In this case, it is expected that the script tags would be added to a plugin QUnit test runner
located somewhere like `wp-content/plugins/foo/tests/qunit`:
```
$ wp qunit-print-script-dependencies media-models wplink --base_href=../../../../../
/* <![CDATA[ */
var _wpUtilSettings = {"ajax":{"url":"\/wp-admin\/admin-ajax.php"}};
/* ]]> */
/* <![CDATA[ */
var _wpMediaModelsL10n = {"settings":{"ajaxurl":"\/wp-admin\/admin-ajax.php","post":{"id":0}}};
/* ]]> */
/* <![CDATA[ */
var wpLinkL10n = {"title":"Insert\/edit link","update":"Update","save":"Add Link","noTitle":"(no title)","noMatchesFound":"No results found.","linkSelected":"Link selected.","linkInserted":"Link inserted."};
/* ]]> */
```
## Credits
By [XWP](https://make.xwp.co). Licensed GPLv2.