php TEC档案页面(不是单个事件):添加特定于Google日历的第二个导出/订阅按钮 - https://cl.ly/2j2d2d1B3s1E

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php TEC档案页面(不是单个事件):添加特定于Google日历的第二个导出/订阅按钮 - https://cl.ly/2j2d2d1B3s1E相关的知识,希望对你有一定的参考价值。

<?php

/**
 * TEC archive pages (not single events): Add a second export/subscribe button specific to Google Calendar. Screenshot: https://cl.ly/2j2d2d1B3s1E
 *
 * Beware: this does not respect Event Categories and such. It's just the same URL no matter which event archive page you are on.
 * Based on maybe_add_link() from TEC v4.5.9
 *
 * @link https://cl.ly/2j2d2d1B3s1E Screenshot.
 * @link https://gist.github.com/cliffordp/96759ce94fedb344509ba2a02fc334ce
 * @link https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/6430110-subscribe-to-calendar-with-google-calendar
 */
add_action( 'tribe_events_after_footer', 'cliff_output_dedicated_google_export_button_archive_pages', 9 );
function cliff_output_dedicated_google_export_button_archive_pages() {
	global $wp_query;

	$show_ical = apply_filters( 'tribe_events_list_show_ical_link', true );

	if ( ! $show_ical ) {
		return;
	}
	if ( tribe_is_month() && ! tribe_events_month_has_events() ) {
		return;
	}
	if ( is_single() || empty( $wp_query->posts ) ) {
		return;
	}

	$ical_link = tribe_get_ical_link();

	// Because Google Calendar does not support https URLs via cid=...
	$count     = 1;
	$ical_link = str_replace( 'https://', 'webcal://', $ical_link, $count );

	$gcal_subscribe = sprintf( 'https://www.google.com/calendar/render?cid=%s', urlencode( $ical_link ) );

	$text = '+ Subscribe via Google Calendar';

	$title = 'Clicking this link will open your Google Calendar, which will prompt you to add this calendar as one of your subscriptions.';

	$output = printf(
		'<a class="tribe-events-gcal tribe-events-button" style="margin-right: 0;" title="%s" href="%s" target="_blank">%s</a>',
		esc_html( $title ),
		esc_url( $gcal_subscribe ),
		esc_html( $text )
	);
}

以上是关于php TEC档案页面(不是单个事件):添加特定于Google日历的第二个导出/订阅按钮 - https://cl.ly/2j2d2d1B3s1E的主要内容,如果未能解决你的问题,请参考以下文章

如何从包含所有页面的 JS 代码的单个 JS 文件中使用特定于某些页面的 JS 代码?

php 事件日历(TEC)和事件聚合器(EA):添加更多未来的导入限制。

php 将发布日期列添加到事件WP列表表(TEC 4.x)

php 将发布日期列添加到事件WP列表表(TEC 4.x)

php 为特定于站点的插件添加Edit Buttin

php MT | TEC |始终在单个活动上显示Google地图和地图链接