-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfunctions.php
More file actions
166 lines (154 loc) · 4.29 KB
/
functions.php
File metadata and controls
166 lines (154 loc) · 4.29 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
<?php
/**
* lsx-demo-theme functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Twenty_Twenty_Five
* @since lsx-demo-theme 1.0
*/
// Adds theme support for post formats.
if ( ! function_exists( 'lsx_demo_theme_post_format_setup' ) ) :
/**
* Adds theme support for post formats.
*
* @since lsx-demo-theme 1.0
*
* @return void
*/
function lsx_demo_theme_post_format_setup() {
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
}
endif;
add_action( 'after_setup_theme', 'lsx_demo_theme_post_format_setup' );
// Enqueues editor-style.css in the editors.
if ( ! function_exists( 'lsx_demo_theme_editor_style' ) ) :
/**
* Enqueues editor-style.css in the editors.
*
* @since lsx-demo-theme 1.0
*
* @return void
*/
function lsx_demo_theme_editor_style() {
add_editor_style( get_parent_theme_file_uri( 'assets/css/editor-style.css' ) );
}
endif;
add_action( 'after_setup_theme', 'lsx_demo_theme_editor_style' );
// Enqueues style.css on the front.
if ( ! function_exists( 'lsx_demo_theme_enqueue_styles' ) ) :
/**
* Enqueues style.css on the front.
*
* @since lsx-demo-theme 1.0
*
* @return void
*/
function lsx_demo_theme_enqueue_styles() {
wp_enqueue_style(
'lsx-demo-theme-style',
get_parent_theme_file_uri( 'style.css' ),
array(),
wp_get_theme()->get( 'Version' )
);
}
endif;
add_action( 'wp_enqueue_scripts', 'lsx_demo_theme_enqueue_styles' );
// Registers custom block styles.
if ( ! function_exists( 'lsx_demo_theme_block_styles' ) ) :
/**
* Registers custom block styles.
*
* @since lsx-demo-theme 1.0
*
* @return void
*/
function lsx_demo_theme_block_styles() {
register_block_style(
'core/list',
array(
'name' => 'checkmark-list',
'label' => __( 'Checkmark', 'lsx-demo-theme' ),
'inline_style' => '
ul.is-style-checkmark-list {
list-style-type: "\2713";
}
ul.is-style-checkmark-list li {
padding-inline-start: 1ch;
}',
)
);
}
endif;
add_action( 'init', 'lsx_demo_theme_block_styles' );
// Registers pattern categories.
if ( ! function_exists( 'lsx_demo_theme_pattern_categories' ) ) :
/**
* Registers pattern categories.
*
* @since lsx-demo-theme 1.0
*
* @return void
*/
function lsx_demo_theme_pattern_categories() {
register_block_pattern_category(
'lsx_demo_theme_page',
array(
'label' => __( 'Pages', 'lsx-demo-theme' ),
'description' => __( 'A collection of full page layouts.', 'lsx-demo-theme' ),
)
);
register_block_pattern_category(
'lsx_demo_theme_post-format',
array(
'label' => __( 'Post formats', 'lsx-demo-theme' ),
'description' => __( 'A collection of post format patterns.', 'lsx-demo-theme' ),
)
);
register_block_pattern_category(
'lsx_demo_theme_pricing',
array(
'label' => __( 'Pricing', 'lsx-demo-theme' ),
'description' => __( 'A collection of pricing table patterns and layouts.', 'lsx-demo-theme' ),
)
);
}
endif;
add_action( 'init', 'lsx_demo_theme_pattern_categories' );
// Registers block binding sources.
if ( ! function_exists( 'lsx_demo_theme_register_block_bindings' ) ) :
/**
* Registers the post format block binding source.
*
* @since lsx-demo-theme 1.0
*
* @return void
*/
function lsx_demo_theme_register_block_bindings() {
register_block_bindings_source(
'lsx-demo-theme/format',
array(
'label' => _x( 'Post format name', 'Label for the block binding placeholder in the editor', 'lsx-demo-theme' ),
'get_value_callback' => 'lsx_demo_theme_format_binding',
)
);
}
endif;
add_action( 'init', 'lsx_demo_theme_register_block_bindings' );
// Registers block binding callback function for the post format name.
if ( ! function_exists( 'lsx_demo_theme_format_binding' ) ) :
/**
* Callback function for the post format name block binding source.
*
* @since lsx-demo-theme 1.0
*
* @return string|void Post format name, or nothing if the format is 'standard'.
*/
function lsx_demo_theme_format_binding() {
$post_format_slug = get_post_format();
if ( $post_format_slug && 'standard' !== $post_format_slug ) {
return get_post_format_string( $post_format_slug );
}
}
endif;