BP_Registration_Theme_Compat

The main theme compat class for BuddyPress Registration.

Defined (1)

The class is defined in the following location(s).

/bp-members/classes/class-bp-registration-theme-compat.php  
  1. class BP_Registration_Theme_Compat { 
  2.  
  3. /** 
  4. * Setup the groups component theme compatibility. 
  5. * @since 1.7.0 
  6. */ 
  7. public function __construct() { 
  8. add_action( 'bp_setup_theme_compat', array( $this, 'is_registration' ) ); 
  9.  
  10. /** 
  11. * Are we looking at either the registration or activation pages? 
  12. * @since 1.7.0 
  13. */ 
  14. public function is_registration() { 
  15.  
  16. // Bail if not looking at the registration or activation page. 
  17. if ( ! bp_is_register_page() && ! bp_is_activation_page() ) { 
  18. return; 
  19.  
  20. // Not a directory. 
  21. bp_update_is_directory( false, 'register' ); 
  22.  
  23. // Setup actions. 
  24. add_filter( 'bp_get_buddypress_template', array( $this, 'template_hierarchy' ) ); 
  25. add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post' ) ); 
  26. add_filter( 'bp_replace_the_content', array( $this, 'dummy_content' ) ); 
  27.  
  28. /** Template ***********************************************************/ 
  29.  
  30. /** 
  31. * Add template hierarchy to theme compat for registration/activation pages. 
  32. * This is to mirror how WordPress has 
  33. * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}. 
  34. * @since 1.8.0 
  35. * @param string $templates The templates from bp_get_theme_compat_templates(). 
  36. * @return array $templates Array of custom templates to look for. 
  37. */ 
  38. public function template_hierarchy( $templates ) { 
  39. $component = sanitize_file_name( bp_current_component() ); 
  40.  
  41. /** 
  42. * Filters the template hierarchy for theme compat and registration/activation pages. 
  43. * This filter is a variable filter that depends on the current component 
  44. * being used. 
  45. * @since 1.8.0 
  46. * @param array $value Array of template paths to add to hierarchy. 
  47. */ 
  48. $new_templates = apply_filters( "bp_template_hierarchy_{$component}", array( 
  49. "members/index-{$component}.php" 
  50. ) ); 
  51.  
  52. // Merge new templates with existing stack 
  53. // @see bp_get_theme_compat_templates(). 
  54. $templates = array_merge( (array) $new_templates, $templates ); 
  55.  
  56. return $templates; 
  57.  
  58. /** 
  59. * Update the global $post with dummy data. 
  60. * @since 1.7.0 
  61. */ 
  62. public function dummy_post() { 
  63. // Registration page. 
  64. if ( bp_is_register_page() ) { 
  65. $title = __( 'Create an Account', 'buddypress' ); 
  66.  
  67. if ( 'completed-confirmation' == bp_get_current_signup_step() ) { 
  68. $title = __( 'Check Your Email To Activate Your Account!', 'buddypress' ); 
  69.  
  70. // Activation page. 
  71. } else { 
  72. $title = __( 'Activate Your Account', 'buddypress' ); 
  73.  
  74. if ( bp_account_was_activated() ) { 
  75. $title = __( 'Account Activated', 'buddypress' ); 
  76.  
  77. bp_theme_compat_reset_post( array( 
  78. 'ID' => 0,  
  79. 'post_title' => $title,  
  80. 'post_author' => 0,  
  81. 'post_date' => 0,  
  82. 'post_content' => '',  
  83. 'post_type' => 'page',  
  84. 'post_status' => 'publish',  
  85. 'is_page' => true,  
  86. 'comment_status' => 'closed' 
  87. ) ); 
  88.  
  89. /** 
  90. * Filter the_content with either the register or activate templates. 
  91. * @since 1.7.0 
  92. */ 
  93. public function dummy_content() { 
  94. if ( bp_is_register_page() ) { 
  95. return bp_buffer_template_part( 'members/register', null, false ); 
  96. } else { 
  97. return bp_buffer_template_part( 'members/activate', null, false );