forked from studiopress/genesis-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·196 lines (139 loc) · 5.17 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
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
<?php
/**
* Raw Child.
*
* This file adds functions to the Raw Child Theme.
*
* @package Raw Child
* @author rawsta
* @license GPL-2.0-or-later
* @link https://github.com/rawsta/raw-child/
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// Child theme (do not remove).
define( 'CHILD_THEME_NAME', 'Raw Child' );
define( 'CHILD_THEME_URL', 'https://rawsta.de/' );
define( 'CHILD_THEME_HANDLE', sanitize_title_with_dashes( wp_get_theme()->get( 'Name' ) ) );
define( 'CHILD_THEME_VERSION', wp_get_theme()->get( 'Version' ) );
// Try minimum requirements and display error messages.
require_once get_stylesheet_directory() . '/lib/errors.php';
// TODO: don't start the engine -> https://garyjones.io/dont-start-the-engine
// Starts the engine.
require_once get_template_directory() . '/lib/init.php';
// Stop loading depriated functions
add_filter( 'genesis_load_deprecated', '__return_false' );
// Set Theme defaults.
require_once get_stylesheet_directory() . '/lib/theme-defaults.php';
// Adds helper functions.
require_once get_stylesheet_directory() . '/lib/helper-functions.php';
// Customize the backend to fit the branding.
require_once get_stylesheet_directory() . '/lib/branding.php';
// Adds image upload and color select to Customizer.
require_once get_stylesheet_directory() . '/lib/customize.php';
// Includes Customizer CSS.
require_once get_stylesheet_directory() . '/lib/output.php';
// Modifying general structure.
require_once get_stylesheet_directory() . '/lib/genesis.php';
// Modifying general structure.
require_once get_stylesheet_directory() . '/lib/structure.php';
// Modifying general structure.
require_once get_stylesheet_directory() . '/lib/template.php';
// Modifying general navigation.
require_once get_stylesheet_directory() . '/lib/navigation.php';
// Modifying Posts and Pages.
require_once get_stylesheet_directory() . '/lib/post-pages.php';
// Customize comments.
require_once get_stylesheet_directory() . '/lib/comments.php';
// Adds WooCommerce support.
require_once get_stylesheet_directory() . '/lib/woocommerce/woocommerce-setup.php';
// Adds the required WooCommerce styles and Customizer CSS.
require_once get_stylesheet_directory() . '/lib/woocommerce/woocommerce-output.php';
// Adds the Genesis Connect WooCommerce notice.
require_once get_stylesheet_directory() . '/lib/woocommerce/woocommerce-notice.php';
// Sets localization.
add_action( 'after_setup_theme', 'raw_child_localization_setup' );
function raw_child_localization_setup() {
load_child_theme_textdomain( genesis_get_theme_handle(), get_stylesheet_directory() . '/assets/languages' );
}
/**
* Adds Gutenberg opt-in features and styling.
*
* @since 1.0.0
*/
add_action( 'after_setup_theme', 'raw_child_gutenberg_support' );
function raw_child_gutenberg_support() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- using same in all child themes to allow action to be unhooked.
require_once get_stylesheet_directory() . '/lib/gutenberg/init.php';
}
// Registers the responsive menus.
if ( function_exists( 'genesis_register_responsive_menus' ) ) {
genesis_register_responsive_menus( genesis_get_config( 'responsive-menus' ) );
}
/**
* Enqueues scripts and styles.
*
* @since 1.0.0
*/
add_action( 'wp_enqueue_scripts', 'raw_child_enqueue_scripts_styles' );
function raw_child_enqueue_scripts_styles() {
$appearance = genesis_get_config( 'appearance' );
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- see https://core.trac.wordpress.org/ticket/49742
genesis_get_theme_handle() . '-fonts',
$appearance['fonts-url'],
[],
null
);
wp_enqueue_script(
genesis_get_theme_handle() . '-js',
get_stylesheet_directory_uri() . '/assets/js/rawchild.js',
[ 'jquery' ],
genesis_get_theme_version(),
true
);
}
/**
* Add preconnect for Google Fonts.
*
* @since 3.4.1
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array URLs to print for resource hints.
*/
add_filter( 'wp_resource_hints', 'raw_child_resource_hints', 10, 2 );
function raw_child_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( genesis_get_theme_handle() . '-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
$urls[] = [
'href' => 'https://fonts.gstatic.com',
'crossorigin',
];
}
return $urls;
}
/**
* Add desired theme supports.
* See config file at `config/theme-supports.php`.
*
* @since 1.0.0
*/
add_action( 'after_setup_theme', 'raw_child_theme_support', 9 );
function raw_child_theme_support() {
$theme_supports = genesis_get_config( 'theme-supports' );
foreach ( $theme_supports as $feature => $args ) {
add_theme_support( $feature, $args );
}
}
/**
* Add desired post type supports.
* See config file at `config/post-type-supports.php`.
*
* @since 1.0.0
*/
add_action( 'after_setup_theme', 'raw_child_post_type_support', 9 );
function raw_child_post_type_support() {
$post_type_supports = genesis_get_config( 'post-type-supports' );
foreach ( $post_type_supports as $post_type => $args ) {
add_post_type_support( $post_type, $args );
}
}