Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
16.67% |
2 / 12 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Sidebar | |
9.09% |
1 / 11 |
|
50.00% |
1 / 2 |
16.02 | |
0.00% |
0 / 1 |
| init | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| enqueueBlockAssets | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(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 | |
| 15 | namespace Beyondwords\Wordpress\Component\Post\Sidebar; |
| 16 | |
| 17 | use Beyondwords\Wordpress\Component\Settings\SettingsUtils; |
| 18 | use Beyondwords\Wordpress\Core\CoreUtils; |
| 19 | |
| 20 | /** |
| 21 | * Sidebar |
| 22 | * |
| 23 | * @since 3.0.0 |
| 24 | */ |
| 25 | defined('ABSPATH') || exit; |
| 26 | |
| 27 | class Sidebar |
| 28 | { |
| 29 | /** |
| 30 | * Init. |
| 31 | * |
| 32 | * @since 4.0.0 |
| 33 | * @since 6.0.0 Make static. |
| 34 | */ |
| 35 | public static function init() |
| 36 | { |
| 37 | add_action('enqueue_block_assets', [self::class, 'enqueueBlockAssets']); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Enqueue Block Editor assets. |
| 42 | * |
| 43 | * @since 6.0.0 Make static. |
| 44 | */ |
| 45 | public static function enqueueBlockAssets() |
| 46 | { |
| 47 | if (CoreUtils::isGutenbergPage()) { |
| 48 | $postType = get_post_type(); |
| 49 | |
| 50 | $postTypes = SettingsUtils::getCompatiblePostTypes(); |
| 51 | |
| 52 | if (in_array($postType, $postTypes)) { |
| 53 | // Register the Block Editor "Sidebar" CSS |
| 54 | wp_enqueue_style( |
| 55 | 'beyondwords-Sidebar', |
| 56 | BEYONDWORDS__PLUGIN_URI . 'src/Component/Post/Sidebar/PostSidebar.css', |
| 57 | [], |
| 58 | BEYONDWORDS__PLUGIN_VERSION |
| 59 | ); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |