From c00ced8a7417eca98f2a4c3d3beace0365259e78 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 4 Feb 2015 15:20:15 -0500 Subject: [PATCH] Adding a theme option file and settings for lock down pages for the glm_menu function to only show certain pages on the top level. --- functions.php | 29 +++++++++++++++++++++++++---- theme.ini | 4 ++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 theme.ini diff --git a/functions.php b/functions.php index a855139..5cdf363 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( + $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 ''."\n"; foreach ($pages as $page) { $childs = get_pages('child_of=' . $page->ID); @@ -128,7 +149,7 @@ function GLM_get_header() { echo ''; } -// // 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 ''; diff --git a/theme.ini b/theme.ini new file mode 100644 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 -- 2.17.1