shell = $shell; } /** * {@inheritdoc} */ public function register(): void { add_action( 'admin_menu', array( $this, 'add_menu' ) ); add_filter( 'admin_body_class', array( $this, 'add_body_class' ) ); } /** * Capability required to open the app. * * @since 0.1.0 * * @return string */ public static function capability(): string { /** * Filters the capability required to open the HostKhata admin app. * * @since 0.1.0 * * @param string $capability Capability name. */ return (string) apply_filters( 'hostkhata_menu_capability', Capabilities::ACCESS_APP ); } /** * Hook suffix of the app page. * * @since 0.1.0 * * @return string */ public static function screen_id(): string { return 'toplevel_page_' . self::SLUG; } /** * Tells whether a hook suffix belongs to the app page. * * @since 0.1.0 * * @param string $hook_suffix Admin page hook suffix. * @return bool */ public static function is_app_screen( string $hook_suffix ): bool { return self::screen_id() === $hook_suffix; } /** * Adds the menu entry. * * @since 0.1.0 * * @return void */ public function add_menu(): void { add_menu_page( __( 'HostKhata', 'hostkhata' ), __( 'HostKhata', 'hostkhata' ), self::capability(), self::SLUG, array( $this->shell, 'render' ), 'dashicons-money-alt', 26 ); } /** * Adds a body class on the app screen so full-width styles can apply. * * @since 0.1.0 * * @param string $classes Space separated body classes. * @return string */ public function add_body_class( $classes ): string { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( $screen && self::screen_id() === $screen->id ) { $classes .= ' hostkhata-screen'; } return (string) $classes; } }