<?php

    Kirki::add_section( 'edumodo_buddyboss_loops_layout', array(
		'title'          => esc_html__( 'Loop Layouts', 'edumodo' ),
        'priority'       => 180,
        'panel'         => 'bp_nouveau_panel'
	) );

		Kirki::add_field( 'edumodo_buddyboss_members_loops_layout', [
			'type'     => 'select',
			'settings' => 'edumodo_buddyboss_members_loops_layout',
			'label'    => __( 'Members', 'edumodo' ),
            'section'  => 'edumodo_buddyboss_loops_layout',
            'default'  => 'three',
            'choices'     => [
                'two'       => esc_html__( 'Two Columns', 'edumodo' ),
                'three'     => esc_html__( 'Three Columns', 'edumodo' ),
                'four'      => esc_html__( 'Four Columns', 'edumodo' ),
            ],
			'priority' => 10,
        ] );
        
        Kirki::add_field( 'edumodo_buddyboss_members_friends_loops_layout', [
			'type'     => 'select',
			'settings' => 'edumodo_buddyboss_members_friends_loops_layout',
			'label'    => __( 'Members > Friends', 'edumodo' ),
            'section'  => 'edumodo_buddyboss_loops_layout',
            'default'  => 'two',
            'choices'     => [
                'two'       => esc_html__( 'Two Columns', 'edumodo' ),
                'three'     => esc_html__( 'Three Columns', 'edumodo' ),
                'four'      => esc_html__( 'Four Columns', 'edumodo' ),
            ],
			'priority' => 20,
        ] );
        
        Kirki::add_field( 'edumodo_buddyboss_members_groups_loops_layout', [
			'type'     => 'select',
			'settings' => 'edumodo_buddyboss_members_groups_loops_layout',
			'label'    => __( 'Members > Groups', 'edumodo' ),
            'section'  => 'edumodo_buddyboss_loops_layout',
            'default'  => 'two',
            'choices'     => [
                'two'       => esc_html__( 'Two Columns', 'edumodo' ),
                'three'     => esc_html__( 'Three Columns', 'edumodo' ),
                'four'      => esc_html__( 'Four Columns', 'edumodo' ),
            ],
			'priority' => 30,
        ] );
        
        Kirki::add_field( 'edumodo_buddyboss_groups_loops_layout', [
			'type'     => 'select',
			'settings' => 'edumodo_buddyboss_groups_loops_layout',
			'label'    => __( 'Groups', 'edumodo' ),
            'section'  => 'edumodo_buddyboss_loops_layout',
            'default'  => 'two',
            'choices'     => [
                'two'       => esc_html__( 'Two Columns', 'edumodo' ),
                'three'     => esc_html__( 'Three Columns', 'edumodo' ),
                'four'      => esc_html__( 'Four Columns', 'edumodo' ),
            ],
			'priority' => 40,
        ] );
        
        Kirki::add_field( 'edumodo_buddyboss_groups_members_layout', [
			'type'     => 'select',
			'settings' => 'edumodo_buddyboss_groups_members_layout',
			'label'    => __( 'Groups > Member', 'edumodo' ),
            'section'  => 'edumodo_buddyboss_loops_layout',
            'default'  => 'two',
            'choices'     => [
                'two'       => esc_html__( 'Two Columns', 'edumodo' ),
                'three'     => esc_html__( 'Three Columns', 'edumodo' ),
                'four'      => esc_html__( 'Four Columns', 'edumodo' ),
            ],
			'priority' => 50,
		] );

add_filter('bp_nouveau_get_loop_classes',function($classes) {
    if( bp_is_members_directory() ) {
        return array_merge($classes,[get_theme_mod('edumodo_buddyboss_members_loops_layout','three'),'buddyboss']);
    }

    if ( bp_is_user() && 'my-friends' === bp_current_action() ) {
        return array_merge($classes,[get_theme_mod('edumodo_buddyboss_members_friends_loops_layout','two'),'buddyboss']);
    }

    if ( bp_is_user() && 'my-groups' === bp_current_action() ) {
        return array_merge($classes,[get_theme_mod('edumodo_buddyboss_members_groups_loops_layout','two'),'buddyboss']);
    }

    if ( bp_is_groups_directory() ) {
        return array_merge($classes,[get_theme_mod('edumodo_buddyboss_groups_loops_layout','two'),'buddyboss']);
    }

    if ( bp_is_group() ) {
        return array_merge($classes,[get_theme_mod('edumodo_buddyboss_groups_members_layout','two'),'buddyboss']);
    }

    return $classes;
});