<?php
declare( strict_types=1 );

namespace FiboFilters\Integrations\Themes;

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

/**
 * Class WoodMart
 */
class WoodMart extends AbstractTheme {
	public function init( string $slug = '', string $name = '', array $args = [] ): void {
		parent::init( $slug, $name, $args );

		$this->change_enable_integration_field_desc();
	}

	/**
	 * Adds extra description for the "Enable integration" option.
	 */
	protected function change_enable_integration_field_desc(): void {

		add_filter(
			'fibofilters/settings/section=general',
			function ( array $settings ): array {
				// Filter location.
				/* translators: %s: name of the theme */
				$settings[200]['description'] = sprintf( _x( 'Filters can be displayed in these modes in the <b>%s</b> theme:', '[admin]', 'fibofilters' ), $this->name );

				// Filter location - Sidebar.
				$woodmart_docs_url  = 'https://xtemos.com/docs-topic/widgets-and-sidebars/';
				$woodmart_docs_url2 = 'https://xtemos.com/docs-topic/how-to-create-filters-form/';
				$woodmart_docs_url3 = 'https://xtemos.com/docs-topic/how-to-add-filters-are-in-custom-shop-page/';

				$sidebar_html = '';
				/* translators: %s: name of the theme */
				$sidebar_html .= '<p>' . sprintf( _x( 'To display FiboFilters in the %s theme Sidebar, follow these steps:', '[admin]', 'fibofilters' ), $this->name ) . '</p>';
				$sidebar_html .= '<ol>';
				/* translators: %s: URL address to the settings page */
				$sidebar_html .= '<li>' . sprintf( _x( 'Go to <code><a href="%s" target="_blank">Woodmart -> Theme Settings</a> -> Product Archive -> Sidebar</code>.', '[admin]', 'fibofilters' ), esc_url( admin_url( '?page=xts_theme_settings' ) ) ) . '</li>';
				$sidebar_html .= '<li>' . _x( 'Select <i>Left Sidebar</i> or <i>Right Sidebar</i> and publish changes.', '[admin]', 'fibofilters' ) . '</li>';
				/* translators: %s: URL address to the WordPress widgets view */
				$sidebar_html .= '<li>' . sprintf( _x( 'Go to <code><a href="%s" target="_blank">Appearance -> Widgets</a></code>.', '[admin]', 'fibofilters' ), $this->get_widgets_link() ) . '</li>';
				$sidebar_html .= '<li>' . _x( 'Add a block called <i>FiboFilters</i> to the <b>Shop page Widget Area</b> and click Update.', '[admin]', 'fibofilters' ) . '</li>';
				/* translators: 1: URL addres of the theme documentation 2: name of the theme */
				$sidebar_html .= '<li>' . sprintf( _x( 'Learn more in the <a href="%1$s" target="_blank">%2$s documentation.</a>', '[admin]', 'fibofilters' ), $woodmart_docs_url, $this->name ) . '</li>';
				$sidebar_html .= '</ol>';

				$settings[260]['html'] = $sidebar_html;

				return $settings;
			},
			15
		);
	}
}
