-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
106 lines (72 loc) · 3.88 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
<?php
/* -----------------------------------------------------------------------------------------------
Theme Support
--------------------------------------------------------------------------------------------------- */
if(! function_exists('blocktheme_support')) :
function blocktheme_support() {
// Add support for block styles.
add_theme_support( 'wp-block-styles' );
// Enqueue editor styles.
add_editor_style('style.css');
}
endif;
add_action('after_setup_theme', 'blocktheme_support');
/* -----------------------------------------------------------------------------------------------
Enqueue Stylesheet & Scripts
--------------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'blocktheme_styles_scripts' ) ) :
function blocktheme_styles_scripts() {
$theme_version = wp_get_theme()->get( 'Version' );
$version_string = is_string( $theme_version ) ? $theme_version : false;
$in_footer = true;
wp_enqueue_style('blocktheme-style',get_theme_file_uri('/style.css'),$version_string);
wp_enqueue_script('blocktheme-app',get_theme_file_uri('/assets/js/app.js'),array(),$theme_version,$in_footer);
}
endif;
add_action('wp_enqueue_scripts', 'blocktheme_styles_scripts');
/* -----------------------------------------------------------------------------------------------
Enqeuue Blocks Styles
--------------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'blocktheme_block_styles' ) ) :
function blocktheme_block_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
$version_string = is_string( $theme_version ) ? $theme_version : false;
wp_enqueue_script('blocktheme-block-styles',get_theme_file_uri( '/assets/js/block-styles.js' ),array( 'wp-blocks' ),$theme_version,true);
}
endif;
add_action( 'enqueue_block_editor_assets', 'blocktheme_block_styles' );
/* -----------------------------------------------------------------------------------------------
Modify Excerpt
--------------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'blocktheme_excerpt_more' ) ) :
function blocktheme_excerpt_more( $more ) {
return '…';
}
endif;
add_filter( 'excerpt_more', 'blocktheme_excerpt_more' );
/* -----------------------------------------------------------------------------------------------
Register Patterns Categories
--------------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'blocktheme_register_block_patterns' ) ) :
function blocktheme_register_block_patterns() {
if( ! function_exists( 'register_block_pattern_category' ) ) return;
// The block pattern categories included in Poe.
$blocktheme_block_pattern_categories = apply_filters( 'blocktheme_block_pattern_categories', array(
'blocktheme-general' => array( 'label' => __( 'blocktheme General', 'blocktheme' ) ),
'blocktheme-footer' => array( 'label' => __( 'blocktheme Footer', 'blocktheme' ) ),
'blocktheme-header' => array( 'label' => __( 'blocktheme Header', 'blocktheme' ) ),
'blocktheme-hero' => array( 'label' => __( 'blocktheme Hero', 'blocktheme' ) ),
'blocktheme-cta' => array( 'label' => __( 'blocktheme CTA', 'blocktheme' ) ),
'blocktheme-section-label' => array( 'label' => __( 'blocktheme Section Label', 'blocktheme' ) ),
));
// Sort the block pattern categories alphabetically based on the label value, to ensure alphabetized order when the strings are localized.
uasort( $blocktheme_block_pattern_categories, function( $a, $b ) {
return strcmp( $a["label"], $b["label"] ); }
);
// Register block pattern categories.
foreach ( $blocktheme_block_pattern_categories as $slug => $settings ) {
register_block_pattern_category( $slug, $settings );
}
}
endif;
add_action( 'init', 'blocktheme_register_block_patterns' );