<?php
/**
 * Gutenberg functions
 *
 */

// Add support for Block Styles.
add_theme_support( 'wp-block-styles' );

// Add support for full and wide align images.
add_theme_support( 'align-wide' );

// Add support for editor styles.
add_theme_support( 'editor-styles' );

add_editor_style('assets/css/gutenberg/editor-style.css');


// Add custom editor font sizes.
add_theme_support(
	'editor-font-sizes',
	array(
		array(
			'name'      => __( 'Small', 'educacion-wp' ),
			'shortName' => __( 'S', 'educacion-wp' ),
			'size'      => 13,
			'slug'      => 'small',
		),
		array(
			'name'      => __( 'Normal', 'educacion-wp' ),
			'shortName' => __( 'N', 'educacion-wp' ),
			'size'      => 16,
			'slug'      => 'normal',
		),
		array(
			'name'      => __( 'Medium', 'educacion-wp' ),
			'shortName' => __( 'M', 'educacion-wp' ),
			'size'      => 20,
			'slug'      => 'medium',
		),
		array(
			'name'      => __( 'Large', 'educacion-wp' ),
			'shortName' => __( 'L', 'educacion-wp' ),
			'size'      => 36,
			'slug'      => 'large',
		),
		array(
			'name'      => __( 'Huge', 'educacion-wp' ),
			'shortName' => __( 'XL', 'educacion-wp' ),
			'size'      => 42,
			'slug'      => 'huge',
		),
	)
);


//Gutenberg Color Palettes
if(!function_exists('educacion_mascot_gutenberg_color_palletts')) {
	function educacion_mascot_gutenberg_color_palletts() {
		$primary_theme_color = educacion_mascot_get_redux_option( 'theme-color-settings-custom-theme-color1' );
		if( empty($primary_theme_color) ) {
			$primary_theme_color = '#f89d35';
		}

		$secondary_theme_color = educacion_mascot_get_redux_option( 'theme-color-settings-custom-theme-color2' );
		if( empty($secondary_theme_color) ) {
			$secondary_theme_color = '#040A18';
		}
		$palettes = array(
			array(
				'name'  => __( 'Primary', 'educacion-wp' ),
				'slug'  => 'primary',
				'color' => $primary_theme_color,
			),
			array(
				'name'  => __( 'Secondary', 'educacion-wp' ),
				'slug'  => 'secondary',
				'color' => $secondary_theme_color,
			),
			array(
				'name'  => __( 'Dark Gray', 'educacion-wp' ),
				'slug'  => 'dark-gray',
				'color' => '#111',
			),
			array(
				'name'  => __( 'Light Gray', 'educacion-wp' ),
				'slug'  => 'light-gray',
				'color' => '#767676',
			),
			array(
				'name'  => __( 'White', 'educacion-wp' ),
				'slug'  => 'white',
				'color' => '#FFF',
			)
		);
		return apply_filters('educacion_mascot_gutenberg_color_palletts_filter', $palettes);
	}
}


// Editor color palette.
add_theme_support(
	'editor-color-palette',
	educacion_mascot_gutenberg_color_palletts()
);

// Add support for responsive embedded content.
add_theme_support( 'responsive-embeds' );




function educacion_mascot_action_wp_enqueue_gutenberg_frontend_styles() {
	if( is_rtl() ) {
		wp_enqueue_style( 'educacion-mascot-gutenberg-frontend-style-rtl', EDUCACION_MASCOT_TEMPLATE_URI . '/assets/css/gutenberg/frontend-style-rtl.css', array(), EDUCACION_MASCOT_THEME_VERSION );
	} else {
		wp_enqueue_style( 'educacion-mascot-gutenberg-frontend-style', EDUCACION_MASCOT_TEMPLATE_URI . '/assets/css/gutenberg/frontend-style.css', array(), EDUCACION_MASCOT_THEME_VERSION );
	}
}

add_action('wp_enqueue_scripts', 'educacion_mascot_action_wp_enqueue_gutenberg_frontend_styles');

function load_custom_wp_admin_style() {
	if( is_admin() ){
		wp_enqueue_style( 'educacion-google-fonts', educacion_mascot_google_fonts_url(), null, false, 'all' );
	}
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );