<?php
/**
 * Theme setup and initialization functions
 *
 * @package Multi
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
}


/**
 * Sets up the theme
 */
function multimagazine_setup() {
	add_editor_style();
	multimagazine_add_support();
	multimagazine_add_image_sizes();

	/**
	 * Make theme available for translation
	 * Translations can be filed in the /languages/ directory
	 */
	load_theme_textdomain( 'multimagazine', get_template_directory() . '/languages' );

	register_nav_menus(
		array(
			'primary'            => __( 'Main menu', 'multimagazine' ),
			'primary_additional' => __( 'Additional header menu', 'multimagazine' ),
			'secondary'          => __( 'Top bar menu', 'multimagazine' ),
			'footer'             => __( 'Footer menu', 'multimagazine' ),
		)
	);
}

/**
 * Adds image size definitions
 */
function multimagazine_add_image_sizes() {
	set_post_thumbnail_size( 900, 450, true ); // Default size.
	add_image_size( 'multimagazine-thumbnail-mini', 100, 68, true );
	add_image_size( 'multimagazine-thumbnail-small', 338, 183, true );
	add_image_size( 'multimagazine-thumbnail-medium', 800, 800, true );
	add_image_size( 'multimagazine-thumbnail-large', 1600, 800, true );
	add_image_size( 'multimagazine-thumbnail-slider', 460, 306, true );
	add_image_size( 'multimagazine-thumbnail-masonry', 600, 400, true );
	add_image_size( 'multimagazine-thumbnail-widget', 50, 50, true );
}

/**
 * Adds theme support for various features
 */
function multimagazine_add_support() {
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'html5', array( 'script', 'style', 'navigation-widgets', 'comment-form', 'comment-list' ) );
	add_theme_support( 'custom-background' );
	add_theme_support( 'custom-logo', array( 'flex-width' => true ) );
	add_theme_support( 'woocommerce' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'custom-header', array() );
	add_theme_support( 'align-wide' );
	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'editor-styles' );
	add_theme_support( 'wp-block-styles' );
	add_theme_support(
		'editor-color-palette',
		array(
			array(
				'name'  => __( 'orange', 'multimagazine' ),
				'slug'  => 'multimagazine-orange',
				'color' => '#ff6000',
			),
			array(
				'name'  => __( 'green', 'multimagazine' ),
				'slug'  => 'multimagazine-green',
				'color' => '#31d49c',
			),
			array(
				'name'  => __( 'dark green', 'multimagazine' ),
				'slug'  => 'multimagazine-dark-green',
				'color' => '#03823c',
			),
			array(
				'name'  => __( 'blue', 'multimagazine' ),
				'slug'  => 'multimagazine-blue',
				'color' => '#269fcc',
			),
			array(
				'name'  => __( 'dark blue', 'multimagazine' ),
				'slug'  => 'multimagazine-dark-blue',
				'color' => '#105772',
			),
			array(
				'name'  => __( 'purple', 'multimagazine' ),
				'slug'  => 'multimagazine-purple',
				'color' => '#a51ef2',
			),
			array(
				'name'  => __( 'pink', 'multimagazine' ),
				'slug'  => 'multimagazine-pink',
				'color' => '#fc83f2',
			),
			array(
				'name'  => __( 'red', 'multimagazine' ),
				'slug'  => 'multimagazine-red',
				'color' => '#f55e23',
			),
			array(
				'name'  => __( 'brown', 'multimagazine' ),
				'slug'  => 'multimagazine-brown',
				'color' => '#eb7f0c',
			),
			array(
				'name'  => __( 'gray', 'multimagazine' ),
				'slug'  => 'multimagazine-gray',
				'color' => '#8097a6',
			),
			array(
				'name'  => __( 'dark gray', 'multimagazine' ),
				'slug'  => 'multimagazine-dark-gray',
				'color' => '#495e6c',
			),
			array(
				'name'  => __( 'light gray', 'multimagazine' ),
				'slug'  => 'multimagazine-light-gray',
				'color' => '#bcc6c9',
			),
			array(
				'name'  => __( 'white', 'multimagazine' ),
				'slug'  => 'multimagazine-white',
				'color' => '#ffffff',
			),
		)
	);
}
