<?php

add_action( 'init', 'create_sekolah_post_type' );
function create_sekolah_post_type() {
	require get_template_directory() . '/post-type/slider.php';
	require get_template_directory() . '/post-type/agenda.php';
	require get_template_directory() . '/post-type/pengumuman.php';
	require get_template_directory() . '/post-type/editorial.php';
	require get_template_directory() . '/post-type/blog.php';
	require get_template_directory() . '/post-type/quotes.php';
	require get_template_directory() . '/post-type/fasilitas.php';
	if ( get_theme_mod('sekolah_type') != "akademi" ) {
	    require get_template_directory() . '/post-type/ekskul.php';
	} else {
		require get_template_directory() . '/post-type/ukm.php';
	}
	require get_template_directory() . '/post-type/prestasi.php';
	if ( get_theme_mod('sekolah_type') == "akademi" ) {
    	require get_template_directory() . '/post-type/dosen.php';
		require get_template_directory() . '/post-type/mahasiswa.php';
	} else if ( get_theme_mod('sekolah_type') == "pesantren" ) {
		require get_template_directory() . '/post-type/ustadz.php';
		require get_template_directory() . '/post-type/santri.php';
	} else {
		require get_template_directory() . '/post-type/gtk.php';
		require get_template_directory() . '/post-type/siswa.php';
	}
	require get_template_directory() . '/post-type/download.php';
	require get_template_directory() . '/post-type/galeri.php';
	require get_template_directory() . '/post-type/video.php';
	require get_template_directory() . '/post-type/materi.php';
}

    require get_template_directory() . '/post-type/taxonomy.php';
	
	
	add_filter('register_post_type_args', 'hide_post', 10, 2);
    
	function hide_post($args, $post_type){
        if ($post_type == 'post'){
			if ( get_theme_mod('opsi_editor') != "false" ) {
	            $showinrest = true;
			} else {
				$showinrest = false;
			}
		    $args['show_in_rest'] = $showinrest;
        }
		if ($post_type == 'page'){
			if ( get_theme_mod('opsi_editor') != "false" ) {
	            $showinrest = true;
			} else {
				$showinrest = false;
			}
		    $args['show_in_rest'] = $showinrest;
        }
		return $args;
    }

?>