-
Notifications
You must be signed in to change notification settings - Fork 30
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
new calendar endpoints | part 4/4 | endpoint implementations #955
base: develop
Are you sure you want to change the base?
new calendar endpoints | part 4/4 | endpoint implementations #955
Conversation
…dpoints\Endpoint.
…cts array<string>|string|WP_Post, int given.
…() does not exist.
…ubtype of Throwable
Preview changes with PlaygroundYou can preview the recent changes for PR#955 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering, why this PR does not get updated. Because 3/4 of the "Changed files" are already in develop.
// Update permalink structure to '/%postname%/'. | ||
update_option( 'permalink_structure', '/%postname%/' ); | ||
|
||
// Reload the global rewrite rules object to ensure it reflects the changes. | ||
global $wp_rewrite; | ||
$wp_rewrite->init(); | ||
flush_rewrite_rules(); | ||
|
||
$output = $event->get_calendar_links(); | ||
$expects = array( | ||
'google' => array( | ||
'name' => 'Google Calendar', | ||
'link' => home_url( '/event/unit-test-event/google-calendar' ), | ||
), | ||
'ical' => array( | ||
'name' => 'iCal', | ||
'download' => home_url( '/event/unit-test-event/ical' ), | ||
), | ||
'outlook' => array( | ||
'name' => 'Outlook', | ||
'download' => home_url( '/event/unit-test-event/outlook' ), | ||
), | ||
'yahoo' => array( | ||
'name' => 'Yahoo Calendar', | ||
'link' => home_url( '/event/unit-test-event/yahoo-calendar' ), | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to change the permalink settings here, but failed.
I wanted to test the rewritten and the ugly permalinks in the same test.
Why did my attempts not work (within the tests)?
/** | ||
* @author Stephen Harris (@stephenharris) | ||
* @source https://github.com/stephenharris/Event-Organiser/blob/develop/includes/event-organiser-utility-functions.php#L1663 | ||
* | ||
* Fold text as per [iCal specifications](http://www.ietf.org/rfc/rfc2445.txt) | ||
* | ||
* Lines of text SHOULD NOT be longer than 75 octets, excluding the line | ||
* break. Long content lines SHOULD be split into a multiple line | ||
* representations using a line "folding" technique. That is, a long | ||
* line can be split between any two characters by inserting a CRLF | ||
* immediately followed by a single linear white space character (i.e., | ||
* SPACE, US-ASCII decimal 32 or HTAB, US-ASCII decimal 9). Any sequence | ||
* of CRLF followed immediately by a single linear white space character | ||
* is ignored (i.e., removed) when processing the content type. | ||
* | ||
* @ignore | ||
* @since 2.7 | ||
* @param string $text The string to be escaped. | ||
* @return string The escaped string. | ||
*/ | ||
private static function eventorganiser_fold_ical_text( string $text ): string { | ||
|
||
$text_arr = array(); | ||
|
||
$lines = ceil( mb_strlen( $text ) / 75 ); | ||
|
||
for ( $i = 0; $i < $lines; $i++ ) { | ||
$text_arr[ $i ] = mb_substr( $text, $i * 75, 75 ); | ||
} | ||
|
||
return join( "\r\n ", $text_arr ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I brazenly stole this code, because I knew it is working for years and I also knew that I couldn't do better.
But I don't just want to pirate Stephen Harris' code, without proper attribution - or rewriting it!
Hello @mauteri , can you please help me getting this finished? Would be nice to get your feedback or help or both! |
Thank you @carstingaxion // acknowledging this is ready for review. |
This PR is the final part of the fragmentation of #831, which was way too big to review or merge.
I try to do better in the future.
Description of the Change
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
echo ‚hello themed iCal world‘;
into itChangelog Entry
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:
OR