mirror of
git://develop.git.wordpress.org/
synced 2025-02-11 10:30:44 +01:00
REST API: Some documentation and test improvements for update_menu_item_cache()
:
* 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53508 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
20ccbb1437
commit
ec0f508a9f
@ -627,6 +627,7 @@ class WP_Query {
|
||||
* @since 4.9.0 Introduced the `$comment_count` parameter.
|
||||
* @since 5.1.0 Introduced the `$meta_compare_key` parameter.
|
||||
* @since 5.3.0 Introduced the `$meta_type_key` parameter.
|
||||
* @since 6.1.0 Introduced the `$update_menu_item_cache` parameter.
|
||||
*
|
||||
* @param string|array $query {
|
||||
* Optional. Array or string of Query parameters.
|
||||
|
@ -753,11 +753,11 @@ function wp_get_nav_menu_items( $menu, $args = array() ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prime all linked objects to menu items.
|
||||
* Updates post and term caches for all linked objects for a list of menu items.
|
||||
*
|
||||
* @since 6.1.0
|
||||
*
|
||||
* @param WP_Post[] $menu_items Array post objects of menu items.
|
||||
* @param WP_Post[] $menu_items Array of menu item post objects.
|
||||
*/
|
||||
function update_menu_item_cache( $menu_items ) {
|
||||
$post_ids = array();
|
||||
@ -767,6 +767,7 @@ function update_menu_item_cache( $menu_items ) {
|
||||
if ( 'nav_menu_item' !== $menu_item->post_type ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
|
||||
$type = get_post_meta( $menu_item->ID, '_menu_item_type', true );
|
||||
|
||||
|
@ -204,8 +204,9 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 55620
|
||||
* @covers update_menu_item_cache
|
||||
*/
|
||||
public function test_update_menu_item_cache_primed_post() {
|
||||
public function test_update_menu_item_cache_primed_posts() {
|
||||
$post_id = self::factory()->post->create();
|
||||
wp_update_nav_menu_item(
|
||||
$this->menu_id,
|
||||
@ -229,11 +230,12 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
|
||||
|
||||
$args = $action->get_args();
|
||||
$last = end( $args );
|
||||
$this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches was not executed.' );
|
||||
$this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55620
|
||||
* @covers update_menu_item_cache
|
||||
*/
|
||||
public function test_update_menu_item_cache_primed_terms() {
|
||||
register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
|
||||
@ -260,7 +262,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
|
||||
|
||||
$args = $action->get_args();
|
||||
$last = end( $args );
|
||||
$this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches was not executed.' );
|
||||
$this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user