buddypresstallyc

The WordPress Core buddypresstallyc class.

Defined (1)

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

/buddypress-connect-for-tally-framework.php  
  1. class buddypresstallyc{ 
  2. function __construct() { 
  3. add_action('init', array($this, 'load_textdomain')); 
  4. add_action('after_setup_theme', array($this, 'after_setup_theme')); 
  5.  
  6.  
  7. /** Load TextDomain ********************************************************************/ 
  8. /** 
  9. * Add languages files. 
  10. * @since 0.1 
  11. * @uses load_plugin_textdomain() 
  12. */ 
  13. function load_textdomain() { 
  14. load_plugin_textdomain( 'bbpresstallyc_textdomain', false, dirname(plugin_basename(__FILE__)).'/languages/' ); 
  15.  
  16.  
  17. /** after_setup_theme hook function ****************************************************/ 
  18. /** 
  19. * This function contain all elements that's need  
  20. * to attached in "after_setup_theme" hook. 
  21. * @since 0.1 
  22. * @used with "after_setup_theme" hook 
  23. */ 
  24. function after_setup_theme() { 
  25. /** Fail silently if WooCommerce is not activated */ 
  26. if ( ! in_array( 'buddypress/bp-loader.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return;  
  27. if(!function_exists('tally_option')) return; 
  28. if(!class_exists('BuddyPress')) return; 
  29.  
  30. /** Setup bbPress sidebar*/ 
  31. register_sidebar( array( 
  32. 'name' => __('BuddyPress Sidebar', 'buddypresstallyc_textdomain'),  
  33. 'id' => 'tally_buddypress',  
  34. 'description' => __('BuddyPress shop Sidebar Widgets', 'buddypresstallyc_textdomain'),  
  35. 'before_widget' => '<div id="%1$s" class="widget %2$s">',  
  36. 'after_widget' => "</div><div class='clear' style='height:30px;'></div>",  
  37. 'before_title' => '<h4 class="heading">',  
  38. 'after_title' => '</h4>',  
  39. )); 
  40. add_action('tally_sidebar', array($this, 'add_sidebar') ); 
  41. add_filter('tally_sitebar_layout_option', array($this, 'sidebar_layout_option')); 
  42. add_filter('tally_sidebar_active', array($this, 'disable_theme_sidebar')); 
  43. add_action('tally_template_init', array($this, 'fix_bbpress_sidebar')); 
  44.  
  45. add_action('wp_enqueue_scripts', array($this, 'custom_scripts')); 
  46.  
  47. add_filter('option_tree_settings_args', array($this, 'add_theme_options')); 
  48.  
  49. add_action('tally_template_init', array($this, 'add_page_content')); 
  50.  
  51.  
  52.  
  53. /** Load Custom frontend scripts ***********************************************/ 
  54. /** 
  55. * This function add custom css and jsvascript for bbpress 
  56. * @since 0.1 
  57. * @used with "bbp_enqueue_scripts" hook 
  58. */ 
  59. function custom_scripts() { 
  60. if(apply_filters('buddypresstallyc_custom_css', false) == true) { 
  61. wp_dequeue_style( 'bp-legacy-css' ); 
  62. //wp_dequeue_script( 'bp-legacy-js' ); 
  63. wp_enqueue_style( 'buddypress-tally-c', BUDDYPRESSTALLYC_URL . 'assets/css/buddypress.css' ); 
  64.  
  65.  
  66.  
  67. /** Add Sidebar To the theme ****************************************************/ 
  68. /** 
  69. * This function add "tally_buddypress" in the theme. 
  70. * @since 0.1 
  71. * @used with "tally_sidebar" hook 
  72. */ 
  73. function add_sidebar() { 
  74. if($this->is_buddypress()) { 
  75. if ( ! dynamic_sidebar( 'tally_buddypress' ) && current_user_can( 'edit_theme_options' ) ) { 
  76. if(function_exists('tally_default_widget_area_content')) { tally_default_widget_area_content( __( 'BuddyPress Sidebar Widget Area', 'buddypresstallyc_textdomain' ) ); }; 
  77. }  
  78.  
  79.  
  80.  
  81. /** Disable Theme Sidebar *****************************************************/ 
  82. /** 
  83. * This function disable deafult sidebar of the theme 
  84. * @since 0.1 
  85. * @used with "tally_sidebar_active" filter 
  86. */ 
  87. function disable_theme_sidebar($active) { 
  88. if($this->is_buddypress()) { 
  89. $active = false; 
  90.  
  91. return $active; 
  92.  
  93. /** Fix bbPress Sidebar *****************************************************/ 
  94. /** 
  95. * This function remove bbpress sidebar from buddypress 
  96. * @since 0.1 
  97. * @used with "tally_sidebar_active" filter 
  98. */ 
  99. function fix_bbpress_sidebar() { 
  100. global $bbpresstallyc; 
  101. if($this->is_buddypress()) { 
  102. remove_action('tally_sidebar', array($bbpresstallyc, 'add_sidebar')); 
  103. //echo bp_current_component(); 
  104.  
  105.  
  106.  
  107. /** Sidebar Laouout option ***************************************************** 
  108. * @since 0.1 
  109. **/ 
  110. function sidebar_layout_option($sidebar_layout) { 
  111. global $wp_query; 
  112. $custom_field = get_post_meta( get_the_ID(), 'tally_sidebar_layout', true ); 
  113.  
  114. if($this->is_buddypress()) { 
  115. if(bp_current_component() == 'activity') { 
  116. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_activity_sidebar_layout'); 
  117. }elseif(bp_current_component() == 'friends') { 
  118. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_friends_sidebar_layout'); 
  119. }elseif(bp_current_component() == 'groups') { 
  120. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_groups_sidebar_layout'); 
  121. }elseif(bp_current_component() == 'messages') { 
  122. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_messages_sidebar_layout'); 
  123. }elseif(bp_current_component() == 'notifications') { 
  124. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_notifications_sidebar_layout'); 
  125. }elseif(bp_current_component() == 'profile') { 
  126. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_profile_sidebar_layout'); 
  127. }elseif(bp_current_component() == 'settings') { 
  128. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_settings_sidebar_layout'); 
  129. }elseif(bp_current_component() == 'forums') { 
  130. $sidebar_layout = $custom_field ? $custom_field : tally_option('buddypress_forums_sidebar_layout'); 
  131.  
  132. return $sidebar_layout; 
  133.  
  134.  
  135.  
  136.  
  137. /** Make the page content *****************************************************/ 
  138. /** 
  139. * This function remove some unwanted post element from the theme 
  140. * @since 0.4 
  141. * @used with "tally_template_init" hook 
  142. */ 
  143. function add_page_content() { 
  144. if(bp_current_component()) { 
  145. remove_all_actions('tally_loop'); 
  146. add_action('tally_loop', 'tally_do_page_content'); 
  147.  
  148.  
  149.  
  150.  
  151. /** Add Theme Options ***************************************************** 
  152. * @since 0.1 
  153. **/ 
  154. function add_theme_options($custom_settings) { 
  155. $custom_settings['sections'][] = array( 'id' => 'buddypress', 'title' => 'BuddyPress'); 
  156.  
  157. $custom_settings['settings']['buddypress_activity_sidebar_layout'] = array( 
  158. 'id' => 'buddypress_activity_sidebar_layout',  
  159. 'label' => __('Activity Pages', 'tally_taxdomain'),  
  160. 'desc' => __('Sidebar layout for BuddyPress activity pages.', 'tally_taxdomain'),  
  161. 'std' => tally_option_std('buddypress_activity_sidebar_layout'),  
  162. 'type' => 'radio-image',  
  163. 'section' => 'buddypress',  
  164. 'rows' => '',  
  165. 'post_type' => '',  
  166. 'taxonomy' => '',  
  167. 'class' => '',  
  168. 'choices' => array( 
  169. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  170. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  171. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  172. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  173. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  174. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  175. ); 
  176.  
  177. $custom_settings['settings']['buddypress_friends_sidebar_layout'] = array( 
  178. 'id' => 'buddypress_friends_sidebar_layout',  
  179. 'label' => __('Friends Pages', 'tally_taxdomain'),  
  180. 'desc' => __('Sidebar layout for BuddyPress friends pages.', 'tally_taxdomain'),  
  181. 'std' => tally_option_std('buddypress_friends_sidebar_layout'),  
  182. 'type' => 'radio-image',  
  183. 'section' => 'buddypress',  
  184. 'rows' => '',  
  185. 'post_type' => '',  
  186. 'taxonomy' => '',  
  187. 'class' => '',  
  188. 'choices' => array( 
  189. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  190. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  191. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  192. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  193. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  194. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  195. ); 
  196.  
  197. $custom_settings['settings']['buddypress_groups_sidebar_layout'] = array( 
  198. 'id' => 'buddypress_groups_sidebar_layout',  
  199. 'label' => __('Groups Pages', 'tally_taxdomain'),  
  200. 'desc' => __('Sidebar layout for BuddyPress groups pages.', 'tally_taxdomain'),  
  201. 'std' => tally_option_std('buddypress_groups_sidebar_layout'),  
  202. 'type' => 'radio-image',  
  203. 'section' => 'buddypress',  
  204. 'rows' => '',  
  205. 'post_type' => '',  
  206. 'taxonomy' => '',  
  207. 'class' => '',  
  208. 'choices' => array( 
  209. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  210. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  211. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  212. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  213. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  214. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  215. ); 
  216.  
  217. $custom_settings['settings']['buddypress_messages_sidebar_layout'] = array( 
  218. 'id' => 'buddypress_messages_sidebar_layout',  
  219. 'label' => __('Messages Pages', 'tally_taxdomain'),  
  220. 'desc' => __('Sidebar layout for BuddyPress messages pages.', 'tally_taxdomain'),  
  221. 'std' => tally_option_std('buddypress_messages_sidebar_layout'),  
  222. 'type' => 'radio-image',  
  223. 'section' => 'buddypress',  
  224. 'rows' => '',  
  225. 'post_type' => '',  
  226. 'taxonomy' => '',  
  227. 'class' => '',  
  228. 'choices' => array( 
  229. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  230. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  231. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  232. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  233. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  234. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  235. ); 
  236.  
  237. $custom_settings['settings']['buddypress_notifications_sidebar_layout'] = array( 
  238. 'id' => 'buddypress_notifications_sidebar_layout',  
  239. 'label' => __('Notifications Pages', 'tally_taxdomain'),  
  240. 'desc' => __('Sidebar layout for BuddyPress notifications pages.', 'tally_taxdomain'),  
  241. 'std' => tally_option_std('buddypress_notifications_sidebar_layout'),  
  242. 'type' => 'radio-image',  
  243. 'section' => 'buddypress',  
  244. 'rows' => '',  
  245. 'post_type' => '',  
  246. 'taxonomy' => '',  
  247. 'class' => '',  
  248. 'choices' => array( 
  249. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  250. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  251. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  252. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  253. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  254. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  255. ); 
  256.  
  257. $custom_settings['settings']['buddypress_profile_sidebar_layout'] = array( 
  258. 'id' => 'buddypress_profile_sidebar_layout',  
  259. 'label' => __('Profile Pages', 'tally_taxdomain'),  
  260. 'desc' => __('Sidebar layout for BuddyPress profile pages.', 'tally_taxdomain'),  
  261. 'std' => tally_option_std('buddypress_profile_sidebar_layout'),  
  262. 'type' => 'radio-image',  
  263. 'section' => 'buddypress',  
  264. 'rows' => '',  
  265. 'post_type' => '',  
  266. 'taxonomy' => '',  
  267. 'class' => '',  
  268. 'choices' => array( 
  269. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  270. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  271. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  272. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  273. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  274. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  275. ); 
  276.  
  277. $custom_settings['settings']['buddypress_settings_sidebar_layout'] = array( 
  278. 'id' => 'buddypress_settings_sidebar_layout',  
  279. 'label' => __('Settings Pages', 'tally_taxdomain'),  
  280. 'desc' => __('Sidebar layout for BuddyPress settings pages.', 'tally_taxdomain'),  
  281. 'std' => tally_option_std('buddypress_settings_sidebar_layout'),  
  282. 'type' => 'radio-image',  
  283. 'section' => 'buddypress',  
  284. 'rows' => '',  
  285. 'post_type' => '',  
  286. 'taxonomy' => '',  
  287. 'class' => '',  
  288. 'choices' => array( 
  289. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  290. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  291. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  292. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  293. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  294. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  295. ); 
  296.  
  297. $custom_settings['settings']['buddypress_forums_sidebar_layout'] = array( 
  298. 'id' => 'buddypress_forums_sidebar_layout',  
  299. 'label' => __('Forums Pages', 'tally_taxdomain'),  
  300. 'desc' => __('Sidebar layout for BuddyPress forums pages.', 'tally_taxdomain'),  
  301. 'std' => tally_option_std('buddypress_forums_sidebar_layout'),  
  302. 'type' => 'radio-image',  
  303. 'section' => 'buddypress',  
  304. 'rows' => '',  
  305. 'post_type' => '',  
  306. 'taxonomy' => '',  
  307. 'class' => '',  
  308. 'choices' => array( 
  309. array( 'label' => 'full-width-content', 'value' => 'full-width-content', 'src' => TALLY_URL.'/core/assets/images/admin/c.gif'),  
  310. array( 'label' => 'Content - Sidebar', 'value' => 'content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/cs.gif'),  
  311. array( 'label' => 'Content - Sidebar - Sidebar', 'value' => 'content-sidebar-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/css.gif'),  
  312. array( 'label' => 'Sidebar - Content', 'value' => 'sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/sc.gif'),  
  313. array( 'label' => 'Sidebar - Content - Sidebar', 'value' => 'sidebar-content-sidebar', 'src' => TALLY_URL.'/core/assets/images/admin/scs.gif'),  
  314. array( 'label' => 'Sidebar - Sidebar - Content', 'value' => 'sidebar-sidebar-content', 'src' => TALLY_URL.'/core/assets/images/admin/ssc.gif'),  
  315. ); 
  316.  
  317. return $custom_settings; 
  318.  
  319.  
  320.  
  321. /** Condition ***************************************************** 
  322. * @since 0.1 
  323. **/ 
  324. function is_buddypress() { 
  325. if( 
  326. ( bp_current_component() == 'activity' ) || 
  327. ( bp_current_component() == 'forums' ) || 
  328. ( bp_current_component() == 'friends' ) || 
  329. ( bp_current_component() == 'groups' ) || 
  330. ( bp_current_component() == 'messages' ) || 
  331. ( bp_current_component() == 'notifications' ) || 
  332. ( bp_current_component() == 'profile' ) || 
  333. ( bp_current_component() == 'settings' ) 
  334. ) { 
  335. return true; 
  336. }else{ 
  337. return false; 
  338.