bp_locate_template (字符串|数组template_names美元保龄球美元的负载保龄球美元require_once真正的

检索现有的最高优先级模板文件的名称。

描述

在TEMPLATEPATH之前搜索STYLESHEETPATH,以便继承父主题的主题只会重载一个文件。如果在这两个文件夹中都找不到模板,则最后查找theme-compat文件夹。

参数

template_names美元

字符串|数组(必需)按顺序搜索的模板文件。

美元的负载

保龄球(可选)如果为true,当找到模板文件时将加载该模板文件。如果为false,将返回路径。默认值:false。

默认值:假

美元require_once

保龄球(可选)是require_once还是require。如果$load为false,则没有效果。默认值:真的。

默认值:真

返回

(字符串)模板文件名(如果找到的话)。

文件:bp-core / bp-core-template-loader.php

function bp_locate_template($template_names, $load = false, $require_once = true){//当没有模板可定位时保释if (empty($template_names)) {return false;} //未找到文件。位于美元= false;$ template_locations = bp_get_template_stack ();//尝试找到一个模板文件。foreach ((array) $template_names as $template_name){//如果模板为空则继续。If (empty($template_name)){继续;} //去掉模板名中的斜杠。$template_name = ltrim($template_name, '/');//循环遍历模板栈 foreach ( (array) $template_locations as $template_location ) { // Continue if $template_location is empty. if ( empty( $template_location ) ) { continue; } // Check child theme first. if ( file_exists( trailingslashit( $template_location ) . $template_name ) ) { $located = trailingslashit( $template_location ) . $template_name; break 2; } } } /** * This action exists only to follow the standard BuddyPress coding convention, * and should not be used to short-circuit any part of the template locator. * * If you want to override a specific template part, please either filter * 'bp_get_template_part' or add a new location to the template stack. */ do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once ); /** * Filter here to allow/disallow template loading. * * @since BuddyPress 2.5.0 * * @param bool $value True to load the template, false otherwise. */ $load_template = (bool) apply_filters( 'bp_locate_template_and_load', true ); if ( $load_template && $load && ! empty( $located ) ) { load_template( $located, $require_once ); } return $located; }

更新日志

更新日志
版本 描述
BuddyPress 1.7.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队