Commit Graph

65 Commits

Author SHA1 Message Date
John Blackbourn 2cb4ebefe2 Docs: Replace `$this` in hook param docs with more appropriate names.
`$this` is a pseudo-variable that cannot be used as the name of a function parameter, so renaming these helps prevent errors when implementing hook callback functions.

Fixes #53457

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


git-svn-id: http://core.svn.wordpress.org/trunk@51129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-30 19:35:58 +00:00
Sergey Biryukov b7c1e7eb62 Docs: Use correct variable in the `style_loader_tag` filter DocBlock.
Follow-up to [46088].

Props rima1889.
Fixes #52673.
Built from https://develop.svn.wordpress.org/trunk@50451


git-svn-id: http://core.svn.wordpress.org/trunk@50062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-27 17:59:03 +00:00
Sergey Biryukov bf3296a9a0 Script Loader: Add the `$group` parameter to `WP_Dependencies::do_item()`.
Previously, the method was called with two parameters in `::do_items()`, while the method signature only included one parameter.

Technically, this was not an issue as `WP_Dependencies::do_item()` is a placeholder meant to be overwritten when extending the class. When handling scripts, `WP_Dependencies` is extended with `WP_Scripts`, and the `$group` parameter was only used in `WP_Scripts::do_item()`, which does expect a second argument.

However, officially adding the parameter to `WP_Dependencies::do_item()` signature prevents code misunderstanding and avoids a warning in PHP code inspection tools.

Props kaggdesign, soulseekah, azaozz, SergeyBiryukov.
Fixes #43627.
Built from https://develop.svn.wordpress.org/trunk@47769


git-svn-id: http://core.svn.wordpress.org/trunk@47545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-06 16:27:12 +00:00
Sergey Biryukov 641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov c289bb59ac Docs: Improve documentation for `WP_Dependencies`, `WP_Scripts`, and `WP_Styles` methods.
See #48303.
Built from https://develop.svn.wordpress.org/trunk@47170


git-svn-id: http://core.svn.wordpress.org/trunk@46970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-03 00:19:03 +00:00
John Blackbourn 9ac1d82f23 Docs: Further improve documentation of known return types, plus other docs fixes.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 21:27:02 +00:00
Sergey Biryukov b35c5b9746 Script Loader: Add `function_exists()` checks for `is_admin()` and `current_theme_supports()`, to accomodate for using `WP_Dependencies` as a standalone class.
Remove `<![CDATA[` when outputting HTML5 script tags. 

Props azaozz.
Fixes #42804.
Built from https://develop.svn.wordpress.org/trunk@46287


git-svn-id: http://core.svn.wordpress.org/trunk@46099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-24 02:56:57 +00:00
Sergey Biryukov 44b49c6fc3 Script Loader: Move the `current_theme_supports()` check above the `wp_default_(scripts|styles)` action, for consistency.
See #42804.
Built from https://develop.svn.wordpress.org/trunk@46171


git-svn-id: http://core.svn.wordpress.org/trunk@45983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-18 22:42:55 +00:00
Sergey Biryukov e9b6e9619e Script Loader: Only check current theme's HTML5 support for scripts and styles on front end.
Avoids a fatal error in the admin if `SCRIPT_DEBUG` is disabled.

Props azaozz.
See #42804.
Built from https://develop.svn.wordpress.org/trunk@46170


git-svn-id: http://core.svn.wordpress.org/trunk@45982 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-18 22:34:56 +00:00
Sergey Biryukov 252628652e Script Loader: Introduce HTML5 support for scripts and styles.
When a theme declares HTML5 support for script and styles via `add_theme_support( 'html5', array( 'script', 'style' ) )`, the `type="text/javascript"` and `type="text/css"` attributes are omitted.

These attributes are unnecessary in HTML5 and cause warnings in the W3C Markup Validation Service.

Props sasiddiqui, swissspidy, knutsp, SergeyBiryukov.
See #42804.
Built from https://develop.svn.wordpress.org/trunk@46164


git-svn-id: http://core.svn.wordpress.org/trunk@45976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-18 14:50:56 +00:00
Sergey Biryukov dcb08f0637 Docs: Fix placement of some duplicate hook references.
Hook documentation should be on the line directly above the line containing the `do_action()` or `apply_filters()` call. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of duplicate hook references.

Includes minor code layout fixes.

See #47110.
Built from https://develop.svn.wordpress.org/trunk@46088


git-svn-id: http://core.svn.wordpress.org/trunk@45900 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-10 19:23:55 +00:00
Gary Pendergast 4803fc405e Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
See #47632.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
Sergey Biryukov c89962511b Script/Style Dependencies: Simplify some logic in `WP_Styles::do_item()`.
Combine repetitive assignments, make the code more consistent with `WP_Scripts::do_item()`.

See #44551.
Built from https://develop.svn.wordpress.org/trunk@43564


git-svn-id: http://core.svn.wordpress.org/trunk@43393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-11 17:42:24 +00:00
John Blackbourn 2361ca884f Docs: Document more parameters and properties using typed array notation.
See #41756

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


git-svn-id: http://core.svn.wordpress.org/trunk@42706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-25 19:33:31 +00:00
Gary Pendergast aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
John Blackbourn 9fdbe6538e Docs: Remove `&` prefixes from parameter documentation to avoid doc parsing errors.
Props sudar for the original patch.

See #35974

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


git-svn-id: http://core.svn.wordpress.org/trunk@41520 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 22:03:33 +00:00
Drew Jaynes 0860bb2771 Docs: Remove `@access` notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Drew Jaynes 1d95dcfa2c Docs: Remove superfluous `@package WordPress` and `@subpackage` notations used outside of file headers in a variety of core files.
Per the inline documentation standards for PHP, there should only be one `@package` and/or `@subpackage` notation per file, and only in the file header.

See #41017.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-01 16:58:42 +00:00
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
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 d81ebb08fb Docs: Add missing `@since` tags to `WP_Styles` properties/methods.
See #35964.
Built from https://develop.svn.wordpress.org/trunk@36733


git-svn-id: http://core.svn.wordpress.org/trunk@36700 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-26 14:39:26 +00:00
Dominik Schilling a04b869652 Styles: Pass the media attribute as an argument to the `style_loader_tag` filter.
Props sebastian.pisula.
Fixes #34765.
Built from https://develop.svn.wordpress.org/trunk@36592


git-svn-id: http://core.svn.wordpress.org/trunk@36559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-19 21:05:26 +00:00
Dominik Schilling 9d8204467c Styles: Bail if `WP_Styles::_css_href()` returns an empty value.
The style `colors` gets registered with `true` as the source value which gets handled later by `wp_style_loader_src()`, a callback for the `style_loader_src` filter in `WP_Styles::_css_href()`. `wp_style_loader_src()` may return false, for example for the default color scheme.

This was removed in [36550].

See #35229.
Built from https://develop.svn.wordpress.org/trunk@36590


git-svn-id: http://core.svn.wordpress.org/trunk@36557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-19 20:34: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 b72f822a69 Add a missing `$html` parameter variable in the hook docs for the `style_loader_tag` filter.
See #32246. See #32891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:03:24 +00:00
Boone Gorges a680859400 Pass stylesheet URL as an argument to 'style_loader_tag' filter.
This change brings the filter's signature in line with 'script_loader_tag'.

Props nicholas_io.
Fixes #32660.
Built from https://develop.svn.wordpress.org/trunk@32898


git-svn-id: http://core.svn.wordpress.org/trunk@32869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-21 19:35:26 +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 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 f7aef5b69a Ensure that inline styles attached to conditional stylesheets are also conditional.
Adds unit test.

Props georgestephanis.
Fixes #29180.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-03 04:10:21 +00:00
Scott Taylor e619abda6e Improve various `@param` docs for `src/wp-includes/*`.
See #30224.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-01 01:34:24 +00:00
Sergey Biryukov beca5ad5a3 wp_add_inline_style():
* Change the `wp-inline-style-$handle` class added in [29956] to `$handle-inline-css` for consistency with existing patterns.
* Add the ID attribute when concatenation is enabled as well.

props georgestephanis.
see #30032.
Built from https://develop.svn.wordpress.org/trunk@29958


git-svn-id: http://core.svn.wordpress.org/trunk@29705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-18 19:04:20 +00:00
Sergey Biryukov 26c8088a97 Add ID attribute to style element from wp_add_inline_style().
props westonruter.
fixes #30032.
Built from https://develop.svn.wordpress.org/trunk@29956


git-svn-id: http://core.svn.wordpress.org/trunk@29703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-18 17:58:19 +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 aa20678c48 Ensure the `style_loader_tag` filter hook is only documented once.
See #26869.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-25 06:29:14 +00:00
Drew Jaynes 86a6a217a4 Inline documentation for hooks in wp-includes/class.wp-styles.php.
Props lkwdwrd.
Fixes #27445.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-28 21:24:14 +00:00
Andrew Nacin 20948e27e8 Revert [27203], restore JIT color scheme stylesheets. Restores [27111].
fixes #27175. see #20729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-12 16:12:15 +00:00
Andrew Nacin 0c47e9b732 Simplify how admin color schemes are enqueued.
Removes a piece of [27111].

fixes #20729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 06:59:13 +00:00
Andrew Nacin 12a64b39db Fix the conditional enqueueing/printing of colors stylesheets, without breaking dependencies.
fixes #18380.
see #20729 which should properly fix this.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-06 22:16:11 +00:00
Andrew Nacin 1e30be32c4 Use CSSJanus via a Grunt task to generate right-to-left CSS.
RTL files are now created on build for core CSS files. These files replace the LTR file completely, rather than being in addition to the existing LTR file.

Benefits:
 * For the user: less CSS is served in RTL, less HTTP requests on the frontend, and less work for the browser.
 * For the core developer: Let the tools do the work.

Notes for core development:
 * The file generation task is `grunt rtl`.
 * `grunt watch` now handles generating RTL files in /build when a CSS file in /src is saved.
 * /src is now locked to LTR. RTL testing must occur via /build. When attempting to run an RTL text direction with /src, an admin notice will display.

Expect RTL bugs. Please report them.

props yoavf.
see #24977.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26022 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-12 21:19:15 +00:00
Andrew Nacin f9be8e4f0c Revert [25202] and enforce that wp_add_inline_style() does not want <style> tags.
Prior to 3.7, these tags were not printed (and thus needed to be provided), but only in the admin and when concatenation was enabled. They should never be required. Strip them when we find them and issue a notice for incorrect usage.

props atimmer, georgestephanis.
fixes #24813.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-15 14:35:09 +00:00
Sergey Biryukov 259ee74782 Prevent WP_Styles::do_item() from adding its own style tags when concatenation is disabled. props stephenharris. fixes #24813.
Built from https://develop.svn.wordpress.org/trunk@25202


git-svn-id: http://core.svn.wordpress.org/trunk@25174 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-01 13:15:09 +00:00
Andrew Nacin 0fa23c1ac2 WP Styles: Correctly print 'after' data when scripts are concatenated. props stephenh1988. fixes #20836.
git-svn-id: http://core.svn.wordpress.org/trunk@24047 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-22 19:22:09 +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
ryan e3b46b25d3 Lose EOF ?>. Clean up EOF newlines. fixes #12307
git-svn-id: http://svn.automattic.com/wordpress/trunk@19712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-08 17:01:11 +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 496752e14e Proper RTL + .dev.css support, first pass. See #12292
git-svn-id: http://svn.automattic.com/wordpress/trunk@13351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-23 23:46:07 +00:00
azaozz 481737b4ae Fix the 'colors' meta-css src (boolean) value generating parse_url errors, fixes #11820
git-svn-id: http://svn.automattic.com/wordpress/trunk@13193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-02-18 10:30:28 +00:00