Change posts and comments pagination `nav` regions to have an aria-label of "Posts pagination" and "Comments pagination", respectively. This provides improved context for the numeric links contained within these regions and differentiates between posts navigation regions and posts pagination regions.
Props michaelbourne, sabernhardt, afercia, xyulex, webmandesign, tirth03, joedolson.
Fixes#54260.
Built from https://develop.svn.wordpress.org/trunk@59113
git-svn-id: http://core.svn.wordpress.org/trunk@58509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Removes query alteration from `build_comment_query_vars_from_block` by introducing a new way to pass the `$page` as argument to functions handling pagination for the comments.
Props cybr, santosguillamot, bernhard-reiter, gziolo.
Fixes#60806.
Built from https://develop.svn.wordpress.org/trunk@59081
git-svn-id: http://core.svn.wordpress.org/trunk@58477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This brings the function in line with the similar `get_edit_post_link()` parameter. The 'get_edit_comment_link' filter now additionally receives the `$comment_id` and `$context` as parameters.
Additionally, as a minor enhancement, the capability check is now more defensive, as it will no longer cause an error if the given comment ID is invalid.
As part of the changeset, comprehensive test coverage for the `get_edit_comment_link()` including the new behavior is added.
Props deepakrohilla.
Fixes#61727.
Built from https://develop.svn.wordpress.org/trunk@58875
git-svn-id: http://core.svn.wordpress.org/trunk@58271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Modifies gravatar image URLs to always use the HTTPS version from secure.gravatar.com.
Gravatar now redirects HTTP image requests to their HTTPS equivalent, resulting in redirects for sites running over an HTTP connection (`is_ssl() === false`). Since the introduction of HTTP/2 the use of sub-domains for different hashes ([1-3].gravatar.com) now represents a performance hinderance rather than improvement.
The scheme passed to `get_avatar_data()` is now ignored for the generation of Gravatar URLs but the setting retained to avoid introducing bugs for sites using either local avatars or third party providers.
Props neoxx, SergeyBiryukov, sippis, peterwilsoncc, mukesh27, costdev, dd32.
Fixes#37454.
Built from https://develop.svn.wordpress.org/trunk@58822
git-svn-id: http://core.svn.wordpress.org/trunk@58218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, a trailing slash was appended to the link returned from `get_pagenum_link()`. If the permalink structure didn't contain a trailing slash, this link could fail.
This change removes trailing slashes and only appends one if the site is set for adding trailing slashes.
This adds a new test file for the accompanying tests, `tests/phpunit/tests/link/getPagenumLink.php`, and moves an existing test for `get_pagenum_link()` to the same file.
Props davemad-davenet, darkfate, Nazgul, scribu, nacin, obenland, chriscct7, jesin, matthewppelsheimer, audrasjb, petitphp, mukesh27, oglekler, mai21, webtechpooja, tejwanihemant, nicolefurlan, hellofromTonya, costdev.
Fixes#2877.
Built from https://develop.svn.wordpress.org/trunk@56939
git-svn-id: http://core.svn.wordpress.org/trunk@56450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Includes:
* Expanding and synchronizing documentation for the `default` and `rating` arguments.
* Adding `@since` entries for the `loading`, `fetchpriority`, and `decoding` arguments.
* Wrapping long lines as per the documentation standards.
* Fixing a typo in the `identicon` value.
* Minor formatting edits for consistency.
Follow-up to [31107], [45632], [47554], [53480], [56037].
See #58833.
Built from https://develop.svn.wordpress.org/trunk@56767
git-svn-id: http://core.svn.wordpress.org/trunk@56279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `esc_url()` function expects to a string for `$url` parameter. There is no input validation within that function. The function contains a `ltrim()` which also expects a string. Passing `null` to this parameter results in `Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1+.
Tracing the stack back, a `null` is being passed to it within `next_posts()` when `get_next_posts_page_link()` returns `null` (it can return a string or `null`).
On PHP 7.0 to PHP 8.x, an empty string is returned from `esc_url()` when `null` is passed to it. The change in this changeset avoids the deprecation notice by not invoking `esc_url()` when `get_next_posts_page_link()` returns `null` and instead sets the `$output` to an empty string, thus maintain the same behavior as before (minus the deprecation notice).
Adds a test to validate an empty string is returned and the absence of the deprecation (when running on PHP 8.1+).
Follow-up to [11383], [9632].
Props codersantosh, nihar007, hellofromTonya, mukesh27, oglekler, rajinsharwar.
Fixes#59154.
Built from https://develop.svn.wordpress.org/trunk@56740
git-svn-id: http://core.svn.wordpress.org/trunk@56252 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, several functions and methods in themes api were designed to check for the existence of files in a child theme before falling back to the parent theme. However, these checks did not consider whether the current theme was a child theme or not, resulting in unnecessary file existence checks for non-child themes. Check to see if stylesheet directory matches the template directory before doing the file exists. This optimization helps reduce unnecessary file system access, as file existence checks can be resource-intensive in PHP.
The following functions and methods have been updated as part of this enhancement:
- `WP_Theme::get_file_path`
- `get_theme_file_path`
- `get_theme_file_uri`
Props spacedmonkey, flixos90, sabernhardt, 10upsimon, mukesh27.
Fixes#59279.
Built from https://develop.svn.wordpress.org/trunk@56523
git-svn-id: http://core.svn.wordpress.org/trunk@56035 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 [55988], [55990], [56014], [56021], [56031], [56032], [56065], [56241].
See #58206.
Built from https://develop.svn.wordpress.org/trunk@56245
git-svn-id: http://core.svn.wordpress.org/trunk@55757 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 [55988].
Props spacedmonkey.
See #58220.
Built from https://develop.svn.wordpress.org/trunk@56021
git-svn-id: http://core.svn.wordpress.org/trunk@55533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`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.
Follow-up to [55990], [56014].
See #58220.
Built from https://develop.svn.wordpress.org/trunk@56019
git-svn-id: http://core.svn.wordpress.org/trunk@55531 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
In preparation for viewing revisions of templates and template parts in the editor, this set changes adds the `_edit_link` argument when registering the `wp_template` and `wp_template_part` post types. This commit also updates `get_edit_post_link` to account for the unique edit URLs for these post types.
Finally, this commit also adds new unit tests for the `get_edit_post_link` function, including tests for the `post`, `wp_template`, and `wp_template_part` post types.
Fixes#57709.
Props andraganescu, spacedmonkey, antonvlasenko, youknowriad, ramonopoly, ironprogrammer, annezazu.
Built from https://develop.svn.wordpress.org/trunk@55743
git-svn-id: http://core.svn.wordpress.org/trunk@55255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.
While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.
Follow-up to [52039], [52040], [52326].
Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes#58012.
Built from https://develop.svn.wordpress.org/trunk@55703
git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Give developers more control over how query caches are handled within an object caches. Now all caches that cache the result of a query, are cached in a group that is suffixed with -queries. Developers can use these groups, to add custom cache invalidation rules or to make them none persistent.
Props spacedmonkey, owi, tillkruess, skithund, peterwilsoncc, flixos90, sergeybiryukov, mukesh27.
Fixes#57625.
Built from https://develop.svn.wordpress.org/trunk@55526
git-svn-id: http://core.svn.wordpress.org/trunk@55048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit renames a few internal variables for better clarity and consistency:
* `$nextpage` to `$next_page` in:
* `get_next_posts_page_link()`
* `get_next_posts_link()`
* `get_next_comments_link()`
* `$nextpage` to `$previous_page` in:
* `get_previous_posts_page_link()`
* `$prevpage` to `$previous_page` in:
* `get_previous_comments_link()`
Includes minor code layout fixes for better readability.
Follow-up to [5045], [8502], [8961], [28111].
Props dalirajab, SergeyBiryukov.
Fixes#57746.
Built from https://develop.svn.wordpress.org/trunk@55364
git-svn-id: http://core.svn.wordpress.org/trunk@54897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Internal links should be followed and it should be easier to modify other rel attributes on comments. This adds a helper function for determining if a URL is internal and also adds some new filters to make it easy to modify rel attributes in comments.
Props thomasplevy, desrosj, sabernhardt, benish74, samiamnot, galbaras, jorbin.
Fixes#53290, #56444.
Built from https://develop.svn.wordpress.org/trunk@55289
git-svn-id: http://core.svn.wordpress.org/trunk@54822 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes#29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds a `rel="privacy-policy"` attribute to user-facing links to the Privacy Policy of the website, when a privacy policy page is set and available. While this `rel` value is still a RFC of the Link Types HTML specification, this changeset helps to make Privacy Policy link more discoverable for user agents and HTML parsers.
Props dshanske, audrasjb, bhavz-10, bookwyrm, faisal03, JeffPaul, peterwilsoncc, paapst, davidbaumwald, costdev, robinwpdeveloper, kawserz.
Fixes#56345.
Built from https://develop.svn.wordpress.org/trunk@55261
git-svn-id: http://core.svn.wordpress.org/trunk@54794 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The function `get_adjacent_post` cached the results of database query in the cache group `counts`. This is a none persistent group and meant cache would not persist on the next request. Change cache to save to the `posts` cache group. Cache invalidation is done by using get last changed value of the `posts` and `terms` group as a salt for the cache key.
Props spacedmonkey, peterwilsoncc, johnbillion, boonebgorges, mukesh27, dd32.
Fixes#41131.
Built from https://develop.svn.wordpress.org/trunk@55085
git-svn-id: http://core.svn.wordpress.org/trunk@54618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit:
* Renames the `$string` parameter to `$url` in `user_trailingslashit()`.
* Renames the `$echo` parameter to `$display` in:
* `edit_term_link()`
* `next_posts()`
* `previous_posts()`
* Renames the `$class` parameter to `$css_class` in:
* `edit_post_link()`
* `_navigation_markup()`
Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54943
git-svn-id: http://core.svn.wordpress.org/trunk@54495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The parameter was documented as `WP_Post`, but it contains the value of `get_adjacent_post()`, which returns an empty string if there is no corresponding post, so the correct type is `WP_Post|string`.
Follow-up to [11243], [16951], [28111], [32606].
Props apermo, audrasjb.
Fixes#57047.
Built from https://develop.svn.wordpress.org/trunk@54841
git-svn-id: http://core.svn.wordpress.org/trunk@54393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The function was erroneously calling `is_wp_error()` on the result of a `get_post()` call, which returns `null` on failure, and never returns a `WP_Error` object.
Previously, passing a non-existing post ID to the function would result in a home URL being returned and a few `Attempt to read property "post_type, post_name, hierarchical..." on null` PHP warnings.
This commit ensures `get_post_permalink()` returns `false` on failure, which brings parity with `get_permalink()`.
Includes a unit test to confirm the correct behavior.
Follow-up to [12923], [13023], [32606].
Props renegeuze, manzoorwani.jk.
Fixes#45329.
Built from https://develop.svn.wordpress.org/trunk@53733
git-svn-id: http://core.svn.wordpress.org/trunk@53292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This ensures that the global is explicitly declared and documented in:
* `get_next_posts_link()`
* `get_posts_nav_link()`
* `get_the_posts_navigation()`
* `get_the_posts_pagination()`
* `get_next_comments_link()`
Follow-up to [30065].
Props mt8.biz, sabernhardt.
Fixes#43164.
Built from https://develop.svn.wordpress.org/trunk@53520
git-svn-id: http://core.svn.wordpress.org/trunk@53109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This aims to improve performance by calling `sanitize_url()` directly, instead of the `esc_url_raw()` wrapper. As of WordPress 6.1, `sanitize_url()` is the recommended function for sanitizing a URL for database or redirect usage.
Follow-up to [11383], [13096], [51597], [53452].
Props benjgrolleau, peterwilsoncc, SergeyBiryukov.
Fixes#55852.
Built from https://develop.svn.wordpress.org/trunk@53455
git-svn-id: http://core.svn.wordpress.org/trunk@53044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While `AS` is an optional keyword in SQL, it is commonly considered best practice to include it for better readability and compatibility. This also makes the queries more consistent with other queries using aliases in core.
Follow-up to [6359], [30238].
Props costdev, domainsupport.
Fixes#54769.
Built from https://develop.svn.wordpress.org/trunk@52553
git-svn-id: http://core.svn.wordpress.org/trunk@52143 1a063a9b-81f0-0310-95a4-ce76da25c4cd