|
11 | 11 | class Admin_Fields { |
12 | 12 | use Singleton; |
13 | 13 |
|
| 14 | + /** |
| 15 | + * Checkbox field callback. |
| 16 | + * |
| 17 | + * @param array $args The field arguments |
| 18 | + */ |
| 19 | + public function checkbox( array $args ) { |
| 20 | + $settings_name = self::get_settings_name( $args ); |
| 21 | + $options = Helper::get_option( $settings_name, true ); |
| 22 | + ?> |
| 23 | + <label for="<?php echo \esc_attr( $args['label_for'] ); ?>"><input type="checkbox" id="<?php echo \esc_attr( $args['label_for'] ); ?>" name="<?php echo \esc_attr( $settings_name ); ?>[<?php echo \esc_attr( $args['label_for'] ); ?>]" value="1"<?php \checked( isset( $options[ $args['label_for'] ] ) ); ?>> |
| 24 | + <?php echo \esc_html( isset( $args['label'] ) ? $args['label'] : '' ); ?> |
| 25 | + </label> |
| 26 | + <?php |
| 27 | + } |
| 28 | + |
14 | 29 | /** |
15 | 30 | * Country field callback. |
16 | 31 | * |
@@ -228,16 +243,22 @@ public function phone( array $args ) { |
228 | 243 | /** |
229 | 244 | * Press Law Checkbox field callback. |
230 | 245 | * |
| 246 | + * @deprecated 2.2.0 Use epiphyt\Impressum\Admin_Fields::checkbox() instead |
| 247 | + * |
231 | 248 | * @param array $args The field arguments |
232 | 249 | */ |
233 | 250 | public function press_law_checkbox( array $args ) { |
234 | | - $settings_name = self::get_settings_name( $args ); |
235 | | - $options = Helper::get_option( $settings_name, true ); |
236 | | - ?> |
237 | | - <label for="<?php echo \esc_attr( $args['label_for'] ); ?>"><input type="checkbox" id="<?php echo \esc_attr( $args['label_for'] ); ?>" name="<?php echo \esc_attr( $settings_name ); ?>[<?php echo \esc_attr( $args['label_for'] ); ?>]" value="1"<?php \checked( isset( $options[ $args['label_for'] ] ) ); ?>> |
238 | | - <?php \esc_html_e( 'I have journalistic/editorial content on my website', 'impressum' ); ?> |
239 | | - </label> |
240 | | - <?php |
| 251 | + \_doing_it_wrong( |
| 252 | + __METHOD__, |
| 253 | + \sprintf( |
| 254 | + /* translators: alternative method */ |
| 255 | + \esc_html__( 'Use %s instead', 'impressum' ), |
| 256 | + 'epiphyt\Impressum\Admin_Fields::checkbox()' |
| 257 | + ), |
| 258 | + '2.2.0' |
| 259 | + ); |
| 260 | + |
| 261 | + self::checkbox( $args ); |
241 | 262 | } |
242 | 263 |
|
243 | 264 | /** |
|
0 commit comments