-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
151 lines (129 loc) · 5.41 KB
/
functions.php
File metadata and controls
151 lines (129 loc) · 5.41 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
namespace planetjon\blitch;
require 'templates.php';
// Configure theme support
function after_setup_theme() {
// HTML5 support
add_theme_support( 'html5', [ 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'style', 'script' ] );
// Title tag
add_theme_support( 'title-tag' );
// Automatic feed links support
add_theme_support( 'automatic-feed-links' );
// Custom logo support
add_theme_support( 'custom-logo',[
'width' => 718,
'height' => 80,
'flex-height' => true,
'flex-width' => true,
'header-text' => [ 'site-banner-title-text' ],
] );
// Post thumbnails support
add_theme_support( 'post-thumbnails' );
// Responsive embeds support
add_theme_support( 'responsive-embeds' );
// Custom menu support
register_nav_menu( 'primary', __( 'Primary Navigation', 'blitch' ) );
}
// Initialize widget zones
function widgets_init() {
// Site Sidebar
register_sidebar( [
'name' => __( 'Site Sidebar', 'blitch' ),
'id' => 'site-sidebar-widget-container',
'description' => __( 'For placing widgets alongside the site', 'blitch' ),
'before_widget' => '<div id="%1$s" class="site-sidebar-widget widget-box %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title title"><span class="text">',
'after_title' => '</span></h3>'
] );
// Site Topbar
register_sidebar( [
'name' => __( 'Site Topbar', 'blitch' ),
'id' => 'site-topbar-widget-container',
'description' => __( 'For placing widgets at the top of the site', 'blitch' ),
'before_widget' => '<div id="%1$s" class="site-topbar-widget widget-box %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title title"><span class="text">',
'after_title' => '</span></h3>'
] );
// Site Header
register_sidebar( [
'name' => __( 'Site Header', 'blitch' ),
'id' => 'site-header-widget-container',
'description' => __( 'For placing widgets immediately after the site header', 'blitch' ),
'before_widget' => '<div id="%1$s" class="site-header-widget widget-box %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title title"><span class="text">',
'after_title' => '</span></h3>'
] );
// Pre content
register_sidebar( [
'name' => __( 'Before Content', 'blitch' ),
'id' => 'before-content-widget-container',
'description' => __( 'For placing widgets before the content', 'blitch' ),
'before_widget' => '<div id="%1$s" class="before-content-widget widget-box %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title title"><span class="text">',
'after_title' => '</span></h3>'
] );
// Post content
register_sidebar( [
'name' => __( 'After Content', 'blitch' ),
'id' => 'after-content-widget-container',
'description' => __( 'For placing widgets after the content', 'blitch' ),
'before_widget' => '<div id="%1$s" class="after-content-widget widget-box %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title title"><span class="text">',
'after_title' => '</span></h3>'
] );
// Homepage content
register_sidebar( [
'name' => __( 'Homepage Sidebar', 'blitch' ),
'id' => 'home-page-widget-container',
'description' => __( 'For placing widgets on the homepage', 'blitch' ),
'before_widget' => '<div id="%1$s" class="home-page-widget widget-box %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title title"><span class="text">',
'after_title' => '</span></h3>'
] );
}
// Queue scripts and styles
function wp_enqueue_scripts() {
wp_register_style( 'blitch-html', get_template_directory_uri() . '/assets/css/html-styles.css' );
wp_register_style( 'blitch-styles', get_template_directory_uri() . '/assets/css/base.css', [ 'blitch-html' ] );
wp_register_style( 'blitch-archive', get_template_directory_uri() . '/assets/css/archive.css', [ 'blitch-styles' ] );
wp_register_style( 'blitch-singular', get_template_directory_uri() . '/assets/css/singular.css', [ 'blitch-styles' ] );
wp_register_style( 'blitch-responsive', get_template_directory_uri() . '/assets/css/responsive.css', [ 'blitch-styles' ] );
wp_register_style( 'blitch-wordpress', get_template_directory_uri() . '/assets/css/wordpress-styles.css', [ 'blitch-styles' ] );
wp_register_style( 'blitch-wordpress-comments', get_template_directory_uri() . '/assets/css/wordpress-comments.css', [ 'blitch-wordpress' ] );
wp_enqueue_style( 'blitch-styles' );
wp_enqueue_style( 'blitch-wordpress' );
wp_enqueue_style( 'blitch-responsive' );
if( is_singular() ) {
wp_enqueue_style( 'blitch-singular' );
wp_enqueue_style( 'blitch-wordpress-comments' );
}
if( is_archive() ) {
wp_enqueue_style( 'blitch-archive' );
}
}
// Queue core comment styling
function comment_form_before() {
if( get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
// Inject header meta
function wp_head() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1" />';
}
// When The Loop is empty
function blitch_no_results() {
printf( '<p>%s</p>', __( 'Hmmm, there\'s nothing here.', 'blitch' ) );
}
add_action( 'after_setup_theme', __NAMESPACE__ . '\after_setup_theme' );
add_action( 'widgets_init', __NAMESPACE__ . '\widgets_init' );
add_action( 'wp_head', __NAMESPACE__ . '\wp_head' );
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\wp_enqueue_scripts' );
add_action( 'comment_form_before', __NAMESPACE__ . '\comment_form_before' );
add_action( 'blitch_no_results', __NAMESPACE__ . '\blitch_no_results' );