| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * @package Polylang | |
| 4 | + */ | |
| 2 | 5 | |
| 3 | 6 | /** |
| 4 | 7 | * Settings class for synchronization settings management |
| 5 | 8 | * |
| @@ -5,8 +8,14 @@ | ||
| 5 | 8 | * |
| 6 | 9 | * @since 1.8 |
| 7 | 10 | */ |
| 8 | 11 | class PLL_Settings_Sync extends PLL_Settings_Module { |
| 12 | + /** | |
| 13 | + * Stores the display order priority. | |
| 14 | + * | |
| 15 | + * @var int | |
| 16 | + */ | |
| 17 | + public $priority = 50; | |
| 9 | 18 | |
| 10 | 19 | /** |
| 11 | 20 | * Constructor |
| 12 | 21 | * |
| @@ -11,9 +20,9 @@ | ||
| 11 | 20 | * Constructor |
| 12 | 21 | * |
| 13 | 22 | * @since 1.8 |
| 14 | 23 | * |
| 15 | - * @param object $polylang polylang object | |
| 24 | + * @param object $polylang The polylang object. | |
| 16 | 25 | */ |
| 17 | 26 | public function __construct( &$polylang ) { |
| 18 | 27 | parent::__construct( |
| 19 | 28 | $polylang, |
| @@ -31,9 +40,8 @@ | ||
| 31 | 40 | * @since 1.8 |
| 32 | 41 | */ |
| 33 | 42 | public function deactivate() { |
| 34 | 43 | $this->options['sync'] = array(); |
| 35 | - update_option( 'polylang', $this->options ); | |
| 36 | 44 | } |
| 37 | 45 | |
| 38 | 46 | /** |
| 39 | 47 | * Displays the settings form |
| @@ -57,25 +65,26 @@ | ||
| 57 | 65 | <?php |
| 58 | 66 | } |
| 59 | 67 | |
| 60 | 68 | /** |
| 61 | - * Sanitizes the settings before saving | |
| 69 | + * Prepare the received data before saving. | |
| 62 | 70 | * |
| 63 | - * @since 1.8 | |
| 71 | + * @since 3.7 | |
| 64 | 72 | * |
| 65 | - * @param array $options | |
| 73 | + * @param array $options Raw values to save. | |
| 74 | + * @return array | |
| 66 | 75 | */ |
| 67 | - protected function update( $options ) { | |
| 68 | - $newoptions = array( 'sync' => empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 ) ); | |
| 69 | - return $newoptions; // take care to return only validated options | |
| 76 | + protected function prepare_raw_data( array $options ): array { | |
| 77 | + // Take care to return only validated options. | |
| 78 | + return array( 'sync' => empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 ) ); | |
| 70 | 79 | } |
| 71 | 80 | |
| 72 | 81 | /** |
| 73 | - * Get the row actions | |
| 82 | + * Get the row actions. | |
| 74 | 83 | * |
| 75 | 84 | * @since 1.8 |
| 76 | 85 | * |
| 77 | - * @return array | |
| 86 | + * @return string[] Row actions. | |
| 78 | 87 | */ |
| 79 | 88 | protected function get_actions() { |
| 80 | 89 | return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' ); |
| 81 | 90 | } |
| @@ -80,13 +89,15 @@ | ||
| 80 | 89 | return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' ); |
| 81 | 90 | } |
| 82 | 91 | |
| 83 | 92 | /** |
| 84 | - * List the post metas to synchronize | |
| 93 | + * Get the list of synchronization settings. | |
| 85 | 94 | * |
| 86 | 95 | * @since 1.0 |
| 87 | 96 | * |
| 88 | - * @return array | |
| 97 | + * @return string[] Array synchronization options. | |
| 98 | + * | |
| 99 | + * @phpstan-return non-empty-array<non-falsy-string, string> | |
| 89 | 100 | */ |
| 90 | 101 | public static function list_metas_to_sync() { |
| 91 | 102 | return array( |
| 92 | 103 | 'taxonomies' => __( 'Taxonomies', 'polylang' ), |