bbp_register_sidebar(); $this->bbp_post_actions(); $this->bbp_forum_layout(); $this->constants(); $this->theme_support(); $this->post_type_support(); } /** * Loads all the parent theme files * * @since 1.0.0 */ public function launch() { # Hook in before the action happens do_action( 'bizznis_pre_bbpress_integration' ); # Stop here, if bizznis bbpress integratin is not defined if ( ! current_theme_supports( 'bizznis-bbpress' ) ) { return; } # Environment is OK, let's go! load_template( BIZZNIS_BBP_INC_DIR . '/settings.php' ); } /** * Register forum specific sidebar if enabled * * @since 1.0.0 */ public function bbp_register_sidebar() { # Register sidebar if option checked if ( bizznis_get_option( 'bizznis_bbp_sidebar' ) ) { bizznis_register_sidebar( array( 'id' => 'sidebar-bbpress', 'name' => __( 'Forums Sidebar', 'bizznis' ), 'description' => __( 'This is the primary sidebar used on all bbPress pages.', 'bizznis' ) ) ); } # Replace the primary sidebar add_action( 'bizznis_before', array( $this, 'check_bbp_sidebar' ) ); } /** * Setup bbPress specific sidebar on bbPress pages if enabled * * @since 1.0.0 */ public function check_bbp_sidebar() { if ( is_bbpress() && bizznis_get_option( 'bizznis_bbp_sidebar' ) ) { # Remove the default Bizznis sidebar remove_action( 'bizznis_sidebar', 'bizznis_do_sidebar' ); # Load up the bbPress sidebar add_action( 'bizznis_sidebar', array( $this, 'load_bbp_sidebar' ) ); } } /** * Loads text instructions when bbPress specific sidebar is empty * * @since 1.0.0 */ public function load_bbp_sidebar() { # Throw up placeholder content if the sidebar is active but empty if ( ! dynamic_sidebar( 'sidebar-bbpress' ) && current_user_can( 'edit_theme_options' ) ) { bizznis_default_widget_area_content( __( 'bbPress Sidebar Widget Area', 'bizznis' ) ); } } /** * Tweak Bizznis post actions * * @since 1.0.0 */ public function bbp_post_actions() { # Remove forum/topic descriptions if ( bizznis_get_option( 'bizznis_bbp_desc' ) ) { add_filter( 'bbp_get_single_forum_description', '__return_false' ); add_filter( 'bbp_get_single_topic_description', '__return_false' ); } # Manipulate with bizznis hooks add_action( 'bizznis_before', array( $this, 'bizznis_post_actions' ) ); } /** * Check if bbPress template * * @since 1.0.2 */ public function bizznis_post_actions() { # Stop here, if not on a bbpress template if ( ! is_bbpress() ) { return; } # Remove bizznis breadcrumbs remove_action( 'bizznis_loop', 'bizznis_do_breadcrumbs', 4 ); # Remove post info & meta remove_action( 'bizznis_post_content', 'bizznis_post_info' ); remove_action( 'bizznis_post_content', 'bizznis_post_meta' ); remove_action( 'bizznis_entry_header', 'bizznis_post_info' ); remove_action( 'bizznis_entry_footer', 'bizznis_post_meta' ); # Remove Bizznis post image and content remove_action( 'bizznis_post_content', 'bizznis_do_post_image' ); remove_action( 'bizznis_post_content', 'bizznis_do_post_content' ); remove_action( 'bizznis_entry_content', 'bizznis_do_post_image' ); remove_action( 'bizznis_entry_content', 'bizznis_do_post_content' ); # Remove authorbox remove_action( 'bizznis_after_entry', 'bizznis_do_author_box_single' ); remove_action( 'bizznis_entry_footer', 'bizznis_do_author_box_single' ); # Remove the navigation remove_action( 'bizznis_after_endwhile', 'bizznis_posts_nav' ); # Remove Bizznis profile fields if ( bbp_is_single_user_edit() ) { remove_action( 'show_user_profile', 'bizznis_user_options_fields' ); remove_action( 'show_user_profile', 'bizznis_user_layout_fields' ); remove_action( 'show_user_profile', 'bizznis_user_seo_fields' ); remove_action( 'show_user_profile', 'bizznis_user_archive_fields' ); } # Re-add the_content back add_action( 'bizznis_post_content', 'the_content' ); add_action( 'bizznis_entry_content', 'the_content' ); } /** * Register forum specific layout if enabled * * @since 1.0.0 */ public function bbp_forum_layout() { # Replace layout with custom selected inside theme settings add_filter( 'bizznis_pre_get_option_site_layout', array( $this, 'bbp_select_layout' ) ); } /** * Selecz forum specific sidebar if enabled * * @since 1.0.0 */ public function bbp_select_layout( $layout ) { # Stop here, if not on a bbpress template if ( ! is_bbpress() ) { return $layout; } # Set some defaults $forum_id = bbp_get_forum_id(); # For some reason, if we use the cached version, weird things seem to happen. $retval = bizznis_get_option( 'site_layout', null, false ); $parent = false; # Check and see if a layout has been set for the parent forum if ( !empty( $forum_id ) ) { $parent = esc_attr( get_post_meta( $forum_id, '_bizznis_layout' , true ) ); if ( !empty( $parent ) ) { return apply_filters( 'bizznis_bbp_layout', $parent ); } } # Second, see if a layout has been defined in the bbPress Bizznis settings if ( empty( $parent ) || ( bizznis_get_option( 'bizznis_bbp_layout' ) !== 'bizznis-default' ) ) { $retval = bizznis_get_option( 'bizznis_bbp_layout' ); } # Filter the return value return apply_filters( 'bizznis_bbp_layout', $retval, $forum_id, $parent ); } /** * Defines theme constants throughout the template * * @since 1.0.0 */ private function constants() { # Directory Locations define( 'BIZZNIS_BBP_INC_DIR', BIZZNIS_INT_BBP_DIR . '/inc' ); define( 'BIZZNIS_BBP_TEMPLATES_DIR', BIZZNIS_INT_BBP_DIR . '/templates' ); # URL Locations define( 'BIZZNIS_BBP_INC_URL', BIZZNIS_INT_BBP_URL . '/inc' ); define( 'BIZZNIS_BBP_TEMPLATES_URL', BIZZNIS_INT_BBP_URL . '/templates' ); } /** * Activates default theme features. * * @since 1.0.0 */ public function theme_support() { add_theme_support( 'bbpress' ); add_theme_support( 'bizznis-bbpress' ); } /** * Initialize post type support for Bizznis features (Layout selector, SEO, Scripts). * * @since 1.0.0 */ public function post_type_support() { add_post_type_support( 'forum', array( 'bizznis-seo', 'bizznis-scripts', 'bizznis-layouts' ) ); add_post_type_support( 'topic', array( 'bizznis-seo', 'bizznis-scripts', 'bizznis-layouts' ) ); } } /** * Launch the ingration class * * @since 1.0.0 */ add_action( 'bbp_after_setup_theme', 'bizznis_bbp_integration' ); function bizznis_bbp_integration() { $bizznis = new Bizznis_BBP; #ready, set, go! $bizznis->launch(); }