Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
9.09% covered (danger)
9.09%
1 / 11
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Sidebar
9.09% covered (danger)
9.09%
1 / 11
50.00% covered (danger)
50.00%
1 / 2
16.02
0.00% covered (danger)
0.00%
0 / 1
 init
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 enqueueBlockAssets
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5/**
6 * BeyondWords Post Inspect Panel.
7 *
8 * Text Domain: beyondwords
9 *
10 * @package Beyondwords\Wordpress
11 * @author  Stuart McAlpine <stu@beyondwords.io>
12 * @since   3.0.0
13 */
14
15namespace Beyondwords\Wordpress\Component\Post\Sidebar;
16
17use Beyondwords\Wordpress\Component\Settings\SettingsUtils;
18use Beyondwords\Wordpress\Core\CoreUtils;
19
20/**
21 * Sidebar
22 *
23 * @since 3.0.0
24 */
25class Sidebar
26{
27    /**
28     * Init.
29     *
30     * @since 4.0.0
31     */
32    public function init()
33    {
34        add_action('enqueue_block_assets', array($this, 'enqueueBlockAssets'));
35    }
36
37    public function enqueueBlockAssets()
38    {
39        if (CoreUtils::isGutenbergPage()) {
40            $postType = get_post_type();
41
42            $postTypes = SettingsUtils::getCompatiblePostTypes();
43
44            if (in_array($postType, $postTypes)) {
45                // Register the Block Editor "Sidebar" CSS
46                wp_enqueue_style(
47                    'beyondwords-Sidebar',
48                    BEYONDWORDS__PLUGIN_URI . 'src/Component/Post/Sidebar/PostSidebar.css',
49                    array(),
50                    BEYONDWORDS__PLUGIN_VERSION
51                );
52            }
53        }
54    }
55}