Add and remove custom-fields for post types

This commit is contained in:
Tetrakern 2024-07-12 10:53:27 +02:00
parent 7c34489538
commit 1bbe8332bf
2 changed files with 12 additions and 5 deletions

View File

@ -254,14 +254,21 @@ function fictioneer_remove_custom_fields_meta_boxes( $post_type, $context ) {
add_action( 'do_meta_boxes', 'fictioneer_remove_custom_fields_meta_boxes', 1, 2 );
/**
* Removes 'custom-fields' support for posts and pages
* Removes 'custom-fields' support for all posts
*
* Note: Disable this if you need the feature support.
*
* @since 5.8.0
* @since 5.21.1 - Added all post types.
*/
function fictioneer_remove_custom_fields_supports() {
remove_post_type_support( 'post', 'custom-fields' );
remove_post_type_support( 'page', 'custom-fields' );
remove_post_type_support( 'fcn_story', 'custom-fields' );
remove_post_type_support( 'fcn_chapter', 'custom-fields' );
remove_post_type_support( 'fcn_collection', 'custom-fields' );
remove_post_type_support( 'fcn_recommendation', 'custom-fields' );
}
add_action( 'init', 'fictioneer_remove_custom_fields_supports' );

View File

@ -144,7 +144,7 @@ function fictioneer_fcn_story_post_type() {
'description' => __( 'Holds stories and details about them.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-book',
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'revisions'],
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
'public' => true,
@ -213,7 +213,7 @@ function fictioneer_fcn_chapter_post_type() {
'description' => __( 'Holds chapters and details about them.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-text-page',
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions'],
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions', 'custom-fields'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
'public' => true,
@ -359,7 +359,7 @@ function fictioneer_fcn_collection_post_type() {
'description' => __( 'Collections of stories, chapters, and recommendations.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-category',
'supports' => ['title', 'author', 'editor', 'thumbnail'],
'supports' => ['title', 'author', 'editor', 'thumbnail', 'custom-fields'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
'public' => true,
@ -428,7 +428,7 @@ function fictioneer_fcn_recommendation_post_type() {
'description' => __( 'Recommendations for external stories.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-star-filled',
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail'],
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'custom-fields'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
'public' => true,