简体   繁体   English

从主题检查buddypress

[英]Checking for buddypress from a theme

How can I check for buddypress from a theme? 如何从某个主题检查buddypress? I've found this page for BP Plugin development 我已经找到此页面用于BP 插件开发

but this action never gets loaded if I hook from a theme. 但是如果我从主题上钩下来,就永远不会加载此操作。 Why does it not work? 为什么不起作用?

PS I need call some BP's functions from a theme, like: Show "BP's Activity Stream" at specific places. PS我需要从某个主题调用BP的一些功能,例如:在特定位置显示“ BP的活动流”。

What I mean with "never gets loaded" is: 我的意思是“永不加载”:

(File in subdirectory of theme, and included in functions.php) (文件位于主题的子目录中,并包含在functions.php中)

function sometestfunction() {
  exit();
}

add_action ('bp_include', 'sometestfunction');

This must make wordpress show a blank page, won't ? 这必须使wordpress显示空白页,不是吗?

Simple check if function 'bp_is_active' is defined: 简单检查是否定义了函数“ bp_is_active”:

if ( function_exists('bp_is_active') ) {
  // do something here...
}

see shanebp answer and comments. 请参阅shanebp的答案和评论。

this action never gets loaded 这个动作永远不会加载

You mean never gets called? 你的意思是永远不会被打来? Not sure why that would be, since you don't provide any code. 不知道为什么会这样,因为您不提供任何代码。 But it's meant for loading plugins. 但这是为了加载插件。

If BP is installed, it is loaded by the time theme templates are parsed. 如果安装了BP,则在解析主题模板时将其加载。

Have you tried calling BP functions in your theme? 您是否尝试过在主题中调用BP函数? I've never had a problem doing that. 我这样做从来没有问题。

Put your function(s) in one of these places: 将您的函数放在以下位置之一:

  • a plugin 一个插件
  • theme/functions.php theme / functions.php
  • bp-custom.php bp-custom.php

http://codex.buddypress.org/plugindev/bp-custom-php/ http://codex.buddypress.org/plugindev/bp-custom-php/

If your code will be used on installs you don't control, you should check for a BuddyPress component: 如果您的代码将用于您无法控制的安装,则应检查BuddyPress组件:

if( bp_is_active( 'activity' ) {  

http://codex.buddypress.org/developer/bp-is-active/ http://codex.buddypress.org/developer/bp-is-active/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM