BP_Forum_Legacy_Theme_Compat

The main theme compat class for legacy BuddyPress forums.

Defined (1)

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

/bp-forums/bp-forums-screens.php  
  1. class BP_Forum_Legacy_Theme_Compat { 
  2.  
  3. /** 
  4. * Set up theme compatibility for the legacy forums component. 
  5. * @since 1.7.0 
  6. */ 
  7. public function __construct() { 
  8. add_action( 'bp_setup_theme_compat', array( $this, 'is_legacy_forum' ) ); 
  9.  
  10. /** 
  11. * Are we looking at something that needs old forum theme compatibility? 
  12. * @since 1.7.0 
  13. */ 
  14. public function is_legacy_forum() { 
  15.  
  16. // Bail if not looking at a group. 
  17. if ( ! bp_is_forums_component() ) 
  18. return; 
  19.  
  20. // Forum Directory. 
  21. if ( ( ! bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && ! bp_current_item() ) { 
  22.  
  23. if ( ! bp_forums_has_directory() ) 
  24. return false; 
  25.  
  26. if ( ! bp_forums_is_installed_correctly() ) { 
  27. bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); 
  28. bp_core_redirect( bp_get_root_domain() ); 
  29.  
  30. bp_update_is_directory( true, 'forums' ); 
  31.  
  32. do_action( 'bp_forums_directory_forums_setup' ); 
  33.  
  34. add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) ); 
  35. add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 
  36.  
  37.  
  38.  
  39. /** Directory *************************************************************/ 
  40.  
  41. /** 
  42. * Update the global $post with directory data. 
  43. * @since 1.7.0 
  44. */ 
  45. public function directory_dummy_post() { 
  46.  
  47. // Title based on ability to create groups. 
  48. if ( is_user_logged_in() ) { 
  49. $title = __( 'Forums', 'buddypress' ) . ' <a class="button show-hide-new bp-title-button" href="#new-topic" id="new-topic-button">' . __( 'New Topic', 'buddypress' ) . '</a>'; 
  50. } else { 
  51. $title = __( 'Forums', 'buddypress' ); 
  52.  
  53. bp_theme_compat_reset_post( array( 
  54. 'ID' => 0,  
  55. 'post_title' => $title,  
  56. 'post_author' => 0,  
  57. 'post_date' => 0,  
  58. 'post_content' => '',  
  59. 'post_type' => 'page',  
  60. 'post_status' => 'publish',  
  61. 'is_page' => true,  
  62. 'comment_status' => 'closed' 
  63. ) ); 
  64.  
  65. /** 
  66. * Filter the_content with the old forum index template part. 
  67. * @since 1.7.0 
  68. */ 
  69. public function directory_content() { 
  70. return bp_buffer_template_part( 'forums/index', null, false );