Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

actions/admin/menu/save.php (1 issue)

1
<?php
2
/**
3
 * Save menu items.
4
 */
5
6
// featured menu items
7
$featured_names = (array) get_input('featured_menu_names', []);
8
$featured_names = array_unique($featured_names);
9
if (in_array(' ', $featured_names)) {
10
	unset($featured_names[array_search(' ', $featured_names)]);
11
}
12
elgg_save_config('site_featured_menu_names', $featured_names);
13
14
// custom menu items
15
$custom_menu_titles = get_input('custom_menu_titles', []);
16
$custom_menu_urls = get_input('custom_menu_urls', []);
17
$num_menu_items = count($custom_menu_titles);
0 ignored issues
show
It seems like $custom_menu_titles can also be of type string; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

17
$num_menu_items = count(/** @scrutinizer ignore-type */ $custom_menu_titles);
Loading history...
18
$custom_menu_items = [];
19
for ($i = 0; $i < $num_menu_items; $i++) {
20
	if (trim($custom_menu_urls[$i]) && trim($custom_menu_titles[$i])) {
21
		$url = $custom_menu_urls[$i];
22
		$title = $custom_menu_titles[$i];
23
		$custom_menu_items[$title] = $url;
24
	}
25
}
26
elgg_save_config('site_custom_menu_items', $custom_menu_items);
27
28
return elgg_ok_response('', elgg_echo('admin:menu_items:saved'));
29