Commit Graph

35 Commits

Author SHA1 Message Date
Weston Ruter
a20cb28d14 Script Loader: Harden removal of script tag wrappers.
* Add `wp_remove_surrounding_empty_script_tags()` to more precisely remove script tag wrappers and warn when doing it wrong.
* Add clarifying comments for XML escaping logic in `wp_get_inline_script_tag()`.
* Leverage `WP_HTML_Tag_Processor` in `test_remove_frameless_preview_messenger_channel`.
* Reuse `assertEqualMarkup` in `test_blocking_dependent_with_delayed_dependency`.
* Normalize whitespace in `parse_markup_fragment` for `assertEqualMarkup`.

Follow-up to [56687].
Props dmsnell, westonruter, flixos90.
See #58664.

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


git-svn-id: http://core.svn.wordpress.org/trunk@56260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-29 19:47:21 +00:00
Weston Ruter
e7747ce23e Script Loader: Use wp_get_script_tag() and wp_get_inline_script_tag()/wp_print_inline_script_tag() helper functions to output scripts on the frontend and login screen.
Using script tag helper functions allows plugins to employ the `wp_script_attributes` and `wp_inline_script_attributes` filters to inject the `nonce` attribute to apply Content Security Policy (e.g. Strict CSP). Use of helper functions also simplifies logic in `WP_Scripts`.

* Update `wp_get_inline_script_tag()` to wrap inline script in CDATA blocks for XHTML-compatibility when not using HTML5.
* Ensure the `type` attribute is printed first in `wp_get_inline_script_tag()` for back-compat.
* Wrap existing `<script>` tags in output buffering to retain IDE supports.
* In `wp_get_inline_script_tag()`, append the newline to `$javascript` before it is passed into the `wp_inline_script_attributes` filter so that the CSP hash can be computed properly.
* In `the_block_template_skip_link()`, opt to enqueue the inline script rather than print it.
* Add `ext-php` to `composer.json` under `suggest` as previously it was an undeclared dependency for running PHPUnit tests.
* Update tests to rely on `DOMDocument` to compare script markup, normalizing unsemantic differences.

Props westonruter, spacedmonkey, flixos90, 10upsimon, dmsnell, mukesh27, joemcgill, swissspidy, azaozz.
Fixes #58664.
See #39941.

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


git-svn-id: http://core.svn.wordpress.org/trunk@56199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 21:05:21 +00:00
audrasjb
16bc8d38a6 Coding Standards: Use a consistent markup for line break tags across Core.
This changeset replaces `<br/>` with `<br />` on various places, as per WordPress Coding Standards.
See https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/#self-closing-elements

Props haritpanchal, costdev, audrasjb.
Fixes #56457.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-02 06:51:13 +00:00
joedolson
a3a61c5a3e General: Remove role="navigation" from nav elements.
Role="navigation" was required for assistive technology to recognize HTML5 element's native ARIA roles while HTML5 and ARIA were being introduced. With the deprecation of IE11, the role attribute is only required when mapping elements that don't have native role.

Props costdev, mukesh27.
Fixes #54054.
Built from https://develop.svn.wordpress.org/trunk@51967


git-svn-id: http://core.svn.wordpress.org/trunk@51556 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-01 21:47:13 +00:00
whyisjake
2e36162a20 Widgets: Don't decode HTML entities ahead of the widget constructor.
This reverts the changes from [51114]. 

See #53138.

Unprops whyisjake. 

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


git-svn-id: http://core.svn.wordpress.org/trunk@50736 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-08 23:40:00 +00:00
whyisjake
81c4c4138c Widgets: Ensure that HTML entities are converted in widget descriptions.
Fixes #53138.

Props justinahinon, audrasjb.

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


git-svn-id: http://core.svn.wordpress.org/trunk@50723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-08 22:17:57 +00:00
noisysocks
1314542c50 REST API: Add widget endpoints
Adds the sidebars, widgets and widget-types REST API endpoints from the
Gutenberg plugin.

Fixes #41683.
Props TimothyBlynJacobs, spacedmonkey, zieladam, jorgefilipecosta, youknowriad, kevin940726.

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


git-svn-id: http://core.svn.wordpress.org/trunk@50604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 08:27:57 +00:00
noisysocks
ed195fbd89 REST API: Revert widget endpoints
Reverts [50993] as it has missing props.

Reverts [50993].
See #41683.

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


git-svn-id: http://core.svn.wordpress.org/trunk@50603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 08:22:56 +00:00
noisysocks
2a4e1e0c04 REST API: Add widget endpoints
Adds the sidebars, widgets and widget-types REST API endpoints from the
Gutenberg plugin.

Fixes #41683.
Props TimothyBlynJacobs.

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


git-svn-id: http://core.svn.wordpress.org/trunk@50602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 07:52:55 +00:00
Sergey Biryukov
07b4429203 Widgets: Use correct escaping function in WP_Widget_Archives::widget().
Props chintan1896, afercia.
See #50826.
Built from https://develop.svn.wordpress.org/trunk@48699


git-svn-id: http://core.svn.wordpress.org/trunk@48461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-31 13:15:05 +00:00
Sergey Biryukov
c4a2b9a9e4 Widgets: Adjust formatting for displaying the closing </nav> tag in widgets for consistency with the opening tag.
Follow-up to [48349].

See #48170.
Built from https://develop.svn.wordpress.org/trunk@48410


git-svn-id: http://core.svn.wordpress.org/trunk@48179 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-08 13:44:04 +00:00
Sergey Biryukov
6fc76c162d Widgets: Correct the logic for displaying the after_widget parameter of the Archives widget.
Follow-up to [48349].

Props mukesh27, joyously.
Fixes #50609.
Built from https://develop.svn.wordpress.org/trunk@48409


git-svn-id: http://core.svn.wordpress.org/trunk@48178 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-08 13:28:03 +00:00
Andrea Fercia
a5721358e1 Docs: Reference the documentation of the new navigation_widgets_format filter instead of repeating it.
Follow-up to [48349].

Props johnbillion.
Fixes #48170.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48157 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 17:06:04 +00:00
Andrea Fercia
04921ffd45 Accessibility: Widgets: Add theme support to make widgets output list of links wrapped within a <nav> element.
Widgets that output list of links can now be wrapped within `<nav>` elements to improve semantics and accessibility.

The `<nav>` elements are also native landmark regions, which helps assistive technology users to navigate through them. Themes can opt-in to this new behavior by declaring support for the new `html5` feature `navigation-widgets`.

Props joedolson, simonjanin, audrasjb, afercia.
Fixes #48170.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-06 20:44:02 +00:00
Sergey Biryukov
fc7561ce11 Coding Standards: Format the markup of widget forms in a more consistent manner.
See #49542.
Built from https://develop.svn.wordpress.org/trunk@47593


git-svn-id: http://core.svn.wordpress.org/trunk@47368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-17 09:38:07 +00:00
Sergey Biryukov
6b2c63031c Coding Standards: Rename $d parameter in various date/time functions to $format for clarity.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47287


git-svn-id: http://core.svn.wordpress.org/trunk@47087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-14 00:07:07 +00:00
John Blackbourn
f243cd573c Docs: Correct invalid hook docblock placement.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-27 19:35:01 +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
bba488f2b7 Widgets: Pre-select currently viewed archive in the Archives dropdown widget, for consistency with the Categories widget.
Props robobot3000, audrasjb, afercia, Themonic.
Fixes #40662.
Built from https://develop.svn.wordpress.org/trunk@44897


git-svn-id: http://core.svn.wordpress.org/trunk@44728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-14 19:31:49 +00:00
Gary Pendergast
2f288c306c Widgets: Remove unnecessary sanitize_text_field() calls in core widget ::form() methods.
This sanitisation only needs to be run in `::update()` to correctly clean up the input.

Props welcher, greenshady.
Fixes #42461.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-15 00:43:49 +00:00
Gary Pendergast
7a617078fa Coding Standards: Upgrade WPCS to 1.2.1.
This upgrade fixes quite a few false positives, as well as auto-fixing some indenting issues.

Fixes #45956.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-12 06:41:52 +00:00
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


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


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +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
Sergey Biryukov
46ff957961 Widgets: Move empty title checks out of the apply_filters( 'widget_title' ) calls for clarity.
See #42226.
Built from https://develop.svn.wordpress.org/trunk@41867


git-svn-id: http://core.svn.wordpress.org/trunk@41701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-15 21:43:47 +00:00
Sergey Biryukov
253541556e Widgets: Pass $instance to widget argument filters:
* `widget_archives_dropdown_args`
* `widget_archives_args`
* `widget_categories_dropdown_args`
* `widget_categories_args`
* `widget_meta_poweredby`
* `widget_pages_args`
* `widget_comments_args`
* `widget_posts_args`
* `widget_tag_cloud_args`

See [33971] for `widget_links_args` and [34662] for `widget_nav_menu_args`.

Props Takahashi_Fumiki.
Fixes #38017.
Built from https://develop.svn.wordpress.org/trunk@41685


git-svn-id: http://core.svn.wordpress.org/trunk@41519 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 22:02:47 +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
Weston Ruter
123158e7d8 Widgets: Revert [40251] pending more accessible solution for showing default widget titles rather than using placeholders.
See #39909.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-19 20:45:40 +00:00
Weston Ruter
d7cb2f7706 Customize: Show title input placeholders for widgets that have default titles when rendered.
Fixes #39909.
Props bor0, dlh, westonruter.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40173 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-08 18:25:44 +00:00
Drew Jaynes
6b8248f3f7 Docs: Standardize hook docs in wp-includes/widgets/* to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:06:28 +00:00
Weston Ruter
f3f84d2f21 Customize: Require opt-in for selective refresh of widgets.
* Introduces `customize-selective-refresh-widgets` theme support feature and adds to themes.
* Introduces `customize_selective_refresh` arg for `WP_Widget::$widget_options` and adds to all core widgets.
* Remove `selective_refresh` from being a component that can be removed via `customize_loaded_components` filter.
* Add `WP_Customize_Widgets::get_selective_refreshable_widgets()` and `WP_Customize_Widgets::is_widget_selective_refreshable()`.
* Fix default `selector` for `Partial` instances.
* Implement and improve Masronry sidebar refresh logic in Twenty Thirteen and Twenty Fourteen, including preservation of initial widget position after refresh.
* Re-initialize ME.js when refreshing `Twenty_Fourteen_Ephemera_Widget`.

See #27355.
Fixes #35855.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-21 21:59:29 +00:00
Drew Jaynes
c1796c55c3 Docs: Improve documentation for the __construct(), widget(), update(), and form() methods in WP_Widget_Archives.
Props leemon.
Fixes #34016. See #34013.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-27 01:11:25 +00:00
Drew Jaynes
02084878f0 Docs: Add a missing file header to wp-includes/widgets/class-wp-widget-archives.php, introduced in [33746].
Also clarifies the class DocBlock summary and tags for `WP_Widget_Archives`.

See #33413. See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 14:43:24 +00:00
Scott Taylor
c1bb5b5ce3 After [33843], update the location of some files in This filter is documented in docs
Props dimadin.
See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-08 22:17:26 +00:00
Scott Taylor
0c97b3625e After [33814], checked() outputs a leading space, so some extra spaces can be removed in the HTML for default widget forms.
See #23012.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-08 19:23:24 +00:00
Scott Taylor
9b8169bd30 Move widget classes to their own files in wp-includes/widgets:
* `default-widgets.php` now requires all of the individual classes
* Move the functions scattered about this file to `widget-functions.php`, which loads before `default-widgets.php`, which only conditionally loads anyway in `wp_maybe_load_widgets()`, which is hooked on `plugins_loaded` 

See #33413, #23012.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-01 13:49:21 +00:00