PluginProbe
Translation with DeepL API / 2.4.3.9
Translation with DeepL API v2.4.3.9
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
← All changes | settings/wp-improved-settings.class.php +158 -164 trunk2.4.3.9 View file →
@@ -1,12 +1,11 @@
1 1 <?php
2 2 /**
3 3 * Improved Settings
4 4 *
5 - * @package wpdeepl_WP_Improved_Settings
6 - * @version 20251205
5 + * @package WP_Improved_Settings
6 + * @version 20221115
7 7 *
8 - * 20251205 Version 2.0 - Adaptée à l'API v2.0, PCP compliant
9 8 * 20221115 esc all
10 9 * 20210111 ajout wpimpsettings_find_option_like
11 10 * 20200320 ajout des setting en tableau
12 11 * 20190705 footer actions prise en compte des méthodes
@@ -13,95 +12,60 @@
13 12 * 201991125 plugin_text_domain supprimé
14 13 * 20191201 plugin paths
15 14 */
16 15
17 -namespace wpdeepl_WP_Improved_Settings;
18 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16 +namespace WP_Improved_Settings;
19 17
20 -if ( !function_exists( 'wpdeepl_WP_Improved_Settings\zebench_get_plugin_paths' ) ) {
18 +if ( !function_exists( 'WP_Improved_Settings\zebench_get_plugin_paths' ) ) {
21 19 function zebench_get_plugin_paths() {
22 - $array = apply_filters( 'wpdeepl_zebench_get_plugin_paths', array() );
20 + $array = apply_filters( 'zebench_get_plugin_paths', array() );
23 21 return $array;
24 22 }
25 23 }
26 24
27 -if( !function_exists('wpdeepl_WP_Improved_Settings\wpimpsettings_find_all_options_like') ){
25 +if( !function_exists('WP_Improved_Settings\wpimpsettings_find_all_options_like') ){
28 26 function wpimpsettings_find_all_options_like( $string ) {
29 - if ( ! current_user_can( 'manage_options' ) ) {
30 - return array();
31 - }
27 + // ugly hack to fetch plugin_name_index options
32 28 global $wpdb;
33 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Prepared statement, admin-only utility function
34 - $results = $wpdb->get_results(
35 - $wpdb->prepare(
36 - "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE %s",
37 - '%' . $wpdb->esc_like( $string ) . '%' // Assainissement (esc_like) et wildcards injectés ici
38 - )
39 - , ARRAY_A );
29 + $search = $wpdb->_real_escape( $string );
30 + $sql = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE '%$search%'";
40 31
32 + $results = $wpdb->get_results( $sql, ARRAY_A );
41 33 return $results;
42 34 }
43 35 }
44 -if( !function_exists('wpdeepl_WP_Improved_Settings\wpimpsettings_find_option_like') ){
36 +
37 +if( !function_exists('WP_Improved_Settings\wpimpsettings_find_option_like') ){
45 38 function wpimpsettings_find_option_like( $string ) {
46 - if ( ! current_user_can( 'manage_options' ) ) {
47 - return array();
48 - }
39 + // ugly hack to fetch plugin_name_index options
49 40 global $wpdb;
50 - $sanitized_string = sanitize_key( $string );
51 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Prepared statement, admin-only utility function
52 - $results = $wpdb->get_results(
53 - $wpdb->prepare(
54 - "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE %s",
55 - $wpdb->esc_like( $sanitized_string ) . '%' // [sanitized_string]%
56 - )
57 - , ARRAY_A );
41 + $search = $wpdb->_real_escape( $string );
42 + $sql = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE '$search%'";
43 +
44 + $results = $wpdb->get_results( $sql, ARRAY_A );
45 + $return = array();
46 + if( $results ) foreach ( $results as $result ) {
47 + $name = str_replace($string .'_', '', $result['option_name'] );
48 + $explode = explode('_', $name );
58 49
59 - $return = array();
60 - if( $results ) {
61 - foreach ( $results as $result ) {
62 - $name = str_replace( $sanitized_string . '_', '', $result['option_name'] );
63 - $explode = explode('_', $name );
64 - $value = $result['option_value'];
65 - if ( ! empty( $explode[0] ) && ! empty( $explode[1] ) ) {
66 - $return[ sanitize_key( $explode[0] ) ][ sanitize_key( $explode[1] ) ] = $value;
67 - }
68 - }
50 + $value = $result['option_value'];
51 + $return[$explode[0]][$explode[1]] = $value;
69 52 }
70 53 return $return;
71 54 }
72 55 }
73 -if ( !class_exists( 'wpdeepl_WP_Improved_Settings\wpdeepl_WP_Improved_Settings' ) ) {
74 -class wpdeepl_WP_Improved_Settings {
75 - /**
76 - * Settings structure from configuration
77 - *
78 - * @var array
79 - */
80 - protected $settingsStructure = array();
81 -
82 - /**
83 - * Extended actions for maintenance tasks
84 - *
85 - * @var array
86 - */
56 +
57 +if ( !class_exists( 'WP_Improved_Settings\WP_Improved_Settings' ) ) {
58 +class WP_Improved_Settings {
59 + // loosely based on wc-dynamic-pricing-and-discounts/classes/rp-wcdpd-settings.class.php
60 + public $settingsStructure = array();
87 61 public $extendedActions = array();
88 62
89 - /**
90 - * Plugin paths cache
91 - *
92 - * @var array
93 - */
94 - protected $plugins_paths = array();
95 63
96 - /**
97 - * Settings API instance
98 - *
99 - * @var WC_Improved_Settings_API
100 - */
101 - protected $WC_Improved_Settings_API;
64 + public $plugins_paths = array();
102 65
103 - // Configuration properties
66 + public $WC_Improved_Settings_API;
67 +
104 68 public $isMainMenu = false;
105 69 public $plugin_id;
106 70 public $menu_order = 20;
107 71 public $minimum_capability = 'manage_options';
@@ -110,19 +74,86 @@
110 74 public $parent_menu = '';
111 75 public $post_type = false;
112 76
113 77
78 +/*Dashboard: 'index.php'
79 +Posts: 'edit.php'
80 +Media: 'upload.php'
81 +Pages: 'edit.php?post_type=page'
82 +Comments: 'edit-comments.php'
83 +Custom Post Types: 'edit.php?post_type=your_post_type'
84 +Appearance: 'themes.php'
85 +Plugins: 'plugins.php'
86 +Users: 'users.php'
87 +Tools: 'tools.php'
88 +Settings: 'options-general.php'
89 +Network Settings: 'settings.php'
90 +WooCommerce : 'woocommerce'
91 +*/
92 +
114 93 public function __construct() {
94 + // Register settings
95 +
115 96 add_action( 'admin_init', array( $this, 'loadSettings' ) );
116 97 add_action( 'admin_init', array( $this, 'registerSettings' ) );
117 98
118 - $this->plugins_paths = apply_filters('wpdeepl_zebench_plugins_paths', array() );
99 + $this->plugins_paths = apply_filters('zebench_plugins_paths', array() );
119 100
120 - add_action( 'admin_menu', array( $this, 'addToMenu' ), $this->menu_order );
101 + // Add link to menu
121 102
122 - if ( !class_exists( 'wpdeepl_WP_Improved_Settings\WC_Improved_Settings_API' )) {
103 + global $wp_filter;
104 + $real_order = $this->menu_order;
105 + while( isset( $wp_filter['admin_menu']->callbacks[$real_order] ) ) {
106 + $real_order++;
107 + }
108 + add_action( 'admin_menu', array( $this, 'addToMenu' ), $real_order );
109 +
110 + // Pass configuration to Javascript
111 + //add_action( 'admin_enqueue_scripts', array( $this, 'configuration_to_javascript' ), 999 );
112 +
113 + // Enqueue templates to be rendered in footer
114 + //add_action( 'admin_footer', array( $this, 'render_templates_in_footer' ) );
115 +
116 + // Settings export call
117 + if ( !empty( $_REQUEST['export_settings'] ) ) {
118 + add_action( 'wp_loaded', array( $this, 'export' ) );
119 + }
120 +
121 + // Settings import call
122 + if ( !empty( $_FILES[$this->option_page]['name']['import'] ) ) {
123 + add_action( 'wp_loaded', array( $this, 'import' ) );
124 + }
125 +
126 + // Print settings import notice
127 + if ( isset( $_REQUEST[$this->option_page .'_imported'] ) ) {
128 + add_action( 'admin_notices', array( $this, 'print_import_notice' ) );
129 + }
130 +
131 + if ( !class_exists( 'WP_Improved_Settings\WC_Improved_Settings_API' )) {
123 132 require_once( dirname( __FILE__ ) . '/wp-improved-settings-api.class.php' );
124 133 }
134 + $this->WC_Improved_Settings_API = new WC_Improved_Settings_API( $this->getPluginID(), $this->getSettingsStructure() );
135 +
136 +
137 + $key_name = $this->plugin_id . '_options_save';
138 + if ( isset( $_REQUEST['save'] ) && isset( $_REQUEST[$key_name] ) && $_REQUEST[$key_name] ) {
139 + $this->saveSettings();
140 +// echo " saving";
141 + if ( method_exists( $this, 'on_save' ) ) {
142 +// echo "on save update";
143 + $this->on_save();
144 + }
145 +
146 + add_action( 'admin_notices', array( $this, 'print_saved_notice' ) );
147 + }
148 +
149 + add_action( 'admin_notices', array( $this, 'maybe_print_notices' ) );
150 +
151 + // Migration notices
152 + //add_action( 'admin_notices', array( $this, 'maybe_display_migration_notice' ), 1 );
153 +
154 + // Delete migration notice
155 + //$this->hide_migration_notice();
125 156 }
126 157
127 158 function getPluginID() {
128 159 return $this->plugin_id;
@@ -135,17 +166,17 @@
135 166 function getMinimumCapability() {
136 167 return $this->minimum_capability;
137 168 }
138 169
139 - protected function saveSettings() {
140 - // Vérification nonce (sera revérifiée dans l'API)
141 - $nonce = isset( $_REQUEST['_wpdeepl_nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpdeepl_nonce'] ) ) : false;
142 - if ( ! wp_verify_nonce( $nonce, 'wpdeepl_save_settings' ) ) {
143 - wp_die( esc_html__( 'Security check failed', 'wpdeepl' ) );
170 + function saveSettings() {
171 + $nonce = isset( $_REQUEST['_zenonce'] ) ? $_REQUEST['_zenonce'] : false;
172 + if ( ! wp_verify_nonce( $nonce, 'zesave_settings' ) ) {
173 + $error_msg = __( 'Unable to submit this form, please refresh and try again.' );
174 + return;
144 175 }
145 176
146 - // L'API gère sa propre vérification nonce
147 177 $this->WC_Improved_Settings_API->process_admin_options();
178 + //$this->process_admin_options();
148 179 }
149 180 /*
150 181 function me() {
151 182 $this->loadSettings();
@@ -157,17 +188,16 @@
157 188 }
158 189
159 190 function print_saved_notice() {
160 191 ?>
161 - <div id="message" class="updated notice is-dismissible"><p><strong><?php esc_html_e( 'Settings saved.', 'wpdeepl' ); ?></strong></p></div>
192 + <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
162 193 <?php
163 194 }
164 195
165 196 public function loadSettings() {
166 - $this->settingsStructure = $this->getSettingsStructure();
167 - $this->WC_Improved_Settings_API = new \wpdeepl_WP_Improved_Settings\WC_Improved_Settings_API( $this->getPluginID(), $this->settingsStructure );
168 197 // load settings into $this sttings ?
169 - //wpdeepl_debug_display( $this->settingsStructure ); die( 'oka6z4e4z64ze4' );
198 + $this->settingsStructure = $this->getSettingsStructure();
199 + //plouf( $this->settingsStructure ); die( 'oka6z4e4z64ze4' );
170 200 }
171 201
172 202 /**
173 203 * Add Settings link to menu
@@ -193,27 +223,27 @@
193 223 * @access public
194 224 * @return void
195 225 */
196 226 public function settingsPage() {
227 +
228 +
197 229 // Get current tab
198 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- navigation tab, no data processing
199 - $current_tab = ( isset( $_GET['tab'] ) ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : $this->defaultSettingsTab;
230 + $current_tab = ( isset( $_GET['tab'] ) ) ? htmlspecialchars( $_GET['tab'] ) : $this->defaultSettingsTab;
200 231
232 +// plouf( $_POST );
233 +
201 234 // Print header
202 235 $this->printHeader();
203 236
204 237 $this->printFields();
205 238
206 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- extendedActions is not defined by user input.
207 239 if ( count( $this->extendedActions ) ) foreach ( $this->extendedActions as $action => $function ) {
208 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- The action name is from the class definitions, not user input.
209 240 if ( isset( $_REQUEST[$action] ) ) {
210 241 if ( function_exists( $function) ) {
211 242 $function();
212 243 }
213 244 else {
214 - /* translators: function does not exist */
215 - printf( esc_html__( 'Undefined function: %s', 'wpdeepl' ), esc_html( $function ) );
245 + printf( __( 'Attention, fonction non définie %s' ), $function );
216 246 }
217 247 }
218 248 }
219 249 $this->printFooter();
@@ -223,27 +253,9 @@
223 253 // Check if current user can manage plugin settings
224 254 if ( !is_admin() ) {
225 255 return;
226 256 }
227 -
228 - $key_value = false;
229 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- plugin_id is hardcoded.
230 - if( isset( $_REQUEST[$this->plugin_id . '_options_save'] ) ) {
231 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- plugin_id is hardcoded.
232 - $key_value = sanitize_text_field( wp_unslash( $_REQUEST[$this->plugin_id . '_options_save'] ) );
233 - }
234 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verified in saveSettings()
235 - if ( isset( $_REQUEST['save'] ) && $key_value ) {
236 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verified in saveSettings()
237 - $this->saveSettings();
238 - if ( method_exists( $this, 'on_save' ) ) {
239 - $this->on_save();
240 - }
241 257
242 - add_action( 'admin_notices', array( $this, 'print_saved_notice' ) );
243 - }
244 - add_action( 'admin_notices', array( $this, 'maybe_print_notices' ) );
245 -
246 258 // Iterate over tabs
247 259 foreach ( $this->settingsStructure as $tab_key => $tab ) {
248 260 // Register tab
249 261 register_setting(
@@ -248,12 +260,9 @@
248 260 // Register tab
249 261 register_setting(
250 262 $this->option_page .'_group_' . $tab_key,
251 263 $this->option_page,
252 - array(
253 - 'type' => 'array',
254 - 'sanitize_callback' => array( $this, 'sanitizeSettings' ),
255 - )
264 + array( $this, 'validateSettings' )
256 265 );
257 266
258 267 // Iterate over sections
259 268 foreach ( $tab['sections'] as $section_key => $section ) {
@@ -286,36 +295,15 @@
286 295 }
287 296 }
288 297 }
289 298
290 - /**
291 - * Sanitize settings before saving
292 - *
293 - * @param mixed $input The input value to sanitize.
294 - * @return mixed Sanitized value.
295 - */
296 - public function sanitizeSettings( $input ) {
297 - if ( ! is_array( $input ) ) {
298 - return sanitize_text_field( $input );
299 - }
300 -
301 - $sanitized = array();
302 - foreach ( $input as $key => $value ) {
303 - $sanitized_key = sanitize_key( $key );
304 - if ( is_array( $value ) ) {
305 - $sanitized[ $sanitized_key ] = $this->sanitizeSettings( $value );
306 - } else {
307 - $sanitized[ $sanitized_key ] = sanitize_text_field( $value );
308 - }
309 - }
310 - return $sanitized;
299 + function validateSettings() {
300 + return true;
311 301 }
312 302
313 - protected function getActiveTab() {
314 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verified in saveSettings()
303 + function getActiveTab() {
315 304 if ( isset( $_GET[ 'tab' ] ) ) {
316 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- navigation tab, sanitized, no data processing
317 - $active_tab = sanitize_key( wp_unslash( $_GET[ 'tab' ] ) );
305 + $active_tab = htmlspecialchars( $_GET[ 'tab' ] );
318 306 }
319 307 elseif ( $this->defaultSettingsTab != '' ) {
320 308 $active_tab = $this->defaultSettingsTab;
321 309 }
@@ -343,9 +331,9 @@
343 331
344 332 $active_tab = $this->getActiveTab();
345 333
346 334 $parent_menu = $this->parent_menu;
347 - $parsed_url = wp_parse_url( $parent_menu );
335 + $parsed_url = parse_url( $parent_menu );
348 336 $extended_url = '';
349 337 if ( isset( $parsed_url['query'] ) && strlen( $parsed_url['query'] ) ) {
350 338 $extended_url = '&' . $parsed_url['query'];
351 339 }
@@ -411,10 +399,9 @@
411 399 }
412 400 $active_tab = $this->getActiveTab();
413 401 $tab_data = $this->settingsStructure[$active_tab];
414 402
415 -
416 - //wpdeepl_debug_display($tab_data, " T AB DATA");
403 + //plouf($tab_data, " T AB DATA");
417 404
418 405
419 406 foreach ( $tab_data['sections'] as $section_id => $section ) {
420 407 $defaults = array(
@@ -425,9 +412,9 @@
425 412 'html' => false,
426 413 );
427 414 $section_data = wp_parse_args( $section, $defaults );
428 415
429 - //wpdeepl_debug_display( $section );
416 + //plouf( $section );
430 417 ?>
431 418 <h3 class="wc-settings-sub-title <?php echo esc_attr( $section_data['class'] ); ?>" id="<?php echo esc_attr( $section_id ); ?>"><?php echo wp_kses_post( $section_data['title'] ); ?></h3>
432 419 <?php if ( ! empty( $section_data['description'] ) ) : ?>
433 420 <p><?php echo wp_kses_post( $section_data['description'] ); ?></p>
@@ -445,9 +432,9 @@
445 432 foreach ( $section_fields as $field ) {
446 433 $fields[] = $field;
447 434 }
448 435
449 - //wpdeepl_debug_display($fields, "on a fields");
436 + //plouf($fields, "on a fields");
450 437
451 438 $this->WC_Improved_Settings_API->generate_settings_html( $fields );
452 439 ?>
453 440 </table>
@@ -452,11 +439,10 @@
452 439 ?>
453 440 </table>
454 441 <?php
455 442 if ( isset( $section['html'] ) && $section['html'] ) {
456 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML already escaped, we need to ouput raw HTML
457 - //echo ( $section['html'] );
458 - echo wp_kses_post( $section['html'] );
443 + // not escaped
444 + echo ( $section['html'] );
459 445 }
460 446 ?>
461 447
462 448 <?php if ( isset( $section['actions'] ) && $section['actions'] ) foreach ( $section['actions'] as $action ) {
@@ -469,12 +455,10 @@
469 455 }
470 456 elseif ( function_exists( $action ) ) {
471 457 $action( $param );
472 458 }
473 -
474 459 else {
475 - /* translators: name of the function not found */
476 - printf( esc_html__( 'Undefined function: %s', 'wpdeepl' ), esc_html( $action ) );
460 + printf( __( 'Attention, fonction non définie %s' ), $action );
477 461 }
478 462 }
479 463
480 464 ?>
@@ -482,12 +466,15 @@
482 466
483 467 <?php if ( count( $fields ) ) : ?>
484 468
485 469 <p class="submit">
486 - <?php wp_nonce_field('wpdeepl_save_settings', '_wpdeepl_nonce' ); ?>
470 + <?php wp_nonce_field('zesave_settings', '_zenonce' ); ?>
487 471 <?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?>
488 - <button name="save" class="button-primary" type="submit" value="<?php esc_attr_e( 'Update', 'wpdeepl' ); ?>"><?php esc_html_e( 'Update', 'wpdeepl' ); ?></button>
472 + <button name="save" class="button-primary" type="submit" value="<?php esc_attr_e( 'Update' ); ?>"><?php _e( 'Update' ); ?></button>
489 473 <?php endif; ?>
474 + <?php
475 + // wp_nonce_field( 'woocommerce-settings' );
476 + ?>
490 477 </p>
491 478 <?php endif; ?>
492 479
493 480 <?php
@@ -504,18 +491,18 @@
504 491 <p><?php echo wp_kses_post( $tab_data['description'] ); ?></p>
505 492 <?php endif;
506 493 }
507 494
508 - protected function tabFooter( $tab_id, $tab_data ) {
495 + function tabFooter( $tab_id, $tab_data ) {
509 496 if ( isset( $tab_data['footer'] ) ) {
510 497 if ( isset( $tab_data['footer']['html'] ) ) foreach ( $tab_data['footer']['html'] as $raw_html ) {
511 - // HTML déjà échappé dans la configuration
512 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
513 - echo $raw_html;
498 + // not escaped
499 + echo ( $raw_html );
514 500 }
515 501 if ( isset( $tab_data['footer']['actions'] ) ) {
516 502 echo '<hr />';
517 503 foreach ( $tab_data['footer']['actions'] as $action ) {
504 + // echo " ACTION = $action";
518 505 $param = false;
519 506
520 507 if ( is_array( $action ) ) {
521 508 list($object, $method) = $action;
@@ -526,11 +513,11 @@
526 513 elseif ( function_exists( $action ) ) {
527 514 $action( $param );
528 515 }
529 516 else {
530 - /* translators: name of the function not found */
531 - printf( esc_html__( 'Undefined function: %s', 'wpdeepl' ), esc_html( $action ) );
517 + printf( __( 'Attention, fonction non définie %s' ), $action );
532 518 }
519 + //plouf($action, "action");
533 520 }
534 521 }
535 522 }
536 523 }
@@ -552,9 +539,9 @@
552 539 }
553 540
554 541
555 542 public function showServerInfo() {
556 - echo '<h2>' . esc_html__('Server information', 'wpdeepl' ) . '</h2>';
543 + echo '<h2>' . __('Server information', '' ) . '</h2>';
557 544
558 545 if( function_exists('ini_get_all' ) ) {
559 546
560 547 $ini_values = ini_get_all();
@@ -575,9 +562,9 @@
575 562 $timeout = round($timeout /1000,1);
576 563 }
577 564
578 565 $informations = array(
579 - 'Server time' => gmdate('d/m/Y H:i:s'),
566 + 'Server time' => date('d/m/Y H:i:s'),
580 567 'Real path' => get_home_path(),
581 568 'PHP version' => phpversion(),
582 569 'Timeout' => $timeout .' s',
583 570 'Memory usage' => $memory_usage,
@@ -593,9 +580,9 @@
593 580 }
594 581 }
595 582
596 583 foreach ($informations as $label => $value) {
597 - printf( "<p><strong>%s</strong>&nbsp;%s</p>", esc_html( $label ), esc_html( $value ) );
584 + printf( "<p><strong>%s</strong>&nbsp;%s</p>", $label, $value );
598 585 }
599 586
600 587
601 588 }
@@ -606,12 +593,20 @@
606 593
607 594 if ( !is_admin() ) {
608 595 return false;
609 596 }
597 + /*$current_plugin_page = $_REQUEST['page'];
598 +
599 + plouf($this->plugin_paths);
600 + if ( !isset( $this->plugin_paths[$current_plugin_page] ) ) {
601 + echo "no path";
602 + return false;
603 + }
604 + $path = $this->plugin_paths[$current_plugin_page];*/
610 605 $path = $this->log_folder;
611 606
612 607 $logs = glob( trailingslashit( $path ) . '*.log');
613 - //wpdeepl_debug_display($logs, "LOGS");
608 + //plouf($logs, "LOGS");
614 609 if ($logs) foreach ($logs as $log_file) {
615 610 $file_name = basename( $log_file );
616 611 $contents = file_get_contents( $log_file );
617 612 if (preg_match('#(\d+)-(\d+)-(\w+)\.log#', $file_name, $match)) {
@@ -617,12 +612,11 @@
617 612 if (preg_match('#(\d+)-(\d+)-(\w+)\.log#', $file_name, $match)) {
618 613 $date = $match[2] . '/' . $match[1];
619 614 echo '<h3>';
620 615 printf(
621 - /* translators: 1. file name 2. month */
622 - esc_html__("File '%1\$s' for %2\$s", 'wpdeepl' ),
623 - esc_html( $match[3] ),
624 - esc_html( $date )
616 + __("Fichier '%s' pour %s" ),
617 + $match[3],
618 + $date
625 619 );
626 620 echo '</h3>';
627 621 $lines = explode( "\n", $contents);
628 622 foreach ( $lines as $line ) {
@@ -631,12 +625,12 @@
631 625 $line = preg_replace( '#"body":"<!DOCTYPE.*?","headers#ism', '"body":"PROBLEME COTE INSURED (disponible dans les logs complets)", "headers', $line);
632 626 if ( stripos( $line, '<!DOCTYPE html>' ) ) {
633 627 continue;
634 628 }
635 - // Contenu log potentiellement dangereux - échapper
636 - echo "<br /><br />" . esc_html( $line ) . "\n";
629 + // not escaped
630 + echo "<br /><br />" . ( $line ) . "\n";
637 631 }
638 - //wpdeepl_debug_display($contents);
632 + //plouf($contents);
639 633
640 634 }
641 635 }
642 636
@@ -641,5 +635,5 @@
641 635 }
642 636
643 637 }
644 638 }
645 -}
639 +}