homegrade_theme_production/includes/utilities.php

103 lines
2.1 KiB
PHP

<?php
$theme_namespace = 'homegrade-theme__texte-fonctionnel';
function getThematiqueFamilySlug($thematique_slug)
{
if (!$thematique_slug) {
return null;
}
switch ($thematique_slug) {
case "energie":
case "urbanisme":
case "stedenbouw":
return "energies-urbanisme";
case "acoustique":
case "akoestiek":
case "petites-coproprietes":
case "kleine-mede-eigendommen":
return "acoustique-coproprietes";
case "isolation":
case "isolatie":
case "au-quotidien":
return "isolation-quotidien";
case "energies":
case "urbanisme":
case "stedenbouw":
return "energies-urbanisme";
case "patrimoine":
case "erfgoed":
case "renovation":
return "patrimoine-renovation";
case "location":
case "verhuur":
case "circulaire-renovatie":
case "renovation-circulaire":
return "location-renovation-circulaire";
}
}
function getParentThematique($thematique)
{
if (!$thematique) {
return null;
}
if ($thematique->parent == 0) {
return $thematique;
} else {
return get_term($thematique->parent, 'thematiques');
}
}
// DOES THE SAME THING AS ABOVE BUT RENAMED
function getMainThematique($thematique)
{
if (!$thematique) {
return null;
}
if ($thematique->parent == 0) {
return $thematique;
} else {
return get_term($thematique->parent, 'thematiques');
}
}
// TO GET ARCHIVE RELATED PAGES BY TEMPLATE
function get_page_by_template($template = '')
{
$args = array(
'meta_key' => '_wp_page_template',
'meta_value' => $template
);
return get_pages($args);
}
function show_post_type_label_name($post_type)
{
switch ($post_type) {
case 'questions':
return __("Question", "homegrade-theme__texte-backoffice");
case 'conseils':
return __("Conseil", "homegrade-theme__texte-backoffice");
case 'page':
return __("Page", "homegrade-theme__texte-backoffice");
case 'post':
return __("News", "homegrade-theme__texte-backoffice");
case 'jobs':
return __("Offre d'emploi", "homegrade-theme__texte-backoffice");
default:
return null;
}
}