functions.php 3.08 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 9
function my_theme_enqueue_styles()
{
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');

}

10
$debug_functions = false;
11

12 13
function echo_debug($words)
{
14 15
    //si mode debug activé, on affiche les informations demandées
    global $debug_functions;
16
    if ($debug_functions) {
17 18 19 20
        echo $words;
    }
}

21 22
function dump_debug($list)
{
23 24 25
    //si mode debug activé, on affiche le var dump demandé

    global $debug_functions;
26
    if ($debug_functions) {
27 28 29 30
        var_dump($list);
    }
}

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

36 37 38
    $id = $member_category_object->cat_ID;
    $server_link = $_SERVER["SERVER_NAME"];
    $link_Category = "http://" . $server_link . "/category/";
39
    $current_category = explode("/", $_SERVER['REQUEST_URI'])[2];
40 41 42 43 44 45 46 47 48

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

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

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

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

66
        $my_link .= "'><a href = \"http://" . $server_link . "/category/";
67 68 69
        $my_link .= $temp_category->slug;
        $my_link .= "\"";

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

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

root's avatar
root committed
77 78 79 80
}

function sort_page()
{
root's avatar
root committed
81
    $link = $_SERVER['REQUEST_URI'];
82
    $cleanLink = explode("?order", $link)[0];
root's avatar
root committed
83 84 85

    if (strpos($link, "order=desc")) {
        ?>
86 87 88 89 90 91 92 93
        <li class="adullact-sort-button">
            <a href="<?php echo $cleanLink; ?>?order=asc">
                Croissant
            </a>
        </li>
        <li class="adullact-sort-button adullact-selected"><a href="<?php echo $cleanLink; ?>?order=desc">
                Décroissant
            </a></li>
root's avatar
root committed
94 95 96
        <?php
    } else {
        ?>
97 98 99 100 101 102
        <li class="adullact-sort-button adullact-selected"><a href="<?php echo $cleanLink; ?>?order=asc">
                Croissant
            </a></li>
        <li class="adullact-sort-button"><a href="<?php echo $cleanLink; ?>?order=desc">
                Décroissant
            </a></li>
root's avatar
root committed
103 104 105

        <?php
    }
106
}
107

root's avatar
root committed
108
?>