Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions includes/alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use HP\Alerts\Taxonomy\AlertLevel;

add_action( 'init', __NAMESPACE__ . '\register_meta' );
add_action( 'init', __NAMESPACE__ . '\register_meta', 300 );
add_action( 'updated_post_meta', __NAMESPACE__ . '\store_display_through', 10, 4 );
add_action( 'added_post_meta', __NAMESPACE__ . '\store_display_through', 10, 4 );
add_action( 'shutdown', __NAMESPACE__ . '\check_expired' );
Expand All @@ -32,7 +32,22 @@ function get_post_types(): array {
*
* @param string[] $post_types An array of post type keys.
*/
return apply_filters( 'hp_alerts_get_post_types', $post_types );
$post_types = apply_filters( 'hp_alerts_get_post_types', $post_types );

/**
* Ensure the post type supports custom fields.
*
* If custom fields are not supported, and the custom fields interface is
* displayed in the block editor, then the editor will crash when we load
* the meta boxes. Strange things afoot!
*/
foreach ( $post_types as $key => $post_type ) {
if ( ! post_type_supports( $post_type, 'custom-fields' ) ) {
unset( $post_types[ $key ] );
}
}

return $post_types;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/taxonomy/alert-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use HP\Alerts;

add_action( 'init', __NAMESPACE__ . '\register_taxonomy' );
add_action( 'init', __NAMESPACE__ . '\register_taxonomy', 300 );
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_block_editor_assets' );
add_filter( 'body_class', __NAMESPACE__ . '\filter_body_class' );
add_action( get_slug() . '_edit_form_fields', __NAMESPACE__ . '\display_edit_form_fields' );
Expand Down