' . '' . '' . '' . ''; /** * Registers the post type and its meta. */ public static function register(): void { register_post_type( self::NAME, [ 'labels' => self::labels(), 'public' => true, 'has_archive' => false, 'rewrite' => [ 'slug' => self::REWRITE_SLUG, 'with_front' => false, ], 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode( self::MENU_ICON ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- WordPress paints an SVG menu icon only when it comes base64-encoded. 'menu_position' => 26, // No author support: front-end submitters are not WordPress authors, so their names // stay out of author archives, oEmbed data and the public users endpoint. 'supports' => [ 'title', 'editor', 'comments', 'revisions' ], 'show_in_rest' => true, 'capability_type' => [ self::NAME, self::CAPABILITY_TYPE ], 'map_meta_cap' => true, 'delete_with_user' => false, ] ); register_post_meta( self::NAME, self::META_VOTES, [ 'type' => 'integer', 'single' => true, 'default' => 0, 'sanitize_callback' => 'absint', ] ); } /** * Adds the post type's hooks. */ public static function add_hooks(): void { add_filter( 'use_block_editor_for_post_type', [ self::class, 'use_block_editor' ], 10, 2 ); } /** * Keeps requests in the classic editor, where the board and status boxes allow one choice each. * * @param bool $use_block_editor Whether the block editor would be used. * @param string $post_type Post type being edited. */ public static function use_block_editor( bool $use_block_editor, string $post_type ): bool { return self::NAME === $post_type ? false : $use_block_editor; } /** * Post type labels. * * @return array */ private static function labels(): array { return [ 'name' => __( 'Feature Requests', 'feature-request-system' ), 'singular_name' => __( 'Feature Request', 'feature-request-system' ), 'menu_name' => __( 'Feature Requests', 'feature-request-system' ), 'all_items' => __( 'All Requests', 'feature-request-system' ), 'add_new' => __( 'Add Request', 'feature-request-system' ), 'add_new_item' => __( 'Add Feature Request', 'feature-request-system' ), 'edit_item' => __( 'Edit Feature Request', 'feature-request-system' ), 'new_item' => __( 'New Feature Request', 'feature-request-system' ), 'view_item' => __( 'View Feature Request', 'feature-request-system' ), 'view_items' => __( 'View Feature Requests', 'feature-request-system' ), 'search_items' => __( 'Search Feature Requests', 'feature-request-system' ), 'not_found' => __( 'No feature requests found.', 'feature-request-system' ), 'not_found_in_trash' => __( 'No feature requests found in Trash.', 'feature-request-system' ), 'item_published' => __( 'Feature request published.', 'feature-request-system' ), 'item_updated' => __( 'Feature request updated.', 'feature-request-system' ), 'filter_items_list' => __( 'Filter feature requests list', 'feature-request-system' ), 'items_list_navigation' => __( 'Feature requests list navigation', 'feature-request-system' ), 'items_list' => __( 'Feature requests list', 'feature-request-system' ), ]; } }