Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Plugins_Page
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 action_links
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 row_meta
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * The plugin page output of the plugin.
4 *
5 * @link
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\Settings_Interface;
14
15/**
16 * This class adds a `Settings` link on the plugins.php page.
17 */
18class Plugins_Page {
19
20    protected Settings_Interface $settings;
21
22    public function __construct( $settings ) {
23        $this->settings = $settings;
24    }
25
26    /**
27     * Add link to Settings page in plugins.php list.
28     *
29     * @hooked plugin_action_links_{basename}
30     *
31     * @param array<int|string, string> $action_links The existing plugin links (usually "Deactivate").
32     * @param ?string                   $_plugin_basename The plugin's directory/filename.php.
33     * @param ?array<int|string, mixed> $_plugin_data An array of plugin data. See `get_plugin_data()`.
34     * @param ?string                   $_context     The plugin context. 'all'|'active'|'inactive'|'recently_activated'
35     *                                               |'upgrade'|'mustuse'|'dropins'|'search'.
36     *
37     * @return array<int|string, string> The links to display below the plugin name on plugins.php.
38     */
39    public function action_links( array $links_array, ?string $_plugin_basename, ?array $_plugin_data, ?string $_context ): array {
40
41        $settings_url = admin_url( '/options-general.php?page=' . $this->settings->get_plugin_slug() );
42        array_unshift( $links_array, '<a href="' . $settings_url . '">Settings</a>' );
43
44        return $links_array;
45    }
46
47    /**
48     * Add a link to GitHub repo on the plugins list.
49     *
50     * @see https://rudrastyh.com/wordpress/plugin_action_links-plugin_row_meta.html
51     *
52     * @param string[]                  $plugin_meta The meta information/links displayed by the plugin description.
53     * @param ?string                   $plugin_file_name The plugin filename to match when filtering.
54     * @param ?array<int|string, mixed> $_plugin_data An array of plugin data. See `get_plugin_data()`.
55     * @param ?string                   $_status The plugin status, e.g. 'Inactive'.
56     *
57     * @return array The filtered $plugin_meta.
58     */
59    public function row_meta( array $plugin_meta, ?string $plugin_file_name, ?array $_plugin_data, ?string $_status ): array {
60
61        if ( $this->settings->get_plugin_basename() === $plugin_file_name ) {
62
63            foreach ( $plugin_meta as $index => $link ) {
64                $plugin_meta[ $index ] = str_replace( 'Visit plugin site', 'View plugin on GitHub', $link );
65            }
66
67            $aws_ses_console_url = 'https://console.aws.amazon.com/ses/home?region=us-east-1#home:';
68            $plugin_meta[]       = '<a target="_blank" href="' . $aws_ses_console_url . '">AWS SES Console</a>';
69
70        }
71
72        return $plugin_meta;
73    }
74
75}