Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Update to hale to hide private pages and adding list private pages te…
…mplate
  • Loading branch information
jmr06005 committed Jan 12, 2015
1 parent ee68c84 commit b551d3f
Show file tree
Hide file tree
Showing 3 changed files with 470 additions and 367 deletions.
35 changes: 32 additions & 3 deletions functions.php
Expand Up @@ -30,9 +30,22 @@ function huskypress_page_menu_args( $args ) {
}
add_filter( 'wp_page_menu_args', 'huskypress_page_menu_args' );




if(!function_exists('is_parent_private')){
function is_parent_private($id){
$page = get_post($id);
if($page->post_parent > 0){
$parent = get_post($page->post_parent);
$private = get_post_meta($parent->ID, 'uc-private', true);
if($private == 'admins' || $private == 'users' || $private == 'list'){
return $parent->ID;
}
else return is_parent_private($parent->ID);
}
else{
return false;
}
}
}

/*
Disabled until theme supports these types... (AB June 26, 2013)
Expand Down Expand Up @@ -426,6 +439,20 @@ function search_menu_item($items, $args){
if(!class_exists('Bootstrap_Nav_Walker')) {
class Bootstrap_Nav_Walker extends Walker_Nav_Menu {
/*This was taken from 320press WP-Bootstrap theme. No licensing restriction given, and it said it was free. */
/* Skip private pages
*/
function skip( $item ) {
$parent = is_parent_private($item->ID);
if($parent !== false) $page = $parent;
else $page = $item->ID;
$private = get_post_meta($page, 'uc-private', true);
if($private == 'admins' || $private == 'users' || $private == 'list'){
return true;
}
else{
return false;
}
}
/* Start of the <ul>
*
* Note on $depth: Counterintuitively, $depth here means the "depth right before we start this menu".
Expand Down Expand Up @@ -470,6 +497,7 @@ if(!class_exists('Bootstrap_Nav_Walker')) {
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
if ( $this->skip( $item ) ) return;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
Expand Down Expand Up @@ -545,6 +573,7 @@ if(!class_exists('Bootstrap_Nav_Walker')) {
*/
function end_el (&$output, $item, $depth, $args)
{
if ( $this->skip( $item ) ) return;
$output .= '</li>';
return;
}
Expand Down

0 comments on commit b551d3f

Please sign in to comment.