init_hooks(); } } /** * Initialize the hooks. */ public function init_hooks() { self::$initialized = true; // Jetpack uses 998 and 'Admin_Menu' uses 1000. add_action( 'admin_menu', array( $this, 'add_wp_admin_submenu' ), $this->menu_priority ); } /** * The page to be added to submenu */ public function add_wp_admin_submenu() { if ( ! apply_filters( 'jetpack_wp_admin_subscriber_management_enabled', false ) || self::$menu_added ) { return; } $page_suffix = null; if ( ( new Host() )->is_wpcom_platform() ) { $page_suffix = add_submenu_page( 'users.php', __( 'Subscribers', 'jetpack-subscribers-dashboard' ), __( 'Subscribers', 'jetpack-subscribers-dashboard' ), 'manage_options', 'subscribers', array( $this, 'render' ) ); } else { $page_suffix = Admin_Menu::add_menu( __( 'Subscribers', 'jetpack-subscribers-dashboard' ), _x( 'Subscribers', 'product name shown in menu', 'jetpack-subscribers-dashboard' ), 'manage_options', 'subscribers', array( $this, 'render' ) ); } if ( $page_suffix ) { add_action( 'load-' . $page_suffix, array( $this, 'admin_init' ) ); self::$menu_added = true; } } /** * Override render funtion */ public function render() { echo '
'; } /** * Initialize the admin resources. */ public function admin_init() { add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) ); } /** * Load the admin scripts. */ public function load_admin_scripts() { Assets::register_script( 'jetpack-subscribers-dashboard', '../build/index.js', __FILE__, array( 'in_footer' => true, 'textdomain' => 'jetpack-subscribers-dashboard', 'enqueue' => true, ) ); Assets::enqueue_script( 'jetpack-script-data' ); } }