From b74591d5d0fe9eb8d98c8390a1285c7611b96709 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 4 Feb 2015 15:39:00 -0500 Subject: [PATCH] Adding config to lock down main navigation Locks down the pages for the top level of the nav to pages listed in the theme.ini file --- functions.php | 25 +++++++++++++++++++++++-- theme.ini | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 theme.ini diff --git a/functions.php b/functions.php index f27dec6..35b2af8 100755 --- a/functions.php +++ b/functions.php @@ -24,6 +24,22 @@ if (!function_exists('glm_quicksite_widget_init')) { } +/** + * get_menu_options + * + * Grab the menu options from the theme.ini file + */ +function glm_get_menu_options() +{ + static $menu_options; + $themeConfig = get_template_directory() . '/theme.ini'; + + if (!$menu_options && is_file($themeConfig)) { + $menu_options = parse_ini_file($themeConfig, true); + } + return $menu_options; +} + /** * glm_page_menu * @@ -31,9 +47,10 @@ if (!function_exists('glm_quicksite_widget_init')) { */ function glm_page_menu($parent = 0, $class = '') { + $menuConfig = glm_get_menu_options(); $frontPageId = get_option('page_on_front'); $parents = array(); - $pages = get_pages(array( + $args = array( 'post_type' => 'page', 'parent' => $parent, 'number' => '', @@ -41,7 +58,11 @@ function glm_page_menu($parent = 0, $class = '') 'post_status' => 'publish', 'sort_order' => 'asc', 'sort_column' => 'menu_order' - )); + ); + if ($parent == 0 && $menuConfig['menu_options']['main_level_pages']) { + $args['include'] = $menuConfig['menu_options']['main_level_pages']; + } + $pages = get_pages($args); echo ''."\n"; foreach ($pages as $page) { $childs = get_pages('child_of=' . $page->ID); diff --git a/theme.ini b/theme.ini new file mode 100644 index 0000000..4ecfcf3 --- /dev/null +++ b/theme.ini @@ -0,0 +1,4 @@ +; This is a theme configuration file + +[menu_options] +main_level_pages = 81, 82, 83, 84, 163, 235 -- 2.17.1