array( 'name' => __( 'Sermons', 'kanzelbuch' ), 'singular_name' => __( 'Sermon', 'kanzelbuch' ), 'add_new_item' => __( 'Add new sermon', 'kanzelbuch' ), 'edit_item' => __( 'Edit sermon', 'kanzelbuch' ), 'all_items' => __( 'All sermons', 'kanzelbuch' ), 'search_items' => __( 'Search sermons', 'kanzelbuch' ), 'not_found' => __( 'No sermons found.', 'kanzelbuch' ), ), 'public' => true, 'has_archive' => true, 'rewrite' => array( 'slug' => 'sermons', 'with_front' => false ), 'menu_icon' => 'dashicons-microphone', 'menu_position' => 20, 'show_in_rest' => true, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), ) ); } $taxes = array( 'sermon_speaker' => array( __( 'Speakers', 'kanzelbuch' ), __( 'Speaker', 'kanzelbuch' ), false, true ), 'sermon_topics' => array( __( 'Topics', 'kanzelbuch' ), __( 'Topic', 'kanzelbuch' ), false, true ), 'sermon_book' => array( __( 'Bible books', 'kanzelbuch' ), __( 'Bible book', 'kanzelbuch' ), false, true ), 'feg_topic_group' => array( __( 'Topic groups', 'kanzelbuch' ), __( 'Topic group', 'kanzelbuch' ), true, true ), 'sermon_series' => array( __( 'Series (legacy)', 'kanzelbuch' ), __( 'Series (legacy)', 'kanzelbuch' ), true, false ), ); foreach ( $taxes as $tax => $d ) { if ( taxonomy_exists( $tax ) ) { register_taxonomy_for_object_type( $tax, 'sermons' ); continue; } register_taxonomy( $tax, 'sermons', array( 'labels' => array( 'name' => $d[0], 'singular_name' => $d[1], ), 'hierarchical' => $d[2], 'public' => $d[3], 'show_ui' => $d[3], 'show_in_nav_menus' => $d[3], 'show_admin_column' => $d[3], 'show_in_rest' => true, 'rewrite' => array( 'slug' => str_replace( '_', '-', $tax ) ), ) ); } foreach ( array( 'asp_sermon_mp4', 'asp_sermon_bible_passage' ) as $key ) { register_post_meta( 'sermons', $key, array( 'type' => 'string', 'single' => true, 'show_in_rest' => true, 'sanitize_callback' => 'asp_sermon_mp4' === $key ? 'esc_url_raw' : 'sanitize_text_field', 'auth_callback' => function () { return current_user_can( 'edit_posts' ); }, ) ); } register_term_meta( 'feg_topic_group', 'fegp_image_id', array( 'type' => 'integer', 'single' => true, 'sanitize_callback' => 'absint' ) ); register_term_meta( 'sermon_topics', 'fegp_group_id', array( 'type' => 'integer', 'single' => true, 'sanitize_callback' => 'absint' ) ); } add_action( 'init', 'fegp_register_types', 20 );