<?php
/**
 * Set and Get the Plugin Data
 *
 * @package                 iCopyDoc Plugins (v1.1, core 22-04-2024)
 * @subpackage              Import Products to OZON
 * @since                   0.1.0
 * 
 * @version                 0.8.1 (29-01-2026)
 * @author                  Maxim Glazunov
 * @link                    https://icopydoc.ru/
 * @see                     
 * 
 * @param       array       $data_arr - Optional
 *
 * @depends                 classes:	
 *                          traits:		
 *                          methods:	
 *                          functions:	
 *                          constants:	
 */
defined( 'ABSPATH' ) || exit;

class IP2OZ_Data {

	/**
	 * Plugin options array.
	 *
	 * @access private
	 * @var array
	 */
	private $data_arr = [];

	/**
	 * Set and Get the Plugin Data.
	 * 
	 * @param array $data_arr
	 */
	public function __construct( $data_arr = [] ) {

		if ( empty( $data_arr ) ) {
			$this->data_arr = [
				[
					'opt_name' => 'status_sborki',
					'def_val' => '-1',
					'mark' => 'private',
					'type' => 'auto',
					'tab' => 'none'
				],
				[ // дата начала сборки
					'opt_name' => 'date_sborki_start',
					'def_val' => '-', // 'Y-m-d H:i
					'mark' => 'private',
					'type' => 'auto',
					'tab' => 'none'
				],
				[ // дата завершения сборки
					'opt_name' => 'date_sborki_end',
					'def_val' => '-', // 'Y-m-d H:i
					'mark' => 'private',
					'type' => 'auto',
					'tab' => 'none'
				],
				[  // дата последнего успешного обновления фида
					'opt_name' => 'date_successful_feed_update',
					'def_val' => 0000000001, // 0000000001 - timestamp format
					'mark' => 'private',
					'type' => 'auto',
					'tab' => 'none'
				],
				[  // дата сохранения настроек плагина
					'opt_name' => 'date_save_set',
					'def_val' => 0000000001, // 0000000001 - timestamp format
					'mark' => 'private',
					'type' => 'auto',
					'tab' => 'none'
				],
				// ? count_products_in_feed
				/* ---------- API SETTINGS ---------- */
				[
					'opt_name' => 'client_id',
					'def_val' => '',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'api_tab',
					'data' => [
						'label' => __( 'Client-Id', 'import-products-to-ozon' ),
						'desc' => 'Client-Id - ' . __( 'from the site OZON', 'import-products-to-ozon' ),
						'placeholder' => '654321'
					]
				],
				[
					'opt_name' => 'api_key',
					'def_val' => '',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'api_tab',
					'data' => [
						'label' => __( 'Api-Key', 'import-products-to-ozon' ),
						'desc' => 'Api-Key - ' . __( 'from the site OZON', 'import-products-to-ozon' ),
						'placeholder' => 'c9a*******************e9d'
					]
				],
				// ------------------- ОСНОВНЫЕ НАСТРОЙКИ -------------------
				[
					'opt_name' => 'syncing_with_ozon',
					'def_val' => 'disabled',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Syncing with OZON', 'import-products-to-ozon' ),
						'desc' => __(
							'Using this parameter, you can stop the plugin completely',
							'import-products-to-ozon'
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'run_cron',
					'def_val' => 'disabled',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => true,
						'table_location' => 'th-td',
						'label' => __(
							'The frequency of full synchronization of products',
							'import-products-to-ozon'
						),
						'desc' => __(
							'With the specified frequency, the plugin will transmit information about all your products to OZON',
							'import-products-to-ozon'
						),
						/*	'desc' => sprintf( '%s. %s "%s" %s "%s"',
							__(
								'With the specified frequency, the plugin will transmit information about all your products to OZON',
								'import-products-to-ozon'
							),
							__( 'If you select the option', 'import-products-to-ozon' ),
							__( 'Import products once and DO NOT import', 'import-products-to-ozon' ),
							__(
								'after importing as scheduled, the parameter value will change to',
								'import-products-to-ozon'
							),
							__( 'Disable scheduled product synchronization', 'import-products-to-ozon' )
						), */
						'woo_attr' => false,
						'key_value_arr' => [
							[
								'value' => 'disabled',
								'text' => __( 'Disable scheduled product synchronization', 'import-products-to-ozon' )
							],
							/*	[
									'value' => 'once',
									'text' => sprintf( '%s',
										__( 'Import products once and DO NOT import', 'import-products-to-ozon' )
									)
								],*/
							[
								'value' => 'hourly',
								'text' => __( 'Import products once an hour', 'import-products-to-ozon' )
							],
							[ 'value' => 'three_hours', 'text' => __( 'Import products every three hours', 'import-products-to-ozon' ) ],
							[ 'value' => 'six_hours', 'text' => __( 'Import products every six hours', 'import-products-to-ozon' ) ],
							[ 'value' => 'twicedaily', 'text' => __( 'Import products twice a day', 'import-products-to-ozon' ) ],
							[ 'value' => 'daily', 'text' => __( 'Import products once a day', 'import-products-to-ozon' ) ],
							[ 'value' => 'every_two_days', 'text' => __( 'Import products every two days', 'import-products-to-ozon' ) ],
							[ 'value' => 'weekly', 'text' => __( 'Import products once a week', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'step_export',
					'def_val' => '500',
					'mark' => 'public',
					'required' => true,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Step export', 'import-products-to-ozon' ),
						'desc' => __(
							'Determines the maximum number of products uploaded to OZON in one minute',
							'import-products-to-ozon'
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => '50', 'text' => '50' ],
							[ 'value' => '100', 'text' => '100' ],
							[ 'value' => '200', 'text' => '200' ],
							[ 'value' => '300', 'text' => '300' ],
							[ 'value' => '400', 'text' => '400' ],
							[
								'value' => '500',
								'text' => '500 (' . __( 'The maximum value allowed by OZON', 'import-products-to-ozon' ) . ')'
							]
						]
					]
				],
				/*[
					'opt_name' => 'ip2oz_cron_start_time', // !
					'def_val' => 'now',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => false,
						'table_location' => 'td-td',
						'label' => __( 'Starting at the specified time', 'import-products-to-ozon' ),
						'desc' => sprintf( '%s',
							__(
								'The time at which the import of products from the feed should begin',
								'import-products-to-ozon'
							)
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'now', 'text' => __( 'Now', 'import-products-to-ozon' ) ],
							[ 'value' => '1am', 'text' => '01-00' ],
							[ 'value' => '2am', 'text' => '02-00' ],
							[ 'value' => '3am', 'text' => '03-00' ],
							[ 'value' => '4am', 'text' => '04-00' ],
							[ 'value' => '5am', 'text' => '05-00' ],
							[ 'value' => '6am', 'text' => '06-00' ],
							[ 'value' => '7am', 'text' => '07-00' ],
							[ 'value' => '8am', 'text' => '08-00' ],
							[ 'value' => '9am', 'text' => '09-00' ],
							[ 'value' => '10am', 'text' => '10-00' ],
							[ 'value' => '11am', 'text' => '11-00' ],
							[ 'value' => '12pm', 'text' => '12-00' ],
							[ 'value' => '1pm', 'text' => '13-00' ],
							[ 'value' => '2pm', 'text' => '14-00' ],
							[ 'value' => '3pm', 'text' => '15-00' ],
							[ 'value' => '4pm', 'text' => '16-00' ],
							[ 'value' => '5pm', 'text' => '17-00' ],
							[ 'value' => '6pm', 'text' => '18-00' ],
							[ 'value' => '7pm', 'text' => '19-00' ],
							[ 'value' => '8pm', 'text' => '20-00' ],
							[ 'value' => '9pm', 'text' => '21-00' ],
							[ 'value' => '10pm', 'text' => '22-00' ],
							[ 'value' => '11pm', 'text' => '23-00' ],
							[ 'value' => '12am', 'text' => '00-00' ]
						]
					]
				],
				[
					'opt_name' => 'feed_assignment', // !
					'def_val' => '',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Feed assignment', 'import-products-to-ozon' ),
						'desc' => __( 'Does not affect the import process. Inner note for your convenience', 'import-products-to-ozon' ),
						'placeholder' => __( 'For Google Merchant Center', 'import-products-to-ozon' )
					]
				],*/
				[
					'opt_name' => 'script_execution_time',
					'def_val' => '26',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'The maximum script execution time', 'import-products-to-ozon' ),
						'desc' => sprintf( '%s. <strong>%s:</strong> 26. %s 10-30 %s',
							__(
								'The maximum script execution time in seconds',
								'import-products-to-ozon'
							),
							__( 'Default value', 'import-products-to-ozon' ),
							__(
								'If you experience freezes when importing the feed, try increasing this parameter by',
								'import-products-to-ozon'
							),
							__( 'points', 'import-products-to-ozon' ),
						),
						'placeholder' => '26',
						'tr_class' => ''
					]
				],
				[
					'opt_name' => 'vat',
					'def_val' => '0',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'VAT rate', 'import-products-to-ozon' ),
						'desc' => sprintf( '%s. %s',
							__( 'By default for all your products', 'import-products-to-ozon' ),
							__(
								'If necessary, you can change the tax inside the product card',
								'import-products-to-ozon'
							)
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[
								'value' => '0',
								'text' => __( 'Not taxed', 'import-products-to-ozon' )
							],
							[
								'value' => '0.05',
								'text' => '5%'
							],
							[
								'value' => '0.07',
								'text' => '7%'
							],
							[
								'value' => '0.1',
								'text' => '10%'
							],
							[
								'value' => '0.2',
								'text' => '20%'
							],
							[
								'value' => '0.22',
								'text' => '22%'
							]
						]
					]
				],
				[
					'opt_name' => 'sku',
					'def_val' => 'prefix_mode',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => true,
						'table_location' => 'th-td',
						'label' => __( 'SKU format', 'import-products-to-ozon' ),
						'desc' => __( 'The source of the SKU of the product', 'import-products-to-ozon' ),
						'woo_attr' => false,
						'default_value' => false,
						'key_value_arr' => [
							[
								'value' => 'prefix_mode',
								'text' => sprintf( 'offer-XXX -- (*XXX - %s)',
									__( 'product ID', 'import-products-to-ozon' )
								)
							],
							[
								'value' => 'products_id',
								'text' => sprintf( 'XXX -- (**XXX - %s)',
									__( 'Add from product ID', 'import-products-to-ozon' )
								)
							],
							[
								'value' => 'sku',
								'text' => sprintf( 'XXX -- (***XXX - %s)',
									__( 'Substitute from SKU', 'import-products-to-ozon' )
								)
							]
						]
					]
				],
				[
					'opt_name' => 'prefix_shop_sku',
					'def_val' => '',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => false,
						'table_location' => 'td-td',
						'label' => __( 'Prefix for product SKU', 'import-products-to-ozon' ),
						'desc' => __(
							'Since you cannot change the ID of previously uploaded products on OZON, this option may be useful at the debugging stage',
							'import-products-to-ozon'
						),
						'placeholder' => 'test-'
					]
				],
				[
					'opt_name' => 'description',
					'def_val' => 'fullexcerpt',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => true,
						'table_location' => 'th-td',
						'label' => __( 'Description of the product', 'import-products-to-ozon' ),
						'desc' => '[description] - ' . __( 'The source of the description', 'import-products-to-ozon' ),
						'woo_attr' => false,
						'key_value_arr' => [
							[
								'value' => 'excerpt',
								'text' => __( 'Only Excerpt description', 'import-products-to-ozon' )
							],
							[
								'value' => 'full',
								'text' => __( 'Only Full description', 'import-products-to-ozon' )
							],
							[
								'value' => 'excerptfull',
								'text' => __( 'Excerpt or Full description', 'import-products-to-ozon' )
							],
							[
								'value' => 'fullexcerpt',
								'text' => __( 'Full or Excerpt description', 'import-products-to-ozon' )
							],
							[
								'value' => 'excerptplusfull',
								'text' => __( 'Excerpt plus Full description', 'import-products-to-ozon' )
							],
							[
								'value' => 'fullplusexcerpt',
								'text' => __( 'Full plus Excerpt description', 'import-products-to-ozon' )
							]
						]
					]
				],
				[
					'opt_name' => 'var_desc_priority',
					'def_val' => 'enabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => false,
						'table_location' => 'td-td',
						'label' => __(
							'The varition description takes precedence over others',
							'import-products-to-ozon'
						),
						'desc' => '',
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'params_arr',
					'def_val' => '',
					'mark' => 'public',
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => true,
						'table_location' => 'th-td',
						'label' => __( 'Include these attributes in the import', 'import-products-to-ozon' ),
						'desc' => sprintf( '%s: %s. %s',
							__( 'Hint', 'import-products-to-ozon' ),
							__(
								'To select multiple values, hold down the (ctrl) button on Windows or (cmd) on a Mac',
								'import-products-to-ozon'
							),
							__(
								'To deselect, press and hold (ctrl) or (cmd), click on the marked items',
								'import-products-to-ozon'
							)
						),
						'woo_attr' => true,
						'default_value' => false,
						'key_value_arr' => [],
						'multiple' => true,
						'size' => '8'
					]
				],
				[
					'opt_name' => 'partnomer',
					'def_val' => 'enabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => false,
						'table_location' => 'td-td',
						'label' => __( 'Part number', 'import-products-to-ozon' ),
						'desc' => '',
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[
								'value' => 'sku',
								'text' => sprintf( '%s',
									__( 'Substitute from SKU', 'import-products-to-ozon' )
								)
							]
						]
					]
				],
				[
					'opt_name' => 'barcode',
					'def_val' => 'disabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => true,
						'table_location' => 'th-td',
						'label' => __( 'Barcode', 'import-products-to-ozon' ),
						'desc' => '',
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[
								'value' => 'sku',
								'text' => sprintf( '%s',
									__( 'Substitute from SKU', 'import-products-to-ozon' )
								)
							],
							[ 'value' => 'post_meta', 'text' => __( 'Substitute from post meta', 'import-products-to-ozon' ) ],
							[
								'value' => 'upc-ean-generator',
								'text' => sprintf( '%s UPC/EAN/GTIN Code Generator',
									__( 'Substitute from the plugin', 'import-products-to-ozon' )
								)
							],
							[
								'value' => 'ean-for-woocommerce',
								'text' => sprintf( '%s EAN for WooCommerce',
									__( 'Substitute from the plugin', 'import-products-to-ozon' )
								)
							],
							[
								'value' => 'germanized',
								'text' => sprintf( '%s WooCommerce Germanized',
									__( 'Substitute from the plugin', 'import-products-to-ozon' )
								)
							]
						]
					]
				],
				[
					'opt_name' => 'barcode_post_meta',
					'def_val' => '',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'main_tab',
					'data' => [
						'has_next' => false,
						'table_location' => 'td-td',
						'label' => __( 'Name post_meta', 'import-products-to-ozon' ),
						'desc' => sprintf( '%s <span class="ip2oz_bold">"%s"</span> %s',
							__( 'If selected', 'import-products-to-ozon' ),
							__( 'Import to post_meta', 'import-products-to-ozon' ),
							__( 'do not forget to fill out this field', 'import-products-to-ozon' )
						),
						'placeholder' => __( 'Name post_meta', 'import-products-to-ozon' )
					]
				],
				[
					'opt_name' => 'sync_stocks',
					'def_val' => 'disabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Synchronizing product stocks', 'import-products-to-ozon' ),
						'desc' => __(
							'At the moment, synchronization works only one way. From your website to the marketplace',
							'import-products-to-ozon'
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'warehouse_id',
					'def_val' => '',
					'mark' => 'public',
					'type' => 'text',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Warehouse ID', 'import-products-to-ozon' ),
						'desc' => __(
							'Warehouse ID',
							'import-products-to-ozon'
						),
						'placeholder' => '1234567898765432'
					]
				],
				[
					'opt_name' => 'old_price',
					'def_val' => 'disabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Old price', 'import-products-to-ozon' ),
						'desc' => __(
							'In old_price indicates the old price of the products, which must necessarily be higher than the new price (price)',
							'import-products-to-ozon'
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'product_promotions',
					'def_val' => 'disabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'main_tab',
					'data' => [
						'label' => __( 'Automatically add a product to promotions', 'import-products-to-ozon' ),
						'desc' => __(
							'Automatically add a product to promotions',
							'import-products-to-ozon'
						),
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'skip_missing_products',
					'def_val' => 'disabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'filtration_tab',
					'data' => [
						'label' => sprintf( '%1$s (%2$s)',
							__( 'Skip missing products', 'import-products-to-ozon' ),
							__( 'except for products for which a pre-order is permitted', 'import-products-to-ozon' )
						),
						'desc' => '',
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				],
				[
					'opt_name' => 'skip_backorders_products',
					'def_val' => 'disabled',
					'mark' => 'public',
					'required' => false,
					'type' => 'select',
					'tab' => 'filtration_tab',
					'data' => [
						'label' => __( 'Skip backorders products', 'import-products-to-ozon' ),
						'desc' => '',
						'woo_attr' => false,
						'key_value_arr' => [
							[ 'value' => 'disabled', 'text' => __( 'Disabled', 'import-products-to-ozon' ) ],
							[ 'value' => 'enabled', 'text' => __( 'Enabled', 'import-products-to-ozon' ) ]
						]
					]
				]
			];
		} else {
			$this->data_arr = $data_arr;
		}

		if ( class_exists( 'WOOCS' ) ) {
			global $WOOCS;
			$currencies_arr = $WOOCS->get_currencies();

			if ( is_array( $currencies_arr ) ) {
				$array_keys = array_keys( $currencies_arr );
				for ( $i = 0; $i < count( $array_keys ); $i++ ) {
					$key_value_arr[] = [
						'value' => $array_keys[ $i ],
						'text' => $array_keys[ $i ]
					];
				}
			}
			$this->data_arr[] = [
				'opt_name' => 'wooc_currencies',
				'def_val' => 'RUB',
				'mark' => 'public',
				'required' => false,
				'type' => 'select',
				'tab' => 'main_tab',
				'data' => [
					'label' => __( 'Currency', 'import-products-to-ozon' ),
					'desc' => sprintf( '%s %s. %s.<br/><strong>%s:</strong> %s %s %s',
						__( 'You have plugin installed', 'import-products-to-ozon' ),
						'WooCommerce Currency Switcher by PluginUs.NET. Woo Multi Currency and Woo Multi Pay',
						__( 'Indicate in what currency the prices should be', 'import-products-to-ozon' ),
						__( 'Please note', 'import-products-to-ozon' ),
						__( 'OZON only supports the following currencies', 'import-products-to-ozon' ),
						'RUB, BYN, KZT, KGS, CNY, USD, EUR',
						__( 'Choosing a different currency can lead to errors', 'import-products-to-ozon' )
					),
					'woo_attr' => false,
					'key_value_arr' => $key_value_arr,
					'tr_class' => 'ip2oz_tr'
				]
			];
		}

		$this->data_arr = apply_filters( 'ip2oz_f_set_default_feed_settings_result_arr', $this->get_data_arr() );

	}

	/**
	 * Get the plugin data array.
	 * 
	 * @return array
	 */
	public function get_data_arr() {
		return $this->data_arr;
	}

	/**
	 * Get options by name.
	 * 
	 * @param array $options_name_arr
	 * 
	 * @return array Example: `array([0] => opt_key1, [1] => opt_key2, ...)`.
	 */
	public function get_options( $options_name_arr = [] ) {

		$res_arr = [];
		if ( ! empty( $this->get_data_arr() ) && ! empty( $options_name_arr ) ) {
			for ( $i = 0; $i < count( $this->get_data_arr() ); $i++ ) {
				if ( in_array( $this->get_data_arr()[ $i ]['opt_name'], $options_name_arr ) ) {
					$arr = $this->get_data_arr()[ $i ];
					$res_arr[] = $arr;
				}
			}
		}
		return $res_arr;

	}

	/**
	 * Get data for tabs.
	 * 
	 * @param string $tab_name Maybe: `main_tab`, `filtration_tab`, `api_tab`,
	 * `instruction_tab` and so on.
	 * 
	 * @return array Example: `array([0] => opt_key1, [1] => opt_key2, ...)`.
	 */
	public function get_data_for_tabs( $tab_name = '' ) {

		$res_arr = [];
		if ( ! empty( $this->get_data_arr() ) ) {
			for ( $i = 0; $i < count( $this->get_data_arr() ); $i++ ) {
				switch ( $tab_name ) {
					case "main_tab":
					case "filtration_tab":

						if ( $this->get_data_arr()[ $i ]['tab'] === $tab_name ) {
							$arr = $this->get_data_arr()[ $i ]['data'];
							$arr['opt_name'] = $this->get_data_arr()[ $i ]['opt_name'];
							$arr['tab'] = $this->get_data_arr()[ $i ]['tab'];
							$arr['type'] = $this->get_data_arr()[ $i ]['type'];
							$res_arr[] = $arr;
						}

						break;
					case "api_tab":

						if ( $this->get_data_arr()[ $i ]['tab'] === 'api_tab' ) {
							$arr = $this->get_data_arr()[ $i ]['data'];
							$arr['opt_name'] = $this->get_data_arr()[ $i ]['opt_name'];
							$arr['tab'] = $this->get_data_arr()[ $i ]['tab'];
							$arr['type'] = $this->get_data_arr()[ $i ]['type'];
							$res_arr[] = $arr;
						}

						break;
					default:

						$res_arr = apply_filters(
							'ip2oz_f_data_for_tabs_before',
							$res_arr,
							$tab_name, $this->get_data_arr()[ $i ]
						);

						if ( $this->get_data_arr()[ $i ]['tab'] === $tab_name ) {
							$arr = $this->get_data_arr()[ $i ]['data'];
							$arr['opt_name'] = $this->get_data_arr()[ $i ]['opt_name'];
							$arr['tab'] = $this->get_data_arr()[ $i ]['tab'];
							$arr['type'] = $this->get_data_arr()[ $i ]['type'];
							$res_arr[] = $arr;
						}

						$res_arr = apply_filters(
							'ip2oz_f_data_for_tabs_after',
							$res_arr,
							$tab_name, $this->get_data_arr()[ $i ]
						);

				}
			}
		}
		return $res_arr;

	}

	/**
	 * Get plugin options name.
	 * 
	 * @param string $whot Maybe: `all`, `public` or `private`.
	 * 
	 * @return array Example: `array([0] => opt_key1, [1] => opt_key2, ...)`.
	 */
	public function get_opts_name( $whot = '' ) {

		$res_arr = [];
		if ( ! empty( $this->get_data_arr() ) ) {
			for ( $i = 0; $i < count( $this->get_data_arr() ); $i++ ) {
				switch ( $whot ) {
					case "public":
						if ( $this->get_data_arr()[ $i ]['mark'] === 'public' ) {
							$res_arr[] = $this->get_data_arr()[ $i ]['opt_name'];
						}
						break;
					case "private":
						if ( $this->get_data_arr()[ $i ]['mark'] === 'private' ) {
							$res_arr[] = $this->get_data_arr()[ $i ]['opt_name'];
						}
						break;
					default:
						$res_arr[] = $this->get_data_arr()[ $i ]['opt_name'];
				}
			}
		}
		return $res_arr;

	}

	/**
	 * Get plugin options name and default date (array).
	 * 
	 * @param string $whot Maybe: `all`, `public` or `private`.
	 * 
	 * @return array Example: `array(opt_name1 => opt_val1, opt_name2 => opt_val2, ...)`.
	 */
	public function get_opts_name_and_def_date( $whot = 'all' ) {

		$res_arr = [];
		if ( ! empty( $this->get_data_arr() ) ) {
			for ( $i = 0; $i < count( $this->get_data_arr() ); $i++ ) {
				switch ( $whot ) {
					case "public":
						if ( $this->get_data_arr()[ $i ]['mark'] === 'public' ) {
							$res_arr[ $this->get_data_arr()[ $i ]['opt_name'] ] = $this->get_data_arr()[ $i ]['def_val'];
						}
						break;
					case "private":
						if ( $this->get_data_arr()[ $i ]['mark'] === 'private' ) {
							$res_arr[ $this->get_data_arr()[ $i ]['opt_name'] ] = $this->get_data_arr()[ $i ]['def_val'];
						}
						break;
					default:
						$res_arr[ $this->get_data_arr()[ $i ]['opt_name'] ] = $this->get_data_arr()[ $i ]['def_val'];
				}
			}
		}
		return $res_arr;

	}

	/**
	 * Get plugin options name and default date (stdClass object).
	 * 
	 * @param string $whot
	 * 
	 * @return array<stdClass>
	 */
	public function get_opts_name_and_def_date_obj( $whot = 'all' ) {

		$source_arr = $this->get_opts_name_and_def_date( $whot );

		$res_arr = [];
		foreach ( $source_arr as $key => $value ) {
			$obj = new stdClass();
			$obj->name = $key;
			$obj->opt_def_value = $value;
			$res_arr[] = $obj; // unit obj
			unset( $obj );
		}
		return $res_arr;

	}

	/**
	 * Get array for the `ip2oz_picture` plugin option.
	 * 
	 * @return array
	 */
	private function get_registered_image_sizes() {

		$res_arr = [
			[ 'value' => 'full', 'text' => __( 'Full size (default)', 'import-products-to-ozon' ) ]
		];
		$sizes = wp_get_registered_image_subsizes();
		foreach ( $sizes as $key => $val ) {
			if ( is_array( $val['crop'] ) ) {
				$crop = '';
			} else {
				$crop = sprintf( ' - %s',
					__( 'сrop thumbnail to exact dimensions', 'import-products-to-ozon' )
				);
			}
			$cur_size_arr = [
				'value' => $key,
				'text' => sprintf( '%sx%s%s (%s)', $val['width'], $val['height'], $crop, $key )
			];
			array_push( $res_arr, $cur_size_arr );
			unset( $cur_size_arr );
		}
		return $res_arr;

	}

}