get_results( $wpdb->prepare( "SELECT DISTINCT {$wpdb->prefix}posts.ID FROM {$wpdb->prefix}posts LEFT JOIN {$wpdb->prefix}gatherpress_events ON {$wpdb->prefix}posts.ID = {$wpdb->prefix}gatherpress_events.post_id LEFT JOIN {$wpdb->prefix}postmeta ON {$wpdb->prefix}posts.ID = {$wpdb->prefix}postmeta.post_id WHERE {$wpdb->prefix}posts.post_type = 'gatherpress_event' AND {$wpdb->prefix}posts.post_status = 'publish' AND {$wpdb->prefix}gatherpress_events.datetime_end_gmt <= %s AND {$wpdb->prefix}postmeta.meta_key = '_event_bridge_for_activitypub_is_remote_cached' ", $ends_before_time_string ), ARRAY_N ); $post_ids = array_column( $results, 0 ); return $post_ids; } /** * Init function: force displaying online event link for federated events. */ public static function init() { \add_filter( 'gatherpress_force_online_event_link', function ( $force_online_event_link ) { // Get the current post object. $post = get_post(); // Check if we are in a valid context and the post type is 'gatherpress'. if ( $post && 'gatherpress_event' === $post->post_type ) { // Add your custom logic here to decide whether to force the link. // For example, force it only if a specific meta field exists. if ( get_post_meta( $post->ID, '_event_bridge_for_activitypub_is_remote_cached', true ) ) { return true; // Force the online event link. } } return $force_online_event_link; // Default behavior. }, 10, 1 ); } }