php 事件日历和相关插件:添加您自己的模板文件加载位置。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 事件日历和相关插件:添加您自己的模板文件加载位置。相关的知识,希望对你有一定的参考价值。

<?php

/**
 * The Events Calendar and related plugins: Add your own location for template file loading.
 *
 * Example "Single Event within List View" for Avada theme (which has theme overrides).
 * Now tries to load in this order:
 * This plugin:                                  /app/public/wp-content/plugins/my-plugin/tribe-events/list/single-event.php
 * Theme root so it stays even if switch themes: /app/public/wp-content/themes/tribe-events/list/single-event.php
 * Child theme with theme overrides:             /app/public/wp-content/themes/Avada-Child-Theme/tribe-events/list/single-event.php
 * Parent theme with theme overrides:            /app/public/wp-content/themes/Avada/tribe-events/list/single-event.php
 * Plugin default:                               /app/public/wp-content/plugins/the-events-calendar/src/views/list/single-event.php
 *
 * @link https://gist.github.com/b76421f2490a8b8995493f203e11b331
 *
 * @see \Tribe__Events__Templates::getTemplateHierarchy()
 *
 * @param string $file     The full file path trying to be loaded.
 * @param string $template The template name, such as
 *
 * @return string
 */
function tribe_additional_template_locations( string $file, string $template ) {
	// Put them in the order of priority (first location gets loaded before second location if first exists)
	$new_locations = [
		'my_plugin'   => trailingslashit( plugin_dir_path( __FILE__ ) ) . 'tribe-events', // /app/public/wp-content/plugins/cliff-test-tec/tribe-events/default-template.php
		'themes_root' => trailingslashit( get_theme_root() ) . 'tribe-events', // /app/public/wp-content/themes/tribe-events/default-template.php
	];

	foreach ( $new_locations as $location ) {
		$new_file = trailingslashit( $location ) . $template;
		if ( file_exists( $new_file ) ) {
			return $new_file;
		}
	}

	return $file;
}

add_filter( 'tribe_events_template', 'tribe_additional_template_locations', 10, 2 );

以上是关于php 事件日历和相关插件:添加您自己的模板文件加载位置。的主要内容,如果未能解决你的问题,请参考以下文章

php 插件事件日历事件日历

php 事件短代码 - 事件日历WordPress插件

创建自动更新的日历事件列表

怎样为DEDECMS织梦系统页面添加日历控件

jquery 日历控件在php中怎么使用

哪种 PHP 日历适合我的需求?还是自己建?