<?php
/**
 * Post Metabox options.
 *
 * @author     ThemeFusion
 * @copyright  (c) Copyright by ThemeFusion
 * @link       https://avada.com
 * @package    Avada
 * @subpackage Core
 */

/**
 * Post page settings
 *
 * @param array $sections An array of our sections.
 * @return array
 */
function avada_page_options_tab_seo( $sections ) {
	$settings_link = '<a href="' . Avada()->settings->get_setting_link( 'meta_tags_separator' ) . '" target="_blank" rel="noopener noreferrer">' . Avada()->settings->get( 'meta_tags_separator' ) . '</a>';
	
	$sections['seo'] = [
		'label'    => esc_html__( 'SEO', 'Avada' ),
		'id'       => 'seo',
		'alt_icon' => 'fusiona-feather',
		'fields'   => [
			'seo_title'        => [
				'id'          => 'seo_title',
				'type'        => 'text',
				'label'       => esc_html__( 'SEO Title', 'Avada' ),
				/* translators: Option value (defaults). */
				'description' => sprintf( esc_html__( 'Insert the SEO title. Inline dynamic data can be used here, incl. {separator}. Separator is currently set to: %s.', 'Avada' ), $settings_link ),
				'default'     => '',
			], 
			'meta_description' => [
				'id'          => 'meta_description',
				'type'        => 'textarea',
				'counter'     => true,
				'max'         => '500',
				'range'       => '125|160',
				/* translators: Option value (defaults). */
				'label'       => esc_html__( 'Meta Description', 'Avada' ),
				'description' => sprintf( esc_html__( 'Insert your post meta description. Inline dynamic data can be used here, incl. {separator}. Separator is currently set to: %s.', 'Avada' ), $settings_link ),
			],
			'meta_og_image'    => [
				'id'          => 'meta_og_image',
				'type'        => 'media',
				'label'       => esc_html__( 'Open Graph Image', 'Avada' ),
				'description' => esc_html__( 'Upload an image to be used as open graph image tag.', 'Avada' ),
				'default'     => '',
				'transport'   => 'postMessage',
			],
			'seo_index' => [
				'type'        => 'radio-buttonset',
				'label'       => esc_html__( 'Index Page', 'fusion-builder' ),
				'description' => esc_html__( 'Controls the robots "index" directive for this page. "Auto" defers to WordPress or any active SEO plugin. "No" explicitly adds noindex, preventing this page from appearing in search results.', 'fusion-builder' ),
				'id'          => 'seo_index',
				'default'     => 'auto',
				'choices'     => [
					'auto' => esc_html__( 'Auto', 'fusion-builder' ),
					'no'   => esc_html__( 'No', 'fusion-builder' ),
				],
				'transport'   => 'postMessage',
			],
			'seo_follow' => [
				'type'        => 'radio-buttonset',
				'label'       => esc_html__( 'Follow Links', 'fusion-builder' ),
				'description' => esc_html__( 'Controls the robots "follow" directive for this page. "Auto" defers to WordPress or any active SEO plugin. "No" explicitly adds nofollow, instructing crawlers not to follow links on this page.', 'fusion-builder' ),
				'id'          => 'seo_follow',
				'default'     => 'auto',
				'choices'     => [
					'auto' => esc_html__( 'Auto', 'fusion-builder' ),
					'no'   => esc_html__( 'No', 'fusion-builder' ),
				],
				'transport'   => 'postMessage',
			],
		],
	];

	return $sections;
}

/* Omit closing PHP tag to avoid "Headers already sent" issues. */
