BP_Registration_Theme_Compat

BuddyPress注册的主要主题compat类。

描述

这个类设置了必要的主题兼容性操作,以安全地将注册模板部分输出到主题的the_title和the_content区域。

文件:bp-members /类/ class-bp-registration-theme-compat.php

类BP_Registration_Theme_Compat{/** *设置组组件主题的兼容性。* * @since BuddyPress 1.7.0 */ public function __construct() {add_action('bp_setup_theme_compat', array($this, 'is_registration'));} /** *我们正在查看注册或激活页面?* * @since BuddyPress 1.7.0 */ public function is_registration(){//如果没有查看注册或激活页面,保释。如果(!bp_is_register_page () & & !Bp_is_activation_page()){返回;} //不是目录。Bp_update_is_directory (false, '注册');/ /设置操作。 add_filter( 'bp_get_buddypress_template', array( $this, 'template_hierarchy' ) ); add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post' ) ); add_filter( 'bp_replace_the_content', array( $this, 'dummy_content' ) ); } /** Template ***********************************************************/ /** * Add template hierarchy to theme compat for registration/activation pages. * * This is to mirror how WordPress has * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}. * * @since BuddyPress 1.8.0 * * @param string $templates The templates from bp_get_theme_compat_templates(). * @return array $templates Array of custom templates to look for. */ public function template_hierarchy( $templates ) { $component = sanitize_file_name( bp_current_component() ); /** * Filters the template hierarchy for theme compat and registration/activation pages. * * This filter is a variable filter that depends on the current component * being used. * * @since BuddyPress 1.8.0 * * @param array $value Array of template paths to add to hierarchy. */ $new_templates = apply_filters( "bp_template_hierarchy_{$component}", array( "members/index-{$component}.php" ) ); // Merge new templates with existing stack // @see bp_get_theme_compat_templates(). $templates = array_merge( (array) $new_templates, $templates ); return $templates; } /** * Update the global $post with dummy data. * * @since BuddyPress 1.7.0 */ public function dummy_post() { // Registration page. if ( bp_is_register_page() ) { $title = __( 'Create an Account', 'buddyboss' ); if ( 'completed-confirmation' == bp_get_current_signup_step() ) { $title = __( 'We\'re almost there!', 'buddyboss' ); } // Activation page. } else { $title = __( 'Activate Your Account', 'buddyboss' ); if ( bp_account_was_activated() ) { $title = __( 'Account Activated', 'buddyboss' ); } } bp_theme_compat_reset_post( array( 'ID' => 0, 'post_title' => $title, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => 'page', 'post_status' => 'publish', 'is_page' => true, 'comment_status' => 'closed' ) ); } /** * Filter the_content with either the register or activate templates. * * @since BuddyPress 1.7.0 */ public function dummy_content() { if ( bp_is_register_page() ) { return bp_buffer_template_part( 'members/register', null, false ); } else { return bp_buffer_template_part( 'members/activate', null, false ); } } }

更新日志

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

方法

问题吗?

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