| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace WP_Syntex\Polylang\Options\Business; |
| 7 |
|
| 8 |
use NOOP_Translations; |
| 9 |
use PLL_Settings_Sync; |
| 10 |
use WP_Syntex\Polylang\Options\Primitive\Abstract_List; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* Class defining synchronization settings list option. |
| 16 |
* |
| 17 |
* @since 3.7 |
| 18 |
* |
| 19 |
* @phpstan-import-type SchemaType from \WP_Syntex\Polylang\Options\Abstract_Option |
| 20 |
*/ |
| 21 |
class Sync extends Abstract_List { |
| 22 |
/** |
| 23 |
* Returns option key. |
| 24 |
* |
| 25 |
* @since 3.7 |
| 26 |
* |
| 27 |
* @return string |
| 28 |
* |
| 29 |
* @phpstan-return 'sync' |
| 30 |
*/ |
| 31 |
public static function key(): string { |
| 32 |
return 'sync'; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Returns the JSON schema part specific to this option. |
| 37 |
* |
| 38 |
* @since 3.7 |
| 39 |
* |
| 40 |
* @return array Partial schema. |
| 41 |
* |
| 42 |
* @phpstan-return array{type: 'array', items: array{type: SchemaType, enum: non-empty-list<non-falsy-string>}} |
| 43 |
*/ |
| 44 |
protected function get_data_structure(): array { |
| 45 |
$GLOBALS['l10n']['polylang'] = new NOOP_Translations(); // Prevents loading the translations too early. |
| 46 |
$enum = array_keys( PLL_Settings_Sync::list_metas_to_sync() ); |
| 47 |
unset( $GLOBALS['l10n']['polylang'] ); |
| 48 |
|
| 49 |
return array( |
| 50 |
'type' => 'array', |
| 51 |
'items' => array( |
| 52 |
'type' => $this->get_type(), |
| 53 |
'enum' => $enum, |
| 54 |
), |
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Returns the description used in the JSON schema. |
| 60 |
* |
| 61 |
* @since 3.7 |
| 62 |
* |
| 63 |
* @return string |
| 64 |
*/ |
| 65 |
protected function get_description(): string { |
| 66 |
return __( 'List of data to synchronize.', 'polylang' ); |
| 67 |
} |
| 68 |
} |
| 69 |
|