-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
272 lines (213 loc) · 6.52 KB
/
functions.php
File metadata and controls
272 lines (213 loc) · 6.52 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<?php
/**
* upTown functions and definitions
*
* @package upTown
*/
/**
* Set the content width based on the theme's design and stylesheet
*
* @since 1.0
*/
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
define( 'UPTOWN_THEME_DIR', trailingslashit( get_template_directory() ) );
define( 'UPTOWN_THEME_URI', trailingslashit( get_template_directory_uri() ) );
$uptown_theme = wp_get_theme( 'uptown' );
if ( $uptown_theme->exists() ) {
$theme = wp_get_theme();
$version = $theme->Version; // get theme version
unset( $theme );
// force css load on local web server
if ( in_array( wp_get_environment_type(), array( 'development', 'local' ) ) ) {
$version = time();
}
define( 'UPTOWN_THEME_VERSION', $version );
}
else {
global $wp_version;
define( 'UPTOWN_THEME_VERSION', esc_html( $wp_version ) );
}
/**
* Load CSS
*/
if ( ! function_exists( 'uptown_load_styles' ) ) {
function uptown_load_styles(): void {
wp_enqueue_style( 'uptown',
get_template_directory_uri() . '/css/main.min.css',
array(),
UPTOWN_THEME_VERSION,
'all'
);
}
add_action( 'wp_enqueue_scripts', 'uptown_load_styles', 15 );
}
/**
* Sets up theme defaults and register support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* @since 1.0
*/
if ( ! function_exists( 'uptown_setup' ) ) {
function uptown_setup() {
/**
* Add default posts and comment RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
'height' => 35,
'width' => 130,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
/**
* Enable support for Post Thumbnails on posts and pages
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
// Set post-thumbnail size
set_post_thumbnail_size( 300, 167, true );
// Set custom image size 'big'
add_image_size( 'big', 640, 360, true );
// Set custom image size 'full'
add_image_size( 'full', 980, 450, true );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'uptown' ),
) );
/**
* Set up the WordPress core custom background feature.
*/
add_theme_support( 'custom-background', apply_filters( 'uptown_custom_background_args', array(
'default-color' => 'e2e2e2',
'default-image' => '',
) ) );
/**
* Add post editor style.
*/
add_editor_style( 'css/style-editor.min.css' );
/**
* Enable support for responsive-embeds feature
*
* @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#responsive-embedded-content
*/
add_theme_support( 'responsive-embeds' );
/**
* Enable support for wp-block-styles feature
*
* @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#opinionated-block-styles
*/
add_theme_support( 'wp-block-styles' );
/**
* Enable support for wide alignment feature
*
* @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#wide-alignment
*/
add_theme_support( 'align-wide' );
/**
* Enable HTML5 feature to allow the use of HTML5 markup
*
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#parameters
* @link https://codex.wordpress.org/Theme_Markup
*/
$args = array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'meta',
'style',
'script',
);
add_theme_support( 'html5', $args );
/**
* Enable to add custom CSS support
*
* @link https://github.com/WordPress/gutenberg/pull/49396
*/
// add_theme_support( 'register_block_style' );
/**
* Enable to use block patterns
*/
// add_theme_support( 'register_block_pattern' );
}
} // endif uptown_setup
add_action( 'after_setup_theme', 'uptown_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*
* @since 1.0
*/
add_action( 'widgets_init', 'uptown_widgets_init' );
function uptown_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'uptown' ),
'id' => 'sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="title"><h3 class="widget-title">',
'after_title' => '</h3></div>',
) );
}
/**
* Enqueue scripts and styles
*
* @since 1.0
*/
add_action( 'wp_enqueue_scripts', 'uptown_scripts' );
function uptown_scripts() {
wp_enqueue_style( 'uptown-style', get_stylesheet_uri() );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
if ( is_singular() && wp_attachment_is_image() )
wp_enqueue_script( 'uptown-keyboard-image-navigation', UPTOWN_THEME_URI . 'js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
wp_register_style( 'oswald-lora', UPTOWN_THEME_URI . 'uptown-fonts.min.css', false, UPTOWN_THEME_VERSION, 'all' );
wp_enqueue_style( 'oswald-lora');
// Accessible menu following https://github.com/argenteum/accessible-nav-wp
wp_enqueue_style( 'uptown-menu', UPTOWN_THEME_URI . 'css/menu.min.css' );
wp_enqueue_style( 'font-awesome', UPTOWN_THEME_URI . 'css/all.min.css' );
wp_enqueue_script( 'uptown-menu', UPTOWN_THEME_URI . 'js/menu.js', array( 'jquery' ), UPTOWN_THEME_VERSION, array( 'in_footer' => true ) );
wp_localize_script( 'uptown-menu', 'screenReaderText', array(
'expand' => __( 'Expand child menu', 'uptown' ),
'collapse' => __( 'Collapse child menu', 'uptown' ),
));
}
/**
* Implement helpful helper functions
*
* @since 1.0
*/
require UPTOWN_THEME_DIR . 'inc/helpers.php';
/**
* Implement the Custom Header feature
*
* @since 1.0
*/
require UPTOWN_THEME_DIR . 'inc/custom-header.php';
/**
* Custom template tags for this theme
*
* @since 1.0
*/
require UPTOWN_THEME_DIR . 'inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates
*
* @since 1.0
*/
require UPTOWN_THEME_DIR . 'inc/extras.php';
/**
* Customizer additions
*
* @since 1.0
*/
require UPTOWN_THEME_DIR . 'inc/customizer.php';