PluginProbe
Translation with DeepL API / trunk
Translation with DeepL API vtrunk
trunk 0.1.20180323 1.0 1.2.5.1 1.5.2.5 1.7.5 2.4.3.12 2.4.3.9 2.4.5
wpdeepl / settings / wp-improved-settings-api.class.php

wp-improved-settings-api.class.php in Translation with DeepL API trunk, at settings/wp-improved-settings-api.class.php

1,347 lines 40.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace wpdeepl_WP_Improved_Settings;
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4 /**
5 * Abstract Settings API Class
6 * From abstract-wc-settings-api.php
7 *
8 *
9 * @package wpdeepl_WP_Improved_Settings
10 * @version 20251205
11 *
12 * 20251205 Version 2.0 - PCP compliant, architecture extensible
13 * 20200320 ajout des setting en tableau
14 * 20190705 : default value for text field
15 */
16
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * WC_Improved_Settings_API class.
21 */
22 if ( !class_exists( 'wpdeepl_WP_Improved_Settings\WC_Improved_Settings_API' ) ) {
23 class WC_Improved_Settings_API {
24 /**
25 * The plugin ID. Used for option names.
26 *
27 * @var string
28 */
29 public $plugin_id = 'woocommerce_';
30
31 /**
32 * ID of the class extending the settings API. Used in option names.
33 *
34 * @var string
35 */
36 public $id = '';
37
38 /**
39 * Feature flags for version control
40 *
41 * @var array
42 */
43 protected $features = array(
44 'cache_enabled' => false, // v2.1+
45 'export_enabled' => false, // Sécurité WordPress.org
46 'advanced_crons' => false, // v2.2+
47 );
48
49 /**
50 * Validation errors.
51 *
52 * @var array of strings
53 */
54 protected $errors = array();
55
56 /**
57 * Setting values.
58 *
59 * @var array
60 */
61 protected $settings = array();
62
63 /**
64 * Form option fields.
65 *
66 * @var array
67 */
68 protected $form_fields = array();
69
70 /**
71 * The posted settings data. When empty, $_POST data will be used.
72 *
73 * @var array
74 */
75 protected $data = array();
76
77 /**
78 * Settings structure from configuration
79 *
80 * @var array
81 */
82 protected $settingsStructure = array();
83
84 public function __construct( $plugin_id , $settingsStructure ) {
85 $this->plugin_id = $plugin_id .'_';
86 $this->settingsStructure = $settingsStructure;
87 $this->init_form_fields();
88 }
89
90 /**
91 * Get feature flag status
92 *
93 * @param string $feature Feature name
94 * @return bool Feature enabled status
95 */
96 public function is_feature_enabled( $feature ) {
97 return isset( $this->features[$feature] ) ? $this->features[$feature] : false;
98 }
99
100 /**
101 * Set feature flag
102 *
103 * @param string $feature Feature name
104 * @param bool $enabled Feature status
105 */
106 public function set_feature( $feature, $enabled ) {
107 $this->features[$feature] = (bool) $enabled;
108 }
109
110 /**
111 * Initialise settings form fields.
112 *
113 * Add an array of fields to be displayed on the gateway's settings screen.
114 *
115 * @since 1.0.0
116 */
117 protected function init_form_fields() {
118 if ( !$this->settingsStructure || !count($this->settingsStructure) ) {
119 return false;
120 }
121 //wpdeepl_debug_display( $this->settingsStructure );die('okozerkozerk');
122 foreach ( $this->settingsStructure as $tab_id => $tab_data ) {
123 foreach ( $tab_data['sections'] as $section_id => $section_data ) {
124 if( isset( $section_data['fields'] ) ) foreach ( $section_data['fields'] as $field ) {
125 $this->id = $tab_id;
126 $field_key = $this->get_field_key( $field['id'] );
127
128 $field['tab'] = $tab_id;
129 $field['section'] = $section_id;
130 if ( isset( $this->form_fields[$field_key] ) ) {
131 // happens on parameter[\d]
132 continue;
133 }
134 $this->form_fields[$field_key] = $field;
135 }
136 }
137 }
138 }
139
140 public function process_admin_options() {
141 // Vérification nonce pour méthode publique
142 if ( ! $this->verify_settings_nonce() ) {
143 wp_die( esc_html__( 'Security check failed', 'wpdeepl' ) );
144 }
145
146 $post_data = $this->get_post_data();
147
148 $current_tab = sanitize_key( $post_data['tab'] ?? '' );
149 if ( empty( $current_tab ) ) {
150 return false;
151 }
152
153 if ( method_exists( $this, 'before_save' ) ) {
154 $this->before_save();
155 }
156
157 //wpdeepl_debug_display($this->form_fields, "fields"); wpdeepl_debug_display($post_data, "POST"); die('oaz4ea6zea4e6a846ek');
158
159
160 foreach ( $this->form_fields as $field_key => $field ) {
161 if ($field['tab'] != $current_tab) {
162 continue;
163 }
164
165 if ( isset( $post_data[$field_key] ) ) {
166 $field_value = $this->sanitize_field_value( $post_data[$field_key], $field );
167 update_option( $field_key, $field_value );
168 } else {
169 update_option($field_key, false);
170 }
171 }
172
173 if ( method_exists( $this, 'on_save' ) ) {
174 $this->on_save();
175 }
176 return true;
177 }
178
179 /**
180 * Sanitize field value based on field type
181 *
182 * @param mixed $value Field value
183 * @param array $field Field configuration
184 * @return mixed Sanitized value
185 */
186 protected function sanitize_field_value( $value, $field ) {
187 $field_type = $field['type'] ?? 'text';
188
189 switch ( $field_type ) {
190 case 'checkbox':
191 return $value == 1 ? 'yes' : 'no';
192 case 'multiselect':
193 case 'array':
194 if ( is_array( $value ) ) {
195 // Sanitize each array element and remove empty entries
196 $sanitized = array();
197 foreach ( $value as $i => $field_input ) {
198 if ( is_array( $field_input ) ) {
199 if ( strlen( implode( '', $field_input ) ) > 0 ) {
200 $sanitized[$i] = array_map( 'sanitize_text_field', $field_input );
201 }
202 } else {
203 $sanitized_value = sanitize_text_field( $field_input );
204 if ( strlen( $sanitized_value ) > 0 ) {
205 $sanitized[] = $sanitized_value;
206 }
207 }
208 }
209 return $sanitized;
210 }
211 return $value;
212 case 'textarea':
213 return sanitize_textarea_field( $value );
214 case 'select':
215 case 'radio':
216 case 'text':
217 default:
218 // Handle arrays that might slip through (shouldn't happen normally)
219 if ( is_array( $value ) ) {
220 return array_map( 'sanitize_text_field', $value );
221 }
222 return sanitize_text_field( $value );
223 }
224 }
225
226 /**
227 * Prefix key for settings.
228 *
229 * @param string $key Field key.
230 * @return string
231 */
232 protected function get_field_key( $key ) {
233 if ( preg_match('#^([\w_]+)\[\d+\]$#', $key, $match ) ) {
234 $key = $match[1];
235 }
236 return $this->plugin_id . $key;
237 }
238
239 protected function get_sub_field_key( $key ) {
240 if ( preg_match('#^([\w_]+)\[(\d+)\]$#', $key, $match ) ) {
241 return $match[2];
242 }
243 return false;
244 }
245
246 protected function get_raw_field_key( $key ) {
247 return $this->plugin_id . $key;
248 }
249
250 public function update_option( $key, $value = '' ) {
251 //echo "\n UPDATING '$key', OPTION = '" . $this->get_field_key( $key ) . "' avec VALUE = '" . $value ."'"; die( 'ozaezeaz4e68a4z4e6ek' );
252 /* if ( empty( $this->settings ) ) {
253 $this->init_settings();
254 }
255
256 $this->settings[ $key ] = $value;
257
258 return update_option( $this->get_option_key(), apply_filters( 'wpimproved_settings_api_sanitized_fields_' . $this->id, $this->settings ), 'yes' );*/
259 return update_option( $this->get_field_key( $key ), $value );
260 }
261
262 /**
263 * Get option from DB.
264 *
265 * Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
266 *
267 * @param string $key Option key.
268 * @param mixed $empty_value Value when empty.
269 * @return string The value specified for the option or a default value for the option.
270 */
271 public function get_option( $key, $empty_value = null ) {
272 return get_option( $this->get_field_key( $key ) );
273 }
274
275 public function generate_radio_html( $key, $data ) {
276 $field_key = $this->get_field_key( $key );
277 $defaults = array(
278 'title' => '',
279 'label' => '',
280 'disabled' => false,
281 'class' => '',
282 'css' => '',
283 'type' => 'text',
284 'desc_tip' => false,
285 'description' => '',
286 'custom_attributes' => array(),
287 );
288
289 $data = wp_parse_args( $data, $defaults );
290
291 if ( ! $data['label'] ) {
292 $data['label'] = $data['title'];
293 }
294
295 ob_start();
296 ?>
297 <tr valign="top">
298 <th scope="row" class="titledesc">
299 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?></label>
300 </th>
301 <td class="forminp">
302 <fieldset>
303 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
304 <?php
305 $stored_value = $this->get_option( $key );
306 if ( !$stored_value && isset( $data['wpdeepl'] ) ) {
307 $stored_value = $data['wpdeepl'];
308 }
309
310 if ( isset( $data['values'] ) ) foreach ( $data['values'] as $value => $label ) :
311 ?>
312 <input <?php disabled( $data['disabled'], true ); ?> class="<?php echo esc_attr( $data['class'] ); ?>" type="radio" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ) . '_' . esc_attr( sanitize_title( $value ) );?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr($value); ?>" <?php checked( $stored_value, $value ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> />
313 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $label ); ?></label>
314 <br />
315 <?php endforeach; ?>
316 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
317 </fieldset>
318 </td>
319 </tr>
320 <?php
321
322 return ob_get_clean();
323 }
324
325 public function generate_raw_html( $key, $data ) {
326 $field_key = $this->get_field_key( $key );
327 $defaults = array(
328 'title' => '',
329 'label' => '',
330 'disabled' => false,
331 'class' => '',
332 'css' => '',
333 'type' => 'text',
334 'desc_tip' => false,
335 'description' => '',
336 'custom_attributes' => array(),
337 );
338
339 $data = wp_parse_args( $data, $defaults );
340
341 ob_start();
342 ?>
343 <tr valign="top">
344 <th scope="row" class="titledesc">
345 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?></label>
346 </th>
347 <td class="forminp">
348 <fieldset>
349 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
350 <?php
351 $stored_value = $this->get_option( $key );
352 if ( !$stored_value && isset( $data['wpdeepl'] ) ) {
353 $stored_value = $data['wpdeepl'];
354 }
355
356 echo wp_kses_post( $data['raw_html'] ); ?>
357 <br/>
358 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
359 </fieldset>
360 </td>
361 </tr>
362 <?php
363
364 return ob_get_clean();
365 }
366
367
368 /**
369 * Get the form fields after they are initialized.
370 *
371 * @return array of options
372 */
373 protected function get_form_fields() {
374 return apply_filters( 'wpdeepl_wpimproved_settings_api_form_fields_' . $this->id, array_map( array( $this, 'set_defaults' ), $this->form_fields ) );
375 }
376
377 /**
378 * Set default required properties for each field.
379 *
380 * @param array $field Setting field array.
381 * @return array
382 */
383 protected function set_defaults( $field ) {
384 if ( ! isset( $field['default'] ) ) {
385 $field['default'] = '';
386 }
387 return $field;
388 }
389
390 /**
391 * Output the admin options table.
392 */
393 public function admin_options() {
394 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_settings_html retourne du HTML déjà sécurisé
395 echo '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>';
396 }
397
398
399
400 /**
401 * Return the name of the option in the WP DB.
402 *
403 * @since 2.6.0
404 * @return string
405 */
406 public function get_option_key() {
407 return $this->plugin_id . $this->id . '_settings';
408 }
409
410 /**
411 * Get a fields type. Defaults to "text" if not set.
412 *
413 * @param array $field Field key.
414 * @return string
415 */
416 protected function get_field_type( $field ) {
417 return empty( $field['type'] ) ? 'text' : $field['type'];
418 }
419
420 /**
421 * Get a fields default value. Defaults to "" if not set.
422 *
423 * @param array $field Field key.
424 * @return string
425 */
426 protected function get_field_default( $field ) {
427 return empty( $field['wpdeepl'] ) ? '' : $field['wpdeepl'];
428 }
429
430 /**
431 * Get a field's posted and validated value.
432 *
433 * @param string $key Field key.
434 * @param array $field Field array.
435 * @param array $post_data Posted data.
436 * @return string
437 */
438 public function get_field_value( $key, $field, $post_data = array() ) {
439 $type = $this->get_field_type( $field );
440 $field_key = $this->get_field_key( $key );
441 $post_data = empty( $post_data ) ? $this->get_post_data() : $post_data;
442 $value = isset( $post_data[ $field_key ] ) ? $post_data[ $field_key ] : null;
443
444 if ( isset( $field['sanitize_callback'] ) && is_callable( $field['sanitize_callback'] ) ) {
445 return call_user_func( $field['sanitize_callback'], $value );
446 }
447
448 // Look for a validate_FIELDID_field method for special handling.
449 if ( is_callable( array( $this, 'validate_' . $key . '_field' ) ) ) {
450 return $this->{'validate_' . $key . '_field'}( $key, $value );
451 }
452
453 // Look for a validate_FIELDTYPE_field method.
454 if ( is_callable( array( $this, 'validate_' . $type . '_field' ) ) ) {
455 return $this->{'validate_' . $type . '_field'}( $key, $value );
456 }
457
458 // Fallback to text.
459 return $this->validate_text_field( $key, $value );
460 }
461
462 /**
463 * Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.
464 *
465 * @param array $data Posted data.
466 */
467 public function set_post_data( $data = array() ) {
468 $this->data = $data;
469 }
470
471 /**
472 * Verify settings nonce for security
473 *
474 * @return bool
475 */
476 protected function verify_settings_nonce() {
477 return isset( $_POST['_wpdeepl_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpdeepl_nonce'] ) ), 'wpdeepl_save_settings' );
478 }
479
480 /**
481 * Recursively sanitize POST data
482 *
483 * @param mixed $data Data to sanitize.
484 * @return mixed Sanitized data.
485 */
486 protected function sanitize_post_data_recursive( $data ) {
487 if ( is_array( $data ) ) {
488 return array_map( array( $this, 'sanitize_post_data_recursive' ), $data );
489 }
490 return sanitize_text_field( $data );
491 }
492
493 /**
494 * Returns the POSTed data, to be used to save the settings.
495 *
496 * @return array
497 */
498 public function get_post_data() {
499 if ( ! empty( $this->data ) && is_array( $this->data ) ) {
500 return $this->data;
501 }
502
503 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- this here is where we clean POST data
504 return $this->sanitize_post_data_recursive( wp_unslash( $_POST ) );
505 }
506
507 /**
508 * Add an error message for display in admin on save.
509 *
510 * @param string $error Error message.
511 */
512 public function add_error( $error ) {
513 $this->errors[] = $error;
514 }
515
516 /**
517 * Get admin error messages.
518 */
519 public function get_errors() {
520 return $this->errors;
521 }
522
523 /**
524 * Display admin error messages.
525 */
526 public function display_errors() {
527 if ( $this->get_errors() ) {
528 echo '<div id="woocommerce_errors" class="error notice is-dismissible">';
529 foreach ( $this->get_errors() as $error ) {
530 echo '<p>' . wp_kses_post( $error ) . '</p>';
531 }
532 echo '</div>';
533 }
534 }
535
536 /**
537 * Initialise Settings.
538 *
539 * Store all settings in a single database entry
540 * and make sure the $settings array is either the default
541 * or the settings stored in the database.
542 *
543 * @since 1.0.0
544 * @uses get_option(), add_option()
545 */
546 public function init_settings() {
547 $this->settings = get_option( $this->get_option_key(), null );
548
549 // If there are no settings defined, use defaults.
550 if ( ! is_array( $this->settings ) ) {
551 $form_fields = $this->get_form_fields();
552 $this->settings = array_merge( array_fill_keys( array_keys( $form_fields ), '' ), wp_list_pluck( $form_fields, 'wpdeepl' ) );
553 }
554 }
555
556 /**
557 * Generate Settings HTML.
558 *
559 * Generate the HTML for the fields on the "settings" screen.
560 *
561 * @param array $form_fields ( default: array() ) Array of form fields.
562 * @param bool $echo Echo or return.
563 * @return string the html for the settings
564 * @since 1.0.0
565 * @uses method_exists()
566 */
567 public function generate_settings_html( $form_fields = array(), $echo = true ) {
568 if ( empty( $form_fields ) ) {
569 //$form_fields = $this->get_form_fields();
570 }
571
572 //wpdeepl_debug_display($form_fields, " form fields");
573
574 $html = '';
575 foreach ( $form_fields as $field ) {
576 $type = $this->get_field_type( $field );
577 //wpdeepl_debug_display($field, " DONC TYPE = '$type'");
578
579 if ( method_exists( $this, 'generate_' . $type . '_html' ) ) {
580 $html .= $this->{'generate_' . $type . '_html'}( $field['id'], $field );
581 } else {
582 $html .= $this->generate_text_html( $field['id'], $field );
583 }
584 }
585
586 if ( $echo ) {
587 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML already escaped in generate_*_html methods
588 echo $html;
589 } else {
590 return $html;
591 }
592 }
593
594 /**
595 * Get HTML for tooltips.
596 *
597 * @param array $data Data for the tooltip.
598 * @return string
599 */
600 protected function get_tooltip_html( $data ) {
601 if ( true === $data['desc_tip'] ) {
602 $tip = $data['description'];
603 } elseif ( ! empty( $data['desc_tip'] ) ) {
604 $tip = $data['desc_tip'];
605 } else {
606 $tip = '';
607 }
608
609 return $tip ? $tip : '';
610 }
611
612 /**
613 * Get HTML for descriptions.
614 *
615 * @param array $data Data for the description.
616 * @return string
617 */
618 protected function get_description_html( $data ) {
619 if ( true === $data['desc_tip'] ) {
620 $description = '';
621 } elseif ( ! empty( $data['desc_tip'] ) ) {
622 $description = $data['description'];
623 } elseif ( ! empty( $data['description'] ) ) {
624 $description = $data['description'];
625 } else {
626 $description = '';
627 }
628
629 return $description ? '<p class="description">' . wp_kses_post( $description ) . '</p>' . "\n" : '';
630 }
631
632 /**
633 * Get custom attributes.
634 *
635 * @param array $data Field data.
636 * @return string
637 */
638 protected function get_custom_attribute_html( $data ) {
639 $custom_attributes = array();
640
641 if ( ! empty( $data['custom_attributes'] ) && is_array( $data['custom_attributes'] ) ) {
642 foreach ( $data['custom_attributes'] as $attribute => $attribute_value ) {
643 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
644 }
645 }
646
647 return implode( ' ', $custom_attributes );
648 }
649
650 /**
651 * Generate Text Input HTML.
652 *
653 * @param string $key Field key.
654 * @param array $data Field data.
655 * @since 1.0.0
656 * @return string
657 */
658 public function generate_text_html( $key, $data ) {
659 $field_key = $this->get_field_key( $key );
660 $defaults = array(
661 'title' => '',
662 'disabled' => false,
663 'wpdeepl' => false,
664 'class' => '',
665 'css' => '',
666 'placeholder' => '',
667 'type' => 'text',
668 'desc_tip' => false,
669 'description' => '',
670 'custom_attributes' => array(),
671 );
672
673 $data = wp_parse_args( $data, $defaults );
674
675 ob_start();
676 ?>
677 <tr valign="top">
678 <th scope="row" class="titledesc">
679 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?></label>
680 </th>
681 <td class="forminp">
682 <fieldset>
683 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
684 <input class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $data['type'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php
685 if ( $this->get_option( $key ) ) {
686 echo esc_attr( $this->get_option( $key ) );
687 }
688 elseif ( $data['wpdeepl'] ) {
689 echo esc_attr( $data['wpdeepl'] );
690 } ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> />
691 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
692 </fieldset>
693 </td>
694 </tr>
695 <?php
696
697 return ob_get_clean();
698 }
699
700 /**
701 * Generate Text Input HTML.
702 *
703 * @param string $key Field key.
704 * @param array $data Field data.
705 * @since 1.0.0
706 * @return string
707 */
708 public function generate_array_html( $key, $data ) {
709
710 $field_key = $this->get_field_key( $key );
711 //wpdeepl_debug_display($data, "data pzeijezpi");
712 //wpdeepl_debug_display($key, "key, field key $field_key");
713 $defaults = array(
714 'title' => '',
715 'disabled' => false,
716 'wpdeepl' => false,
717 'class' => '',
718 'css' => '',
719 'placeholder' => '',
720 'type' => 'text',
721 'desc_tip' => false,
722 'description' => '',
723 'custom_attributes' => array(),
724 );
725
726 $data = wp_parse_args( $data, $defaults );
727
728
729 ob_start();
730 ?>
731 <tr valign="top">
732 <th scope="row" class="titledesc">
733 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?></label>
734 </th>
735 <?php foreach ( $data['keys'] as $input_key => $input_type ) :
736 $main_class = "input-" . $input_type;
737 $main_type = $input_type;
738 if ( $main_type == 'decimal' ) {
739 $main_type = 'text';
740 }
741 ?>
742
743 <td class="forminp <?php echo esc_attr( sanitize_key( $field_key ) ); ?> <?php echo esc_attr( sanitize_key( $field_key ) .'_' . $input_key ); ?>">
744 <fieldset>
745 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
746 <input class="<?php echo esc_attr( $main_class );; ?> regular-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $input_type ); ?>" name="<?php echo esc_attr( $field_key ); ?>[<?php echo esc_attr( $data['index'] ); ?>][<?php echo esc_attr( $input_key ); ?>]" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php
747 if ( isset( $data['values'][$input_key] ) ) {
748 echo esc_attr( $data['values'][$input_key] );
749 }
750 elseif ( $data['wpdeepl'] ) {
751 echo esc_attr( $data['wpdeepl'] );
752 } ?>" placeholder="<?php echo isset( $data['placeholders'][$input_key] ) ? esc_attr( $data['placeholders'][$input_key] ) : ''; ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> />
753 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
754 </fieldset>
755
756 </td>
757 <?php endforeach; ?>
758 <td><a href="#" class="delete_row" onclick="jQuery(this).parent('td').parent('tr').remove(); return false;"><?php esc_html_e( 'Delete', 'wpdeepl' ); ?></a></td>
759 </tr>
760 <?php
761
762 return ob_get_clean();
763 }
764 /**
765 * Generate Price Input HTML.
766 *
767 * @param string $key Field key.
768 * @param array $data Field data.
769 * @since 1.0.0
770 * @return string
771 */
772 public function generate_price_html( $key, $data ) {
773 $field_key = $this->get_field_key( $key );
774 $defaults = array(
775 'title' => '',
776 'disabled' => false,
777 'class' => '',
778 'css' => '',
779 'placeholder' => '',
780 'type' => 'text',
781 'desc_tip' => false,
782 'description' => '',
783 'custom_attributes' => array(),
784 );
785
786 $data = wp_parse_args( $data, $defaults );
787
788 ob_start();
789 ?>
790 <tr valign="top">
791 <th scope="row" class="titledesc">
792 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?></label>
793 </th>
794 <td class="forminp">
795 <fieldset>
796 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
797 <input class="wc_input_price input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $this->get_option( $key ) ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> />
798 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
799 </fieldset>
800 </td>
801 </tr>
802 <?php
803
804 return ob_get_clean();
805 }
806
807 /**
808 * Generate Decimal Input HTML.
809 *
810 * @param string $key Field key.
811 * @param array $data Field data.
812 * @since 1.0.0
813 * @return string
814 */
815 public function generate_decimal_html( $key, $data ) {
816 $field_key = $this->get_field_key( $key );
817 $defaults = array(
818 'title' => '',
819 'disabled' => false,
820 'class' => '',
821 'css' => '',
822 'placeholder' => '',
823 'type' => 'text',
824 'desc_tip' => false,
825 'description' => '',
826 'custom_attributes' => array(),
827 );
828
829 $data = wp_parse_args( $data, $defaults );
830
831 ob_start();
832 ?>
833 <tr valign="top">
834 <th scope="row" class="titledesc">
835 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?></label>
836 </th>
837 <td class="forminp">
838 <fieldset>
839 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
840 <input class="wc_input_decimal input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( wc_format_localized_decimal( $this->get_option( $key ) ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> />
841 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
842 </fieldset>
843 </td>
844 </tr>
845 <?php
846
847 return ob_get_clean();
848 }
849
850 /**
851 * Generate Password Input HTML.
852 *
853 * @param string $key Field key.
854 * @param array $data Field data.
855 * @since 1.0.0
856 * @return string
857 */
858 public function generate_password_html( $key, $data ) {
859 $data['type'] = 'password';
860 return $this->generate_text_html( $key, $data );
861 }
862
863 /**
864 * Generate Color Picker Input HTML.
865 *
866 * @param string $key Field key.
867 * @param array $data Field data.
868 * @since 1.0.0
869 * @return string
870 */
871 public function generate_color_html( $key, $data ) {
872 $field_key = $this->get_field_key( $key );
873 $defaults = array(
874 'title' => '',
875 'disabled' => false,
876 'class' => '',
877 'css' => '',
878 'placeholder' => '',
879 'desc_tip' => false,
880 'description' => '',
881 'custom_attributes' => array(),
882 );
883
884 $data = wp_parse_args( $data, $defaults );
885
886 ob_start();
887 ?>
888 <tr valign="top">
889 <th scope="row" class="titledesc">
890
891 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php
892 // get_tooltip_html returns safe HTML
893 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
894 echo $this->get_tooltip_html( $data ); ?></label>
895 </th>
896 <td class="forminp">
897 <fieldset>
898 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
899 <span class="colorpickpreview" style="background:<?php echo esc_attr( $this->get_option( $key ) ); ?>;">&nbsp;</span>
900 <input class="colorpick <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> />
901 <div id="colorPickerDiv_<?php echo esc_attr( $field_key ); ?>" class="colorpickdiv" style="z-index: 100; background: #eee; border: 1px solid #ccc; position: absolute; display: none;"></div>
902 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
903 </fieldset>
904 </td>
905 </tr>
906 <?php
907
908 return ob_get_clean();
909 }
910
911 /**
912 * Generate Textarea HTML.
913 *
914 * @param string $key Field key.
915 * @param array $data Field data.
916 * @since 1.0.0
917 * @return string
918 */
919 public function generate_textarea_html( $key, $data ) {
920 $field_key = $this->get_field_key( $key );
921 $defaults = array(
922 'title' => '',
923 'disabled' => false,
924 'class' => '',
925 'css' => '',
926 'placeholder' => '',
927 'type' => 'text',
928 'desc_tip' => false,
929 'description' => '',
930 'custom_attributes' => array(),
931 );
932
933 $data = wp_parse_args( $data, $defaults );
934
935 ob_start();
936 ?>
937 <tr valign="top">
938 <th scope="row" class="titledesc">
939 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php
940 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_tooltip_html retourne HTML déjà sécurisé
941 echo $this->get_tooltip_html( $data ); ?></label>
942 </th>
943 <td class="forminp">
944 <fieldset>
945 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
946 <textarea rows="3" cols="20" class="input-text wide-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $data['type'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?>><?php echo $this->get_option( $key ) ? esc_textarea( $this->get_option( $key ) ) : esc_attr( $data['placeholder']); ?></textarea>
947 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
948 </fieldset>
949 </td>
950 </tr>
951 <?php
952
953 return ob_get_clean();
954 }
955
956 /**
957 * Generate Checkbox HTML.
958 *
959 * @param string $key Field key.
960 * @param array $data Field data.
961 * @since 1.0.0
962 * @return string
963 */
964 public function generate_checkbox_html( $key, $data ) {
965 $field_key = $this->get_field_key( $key );
966 $defaults = array(
967 'title' => '',
968 'label' => '',
969 'disabled' => false,
970 'class' => '',
971 'css' => '',
972 'type' => 'text',
973 'desc_tip' => false,
974 'description' => '',
975 'custom_attributes' => array(),
976 );
977
978 $data = wp_parse_args( $data, $defaults );
979
980 if ( ! $data['label'] ) {
981 $data['label'] = $data['title'];
982 }
983
984 ob_start();
985 ?>
986 <tr valign="top">
987 <th scope="row" class="titledesc">
988 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php
989 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_tooltip_html retourne HTML déjà sécurisé
990 echo $this->get_tooltip_html( $data ); ?></label>
991 </th>
992 <td class="forminp">
993 <fieldset>
994 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
995 <label for="<?php echo esc_attr( $field_key ); ?>">
996 <input <?php disabled( $data['disabled'], true ); ?> class="<?php echo esc_attr( $data['class'] ); ?>" type="checkbox" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="1" <?php checked( filter_var( $this->get_option( $key ), FILTER_VALIDATE_BOOLEAN ) ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> /> <?php echo wp_kses_post( $data['label'] ); ?></label><br/>
997 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
998 </fieldset>
999 </td>
1000 </tr>
1001 <?php
1002
1003 return ob_get_clean();
1004 }
1005
1006 /**
1007 * Generate Select HTML.
1008 *
1009 * @param string $key Field key.
1010 * @param array $data Field data.
1011 * @since 1.0.0
1012 * @return string
1013 */
1014 public function generate_select_html( $key, $data ) {
1015 $field_key = $this->get_raw_field_key( $key );
1016 $sub_field_key = $this->get_sub_field_key( $key );
1017 $selected_value = $this->get_option($key);
1018 if ( $sub_field_key ) {
1019 $selected_value = $selected_value[$sub_field_key];
1020 }
1021 //wpdeepl_debug_display($selected_value, " seleizehri pour key $key / field key $field_key");
1022 $defaults = array(
1023 'title' => '',
1024 'disabled' => false,
1025 'class' => '',
1026 'css' => '',
1027 'placeholder' => '',
1028 'type' => 'text',
1029 'desc_tip' => false,
1030 'description' => '',
1031 'custom_attributes' => array(),
1032 'options' => array(),
1033 );
1034
1035 $data = wp_parse_args( $data, $defaults );
1036
1037 //wpdeepl_debug_display($data, "pour key $key");
1038
1039
1040 ob_start();
1041 ?>
1042 <tr valign="top">
1043 <th scope="row" class="titledesc">
1044
1045
1046 <label for="<?php echo esc_attr( $field_key ); ?>"><?php
1047 // get_tooltip_html return safe HTML. Output needs no escaping.
1048 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1049 echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); ?></label>
1050 </th>
1051 <td class="forminp">
1052 <fieldset>
1053 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
1054 <select class="select <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?>>
1055 <?php foreach ( ( array ) $data['options'] as $option_key => $option_value ) : ?>
1056 <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( ( string ) $option_key, esc_attr( $selected_value ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
1057 <?php endforeach; ?>
1058 </select>
1059 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
1060 </fieldset>
1061 </td>
1062 </tr>
1063 <?php
1064
1065 return ob_get_clean();
1066 }
1067
1068 /**
1069 * Generate Multiselect HTML.
1070 *
1071 * @param string $key Field key.
1072 * @param array $data Field data.
1073 * @since 1.0.0
1074 * @return string
1075 */
1076 public function generate_multiselect_html( $key, $data ) {
1077 $field_key = $this->get_field_key( $key );
1078 $defaults = array(
1079 'title' => '',
1080 'disabled' => false,
1081 'class' => '',
1082 'css' => '',
1083 'placeholder' => '',
1084 'type' => 'text',
1085 'desc_tip' => false,
1086 'description' => '',
1087 'custom_attributes' => array(),
1088 'select_buttons' => false,
1089 'options' => array(),
1090 );
1091
1092 $data = wp_parse_args( $data, $defaults );
1093 $value = ( array ) $this->get_option( $key, array() );
1094
1095 //wpdeepl_debug_display($data['options'], 'options');
1096
1097 ob_start();
1098 ?>
1099 <tr valign="top">
1100 <th scope="row" class="titledesc">
1101
1102
1103 <label for="<?php echo esc_attr( $field_key ); ?>"><?php
1104 // get_tooltip_html return safe HTML. Output needs no escaping.
1105 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1106 echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); ?></label>
1107 </th>
1108 <td class="forminp">
1109 <fieldset>
1110 <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
1111 <select multiple="multiple" class="multiselect <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>[]" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?>>
1112 <?php foreach ( ( array ) $data['options'] as $option_key => $option_value ) : ?>
1113 <?php if ( is_array( $option_value ) ) : ?>
1114 <optgroup label="<?php echo esc_attr( $option_key ); ?>">
1115 <?php foreach ( $option_value as $option_key_inner => $option_value_inner ) : ?>
1116 <option value="<?php echo esc_attr( $option_key_inner ); ?>" <?php selected( in_array( ( string ) $option_key_inner, $value, true ), true ); ?>><?php echo esc_attr( $option_value_inner ); ?></option>
1117 <?php endforeach; ?>
1118 </optgroup>
1119 <?php else : ?>
1120 <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( ( string ) $option_key, $value, true ), true ); ?>><?php echo esc_attr( $option_value ); ?></option>
1121 <?php endif; ?>
1122 <?php endforeach; ?>
1123 </select>
1124 <?php echo wp_kses_post( $this->get_description_html( $data ) ); ?>
1125 <?php if ( $data['select_buttons'] ) : ?>
1126 <br/><a class="select_all button" href="#"><?php esc_htmlesc_html_e( 'Select all', 'wpdeepl' ); ?></a> <a class="select_none button" href="#"><?php esc_htmlesc_html_e( 'Select none', 'wpdeepl' ); ?></a>
1127 <?php endif; ?>
1128 </fieldset>
1129 </td>
1130 </tr>
1131 <?php
1132
1133 return ob_get_clean();
1134 }
1135
1136
1137 function generate_file_upload_html( $key, $data ) {
1138 $field_key = $this->get_field_key( $key );
1139 $defaults = array(
1140 'title' => '',
1141 'class' => '',
1142 'page' => $this->option_page,
1143 'action' => '',
1144 );
1145
1146 $data = wp_parse_args( $data, $defaults );
1147
1148 ob_start();
1149 $bytes = apply_filters( 'wpdeepl_import_upload_size_limit', wp_max_upload_size() );
1150 $size = size_format( $bytes );
1151 $upload_dir = wp_upload_dir();
1152 if ( ! empty( $upload_dir['error'] ) ) :
1153 ?><div class="error"><p><?php
1154 esc_html_e('Before you can upload your import file, you will need to fix the following error:', 'wpdeepl' ); ?></p>
1155 <p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p></div><?php
1156 else :
1157 ?>
1158 <form enctype="multipart/form-data" id="import-adr-form" method="post" class="wp-upload-form" action="?page='<?php echo esc_attr( $data['page'] ); ?>'">
1159
1160 <input type="hidden" name="page" value="<?php echo esc_attr( $data['page'] ); ?>" />
1161 <h3><?php echo esc_html( $data['title'] ); ?></h3>
1162 <p>
1163 <label for="filename"><?php esc_html_e( 'Choose a file from your computer:', 'wpdeepl' ); ?></label> (<?php
1164 /* translators: size of the maximum upload */
1165 printf( esc_html__( 'Maximum size: %s', 'wpdeepl' ), esc_html( $size ) ); ?>)
1166 <input type="file" id="filename" name="filename" size="25" />
1167 </p>
1168
1169 <input type="hidden" name="action" value="<?php echo esc_attr( $data['action'] ) ; ?>" />
1170 <input type="hidden" name="max_file_size" value="<?php echo esc_attr( $bytes ); ?>" />
1171 </p>
1172 <?php submit_button( __( 'Upload file and import', 'wpdeepl' ), 'primary' ); ?>
1173 </form>
1174 <?php
1175 endif;
1176
1177 return ob_get_clean();
1178 }
1179
1180 /**
1181 * Generate Title HTML.
1182 *
1183 * @param string $key Field key.
1184 * @param array $data Field data.
1185 * @since 1.0.0
1186 * @return string
1187 */
1188 public function generate_title_html( $key, $data ) {
1189 $field_key = $this->get_field_key( $key );
1190 $defaults = array(
1191 'title' => '',
1192 'class' => '',
1193 );
1194
1195 $data = wp_parse_args( $data, $defaults );
1196
1197 ob_start();
1198 ?>
1199 </table>
1200 <h3 class="wc-settings-sub-title <?php echo esc_attr( $data['class'] ); ?>" id="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></h3>
1201 <?php if ( ! empty( $data['description'] ) ) : ?>
1202 <p><?php echo wp_kses_post( $data['description'] ); ?></p>
1203 <?php endif; ?>
1204 <table class="form-table">
1205 <?php
1206
1207 return ob_get_clean();
1208 }
1209
1210 /**
1211 * Validate Text Field.
1212 *
1213 * Make sure the data is escaped correctly, etc.
1214 *
1215 * @param string $key Field key.
1216 * @param string $value Posted Value.
1217 * @return string
1218 */
1219 public function validate_text_field( $key, $value ) {
1220 $value = is_null( $value ) ? '' : $value;
1221 return wp_kses_post( trim( stripslashes( $value ) ) );
1222 }
1223
1224 /**
1225 * Validate Price Field.
1226 *
1227 * Make sure the data is escaped correctly, etc.
1228 *
1229 * @param string $key Field key.
1230 * @param string $value Posted Value.
1231 * @return string
1232 */
1233 public function validate_price_field( $key, $value ) {
1234 $value = is_null( $value ) ? '' : $value;
1235 return ( '' === $value ) ? '' : wc_format_decimal( trim( stripslashes( $value ) ) );
1236 }
1237
1238 /**
1239 * Validate Decimal Field.
1240 *
1241 * Make sure the data is escaped correctly, etc.
1242 *
1243 * @param string $key Field key.
1244 * @param string $value Posted Value.
1245 * @return string
1246 */
1247 public function validate_decimal_field( $key, $value ) {
1248 $value = is_null( $value ) ? '' : $value;
1249 return ( '' === $value ) ? '' : wc_format_decimal( trim( stripslashes( $value ) ) );
1250 }
1251
1252 /**
1253 * Validate Password Field. No input sanitization is used to avoid corrupting passwords.
1254 *
1255 * @param string $key Field key.
1256 * @param string $value Posted Value.
1257 * @return string
1258 */
1259 public function validate_password_field( $key, $value ) {
1260 $value = is_null( $value ) ? '' : $value;
1261 return trim( stripslashes( $value ) );
1262 }
1263
1264 /**
1265 * Validate Textarea Field.
1266 *
1267 * @param string $key Field key.
1268 * @param string $value Posted Value.
1269 * @return string
1270 */
1271 public function validate_textarea_field( $key, $value ) {
1272 $value = is_null( $value ) ? '' : $value;
1273 return wp_kses( trim( stripslashes( $value ) ),
1274 array_merge(
1275 array(
1276 'iframe' => array(
1277 'src' => true,
1278 'style' => true,
1279 'id' => true,
1280 'class' => true,
1281 ),
1282 ),
1283 wp_kses_allowed_html( 'post' )
1284 )
1285 );
1286 }
1287
1288 /**
1289 * Validate Checkbox Field.
1290 *
1291 * If not set, return "no", otherwise return "yes".
1292 *
1293 * @param string $key Field key.
1294 * @param string $value Posted Value.
1295 * @return string
1296 */
1297 public function validate_checkbox_field( $key, $value ) {
1298 return ! is_null( $value ) ? 'yes' : 'no';
1299 }
1300
1301 /**
1302 * Validate Select Field.
1303 *
1304 * @param string $key Field key.
1305 * @param string $value Posted Value.
1306 * @return string
1307 */
1308 public function validate_select_field( $key, $value ) {
1309 $value = is_null( $value ) ? '' : $value;
1310 return wc_clean( stripslashes( $value ) );
1311 }
1312
1313 /**
1314 * Validate Multiselect Field.
1315 *
1316 * @param string $key Field key.
1317 * @param string $value Posted Value.
1318 * @return string|array
1319 */
1320 public function validate_multiselect_field( $key, $value ) {
1321 return is_array( $value ) ? array_map( 'wc_clean', array_map( 'stripslashes', $value ) ) : '';
1322 }
1323
1324 /**
1325 * Validate the data on the "Settings" form.
1326 *
1327 * @deprecated 2.6.0 No longer used.
1328 * @param array $form_fields Array of fields.
1329 */
1330 public function validate_settings_fields( $form_fields = array() ) {
1331 wc_deprecated_function( 'validate_settings_fields', '2.6' );
1332 }
1333
1334 /**
1335 * Format settings if needed.
1336 *
1337 * @deprecated 2.6.0 Unused.
1338 * @param array $value Value to format.
1339 * @return array
1340 */
1341 public function format_settings( $value ) {
1342 wc_deprecated_function( 'format_settings', '2.6' );
1343 return $value;
1344 }
1345 }
1346 }
1347