Completed
Push — constructionplanless ( cb84a3...5132cc )
by Dominik
01:29
created

Init.php ➔ loadFeatures()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 53
rs 9.0254
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
15
function initTheme()
16
{
17
    // initialize plugin defaults
18
    Flynt\initDefaults();
19
20
    // Set to true to load all assets from a CDN if there is one specified
21
    Asset::loadFromCdn(false);
22
23
    // WP Stuff
24
    add_theme_support('title-tag');
25
    add_theme_support('post-thumbnails');
26
27
    new Timber();
28
}
29
30
function loadFeatures()
31
{
32
    $basePath = get_template_directory() . '/dist/Features';
33
34
    Feature::register('flynt-youtube-no-cookie-embed', $basePath);
35
36
    // register all components in 'Components' folder
37
    Feature::register('flynt-components', $basePath, [get_template_directory() . '/dist/Components/']);
38
39
    // initialize ACF Field Groups and Option Pages
40
    Feature::register('flynt-acf', $basePath, [[
41
        'FieldLoader',
42
        'OptionPages',
43
        'FlexibleContentToggle',
44
        'GoogleMaps'
45
    ]]);
46
47
    // enable admin notices
48
    Feature::register('flynt-admin-notices', $basePath);
49
50
    // use timber rendering
51
    Feature::register('flynt-timber-loader', $basePath);
52
53
    // load jQuery in footer by default
54
    Feature::register('flynt-jquery', $basePath);
55
56
    // clean up some things
57
    Feature::register('flynt-clean-head', $basePath);
58
    Feature::register('flynt-clean-rss', $basePath);
59
    Feature::register('flynt-mime-types', $basePath);
60
    Feature::register('flynt-remove-editor', $basePath);
61
    Feature::register('flynt-tiny-mce', $basePath);
62
    Feature::register('flynt-base-style', $basePath);
63
64
    // add components previews
65
    Feature::register('flynt-admin-component-preview', $basePath);
66
67
    // google analytics
68
    Feature::register('flynt-google-analytics', $basePath);
69
70
    // hide protected posts
71
    Feature::register('flynt-hide-protected-posts', $basePath);
72
73
    // move yoast seo plugin box to the bottom of the backend interface
74
    Feature::register('flynt-yoast-to-bottom', $basePath);
75
76
    Feature::register('flynt-password-form', $basePath);
77
    Feature::register('flynt-external-script-loader', $basePath);
78
    Feature::register('flynt-lodash', $basePath);
79
    Feature::register('flynt-component-log-server', $basePath);
80
81
    do_action('Flynt/afterRegisterFeatures', $basePath);
82
}
83