| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- /**
- * Craft in America Custom Types Plugin
- *
- * @since 1.0.0
- * @package cia_post_types
- *
- * @wordpress-plugin
- * Plugin Name: Craft in America - Content Types
- * Plugin URI:
- * Description: Adds custom custom types, and p2p relationships
- * Version: 1.0.0
- * Author: TOJ <john@yvvas.com>
- */
-
- // 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' );
|