*/ // If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { die; } require_once 'includes/cmb2/init.php'; include('includes/custom-types.php'); include('includes/custom-taxonomies.php'); include('includes/custom-metaboxes.php'); include('includes/p2p-mappings.php'); /** * Class that holds all the necessary * functionality to build custom post types */ class PostType { /** * The custom post type slug * @var string */ private $post_type; /** * The custom post type icon * @var string */ private $icon; function __construct($post_type, $icon) { $this->post_type = $post_type; $this->icon = $icon; } /** Register custom post type call-back */ public function register_post_type() { $args = [ 'label' => esc_html( ucfirst($this->post_type), 'test-plugin' ), 'public' => true, 'menu_position' => 47, 'menu_icon' => $this->icon, 'supports' => ['title', 'editor', 'revisions', 'thumbnail'], 'has_archive' => false, 'show_in_rest' => true, 'publicly_queryable' => true, // Needed for slug 'rewrite' => array( // Rewrite permalink stuff 'slug' => $this->post_type, 'with_front' => false ), ]; register_post_type( $this->post_type, $args ); } } /** * Plugin Logic * Where the magic actually happens */ $custom_types = get_all_custom_types(); foreach ($custom_types as $type) { $icon = get_icon($type); $custom_type_instance = new PostType($type, $icon); add_action( 'init', [ $custom_type_instance, 'register_post_type' ], 10 ); } /** * Create taxonomies */ add_action('init', 'create_materials_taxonomy'); add_action('init', 'create_types_taxonomy'); /** * Create CMB Metaboxes */ add_action( 'cmb2_admin_init', 'cmb2_hero_metaboxes' ); add_action( 'cmb2_admin_init', 'cmb2_sticky_metaboxes' ); add_action( 'cmb2_admin_init', 'cmb2_artist_sort_metaboxes' ); add_action( 'cmb2_admin_init', 'cmb2_episode_credits_metaboxes' ); add_action( 'cmb2_admin_init', 'cmb2_event_date_metaboxes' ); add_action( 'cmb2_admin_init', 'cmb2_exhibition_date_metaboxes' );