App.php 2.21 KB
Newer Older
Michael Iseard's avatar
Michael Iseard committed
1
2
3
4
<?php

namespace App\Controllers;

5
use App\wp_bootstrap4_navwalker;
Michael Iseard's avatar
Michael Iseard committed
6
use Sober\Controller\Controller;
7
use function App\get_logo;
Michael Iseard's avatar
Michael Iseard committed
8

9
10
11
class App extends Controller {

    /**
Michael Iseard's avatar
Michael Iseard committed
12
13
14
     * Calculate extra body classes
     *
     * @return string
15
     */
Michael Iseard's avatar
Michael Iseard committed
16
17
18
19
20
21
22
23
24
    public function body_class() {

        $class=[];

        if($this->site_news()) {
            array_push($class, 'site-news');
        }

        return implode(" ", $class);
25
26
27
    }

    /**
Michael Iseard's avatar
Michael Iseard committed
28
29
     * Define navbar variables
     *
30
31
32
33
     * @return array
     */
    public function navbar() {
        return [
Michael Iseard's avatar
Michael Iseard committed
34
            'class' => 'navbar-dark',
35
            'logoStyle' => get_logo('white', true),
36
            'logoSize'  => '30px',
Michael Iseard's avatar
Michael Iseard committed
37
            'btnClass' => 'btn-outline-light'
38
        ];
Michael Iseard's avatar
Michael Iseard committed
39
40
    }

41
42
43
44
    public static function title() {
        if ( is_home() ) {
            if ( $home = get_option( 'page_for_posts', true ) ) {
                return get_the_title( $home );
Michael Iseard's avatar
Michael Iseard committed
45
            }
46
47

            return __( 'Latest Posts', 'kudos-website' );
Michael Iseard's avatar
Michael Iseard committed
48
        }
49
        if ( is_archive() ) {
Michael Iseard's avatar
Michael Iseard committed
50
51
            return get_the_archive_title();
        }
52
53
        if ( is_search() ) {
            return sprintf( __( 'Search Results for %s', 'kudos-website' ), get_search_query() );
Michael Iseard's avatar
Michael Iseard committed
54
        }
55
56
        if ( is_404() ) {
            return __( 'Not Found', 'kudos-website' );
Michael Iseard's avatar
Michael Iseard committed
57
        }
58

Michael Iseard's avatar
Michael Iseard committed
59
60
61
        return get_the_title();
    }

62
63
    public function siteName() {
        return get_bloginfo( 'name' );
Michael Iseard's avatar
Michael Iseard committed
64
    }
Michael Iseard's avatar
Michael Iseard committed
65

66
67
68
69
    public function site_news() {
        if ( is_front_page() || carbon_get_theme_option( 'site_news_all_pages' ) ) {
            if ( carbon_get_theme_option( 'show_site_news' ) ) {
                return carbon_get_theme_option( 'site_news' );
Michael Iseard's avatar
Michael Iseard committed
70
71
72
73
74
75
76
77
78
            }
        }

        return false;
    }

    /**
     * @return array
     */
79
80
81
    public function cta() {
        $cta['label'] = carbon_get_theme_option( 'cta_label' );
        $cta['link']  = carbon_get_theme_option( 'cta_link' );
Michael Iseard's avatar
Michael Iseard committed
82
83
84
85
86
87
88
89

        return $cta;
    }

    /**
     * Primary Nav Menu arguments
     * @return array
     */
90
91
92
93
94
95
    public function primary_menu() {
        return [
            'theme_location' => 'primary_navigation',
            'menu_class'     => 'navbar-nav',
            'walker'         => new wp_bootstrap4_navwalker(),
        ];
Michael Iseard's avatar
Michael Iseard committed
96
    }
Michael Iseard's avatar
Michael Iseard committed
97
}