%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/atv-api/wp-content/themes/atv/inc/controllers/
Upload File :
Create Path :
Current File : /var/www/html/atv-api/wp-content/themes/atv/inc/controllers/globalController.php

<?php 

class GlobalSettings {

    public function index($request)
    {
        $headerMenu = wp_get_nav_menu_items('Header');
        $footerMenu = wp_get_nav_menu_items('Footer');
        $tours = getPosts('tours');
        $rents = getPosts('rent');
        $menu = [];

        foreach($headerMenu as $header) {
            $menu['header'][] = ['title' => $header->title, 'slug' => strtolower(str_replace(" ", "-", $header->title))];
        }

        foreach($footerMenu as $footer) {
            $menu['footer'][] = ['title' => $footer->title, 'slug' => strtolower(str_replace(" ", "-", $footer->title))];
        }

        $toursArr = [];
        foreach($tours as $tour) {
            $toursArr[] = [
                "title" => get_the_title($tour->ID),
                "image" => get_the_post_thumbnail_url($tour->ID),
				"single_price_label" => get_field("single_price_label", $tour->ID),
                "price" => get_field("price_eur", $tour->ID),
				"double_price_label" => get_field("double_price_label", $tour->ID),
				"double_price" => get_field("double_price_eur", $tour->ID),				
                "slug" => $tour->post_name
            ];
        }

        $rentArr = [];

        foreach($rents as $rent) {
            $title = explode(" ", get_the_title($rent->ID));
            $injectTitle = "<h5>" . $title[0] . "</h5>";
            unset($title[0]);
            $injectTitle .= "<h5>" . implode(" ", $title) . "</h5>";

            $rentArr[] = [
                "title" => $injectTitle,
                "brandImage" => get_field("brand_image", $rent->ID),
                "brandImageBlack" => get_field("brand_image_black", $rent->ID),
                "image" => get_the_post_thumbnail_url($rent->ID),
                "slug" => $rent->post_name
            ];
        }


        return [
                "menu" => $menu,
                "socials" => [
                    'fb' => get_field('facebook', 'options'),
                    'tw' => get_field('twitter', 'options'),
                    'in' => get_field('instagram', 'options'),
					"email" => get_field('email', 'options'),
                ],
                'header' => [
                    'tours' => $toursArr,
                    'rents' => $rentArr
                ],
                'contact' => [
                    'small_title' => get_field('small_title', 145),
                    'title' => get_field('title', 145),
                    'phone' => get_field('phone', 145),
                    'form_description' => get_field('form_description', 145),
                    'location_image' => get_field('location_image', 145),
                    'location_url' => get_field('location_url', 145)
                ],
                "legal" => nl2br(get_post(165)->post_content)
            ];
    }

}

Zerion Mini Shell 1.0