-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.php
128 lines (109 loc) · 3.62 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace Blujay\Setup;
/**
* Register some useful constants
*/
define('THEMEDIR', get_template_directory_uri());
define('ASSETDIR', THEMEDIR . '/assets');
define('DISTDIR', THEMEDIR . '/dist');
/**
* Theme setup
*/
function theme_setup()
{
// Make theme available for translation
load_theme_textdomain('blujay', get_template_directory() . '/lang');
// Add default posts and comments RSS feed links to head
add_theme_support('automatic-feed-links');
// Enable support for Post Thumbnails on posts and pages
add_theme_support('post-thumbnails');
// Enable plugins to manage the document title
add_theme_support('title-tag');
// Enable support for Post Formats
add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'));
// Enable support for HTML5 markup
add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption'));
}
add_action('after_setup_theme', __NAMESPACE__ . '\\theme_setup');
/**
* Enable and/or disable theme helpers
*/
function enable_theme_helpers()
{
// Cleanup header
add_action('init', '\Blujay\Helpers\cleanup_header');
add_action('init', '\Blujay\Helpers\disable_rest_and_oembed');
add_action('init', '\Blujay\Helpers\disable_emoji');
// Move scripts to footer
add_action('wp_enqueue_scripts', '\Blujay\Helpers\move_js_to_footer');
// Add page and post slugs to body class
add_filter('body_class', '\Blujay\Helpers\add_classes_to_body');
// Add custom image sizes to media library
add_filter('image_size_names_choose', '\Blujay\Helpers\add_custom_image_sizes_to_media_library');
// Enable execution of shortcodes in widgets
add_action('init', '\Blujay\Helpers\enable_shortcodes_in_html_widget');
}
add_action('after_setup_theme', __NAMESPACE__ . '\\enable_theme_helpers');
/**
* Register assets
*/
function register_assets()
{
// Scripts
wp_enqueue_script(
'main-scripts',
get_template_directory_uri() . '/dist/scripts/main.js',
array('jquery'),
filemtime(get_template_directory() . '/dist/scripts/main.js'),
true
);
// Styles
wp_enqueue_style(
'main-styles',
get_template_directory_uri() . '/dist/styles/main.css',
array(),
filemtime(get_template_directory() . '/dist/styles/main.css')
);
}
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\register_assets');
/**
* Register menus
*/
register_nav_menus(array(
'primary' => __('Primary Menu', 'blujay'),
));
/**
* Register custom image sizes
*/
function add_image_sizes()
{
// Example custom image size
// add_image_size('featured', '350', '200', true);
}
add_action('init', __NAMESPACE__ . '\\add_image_sizes');
/**
* Register sidebar and widget areas
*/
function widgets_init()
{
register_sidebar(array(
'name' => __('Primary Sidebar', 'blujay'),
'id' => 'primary-sidebar',
'description' => 'Widgets displayed in the blog sidebar.',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => __('Footer Widgets', 'blujay'),
'id' => 'footer-widgets',
'description' => 'Select up to three widgets for display in the footer.',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');
?>