Skip to content

Commit

Permalink
Rename proposed filter "timber/menu/items" to "timber/menu/item_objects"
Browse files Browse the repository at this point in the history
As suggested by @gchtr.

Co-authored-by: Lukas Gächter <lukas.gaechter@mind.ch>
  • Loading branch information
mcaskill and gchtr committed Mar 3, 2023
1 parent 58c2a2c commit de70e0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Integration/WpmlIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function init(): void
add_filter('timber/url_helper/get_content_subdir/home_url', [$this, 'file_system_to_url'], 10, 1);
add_filter('timber/url_helper/url_to_file_system/path', [$this, 'file_system_to_url'], 10, 1);
add_filter('timber/menu/id_from_location', [$this, 'menu_object_id_filter'], 10, 1);
add_filter('timber/menu/items', [$this, 'menu_items_filter'], 10, 1);
add_filter('timber/menu/item_objects', [$this, 'menu_item_objects_filter'], 10, 1);
add_filter('timber/image_helper/_get_file_url/home_url', [$this, 'file_system_to_url'], 10, 1);
}

Expand All @@ -35,7 +35,7 @@ public function menu_object_id_filter($id)
return wpml_object_id_filter($id, 'nav_menu');
}

public function menu_items_filter(array $items)
public function menu_item_objects_filter(array $items)
{
return array_map(
fn ($item) => ($item instanceof WPML_LS_Menu_Item ? new WP_Post($item) : $item),
Expand Down
4 changes: 2 additions & 2 deletions src/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static function build(?WP_Term $menu, $args = []): ?self
* @since 2.0.0
* @example
* ```
* add_filter( 'timber/menu/items', function ( $items ) {
* add_filter( 'timber/menu/item_objects', function ( $items ) {
* return array_map(function ($item) {
* if ( is_object( $item ) && ! ( $item instanceof \WP_Post ) ) {
* return new \WP_Post( get_object_vars( $item ) );
Expand All @@ -225,7 +225,7 @@ public static function build(?WP_Term $menu, $args = []): ?self
* @param array<mixed> $item
* @param WP_Term $menu
*/
$sorted_menu_items = apply_filters('timber/menu/items', $sorted_menu_items, $menu);
$sorted_menu_items = apply_filters('timber/menu/item_objects', $sorted_menu_items, $menu);

// Create Menu object
$nav_menu = new static($menu, (array) $args);
Expand Down
2 changes: 1 addition & 1 deletion tests/test-timber-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public function testMenuItemsFilter()
}, $items);
};

$this->add_filter_temporarily('timber/menu/items', $filter, 10, 2);
$this->add_filter_temporarily('timber/menu/item_objects', $filter, 10, 2);

$menu = Timber::get_menu($menu_id);
$items = $menu->get_items();
Expand Down

0 comments on commit de70e0b

Please sign in to comment.