get_queried_object(); $parent_id = $object->post_parent; $depth = 0; while ($parent_id > 0) { $page = get_page($parent_id); $parent_id = $page->post_parent; $depth++; } return $depth; } function getNbChildren($child=NULL,$echo=NULL){ global $wpdb; $child = (!$child) ? 0 : $child; $query = 'select ID, post_title, guid from '.$wpdb->posts.' where post_type=\'page\' and post_status=\'publish\' and post_parent='.$child.' order by menu_order'; $result = $wpdb->get_results($query,ARRAY_A); if($echo) echo count($result); else return count($result); } function allBtn($monID=0,$idEnCours=0,$allBtnTr=""){ if ($allBtnTr == ""){ $wTous = "Tous"; $selected = ""; if (strtoupper(qtrans_getLanguage()) == "EN"){ $wTous = "All"; } } else{ $wTous = $allBtnTr; } if ($monID == $idEnCours){ $selected = ' class="selected" '; } $result = ''.$wTous.''; return $result; } function list_pages($child=NULL,$echo=NULL,$type="",$idEnCours=0,$allBtnTr="Tous") { global $wpdb; global $wp_query; $i = 0; $items = ""; if ($type == "listMenu" OR $type == "listMenuNiveau3"){ $items = allBtn($child,$idEnCours,$allBtnTr); if ($type == "listMenuNiveau3"){ $items = str_replace('class="all"', 'class="all step1 step2 step3"', $items); } } $child = (!$child) ? 0 : $child; $query = 'select ID, post_title, guid from '.$wpdb->posts.' where post_type=\'page\' and post_status=\'publish\' and post_parent='.$child.' order by menu_order'; $result = $wpdb->get_results($query,ARRAY_A); foreach($result as $key => $val) { $monID = $val['ID']; $montitre= get_the_title($monID); $montitre = str_replace("- ", "", $montitre); $montitre = str_replace(" -", "", $montitre); $selected = ""; $monUrl = get_permalink($monID); $currentLang = strtoupper(qtrans_getLanguage()); $ssTitre= get_post_meta($monID, "ssTitre" . $currentLang, TRUE); $titreMenu = get_post_meta($monID, "titreMenu" . $currentLang, TRUE); $thumb = get_post_meta($monID, "vignette", TRUE); $isTitreUnique = ""; if ($ssTitre == ""){ $isTitreUnique = ' class="titreUnique" '; } if ($monID == $idEnCours){ $selected = ' class="selected" '; } if ((strpos($montitre,"FrançaisLng")==0) AND (strpos($montitre,"EnglishLng")==0)){ if ($type == "listMenu"){ //Génération des sous-menus if ($titreMenu != ""){ $montitre = $titreMenu; } $items .= ''.$montitre.''; } elseif ($type == "listMenuNiveau3"){ //Génération des sous-menus 3eme niveau $classes = ""; if ($i < 16) { $classes = 'class="'.$thumb.' step1"'; } if ($i >= 16 && $i <32) { $classes = 'class="'.$thumb.' step2"'; } if ($i >= 32 && $i <48) { $classes = 'class="'.$thumb.' step3"'; } if ($titreMenu != ""){ $montitre = $titreMenu; } $items .= ''.$montitre.''; if ($i == 15){ $items .= '
  • '; } if ($i == 31){ $items .= '
  • '; } } elseif ($type == "listVignettes"){ $items .= '
  • '; } else{ //Génération des listes dans les pages $items .= ''.$montitre.''.$ssTitre.''; } } ++$i; } if($echo) echo $items; else return $items; } ?>