Completed
Push — componentlibrary ( e8d0dd...512a9e )
by
unknown
01:37
created

Init.php ➔ initTheme()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Flynt\Init;
4
5
use Flynt;
6
use Flynt\Utils\Asset;
7
use Flynt\Utils\Feature;
8
use Flynt\Utils\FileLoader;
9
use Flynt\Utils\StringHelpers;
10
use Timber\Timber;
11
12
add_action('after_setup_theme', __NAMESPACE__ . '\\initTheme');
13
add_action('after_setup_theme', __NAMESPACE__ . '\\loadFeatures', 100);
14
add_action('after_setup_theme', __NAMESPACE__ . '\\loadComponents', 101);
15
16
function initTheme()
17
{
18
    // initialize plugin defaults
19
    Flynt\initDefaults();
20
21
    // Set to true to load all assets from a CDN if there is one specified
22
    Asset::loadFromCdn(false);
23
24
    // WP Stuff
25
    add_theme_support('title-tag');
26
    add_theme_support('post-thumbnails');
27
28
    new Timber();
29
}
30
31
function loadFeatures()
32
{
33
    $basePath = get_template_directory() . '/dist/Features';
34
35
    global $flyntCurrentOptionCategory;
36
    $flyntCurrentOptionCategory = 'feature';
37
38
    Feature::register('YoutubeNoCookieEmbed', $basePath);
39
40
    // initialize ACF Field Groups and Option Pages
41
    Feature::register('Acf', $basePath, [[
42
        'FlexibleContentToggle',
43
        'GoogleMaps'
44
    ]]);
45
46
    // enable admin notices
47
    Feature::register('AdminNotices', $basePath);
48
49
    // use timber rendering
50
    Feature::register('TimberLoader', $basePath);
51
52
    // load jQuery in footer by default
53
    Feature::register('Jquery', $basePath);
54
55
    // clean up some things
56
    Feature::register('CleanHead', $basePath);
57
    Feature::register('CleanRss', $basePath);
58
    Feature::register('MimeTypes', $basePath);
59
    Feature::register('RemoveEditor', $basePath);
60
    Feature::register('TinyMce', $basePath);
61
    Feature::register('BaseStyle', $basePath);
62
63
    // add components previews
64
    Feature::register('AdminComponentPreview', $basePath);
65
66
    // google analytics
67
    Feature::register('GoogleAnalytics', $basePath);
68
69
    // hide protected posts
70
    Feature::register('HideProtectedPosts', $basePath);
71
72
    // move yoast seo plugin box to the bottom of the backend interface
73
    Feature::register('YoastToBottom', $basePath);
74
75
    Feature::register('PasswordForm', $basePath);
76
    Feature::register('ExternalScriptLoader', $basePath);
77
    Feature::register('Lodash', $basePath);
78
    Feature::register('ComponentLogServer', $basePath);
79
80
    do_action('Flynt/afterRegisterFeatures');
81
}
82
83
function loadComponents()
84
{
85
    $basePath = get_template_directory() . '/dist/Components';
86
    global $flyntCurrentOptionCategory;
87
    $flyntCurrentOptionCategory = 'component';
88
    Flynt\registerComponentsFromPath($basePath);
89
    do_action('Flynt/afterRegisterComponents');
90
}
91