|
4 | 4 |
|
5 | 5 | namespace DoWStarterTheme\Common\Menu; |
6 | 6 |
|
7 | | -use KepnerTregoe\Common\Contracts\Hookable; |
8 | | -use KepnerTregoe\Common\Helpers\SVG; |
9 | | -use KepnerTregoe\Deps\Illuminate\Support\Collection; |
| 7 | +use DoWStarterTheme\Common\Contracts\Hookable; |
| 8 | +use DoWStarterTheme\Common\Helpers\SVG; |
| 9 | +use DoWStarterTheme\Deps\Illuminate\Support\Collection; |
10 | 10 | use WP_Post; |
11 | 11 |
|
12 | 12 | /** |
13 | 13 | * Menu class |
14 | 14 | */ |
15 | 15 | class MenuHooks implements Hookable |
16 | 16 | { |
17 | | - /** |
18 | | - * Class constructor. |
19 | | - * |
20 | | - * @param SVG $svg SVG helper instance. |
21 | | - */ |
| 17 | + /** |
| 18 | + * Class constructor. |
| 19 | + * |
| 20 | + * @param SVG $svg SVG helper instance. |
| 21 | + */ |
22 | 22 | public function __construct( |
23 | 23 | private SVG $svg, |
24 | 24 | ) { |
25 | 25 | } |
26 | 26 |
|
27 | 27 | /** |
28 | | - * Adds icons to menu items. |
29 | | - * |
30 | | - * @filter wp_nav_menu_objects |
31 | | - * |
32 | | - * @param WP_Post[] $items Menu items. |
33 | | - * @param array<string, mixed> $args object of wp_nav_menu() arguments. |
34 | | - * @return WP_Post[] customized menu items with icons. |
35 | | - */ |
36 | | - public function addIcons(array $items) { |
| 28 | + * Adds icons to menu items. |
| 29 | + * |
| 30 | + * @filter wp_nav_menu_objects |
| 31 | + * |
| 32 | + * @param array<WP_Post> $items Menu items. |
| 33 | + * @return array<WP_Post> customized menu items with icons. |
| 34 | + */ |
| 35 | + public function addIcons(array $items) { |
37 | 36 | return Collection::make($items) |
38 | | - ->map(function (WP_Post $item) { |
39 | | - $icon = get_field('icon', $item); |
| 37 | + ->map( |
| 38 | + function (WP_Post $item) { |
| 39 | + $icon = get_field('icon', $item); |
40 | 40 |
|
41 | | - if (!is_numeric($icon)) { |
42 | | - return $item; |
43 | | - } |
| 41 | + if (! is_numeric($icon)) { |
| 42 | + return $item; |
| 43 | + } |
44 | 44 |
|
45 | | - $item->title = sprintf( |
46 | | - '%s%s', |
47 | | - $this->svg->getAttachment($icon), |
48 | | - $item->title |
49 | | - ); |
| 45 | + $item->title = sprintf( |
| 46 | + '%s%s', |
| 47 | + $this->svg->getAttachment($icon), |
| 48 | + $item->title |
| 49 | + ); |
50 | 50 |
|
51 | | - return $item; |
52 | | - }) |
| 51 | + return $item; |
| 52 | + } |
| 53 | + ) |
53 | 54 | ->all(); |
54 | | - } |
| 55 | + } |
55 | 56 | } |
0 commit comments