Created
December 17, 2019 18:18
-
-
Save bskousen/1cb8946e5d617c1a4369eab9538fad6d to your computer and use it in GitHub Desktop.
The Events Calendar REST API Hide from Listing fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: The Events Calendar REST API Hide from Listing fix | |
* Description: This plugin is a temporary fix for The Events Calendar REST API issue that prevents events updated via | |
* the REST API from correctly showing in the calendar. | |
*/ | |
/** | |
* Filters the post array arguments generated during a TEC REST request to update an event to remove empty | |
* `hide_from_listings` values. | |
* | |
* @param array $postarr The post array, as prepared from The Events Calendar code. | |
* | |
* @return array The post array, filtered to remove the empty `_EventHideFromUpcoming` value, if required. | |
*/ | |
function remove_empty_hide_from_listings_value( array $postarr ) { | |
if ( isset( $postarr['EventHideFromUpcoming'] ) && ! tribe_is_truthy( $postarr['EventHideFromUpcoming'] ) ) { | |
$postarr = array_diff_key( $postarr, [ 'EventHideFromUpcoming', 'EventHideFromUpcoming' ] ); | |
} | |
return $postarr; | |
} | |
add_filter( 'tribe_events_rest_event_prepare_postarr', 'remove_empty_hide_from_listings_value' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment