Ejemplo n.º 1
0
function is_service_page()
{
    global $post;
    if ($post->post_type === 'service' && !is_tag() && !is_search()) {
        return get_depth($post->ID);
    }
    return false;
}
Ejemplo n.º 2
0
 function forum_newtopic()
 {
     global $settings, $locale;
     if (isset($_POST['select_forum'])) {
         $_POST['forum_sel'] = isset($_POST['forum_sel']) && isnum($_POST['forum_sel']) ? $_POST['forum_sel'] : 0;
         redirect(FORUM . 'post.php?action=newthread&forum_id=' . $_POST['forum_sel']);
     }
     echo openmodal('newtopic', $locale['forum_0057'], array('button_id' => 'newtopic', 'class' => 'modal-md'));
     $index = dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
     $result = dbquery("SELECT a.forum_id, a.forum_name, b.forum_name as forum_cat_name, a.forum_post\n\t\t FROM " . DB_FORUMS . " a\n\t\t LEFT JOIN " . DB_FORUMS . " b ON a.forum_cat=b.forum_id\n\t\t WHERE " . groupaccess('a.forum_access') . " " . (multilang_table("FO") ? "AND a.forum_language='" . LANGUAGE . "' AND" : "AND") . "\n\t\t (a.forum_type ='2' or a.forum_type='4') AND a.forum_post < " . USER_LEVEL_PUBLIC . " AND a.forum_lock !='1' ORDER BY a.forum_cat ASC, a.forum_branch ASC, a.forum_name ASC");
     $options = array();
     if (dbrows($result) > 0) {
         while ($data = dbarray($result)) {
             $depth = get_depth($index, $data['forum_id']);
             if (checkgroup($data['forum_post'])) {
                 $options[$data['forum_id']] = str_repeat("&#8212;", $depth) . $data['forum_name'] . " " . ($data['forum_cat_name'] ? "(" . $data['forum_cat_name'] . ")" : '');
             }
         }
         echo "<div class='well clearfix m-t-10'>\n";
         echo form_select('forum_sel', $locale['forum_0395'], '', array('options' => $options, 'inline' => 1, 'width' => '100%'));
         echo "<div class='display-inline-block col-xs-12 col-sm-offset-3'>\n";
         echo form_button('select_forum', $locale['forum_0396'], 'select_forum', array('class' => 'btn-primary btn-sm'));
         echo "</div>\n";
         echo "</div>\n";
         echo closeform();
     } else {
         echo "<div class='well text-center'>\n";
         echo $locale['forum_0328'];
         echo "</div>\n";
     }
     echo closemodal();
 }
Ejemplo n.º 3
0
function get_depth($index, $child_id, $depth = false)
{
    if (!$depth) {
        $depth = 1;
    }
    foreach ($index as $key => $value) {
        if (in_array($child_id, $value)) {
            if ($key == 0) {
                return $depth;
            } else {
                return get_depth($index, $key, $depth + 1);
            }
        }
    }
}
            if (in_array("about-us", explode("/", $_SERVER["REQUEST_URI"]))) {
                wp_nav_menu(array('menu' => 'Sub-About Us'));
            } else {
                //Default Menu Display
                if (get_depth() == 0) {
                    $this_cat = get_category($cat);
                    $id = $this_cat->cat_ID;
                    echo '<ul>';
                    wp_list_categories('exclude=1&orderby=ID&show_count=0&title_li=&use_desc_for_title=0&child_of=' . $id . '&depth=1');
                    echo '</ul>';
                } else {
                    if (get_depth() == 1) {
                        $this_category = get_category($cat);
                        get_category_siblings($this_category);
                    } else {
                        if (get_depth() == 2) {
                            $this_category = get_category($cat);
                            get_category_siblings($this_category);
                        } else {
                            wp_list_categories('exclude=1&title_li=&depth=2');
                        }
                    }
                }
            }
        }
    }
}
?>
			</ul>
		</li>
		<div id="wpcf7-smc">
Ejemplo n.º 5
0
    ##strip leading and trailing whitespace
    $name = preg_replace('/(^\\s+|\\s+$)/', '', $name);
    ##replace runs of 1 or more space with a single dash
    $name = preg_replace('/\\s+/', '-', $name);
    return $name;
}
//if single, find the post id, then we can find the category
if (is_category()) {
    if (get_depth() == 0) {
        $category = get_the_category();
        $name = $category[0]->name;
        $side = cattoside($name);
        set_query_var("cat", $this_cat_id);
        get_sidebar($side);
    } else {
        if (get_depth() == 1) {
            $category = get_the_category();
            $parent = get_category($category[0]->category_parent);
            $name = $parent->name;
            $side = cattoside($name);
            set_query_var("cat", $this_cat_id);
            get_sidebar($side);
        } else {
            $leaf_category = get_the_category();
            $category = $leaf_category;
            $parent_id = $category[0]->category_parent;
            $id_chain = array();
            while ($parent_id) {
                array_unshift($id_chain, $parent_id);
                $category = get_category($parent_id);
                $parent_id = $category->category_parent;
Ejemplo n.º 6
0
function get_depth($id = '', $depth = '', $i = 0)
{
    global $wpdb;
    if ($depth == '') {
        if (is_page()) {
            if ($id == '') {
                global $post;
                $id = $post->ID;
            }
            $depth = $wpdb->get_var("SELECT post_parent FROM {$wpdb->posts} WHERE ID = '" . $id . "'");
            return get_depth($id, $depth, $i);
        } elseif (is_category()) {
            if ($id == '') {
                global $cat;
                $id = $cat;
            }
            $depth = $wpdb->get_var("SELECT parent FROM {$wpdb->term_taxonomy} WHERE term_id = '" . $id . "'");
            return get_depth($id, $depth, $i);
        } elseif (is_single()) {
            if ($id == '') {
                $category = get_the_category();
                $id = $category[0]->cat_ID;
            }
            $depth = $wpdb->get_var("SELECT parent FROM {$wpdb->term_taxonomy} WHERE term_id = '" . $id . "'");
            return get_depth($id, $depth, $i);
        }
    } elseif ($depth == '0') {
        return $i;
    } elseif (is_single() || is_category()) {
        $depth = $wpdb->get_var("SELECT parent FROM {$wpdb->term_taxonomy} WHERE term_id = '" . $depth . "'");
        $i++;
        return get_depth($id, $depth, $i);
    } elseif (is_page()) {
        $depth = $wpdb->get_var("SELECT post_parent FROM {$wpdb->posts} WHERE ID = '" . $depth . "'");
        $i++;
        return get_depth($id, $depth, $i);
    }
}