generated from germanfrelo/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
103 lines (86 loc) · 3.1 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
<?php
/**
* IMPORTANT❗️:
* Replace all instances of the word 'themeslug' with the name of your theme.
*/
/**
* Load stylesheets on the front end of the website.
*
* @link https://developer.wordpress.org/themes/core-concepts/including-assets/#front-end-stylesheets
* @link https://developer.wordpress.org/themes/advanced-topics/child-themes/#loading-style-css
*/
function themeslug_enqueue_styles() {
// Load custom stylesheets
wp_enqueue_style( 'base-style', get_theme_file_uri( 'assets/css/base.css' ) );
wp_enqueue_style( 'layouts-style', get_theme_file_uri( 'assets/css/layouts.css' ) );
wp_enqueue_style( 'utility-classes-style', get_theme_file_uri( 'assets/css/utility-classes.css' ) );
wp_enqueue_style( 'gravity-forms-style', get_theme_file_uri( 'assets/css/gravity-forms.css' ) );
// Load the theme's style.css file
wp_enqueue_style( 'themeslug-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_styles' );
/**
* Load stylesheets in the editor.
*
* @link https://developer.wordpress.org/themes/core-concepts/including-assets/#editor-stylesheets
*/
function themeslug_setup() {
add_editor_style( array(
// Load another custom stylesheets
get_theme_file_uri( 'assets/css/base.css' ),
get_theme_file_uri( 'assets/css/layouts.css' ),
get_theme_file_uri( 'assets/css/utility-classes.css' ),
get_theme_file_uri( 'assets/css/gravity-forms.css' ),
// Load the theme's style.css file
get_stylesheet_uri()
) );
}
add_action( 'after_setup_theme', 'themeslug_setup' );
/**
* Register custom block style variations.
*
* @link https://developer.wordpress.org/themes/features/block-style-variations/
* @link https://developer.wordpress.org/reference/functions/register_block_style/
*/
function themeslug_block_style_variations() {
// register_block_style(
// 'core/_____',
// array(
// 'name' => '__________',
// 'label' => __( '__________', 'themeslug' ),
// 'inline_style' => '
// .wp-block-_____.is-style-__________ {
// // Your block styles here...
// }
// '
// )
// );
}
add_action( 'init', 'themeslug_block_style_variations' );
/**
* Enqueue custom block stylesheets.
*
* @link https://developer.wordpress.org/themes/features/block-stylesheets/
* @link https://developer.wordpress.org/news/2022/12/07/leveraging-theme-json-and-per-block-styles-for-more-performant-themes/
* @link https://developer.wordpress.org/reference/functions/wp_enqueue_block_style/
*/
function themeslug_block_stylesheets() {
// Add the block name (with namespace) for each style
$blocks = array(
'core/button',
'core/navigation',
'core/query-pagination',
'core/site-logo',
);
// Loop through each block and enqueue its styles
foreach ( $blocks as $block ) {
// Replace slash with hyphen for filename
$slug = str_replace( '/', '-', $block );
wp_enqueue_block_style( $block, array(
'handle' => "themeslug-block-{$slug}",
'src' => get_theme_file_uri( "assets/css/blocks/{$slug}.css" ),
'path' => get_theme_file_path( "assets/css/blocks/{$slug}.css" )
) );
}
}
add_action( 'init', 'themeslug_block_stylesheets' );