Conversation
PR Summary
|
includes/core/classes/class-feed.php
Outdated
| add_action( 'pre_get_posts', array( $this, 'handle_events_feed_query' ) ); | ||
|
|
||
| // Modify feed link for past events page. | ||
| add_filter( 'post_type_archive_feed_link', array( $this, 'modify_feed_link_for_past_events' ), 10, 1 ); |
There was a problem hiding this comment.
Don't need 10, 1 as those are defaults.
| @@ -189,8 +189,9 @@ public function prepare_event_query_before_execution( WP_Query $query ): void { | |||
| if ( $page->id === $query->queried_object_id ) { | |||
| $query->set( 'post_type', 'gatherpress_event' ); | |||
There was a problem hiding this comment.
Maybe bring this down with the other ->set on line 194 to keep like things together.
includes/core/classes/class-feed.php
Outdated
| $query->set( 'gatherpress_events_query', 'upcoming' ); | ||
|
|
||
| // Check for type parameter to determine if we want past or upcoming events. | ||
| $event_type = 'upcoming'; // Default to upcoming events. |
There was a problem hiding this comment.
Add a line break here for readability.
includes/core/classes/class-feed.php
Outdated
|
|
||
| // Check for type parameter to determine if we want past or upcoming events. | ||
| $event_type = 'upcoming'; // Default to upcoming events. | ||
| if ( isset( $_GET['type'] ) && 'past' === sanitize_text_field( wp_unslash( $_GET['type'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Public feed URL parameter, nonce not required. |
There was a problem hiding this comment.
if (
isset( $_GET['type'] ) &&
'past' === sanitize_text_field( wp_unslash( $_GET['type'] ) )
) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Public feed URL parameter, nonce not required.
multiline for readability.
includes/core/classes/class-feed.php
Outdated
| global $wp_query; | ||
|
|
||
| // Check if we're on the past events page by looking for the gatherpress_events_query var. | ||
| if ( isset( $wp_query->query_vars['gatherpress_events_query'] ) && 'past' === $wp_query->query_vars['gatherpress_events_query'] ) { |
There was a problem hiding this comment.
Same here, multiline for readability.
| $page_id = $query->queried_object_id; | ||
| $events_query = $key; | ||
| $query->set( 'post_type', 'gatherpress_event' ); | ||
| $query->set( 'gatherpress_events_query', $key ); |
There was a problem hiding this comment.
Let's change to gatherpress_event_query
There was a problem hiding this comment.
@mauteri I just realized we can't make this change without changing a bunch of things. I feel like we should keep it plural for now. Or I will get to that change later in the week where I can test the query loop block which uses this. Up to you.
There was a problem hiding this comment.
@mauteri Just to follow up on this. I reverted everything back to plural for now because it was indeed messing up the Event Query block. I am going to troubleshoot and try to fix that(simple search and replace/npm run build did not seem to do the trick). But for now, I am going to revert this change so the pr is in a working state. But I'll keep working on it.
There was a problem hiding this comment.
@mauteri OK, it should be all set now. Please review again.
Preview changes with PlaygroundYou can preview the recent changes for PR#1189 with the following PHP versions: PHP Version 8.3
PHP Version 7.4
Download Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions. |
|
Hello @jmarx , Could you write a short explanation, for what kind of use cases such a feature would be needed? |
Description of the Change
Closes #1188
How to test the Change
Test the past events feed:
Visit http://yoursite.com/event/feed/?type=past - should show past events
Visit http://yoursite.com/event/feed/ - should show upcoming events
Test the automatic feed link on past events page:
Configure a past events archive page in GatherPress Settings
Visit that page and check the RSS feed link in page source
Verify the link includes ?type=past parameter
Test edge cases:
?type=invalid should default to upcoming events
?type= should default to upcoming events
Changelog Entry
Adds support for past events RSS feeds via ?type=past parameter. When viewing the past events archive page, the RSS feed link automatically includes this parameter.
Added - Past events RSS feed support with ?type=past parameter
Credits
Props @jmarx
Checklist: