function cp_default_menus() { $menus = array('primary' => __('Header', APP_TD), 'secondary' => __('Footer', APP_TD)); foreach ($menus as $location => $name) { if (has_nav_menu($location)) { continue; } $menu_id = wp_create_nav_menu($name); if (is_wp_error($menu_id)) { continue; } wp_update_nav_menu_item($menu_id, 0, array('menu-item-title' => __('Home', APP_TD), 'menu-item-url' => home_url('/'), 'menu-item-status' => 'publish')); $page_ids = array(CP_Ads_Categories::get_id(), CP_Blog_Archive::get_id()); foreach ($page_ids as $page_id) { $page = get_post($page_id); if (!$page) { continue; } wp_update_nav_menu_item($menu_id, 0, array('menu-item-type' => 'post_type', 'menu-item-object' => 'page', 'menu-item-object-id' => $page_id, 'menu-item-title' => $page->post_title, 'menu-item-url' => get_permalink($page), 'menu-item-status' => 'publish')); } $locations = get_theme_mod('nav_menu_locations'); $locations[$location] = $menu_id; set_theme_mod('nav_menu_locations', $locations); } }
function __construct() { self::$_template = 'tpl-categories.php'; parent::__construct(self::$_template, __('Categories', APP_TD)); // Replace any children the "Categories" menu item might have with the category dropdown add_filter('wp_nav_menu_objects', array($this, 'disable_children'), 10, 2); add_filter('walker_nav_menu_start_el', array($this, 'insert_dropdown'), 10, 4); }