functions.php 3.14 KB
Newer Older
1
<?php
root's avatar
root committed
2
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
3

root's avatar
root committed
4 5 6 7 8
function my_theme_enqueue_styles()
{
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
}

N. Peraldi's avatar
N. Peraldi committed
9
$debug_functions = false;
10

N. Peraldi's avatar
N. Peraldi committed
11 12
function echo_debug($words)
{
13 14
    //si mode debug activé, on affiche les informations demandées
    global $debug_functions;
N. Peraldi's avatar
N. Peraldi committed
15
    if ($debug_functions) {
16 17 18 19
        echo $words;
    }
}

N. Peraldi's avatar
N. Peraldi committed
20 21
function dump_debug($list)
{
22 23 24
    //si mode debug activé, on affiche le var dump demandé

    global $debug_functions;
N. Peraldi's avatar
N. Peraldi committed
25
    if ($debug_functions) {
26 27 28 29
        var_dump($list);
    }
}

30
function childrens_of_member_category($category_to_select)
root's avatar
root committed
31 32
{
    //cette fonction affiche la liste des catégories enfants de la catégorie mère Adhérent
33
    $member_category_object = get_category_by_slug("adherent");
root's avatar
root committed
34

35 36 37
    $id = $member_category_object->cat_ID;
    $server_link = $_SERVER["SERVER_NAME"];
    $link_Category = "http://" . $server_link . "/category/";
N. Peraldi's avatar
N. Peraldi committed
38
    $current_category = $category_to_select;
39 40 41 42 43 44 45 46 47

    dump_debug($_SERVER);
    echo_debug("\n----------------------\n");
    dump_debug($member_category_object);
    //SERVER_NAME

    $childrens = get_term_children($id, "category"); //contiendra les id de tous les enfants de adhérent

    if ($current_category == "adherent" || $current_category == "") {
48
        echo " <li class='adullact-sort-button adullact-selected'><a href='" . $link_Category . "adherent/'>Tout</a></li>";
root's avatar
root committed
49
    } else {
50
        echo " <li class='adullact-sort-button'><a href='" . $link_Category . "adherent/'>Tout</a></li>";
root's avatar
root committed
51
    }
root's avatar
root committed
52 53

    foreach ($childrens as $c) {
root's avatar
root committed
54
        $temp_category = get_category($c); //objet contenant les infos de la catégorie enfant
root's avatar
root committed
55

56
        $my_link = "<li class='adullact-sort-button";
root's avatar
root committed
57

58
        if ($temp_category->slug == $category_to_select) {
59 60
            //si on est en train d'afficher la catégorie sélectionnée
            $my_link .= " adullact-selected";
N. Peraldi's avatar
N. Peraldi committed
61
        } else {
62 63
            echo_debug($temp_category->slug . "=/=" . $category_to_select);
        }
64

N. Peraldi's avatar
N. Peraldi committed
65
        $my_link .= "'><a href = \"http://" . $server_link . "/category/";
66 67 68
        $my_link .= $temp_category->slug;
        $my_link .= "\"";

N. Peraldi's avatar
N. Peraldi committed
69
        $my_link .= "\">";
70
        $my_link .= $temp_category->name;
71
        $my_link .= "</a></li>";
72 73

        echo $my_link;
root's avatar
root committed
74 75 76
    }
}

N. Peraldi's avatar
N. Peraldi committed
77
function sort_page($order, $page,$link)
root's avatar
root committed
78
{
N. Peraldi's avatar
N. Peraldi committed
79 80
    $for_asc_link = $link . "?page=" . $page . "&order=asc";
    $for_desc_link = $link . "?page=" . $page . "&order=desc";
N. Peraldi's avatar
N. Peraldi committed
81
    if ($order == "desc") {
root's avatar
root committed
82
        ?>
83
        <li class="adullact-sort-button">
N. Peraldi's avatar
N. Peraldi committed
84
            <a href="<?php echo $for_asc_link; ?>">
85 86 87
                Croissant
            </a>
        </li>
N. Peraldi's avatar
N. Peraldi committed
88 89
        <li class="adullact-sort-button adullact-selected">
            <a href="<?php echo $for_desc_link; ?>">
90
                Décroissant
N. Peraldi's avatar
N. Peraldi committed
91 92
            </a>
        </li>
root's avatar
root committed
93 94 95
        <?php
    } else {
        ?>
N. Peraldi's avatar
N. Peraldi committed
96 97
        <li class="adullact-sort-button adullact-selected">
            <a href="<?php echo $for_asc_link; ?>">
98
                Croissant
N. Peraldi's avatar
N. Peraldi committed
99 100 101 102
            </a>
        </li>
        <li class="adullact-sort-button">
            <a href="<?php echo $for_desc_link; ?>">
103
                Décroissant
N. Peraldi's avatar
N. Peraldi committed
104 105
            </a>
        </li>
root's avatar
root committed
106 107 108

        <?php
    }
N. Peraldi's avatar
N. Peraldi committed
109
}