| Conditions | 2 |
| Paths | 2 |
| Total Lines | 73 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 32 | function loadFeatures() |
||
| 33 | { |
||
| 34 | $basePath = get_template_directory() . '/dist/Features'; |
||
| 35 | |||
| 36 | if (!is_dir($basePath)) { |
||
| 37 | trigger_error( |
||
| 38 | "Failed loading Features! {$basePath} does not exist! Did you run `flynt start` yet?", |
||
| 39 | E_USER_WARNING |
||
| 40 | ); |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | Feature::register('flynt-youtube-no-cookie-embed', $basePath); |
||
| 45 | |||
| 46 | // register all components in 'Components' folder |
||
| 47 | Feature::register('flynt-components', $basePath, [get_template_directory() . '/dist/Components/']); |
||
| 48 | |||
| 49 | // register all custom post types |
||
| 50 | Feature::register('flynt-custom-post-types', $basePath, [[ |
||
| 51 | 'dir' => get_template_directory() . '/config/customPostTypes/', |
||
| 52 | 'fileName' => 'config.json' |
||
| 53 | ]]); |
||
| 54 | |||
| 55 | // register all custom taxonomies |
||
| 56 | Feature::register('flynt-custom-taxonomies', $basePath, [[ |
||
| 57 | 'dir' => get_template_directory() . '/config/customTaxonomies/' |
||
| 58 | ]]); |
||
| 59 | |||
| 60 | // initialize ACF Field Groups and Option Pages |
||
| 61 | Feature::register('flynt-acf', $basePath, [[ |
||
| 62 | 'FieldLoader', |
||
| 63 | 'FieldGroupComposer', |
||
| 64 | 'OptionPages', |
||
| 65 | 'FlexibleContentToggle', |
||
| 66 | 'GoogleMaps' |
||
| 67 | ]]); |
||
| 68 | |||
| 69 | // enable admin notices |
||
| 70 | Feature::register('flynt-admin-notices', $basePath); |
||
| 71 | |||
| 72 | // use timber rendering |
||
| 73 | Feature::register('flynt-timber-loader', $basePath); |
||
| 74 | |||
| 75 | // load jQuery in footer by default |
||
| 76 | Feature::register('flynt-jquery', $basePath); |
||
| 77 | |||
| 78 | // clean up some things |
||
| 79 | Feature::register('flynt-clean-head', $basePath); |
||
| 80 | Feature::register('flynt-clean-rss', $basePath); |
||
| 81 | Feature::register('flynt-mime-types', $basePath); |
||
| 82 | Feature::register('flynt-remove-editor', $basePath); |
||
| 83 | Feature::register('flynt-tiny-mce', $basePath); |
||
| 84 | Feature::register('flynt-base-style', $basePath); |
||
| 85 | |||
| 86 | // add components previews |
||
| 87 | Feature::register('flynt-admin-component-preview', $basePath); |
||
| 88 | |||
| 89 | // google analytics |
||
| 90 | Feature::register('flynt-google-analytics', $basePath); |
||
| 91 | |||
| 92 | // hide protected posts |
||
| 93 | Feature::register('flynt-hide-protected-posts', $basePath); |
||
| 94 | |||
| 95 | // move yoast seo plugin box to the bottom of the backend interface |
||
| 96 | Feature::register('flynt-yoast-to-bottom', $basePath); |
||
| 97 | |||
| 98 | Feature::register('flynt-password-form', $basePath); |
||
| 99 | Feature::register('flynt-external-script-loader', $basePath); |
||
| 100 | Feature::register('flynt-lodash', $basePath); |
||
| 101 | Feature::register('flynt-component-log-server', $basePath); |
||
| 102 | |||
| 103 | do_action('Flynt/afterRegisterFeatures', $basePath); |
||
| 104 | } |
||
| 105 |