LotCost and loads the page script there (and nowhere else). */ final class Admin { const SLUG = 'lotcost'; /** * Hook suffix of the page, set when the menu is added. * * @var string|false */ private $hook_suffix = false; /** * Hook into the admin. */ public function register(): void { add_action( 'admin_menu', array( $this, 'add_menu' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); add_filter( 'plugin_action_links_' . plugin_basename( LOTCOST_FILE ), array( $this, 'action_links' ) ); } /** * Add the page under the WooCommerce menu. */ public function add_menu(): void { $this->hook_suffix = add_submenu_page( 'woocommerce', __( 'LotCost', 'lotcost' ), __( 'LotCost', 'lotcost' ), 'manage_woocommerce', self::SLUG, array( $this, 'render' ) ); } /** * Link on the Plugins screen. * * @param string[] $links Existing links. * @return string[] */ public function action_links( array $links ): array { $url = admin_url( 'admin.php?page=' . self::SLUG ); array_unshift( $links, '' . esc_html__( 'Open LotCost', 'lotcost' ) . '' ); return $links; } /** * The page: a mount point, React does the rest. */ public function render(): void { echo '
' . esc_html__( 'LotCost: the page script is missing. Reinstall the plugin.', 'lotcost' ) . '