bbpresstallyc

The WordPress Core 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_template_init', 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', 'bbpresstallyc_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() { 
  89. if(is_bbpress()) { 
  90. remove_all_actions('tally_loop'); 
  91. add_action('tally_loop', array($this, 'page_content')); 
  92.  
  93.  
  94. function page_content() { 
  95. if ( have_posts() ) :  
  96. while ( have_posts() ) : the_post(); 
  97. echo '<article '; post_class(); echo '>'; 
  98. echo '<div class="entry-content">'; 
  99. the_content(); 
  100. echo '</div>'; 
  101. echo '</article>'; 
  102. endwhile; 
  103. else : 
  104. _e('Sorry No Post fund', 'bbpresstallyc_textdomain'); 
  105. endif; 
  106.  
  107.  
  108.  
  109. /** Load Custom frontend scripts ***********************************************/ 
  110. /** 
  111. * This function add custom css and jsvascript for bbpress 
  112. * @since 0.1 
  113. * @used with "bbp_enqueue_scripts" hook 
  114. */ 
  115. function custom_scripts() { 
  116. if(class_exists('bbPress')) { 
  117. if(apply_filters('bbpresstallyc_custom_css', false) == true) { 
  118. wp_deregister_style( 'bbp-default' ); 
  119. wp_enqueue_style( 'bbp-default', BBPRESSTALLYC_URL.'assets/css/bbpress.css' ); 
  120.  
  121.  
  122. /** Add Archive page title ***********************************************/ 
  123. /** 
  124. * This function add title in the forum index page 
  125. * @since 0.1 
  126. * @used with "tally_page_title" filter 
  127. */ 
  128. function archive_page_title($title) { 
  129. if(class_exists('bbPress') && is_bbpress() && is_post_type_archive('forum')) { 
  130. ob_start(); 
  131. bbp_forum_archive_title(); 
  132. $title = ob_get_contents(); 
  133. ob_end_clean(); 
  134. return $title; 
  135.  
  136.  
  137. }// END of the class