register_post_type(); } else { add_action( 'init', [ $this, 'register_post_type' ] ); } } /** * @return void */ public function register_post_type(): void { if ( post_type_exists( Constants::POST_TYPE_PLACEMENT ) ) { return; } $labels = [ 'name' => __( 'Ad Placements', 'adpresso' ), 'singular_name' => __( 'Ad Placement', 'adpresso' ), 'add_new' => __( 'New Placement', 'adpresso' ), 'add_new_item' => __( 'Add New Placement', 'adpresso' ), 'edit_item' => __( 'Edit Placement', 'adpresso' ), 'view_item' => __( 'View Placement', 'adpresso' ), 'search_items' => __( 'Search Placements', 'adpresso' ), 'not_found' => __( 'No Placements found', 'adpresso' ), 'not_found_in_trash' => __( 'No Placements found in Trash', 'adpresso' ), ]; $args = [ 'public' => true, 'show_ui' => false, 'show_in_menu' => false, 'supports' => [ 'title', 'author' ], 'capability_type' => 'adpresso_placement', 'map_meta_cap' => true, 'capabilities' => adpresso_get_post_type_capabilities( 'placement' ), 'hierarchical' => false, 'has_archive' => false, 'menu_position' => null, 'show_in_rest' => true, 'exclude_from_search' => true, 'rewrite' => false, 'labels' => $labels, 'publicly_queryable' => false, ]; register_post_type( Constants::POST_TYPE_PLACEMENT, apply_filters( 'adpresso_register_post_type_placement', $args ) ); /** * Fires after the core Placement post type and its statuses are registered. * Allows adding custom post statuses or performing other actions. * * @param string $post_type The registered post type slug (Constants::POST_TYPE_PLACEMENT). */ do_action( 'adpresso_after_register_placement_post_type', Constants::POST_TYPE_PLACEMENT ); } }