Passed
Push — master ( 70b091...3b468f )
by Virginia
01:35
created

gutenberg.php ➔ load_gutenberg_admin_style()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * LSX functions to make theme Gutenberg compatible
4
 *
5
 * @package    lsx
6
 * @subpackage Gutenberg
7
 */
8
9
if ( ! defined( 'ABSPATH' ) ) {
10
	exit;
11
}
12
13
// Enqueue Admin styles on admin area
14
function load_gutenberg_admin_style() {
15
	wp_enqueue_style( 'admin_css', get_template_directory_uri() . '/assets/css/admin/gutenberg-admin.css', false, '1.0.0' );
16
}
17
add_action( 'admin_enqueue_scripts', 'load_gutenberg_admin_style' );
18
19
// Gutenberg Compatibility
20
require_once( get_template_directory() . '/lib/theme-support.php' );
21
22
/**
23
 * Add custom class for Gutenberg Compatible template
24
 */
25
26
function add_gutenberg_compatible_body_class( $classes ) {
27
	if ( ! is_home() && ! is_front_page() )
28
		if ( is_page() || is_page_template() || is_single() )
29
			$classes[] = 'gutenberg-compatible-template';
30
		return $classes;
31
32
}
33
34
add_filter( 'body_class', __NAMESPACE__ . '\add_gutenberg_compatible_body_class' );
35
36
// Add custom class for templates that are using the Gutengerg editor
37
add_action('body_class', function( $classes ) {
38
	if ( has_blocks( get_the_ID() ) )
39
		$classes[] = 'using-gutenberg';
40
	return $classes;
41
});
42