-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
120 lines (93 loc) · 2.8 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
<?php
/**
* This file adds functions to the Shanti theme for WordPress.
*
* @package Shanti
* @author Themeist
* @license GNU General Public License v3 or later
* @link https://shanti.themeist.com/
*/
if ( ! function_exists( 'shanti_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 0.1.0
*
* @return void
*/
function shanti_setup() {
// Make theme available for translation.
load_theme_textdomain( 'shanti', get_template_directory() . '/languages' );
// Register Navigation menus.
register_nav_menus(
array(
'primary' => esc_html__( 'Primary Menu', 'shanti' ),
)
);
// Add support for block styles.
add_theme_support( 'wp-block-styles' );
// Remove core block patterns.
remove_theme_support( 'core-block-patterns' );
// Enqueue editor styles.
add_editor_style( 'style.css' );
}
}
add_action( 'after_setup_theme', 'shanti_setup' );
/**
* Restores the Customizer since we still rely on it.
*/
function shanti_restore_customizer() {
// There's no need to return anything.
// The empty callback will do the trick.
}
add_action( 'customize_register', 'shanti_restore_customizer' );
/**
* Enqueue styles.
*
* @since 0.1.0
*/
function shanti_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
$version_string = is_string( $theme_version ) ? $theme_version : false;
wp_register_style( 'shanti-style', get_template_directory_uri() . '/style.css', array(), $version_string );
// Add styles inline.
wp_add_inline_style( 'shanti-style', shanti_font_styles() );
// Enqueue theme stylesheet.
wp_enqueue_style( 'shanti-style' );
}
add_action( 'wp_enqueue_scripts', 'shanti_styles' );
/**
* Enqueue editor styles.
*
* @since 0.1.0
*/
function shanti_editor_styles() {
// Add styles inline.
wp_add_inline_style( 'wp-block-library', shanti_font_styles() );
}
add_action( 'admin_init', 'shanti_editor_styles' );
/**
* Get Google fonts and save locally with WPTT Webfont Loader.
*/
function shanti_font_styles() {
$font_families = array(
'Montserrat:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600',
);
$fonts_url = add_query_arg(
array(
'family' => implode( '&family=', $font_families ),
'display' => 'swap',
),
'https://fonts.googleapis.com/css2'
);
include_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );
return wptt_get_webfont_url( esc_url_raw( $fonts_url ) );
}
// Register theme specific block patterns
require get_template_directory() . '/inc/block-patterns.php';
// Register theme specific block styles
require get_template_directory() . '/inc/block-styles.php';