PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
jetpack / jetpack_vendor / automattic / jetpack-masterbar / src / admin-menu / class-domain-only-admin-menu.php

class-domain-only-admin-menu.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3, at jetpack_vendor/automattic/jetpack-masterbar/src/admin-menu/class-domain-only-admin-menu.php

73 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Domain-only sites Admin Menu file.
4 *
5 * @package automattic/jetpack-masterbar
6 */
7
8 namespace Automattic\Jetpack\Masterbar;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit( 0 );
12 }
13
14 /**
15 * Class Domain_Only_Admin_Menu.
16 */
17 class Domain_Only_Admin_Menu extends Base_Admin_Menu {
18 /**
19 * The `WPCOM_Email_Subscription_Checker` instance used to verify if a site has an email subscription.
20 *
21 * @var WPCOM_Email_Subscription_Checker
22 */
23 private $email_subscriptions_checker;
24
25 /**
26 * Constructor that lets us pass in a WPCOM_Email_Subscription_Checker dependency.
27 *
28 * @param WPCOM_Email_Subscription_Checker $email_subscriptions_checker The WPCOM_Email_Subscription_Checker instance.
29 */
30 protected function __construct( $email_subscriptions_checker = null ) {
31 parent::__construct();
32
33 $this->email_subscriptions_checker = $email_subscriptions_checker;
34
35 if ( empty( $this->email_subscriptions_checker ) ) {
36 $this->set_email_subscription_checker( new WPCOM_Email_Subscription_Checker() );
37 }
38 }
39
40 /**
41 * This setter lets us inject an WPCOM_Email_Subscription_Checker instance.
42 *
43 * @param WPCOM_Email_Subscription_Checker $email_subscriptions_checker An WPCOM_Email_Subscription_Checker instance.
44 *
45 * @return void
46 */
47 public function set_email_subscription_checker( $email_subscriptions_checker ) {
48 $this->email_subscriptions_checker = $email_subscriptions_checker;
49 }
50
51 /**
52 * Create the desired menu output.
53 */
54 public function reregister_menu_items() {
55 global $menu, $submenu;
56
57 $menu = array(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
58 $submenu = array(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
59
60 // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
61 add_menu_page( esc_attr__( 'Manage Domain', 'jetpack-masterbar' ), __( 'Manage Domain', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/domains/manage/' . $this->domain . '/edit/' . $this->domain, null, 'dashicons-admin-settings' );
62
63 if ( $this->email_subscriptions_checker->has_email() ) {
64 // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
65 add_menu_page( esc_attr__( 'Manage Email', 'jetpack-masterbar' ), __( 'Manage Email', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/email/' . $this->domain . '/manage/' . $this->domain, null, 'dashicons-admin-settings' );
66 }
67 // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
68 add_menu_page( esc_attr__( 'Manage Purchases', 'jetpack-masterbar' ), __( 'Manage Purchases', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/purchases/subscriptions/' . $this->domain, null, 'dashicons-cart' );
69 // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
70 add_menu_page( esc_attr__( 'My Mailboxes', 'jetpack-masterbar' ), __( 'My Mailboxes', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/mailboxes/' . $this->domain, null, 'dashicons-email' );
71 }
72 }
73