Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE | new calendar endpoints #831

Closed
wants to merge 65 commits into from

Conversation

carstingaxion
Copy link
Collaborator

@carstingaxion carstingaxion commented Aug 29, 2024

Original PR description

As a proof-of-concept PR, this code needs for sure some orchestration!

The used anonymous functions are my preferred way of experimenting, but not meant to stay.

I can see 3 different ways to go on:

  1. a custom class-add-to-calendar.php
  2. Or even a further abstraction into another new class-rewrite-api.php that handles all the rewrites stuff and is only used by the current class-event.php
  3. Or a new class-endpoints.php, that could also be the future home for Add subscribeable Ical feeds #603
  4. Or maybe there is even better places within the existing code base?

Following path number 2 could be interesting for the future, as it could be reused, if GatherPress would want to create /tickets or /qr endpoints on events, for example. Long time ago created a similar abstraction to route AJAX requests, because it was (maybe still is) usually around 10 times faster than the REST API.

———

I’ve also tried using add_rewrite_endpoint() in the first run, but this would have added the new endpoints to all EP_PERMALINK rewrites, which would have meant: all non-hierarchical post types. In that case, I would have had to set custom 404s on all non-event post types, which ended up being very tedious and a lot of additional code. That’s why I went with add_rewrite_rule() which allows a restriction on one post type.

Description of the Change

This PR add several new URL endpoints to events, one per each add-to-calendar link. The new endpoints are:

  • example.org/event/my-sample-event/ical
  • example.org/event/my-sample-event/iCal (Alias for /ical)
  • example.org/event/my-sample-event/outlook (Alias for /ical)
  • example.org/event/my-sample-event/googlecalendar
  • example.org/event/my-sample-event/yahoocalendar

With the original intention to help with #704, this PR also does some more subtle changes to the generated ics file, like changing its default line breaks.

Because this renders into a sites frontend output, this PR additionally introduces a way to overwrite the generated iCal via a theme template. This opens another way of extension and can be used to test this PR.

With the original intention to help with #704, this PR also does some more subtle changes [...]

Can be stated as totally outdated!

Unfortunately, this PR does NOT help with #704,
but instead has grown from 193 to 2607 lines of code and now closes #603 instead.

An extensive description can be found in a new /docs/developer/custom-url-endpoints article, that is also part of this PR.

custom-url-endpoints__office365-calendar

This PR introduces the following of new endpoints:

  • example.org/event/my-sample-event/ical

    provides a download-able .ics file in ical format.

  • example.org/event/my-sample-event/outlook

    provides the same download-able file as an alias.

  • example.org/event/my-sample-event/google-calendar

    redirects to create a new event in Google Calendar.

  • example.org/event/my-sample-event/yahoo-calendar

    redirects to create a new event in Yahoo Calendar.

  • example.org/event/feed/ical

    provides a subscribe-able event feed in ical format with all events of the site.

  • example.org/venue/my-sample-venue/feed/ical

    provides a subscribe-able event feed in ical format with all events at that venue.

  • example.org/topic/my-sample-topic/feed/ical

    provides a subscribe-able event feed in ical format with all events grouped into that topic.

How to test the Change

  • Test the Add to Google calendar
    1. (You need an google account & use their calendar)
    2. Go to the frontend of any event and hit the the Add to calendar > Google button
    3. Confirm that the drafted event in the Google calendar matches the GatherPress event
  • Test the Add to Yahoo calendar
    1. (You need an yahoo account & use their calendar)
    2. Go to the frontend of any event and hit the the Add to calendar > Yahoo button
    3. Confirm that the drafted event in the Yahoo calendar matches the GatherPress event
  • create a ical-download.php file and put it at the root of your active theme to overwrite the plugin template
    1. Create that file
    2. Put some echo ‚hello themed iCal world‘; into it
    3. Go to the frontend of any event and hit the the Add to calendar > iCal button (to make use of your template)
  • https://icalendar.org/validator.html

Changelog Entry

Added - Human readable, shareable and subscribe-able „Add to calendar“ links for each event.

Credits

Props @carstingaxion

Checklist:

Related PRs that can be reviewed & merged after this:

To get the new endpoints into the block-editor, one of the following would be required:

@carstingaxion carstingaxion mentioned this pull request Aug 29, 2024
62 tasks
@carstingaxion

This comment was marked as outdated.

@carstingaxion

This comment was marked as resolved.

includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/templates/frontend/ical-download.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
includes/core/classes/class-event-setup.php Outdated Show resolved Hide resolved
@carstingaxion

This comment was marked as resolved.

@mauteri
Copy link
Contributor

mauteri commented Sep 4, 2024

Thanks for your review @mauteri, but that was exactly what I wanted to pretend you from with my comment and the PR description.

I meant to start with a more strategic What-should-go-where before going into the details.

What do you think?

Sorry, I'm still a bit brain dead from being off for 2 weeks and trying to get back in the flow of things. I think the class-calendar.php (or class-add-to-calendar.php... I like the former a bit more because it is a shorter class name) is the approach I would go with. And move all calendar-related methods to that new class. Smaller, concise classes are easier to maintain and much more approachable.

Copy link

Preview changes with Playground

You can preview the least recent changes for PR#831 by following one of the links below:

⚠️ Note: The preview sites are created using WordPress Playground. You can add content, edit settings, and test the themes as you would on a real site, but please note that changes are not saved between sessions.

@carstingaxion
Copy link
Collaborator Author

Hello @mauteri ,

I've updated the PR description with more relevant info and fixed the simple errors.

The remaining CS failures and Unit test failures are kind of intentional, to remind us what needs attention.

I will now not be able to add some helping review comments, but open it up for Reviews anyway.
If someone has time and wants to take a look, it would be a pleasure.

@carstingaxion
Copy link
Collaborator Author

I'm going to start adding some review-comments for you now @mauteri. Would be cool, if you find the time (or someone else) to go trough all of this me...melange.

Copy link
Collaborator Author

@carstingaxion carstingaxion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauteri I added 16 comments to help navigate to the most problematic parts.

@carstingaxion carstingaxion added this to the 0.32.0 milestone Sep 23, 2024
@carstingaxion carstingaxion changed the title new calendar endpoints DO NOT MERGE | new calendar endpoints Oct 4, 2024
@carstingaxion carstingaxion marked this pull request as draft October 4, 2024 02:10
@mauteri mauteri changed the base branch from main to develop October 10, 2024 13:00
@shawfactor
Copy link

Does this provide a general event feed, listing all events fit the site in iCal

e.g. example.org/events/feed/ical/

?

And does this also support taxonomies

?

e.g. example.org/events/feed/ical/topic/parents:

Pete

@carstingaxion
Copy link
Collaborator Author

Hello Pete,

yes that's correct.

Just that this is the first PR, which is and will be replaced by #928 and #955

Additionally #929 contains a lot documentation about all this.

Please have a look and tell me what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add subscribeable Ical feeds
3 participants