admin_asset_manager = $admin_asset_manager; $this->shortlinker = $shortlinker; } /** * {@inheritDoc} */ public function register_hooks() { add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 8 ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); } /** * Adds the workouts submenu page. * * @param array $submenu_pages The Yoast SEO submenu pages. * * @return array the filtered submenu pages. */ public function add_submenu_page( $submenu_pages ) { // this inserts the workouts menu page at the correct place in the array without overriding that position. $submenu_pages[] = [ 'wpseo_dashboard', '', \__( 'Workouts', 'wordpress-seo' ) . ' ', 'edit_others_posts', 'wpseo_workouts', [ $this, 'render' ], ]; return $submenu_pages; } /** * Enqueue the workouts app. */ public function enqueue_assets() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved. if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_workouts' ) { return; } $this->admin_asset_manager->enqueue_style( 'workouts' ); } /** * Renders the target for the React to mount to. */ public function render() { $cornerstone_guide = $this->shortlinker->build_shortlink( 'https://yoa.st/4f1' ); $cornerstone_upsell = $this->shortlinker->build_shortlink( 'https://yoa.st/4f2' ); require_once WPSEO_PATH . 'admin/views/workouts.php'; } }