Brian Hogg

Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • Brian Hogg
    Participant

    Thanks! That seems to have done the trick. I was seeing a couple oddities when in a different month then flipping to list view, but not able to replicate now. Will post another thread if needed 🙂

    Brian Hogg
    Participant

    Hey Brook,

    By “digging” I meant debugging, the casual look didn’t find what was missing 🙂

    I found the issue – in addition to Tribe__Events__Main::activate(), I also need to call this in the setup:

    Tribe__Events__Main::instance()->init();

    which will add hooks/filters like this on the pre_get_posts action:

    Tribe__Events__Query::pre_get_posts()

    Or by doing this in my setUp() with do_action( ‘init’ ):

    		update_option( 'timezone_string', 'America/New_York' );
    		date_default_timezone_set( get_option( 'timezone_string' ) );
    
    		require_once( dirname( __FILE__ ) . '/../../the-events-calendar/the-events-calendar.php' );
    		Tribe__Events__Main::activate();
    		do_action( 'init' );
    		update_option( 'active_plugins', array( 'event-calendar-newsletter/event-calendar-newsletter.php', 'the-events-calendar/the-events-calendar.php' ) );

    This handles things like adding post__not_in the upcoming IDs to hide and voila, tests pass!

    There’s likely a better way to this to have the init action fired and plugins loaded, suggestions welcome 🙂

    Brian Hogg
    Participant

    You’re right, passing in ‘yes’ vs. a boolean does save the meta as ‘yes’ (I could have sworn I tried this before and it didn’t work), so updating the inline documentation would be good.

    Unfortunately that still doesn’t do the trick during the automated test, I’ll need to dig in a bit further to see what else other than Tribe__Events__Main::activate(); needs to be called in order to get the right hooks/filters in place.

    Thanks!
    Brian

    Brian Hogg
    Participant

    Appreciate the ideas! I’m able to get non-‘hide from listing’ events to query and be testable as expected, so certainly a great start.

    I did dig in and noticed the cache, but adding this doesn’t do the trick:

    	    $cache = new Tribe__Cache();
    	    $cache->delete( 'tribe-hide-from-upcoming-events', 'save_post' );
    

    The ::activate() and missing other add_actions/filters could definitely be part of the issue, but adding an event with tribe_create_event() should still save as ‘yes’ vs. ‘1’? I’ll try and dig in and see what’s up, but there must be something else causing that posts__not_in to not fire properly.

    Brian Hogg
    Participant

    Thanks Brook! Yes was trolling through the Query class 🙂

    It is the latest version, but I think part of the issue might be that the query is being run from an automated integration test. I’m including the file, adding to active_plugins, and calling Tribe__Events__Main::activate(); during the setup. I’m adding the event using tribe_create_event with EventHideFromUpcoming set to boolean true as per the function docblock.

    With the hide_upcoming => true set it does correctly hide on the frontend now but just not through the automated test.

    I did an output when looping through the events with var_dump( get_post_meta( get_the_ID(), '_EventHideFromUpcoming', true ) ) and when adding using tribe_create_event and this create event statement:

    tribe_create_event( array(
    			'post_status' => 'publish',
    			'post_title' => 'Event to ignore',
    			'post_content' => 'Sed egestas libero eu neque sagittis laoreet. Quisque sed tortor ac orci posuere dignissim rutrum sed purus. Curabitur in nisl volutpat, commodo erat vel, ultricies odio. Donec euismod nisi et tortor pretium, a porta tellus sodales. Etiam facilisis, metus vitae ultrices malesuada, lorem turpis ultrices elit, sit amet accumsan ex mi nec mi. Nunc ac elit fermentum ipsum ultricies luctus. Nam non mollis erat. Aliquam egestas sapien sapien, nec suscipit ante lacinia eu. Fusce mollis eu risus a commodo. Nunc pretium id dolor sed volutpat. Suspendisse nec est bibendum, gravida ligula ut, sagittis magna. Nunc quis mauris diam. Aliquam at nulla nec diam pellentesque viverra vel quis purus. Nunc et eros nunc. Suspendisse potenti.',
    			'EventStartDate' => date( 'Y-m-d', time() + ( 86400 * 5 ) ),
    			'EventEndDate' => date( 'Y-m-d', time() + ( 86400 * 5 ) ),
    			'EventAllDay' => true,
    			'EventHideFromUpcoming' => true,
    			'EventShowMapLink' => true,
    			'EventShowMap' => true,
    			'EventCost' => '0',
    			'Venue' => array( 'VenueID' => $venue_id ),
    			'Organizer' => array( 'OrganizerID' => $organizer_id ),
    		) );

    The value is “1” (probably the string value of the boolean) vs. the “yes” that _EventHideFromUpcoming is supposed to be. But even setting _EventHideFromUpcoming to “yes” manually via update_post_meta doesn’t do the trick.

    I’ll keep digging through the quagmire but thoughts welcome 🙂

    in reply to: Unable to query all events #1120279
    Brian Hogg
    Participant

    Hi Cliff,

    Thanks for the quick reply!

    tribe_get_events() is basically just a wrapper for Tribe__Events__Query::getEvents() so it gives the same result. But it turns out the issue was occurring somewhere else to limit the amount of events displayed. All sorted!

    Cheers,
    Brian

Viewing 6 posts - 1 through 6 (of 6 total)