Commit Graph

464 Commits

Author SHA1 Message Date
Sergey Biryukov
2d2a9c4715 Posts, Post Types: Speed cached get_pages() calls.
This improves performance for sites with persistent cache backend having a lot of pages requested via the `get_pages() function, by taking advantage of `wp_cache_get_multiple()` instead of fetching each individual page from the backend cache server one by one.

It also matches the behaviour of `get_pages()` when the pages are retrieved from the database.

Props david.binda, hellofromTonya.
Fixes #51469.

git-svn-id: https://develop.svn.wordpress.org/trunk@51018 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-25 23:40:12 +00:00
SergeyBiryukov
cb5a19f8c1 Posts, Post Types: Remove some unused strings from built-in post type declarations.
The `customize_changeset`, `wp_block`, and `wp_template` post types are not displayed in the admin menu or in the admin bar.

If they do get added, the labels can just fall back to `name` and `singular_name` until separate strings are required for more flexible translations.

Follow-up to [38810], [44146], [51003].

See #53176.

git-svn-id: https://develop.svn.wordpress.org/trunk@51015 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-25 22:48:02 +00:00
Sergey Biryukov
304715ae99 Block Editor: Declare the wp_template post type as built-in.
Remove redundant `show_in_admin_bar` property, which defaults to the value of `show_in_menu`.

Follow-up to [51003].

See #53176.

git-svn-id: https://develop.svn.wordpress.org/trunk@51014 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-25 22:27:20 +00:00
Riad Benguella
ea49625d59 Block Editor: Introduce block templates for classic themes.
With this patch, users will be able to create custom block based templates
and assign them to specific pages/posts.

Themes can also opt-out of this feature

Props bernhard-reiter, carlomanf.
Fixes #53176.


git-svn-id: https://develop.svn.wordpress.org/trunk@51003 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-25 14:19:14 +00:00
Sergey Biryukov
110f132f7e General: Ensure consistent type for integer properties of WP_Post, WP_Term, and WP_User.
Previously, these properties could be unexpectedly converted to strings in some contexts.

This applies to the following functions:

* `sanitize_post_field()`
* `sanitize_term_field()`
* `sanitize_user_field()`

and the following properties:

* `WP_Post::ID`
* `WP_Post::post_parent`
* `WP_Post::menu_order`
* `WP_Term::term_id`
* `WP_Term::term_taxonomy_id`
* `WP_Term::parent`
* `WP_Term::count`
* `WP_Term::term_group`
* `WP_User::ID`

Props grantmkin, SergeyBiryukov.
Fixes #53235. See #52995.

git-svn-id: https://develop.svn.wordpress.org/trunk@50935 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-19 22:10:58 +00:00
Jonathan Desrosiers
2ac7f39570 Posts, Post Types: Enable revisions for the wp_block post type.
This allows site owners to take advantage of revisions while broader improvements to block management and reusable blocks are explored.

Props matveb, audrasjb, desrosj.
Fixes #53072.

git-svn-id: https://develop.svn.wordpress.org/trunk@50835 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-10 18:37:36 +00:00
Adam Silverstein
6a5ff5aa03 Images: enable WebP support.
Add support for uploading, editing and saving WebP images when supported by the server.

Add 'image/webp' to supported mime types. Correctly identify WebP images and sizes even when PHP doesn't support WebP. Resize uploaded WebP files (when supported) and use for front end markup.

Props markoheijne, blobfolio, Clorith, joemcgill, atjn, desrosj, spacedmonkey, marylauc, mikeschroder, hellofromtonya, flixos90.
Fixes #35725.



git-svn-id: https://develop.svn.wordpress.org/trunk@50810 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-04 14:43:36 +00:00
Greg Ziółkowski
4072823456 Editor: Update WordPress packages to use with WordPress 5.8
In the response to the discussion during the Dev Chat, I'm doing a first pass to keep WordPress packages up to date in the WordPress 5.8 release cycle.

See https://github.com/WordPress/wordpress-develop/pull/1176 for more details.

Props youknowriad, aristath, andraganescu.
See #52991.



git-svn-id: https://develop.svn.wordpress.org/trunk@50761 602fd350-edb4-49c9-b593-d223f7449a82
2021-04-15 14:41:38 +00:00
David Baumwald
3bb06ce10b Docs: Clarify return results for a non-existing ID in metadata functions.
[48658] documented that various metadata functions return false for an invalid ID. However, that does not clarify what an invalid ID is: a non-numeric, zero, or negative value. This change adds the clarification in all relevant metadata function docblocks.

Props icopydoc, SergeyBiryukov, davidkryzaniak, audrasjb.
Fixes #51797.

git-svn-id: https://develop.svn.wordpress.org/trunk@50641 602fd350-edb4-49c9-b593-d223f7449a82
2021-04-02 15:47:34 +00:00
Sergey Biryukov
f7d5b2bca6 Docs: Document the import_id parameter of wp_insert_post().
Follow-up to [9100].

Props donmhico.
Fixes #52943.

git-svn-id: https://develop.svn.wordpress.org/trunk@50621 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-31 13:03:54 +00:00
Sergey Biryukov
05566e992d Coding Standards: Use strict comparison for return type checks in a few functions:
* `get_bookmark()`
* `get_comment()`
* `get_post()`
* `get_children()`
* `wp_get_recent_posts()`
* `wp_get_post_revision()`
* `wp_get_nav_menu_items()`

Follow-up to [45710] for `get_term()`, [48507] for `wpdb::get_row()` and `wpdb::get_results()`.

See #52627.

git-svn-id: https://develop.svn.wordpress.org/trunk@50558 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-21 12:39:25 +00:00
Sergey Biryukov
3f7760b93e Docs: Correct formatting for the description of some register_post_type() parameters.
Props audrasjb.
Fixes #52836.

git-svn-id: https://develop.svn.wordpress.org/trunk@50538 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-17 17:31:19 +00:00
Sergey Biryukov
1446948f95 Docs: Add missing @since tags for item_link and item_link_description post type and taxonomy labels.
Follow-up to [50527].

See #52688.

git-svn-id: https://develop.svn.wordpress.org/trunk@50529 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-13 10:23:56 +00:00
Greg Ziółkowski
380d0445e8 Editor: Make block type aware of variations
Currently block variations are only defined on the client. In some cases, creating block variations on the server can be very useful, especially when needed data is not exposed in the REST APIs.

Related to https://github.com/WordPress/gutenberg/pull/29095.

Props: gwwar, timothyblynjacobs.
Fixes: #52688.



git-svn-id: https://develop.svn.wordpress.org/trunk@50527 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-12 13:33:21 +00:00
John Blackbourn
fa05e5e733 Docs: Add examples of possible names for various hooks whose name contains a dynamic portion.
This provides greater discoverability of such hooks in search results on the Code Reference site as well as increased clarity when reading the source.

See #50734, #52628


git-svn-id: https://develop.svn.wordpress.org/trunk@50505 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-07 12:30:38 +00:00
Sergey Biryukov
cebbabbe21 Media: Explicitly declare the $pagenow global in wp_get_attachment_url().
This avoids an "Undefined index" PHP notice in the function when running the `media` test group separately.

Follow-up to [32342], [50156], [50164], [50393].

Props johnbillion.
Fixes #52606.

git-svn-id: https://develop.svn.wordpress.org/trunk@50406 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-22 18:53:11 +00:00
Peter Wilson
50af962653 Posts/Post Types: Prevent duplicates in sticky posts option.
In `unstick_post()` if a post ID is duplicated in the `sticky_posts` option remove all instances.

In both `stick_post()` and `unstick_post()` check for duplicate IDs already stored in the `sticky_post` option and remove them if the option is updated.

Props rahmohn, archon810.
Fixes #52007.


git-svn-id: https://develop.svn.wordpress.org/trunk@50380 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-17 22:56:34 +00:00
John Blackbourn
f0e3ab49b3 Posts, Post Types: Clarify the documentation about the return value of get_post() when a falsey value is passed.
Props Rahe, juliobox, peterwilsoncc, hellofromTonya, audrasjb

Fixes #33068


git-svn-id: https://develop.svn.wordpress.org/trunk@50266 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-09 13:42:58 +00:00
Peter Wilson
2e23c29603 Posts/Post Types: Improve documentation of get_posts().
Add references to `WP_Query` to the documentation of `get_posts()`. As the developer documentation for `WP_Query` includes an expanded explanation a full link to developer.wordpress.org is included rather than a standard `@see`.

Props dam6pl, peterwilsoncc.
See #51852, #51800.



git-svn-id: https://develop.svn.wordpress.org/trunk@50257 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-08 22:50:36 +00:00
Peter Wilson
4cfbf629ca Posts, Post Types: Additional functions to check if a post is publicly viewable.
Introduces `is_post_status_viewable()` as a sibling to `is_post_type_viewable()`. Internal and protected statuses are never considered viewable. For built in posts statuses the `public` attribute is checked, for custom statuses the `publicly_queryable` attribute is checked.

Introduces `is_post_publicly_viewable()` for determining if an individual post can be viewed by logged out users. A post is considered viewable if both `is_post_status_viewable()` and `is_post_type_viewable()` return `true` for the post's attributes.

Additionally modifies `is_post_type_viewable()` to return `false` if an unregistered post type is passed to the function to avoid attempting to access properties on a non-object.

Props peterwilsoncc, SergeyBiryukov, whyisjake, TimothyBlynJacobs.
Fixes #49380.



git-svn-id: https://develop.svn.wordpress.org/trunk@50130 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-01 23:31:54 +00:00
Sergey Biryukov
e1001678a6 Posts, Post Types: Introduce "Filter by date" and "Filter by category" as post type and taxonomy labels, respectively.
This provides a more consistent location for these strings and allows for reusing them in other places without hardcoding them in the markup.

Props nicolalaserra, audrasjb, johnjamesjacoby, SergeyBiryukov.
Fixes #42421.

git-svn-id: https://develop.svn.wordpress.org/trunk@50120 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-01 14:11:57 +00:00
Sergey Biryukov
919019865a Docs: Revert documentation change for wp_get_attachment_metadata().
This more accurately describes the behavior of the function, and is more consistent with the documentation for other post and attachment functions.

Follow-up to [50039].

Props Mista-Flo.
See #52196.

git-svn-id: https://develop.svn.wordpress.org/trunk@50051 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-28 10:40:31 +00:00
Jake Spurlock
7447e215b7 Media: Ensure that wp_get_attachment_metadata can return values from the global $post, if avaiable.
In [49084] (for #50679), wp_get_attachment_metadata() was changed to improve performance, but it had the side effect of eliminating the ability to call it with no arguments and have it default to using the global $post.

This change restores that ability, while keeping the performance improvements from the original change.

Fixes #52196.

Props cfinke, hellofromTonya, mukesh27, dilipbheda, Mista-Flo, audrasjb, SergeyBiryukov, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@50039 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-28 00:07:21 +00:00
Gary Pendergast
e2bb95aa50 Posts: Create a new function for resolving the post date.
`wp_insert_post()` has a few checks using `post_date` and `post_date_gmt`, to determine the correct post date. This functionality is now extracted out into a new `wp_resolve_post_date()` function, allowing the checks to be reused elsewhere.

Props jmdodd.
Fixes #52187.



git-svn-id: https://develop.svn.wordpress.org/trunk@50012 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-25 01:06:25 +00:00
Peter Wilson
0839d27da9 Media: Ensure get_post_status() does not contain half a comment.
Removes a misplaced comment, follow up to [49985].

Props SergeyBiryukov.
Fixes #52326.



git-svn-id: https://develop.svn.wordpress.org/trunk@49986 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-20 04:58:20 +00:00
Peter Wilson
56939ff70e Media: Ensure get_post_status() returns correct result for attachments.
Prevent `get_post_status()` returning `false` for attachments if the parent post has been deleted. The returned attachment post status is now passed through the `get_post_status` filter.

Add tests for `get_post_status()`.

Props peterwilsoncc, timothyblynjacobs for review.
Fixes #52326.



git-svn-id: https://develop.svn.wordpress.org/trunk@49985 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-20 04:39:24 +00:00
Sergey Biryukov
994e657e74 Coding Standards: Fix WPCS issue in [49963].
Props pawki07, mukesh27.
Fixes #52316. See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49965 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-16 17:19:00 +00:00
Sergey Biryukov
fbab01c8ce Docs: In various @return tags, list the expected type first, instead of false.
Follow-up to [46696], [47060], [49926], [49927], [49929].

See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49963 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-15 20:06:50 +00:00
John Blackbourn
8153c8ba02 Docs: Corrections and improvements to types used in various docblocks.
See #51800, #52217


git-svn-id: https://develop.svn.wordpress.org/trunk@49936 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-05 17:14:24 +00:00
Sergey Biryukov
715daf875a Docs: In various @return tags, list the expected type first, instead of false or WP_Error.
Follow-up to [46696], [47060], [49926], [49927].

See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49929 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-04 17:16:43 +00:00
John Blackbourn
679ccc35e6 Docs: Promote many bool types to true or false where only that value is used.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49927 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-03 22:02:13 +00:00
John Blackbourn
374b41ed13 Docs: Various docblock corrections particularly relating to boolean types.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49926 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-03 21:55:04 +00:00
Sergey Biryukov
54b6981355 Posts, Post Types: Correct the check for term IDs to be queued for lazy-loading term meta.
This ensures that the `$term_ids` array in `wp_queue_posts_for_term_meta_lazyload()` (an indexed array not keyed by ID) does not contain duplicate values.

Props denishua, akabarikalpesh.
Fixes #52144.

git-svn-id: https://develop.svn.wordpress.org/trunk@49905 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-24 11:19:29 +00:00
John Blackbourn
37f8276a18 Docs: Various docblock improvements.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49790 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 23:57:29 +00:00
John Blackbourn
81b89682c3 Docs: Various docblock corrections.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49789 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 23:51:52 +00:00
John Blackbourn
f1e610531a REST API: Pass the previous state of the post as a parameter to the wp_after_insert_post hook.
This enables, for example, the previous post status to be used by this hook without the need to first capture it on an earlier hook.

This also fixes the value of the `$fire_after_hooks` parameter in `get_default_post_to_edit()` so the `wp_after_insert_post` action correctly fires just once on the new post screen.

Props Collizo4sky, peterwilsoncc, hellofromTonya, TimothyBlynJacobs, SergeyBiryukov

Fixes #45114


git-svn-id: https://develop.svn.wordpress.org/trunk@49731 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-01 20:45:43 +00:00
John Blackbourn
c8f7440c6a Docs: Upgrade more parameters in docblocks to used typed array notation.
See #51800, #41756


git-svn-id: https://develop.svn.wordpress.org/trunk@49693 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-24 21:25:46 +00:00
John Blackbourn
f2c9d2851c Docs: Various docblock corrections relating to parameter types.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49692 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-24 21:20:36 +00:00
Sergey Biryukov
4f28c68eb6 Docs: Correct $fire_after_hooks parameter name in @since tags.
Follow-up to [49172], [49173].

See #45114.

git-svn-id: https://develop.svn.wordpress.org/trunk@49673 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-20 11:56:08 +00:00
John Blackbourn
a47e8924b0 Docs: Document parameters that accept an array of integers using typed array notation.
While many of these parameters also technically accept an array of numerical strings, they are all ultimately cast to an array of integers. Documenting them as such assists developers in understanding the expected types.

See #51800, #41756


git-svn-id: https://develop.svn.wordpress.org/trunk@49672 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-19 18:22:02 +00:00
Helen Hou-Sandi
56ffe940b0 Multisite: More consistency for clean_dirsize_cache().
Props SergeyBiryukov.
Fixes #19879.


git-svn-id: https://develop.svn.wordpress.org/trunk@49616 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-16 22:29:42 +00:00
Sergey Biryukov
637a3e8b5d Docs: Clarify that get_pages() returns an array of pages, not an HTML list.
Props ben.meredith@gmail.com, ovenall, johannadevos.
Fixes #39049. See #51768.

git-svn-id: https://develop.svn.wordpress.org/trunk@49595 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-14 15:00:00 +00:00
John Blackbourn
8e25b92b63 Docs: Docblock corrections relating to WP_Post objects.
See #51373, #50768


git-svn-id: https://develop.svn.wordpress.org/trunk@49544 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-09 15:13:56 +00:00
Sergey Biryukov
da97d6779a Docs: Change the @since entry for template and template_lock post type arguments to 5.0.0.
These arguments were introduced with the initial block editor, but not documented previously.

Follow-up to [49495].

Props TimothyBlynJacobs.
See #46261.

git-svn-id: https://develop.svn.wordpress.org/trunk@49496 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-04 02:45:26 +00:00
Sergey Biryukov
1d2ecc5b6e Docs: Add documentation for the template_lock argument to register_post_type().
Add a `@since` entry for `template` and `template_lock` arguments.

Follow-up to [49041], [49492], [49494].

See #46261.

git-svn-id: https://develop.svn.wordpress.org/trunk@49495 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-04 02:30:24 +00:00
Sergey Biryukov
aed826aab1 Docs: Add a reference to wp_insert_post() for information on the arguments accepted by wp_update_post().
See #50768.

git-svn-id: https://develop.svn.wordpress.org/trunk@49493 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-04 01:37:21 +00:00
Peter Wilson
088fd3cd39 Taxonomy: Revert Light-weight/partial term counts.
Partial revert of [49141], [49171], [49316].

All functional changes are removed, appropriate term counting unit tests are retained.

See #40351.


git-svn-id: https://develop.svn.wordpress.org/trunk@49451 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-30 04:57:16 +00:00
Sergey Biryukov
fce8f2bf4d Posts, Post Types: Check if taxonomy is set for the tax_input parameter of wp_insert_post().
This avoids a PHP notice when creating a post with multiple taxonomies both having a default term.

Props yakimun, szaqal21, hareesh-pillai, audrasjb.
Fixes #51320.

git-svn-id: https://develop.svn.wordpress.org/trunk@49328 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-27 16:40:35 +00:00
Sergey Biryukov
548d03026b Docs: Fix typo in {$old_status}_to_{$new_status} hook description.
See #50768.

git-svn-id: https://develop.svn.wordpress.org/trunk@49326 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-27 15:40:21 +00:00
Helen Hou-Sandi
80329c379a Multisite: More specific caching for get_dirsize.
Instead of one cache entry for all upload folders for a site on multisite, this now caches for each folder and invalidates that cache based on context. In multisite, this should speed up `get_dirsize` calls since older directories that are much less likely to change will no longer have the size recalculated.

Props janthiel, A5hleyRich, batmoo.
Fixes #19879.


git-svn-id: https://develop.svn.wordpress.org/trunk@49212 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-19 21:49:58 +00:00