PluginProbe
Polylang / 3.8.9
Polylang v3.8.9
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / src / Options / Business / Sync.php

Sync.php in Polylang 3.8.9, at src/Options/Business/Sync.php

90 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Options;
11 use WP_Syntex\Polylang\Options\Primitive\Abstract_List;
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * Class defining synchronization settings list option.
17 *
18 * @since 3.7
19 *
20 * @phpstan-import-type SchemaType from \WP_Syntex\Polylang\Options\Abstract_Option
21 */
22 class Sync extends Abstract_List {
23 /**
24 * Returns option key.
25 *
26 * @since 3.7
27 *
28 * @return string
29 *
30 * @phpstan-return 'sync'
31 */
32 public static function key(): string {
33 return 'sync';
34 }
35
36
37 /**
38 * Adds information to the site health info array.
39 *
40 * @since 3.8
41 *
42 * @param Options $options An instance of the Options class providing additional configuration.
43 *
44 * @return array The updated site health information.
45 */
46 public function get_site_health_info( Options $options ): array { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
47 if ( empty( $this->get() ) ) {
48 $value = '0: ' . __( 'Synchronization disabled', 'polylang' );
49 } else {
50 $value = implode( ', ', $this->get() );
51 }
52
53 return $this->format_single_value_for_site_health_info( $value );
54 }
55
56 /**
57 * Returns the JSON schema part specific to this option.
58 *
59 * @since 3.7
60 *
61 * @return array Partial schema.
62 *
63 * @phpstan-return array{type: 'array', items: array{type: SchemaType, enum: non-empty-list<non-falsy-string>}}
64 */
65 protected function get_data_structure(): array {
66 $GLOBALS['l10n']['polylang'] = new NOOP_Translations(); // Prevents loading the translations too early.
67 $enum = array_keys( PLL_Settings_Sync::list_metas_to_sync() );
68 unset( $GLOBALS['l10n']['polylang'] );
69
70 return array(
71 'type' => 'array',
72 'items' => array(
73 'type' => $this->get_type(),
74 'enum' => $enum,
75 ),
76 );
77 }
78
79 /**
80 * Returns the description used in the JSON schema.
81 *
82 * @since 3.7
83 *
84 * @return string
85 */
86 protected function get_description(): string {
87 return __( 'List of data to synchronize.', 'polylang' );
88 }
89 }
90