Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
182 lines (162 loc) · 3.92 KB
/
Copy pathfunctions.php
File metadata and controls
182 lines (162 loc) · 3.92 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
<?php
/**
* OK Network Chapter functions and definitions.
*
* @package OKFN_Chapter
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Sets up theme defaults and registers support for WordPress features.
*
* @return void
*/
function okfn_chapter_setup() {
load_theme_textdomain( 'okfn-chapter', get_template_directory() . '/languages' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'editor-styles' );
add_editor_style( 'styles/fonts.css' );
add_editor_style( 'styles/tokens.css' );
add_editor_style( 'styles/components.css' );
add_theme_support(
'custom-logo',
array(
'height' => 90,
'width' => 320,
'flex-height' => true,
'flex-width' => true,
)
);
}
add_action( 'after_setup_theme', 'okfn_chapter_setup' );
/**
* Enqueues front-end styles.
*
* @return void
*/
function okfn_chapter_enqueue_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
wp_enqueue_style(
'okfn-chapter-fonts',
get_template_directory_uri() . '/styles/fonts.css',
array(),
$theme_version
);
wp_enqueue_style(
'okfn-chapter-tokens',
get_template_directory_uri() . '/styles/tokens.css',
array( 'okfn-chapter-fonts' ),
$theme_version
);
wp_enqueue_style(
'okfn-chapter-components',
get_template_directory_uri() . '/styles/components.css',
array( 'okfn-chapter-tokens' ),
$theme_version
);
}
add_action( 'wp_enqueue_scripts', 'okfn_chapter_enqueue_styles' );
/**
* Drops the core Google Fonts collection so Site Editor cannot pull remote webfonts.
* HK Grotesk and Necto Mono are self-hosted under SIL OFL 1.1.
*
* @return void
*/
function okfn_chapter_disable_remote_font_collections() {
if ( function_exists( 'wp_unregister_font_collection' ) ) {
wp_unregister_font_collection( 'google-fonts' );
}
}
add_action( 'init', 'okfn_chapter_disable_remote_font_collections' );
/**
* Registers the OK Network pattern category.
*
* @return void
*/
function okfn_chapter_register_pattern_category() {
register_block_pattern_category(
'okfn',
array(
'label' => __( 'OK Network', 'okfn-chapter' ),
'description' => __( 'Chapter layouts ported from the Open Knowledge visual identity.', 'okfn-chapter' ),
)
);
}
add_action( 'init', 'okfn_chapter_register_pattern_category' );
/**
* Registers block styles that match Django CMS components.
*
* @return void
*/
function okfn_chapter_register_block_styles() {
register_block_style(
'core/button',
array(
'name' => 'pill',
'label' => __( 'Pill', 'okfn-chapter' ),
)
);
register_block_style(
'core/button',
array(
'name' => 'fill-white',
'label' => __( 'White fill', 'okfn-chapter' ),
)
);
register_block_style(
'core/heading',
array(
'name' => 'highlight',
'label' => __( 'Highlight (mono)', 'okfn-chapter' ),
)
);
register_block_style(
'core/group',
array(
'name' => 'orb-blue',
'label' => __( 'Blue orb', 'okfn-chapter' ),
)
);
register_block_style(
'core/group',
array(
'name' => 'orb-green',
'label' => __( 'Green orb', 'okfn-chapter' ),
)
);
register_block_style(
'core/group',
array(
'name' => 'orb-purple',
'label' => __( 'Purple orb', 'okfn-chapter' ),
)
);
register_block_style(
'core/group',
array(
'name' => 'orb-yellow',
'label' => __( 'Yellow orb', 'okfn-chapter' ),
)
);
}
add_action( 'init', 'okfn_chapter_register_block_styles' );
/**
* Falls back to the bundled OKFN wordmark when no custom logo is set.
*
* @param string $html Custom logo HTML.
* @return string
*/
function okfn_chapter_default_logo( $html ) {
if ( $html ) {
return $html;
}
$src = get_template_directory_uri() . '/assets/images/lg-okfn.svg';
return sprintf(
'<a href="%1$s" class="custom-logo-link" rel="home"><img src="%2$s" class="custom-logo" alt="%3$s" width="180" height="51"/></a>',
esc_url( home_url( '/' ) ),
esc_url( $src ),
esc_attr( get_bloginfo( 'name' ) )
);
}
add_filter( 'get_custom_logo', 'okfn_chapter_default_logo' );