BP_Activity_Theme_Compat

The main theme compat class for BuddyPress Activity.

Defined (1)

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

/bp-activity/classes/class-bp-activity-theme-compat.php  
  1. class BP_Activity_Theme_Compat { 
  2.  
  3. /** 
  4. * Set up the activity component theme compatibility. 
  5. * @since 1.7.0 
  6. */ 
  7. public function __construct() { 
  8. add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) ); 
  9.  
  10. /** 
  11. * Set up the theme compatibility hooks, if we're looking at an activity page. 
  12. * @since 1.7.0 
  13. */ 
  14. public function is_activity() { 
  15.  
  16. // Bail if not looking at a group. 
  17. if ( ! bp_is_activity_component() ) 
  18. return; 
  19.  
  20. // Activity Directory. 
  21. if ( ! bp_displayed_user_id() && ! bp_current_action() ) { 
  22. bp_update_is_directory( true, 'activity' ); 
  23.  
  24. /** This action is documented in bp-activity/bp-activity-screens.php */ 
  25. do_action( 'bp_activity_screen_index' ); 
  26.  
  27. add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) ); 
  28. add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) ); 
  29. add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 
  30.  
  31. // Single activity. 
  32. } elseif ( bp_is_single_activity() ) { 
  33. add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) ); 
  34. add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'single_dummy_post' ) ); 
  35. add_filter( 'bp_replace_the_content', array( $this, 'single_dummy_content' ) ); 
  36.  
  37. /** Directory *************************************************************/ 
  38.  
  39. /** 
  40. * Add template hierarchy to theme compat for the activity directory page. 
  41. * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}. 
  42. * @since 1.8.0 
  43. * @param string $templates The templates from bp_get_theme_compat_templates(). 
  44. * @return array $templates Array of custom templates to look for. 
  45. */ 
  46. public function directory_template_hierarchy( $templates ) { 
  47.  
  48. /** 
  49. * Filters the template hierarchy for the activity directory page. 
  50. * @since 1.8.0 
  51. * @param array $index-directory Array holding template names to be merged into template list. 
  52. */ 
  53. $new_templates = apply_filters( 'bp_template_hierarchy_activity_directory', array( 
  54. 'activity/index-directory.php' 
  55. ) ); 
  56.  
  57. // Merge new templates with existing stack 
  58. // @see bp_get_theme_compat_templates(). 
  59. $templates = array_merge( (array) $new_templates, $templates ); 
  60.  
  61. return $templates; 
  62.  
  63. /** 
  64. * Update the global $post with directory data. 
  65. * @since 1.7.0 
  66. */ 
  67. public function directory_dummy_post() { 
  68. bp_theme_compat_reset_post( array( 
  69. 'ID' => 0,  
  70. 'post_title' => bp_get_directory_title( 'activity' ),  
  71. 'post_author' => 0,  
  72. 'post_date' => 0,  
  73. 'post_content' => '',  
  74. 'post_type' => 'page',  
  75. 'post_status' => 'publish',  
  76. 'is_page' => true,  
  77. 'comment_status' => 'closed' 
  78. ) ); 
  79.  
  80. /** 
  81. * Filter the_content with the groups index template part. 
  82. * @since 1.7.0 
  83. */ 
  84. public function directory_content() { 
  85. return bp_buffer_template_part( 'activity/index', null, false ); 
  86.  
  87. /** Single ****************************************************************/ 
  88.  
  89. /** 
  90. * Add custom template hierarchy to theme compat for activity permalink pages. 
  91. * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}. 
  92. * @since 1.8.0 
  93. * @param string $templates The templates from bp_get_theme_compat_templates(). 
  94. * @return array $templates Array of custom templates to look for. 
  95. */ 
  96. public function single_template_hierarchy( $templates ) { 
  97.  
  98. /** 
  99. * Filters the template hierarchy for the activity permalink pages. 
  100. * @since 1.8.0 
  101. * @param array $index Array holding template names to be merged into template list. 
  102. */ 
  103. $new_templates = apply_filters( 'bp_template_hierarchy_activity_single_item', array( 
  104. 'activity/single/index.php' 
  105. ) ); 
  106.  
  107. // Merge new templates with existing stack 
  108. // @see bp_get_theme_compat_templates(). 
  109. $templates = array_merge( (array) $new_templates, $templates ); 
  110.  
  111. return $templates; 
  112.  
  113. /** 
  114. * Update the global $post with the displayed user's data. 
  115. * @since 1.7.0 
  116. */ 
  117. public function single_dummy_post() { 
  118. bp_theme_compat_reset_post( array( 
  119. 'ID' => 0,  
  120. 'post_title' => __( 'Activity', 'buddypress' ),  
  121. 'post_author' => 0,  
  122. 'post_date' => 0,  
  123. 'post_content' => '',  
  124. 'post_type' => 'page',  
  125. 'post_status' => 'publish',  
  126. 'is_page' => true,  
  127. 'comment_status' => 'closed' 
  128. ) ); 
  129.  
  130. /** 
  131. * Filter the_content with the members' activity permalink template part. 
  132. * @since 1.7.0 
  133. */ 
  134. public function single_dummy_content() { 
  135. return bp_buffer_template_part( 'activity/single/home', null, false );