When inserting a term from a non-existing taxonomy as a nav item, the `post_title` property should be empty, and the function should not throw a fatal error for `wp_specialchars_decode()`.
Includes bringing some consistency to similar checks for post types and post type archives in the same code fragment.
Follow-up to [14283], [14450], [35382], [36095].
Props dd32, narenin, mukesh27, SergeyBiryukov.
Fixes#61799.
Built from https://develop.svn.wordpress.org/trunk@58854
git-svn-id: http://core.svn.wordpress.org/trunk@58250 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
* Make the function description more specific, for consistency with other similar functions.
* Add a `@since` note for the `$update_menu_item_cache` parameter of `WP_Query::parse_query()`.
* Add missing `@covers` tags for the unit tests.
Follow-up to [53504].
See #55620.
Built from https://develop.svn.wordpress.org/trunk@53508
git-svn-id: http://core.svn.wordpress.org/trunk@53097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add a new parameter to `WP_Query` called `update_menu_item_cache` that when set to true, primes the caches for linked terms and posts for menu item post objects. This change moves logic
found in `wp_get_nav_menu_items` into a new function called `update_menu_item_cache`. Update the menu item REST API controller, to pass the `update_menu_item_cache` parameter to the
arguments used for the `WP_Query` run to get menu items.
Props furi3r, TimothyBlynJacobs, spacedmonkey, peterwilsoncc, mitogh.
Fixes#55620.
--This line, and those below, will be ignored--
M src/wp-includes/class-wp-query.php
M src/wp-includes/nav-menu.php
M src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php
M tests/phpunit/tests/post/nav-menu.php
Built from https://develop.svn.wordpress.org/trunk@53504
git-svn-id: http://core.svn.wordpress.org/trunk@53093 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
Change the `wp_get_nav_menu_items` function to replace the call to `get_objects_in_term` with a simple taxonomy query. This change improves performance as it results in one fewer query to retrieve menu items from the
database.
Props Spacedmonkey, peterwilsoncc.
Fixes#55372.
Built from https://develop.svn.wordpress.org/trunk@53010
git-svn-id: http://core.svn.wordpress.org/trunk@52599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In `wp_get_nav_menu_items` multiple function calls to `get_terms` and `get_posts` were being used to load post/term objects into
memory. This change replaces calls to `get_terms` and `get_posts` with calls to `_prime_post_caches` and
`_prime_term_caches`. These functions are designed to prime object caches and do not have the overhead of a query object. This
change also replaces multiple queries with a single query, saving many SQL queries per page load.
Props Spacedmonkey, peterwilsoncc.
Fixes#55428.
--This line, and those below,
will be ignored--
M src/wp-includes/nav-menu.php
Built from https://develop.svn.wordpress.org/trunk@52975
git-svn-id: http://core.svn.wordpress.org/trunk@52564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In the new menu items, global items and template controllers manually call the function `wp_after_insert_post()` to manually fire the action of the same name after all potential data is updated.
This accounts for the use case in which a theme or plugin developer has modified the endpoints use of either taxonomy or meta data.
The new parameter `$fire_after_hooks` is added to `wp_update_nav_menu_item()` to control whether the `wp_after_insert_post` action is fired when it in turn calls `wp_insert_post()`.
Props spacedmonkey, peterwilsoncc, zieladam.
Fixes#54536.
Built from https://develop.svn.wordpress.org/trunk@52276
git-svn-id: http://core.svn.wordpress.org/trunk@51868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The menu items REST API controller was added in [52079]. This included functionality to add a "block" menu item type. This functionality is experimental and not currently used in WordPress core, so should be removed.
Props noisysocks.
See #40878.
Built from https://develop.svn.wordpress.org/trunk@52184
git-svn-id: http://core.svn.wordpress.org/trunk@51776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit introduces the `/wp/v2/menus`, `/wp/v2/menu-items` and `/wp/v2/menu-locations` REST API endpoints. These endpoints are fully available to users with the `edit_theme_options` capability, but can be read by any user who can edit a REST API available post type.
The `nav_menu` taxonomy and `nav_menu_item` post type now map their capabilities to the `edit_theme_options` primitive capability. This allows developers to provide more fine-grained access control. However, if a developer is currently dynamically removing the `edit_theme_options` capability using `map_meta_cap`, they should use the `user_has_cap` filter instead.
The `wp_update_nav_menu_item()` function has been adjusted to return an error if saving the menu item post or assigning the menu item to a menu generate an error.
Lastly, a new menu item type is introduced, `block`, that can be used to store a Block as a menu item.
Props andraganescu, antonvlasenko, dingo_d, dlh, isabel_brison, kadamwhite, Mamaduka, NateWr, noisysocks, peterwilsoncc, ryelle, schlessera, soean, Spacedmonkey, talldanwp, TimothyBlynJacobs, tobifjellner, westonruter, wpscholar, zieladam.
Fixes#40878.
Built from https://develop.svn.wordpress.org/trunk@52079
git-svn-id: http://core.svn.wordpress.org/trunk@51671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* `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.
Built from https://develop.svn.wordpress.org/trunk@50558
git-svn-id: http://core.svn.wordpress.org/trunk@50171 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This allows a menu item `post_date` to be set to particular value, rather than only allowing it to be set to "now". In particular, the WordPress Importer can use this to perform faster, more accurate duplicate checks.
Props jmdodd.
Fixes#52189.
Built from https://develop.svn.wordpress.org/trunk@50013
git-svn-id: http://core.svn.wordpress.org/trunk@49714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As it already was not possible to pass the required parameters without also passing the optional one anyway, removing the default value for the (not so) optional parameters should not affect backward compatibility.
This change affects three functions in core:
* `get_comment_delimited_block_content()`
* `do_enclose()`
* `_wp_delete_tax_menu_item()`
Props jrf, ayeshrajans, desrosj.
Fixes#50343.
Built from https://develop.svn.wordpress.org/trunk@48794
git-svn-id: http://core.svn.wordpress.org/trunk@48556 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This allows special pages to be denoted as such when editing a menu in the Customizer.
This applies to the Front Page, Posts Page, and Privacy Policy Page.
Follow-up to [47211], [47213], [47763].
Props dlh, whyisjake, SergeyBiryukov.
Fixes#46829. See #49374.
Built from https://develop.svn.wordpress.org/trunk@48619
git-svn-id: http://core.svn.wordpress.org/trunk@48381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The tag was supported in phpDocumentor 1.x, but is no longer supported in 2.x and 3.x.
Usage of static variables is considered an internal implementation detail and has no information value for someone reading the docs.
Props alishanvr, jrf.
Fixes#50426.
Built from https://develop.svn.wordpress.org/trunk@48109
git-svn-id: http://core.svn.wordpress.org/trunk@47878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When nav menu location slugs are integers, some hard to debug results can occur. `register_nav_menus()` utilizes `array_merge()` which renumbers numeric indexes, starting from 0. Because of this, numeric menu locations will almost always be changed.
This change introduces a `_doing_it_wrong()` notice to inform developers that nav menu locations should always be strings.
Props audrasjb, desrosj, welcher.
Fixes#45361.
Built from https://develop.svn.wordpress.org/trunk@46102
git-svn-id: http://core.svn.wordpress.org/trunk@45914 1a063a9b-81f0-0310-95a4-ce76da25c4cd