$plural,
'singular_name' => $singular,
'add_new' => 'Add ' . strtolower( $singular ),
'add_new_item' => 'Add a new ' . strtolower( $singular ),
'edit_item' => 'Edit ' . strtolower( $singular ),
'new_item' => 'New ' . strtolower( $singular ),
'view_item' => 'View ' . strtolower( $singular ),
'all_items' => $plural,
'search_items' => 'Search ' . $lower,
'not_found' => 'No ' . $lower . ' yet',
'menu_name' => $plural,
),
$extra
);
}
function clanfront_register_types() {
register_post_type(
'clanfront_member',
array(
'labels' => clanfront_labels(
'Member',
'Members',
array(
'featured_image' => 'Member picture',
'set_featured_image' => 'Set member picture',
'remove_featured_image' => 'Remove member picture',
'use_featured_image' => 'Use as member picture',
)
),
'public' => true,
'has_archive' => 'roster',
'rewrite' => array( 'slug' => 'member', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
'show_in_menu' => 'edit.php?post_type=clanfront_match',
'show_in_rest' => false,
)
);
register_post_type(
'clanfront_match',
array(
'labels' => clanfront_labels( 'Match or event', 'Matches & events', array( 'menu_name' => 'Matches & events', 'add_new' => 'Add match or event', 'all_items' => 'Matches & events' ) ),
'public' => true,
'has_archive' => 'matches',
'rewrite' => array( 'slug' => 'match', 'with_front' => false ),
'supports' => array( 'title' ),
'show_in_menu' => 'edit.php?post_type=clanfront_match',
'show_in_rest' => false,
'menu_icon' => 'dashicons-groups',
)
);
register_post_type(
'clanfront_news',
array(
'labels' => clanfront_labels(
'Article',
'News',
array(
'featured_image' => 'Article picture',
'set_featured_image' => 'Set article picture',
'remove_featured_image' => 'Remove article picture',
'use_featured_image' => 'Use as article picture',
'add_new' => 'Add article',
'not_found' => 'No articles yet',
)
),
'public' => true,
'has_archive' => 'news',
'rewrite' => array( 'slug' => 'article', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'author' ),
'show_in_menu' => 'edit.php?post_type=clanfront_match',
'show_in_rest' => true,
)
);
register_post_type(
'clanfront_media',
array(
'labels' => clanfront_labels(
'Gallery item',
'Gallery',
array(
'featured_image' => 'Image',
'set_featured_image' => 'Set image',
'remove_featured_image' => 'Remove image',
'use_featured_image' => 'Use as image',
)
),
'public' => true,
'has_archive' => 'gallery',
'rewrite' => array( 'slug' => 'gallery-item', 'with_front' => false ),
'supports' => array( 'title', 'thumbnail', 'page-attributes' ),
'show_in_menu' => 'edit.php?post_type=clanfront_match',
'show_in_rest' => false,
)
);
register_post_type(
'clanfront_server',
array(
'labels' => clanfront_labels( 'Server', 'Game servers' ),
'public' => false,
'show_ui' => true,
'exclude_from_search' => true,
'supports' => array( 'title', 'page-attributes' ),
'show_in_menu' => 'edit.php?post_type=clanfront_match',
'show_in_rest' => false,
)
);
register_post_type(
'clanfront_applicant',
array(
'labels' => clanfront_labels( 'Application', 'Applications' ),
'public' => false,
'show_ui' => true,
'exclude_from_search' => true,
'supports' => array( 'title' ),
'capabilities' => array( 'create_posts' => 'do_not_allow' ),
'map_meta_cap' => true,
'show_in_menu' => 'edit.php?post_type=clanfront_match',
'show_in_rest' => false,
)
);
add_shortcode( 'clanfront_email', 'clanfront_email_shortcode' );
}
add_action( 'init', 'clanfront_register_types' );
function clanfront_email_shortcode() {
$email = sanitize_email( clanfront_setting( 'email' ) );
if ( ! $email ) {
// Only you (logged in) see this reminder; visitors see nothing until an email is set.
return current_user_can( 'manage_options' ) ? 'Add your contact email under Clanfront → Settings.' : '';
}
return '' . esc_html( antispambot( $email ) ) . '';
}