Support » Plugin: WP Event Calendar » Passed Events break get_oembed_response_data()

  • Due to get_oembed_response_data() expecting Post Status to be ‘publish’ at all times, this can cause some invalid oEmbeds to be generated for passed Events.

    wp_oembed_add_discovery_links() gets output on each Singluar template to generate the relevant oEmbed Discovery Links. However, navigating to these will result in an “oembed_invalid_url” error for passed Events.

    I was able to get around this with the following, but it could be a good addition to the plugin.

    
    add_filter( 'oembed_request_post_id', function( $post_id, $request_url ) {
    
        if ( get_post_type( $post_id ) == 'event' ) {
            add_filter( 'get_post_status', 'fake_post_status_for_events_oembed', 10, 2 );
        }
    
        return $post_id;
    
    }, 10, 2 );
    
    function fake_post_status_for_events_oembed( $post_status, $post ) {
    
        if ( in_array( $post_status, array( 'passed', 'hidden' ) ) ) {
            return 'publish';
        }
    
        return $post_status;
    
    }
    
  • You must be logged in to reply to this topic.