<?php
/**
 * Custom  Funtions
 *
 * @package Matrimony
 */

//===================== Normal Category  ========//
function matrimony_category_lists(){
	$category   = get_categories();
	$cat_list   = array();
	$cat_list[0]= esc_html__('Select category','matrimony');
	foreach ($category as $cat) {
		$cat_list[$cat->slug]  = $cat->name;
	}
	return $cat_list;
}
//===================== Normal Posts  ========//
function matrimony_post_list(){
    $options_posts = array();
    $options_posts_obj = get_posts('posts_per_page=-1');
    $options_posts[''] = esc_html__('Select a Post:','matrimony');
    foreach ($options_posts_obj as $post) {
        $options_posts[$post->ID] = $post->post_title;
    }
    return $options_posts;
}
//===================== Sidebar Functions  ========//
if( ! function_exists( 'matrimony_get_sidebar' ) ):
function matrimony_get_sidebar() {
	global $post;
    $sidebar_meta_option = 'right-sidebar';
    if( is_singular() ){
    	$sidebar_meta_option = get_post_meta( $post->ID, 'matrimony_sidebar_layout', true );
    	if ( 'both-sidebar' == $sidebar_meta_option ){
    		get_sidebar();	
    		get_sidebar( 'left' );
    	} elseif( 'right-sidebar' == $sidebar_meta_option ) {
    		get_sidebar();
    	}elseif( 'left-sidebar' == $sidebar_meta_option ) {
    		get_sidebar( 'left' );
    	}else{
    		$classes[] = 'no-sidebar';
    	}
    } else{
    	$sidebar_meta_option = get_theme_mod( 'matrimony_archive_setting_sidebar_option', 'right-sidebar' );
    	if ( 'both-sidebar' == $sidebar_meta_option ){
    		get_sidebar();	
    		get_sidebar( 'left' );
    	} elseif( 'right-sidebar' == $sidebar_meta_option ) {
    		get_sidebar();
    	}elseif( 'left-sidebar' == $sidebar_meta_option ) {
    		get_sidebar( 'left' );
    	}else{
    		$classes[] = 'no-sidebar';
    	}  	
    }
}
endif;	
