php 活动日历:将活动档案的iCalendar导出链接更改为webcal://

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 活动日历:将活动档案的iCalendar导出链接更改为webcal://相关的知识,希望对你有一定的参考价值。

<?php
/**
 * The Events Calendar: Change Event Archives' iCalendar export links to webcal://
 *
 * This causes the "iCal Export" button to recommend to calendar applications
 * (e.g. Apple, Outlook, etc.) that they should *subscribe* instead of *download*.
 *
 * We have to use JavaScript instead of PHP because the "Export Events"
 * iCalendar link gets built via JS via
 * /wp-content/plugins/the-events-calendar/src/resources/js/tribe-events.min.js
 * (the script with the `tribe-events-calendar-script` handle).
 *
 * If we were to use PHP (using the `tribe_get_ical_link`,
 * `tribe_get_single_ical_link`, and `tribe_events_force_filtered_ical_link`
 * filters), the link would be static instead of being dynamic to things like
 * an Event Category archive page.
 *
 * @link https://gist.github.com/cliffordp/be034504a2c530495b7d58e704352069
 * @link https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/31305556-add-true-subscribe-functionality-for-ical-google
 */
add_action( 'wp_footer', 'cliff_ical_link_js_override_webcal', 100 );
function cliff_ical_link_js_override_webcal() {
	wp_enqueue_script( 'jquery' );
	?>
    <script type="text/javascript">
		jQuery( document ).ready( function ( $ ) {
			var url = $( 'a.tribe-events-ical' ).attr( 'href' );

			url = url.replace( 'https://', 'webcal://' );
			url = url.replace( 'http://', 'webcal://' );

			$( 'a.tribe-events-ical' ).attr( 'href', url );
		} );
    </script>
	<?php
}

以上是关于php 活动日历:将活动档案的iCalendar导出链接更改为webcal://的主要内容,如果未能解决你的问题,请参考以下文章

防止谷歌日历在远程 icalendar 文件更改时创建重复条目

从 PHP 时区值生成 iCalendar VTIMEZONE 组件

php 活动日历 - 社区活动:将高级自定义字段排入社区活动添加/编辑表单页面。

php 活动日历 - 社区活动:将高级自定义字段排入社区活动添加/编辑表单页面。

php 活动日历:社区活动:将图片上传限制为3兆字节。

php 活动日历:社区活动:将图片上传限制为3兆字节。