-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
191 lines (162 loc) · 5.62 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
<?php
/**
* This file adds functions to the UniBlock WordPress theme.
*
* @package UniBlock
* @author WPZOOM
* @license GNU General Public License v2 or later
* @link https://www.wpzoom.com/
*/
if ( ! function_exists( 'uniblock_setup' ) ) {
/**
* Sets up theme defaults and registers 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 for post thumbnails.
*
* @since 1.0.0
*
* @return void
*/
function uniblock_setup() {
// Make theme available for translation.
load_theme_textdomain( 'uniblock', get_template_directory() . '/languages' );
// Enqueue editor styles and fonts.
add_editor_style(
array(
'./style.css',
)
);
// Remove core block patterns.
remove_theme_support( 'core-block-patterns' );
register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'uniblock' ) ) );
}
}
add_action( 'after_setup_theme', 'uniblock_setup' );
// Enqueue style sheet.
add_action( 'wp_enqueue_scripts', 'uniblock_enqueue_style_sheet' );
function uniblock_enqueue_style_sheet() {
wp_enqueue_style( 'uniblock', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
}
/**
* Register block styles.
*
* @since 1.0.0
*/
function uniblock_register_block_styles() {
$block_styles = array(
'core/button' => array(
'fill-background' => __( 'Fill Background', 'uniblock' ),
'outline-background' => __( 'Outline Background', 'uniblock' ),
),
'core/group' => array(
'shadow' => __( 'Shadow', 'uniblock' ),
'border' => __( 'Border', 'uniblock' ),
'full-height' => __( 'Full-height', 'uniblock' ),
),
'core/cover' => array(
'round-corners' => __( 'Rounded', 'uniblock' ),
),
'core/column' => array(
'shadow' => __( 'Shadow', 'uniblock' ),
'border' => __( 'Border', 'uniblock' ),
'pull-right' => __( 'Pull right', 'uniblock' ),
'pull-left' => __( 'Pull left', 'uniblock' ),
),
'core/image' => array(
'shadow' => __( 'Shadow', 'uniblock' ),
),
'core/list' => array(
'no-disc' => __( 'No Disc', 'uniblock' ),
),
'core/media-text' => array(
'shadow-media' => __( 'Shadow', 'uniblock' ),
),
'core/navigation-link' => array(
'fill' => __( 'Fill', 'uniblock' ),
'fill-background' => __( 'Fill Background', 'uniblock' ),
'outline' => __( 'Outline', 'uniblock' ),
'outline-background' => __( 'Outline Background', 'uniblock' ),
),
);
foreach ( $block_styles as $block => $styles ) {
foreach ( $styles as $style_name => $style_label ) {
register_block_style(
$block,
array(
'name' => $style_name,
'label' => $style_label,
)
);
}
}
}
add_action( 'init', 'uniblock_register_block_styles' );
/**
* Registers block categories, and type.
*
* @since 1.0
*/
if ( ! function_exists( 'uniblock_register_block_pattern_categories' ) ) {
function uniblock_register_block_pattern_categories() {
/* Functionality specific to the Block Pattern Explorer plugin. */
if ( function_exists( 'register_block_pattern_category_type' ) ) {
register_block_pattern_category_type( 'uniblock', array( 'label' => __( 'uniblock', 'uniblock' ) ) );
}
$block_pattern_categories = array(
'uniblock-footer' => array(
'label' => __( 'Footer', 'uniblock' ),
'categoryTypes' => array( 'uniblock' ),
),
'uniblock-general' => array(
'label' => __( 'Sections', 'uniblock' ),
'categoryTypes' => array( 'uniblock' ),
),
'uniblock-header' => array(
'label' => __( 'Header', 'uniblock' ),
'categoryTypes' => array( 'uniblock' ),
),
'uniblock-page' => array(
'label' => __( 'Pages', 'uniblock' ),
'categoryTypes' => array( 'uniblock' ),
),
'uniblock-query' => array(
'label' => __( 'Blog Posts', 'uniblock' ),
'categoryTypes' => array( 'uniblock' ),
),
);
foreach ( $block_pattern_categories as $name => $properties ) {
register_block_pattern_category( $name, $properties );
}
}
add_action( 'init', 'uniblock_register_block_pattern_categories', 9 );
}
// Theme Admin Page
require get_template_directory() . '/inc/admin/theme-admin.php';
/*--------------------------------------------------------------
# Enqueue Admin Scripts and Styles
--------------------------------------------------------------*/
if ( ! function_exists( 'uniblock_admin_scripts' ) ) :
function uniblock_admin_scripts() {
wp_enqueue_style( 'uniblock-admin-styles', get_template_directory_uri() . '/assets/admin/css/admin-styles.css' );
}
add_action( 'admin_enqueue_scripts', 'uniblock_admin_scripts' );
endif;
/* Add the link to the Customizer */
// add_action('customize_register', function ( $manager ) { }, 10, 1 );
add_action( 'init', 'uniblock_font_collections' );
function uniblock_font_collections() {
/* Register a collection of recommended fonts */
wp_register_font_collection( 'uniblock', [
'name' => __( 'UniBlock', 'themeslug' ),
'description' => __( 'A collection of fantasy fonts.', 'themeslug' ),
'font_families' => get_theme_file_path( 'assets/fonts/uniblock.json' ),
'categories' => [
[
'name' => __( 'Display', 'themeslug' ),
'slug' => 'display'
]
]
] );
}