`str_starts_with()` and `str_ends_with()` were introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins or ends with the given substring (needle).
WordPress core includes a polyfill for these functions on PHP < 8.0 as of WordPress 5.9.
This commit uses `str_starts_with()` and `str_ends_with()` in core files where appropriate:
* `$needle === substr( $string, 0, $length )`, where `$length` is the length of `$needle`, is replaced with `str_starts_with( $haystack, $needle )`.
* `$needle === substr( $string, $offset )`, where `$offset` is negative and the absolute value of `$offset` is the length of `$needle`, is replaced with `str_ends_with( $haystack, $needle )`.
This aims to make the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [52039], [52040], [52326], [55703], [55710], [55987], [55988].
Props Soean, spacedmonkey, Clorith, ocean90, azaozz, sabernhardt, SergeyBiryukov.
Fixes#58220.
Built from https://develop.svn.wordpress.org/trunk@55990
git-svn-id: http://core.svn.wordpress.org/trunk@55502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).
WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].
Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes#58206.
Built from https://develop.svn.wordpress.org/trunk@55988
git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This aims to make the code more readable and consistent, as the function is already used extensively in core files.
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
Follow-up to [55703], [55959].
Props spacedmonkey.
Fixes#58012.
Built from https://develop.svn.wordpress.org/trunk@55987
git-svn-id: http://core.svn.wordpress.org/trunk@55499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset improve Dashboard screen options by stacking them vertically on small screens.
Props dhrumilk, prashantbhivsane, marybaum, dhruvishah2203, ababir, mukesh27, chiragrathod103, oglekler, tb1909, jahidcse, audrasjb.
Fixes#57977.
Built from https://develop.svn.wordpress.org/trunk@55984
git-svn-id: http://core.svn.wordpress.org/trunk@55496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset switches the `wp_enqueue_*` functions to `wp_register_*` for IE-related resources, which maintains handles, source references, etc., keeps all
IE-specific files within the theme package to avoid errors, and requires site admins to opt in to loading them in the theme.
It also replaces the content of `html5.js` shiv with a comment (to avoid 404s), and removes IE specific code from `header.php`.
Props desrosj, sabernhardt, audrasjb, neychok, oglekler.
See #56699.
Built from https://develop.svn.wordpress.org/trunk@55982
git-svn-id: http://core.svn.wordpress.org/trunk@55494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset switches the `wp_enqueue_*` functions to `wp_register_*` for IE-related resources, which maintains handles, source references, etc., keeps all
IE-specific files within the theme package to avoid errors, and requires site admins to opt in to loading them in the theme.
It also replaces the content of `html5.js` shiv with a comment (to avoid 404s), removes IE-specific code in general stylesheets, and removes IE specific code
from Customizer, header.php and custom-header.php.
Props desrosj, sabernhardt, audrasjb, neychok, oglekler.
See #56699.
Built from https://develop.svn.wordpress.org/trunk@55981
git-svn-id: http://core.svn.wordpress.org/trunk@55493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset switches the `wp_enqueue_*` functions to `wp_register_*` for IE-related resources, which maintains handles, source references, etc., keeps all
IE-specific files within the theme package to avoid errors, and requires site admins to opt in to loading them in the theme.
It also replace the content of `html5.js` shiv with a comment (to avoid 404s) and removes IE-specific code in general stylesheets.
Props desrosj, sabernhardt, audrasjb, neychok, oglekler.
See #56699.
Built from https://develop.svn.wordpress.org/trunk@55980
git-svn-id: http://core.svn.wordpress.org/trunk@55492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Update the performance tests to account for the relocation of the theme unit test data repository to the WordPress organisation on GitHub.
Props costdev, kafleg, williampatton, dd32, otto42, poena, jrf, joemcgill, peterwilsoncc, mukesh27.
Fixes#58569.
Built from https://develop.svn.wordpress.org/trunk@55976
git-svn-id: http://core.svn.wordpress.org/trunk@55488 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Hide the password for the "Post via e-mail" settings in writing options. Use the same password hiding mechanisms in use elsewhere in core.
Props mastrup, denis-de-bernardy, ryan, brookedot, wojtek.szkutnik, dd32, sabreuse, sergeybiryukov, costdev, peterwilsoncc, zgrkaralar, clorith, renyot, sabernhardt, boniu91, ironprogrammer, bgoewert.
Fixes#9883.
Built from https://develop.svn.wordpress.org/trunk@55974
git-svn-id: http://core.svn.wordpress.org/trunk@55486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Implement `aria-sort` and change icon states to indicate current sort for list tables. Allow screen reader users to get context about the current sort and allow sighted users to know how the table is currently sorted.
Props afercia, rianrietveld, joedolson, alexstine, johnjamesjacoby.
Fixes#32170.
Built from https://develop.svn.wordpress.org/trunk@55971
git-svn-id: http://core.svn.wordpress.org/trunk@55483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset improves a JS conditional statement to fix a console error thrown by Firefox on `event.target.matches`.
Props kjellr, laurelfulford, audrasjb, dimijazz, ianbelanger, pbiron, poena, McAlyster, janpaulkleijn, swissspidy, mukesh27, rehanali.
Fixes#46474.
See #45903 (fixes one of the two issues of this ticket).
Built from https://develop.svn.wordpress.org/trunk@55970
git-svn-id: http://core.svn.wordpress.org/trunk@55482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As placeholders may introduce confusion about whether the example is the input's predefined value or not, this changeset moves the "Just another WordPress
site" historic tagline as an example quoted in the field's description.
Props Cybr, audrasjb, sabernhardt, pavanpatil1, tb1909.
Fixes#57675.
Built from https://develop.svn.wordpress.org/trunk@55969
git-svn-id: http://core.svn.wordpress.org/trunk@55481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The intention behind this change is to prevent sensitive data in responses for logged in users being cached and available to others, for example via the browser history after the user logs out.
The `no-store` directive instructs caches in the browser or within proxies not to store the response in the cache. This is subtly different from the `no-cache` directive which means the response can be cached but must be revalidated before re-use. WordPress does not use ETag headers by default therefore this does not achieve the same result.
The `private` directive complements the `no-store` directive by specifying that the response contains private information that should not be stored in a public cache. Som
e proxy caches may ignore the `no-store` directive but respect the `private` directive, thus it is included.
The existing `Cache-Control` header for users who are not logged in remains unchanged, and the existing cache prevention directives remain in place for backwards compatib
ility.
Props soulseekah, luehrsen, Dharm1025, markdoliner, rutviksavsani, ayeshrajans, paulkevan, clorith, andy786, johnbillion
Fixes#21938, Fixes#57627
Built from https://develop.svn.wordpress.org/trunk@55968
git-svn-id: http://core.svn.wordpress.org/trunk@55480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset removes unused parameters and variables, fixes a typo, and improves some docblocks as per documentation standards.
Props upadalavipul, mukesh27, costdev, sabernhardt, hellofromtonya, audrasjb.
Fixes#57397.
Built from https://develop.svn.wordpress.org/trunk@55963
git-svn-id: http://core.svn.wordpress.org/trunk@55475 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Because `update_menu_item_cache` parameter doesn't have any description in this function, the `wp_get_nav_menu_items()` documentation page on DevHub fallbacks
to `get_post()` params descriptions… which fallbacks to `parse_query()`.
In parse_query(), the `update_menu_item_cache` param is set to `false` by default, so `wp_get_nav_menu_items()` ends up with a value of `false` by default,
which is wrong since `wp_get_nav_menu_items()` overrides this parameter to set it to true by default.
This changeset adds `update_menu_item_cache` parameter to `wp_get_nav_menu_items()` docblock, and indicates that it is set to `true` by default.
Follow-up to [53504].
Props audrasjb, matmoe.
Fixes#58468.
See #57840.
Built from https://develop.svn.wordpress.org/trunk@55962
git-svn-id: http://core.svn.wordpress.org/trunk@55474 1a063a9b-81f0-0310-95a4-ce76da25c4cd
On the `<body>` element, as a best practice background color and text color should always be set together. This makes it easier to quickly understand the
underlying color scheme.
Props allancole, joyously, samful, sabernhardt, oglekler, ronakganatra, tb1909, ugyensupport.
Fixes#45916.
Built from https://develop.svn.wordpress.org/trunk@55960
git-svn-id: http://core.svn.wordpress.org/trunk@55472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Change the `label` for `.check-column` inside list tables to a block filling the entire cell. Improves accessibility by increasing the target area for the control.
Props mitchoyoshitaka, lessbloat, sabernhardt, ogleker, tacoverdo, joostdevalk, karmatosed.
Fixes#21516.
Built from https://develop.svn.wordpress.org/trunk@55954
git-svn-id: http://core.svn.wordpress.org/trunk@55466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds a `is_block_theme` property to each theme in the `wp/v2/themes` API response, which uses `WP_Theme::is_block_theme` to determinate whether
the theme is block theme or not.
Props grantmkin, ironprogrammer, zunaid321, azaozz, spacedmonkey, audrasjb, costdev.
Fixes#58123.
Built from https://develop.svn.wordpress.org/trunk@55951
git-svn-id: http://core.svn.wordpress.org/trunk@55463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `WP_Theme_JSON::append_to_selector()` method was previously used for both appending and prepending which violated the single responsibility principle. It resulted in additional conditionals which also came at a performance cost, particularly because the method is called over 1,000 times during a regular WordPress request.
With the new `WP_Theme_JSON::prepend_to_selector()` method, there are now two distinct methods for the two distinct purposes. The now useless third parameter on `WP_Theme_JSON::append_to_selector()` has been removed (rather than deprecated), which is acceptable given that it is a protected method on a class that is not intended for extensions.
Props bor0, costdev, flixos90, isabel_brison, oandregal, spacedmonkey.
Fixes#58193.
See #58457.
Built from https://develop.svn.wordpress.org/trunk@55950
git-svn-id: http://core.svn.wordpress.org/trunk@55462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes#57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Redirect users visiting the `wp-admin/media.php` file to the media library, `wp-admin/upload.php`. An user facing warning is displayed when the media library is reached via a deprecated link.
Follow up to [55647].
Props jorbin, audrasjb, azaozz, NekoJonez, kebbet, costdev.
Fixes#57612.
Built from https://develop.svn.wordpress.org/trunk@55943
git-svn-id: http://core.svn.wordpress.org/trunk@55455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Change check to see if the current theme is a block theme, to check the path `/templates/index.html` first over the deprecated path `/block-templates/index.html`.
As this path was deprecated in WP 5.9, it is more likely the block theme would use the current path. This saves a file_exists call which improves performance.
Props nihar007, spacedmonkey.
Fixes#58520.
Built from https://develop.svn.wordpress.org/trunk@55941
git-svn-id: http://core.svn.wordpress.org/trunk@55453 1a063a9b-81f0-0310-95a4-ce76da25c4cd