Hide ePUB metabox if disabled

This commit is contained in:
Tetrakern 2023-08-19 19:03:03 +02:00
parent 42878bd90b
commit dc8a5f7bdc
2 changed files with 26 additions and 1 deletions

View File

@ -212,7 +212,7 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
| `add_meta_boxes_comment` | `fictioneer_add_comment_meta_box`
| `admin_bar_menu` | `fictioneer_remove_comments_from_admin_bar`
| `admin_enqueue_scripts` | `fictioneer_admin_scripts`, `fictioneer_admin_styles`, `fictioneer_disable_moderator_comment_edit`, `fictioneer_hide_private_data`
| `admin_head` | `fictioneer_remove_update_notice`
| `admin_head` | `fictioneer_remove_update_notice`, `fictioneer_hide_epub_inputs`
| `admin_head-post.php` | `fictioneer_hide_story_sticky_checkbox`, `fictioneer_hide_permalink`
| `admin_head-profile.php` | `fictioneer_remove_profile_blocks`
| `admin_init` | `fictioneer_register_settings`, `fictioneer_skip_dashboard`, `fictioneer_initialize_roles`, `fictioneer_bring_out_legacy_trash`

View File

@ -412,4 +412,29 @@ function fictioneer_acf_remove_fields( $keys, $fields ) {
return $fields;
}
// =============================================================================
// HIDE EPUB GROUP IF EPUBS ARE DISABLED
// =============================================================================
/**
* Hide ePUB metabox if ePUBs are disabled
*
* Note: The ACF field group is loaded from JSON, which happens after filters
* were applied. So this is one of the easier ways to hide the group.
*
* @since 5.6.2
*/
function fictioneer_hide_epub_inputs() {
global $post_type;
if ( $post_type === 'fcn_story' ) {
echo '<style> #acf-group_60edb914ba16c {display: none !important;}</style>';
}
}
if ( ! get_option( 'fictioneer_enable_epubs' ) ) {
add_action( 'admin_head', 'fictioneer_hide_epub_inputs' );
}
?>