AlkantarClanX12
| Current Path : /www/capitalgmcbuickregina_830/public/wp-content/themes/lbx-egypt/app/Hooks/ |
| Current File : /www/capitalgmcbuickregina_830/public/wp-content/themes/lbx-egypt/app/Hooks/SetCustomSitemaps.php |
<?php
namespace App\Hooks;
use App\View\Composers\Sitemap;
use Illuminate\Support\Str;
class SetCustomSitemaps extends Hook
{
protected $actions = [
'after_setup_theme'
];
public function __invoke()
{
add_filter('wpseo_sitemap_page_content', function () {
$output = '';
$lbSettings = get_leadbox_settings();
$showroom_page = get_page_by_title(ucfirst($lbSettings['manufacturer'])." Showroom");
$locale = get_locale();
if(get_page_by_title(ucfirst("new")) !== null){
// MODELS SITEMAP
foreach ((New Sitemap)->getModels() as $model) {
$output .= create_custom_sitemap_url( get_site_url() . "/new/{$model}/" );
}
// MODEL TRIMS SITEMAP
foreach ((New Sitemap)->getModelTrims() as $trim) {
$output .= create_custom_sitemap_url( get_site_url() . "/new/{$trim}/" );
}
}
if($showroom_page !== null && $showroom_page->post_status === 'publish') {
$showroom_models = (new Sitemap)->getShowroomModels();
$excludedModelsOption = Str::lower(get_option('dealer-settings-showroom-options')['excluded_models']);
// SHOWROOM MODELS SITEMAP
foreach ($showroom_models as $showroomModel) {
$modelWithoutMaker = explode('_', Str::replace('-' . get_leadbox_manufacturer(), '', $showroomModel))[0];
$isExcluded = in_array($modelWithoutMaker, explode(",", Str::replace(" ", "-", $excludedModelsOption)));
if (!$isExcluded) {
if (strpos($locale, 'en') !== false)
$output .= create_custom_sitemap_url(get_site_url() . "/showroom/" . $showroomModel . "/");
else
$output .= create_custom_sitemap_url(get_site_url() . "/salle-de-montre/" . $showroomModel . "/");
}
}
}
return $output;
});
}
}