Commit Graph

65 Commits

Author SHA1 Message Date
Drew Jaynes
9cb5247392 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

Built from https://develop.svn.wordpress.org/trunk@37518


git-svn-id: http://core.svn.wordpress.org/trunk@37486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:50:28 +00:00
Jeremy Felt
4d9c9b9433 Ensure consistent dependency order when using wp_add_inline_script()
This disables the concatenation of remaining enqueued scripts once `wp_add_inline_script()` is invoked, which allows us to reliably print these scripts and their before/after inline scripts in the desired order.

Props gitlost, azaozz, swisspidy, ocean90.
Fixes #36392.

Built from https://develop.svn.wordpress.org/trunk@37171


git-svn-id: http://core.svn.wordpress.org/trunk@37138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-10 03:33:26 +00:00
Aaron Jorbin
1972aa2a2a Add grunt prerelease task
An unintended consequence of improving the precommit task is that when it's time to run a release, more tasks need to get run to verify things. This adds a prerelease task to help fix that situation. grunt prerelease should include tasks that verify the code base is ready to be released to the wild and find all the tears on the mausoleum floor and help Blood stain the Colosseum doors.

See #35557

Built from https://develop.svn.wordpress.org/trunk@36930


git-svn-id: http://core.svn.wordpress.org/trunk@36898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-10 05:37:27 +00:00
Dominik Schilling
f4ef187c2c Dependencies: Improve group processing of script dependencies.
This is a follow-up to [36604].

When processing dependencies `$this->group` will be the minimum of the script's registered group and all preceding siblings. This is wrong because only a scripts ancestors in the dependency chain should affect where it is loaded. Effectively `$this->group` introduced a form of global state which potentially corrupted the group of dependencies. Sorting covers up this problem.
The issue in #35873 was that script were not moving their dependencies to a lower group when necessary.

The fix:
* In `WP_Dependencies::all_deps()` pass the new `$group` value to `WP_Dependencies::all_deps()`. Previously the wrong value was passed because the parent script could have moved with `WP_Scripts::set_group()`.
* In `WP_Scripts::all_deps()` pass the `$group` parameter to `WP_Dependencies::all_deps()` so it doesn't always use `false` for `$group`. Same for `WP_Styles::all_deps()`.

Props stephenharris, gitlost.
Fixes #35956.
Built from https://develop.svn.wordpress.org/trunk@36871


git-svn-id: http://core.svn.wordpress.org/trunk@36838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-06 19:50:27 +00:00
Dominik Schilling
820c9e2fca Docs: Improve inline docs for WP_Dependencies, WP_Styles, and WP_Scripts.
Also, make them and related files part of WordPress.

See #35964.
Built from https://develop.svn.wordpress.org/trunk@36744


git-svn-id: http://core.svn.wordpress.org/trunk@36711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-27 20:34:29 +00:00
Dominik Schilling
167aae554f Docs: Document properties of WP_Scripts and add missing @since tags.
See #35964.
Built from https://develop.svn.wordpress.org/trunk@36730


git-svn-id: http://core.svn.wordpress.org/trunk@36697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-26 13:05:26 +00:00
Drew Jaynes
8cd541daed Docs: Standardize DocBlocks for two new WP_Scripts methods, add_inline_script() and print_inline_script(), introduced in [36633].
See #14853. See #32246.

Built from https://develop.svn.wordpress.org/trunk@36706


git-svn-id: http://core.svn.wordpress.org/trunk@36673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-25 05:11:26 +00:00
Pascal Birchler
b47a3831ee Script Loader: Introduce wp_add_inline_script().
This new function can be used to add inline JavaScript before and after enqueued scripts, just like `wp_add_inline_style()` works for CSS.

Props atimmer, abiralneupane, ocean90, swissspidy.
Fixes #14853.
Built from https://develop.svn.wordpress.org/trunk@36633


git-svn-id: http://core.svn.wordpress.org/trunk@36600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 16:44:26 +00:00
Dominik Schilling
bc5d22266d Script/Style Dependencies: Make sure that inline styles for handles without a source are printed.
This prevents breaking plugins which are adding inline styles to the `wp-admin` handle after [36341].

Props dd32, ocean90.
Fixes #35229.
Built from https://develop.svn.wordpress.org/trunk@36550


git-svn-id: http://core.svn.wordpress.org/trunk@36517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-17 17:11:26 +00:00
Drew Jaynes
36367e7f6e Docs: Add missing DocBlocks, including summaries and @since versions, to the __construct() and init() methods in WP_Scripts.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@35965


git-svn-id: http://core.svn.wordpress.org/trunk@35930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-16 17:48:27 +00:00
Scott Taylor
a3e36194fd Scripts: in WP_Scripts::set_group(), the args prop of the _WP_Dependency instance defaults to null - check that it is set before comparing.
Props tivnet, chriscct7.
Fixes #25462.

Built from https://develop.svn.wordpress.org/trunk@34862


git-svn-id: http://core.svn.wordpress.org/trunk@34827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 13:54:25 +00:00
Scott Taylor
c502a281bb After [32656], add @access annotations to methods that have no doc block in wp-includes/*.
Makes it easier to search for no doc blocks via `}[\n\t\r ]+(protected|private|public)`.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32657


git-svn-id: http://core.svn.wordpress.org/trunk@32627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-29 21:37:24 +00:00
Scott Taylor
bd8fafea54 Use void instead of null where appropriate when pipe-delimiting @return types. If a @return only contains void, remove it.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32568


git-svn-id: http://core.svn.wordpress.org/trunk@32538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-24 05:40:25 +00:00
Scott Taylor
451914addb Add missing doc blocks to class.wp-(scripts|styles).php.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32566


git-svn-id: http://core.svn.wordpress.org/trunk@32536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-24 05:05:26 +00:00
Scott Taylor
4ca760354f Revert [31030] and [31033]. Incidentally, there is no lazy-loading happening here anyway.
Pushing #26111 to future.

Built from https://develop.svn.wordpress.org/trunk@32124


git-svn-id: http://core.svn.wordpress.org/trunk@32103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-14 15:13:28 +00:00
Andrew Ozz
9d3ea188d7 Add support for IE conditional comments for WP_Scripts to match the functionality of WP_Styles, including unit tests. Props filosofo, aaroncampbell, ethitter, georgestephanis, valendesigns. Fixes #16024.
Built from https://develop.svn.wordpress.org/trunk@31223


git-svn-id: http://core.svn.wordpress.org/trunk@31204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-17 01:37:22 +00:00
Scott Taylor
cf6adef68f Revert [31032], this did not get much love.
See #25277.

Built from https://develop.svn.wordpress.org/trunk@31189


git-svn-id: http://core.svn.wordpress.org/trunk@31170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 01:11:23 +00:00
Scott Taylor
b39c37ff89 After [31030]: if a callable is passed as the 3rd arg to wp_localize_script()/WP_Scripts->localize(), pass $handle and $object_name to the user func when invoking it.
Props jtsternberg.
Fixes #26111.

Built from https://develop.svn.wordpress.org/trunk@31033


git-svn-id: http://core.svn.wordpress.org/trunk@31014 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-03 05:13:24 +00:00
Scott Taylor
650a6d1062 Add the ability to print data *after* a script, whether it is concatenated or not:
* Add a third argument to `WP_Scripts->print_extra_script()`, `$key`, which will be passed to `->get_data()` (no longer passes hardcoded `'data'`)
* When `$key` is set to `'data-after'`, the inline script will be printed after the `<script>` tag. If the scripts are being concatenated, all scripts' `'data-after'` data will be printed after the concatenated `<script>` has been rendered.

Props hakre, wonderboymusic.
Fixes #25277.

Built from https://develop.svn.wordpress.org/trunk@31032


git-svn-id: http://core.svn.wordpress.org/trunk@31013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-03 05:08:24 +00:00
Scott Taylor
e649887e40 Allow the 3rd argument to wp_localize_script()/WP_Scripts->localize() to be a callable, allowing data to be lazy-loaded when the script is actually enqueued.
Props jtsternberg.
Fixes #26111.

Built from https://develop.svn.wordpress.org/trunk@31030


git-svn-id: http://core.svn.wordpress.org/trunk@31011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-03 03:54:22 +00:00
Drew Jaynes
23707b1ada Convert various uses of (optional) in core parameter descriptions to use the style prescribed in the inline documentation standards for PHP.
The style for marking parameters optional in inline PHP docs is: `@param type $var Optional. Description. Accepts. Default.`, where Accepts can be omitted on a case-by-case basis.

Props coffee2code.
Fixes #30591.

Built from https://develop.svn.wordpress.org/trunk@30753


git-svn-id: http://core.svn.wordpress.org/trunk@30743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-06 21:24:45 +00:00
John Blackbourn
d0b10b5022 Apply a filter to the <script> tag for enqueued scripts in the same way a filter is applied to the <link> tag for enqueued styles.
Fixes #13592
Props quietnic, MikeHansenMe

Built from https://develop.svn.wordpress.org/trunk@30403


git-svn-id: http://core.svn.wordpress.org/trunk@30398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-20 05:18:25 +00:00
Gary Pendergast
007ec52958 Add wp_json_encode(), a wrapper for json_encode() that ensures everything is converted to UTF-8.
Change all core calls from `json_encode()` to `wp_json_encode()`.

Fixes #28786.


Built from https://develop.svn.wordpress.org/trunk@30055


git-svn-id: http://core.svn.wordpress.org/trunk@30055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-28 18:35:19 +00:00
Scott Taylor
53968da5e2 WP_Scripts->in_default_dir() should use the WPINC constant
Props wojtek.szkutnik
See #14157.

Built from https://develop.svn.wordpress.org/trunk@28907


git-svn-id: http://core.svn.wordpress.org/trunk@28706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-29 22:23:15 +00:00
Scott Taylor
5030fdef62 Add missing access modifiers to methods in WP_Scripts and WP_Styles.
See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28518


git-svn-id: http://core.svn.wordpress.org/trunk@28344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:17:14 +00:00
Drew Jaynes
e58c1d08e7 Inline documentation for hooks in wp-includes/class.wp-scripts.php.
Props kpdesign for a wording switcheroo.
Fixes #27518.

Built from https://develop.svn.wordpress.org/trunk@27731


git-svn-id: http://core.svn.wordpress.org/trunk@27568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-26 05:48:14 +00:00
Andrew Nacin
6655f30fd9 If the script_loader_src filter returns nothing, bail instead of printing <script src="">.
props niallkennedy.
fixes #22470.

Built from https://develop.svn.wordpress.org/trunk@25465


git-svn-id: http://core.svn.wordpress.org/trunk@25386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-16 22:12:09 +00:00
Andrew Nacin
bf759fe207 If someone tries to localize 'jquery', which is now an alias with jquery-core and jquery-migrate dependencies, add the data to jquery-core.
fixes #24197.



git-svn-id: http://core.svn.wordpress.org/trunk@24635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-10 05:38:17 +00:00
nacin
5c228ae869 Allow protocol-relative URLs when registering/enqueueing scripts and styles.
props mimecine, TobiasBg, georgestephanis.
props kurtpayne for the test coverage.
fixes #16560.



git-svn-id: http://core.svn.wordpress.org/trunk@21166 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-06-28 20:18:38 +00:00
nacin
bc2655affc If a plugin triggers the WP_Scripts constructor prior to init, fire wp_default_scripts()
then and again on init.

Only add our localized strings once we've fired init, in case we do have the situation
where we fire wp_default_scripts() twice.

Fixes issues where plugins or themes try to enqueue a default script handle prior to
init. Does not allow #19959 to regress.

see #20971 for trunk.



git-svn-id: http://core.svn.wordpress.org/trunk@21132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-06-26 05:33:19 +00:00
ryan
d910c26182 Pinking shears 6-20000
git-svn-id: http://svn.automattic.com/wordpress/trunk@20000 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-27 19:46:52 +00:00
nacin
a0b0149065 Coverage for load-scripts.php. fixes #19959.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-08 16:15:24 +00:00
nacin
e82da3b730 Wait until init to fire wp_default_scripts. Fixes localization issues when a plugin calls wp_enqueue_script() too early (in spite of the _doing_it_wrong warning signs added in #11526). fixes #19959.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-08 15:29:24 +00:00
azaozz
909e20ed27 Move an unsightly semicolon to where it belongs in wp_localize_script(), props tw2113, fixes #19830
git-svn-id: http://svn.automattic.com/wordpress/trunk@19832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-06 18:52:57 +00:00
ryan
07ff8b216b Use one space, not two, after trailing punctuation. fixes #19537
git-svn-id: http://svn.automattic.com/wordpress/trunk@19593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-12-13 23:45:31 +00:00
nacin
60dc347247 Remove wp_add_script_before() from 3.3. Continue to use wp_localize_script() for your data-passing needs. fixes #11520.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19573 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-12-08 20:46:58 +00:00
azaozz
10859e2b8f Ressurect WP_Scripts::localize() and fix public function names, fixes #11520
git-svn-id: http://svn.automattic.com/wordpress/trunk@19217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-11-08 18:05:59 +00:00
azaozz
b26dcf5ce6 Recursively convert html entities in script localization strings, see #11520
git-svn-id: http://svn.automattic.com/wordpress/trunk@18813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-29 06:43:46 +00:00
nacin
fc7fb8b03e Revert [18804] until we have a proper solution. see #11520.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-29 05:50:44 +00:00
azaozz
e30854e968 Convert html entities in script localization strings, see #11520
git-svn-id: http://svn.automattic.com/wordpress/trunk@18804 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-29 00:34:24 +00:00
azaozz
f634dd5af4 Editor API enhancement, first run (still needs some work), see #17144
git-svn-id: http://svn.automattic.com/wordpress/trunk@18498 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-08-03 10:19:00 +00:00
azaozz
852882df30 Optimize script-loader a bit, see #11520
git-svn-id: http://svn.automattic.com/wordpress/trunk@18496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-08-03 01:54:29 +00:00
azaozz
23b9d7759a Introduce WP_Dependencies::get_data() method, change scripts and styles priority to follow the "natural" order in HTML, i.e. the last one wins, props scribu, see #11520
git-svn-id: http://svn.automattic.com/wordpress/trunk@18480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-07-28 18:24:00 +00:00
azaozz
21058cf460 Use json_encode() for adding script data (formerly l10n). Add the same functionality to WP_Styles for adding inline css after a stylesheet has been outputted. See #11520
git-svn-id: http://svn.automattic.com/wordpress/trunk@18464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-07-25 00:36:06 +00:00
azaozz
23f490bb02 Support for using wp_enqueue_script() and wp_enqueue_style() in the HTML body. All scripts and styles are added in the footer, fixes #9346
git-svn-id: http://svn.automattic.com/wordpress/trunk@18446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-07-21 16:32:01 +00:00
nacin
b8ce0261df More param fixes, props duck_. see #14783.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16469 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-11-18 19:12:48 +00:00
ryan
847499e531 Pinking shears
git-svn-id: http://svn.automattic.com/wordpress/trunk@16438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-11-17 18:47:34 +00:00
westi
583ac68a44 Move the l10n helper function into a seperate js file so we can always output it first.
Fixes #15124.

git-svn-id: http://svn.automattic.com/wordpress/trunk@16282 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-11-10 21:53:30 +00:00
azaozz
77706e5c74 Too many question marks, see #11315
git-svn-id: http://svn.automattic.com/wordpress/trunk@12559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-12-28 00:56:41 +00:00
azaozz
7b40c7a03f WP_Dependencies: pass NULL to disable script and style version query strings, props scribu amattie, fixes #11315
git-svn-id: http://svn.automattic.com/wordpress/trunk@12558 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-12-28 00:48:20 +00:00