| @@ -18,9 +18,9 @@ | ||
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The list of post types to show in the form. |
| 21 | 21 | * |
| 22 | - * @var array | |
| 22 | + * @var string[] | |
| 23 | 23 | */ |
| 24 | 24 | private $post_types; |
| 25 | 25 | |
| 26 | 26 | /** |
| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * The list of post types to disable in the form. |
| 28 | 28 | * |
| 29 | - * @var array | |
| 29 | + * @var string[] | |
| 30 | 30 | */ |
| 31 | 31 | private $disabled_post_types; |
| 32 | 32 | |
| 33 | 33 | /** |
| @@ -32,9 +32,9 @@ | ||
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * The list of taxonomies to show in the form. |
| 35 | 35 | * |
| 36 | - * @var array | |
| 36 | + * @var string[] | |
| 37 | 37 | */ |
| 38 | 38 | private $taxonomies; |
| 39 | 39 | |
| 40 | 40 | /** |
| @@ -39,18 +39,18 @@ | ||
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * The list of taxonomies to disable in the form. |
| 42 | 42 | * |
| 43 | - * @var array | |
| 43 | + * @var string[] | |
| 44 | 44 | */ |
| 45 | 45 | private $disabled_taxonomies; |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Constructor | |
| 48 | + * Constructor. | |
| 49 | 49 | * |
| 50 | 50 | * @since 1.8 |
| 51 | 51 | * |
| 52 | - * @param object $polylang polylang object | |
| 52 | + * @param object $polylang The Polylang object. | |
| 53 | 53 | */ |
| 54 | 54 | public function __construct( &$polylang ) { |
| 55 | 55 | parent::__construct( |
| 56 | 56 | $polylang, |
| @@ -106,11 +106,18 @@ | ||
| 106 | 106 | $disabled = in_array( $post_type, $this->disabled_post_types ); |
| 107 | 107 | printf( |
| 108 | 108 | '<li><label><input name="post_types[%s]" type="checkbox" value="1" %s %s/> %s</label></li>', |
| 109 | 109 | esc_attr( $post_type ), |
| 110 | - checked( in_array( $post_type, $this->options['post_types'] ) || $disabled, true, false ), | |
| 110 | + checked( $disabled || in_array( $post_type, $this->options['post_types'], true ), true, false ), | |
| 111 | 111 | disabled( $disabled, true, false ), |
| 112 | - esc_html( $pt->labels->name ) | |
| 112 | + esc_html( | |
| 113 | + sprintf( | |
| 114 | + /* translators: 1 is a post type or taxonomy label, 2 is a post type or taxonomy key. */ | |
| 115 | + _x( '%1$s (%2$s)', 'content type setting choice', 'polylang' ), | |
| 116 | + $pt->labels->name, | |
| 117 | + $pt->name | |
| 118 | + ) | |
| 119 | + ) | |
| 113 | 120 | ); |
| 114 | 121 | } |
| 115 | 122 | } |
| 116 | 123 | ?> |
| @@ -130,11 +137,18 @@ | ||
| 130 | 137 | $disabled = in_array( $taxonomy, $this->disabled_taxonomies ); |
| 131 | 138 | printf( |
| 132 | 139 | '<li><label><input name="taxonomies[%s]" type="checkbox" value="1" %s %s/> %s</label></li>', |
| 133 | 140 | esc_attr( $taxonomy ), |
| 134 | - checked( in_array( $taxonomy, $this->options['taxonomies'] ) || $disabled, true, false ), | |
| 141 | + checked( $disabled || in_array( $taxonomy, $this->options['taxonomies'], true ), true, false ), | |
| 135 | 142 | disabled( $disabled, true, false ), |
| 136 | - esc_html( $tax->labels->name ) | |
| 143 | + esc_html( | |
| 144 | + sprintf( | |
| 145 | + /* translators: 1 is a post type or taxonomy label, 2 is a post type or taxonomy key. */ | |
| 146 | + _x( '%1$s (%2$s)', 'content type setting choice', 'polylang' ), | |
| 147 | + $tax->labels->name, | |
| 148 | + $tax->name | |
| 149 | + ) | |
| 150 | + ) | |
| 137 | 151 | ); |
| 138 | 152 | } |
| 139 | 153 | } |
| 140 | 154 | ?> |
| @@ -144,19 +158,21 @@ | ||
| 144 | 158 | } |
| 145 | 159 | } |
| 146 | 160 | |
| 147 | 161 | /** |
| 148 | - * Sanitizes the settings before saving | |
| 162 | + * Prepares the received data before saving. | |
| 149 | 163 | * |
| 150 | - * @since 1.8 | |
| 164 | + * @since 3.7 | |
| 151 | 165 | * |
| 152 | - * @param array $options | |
| 166 | + * @param array $options Raw values to save. | |
| 167 | + * @return array | |
| 153 | 168 | */ |
| 154 | - protected function update( $options ) { | |
| 169 | + protected function prepare_raw_data( array $options ): array { | |
| 155 | 170 | $newoptions = array(); |
| 156 | 171 | |
| 157 | 172 | foreach ( array( 'post_types', 'taxonomies' ) as $key ) { |
| 158 | 173 | $newoptions[ $key ] = empty( $options[ $key ] ) ? array() : array_keys( $options[ $key ], 1 ); |
| 159 | 174 | } |
| 160 | - return $newoptions; // Take care to return only validated options | |
| 175 | + | |
| 176 | + return $newoptions; // Take care to return only validated options. | |
| 161 | 177 | } |
| 162 | 178 | } |