avoid re-adding page to the main nav each time roots is activated
This commit is contained in:
@@ -65,7 +65,10 @@ if (is_admin() && 'themes.php' === $pagenow && isset( $_GET['activated'])) {
|
|||||||
if ($roots_nav_theme_mod) { set_theme_mod('nav_menu_locations', $roots_nav_theme_mod ); }
|
if ($roots_nav_theme_mod) { set_theme_mod('nav_menu_locations', $roots_nav_theme_mod ); }
|
||||||
|
|
||||||
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
|
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
|
||||||
|
|
||||||
$primary_nav_term_id = (int) $primary_nav->term_id;
|
$primary_nav_term_id = (int) $primary_nav->term_id;
|
||||||
|
$menu_items= wp_get_nav_menu_items($primary_nav_term_id);
|
||||||
|
if(!$menu_items || empty($menu_items)){
|
||||||
$pages = get_pages();
|
$pages = get_pages();
|
||||||
foreach($pages as $page) {
|
foreach($pages as $page) {
|
||||||
$item = array(
|
$item = array(
|
||||||
@@ -76,6 +79,7 @@ if (is_admin() && 'themes.php' === $pagenow && isset( $_GET['activated'])) {
|
|||||||
);
|
);
|
||||||
wp_update_nav_menu_item($primary_nav_term_id, 0, $item);
|
wp_update_nav_menu_item($primary_nav_term_id, 0, $item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user