-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.php
147 lines (121 loc) · 4.29 KB
/
functions.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Functions.php is the home of code used across the theme and can enable
* functionality in the WordPress dashboard menu such as featured images and
* sidebars.
*
*
* Resources: https://developer.wordpress.org/themes/basics/theme-functions/
*
* Table of Contents:
* #SETUP - Theme basic set-up and functionality
* #SCRIPTS - Enqueue styles and scripts
* #MENUS - Register menus
* #WIDGETS - Enqueue widget areas (sidebars and footers)
*
* In a more extensive theme, you would split these sections into
* individual .php files in an "includes" or "inc" folder
*/
/* =============================================================================
#SETUP - Theme basic set-up and functionality
*/
// Make all functions "pluggable" with if wrappers so a child theme can override
if ( ! function_exists( 'bareminimum_setup' ) ) {
function bareminimum_setup() {
// Let WordPress automatically generate the <head>'s <title> tag for SEO
add_theme_support( 'title-tag' );
// Add RSS feed links to the document <head>
add_theme_support( 'automatic-feed-links' );
/**
* Enable featured images (post thumbnails), commonly displayed on index,
* archive, and blog pages and also used as the thumbnail image when sharing
* to social media
*/
add_theme_support( 'post-thumbnails' );
/**
* Update default WordPress core markup tags to modern HTML5 code for this
* array of items - comments, search form, gallery images, photo captions
*/
add_theme_support( 'html5', array(
'comment-list',
'comment-form',
'search-form',
'gallery',
'caption' )
);
/**
* Add theme support for selective refresh for widgets to allow
* Customizer editing without a full page reload.
*
* Not strictly "bare minimum" but basic and nice to have
*/
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Other common functions you might add here:
* Post formats (a la Tumblr style)
* Content width
* Custom Theme background (color or image)
* Custom Header
* Custom Logo
* Additional image sizes
*/
}
add_action( 'after_setup_theme', 'bareminimum_setup' );
} // don't forget to close the pluggable if statement
/* =============================================================================
#SCRIPTS - Enqueue styles and scripts
*/
if ( ! function_exists( 'bareminimum_enqueue_scripts' ) ) {
function bareminimum_enqueue_scripts() {
// Load main stylesheet
wp_enqueue_style( 'style', get_stylesheet_uri() );
// naturally we can load jQuery and any other scripts from here
}
add_action( 'wp_enqueue_scripts', 'bareminimum_enqueue_scripts' );
}
/* =============================================================================
#MENUS - Register menus
*/
// Register main menu
function bareminimum_register_menus() {
register_nav_menu( 'main_menu', 'Main Menu' );
}
add_action( 'after_setup_theme', 'bareminimum_register_menus' );
/* Print this menu in the theme template by copying this code:
<?php if (has_nav_menu( 'main_menu') :
wp_nav_menu(array('theme_location' => 'main_menu'));
endif; ?>
*/
/* =============================================================================
#WIDGETS - Enqueue widget areas (sidebars and footers)
*/
function bareminimum_register_widget_areas() {
// Add whatever wrappers and classes you need for styling
// The before/after keys have WordPress defaults and can be skipped
$footer = array(
'name' => 'Footer widgets', // Displays in the WP dashboard
'id' => 'footer_widgets', // must be lowercase
'description' => '',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
);
register_sidebar( $footer );
/* Print this widget space in a theme template page by copying this code:
<?php if ( is_active_sidebar( 'footer_widgets' ) ) :
dynamic_sidebar( 'footer_widgets' );
endif; ?>
*/
$sidebar = array(
'name' => 'Sidebar',
'id' => 'sidebar_widgets', // must be lowercase
'description' => '',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
);
register_sidebar( $sidebar );
}
add_action( 'widgets_init', 'bareminimum_register_widget_areas' );