Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
3 / 9
33.33% covered (danger)
33.33%
1 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Admin_Assets
33.33% covered (danger)
33.33%
3 / 9
33.33% covered (danger)
33.33%
1 / 3
33.00
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 enqueue_styles
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
4
 enqueue_scripts
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2/**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link       https://BrianHenry.ie
6 * @since      1.0.0
7 *
8 * @package brianhenryie/bh-wp-aws-ses-bounce-handler
9 */
10
11namespace BrianHenryIE\AWS_SES_Bounce_Handler\Admin;
12
13use BrianHenryIE\AWS_SES_Bounce_Handler\API_Interface;
14use BrianHenryIE\AWS_SES_Bounce_Handler\Settings_Interface;
15
16/**
17 * The admin-specific functionality of the plugin.
18 *
19 * Defines the plugin name, version, and two examples hooks for how to
20 * enqueue the admin-specific stylesheet and JavaScript.
21 */
22class Admin_Assets {
23
24    protected Settings_Interface $settings;
25
26    /**
27     * @var API_Interface
28     */
29    protected API_Interface $api;
30
31    public function __construct( API_Interface $api, Settings_Interface $settings ) {
32        $this->settings = $settings;
33        $this->api      = $api;
34    }
35
36    /**
37     * Register the stylesheets for the admin area.
38     *
39     * @since    1.0.0
40     */
41    public function enqueue_styles(): void {
42        global $pagenow;
43        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
44        if ( 'options-general.php' === $pagenow && isset( $_GET['page'] ) && 'bh-wp-aws-ses-bounce-handler' === filter_var( wp_unslash( $_GET['page'] ), FILTER_SANITIZE_STRING ) ) {
45            $url = plugin_dir_url( $this->settings->get_plugin_basename() ) . 'assets/bh-wp-aws-ses-bounce-handler-admin.css';
46            wp_enqueue_style( $this->settings->get_plugin_slug(), $url, array(), $this->settings->get_plugin_version(), 'all' );
47        }
48    }
49
50    /**
51     * Register the JavaScript for the admin area.
52     *
53     * @since    1.2.0
54     */
55    public function enqueue_scripts(): void {
56        global $pagenow;
57        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
58        if ( 'options-general.php' === $pagenow && isset( $_GET['page'] ) && 'bh-wp-aws-ses-bounce-handler' === filter_var( wp_unslash( $_GET['page'] ), FILTER_SANITIZE_STRING ) ) {
59            $url     = plugin_dir_url( $this->settings->get_plugin_basename() ) . 'assets/bh-wp-aws-ses-bounce-handler-admin.js';
60            $version = $this->settings->get_plugin_version();
61            wp_enqueue_script( $this->settings->get_plugin_slug(), $url, array( 'jquery' ), $version, false );
62        }
63    }
64
65}