<?php
/**
 * Series taxonomy.
 *
 * Registers the `igit_series` taxonomy so editors can group posts into a
 * named series. When "Find Related Posts By → Series" is selected, the query
 * layer fetches other posts in the same series.
 *
 * @package IGIT_RPWT
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class IGIT_RPWT_Series {

	public function __construct() {
		add_action( 'init', array( $this, 'register_taxonomy' ) );
	}

	/**
	 * Register the igit_series taxonomy on all public post types.
	 */
	public function register_taxonomy() {
		$post_types = array_filter(
			get_post_types( array( 'public' => true ) ),
			function ( $pt ) { return 'attachment' !== $pt; }
		);

		register_taxonomy(
			'igit_series',
			array_values( $post_types ),
			array(
				'labels'             => array(
					'name'              => _x( 'Series', 'taxonomy general name', 'igit-related-posts-with-thumb-images-after-posts' ),
					'singular_name'     => _x( 'Series', 'taxonomy singular name', 'igit-related-posts-with-thumb-images-after-posts' ),
					'add_new_item'      => __( 'Add New Series', 'igit-related-posts-with-thumb-images-after-posts' ),
					'new_item_name'     => __( 'New Series Name', 'igit-related-posts-with-thumb-images-after-posts' ),
					'menu_name'         => __( 'Series', 'igit-related-posts-with-thumb-images-after-posts' ),
				),
				'hierarchical'         => false,
				'public'               => false,
				'publicly_queryable'   => false,
				'show_ui'              => true,
				'show_in_menu'         => true,
				'show_in_nav_menus'    => false,
				'show_in_rest'         => true,
				'show_admin_column'    => true,
				'rewrite'              => false,
			)
		);
	}
}
