Example #1
0
function get_descendants($parent_id, $post_type = 'post')
{
    $descendants = array();
    $children = get_posts(array('numberposts' => -1, 'post_status' => 'publish', 'post_type' => $post_type, 'post_parent' => $parent_id, 'orderby' => 'menu_order', 'order' => 'ASC'));
    foreach ($children as $child) {
        $descendants[$child->ID]['post'] = $child;
        $grandchildren = get_descendants($child->ID, $post_type);
        if (!empty($grandchildren)) {
            $descendants[$child->ID]['children'] = $grandchildren;
        }
    }
    return $descendants;
}
Example #2
0
                $deleteIds = get_descendants(intval($_POST['link']));
                if (!empty($deleteIds)) {
                    $result = $db->query('DELETE FROM ' . DB_PREFIX . 'links WHERE id IN (' . implode(',', $deleteIds) . ')');
                }
            }
            break;
        case 'saveLink':
            if (array_key_exists('url', $_POST) && array_key_exists('name', $_POST) && array_key_exists('title', $_POST) && array_key_exists('link', $_POST)) {
                $result = $db->query('UPDATE ' . DB_PREFIX . 'links SET url = "' . $_POST['url'] . '", name = "' . $_POST['name'] . '", title = "' . $_POST['title'] . '" WHERE id = ' . intval($_POST['link']));
            }
            break;
        case 'deleteMenu':
            if (array_key_exists('menuname', $_POST)) {
                $menu = get_menus($_POST['menuname']);
                if (!empty($menu)) {
                    $deleteIds = get_descendants($menu[$_POST['menuname']]['id']);
                    if (!empty($deleteIds)) {
                        $result = $db->query('DELETE FROM ' . DB_PREFIX . 'links WHERE id IN (' . implode(',', $deleteIds) . ')');
                    }
                }
            }
            break;
    }
    exit;
}
// If a valid menu is given, load it's settings
if ($menu) {
    $links = get_navigation($menu['varname']);
    $js[] = 'links';
    $cache->removeCache(CACHE_NAVIGATION);
    $smarty->assign('menu_id', $menu['id']);
Example #3
0
					<?php 
    $buckets = get_buckets();
    $bucket = $buckets[$bucket];
    echo "<span class=\"left\"><span class=\"fa fa-{$bucket['icon']}\"></span></span>";
    echo $bucket['title'];
    ?>
				</a>
			</div>
		</div>
	</div>

	<nav id="bucket-menu">
		<div class="row collapse">
			<div class="small-12 columns">
				<?php 
    if ($descendants = get_descendants($top_level, 'any')) {
        ?>

					<ul class="menu show-for-medium-up">
						<?php 
        applegate_bucket_menu_loop($descendants);
        ?>
					</ul>

					<select class="select-menu hide-for-medium-up">
						<?php 
        applegate_bucket_menu_loop_selectbox($descendants);
        ?>
					</select>

				<?php