Commit Graph

30 Commits

Author SHA1 Message Date
John Blackbourn c9746ab584 Docs: Various corrections and improvements relating to types used in inline documentation.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51796 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-18 13:50:05 +00:00
hellofromTonya f2f05f8e04 Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_Sitemaps_Provider::get_max_num_pages()`.
In each child class, renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Reassigns the generic parameter to the original parameter.
Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made.

Note: Reassignment is done after the guard clause.
Why? To avoid unnecessary processing and memory should the method bail out.

Follow-up to [48072].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51788


git-svn-id: http://core.svn.wordpress.org/trunk@51395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 19:42:56 +00:00
hellofromTonya a4b163a674 Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_Sitemaps_Provider::get_url_list()`.
In each child and grandchild class, renames the second parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Reassigns the generic parameter to the original parameter.
Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made.

Follow-up to [48072].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51787


git-svn-id: http://core.svn.wordpress.org/trunk@51394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 19:21:57 +00:00
Sergey Biryukov e53ffbaf95 Code Modernization: Pass correct default value to `http_build_query()` in `WP_Sitemaps_Provider::get_sitemap_url()`.
The `WP_Sitemaps_Provider::get_sitemap_url()` method calls the PHP native `http_build_query()` function, the second parameter of which is the ''optional'' `$numeric_prefix` parameter which expects a `string`.

A parameter being optional, however, does not automatically make it nullable.

As of PHP 8.1, passing `null` to a non-nullable PHP native function will generate a deprecation notice.

In this case, this function call yielded a `http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated` notice.

Changing the `null` to an empty string fixes this without a backward compatibility break.

This change is already covered by tests as 14 of the existing tests failed on these function calls when running the tests on PHP 8.1.

References:
* [https://www.php.net/manual/en/function.http-build-query.php PHP Manual: http_build_query()]
* [https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg PHP RFC: Deprecate passing null to non-nullable arguments of internal functions]

Follow-up to [48470].

Props jrf.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51652


git-svn-id: http://core.svn.wordpress.org/trunk@51258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-23 11:44:01 +00:00
Sergey Biryukov d3d78e755b Coding Standards: Add a space before `/` character in some self-closing HTML tags.
While this has no effect on the code, it fixes a minor inconsistency with the rest of core.

Props laxman-prajapati.
Fixes #52870.
Built from https://develop.svn.wordpress.org/trunk@50556


git-svn-id: http://core.svn.wordpress.org/trunk@50169 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-20 18:30:08 +00:00
Sergey Biryukov f7c520c1d5 Sitemaps: Center the container for sitemap content.
Props ramiy, swissspidy.
Fixes #50658.
Built from https://develop.svn.wordpress.org/trunk@49221


git-svn-id: http://core.svn.wordpress.org/trunk@48983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-20 02:22:07 +00:00
Sergey Biryukov 6fe59c4bdc Sitemaps: Check the result of `get_term_link()` when collecting the URLs in `WP_Sitemaps_Taxonomies::get_url_list()`.
This avoids a PHP warning during sitemap generation if `get_term_link()` returns an error, e.g. due to term ID being shared between multiple taxonomies.

Additionally, pass the `$taxonomy` argument to `get_term_link()` to properly disambiguate the call.

Props dd32.
Fixes #51416.
Built from https://develop.svn.wordpress.org/trunk@49137


git-svn-id: http://core.svn.wordpress.org/trunk@48899 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-13 15:04:07 +00:00
Felix Arntz 5918f7e11d Taxonomy: Allow for `wp_count_terms( $args )` signature, making passing a taxonomy optional.
This brings `wp_count_terms()` in line with other taxonomy functions such as `get_terms()` which technically no longer require a taxonomy. Similar to the previously modified functions, no deprecation warning is triggered when using the legacy signature.

Fixes #36399.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-21 22:32:06 +00:00
Sergey Biryukov 1f85e7484f Docs: Consistently use third-person singular verbs for various filter descriptions, per the documentation standards.
See #50768.
Built from https://develop.svn.wordpress.org/trunk@48782


git-svn-id: http://core.svn.wordpress.org/trunk@48544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-11 00:34:08 +00:00
John Blackbourn 0bf9b04c53 Docs: Various formatting improvements to inline docblocks.
See #49572
Built from https://develop.svn.wordpress.org/trunk@48574


git-svn-id: http://core.svn.wordpress.org/trunk@48336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 00:52:05 +00:00
Pascal Birchler 1f153b0d12 Sitemaps: Replace `wp_sitemaps_register_providers` filter with more suitable `wp_sitemaps_add_provider` filter.
The previous filter failed the goal of allowing developers to filter all providers before they are registered, since it only filtered the built-in ones.

The more specific `wp_sitemaps_add_provider` filter enables exactly that, as it filters every sitemap provider right before it is added to the sitemaps registry.

Props pbiron, pfefferle, Chouby, swissspidy.
Fixes #50660.
Built from https://develop.svn.wordpress.org/trunk@48543


git-svn-id: http://core.svn.wordpress.org/trunk@48305 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 16:14:07 +00:00
Pascal Birchler 694b407297 Sitemaps: Rename `wp_get_sitemaps()` to `wp_get_sitemaps_providers()`
Following [48536], rename the function to match the rest of the sitemaps logic.

Also eliminates some dead code after [48523].

Props pbiron.
See #50724. See #50643.
Built from https://develop.svn.wordpress.org/trunk@48540


git-svn-id: http://core.svn.wordpress.org/trunk@48302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 15:57:04 +00:00
Sergey Biryukov 12daeec1f7 Sitemaps: Rename 'sitemap' to 'provider' in `WP_Sitemaps_Registry` class.
This class is for registering sitemap providers, not individual sitemaps.

Props swissspidy.
Fixes #50724.
Built from https://develop.svn.wordpress.org/trunk@48536


git-svn-id: http://core.svn.wordpress.org/trunk@48298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 15:29:02 +00:00
Pascal Birchler 1f27914191 Sitemaps: Correctly enforce maximum number of sitemaps in index.
Before this change, the limit of 50k entries was enforced for the number of providers, not the amount of sitemaps all providers add to the index in total.

Props pbiron, swissspidy.
Fixes #50666.
Built from https://develop.svn.wordpress.org/trunk@48532


git-svn-id: http://core.svn.wordpress.org/trunk@48294 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 13:57:05 +00:00
whyisjake 7f92797960 Sitemaps: Ensure correct HTTP status when sitemaps are disabled
If sitemaps are disabled, previously there would be a rewrite rule for the sitemap endpoint. This endpoint would display the homepage since there was a rewrite rule. Now, Sitemaps are loaded, and the proper HTTP headers are returned.

Fixes #50643.
Props swissspidy, kraftbj, donmhico.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 00:57:05 +00:00
Pascal Birchler 2c92383b8d Sitemaps: Ensure entry for ‘page’ post type sitemap in index.
If there are no pages and no static homepage, there will still be one sitemap including the homepage URL.

This change ensures that this sitemap is correctly listed in the sitemap index.

Props Chouby, pacifika, elrae.
Fixes #50571.
Built from https://develop.svn.wordpress.org/trunk@48476


git-svn-id: http://core.svn.wordpress.org/trunk@48245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-14 12:26:02 +00:00
Pascal Birchler acca036e88 Sitemaps: Exclude post types and taxonomies that are not publicly queryable.
Props Cybr.
Fixes #50607.
Built from https://develop.svn.wordpress.org/trunk@48474


git-svn-id: http://core.svn.wordpress.org/trunk@48243 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-14 11:57:06 +00:00
Pascal Birchler 7757fe0b0c Sitemaps: Add missing slash when calling `home_url()` for consistency.
Props Chouby.
Fixes #50570.
Built from https://develop.svn.wordpress.org/trunk@48472


git-svn-id: http://core.svn.wordpress.org/trunk@48241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-14 11:54:06 +00:00
Pascal Birchler c1ac7b5e16 Sitemaps: Add wrapping `<div>` around sitemap in stylesheet.
This makes it easier to style the sitemap and for example center the entire content area.

Props ramiy.
Fixes #50622.
Built from https://develop.svn.wordpress.org/trunk@48471


git-svn-id: http://core.svn.wordpress.org/trunk@48240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-14 11:45:03 +00:00
Pascal Birchler 66c6ad97bc Sitemaps: Pass full paths to `home_url()` calls.
This makes it easier for plugins using the `home_url` filter to detect sitemap URLs.

Props Chouby.
Fixes #50592.
Built from https://develop.svn.wordpress.org/trunk@48470


git-svn-id: http://core.svn.wordpress.org/trunk@48239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-14 11:43:03 +00:00
Sergey Biryukov 376435ac9a Sitemaps: Remove some extra space from `WP_Sitemaps_Stylesheet::get_stylesheet_css()`.
Follow-up to [48414].

See #50449.
Built from https://develop.svn.wordpress.org/trunk@48425


git-svn-id: http://core.svn.wordpress.org/trunk@48194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-10 16:12:03 +00:00
whyisjake 68e56464c4 Sitemaps: Add better support for RTL sites.
While the URLs are intended to be machine readable, they should always be LTR, while other data would be RTL in the sitemap.

Fixes #50449.

Props joyously, SergeyBiryukov, pbiron. apedog, ramiy.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-10 00:50:04 +00:00
Pascal Birchler 69e876747d Sitemaps: Do not unnecessarily call `WP_Query::get_posts()` in posts provider.
The posts have already been fetched at this point, no need to do it again.

Props Chouby.
Fixes #50463.
Built from https://develop.svn.wordpress.org/trunk@48282


git-svn-id: http://core.svn.wordpress.org/trunk@48051 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-03 12:03:01 +00:00
Sergey Biryukov e13c363b17 Docs: Capitalize "ID", when referring to a post ID, term ID, etc. in a more consistent way.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48104


git-svn-id: http://core.svn.wordpress.org/trunk@47873 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 12:02:12 +00:00
John Blackbourn 1a77bb81d8 Docs: Remove unnecessary variables names from `@return` tags.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48100


git-svn-id: http://core.svn.wordpress.org/trunk@47869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-19 22:55:12 +00:00
John Blackbourn fe823d698f Docs: Corrections and improvements to inline docs related to XML sitemaps.
See #50117, #49572
Built from https://develop.svn.wordpress.org/trunk@48098


git-svn-id: http://core.svn.wordpress.org/trunk@47867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-19 22:26:10 +00:00
Sergey Biryukov a15912561e Docs: Document globals in `WP_Sitemaps_*` classes the same way they are documented in the rest of core.
See #49572, #50117.
Built from https://develop.svn.wordpress.org/trunk@48093


git-svn-id: http://core.svn.wordpress.org/trunk@47860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-19 17:56:09 +00:00
Sergey Biryukov 168a9df672 Coding Standards: Fix WPCS issues in `wp-includes/sitemaps/`.
Some of these were not caught when running `composer lint:errors`, but are fixed when running `phpcbf` directly.

Follow-up to [48072], [48080].

See #49542, #50117.
Built from https://develop.svn.wordpress.org/trunk@48081


git-svn-id: http://core.svn.wordpress.org/trunk@47848 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-18 14:46:09 +00:00
Sergey Biryukov e1bd050cb9 Coding Standards: Remove unused variable in `WP_Sitemaps_Provider::get_sitemap_entries()`.
Follow-up to [48072].

See #49542, #50117.
Built from https://develop.svn.wordpress.org/trunk@48080


git-svn-id: http://core.svn.wordpress.org/trunk@47847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-18 14:44:07 +00:00
Pascal Birchler 609dd1d14f Sitemaps: Add XML sitemaps functionality to WordPress.
While web crawlers are able to discover pages from links within the site and from other sites, XML sitemaps supplement this approach by allowing crawlers to quickly and comprehensively identify all URLs included in the sitemap and learn other signals about those URLs using the associated metadata.

See https://make.wordpress.org/core/2020/06/10/merge-announcement-extensible-core-sitemaps/ for more details.

This feature exposes the sitemap index via `/wp-sitemap.xml` and exposes a variety of new filters and hooks for developers to modify the behavior. Users can disable sitemaps completely by turning off search engine visibility in WordPress admin.

This change also introduces a new `esc_xml()` function to escape strings for output in XML, as well as XML support to `wp_kses_normalize_entities()`.

Props Adrian McShane, afragen, adamsilverstein, casiepa, flixos90, garrett-eclipse, joemcgill, kburgoine, kraftbj, milana_cap, pacifika, pbiron, pfefferle, Ruxandra Gradina, swissspidy, szepeviktor, tangrufus, tweetythierry.
Fixes #50117.
See #3670. See #19998.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47839 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-17 15:24:07 +00:00