Google_Calendar::format_event_details_for_url( string $event_details, WP_Post|int $post, int $length )

Truncate Event Description and add permalink if greater than $length characters.


Parameters

$event_details

(string) (Required) The event description.

$post

(WP_Post|int) (Required) The event post or ID.

$length

(int) (Required) The max length for the description before adding a "read more" link.


Top ↑

Return

(string) The possibly modified event description.


Top ↑

Source

File: src/Tribe/Views/V2/iCalendar/Links/Google_Calendar.php

	public function format_event_details_for_url( $event_details, $post, int $length = 0 ) {
		// Hack: Add space after paragraph
		// Normally Google Cal understands the newline character %0a
		// And that character will automatically replace newlines on urlencode()
		$event_details = str_replace ( '</p>', '</p> ', $event_details );
		$event_details = strip_tags( $event_details );

		if ( strlen( $event_details ) <= 996 ) {
			return $event_details;
		}

		$event_details = substr( $event_details, 0, 996 );

		$event_url     = get_permalink( $post );

		//Only add the permalink if it's shorter than 900 characters, so we don't exceed the browser's URL limits.
		if ( strlen( $event_url ) > 900 ) {
			return $event_details;
		}

		// Append the "read more" link.
		$event_details .= sprintf( esc_html__( ' (View Full %1$s Description Here: %2$s)', 'the-events-calendar' ), $this->singular_event_label, $event_url );

		return $event_details;
	}

Top ↑

Changelog

Changelog
Version Description
5.14.0 Introduced.