Help with query function get_calendar()

The line you quote doesn’t actually query any posts. It’s just a very general check if there are any posts at all ever.

The issue with parts of WP core like this, is that WordPress is engineered to query sets of posts. Whenever said sets might get extremely large — it mostly has to abandon WP_Query with all the functionality it has and go for raw SQL.

It’s not that hard to generate conditions for set of posts scenario for this (not tested, might also need type if your values are boolean):

$condition = array(
    array(
        'key'   => 'ua_allow_future_check',
        'value' => true,
    ),
);

$meta_query = new WP_Meta_Query( $condition );
$sql        = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );

var_dump( $sql );

Gives us:

Array
(
    [join] =>  INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
    [where] =>  AND ( (wp_postmeta.meta_key = 'ua_allow_future_check' AND CAST(wp_postmeta.meta_value AS CHAR) = '1') )
)

But bolting this to the fork of get_calendar() is separate and messy story.