php 活动日历PRO:在单个Venue页面上启用评论。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 活动日历PRO:在单个Venue页面上启用评论。相关的知识,希望对你有一定的参考价值。

<?php

/**
 * The Events Calendar PRO: enable comments on single Venue pages.
 *
 * @link https://gist.github.com/cliffordp/50a6ad0b2f23a1824b6c621a3e54b2e6
 * @link https://theeventscalendar.com/support/forums/topic/comments-on-organizer-and-venue/
 */
add_filter( 'tribe_events_register_venue_type_args', function ( $args ) {
	$args['supports'][] = 'comments';

	return $args;
} );

/**
 * Force "Allow Comments" to TRUE for all Venues.
 */
add_filter( 'comments_open', function ( $open, $post_id ) {
	if (
		function_exists( 'tribe_is_venue' )
		&& tribe_is_venue( $post_id )
	) {
		return true;
	} else {
		return $open;
	}
}, 10, 2 );

/**
 * Load the Comments Form on the Venue single page. Quite a bit of hackery to
 * accomplish this, but it should work reliably.
 */
add_action( 'tribe_events_single_venue_after_upcoming_events', function () {
	/**
	 * Needed because of the comment form's `global $id` and `global $post`
	 * thinking it's an event, not a venue. Possibly a bug in the Venue single
	 * page but maybe not.
	 */
	wp_reset_postdata();

	/**
	 * Remove TEC's hijacking of the comments template so it's no longer
	 * /wp-content/plugins/the-events-calendar/src/admin-views/no-comments.php
	 * and therefore we get to use the theme's comments.php file, as expected.
	 *
	 * comments_template() is not needed to load the comments form because it is
	 * already loading after removing TEC's hijacking of the comments template.
	 */
	remove_filter( 'comments_template', array( 'Tribe__Events__Template_Factory', 'remove_comments_template' ) );
	remove_filter( 'comments_template', array( 'Tribe__Events__Templates', 'load_ecp_comments_page_template' ) );
} );

以上是关于php 活动日历PRO:在单个Venue页面上启用评论。的主要内容,如果未能解决你的问题,请参考以下文章

php 事件日历PRO:从单个事件页面上显示删除PRO附加字段。

php 事件日历PRO:从单个事件页面上显示删除PRO附加字段。

php 事件日历:所有Venue slugs都以自定义字符串为前缀。适用于wp-admin和社区活动。

php 活动日历PRO:禁用所有“查看全部”文本和重复活动的链接。

php 活动日历PRO:禁用所有“查看全部”文本和重复活动的链接。

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