more checks to prevent admin ui crashes

This commit is contained in:
André Menrath 2024-12-23 14:47:25 +01:00
parent 355dfb8991
commit 460b223920

View file

@ -86,6 +86,10 @@ class Health_Check {
* @return bool True if the check passed.
*/
public static function test_if_event_transformer_is_used( $event_plugin ) {
if ( ! Setup::get_instance()->is_activitypub_plugin_active() ) {
return false;
}
// Get a (random) event post.
$event_posts = self::get_most_recent_event_posts( $event_plugin->get_post_type(), 1 );
@ -113,6 +117,10 @@ class Health_Check {
* @return WP_Post[]|false Array of event posts, or false if none are found.
*/
public static function get_most_recent_event_posts( $event_post_type = null, $number_of_posts = 5 ) {
if ( ! Setup::get_instance()->is_activitypub_plugin_active() ) {
return false;
}
if ( ! $event_post_type ) {
$active_event_plugins = Setup::get_instance()->get_active_event_plugins();
$active_event_plugin = reset( $active_event_plugins );