本文整理汇总了PHP中bp_use_theme_compat_with_current_theme函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_use_theme_compat_with_current_theme函数的具体用法?PHP bp_use_theme_compat_with_current_theme怎么用?PHP bp_use_theme_compat_with_current_theme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_use_theme_compat_with_current_theme函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: start
/**
* Set up the BuddyPress-specific theme compat methods.
*
* Themes should use this method in their constructor.
*
* @since BuddyPress (1.7.0)
*/
protected function start()
{
// Sanity check
if (!bp_use_theme_compat_with_current_theme()) {
return;
}
// Setup methods
$this->setup_globals();
$this->setup_actions();
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:17,代码来源:bp-core-theme-compatibility.php
示例2: bp_core_load_template
/**
* Load a specific template file with fallback support.
*
* Example:
* bp_core_load_template( 'members/index' );
* Loads:
* wp-content/themes/[activated_theme]/members/index.php
*
* @param array $templates Array of templates to attempt to load.
*/
function bp_core_load_template($templates)
{
global $wp_query;
// Reset the post.
bp_theme_compat_reset_post(array('ID' => 0, 'is_404' => true, 'post_status' => 'publish'));
// Set theme compat to false since the reset post function automatically sets
// theme compat to true.
bp_set_theme_compat_active(false);
// Fetch each template and add the php suffix.
$filtered_templates = array();
foreach ((array) $templates as $template) {
$filtered_templates[] = $template . '.php';
}
// Only perform template lookup for bp-default themes.
if (!bp_use_theme_compat_with_current_theme()) {
$template = locate_template((array) $filtered_templates, false);
// Theme compat doesn't require a template lookup.
} else {
$template = '';
}
/**
* Filters the template locations.
*
* Allows plugins to alter where the template files are located.
*
* @since 1.1.0
*
* @param string $template Located template path.
* @param array $filtered_templates Array of templates to attempt to load.
*/
$located_template = apply_filters('bp_located_template', $template, $filtered_templates);
if (!empty($located_template)) {
// Template was located, lets set this as a valid page and not a 404.
status_header(200);
$wp_query->is_page = true;
$wp_query->is_singular = true;
$wp_query->is_404 = false;
/**
* Fires before the loading of a located template file.
*
* @since 1.6.0
*
* @param string $located_template Template found to be loaded.
*/
do_action('bp_core_pre_load_template', $located_template);
/**
* Filters the selected template right before loading.
*
* @since 1.1.0
*
* @param string $located_template Template found to be loaded.
*/
load_template(apply_filters('bp_load_template', $located_template));
/**
* Fires after the loading of a located template file.
*
* @since 1.6.0
*
* @param string $located_template Template found that was loaded.
*/
do_action('bp_core_post_load_template', $located_template);
// Kill any other output after this.
exit;
// No template found, so setup theme compatibility.
// @todo Some other 404 handling if theme compat doesn't kick in.
} else {
// We know where we are, so reset important $wp_query bits here early.
// The rest will be done by bp_theme_compat_reset_post() later.
if (is_buddypress()) {
status_header(200);
$wp_query->is_page = true;
$wp_query->is_singular = true;
$wp_query->is_404 = false;
}
/**
* Fires if there are no found templates to load and theme compat is needed.
*
* @since 1.7.0
*/
do_action('bp_setup_theme_compat');
}
}
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:92,代码来源:bp-core-catchuri.php
示例3: bp_load_theme_functions
/**
* Attempt to load a custom BP functions file, similar to each themes functions.php file.
*
* @since 1.7.0
*
* @global string $pagenow
* @uses bp_locate_template()
*/
function bp_load_theme_functions()
{
global $pagenow, $wp_query;
// do not load our custom BP functions file if theme compat is disabled
if (!bp_use_theme_compat_with_current_theme()) {
return;
}
// Do not include on BuddyPress deactivation
if (bp_is_deactivation()) {
return;
}
// If the $wp_query global is empty (the main query has not been run,
// or has been reset), load_template() will fail at setting certain
// global values. This does not happen on a normal page load, but can
// cause problems when running automated tests
if (!is_a($wp_query, 'WP_Query')) {
return;
}
// Only include if not installing or if activating via wp-activate.php
if (!defined('WP_INSTALLING') || 'wp-activate.php' === $pagenow) {
bp_locate_template('buddypress-functions.php', true);
}
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:31,代码来源:bp-core-template-loader.php
示例4: bp_template_include_theme_compat
/**
* Reset main query vars and filter 'the_content' to output a BuddyPress template part as needed.
*
* @since 1.7.0
*
* @uses bp_is_single_user() To check if page is single user.
* @uses bp_get_single_user_template() To get user template.
* @uses bp_is_single_user_edit() To check if page is single user edit.
* @uses bp_get_single_user_edit_template() To get user edit template.
* @uses bp_is_single_view() To check if page is single view.
* @uses bp_get_single_view_template() To get view template.
* @uses bp_is_forum_edit() To check if page is forum edit.
* @uses bp_get_forum_edit_template() To get forum edit template.
* @uses bp_is_topic_merge() To check if page is topic merge.
* @uses bp_get_topic_merge_template() To get topic merge template.
* @uses bp_is_topic_split() To check if page is topic split.
* @uses bp_get_topic_split_template() To get topic split template.
* @uses bp_is_topic_edit() To check if page is topic edit.
* @uses bp_get_topic_edit_template() To get topic edit template.
* @uses bp_is_reply_edit() To check if page is reply edit.
* @uses bp_get_reply_edit_template() To get reply edit template.
* @uses bp_set_theme_compat_template() To set the global theme compat template.
*
* @param string $template Template name.
* @return string $template Template name.
*/
function bp_template_include_theme_compat($template = '')
{
// If the current theme doesn't need theme compat, bail at this point.
if (!bp_use_theme_compat_with_current_theme()) {
return $template;
}
/**
* Fires when resetting main query vars and filtering 'the_content' to output BuddyPress template parts.
*
* Use this action to execute code that will communicate to BuddyPress's
* theme compatibility layer whether or not we're replacing the_content()
* with some other template part.
*
* @since 1.7.0
*/
do_action('bp_template_include_reset_dummy_post_data');
// Bail if the template already matches a BuddyPress template.
if (!empty(buddypress()->theme_compat->found_template)) {
return $template;
}
/**
* If we are relying on BuddyPress's built in theme compatibility to load
* the proper content, we need to intercept the_content, replace the
* output, and display ours instead.
*
* To do this, we first remove all filters from 'the_content' and hook
* our own function into it, which runs a series of checks to determine
* the context, and then uses the built in shortcodes to output the
* correct results from inside an output buffer.
*
* Uses bp_get_theme_compat_templates() to provide fall-backs that
* should be coded without superfluous mark-up and logic (prev/next
* navigation, comments, date/time, etc...)
*
* Hook into 'bp_get_buddypress_template' to override the array of
* possible templates, or 'bp_buddypress_template' to override the result.
*/
if (bp_is_theme_compat_active()) {
$template = bp_get_theme_compat_templates();
add_filter('the_content', 'bp_replace_the_content');
// Add BuddyPress's head action to wp_head.
if (!has_action('wp_head', 'bp_head')) {
add_action('wp_head', 'bp_head');
}
}
/**
* Filters the template name to include.
*
* @since 1.7.0
*
* @param string $template Template name.
*/
return apply_filters('bp_template_include_theme_compat', $template);
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:80,代码来源:bp-core-theme-compatibility.php
示例5: bp_core_load_template
/**
* Load a specific template file with fallback support.
*
* Example:
* bp_core_load_template( 'members/index' );
* Loads:
* wp-content/themes/[activated_theme]/members/index.php
*
* @param array $templates Array of templates to attempt to load.
* @return bool|null Returns false on failure.
*/
function bp_core_load_template($templates)
{
global $wp_query;
// check if BP page belongs to, or is a child of, a BP directory page
$page_id = false;
foreach ((array) buddypress()->pages as $page) {
if ($page->name == buddypress()->unfiltered_uri[buddypress()->unfiltered_uri_offset]) {
$page_id = $page->id;
break;
}
}
// Set up reset post args
$reset_post_args = array('is_404' => true, 'post_status' => 'publish');
// BP page exists - fill in the $wp_query->post object
//
// bp_theme_compat_reset_post() looks at the $wp_query->post object to fill in
// the post globals
if (!empty($page_id)) {
$wp_query->post = get_post($page_id);
$reset_post_args['ID'] = $page_id;
} else {
$reset_post_args['ID'] = 0;
}
// Reset the post
bp_theme_compat_reset_post($reset_post_args);
// Set theme compat to false since the reset post function automatically sets
// theme compat to true
bp_set_theme_compat_active(false);
// Fetch each template and add the php suffix
$filtered_templates = array();
foreach ((array) $templates as $template) {
$filtered_templates[] = $template . '.php';
}
// Only perform template lookup for bp-default themes
if (!bp_use_theme_compat_with_current_theme()) {
$template = locate_template((array) $filtered_templates, false);
// Theme compat doesn't require a template lookup
} else {
$template = '';
}
// Filter the template locations so that plugins can alter where they are located
$located_template = apply_filters('bp_located_template', $template, $filtered_templates);
if (!empty($located_template)) {
// Template was located, lets set this as a valid page and not a 404.
status_header(200);
$wp_query->is_page = true;
$wp_query->is_singular = true;
$wp_query->is_404 = false;
do_action('bp_core_pre_load_template', $located_template);
load_template(apply_filters('bp_load_template', $located_template));
do_action('bp_core_post_load_template', $located_template);
// Kill any other output after this.
exit;
// No template found, so setup theme compatability
// @todo Some other 404 handling if theme compat doesn't kick in
} else {
// We know where we are, so reset important $wp_query bits here early.
// The rest will be done by bp_theme_compat_reset_post() later.
if (is_buddypress()) {
status_header(200);
$wp_query->is_page = true;
$wp_query->is_singular = true;
$wp_query->is_404 = false;
}
do_action('bp_setup_theme_compat');
}
}
开发者ID:eresyyl,项目名称:mk,代码行数:78,代码来源:bp-core-catchuri.php
示例6: bp_core_load_template
/**
* Load a specific template file with fallback support.
*
* Example:
* bp_core_load_template( 'members/index' );
* Loads:
* wp-content/themes/[activated_theme]/members/index.php
*
* @param array $templates Array of templates to attempt to load.
* @return bool|null Returns false on failure.
*/
function bp_core_load_template( $templates ) {
global $wp_query;
// Reset the post
bp_theme_compat_reset_post( array(
'ID' => 0,
'is_404' => true,
'post_status' => 'publish',
) );
// Set theme compat to false since the reset post function automatically sets
// theme compat to true
bp_set_theme_compat_active( false );
// Fetch each template and add the php suffix
$filtered_templates = array();
foreach ( (array) $templates as $template ) {
$filtered_templates[] = $template . '.php';
}
// Only perform template lookup for bp-default themes
if ( ! bp_use_theme_compat_with_current_theme() ) {
$template = locate_template( (array) $filtered_templates, false );
// Theme compat doesn't require a template lookup
} else {
$template = '';
}
// Filter the template locations so that plugins can alter where they are located
$located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
if ( !empty( $located_template ) ) {
// Template was located, lets set this as a valid page and not a 404.
status_header( 200 );
$wp_query->is_page = true;
$wp_query->is_singular = true;
$wp_query->is_404 = false;
do_action( 'bp_core_pre_load_template', $located_template );
load_template( apply_filters( 'bp_load_template', $located_template ) );
do_action( 'bp_core_post_load_template', $located_template );
// Kill any other output after this.
exit();
// No template found, so setup theme compatibility
// @todo Some other 404 handling if theme compat doesn't kick in
} else {
// We know where we are, so reset important $wp_query bits here early.
// The rest will be done by bp_theme_compat_reset_post() later.
if ( is_buddypress() ) {
status_header( 200 );
$wp_query->is_page = true;
$wp_query->is_singular = true;
$wp_query->is_404 = false;
}
do_action( 'bp_setup_theme_compat' );
}
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:74,代码来源:bp-core-catchuri.php
示例7: generate_activity_stream
public function generate_activity_stream($atts, $content = null)
{
//allow to use all those args awesome!
$atts = shortcode_atts(array('title' => 'Latest Activity', 'pagination' => 'true', 'display_comments' => 'threaded', 'include' => false, 'exclude' => false, 'in' => false, 'sort' => 'DESC', 'page' => 1, 'per_page' => 5, 'max' => false, 'scope' => false, 'user_id' => false, 'object' => false, 'action' => false, 'primary_id' => false, 'secondary_id' => false, 'search_terms' => false, 'use_compat' => bp_use_theme_compat_with_current_theme(), 'allow_posting' => false), $atts);
extract($atts);
//hide on user activity, activity directory and group activity
if (is_user_logged_in() && (function_exists('bp_is_activity_component') && bp_is_activity_component() || function_exists('bp_is_group_home') && bp_is_group_home())) {
return '';
}
ob_start();
?>
<?php
if ($use_compat) {
?>
<div id="buddypress">
<?php
}
?>
<?php
if ($title) {
?>
<h3 class="activity-shortcode-title"><?php
echo $title;
?>
</h3>
<?php
}
?>
<?php
do_action('bp_before_activity_loop');
?>
<?php
if ($allow_posting && is_user_logged_in()) {
?>
<?php
bp_locate_template(array('activity/post-form.php'), true);
?>
<?php
}
?>
<?php
if (bp_has_activities($atts)) {
?>
<div class="activity <?php
if (!$display_comments) {
?>
hide-activity-comments<?php
}
?>
shortcode-activity-stream">
<?php
if (empty($_POST['page'])) {
?>
<ul id="activity-stream" class="activity-list item-list">
<?php
}
?>
<?php
while (bp_activities()) {
bp_the_activity();
?>
<?php
bp_get_template_part('activity/entry');
?>
<?php
}
?>
<?php
if (empty($_POST['page'])) {
?>
</ul>
<?php
}
?>
<?php
if ($pagination) {
?>
<div class="pagination">
<div class="pag-count"><?php
bp_activity_pagination_count();
?>
</div>
<div class="pagination-links"><?php
bp_activity_pagination_links();
//.........这里部分代码省略.........
开发者ID:poweronio,项目名称:mbsite,代码行数:101,代码来源:bp-activity-as-shortcode.php
注:本文中的bp_use_theme_compat_with_current_theme函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论