bbpresstallyc

The bbPress Connect For Tally Framework bbpresstallyc class.

Defined (1)

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

/bbpress-connect-for-tally-framework.php  
  1. class bbpresstallyc{ 
  2.  
  3. function __construct() { 
  4. add_action('init', array($this, 'load_textdomain')); 
  5. add_action('after_setup_theme', array($this, 'after_setup_theme')); 
  6.  
  7.  
  8.  
  9. /** Load TextDomain ********************************************************************/ 
  10. /** 
  11. * Add languages files. 
  12. * @since 0.1 
  13. * @uses load_plugin_textdomain() 
  14. */ 
  15. function load_textdomain() { 
  16. load_plugin_textdomain( 'bbpresstallyc_textdomain', false, dirname(plugin_basename(__FILE__)).'/languages/' ); 
  17.  
  18.  
  19.  
  20. /** after_setup_theme hook function ****************************************************/ 
  21. /** 
  22. * This function contain all elements that's need  
  23. * to attached in "after_setup_theme" hook. 
  24. * @since 0.1 
  25. * @used with "after_setup_theme" hook 
  26. */ 
  27. function after_setup_theme() { 
  28. /** Fail silently if WooCommerce is not activated */ 
  29. if ( ! in_array( 'bbpress/bbpress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return;  
  30. if(!function_exists('tally_option')) return;  
  31.  
  32. /** Setup bbPress sidebar*/ 
  33. register_sidebar( array( 
  34. 'name' => __('bbPress Sidebar', 'bbpresstallyc_textdomain'),  
  35. 'id' => 'tally_bbpress',  
  36. 'description' => __('bbPress shop Sidebar Widgets', 'bbpresstallyc_textdomain'),  
  37. 'before_widget' => '<div id="%1$s" class="widget %2$s">',  
  38. 'after_widget' => "</div><div class='clear' style='height:30px;'></div>",  
  39. 'before_title' => '<h4 class="heading">',  
  40. 'after_title' => '</h4>',  
  41. )); 
  42. add_action( 'tally_sidebar', array($this, 'add_sidebar') ); 
  43. add_filter('tally_sidebar_active', array($this, 'disable_theme_sidebar')); 
  44.  
  45. add_action('tally_reset_loops', array($this, 'add_page_content')); 
  46.  
  47. add_filter ('bbp_no_breadcrumb', '__return_true'); 
  48.  
  49. add_action('wp_enqueue_scripts', array($this, 'custom_scripts')); 
  50.  
  51. add_filter('tally_page_title', array($this, 'archive_page_title')); 
  52.  
  53.  
  54.  
  55. /** Add Sidebar To the theme ****************************************************/ 
  56. /** 
  57. * This function add "tally_bbpress" in the theme. 
  58. * @since 0.1 
  59. * @used with "tally_sidebar" hook 
  60. */ 
  61. function add_sidebar() { 
  62. if(is_bbpress()) { 
  63. if ( ! dynamic_sidebar( 'tally_bbpress' ) && current_user_can( 'edit_theme_options' ) ) { 
  64. if(function_exists('tally_default_widget_area_content')) { tally_default_widget_area_content( __( 'bbPress Sidebar Widget Area', 'tally_textdomain' ) ); }; 
  65. }  
  66.  
  67.  
  68. /** Disable Theme Sidebar *****************************************************/ 
  69. /** 
  70. * This function disable deafult sidebar of the theme 
  71. * @since 0.1 
  72. * @used with "tally_sidebar_active" filter 
  73. */ 
  74. function disable_theme_sidebar($active) { 
  75. if(is_bbpress()) { 
  76. $active = false; 
  77.  
  78. return $active; 
  79.  
  80.  
  81.  
  82. /** Make the page content *****************************************************/ 
  83. /** 
  84. * This function remove some unwanted post element from the theme 
  85. * @since 0.1 
  86. * @used with "tally_reset_loops" hook 
  87. */ 
  88. function add_page_content($active) { 
  89. if(is_bbpress()) { 
  90. tally_defaults_reset_loops(); 
  91.  
  92. remove_action( 'tally_entry_header', 'tally_do_post_media', 4 ); 
  93. remove_action( 'tally_entry_header', 'tally_entry_header_markup_open', 5 ); 
  94. remove_action( 'tally_entry_header', 'tally_entry_header_markup_close', 15 ); 
  95. remove_action( 'tally_entry_header', 'tally_do_post_title' ); 
  96. remove_action( 'tally_entry_header', 'tally_do_post_info', 12 ); 
  97. remove_action( 'tally_entry_header', 'tally_do_post_format_link', 13 ); 
  98. remove_action( 'tally_entry_content', 'tally_do_post_format_quote', 10 ); 
  99. remove_action( 'tally_entry_content', 'tally_do_post_content_nav', 12 ); 
  100. remove_action( 'tally_entry_footer', 'tally_entry_footer_markup_open', 5 ); 
  101. remove_action( 'tally_entry_footer', 'tally_entry_footer_markup_close', 15 ); 
  102. remove_action( 'tally_entry_footer', 'tally_do_post_meta' ); 
  103. remove_action( 'tally_after_entry', 'tally_do_author_box_single', 8 ); 
  104. remove_action( 'tally_after_endwhile', 'tally_do_posts_nav' ); 
  105.  
  106. return $active; 
  107.  
  108.  
  109.  
  110. /** Load Custom frontend scripts ***********************************************/ 
  111. /** 
  112. * This function add custom css and jsvascript for bbpress 
  113. * @since 0.1 
  114. * @used with "bbp_enqueue_scripts" hook 
  115. */ 
  116. function custom_scripts() { 
  117. if(class_exists('bbPress')) { 
  118. if(apply_filters('bbpresstallyc_custom_css', false) == true) { 
  119. wp_deregister_style( 'bbp-default' ); 
  120. wp_enqueue_style( 'bbp-default', BBPRESSTALLYC_URL.'assets/css/bbpress.css' ); 
  121.  
  122.  
  123. /** Add Archive page title ***********************************************/ 
  124. /** 
  125. * This function add title in the forum index page 
  126. * @since 0.1 
  127. * @used with "tally_page_title" filter 
  128. */ 
  129. function archive_page_title($title) { 
  130. if(class_exists('bbPress') && is_bbpress() && is_post_type_archive('forum')) { 
  131. ob_start(); 
  132. bbp_forum_archive_title(); 
  133. $title = ob_get_contents(); 
  134. ob_end_clean(); 
  135. return $title; 
  136.  
  137.  
  138. }// END of the class