-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
111 lines (93 loc) · 2.55 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
<?php
/**
* Functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package agrippa
* @since 1.0.0
*/
/**
* The theme version.
*
* @since 1.0.0
*/
define( 'AGRIPPA_VERSION', wp_get_theme()->get( 'Version' ) );
/**
* Add theme support for block styles and editor style.
*
* @since 1.0.0
*
* @return void
*/
function agrippa_setup() {
add_editor_style( './assets/css/style-shared.min.css' );
/*
* Load additional block styles.
*/
$styled_blocks = [ 'button', 'quote', 'navigation', 'search' ];
foreach ( $styled_blocks as $block_name ) {
$args = array(
'handle' => "agrippa-$block_name",
'src' => get_theme_file_uri( "assets/css/blocks/$block_name.min.css" ),
'path' => get_theme_file_path( "assets/css/blocks/$block_name.min.css" ),
);
// Replace the "core" prefix if you are styling blocks from plugins.
wp_enqueue_block_style( "core/$block_name", $args );
}
}
add_action( 'after_setup_theme', 'agrippa_setup' );
// Load style.css on the front-end through the function wp_enqueue_scripts
/**
* Enqueue the CSS files.
*
* @since 1.0.0
*
* @return void
*/
function agrippa_styles() {
wp_enqueue_style(
'agrippa-style',
get_stylesheet_uri(), /* ->Returns the active theme’s style.css file URL*/
[],
AGRIPPA_VERSION
);
wp_enqueue_style(
'agrippa-shared-styles',
get_theme_file_uri( 'assets/css/style-shared.min.css' ),
[],
AGRIPPA_VERSION
);
}
add_action( 'wp_enqueue_scripts', 'agrippa_styles' );
// Filters.
require_once get_theme_file_path( 'inc/filters.php' );
// Block variation example.
require_once get_theme_file_path( 'inc/register-block-variations.php' );
// Block style examples.
require_once get_theme_file_path( 'inc/register-block-styles.php' );
// Block pattern and block category examples.
require_once get_theme_file_path( 'inc/register-block-patterns.php' );
// Allow SVG images to be uploaded
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4 );
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
function fix_svg() {
echo '<style type="text/css">
.attachment-266x266, .thumbnail img {
width: 100% !important;
height: auto !important;
}
</style>';
}
add_action( 'admin_head', 'fix_svg' );