<?php
/**
 * Customizer settings: page layout
 *
 * @package Multi
 */

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

/**
 * Customizer settings for page layout
 */
class Multimagazine_Customize_Layout {

	/**
	 * Registers the section and fires the extension hook.
	 *
	 * @param WP_Customize_Manager $wp_customize Customizer manager instance.
	 */
	public static function register_section( $wp_customize ) {
		$wp_customize->add_section(
			'layout',
			array(
				'title'    => __( 'Layout', 'multimagazine' ),
				'priority' => 30,
			)
		);
		do_action( 'multimagazine_customize_layout', $wp_customize );
	}

	/**
	 * Registers the layout type setting.
	 */
	public static function register_layout_type() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_layout_type',
			'layout',
			array(
				'wide'         => __( 'Wide (default)', 'multimagazine' ),
				'boxed'        => __( 'Boxed', 'multimagazine' ),
				'boxed shadow' => __( 'Boxed with shadow', 'multimagazine' ),
			),
			__( 'Layout type', 'multimagazine' )
		);
	}

	/**
	 * Registers the content bg image setting.
	 */
	public static function register_content_bg_image() {
		global $multimagazine_customize;
		$multimagazine_customize->image_setting( 'multi_content_bg_image', 'layout', __( 'Content background image', 'multimagazine' ) );
	}

	/**
	 * Registers the layout width setting.
	 */
	public static function register_layout_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_layout_width', 'layout', 900, 1600, 1, __( 'Layout width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the sidebar width setting.
	 */
	public static function register_sidebar_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_sidebar_width', 'layout', 150, 500, 5, __( 'Sidebar width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the column gap setting.
	 */
	public static function register_column_gap() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_column_gap', 'layout', 10, 200, 1, __( 'Space between columns', 'multimagazine' ), __( 'Number of pixels. May be overwritten by post settings.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the content bottom margin setting.
	 */
	public static function register_content_bottom_margin() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_content_bottom_margin', 'layout', 0, 300, 10, __( 'Content bottom margin', 'multimagazine' ), __( 'Number of pixels. May be overwritten by post settings.', 'multimagazine' ), 'postMessage' );
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_Layout', 'register_section' ) );
add_action( 'multimagazine_customize_layout', array( 'Multimagazine_Customize_Layout', 'register_layout_type' ), 10 );
add_action( 'multimagazine_customize_layout', array( 'Multimagazine_Customize_Layout', 'register_content_bg_image' ), 15 );
add_action( 'multimagazine_customize_layout', array( 'Multimagazine_Customize_Layout', 'register_layout_width' ), 20 );
add_action( 'multimagazine_customize_layout', array( 'Multimagazine_Customize_Layout', 'register_sidebar_width' ), 25 );
add_action( 'multimagazine_customize_layout', array( 'Multimagazine_Customize_Layout', 'register_column_gap' ), 30 );
add_action( 'multimagazine_customize_layout', array( 'Multimagazine_Customize_Layout', 'register_content_bottom_margin' ), 35 );
