1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace Undefined\Stash; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Theme setup |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
function setControllers() |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Add the main language page id and name for the controller here |
13
|
|
|
*/ |
14
|
|
|
Controller::Instance()->setPages([ |
15
|
|
|
2 => "sample", |
16
|
|
|
]); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
add_action('init', __NAMESPACE__ . '\\setControllers'); |
20
|
|
|
|
21
|
|
|
function setup() |
22
|
|
|
{ |
23
|
|
|
// Enable features from Soil when plugin is activated |
24
|
|
|
// https://roots.io/plugins/soil/ |
25
|
|
|
add_theme_support('soil-clean-up'); |
26
|
|
|
add_theme_support('soil-nav-walker'); |
27
|
|
|
add_theme_support('soil-nice-search'); |
28
|
|
|
add_theme_support('soil-jquery-cdn'); |
29
|
|
|
add_theme_support('soil-relative-urls'); |
30
|
|
|
|
31
|
|
|
// Make theme available for translation |
32
|
|
|
// Community translations can be found at https://github.com/roots/sage-translations |
33
|
|
|
load_theme_textdomain('stash', get_template_directory() . '/lang'); |
34
|
|
|
|
35
|
|
|
// Enable plugins to manage the document title |
36
|
|
|
// http://codex.wordpress.org/Function_Reference/add_theme_support#Title_Tag |
37
|
|
|
add_theme_support('title-tag'); |
38
|
|
|
|
39
|
|
|
// Register wp_nav_menu() menus |
40
|
|
|
// http://codex.wordpress.org/Function_Reference/register_nav_menus |
41
|
|
|
register_nav_menus([ |
42
|
|
|
'primary_navigation' => __('Primary Navigation', 'stash') |
43
|
|
|
]); |
44
|
|
|
|
45
|
|
|
// Enable post thumbnails |
46
|
|
|
// http://codex.wordpress.org/Post_Thumbnails |
47
|
|
|
// http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size |
48
|
|
|
// http://codex.wordpress.org/Function_Reference/add_image_size |
49
|
|
|
add_theme_support('post-thumbnails'); |
50
|
|
|
|
51
|
|
|
// Enable post formats |
52
|
|
|
// http://codex.wordpress.org/Post_Formats |
53
|
|
|
add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']); |
54
|
|
|
|
55
|
|
|
// Enable HTML5 markup support |
56
|
|
|
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5 |
57
|
|
|
add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); |
58
|
|
|
|
59
|
|
|
add_theme_support('menus'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); |
63
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.