Adding a theme option file and settings for lock down pages
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 4 Feb 2015 20:20:15 +0000 (15:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 4 Feb 2015 20:20:15 +0000 (15:20 -0500)
for the glm_menu function to only show certain pages on the top level.

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

index a855139..5cdf363 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(
+    $parents      = 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);
@@ -128,7 +149,7 @@ function GLM_get_header() {
     echo '</div>';
 }
 
-// // The code below is useful when you want the image to resize to 
+// // The code below is useful when you want the image to resize to
 //    if (has_post_thumbnail()) {
 //            $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(), "full");
 //            echo '<img src="'.$image_data[0].'" style="no-repeat;max-height:400px;">';
diff --git a/theme.ini b/theme.ini
new file mode 100644 (file)
index 0000000..1eceb98
--- /dev/null
+++ b/theme.ini
@@ -0,0 +1,4 @@
+; This is a theme configuration file
+
+[menu_options]
+main_level_pages = 2, 130