Adding config to lock down main navigation
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 4 Feb 2015 20:39:00 +0000 (15:39 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 4 Feb 2015 20:39:00 +0000 (15:39 -0500)
Locks down the pages for the top level of the nav to pages listed in the
theme.ini file

functions.php
theme.ini [new file with mode: 0644]

index f27dec6..35b2af8 100755 (executable)
@@ -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 '<ul'.(($class)?' class="'.$class.'"':'').'><!-- begin -->'."\n";
     foreach ($pages as $page) {
         $childs = get_pages('child_of=' . $page->ID);
diff --git a/theme.ini b/theme.ini
new file mode 100644 (file)
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