<?php
/**
 * bbPress Theme Options
 *
 * @since tdframework 1.0
 */

/**
 * bbPress plugin filters
 * Change bbPress separator
 */
	 function theme_bbp_styles(){
		// check if BBPress is active
		if ( core_theme_is_plugin_active('bbpress/bbpress.php')) {
			wp_enqueue_style('style-bbp', FRAMWORK_URI . 'addons/bbpress/style-bbp.css');
		}
	 }
	 add_action( 'wp_enqueue_scripts', 'theme_bbp_styles' );

	function theme_bbp_breadcrumb_sep( $args ) {
		$args['sep'] = ' \ ';
		return $args;
	}
	add_filter( 'bbp_before_get_breadcrumb_parse_args', 'theme_bbp_breadcrumb_sep' );

	// Change bbPress before container
	function theme_bbp_breadcrumb_before( $args ) {
		$args['before'] = '<div class="theme-breadcrumbs breadcrumb-list"><i class="icon-home fa fa-home"></i> ';
		return $args;
	}
	add_filter( 'bbp_before_get_breadcrumb_parse_args', 'theme_bbp_breadcrumb_before' );

	// Change bbPress before container
	function theme_bbp_breadcrumb_after( $args ) {
		$args['after'] = '</div>';
		return $args;
	}
	add_filter( 'bbp_before_get_breadcrumb_parse_args', 'theme_bbp_breadcrumb_after' );

// Adds bbPress layout option page
//
function theme_bpp_layoutoptions() {
	global $core_theme_options_handler;
	global $core_layout_default;

	$options = new CoreOptionGroup('z-bbp-layouts', __('bbPress', THEME_SLUG), __('Use this page to define the layout of bbPress pages.', THEME_SLUG), FRAMWORK_URI . 'addons/bbpress/options-bbpress.png');
	$core_theme_options_handler->group_add($options);

	$layouts = array(
		'layout-bbp' => __('bbPress page', THEME_SLUG)
	);
	foreach ($layouts as $key => $value) {
		$section = new CoreOptionSection($key, $value);
		$options->section_add($section);
		$section->option_add(new CoreOption($key, null, 'layout', null, $core_layout_default));

		// Slider
		$section->option_add(new CoreOption('slider_'.$key, __('Slider', THEME_SLUG), 'sliders', __('The slider will be displayed at the top of the', THEME_SLUG) . ' ' . $value . ' .'));

		$section->option_add(new CoreOption($key.'_background', __('Background', THEME_SLUG), 'image'));

		$section->option_add(new CoreOption($key.'_colorscheme', __('Color scheme', THEME_SLUG), 'colorschemes-list'));

		$section->option_add(new CoreOption('custom_content_' .$key , __('Slogan block', THEME_SLUG), 'text-multiline', __('Any HTML put here will be included in it\'s own block above the content.', THEME_SLUG)));

		$section->option_add(new CoreOption('custom_content_' .$key.'_bg' , __('Slogan background', THEME_SLUG), 'image', __('A background for the', THEME_SLUG) . ' ' . $value. ' ' . __('slogan block above the content.', THEME_SLUG)));
	}
}
add_action('after_setup_theme', 'theme_bpp_layoutoptions');

// Outputs bbPress layout
function theme_bpp_layout($layout) {
	if (!is_bbpress())
		return $layout;
	else
		return core_options_get('layout-bbp');
}
add_filter('core_layout', 'theme_bpp_layout');

// Get bbPress Sliders
function theme_bbp_slider($slider){
	if ( !is_bbpress() )
		return $slider;
	else{
		$post_type = 'theme';
		$slug = '_layout-bbp';
	}
	return core_options_get('slider'.$slug, $post_type);
}
add_filter('slider_area', 'theme_bbp_slider');

// Get bbPress background image
function theme_bbp_get_background($backgroundimage){
	if ( !is_bbpress() )
		return $backgroundimage;
	else
		return core_options_get('layout-bbp_background', 'theme');
}
add_filter('layout_background', 'theme_bbp_get_background');

//Get bbPress colorscheme
function theme_bbp_colorscheme($scheme){
	if ( !is_bbpress() )
		return $scheme;
	else
		return core_options_get('layout-bbp_colorscheme', 'theme');
}
add_filter('color_scheme', 'theme_bbp_colorscheme');

// Get bbPress custom content
function theme_bbp_custom_content($content){
	if( !is_bbpress())
		return $content;
	else
		return core_options_get('custom_content_layout-bbp', 'theme');
}
add_filter('custom_content', 'theme_bbp_custom_content');

// Get bbPress custom content background
function theme_bbp_custom_content_bg($slogan_bg){
	if( !is_bbpress() )
		return $slogan_bg;
	else
		$slogan_bg = core_options_get('custom_content_layout-bbp_bg', 'theme');

	return $slogan_bg;
}
add_filter('slogan_background', 'theme_bbp_custom_content_bg');

function theme_bbp_no_breadcrumb ($param) {
	return true;
}
//add_filter('bbp_no_breadcrumb', 'theme_bbp_no_breadcrumb');

?>