<?php

if ( ! function_exists( 'ginevra_core_add_page_footer_options' ) ) {
	/**
	 * Function that add general options for this module
	 */
	function ginevra_core_add_page_footer_options() {
		$qode_framework = qode_framework_get_framework_root();

		$page = $qode_framework->add_options_page(
			array(
				'scope'       => GINEVRA_CORE_OPTIONS_NAME,
				'type'        => 'admin',
				'slug'        => 'footer',
				'icon'        => 'fa fa-cog',
				'title'       => esc_html__( 'Footer', 'ginevra-core' ),
				'description' => esc_html__( 'Global Footer Options', 'ginevra-core' ),
			)
		);

		if ( $page ) {

			$page->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_enable_page_footer',
					'title'         => esc_html__( 'Enable Page Footer', 'ginevra-core' ),
					'description'   => esc_html__( 'Use this option to enable/disable page footer', 'ginevra-core' ),
					'default_value' => 'yes',
				)
			);

			$page_footer_section = $page->add_section_element(
				array(
					'name'       => 'qodef_page_footer_section',
					'title'      => esc_html__( 'Footer Area', 'ginevra-core' ),
					'dependency' => array(
						'hide' => array(
							'qodef_enable_page_footer' => array(
								'values'        => 'no',
								'default_value' => '',
							),
						),
					),
				)
			);

			// General Footer Area Options

			$page_footer_section->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_enable_uncovering_footer',
					'title'         => esc_html__( 'Enable Uncovering Footer', 'ginevra-core' ),
					'description'   => esc_html__( 'Enabling this option will make Footer gradually appear on scroll', 'ginevra-core' ),
					'default_value' => 'no',
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'color',
					'name'       => 'qodef_global_footer_area_background_color',
					'title'      => esc_html__( 'Global Footer Background Color', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 6,
					),
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'image',
					'name'       => 'qodef_global_footer_area_background_image',
					'title'      => esc_html__( 'Global Footer Background Image', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 6,
					),
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_global_footer_area_background_size',
					'title'      => esc_html__( 'Global Footer Background Size', 'ginevra-core' ),
					'options'       => array(
						'contain' => esc_html__( 'Contain', 'ginevra-core' ),
						'cover'   => esc_html__( 'Cover', 'ginevra-core' ),
						'initial' => esc_html__( 'Initial', 'ginevra-core' ),
					),
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_global_footer_area_background_position',
					'title'      => esc_html__( 'Global Footer Background Position', 'ginevra-core' ),
					'options'       => array(
						'center top'    => esc_html__( 'Center Top', 'ginevra-core' ),
						'center center' => esc_html__( 'Center Center', 'ginevra-core' ),
						'center bottom' => esc_html__( 'Center Bottom', 'ginevra-core' ),
						'left top'      => esc_html__( 'Left Top', 'ginevra-core' ),
						'left center'   => esc_html__( 'Left Center', 'ginevra-core' ),
						'left bottom'   => esc_html__( 'Left Bottom', 'ginevra-core' ),
						'right top'     => esc_html__( 'Right Top', 'ginevra-core' ),
						'right center'  => esc_html__( 'Right Center', 'ginevra-core' ),
						'right bottom'  => esc_html__( 'Right Bottom', 'ginevra-core' ),
					),
					'default_value' => 'center bottom',
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_global_footer_area_background_repeat',
					'title'      => esc_html__( 'Global Footer Background Repeat', 'ginevra-core' ),
					'options'       => array(
						'no-repeat' => esc_html__( 'No Repeat', 'ginevra-core' ),
						'repeat' => esc_html__( 'Repeat', 'ginevra-core' ),
						'repeat-x'   => esc_html__( 'Repeat Horizontally', 'ginevra-core' ),
						'repeat-y' => esc_html__( 'Repeat Vertically', 'ginevra-core' ),
					),
					'default_value' => 'no-repeat',
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_global_footer_area_responsive_background_size',
					'title'      => esc_html__( 'Global Footer Responsive Background Size', 'ginevra-core' ),
					'description'      => esc_html__( 'Override background size below 1024px', 'ginevra-core' ),
					'options'       => array(
						'contain' => esc_html__( 'Contain', 'ginevra-core' ),
						'cover'   => esc_html__( 'Cover', 'ginevra-core' ),
						'initial' => esc_html__( 'Initial', 'ginevra-core' ),
					),
					'default_value' => 'initial',
				)
			);

			$page_footer_section->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_global_footer_area_responsive_background_position',
					'title'      => esc_html__( 'Global Footer Responsive Background Position', 'ginevra-core' ),
					'description'      => esc_html__( 'Override background position below 1024px', 'ginevra-core' ),
					'options'       => array(
						'center top'    => esc_html__( 'Center Top', 'ginevra-core' ),
						'center center' => esc_html__( 'Center Center', 'ginevra-core' ),
						'center bottom' => esc_html__( 'Center Bottom', 'ginevra-core' ),
						'left top'      => esc_html__( 'Left Top', 'ginevra-core' ),
						'left center'   => esc_html__( 'Left Center', 'ginevra-core' ),
						'left bottom'   => esc_html__( 'Left Bottom', 'ginevra-core' ),
						'right top'     => esc_html__( 'Right Top', 'ginevra-core' ),
						'right center'  => esc_html__( 'Right Center', 'ginevra-core' ),
						'right bottom'  => esc_html__( 'Right Bottom', 'ginevra-core' ),
						'30% bottom'  => esc_html__( 'Predefined', 'ginevra-core' ),
					),
					'default_value' => 'center bottom',
				)
			);

			// Top Footer Area Section

			$page_footer_section->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_enable_top_footer_area',
					'title'         => esc_html__( 'Enable Top Footer Area', 'ginevra-core' ),
					'description'   => esc_html__( 'Use this option to enable/disable top footer area', 'ginevra-core' ),
					'default_value' => 'yes',
				)
			);

			$top_footer_area_section = $page_footer_section->add_section_element(
				array(
					'name'       => 'qodef_top_footer_area_section',
					'title'      => esc_html__( 'Top Footer Area', 'ginevra-core' ),
					'dependency' => array(
						'hide' => array(
							'qodef_enable_top_footer_area' => array(
								'values'        => 'no',
								'default_value' => '',
							),
						),
					),
				)
			);

			$top_footer_area_section->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_set_footer_top_area_in_grid',
					'title'         => esc_html__( 'Top Footer Area In Grid', 'ginevra-core' ),
					'description'   => esc_html__( 'Enabling this option will set page top footer area to be in grid', 'ginevra-core' ),
					'default_value' => 'yes',
				)
			);

			$top_footer_area_section->add_field_element(
				array(
					'field_type'    => 'select',
					'name'          => 'qodef_set_footer_top_area_columns',
					'title'         => esc_html__( 'Top Footer Area Columns', 'ginevra-core' ),
					'description'   => esc_html__( 'Choose number of columns for top footer area', 'ginevra-core' ),
					'options'       => ginevra_core_get_select_type_options_pool( 'columns_number', true, array( '5', '6' ) ),
					'default_value' => '4',
				)
			);

            $top_footer_area_section->add_field_element(
                array(
                    'field_type'    => 'select',
                    'name'          => 'qodef_set_footer_top_area_columns_proportion',
                    'title'         => esc_html__( 'Top Footer Area Columns Proportion', 'ginevra-core' ),
                    'options'       => array(
                        'equal'  => esc_html__( '1/4 1/4 1/4 1/4', 'ginevra-core' ),
                        'custom'  => esc_html__( '1/2 1/6 1/6 1/6', 'ginevra-core' ),),
                    'default_value' => 'equal',
                    'dependency' => array (
                        'show' => array (
                            'qodef_set_footer_top_area_columns' => array (
                                'values'        => '4',
                                'default_value' => '',
                            ),
                        ),
                    ),
                )
            );

			$top_footer_area_section->add_field_element(
				array(
					'field_type'  => 'select',
					'name'        => 'qodef_set_footer_top_area_grid_gutter',
					'title'       => esc_html__( 'Top Footer Area Grid Gutter', 'ginevra-core' ),
					'description' => esc_html__( 'Choose grid gutter size to set space between columns for top footer area', 'ginevra-core' ),
					'options'     => ginevra_core_get_select_type_options_pool( 'items_space' ),
				)
			);

			$top_footer_area_section->add_field_element(
				array(
					'field_type'  => 'select',
					'name'        => 'qodef_set_footer_top_area_content_alignment',
					'title'       => esc_html__( 'Content Alignment', 'ginevra-core' ),
					'description' => esc_html__( 'Set widgets content alignment inside top footer area', 'ginevra-core' ),
					'options'     => array(
						''       => esc_html__( 'Default', 'ginevra-core' ),
						'left'   => esc_html__( 'Left', 'ginevra-core' ),
						'center' => esc_html__( 'Center', 'ginevra-core' ),
						'right'  => esc_html__( 'Right', 'ginevra-core' ),
					),
				)
			);

			$top_footer_area_styles_section = $top_footer_area_section->add_section_element(
				array(
					'name'  => 'qodef_top_footer_area_styles_section',
					'title' => esc_html__( 'Top Footer Area Styles', 'ginevra-core' ),
				)
			);

			$top_footer_area_styles_row = $top_footer_area_styles_section->add_row_element(
				array(
					'name'  => 'qodef_top_footer_area_styles_row',
					'title' => '',
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type'  => 'select',
					'name'        => 'qodef_footer_top_skin',
					'title'       => esc_html__( 'Footer Top Skin', 'ginevra-core' ),
					'description' => esc_html__( 'Choose a predefined style for footer top elements', 'ginevra-core' ),
					'options'     => array(
						'none'  => esc_html__( 'None', 'ginevra-core' ),
						'light' => esc_html__( 'Light', 'ginevra-core' ),
						'dark'  => esc_html__( 'Dark', 'ginevra-core' ),
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_top_footer_area_padding_top',
					'title'      => esc_html__( 'Padding Top', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_top_footer_area_padding_bottom',
					'title'      => esc_html__( 'Padding Bottom', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_top_footer_area_side_padding',
					'title'      => esc_html__( 'Side Padding', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'color',
					'name'       => 'qodef_top_footer_area_background_color',
					'title'      => esc_html__( 'Background Color', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'image',
					'name'       => 'qodef_top_footer_area_background_image',
					'title'      => esc_html__( 'Background Image', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'color',
					'name'       => 'qodef_top_footer_area_top_border_color',
					'title'      => esc_html__( 'Top Border Color', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_top_footer_area_top_border_width',
					'title'      => esc_html__( 'Top Border Width', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
						'suffix'    => esc_html__( 'px', 'ginevra-core' ),
					),
				)
			);

			$top_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_top_footer_area_top_border_style',
					'title'      => esc_html__( 'Top Border Style', 'ginevra-core' ),
					'options'    => ginevra_core_get_select_type_options_pool( 'border_style' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$top_footer_area_styles_row_2 = $top_footer_area_styles_section->add_row_element(
				array(
					'name'  => 'qodef_top_footer_area_styles_row_2',
					'title' => '',
				)
			);

			$top_footer_area_styles_row_2->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_set_footer_top_area_border_in_grid',
					'title'         => esc_html__( 'Top Border In Grid', 'ginevra-core' ),
					'default_value' => 'no',
					'args'        => array(
						'col_width' => 4,
					),
				)
			);

			$top_footer_area_styles_row_2->add_field_element(
				array(
					'field_type'  => 'text',
					'name'        => 'qodef_top_footer_area_widgets_margin_bottom',
					'title'       => esc_html__( 'Widgets Margin Bottom', 'ginevra-core' ),
					'description' => esc_html__( 'Set space value between widgets', 'ginevra-core' ),
					'args'        => array(
						'col_width' => 4,
					),
				)
			);

			$top_footer_area_styles_row_2->add_field_element(
				array(
					'field_type'  => 'text',
					'name'        => 'qodef_top_footer_area_widgets_title_margin_bottom',
					'title'       => esc_html__( 'Widgets Title Margin Bottom', 'ginevra-core' ),
					'description' => esc_html__( 'Set space value between widget title and widget content', 'ginevra-core' ),
					'args'        => array(
						'col_width' => 4,
					),
				)
			);

			// Bottom Footer Area Section

			$page_footer_section->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_enable_bottom_footer_area',
					'title'         => esc_html__( 'Enable Bottom Footer Area', 'ginevra-core' ),
					'description'   => esc_html__( 'Use this option to enable/disable bottom footer area', 'ginevra-core' ),
					'default_value' => 'yes',
				)
			);

			$bottom_footer_area_section = $page_footer_section->add_section_element(
				array(
					'name'       => 'qodef_bottom_footer_area_section',
					'title'      => esc_html__( 'Bottom Footer Area', 'ginevra-core' ),
					'dependency' => array(
						'hide' => array(
							'qodef_enable_bottom_footer_area' => array(
								'values'        => 'no',
								'default_value' => '',
							),
						),
					),
				)
			);

			$bottom_footer_area_section->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_set_footer_bottom_area_in_grid',
					'title'         => esc_html__( 'Bottom Footer Area In Grid', 'ginevra-core' ),
					'description'   => esc_html__( 'Enabling this option will set page bottom footer area to be in grid', 'ginevra-core' ),
					'default_value' => 'yes',
				)
			);

			$bottom_footer_area_section->add_field_element(
				array(
					'field_type'    => 'select',
					'name'          => 'qodef_set_footer_bottom_area_columns',
					'title'         => esc_html__( 'Bottom Footer Area Columns', 'ginevra-core' ),
					'description'   => esc_html__( 'Choose number of columns for bottom footer area', 'ginevra-core' ),
					'options'       => ginevra_core_get_select_type_options_pool( 'columns_number', true, array( '3', '4', '5', '6' ) ),
					'default_value' => '2',
				)
			);

			$bottom_footer_area_section->add_field_element(
				array(
					'field_type'  => 'select',
					'name'        => 'qodef_set_footer_bottom_area_grid_gutter',
					'title'       => esc_html__( 'Bottom Footer Area Grid Gutter', 'ginevra-core' ),
					'description' => esc_html__( 'Choose grid gutter size to set space between columns for bottom footer area', 'ginevra-core' ),
					'options'     => ginevra_core_get_select_type_options_pool( 'items_space' ),
				)
			);

			$bottom_footer_area_section->add_field_element(
				array(
					'field_type'  => 'select',
					'name'        => 'qodef_set_footer_bottom_area_content_alignment',
					'title'       => esc_html__( 'Content Alignment', 'ginevra-core' ),
					'description' => esc_html__( 'Set widgets content alignment inside bottom footer area', 'ginevra-core' ),
					'options'     => array(
						''              => esc_html__( 'Default', 'ginevra-core' ),
						'left'          => esc_html__( 'Left', 'ginevra-core' ),
						'center'        => esc_html__( 'Center', 'ginevra-core' ),
						'right'         => esc_html__( 'Right', 'ginevra-core' ),
						'space-between' => esc_html__( 'Space Between', 'ginevra-core' ),
					),
				)
			);

			$bottom_footer_area_styles_section = $bottom_footer_area_section->add_section_element(
				array(
					'name'  => 'qodef_bottom_footer_area_styles_section',
					'title' => esc_html__( 'Bottom Footer Area Styles', 'ginevra-core' ),
				)
			);

			$bottom_footer_area_styles_row = $bottom_footer_area_styles_section->add_row_element(
				array(
					'name'  => 'qodef_bottom_footer_area_styles_row',
					'title' => '',
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type'  => 'select',
					'name'        => 'qodef_footer_bottom_skin',
					'title'       => esc_html__( 'Footer Bottom Skin', 'ginevra-core' ),
					'description' => esc_html__( 'Choose a predefined style for footer bottom elements', 'ginevra-core' ),
					'options'     => array(
						'none'  => esc_html__( 'None', 'ginevra-core' ),
						'light' => esc_html__( 'Light', 'ginevra-core' ),
						'dark'  => esc_html__( 'Dark', 'ginevra-core' ),
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_bottom_footer_area_padding_top',
					'title'      => esc_html__( 'Padding Top', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_bottom_footer_area_padding_bottom',
					'title'      => esc_html__( 'Padding Bottom', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_bottom_footer_area_side_padding',
					'title'      => esc_html__( 'Side Padding', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'color',
					'name'       => 'qodef_bottom_footer_area_background_color',
					'title'      => esc_html__( 'Background Color', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'color',
					'name'       => 'qodef_bottom_footer_area_top_border_color',
					'title'      => esc_html__( 'Top Border Color', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'text',
					'name'       => 'qodef_bottom_footer_area_top_border_width',
					'title'      => esc_html__( 'Top Border Width', 'ginevra-core' ),
					'args'       => array(
						'col_width' => 3,
						'suffix'    => esc_html__( 'px', 'ginevra-core' ),
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type' => 'select',
					'name'       => 'qodef_bottom_footer_area_top_border_style',
					'title'      => esc_html__( 'Top Border Style', 'ginevra-core' ),
					'options'    => ginevra_core_get_select_type_options_pool( 'border_style' ),
					'args'       => array(
						'col_width' => 3,
					),
				)
			);

			$bottom_footer_area_styles_row->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_set_footer_bottom_area_border_in_grid',
					'title'         => esc_html__( 'Top Border In Grid', 'ginevra-core' ),
					'default_value' => 'no',
					'args'        => array(
						'col_width' => 3,
					),
				)
			);

			// Hook to include additional options after module options
			do_action( 'ginevra_core_action_after_page_footer_options_map', $page );
		}
	}

	add_action( 'ginevra_core_action_default_options_init', 'ginevra_core_add_page_footer_options', ginevra_core_get_admin_options_map_position( 'footer' ) );
}
