<?php

function prestasi_color_scheme_css() {
	$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );

	

	$color_scheme = prestasi_get_color_scheme();

	// Convert main and sidebar text hex color to rgba.
	$colors                      = array(
		'background_color'           => $color_scheme[0], // press body background
		'press_color1'               => $color_scheme[1], // press background wrapper
		'press_color2'               => $color_scheme[2], // press text global color
		'press_color3'               => $color_scheme[3], // press link global color 
		'press_color4'               => $color_scheme[4], // press runing BG color
		'press_color5'               => $color_scheme[5], // press runing text color
		'press_color6'               => $color_scheme[6], // press runing link color
		'press_color7'               => $color_scheme[7], // press search head BG
		'press_color8'               => $color_scheme[8], // press search head text
		'press_color9'               => $color_scheme[9], // press search button BG
		'press_color10'              => $color_scheme[10], // press search button text
		'press_color11'              => $color_scheme[11], // press header BG color
		'press_color12'              => $color_scheme[12], // press header text color
		'press_color13'              => $color_scheme[13], // press ikon search BG
		'press_color14'              => $color_scheme[14], // press ikon search text
		'press_color15'              => $color_scheme[15], // press ikon search border
		'press_color16'              => $color_scheme[16], // press ikon menu BG
		'press_color17'              => $color_scheme[17], // press ikon menu text
		'press_color18'              => $color_scheme[18], // press ikon menu border
		'press_color19'              => $color_scheme[19], // press menu mobile BG
		'press_color20'              => $color_scheme[20], // press menu mobile link
		'press_color21'              => $color_scheme[21], // press after slider BG
		'press_color22'              => $color_scheme[22], // press info sekolah BG
		'press_color23'              => $color_scheme[23], // press info sekolah aksen
		'press_color24'              => $color_scheme[24], // press span title BG
		'press_color25'              => $color_scheme[25], // press span title color
		'press_color26'              => $color_scheme[26], // press span title border
		'press_color27'              => $color_scheme[27], // press nama sekolah
		'press_color28'              => $color_scheme[28], // press alamat sekolah
		'press_color29'              => $color_scheme[29], // press telepon sekolah
		'press_color30'              => $color_scheme[30], // press facebook BG
		'press_color31'              => $color_scheme[31], // press facebook color
		'press_color32'              => $color_scheme[32], // press twitter BG
		'press_color33'              => $color_scheme[33], // press twitter color
		'press_color34'              => $color_scheme[34], // press instagram BG
		'press_color35'              => $color_scheme[35], // press instagram color
		'press_color36'              => $color_scheme[36], // press youtube BG
		'press_color37'              => $color_scheme[37], // press youtube color
		'press_color38'              => $color_scheme[38], // press envelope BG
		'press_color39'              => $color_scheme[39], // press envelope color
		'press_color40'              => $color_scheme[40], // press whatsapp BG
		'press_color41'              => $color_scheme[41], // press whatsapp color
		'press_color42'              => $color_scheme[42], // press agenda BG
		'press_color43'              => $color_scheme[43], // press agenda color
		'press_color44'              => $color_scheme[44], // press agenda aksen
		'press_color45'              => $color_scheme[45], // press agenda title
		'press_color46'              => $color_scheme[46], // press agenda span title BG
		'press_color47'              => $color_scheme[47], // press agenda span title text
		'press_color48'              => $color_scheme[48], // press agenda span title border
		'press_color49'              => $color_scheme[49], // press pos slide bg
		'press_color50'              => $color_scheme[50], // press pos slide color
		'press_color51'              => $color_scheme[51], // press umum bg
		'press_color52'              => $color_scheme[52], // press umum text
		'press_color53'              => $color_scheme[53], // press umum link
		'press_color54'              => $color_scheme[54], // press umum span title bg
		'press_color55'              => $color_scheme[55], // press umum span title color
		'press_color56'              => $color_scheme[56], // press umum span title border
		'press_color57'              => $color_scheme[57], // press quotes bg
		'press_color58'              => $color_scheme[58], // press quotes heading
		'press_color59'              => $color_scheme[59], // press quotes color
		'press_color60'              => $color_scheme[60], // press kepala guru bg
		'press_color61'              => $color_scheme[61], // press editor bg
		'press_color62'              => $color_scheme[62], // press editor color
		'press_color63'              => $color_scheme[63], // press editor more bg
		'press_color64'              => $color_scheme[64], // press editor more text
		'press_color65'              => $color_scheme[65], // press editor more border
		'press_color66'              => $color_scheme[66], // press guru slide bg
		'press_color67'              => $color_scheme[67], // press guru slide text
		'press_color68'              => $color_scheme[68], // press guru slide link
		'press_color69'              => $color_scheme[69], // press block blog bg
		'press_color70'              => $color_scheme[70], // press blog span title bg
		'press_color71'              => $color_scheme[71], // press blog span title text
		'press_color72'              => $color_scheme[72], // press blog span title border
		'press_color73'              => $color_scheme[73], // press box blog bg
		'press_color74'              => $color_scheme[74], // press box blog meta
		'press_color75'              => $color_scheme[75], // press box blog link
        'press_color76'              => $color_scheme[76], // press fasilitas head color
		'press_color77'              => $color_scheme[77], // press kegiatan head color
		'press_color78'              => $color_scheme[78], // press box kegiatan bg
		'press_color79'              => $color_scheme[79], // press box kegiatan color
		'press_color80'              => $color_scheme[80], // press galeri head color
		'press_color81'              => $color_scheme[81], // press video head color
		'press_color82'              => $color_scheme[82], // press box heading title bg
		'press_color83'              => $color_scheme[83], // press box heading title color
		'press_color84'              => $color_scheme[84], // press arsip heading title
		'press_color85'              => $color_scheme[85], // press arsip tanggal pos bg
		'press_color86'              => $color_scheme[86], // press arsip tanggal pos color
		'press_color87'              => $color_scheme[87], // press arsip agenda lewat bg
		'press_color88'              => $color_scheme[88], // press arsip agenda lewat color
		'press_color89'              => $color_scheme[89], // press arsip gtk bg
		'press_color90'              => $color_scheme[90], // press arsip gtk color
		'press_color91'              => $color_scheme[91], // press download tr bg
		'press_color92'              => $color_scheme[92], // press download tr color
		'press_color93'              => $color_scheme[93], // press download table color
		'press_color94'              => $color_scheme[94], // press download table link
		'press_color95'              => $color_scheme[95], // press materi utama bg
		'press_color96'              => $color_scheme[96], // press materi utama color
		'press_color97'              => $color_scheme[97], // press materi utama link
		'press_color98'              => $color_scheme[98], // press box soal bg
		'press_color99'              => $color_scheme[99], // press box soal border
		'press_color100'             => $color_scheme[100], // press box soal color
		'press_color101'             => $color_scheme[101], // press box soal link
		'press_color102'             => $color_scheme[102], // press agenda countdown color
		'press_color103'             => $color_scheme[103], // press agenda expired
		'press_color104'             => $color_scheme[104], // press single border color
		'press_color105'             => $color_scheme[105], // press comment bg
		'press_color106'             => $color_scheme[106], // press comment border
		'press_color107'             => $color_scheme[107], // press comment text
		'press_color108'             => $color_scheme[108], // press comment submit bg
		'press_color109'             => $color_scheme[109], // press comment submit color
		'press_color110'             => $color_scheme[110], // press footer widget bg
		'press_color111'             => $color_scheme[111], // press footer widget color
		'press_color112'             => $color_scheme[112], // press footer widget link
		'press_color113'             => $color_scheme[113], // press footer tags bg
		'press_color114'             => $color_scheme[114], // press footer tags color
		'press_color115'             => $color_scheme[115], // press copyright bg
		'press_color116'             => $color_scheme[116], // press copyright color
		'press_color117'             => $color_scheme[117], // press copyright link
		'press_color118'             => $color_scheme[118], // press mobile home bg
		'press_color119'             => $color_scheme[119], // press mobile home color
		'press_color120'             => $color_scheme[120], // press mobile phone bg
		'press_color121'             => $color_scheme[121], // press mobile phone color
		'press_color122'             => $color_scheme[122], // press mobile email bg
		'press_color123'             => $color_scheme[123], // press mobile phone color
		'press_color124'             => $color_scheme[124], // press mobile wa bg
		'press_color125'             => $color_scheme[125], // press mobile wa color
		'press_color126'             => $color_scheme[126], // press mobile scroll bg
		'press_color127'             => $color_scheme[127], // press mobile scroll color
		'press_color128'             => $color_scheme[128], // press table bg
	);

	$color_scheme_css = prestasi_get_color_scheme_css( $colors );

	wp_add_inline_style( 'press-style', $color_scheme_css );
}
add_action( 'wp_enqueue_scripts', 'prestasi_color_scheme_css' );

function prestasi_customize_control_js() {
	wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/javascript/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', true );
	wp_localize_script( 'color-scheme-control', 'colorScheme', prestasi_get_color_schemes() );
}
add_action( 'customize_controls_enqueue_scripts', 'prestasi_customize_control_js' );

function prestasi_customize_preview_js() {
	wp_enqueue_script( 'prestasi-customize-preview', get_template_directory_uri() . '/javascript/customize-preview.js', array( 'customize-preview' ), '20141216', true );
}
add_action( 'customize_preview_init', 'prestasi_customize_preview_js' );