Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Assets
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 init
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 admin_enqueue_scripts
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2/**
3 * BeyondWords Metabox — asset enqueue.
4 *
5 * @package BeyondWords\Editor\Classic
6 * @since   7.0.0
7 */
8
9declare( strict_types = 1 );
10
11namespace BeyondWords\Editor\Classic;
12
13defined( 'ABSPATH' ) || exit;
14
15/**
16 * Metabox asset enqueue.
17 *
18 * @since 7.0.0
19 */
20class Assets {
21
22    /**
23     * Register WordPress hooks.
24     */
25    public static function init(): void {
26        add_action( 'admin_enqueue_scripts', [ self::class, 'admin_enqueue_scripts' ] );
27    }
28
29    /**
30     * Enqueue Metabox CSS on classic-editor post screens for compatible post types.
31     *
32     * No API-valid check needed: class-plugin.php only calls init() with a
33     * valid API connection.
34     *
35     * @param string $hook Current admin page hook.
36     */
37    public static function admin_enqueue_scripts( $hook ): void {
38        if ( 'post.php' !== $hook && 'post-new.php' !== $hook ) {
39            return;
40        }
41
42        if ( ! in_array( get_post_type(), \BeyondWords\Settings\Utils::get_compatible_post_types(), true ) ) {
43            return;
44        }
45
46        wp_enqueue_style(
47            'beyondwords-metabox',
48            BEYONDWORDS__PLUGIN_URI . 'src/editor/classic/classic.css',
49            false,
50            BEYONDWORDS__PLUGIN_VERSION
51        );
52    }
53}