PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / core / admin / wpbc-settings-functions.php

wpbc-settings-functions.php in Booking Calendar 11.9, at core/admin/wpbc-settings-functions.php

501 lines 20.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @package Booking Calendar
4 * @category Support functions for Settings page
5 * @author wpdevelop
6 *
7 * @web-site https://wpbookingcalendar.com/
8 * @email [email protected]
9 *
10 * @modified 2022-02-08
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 /**
17 * Check if show "Settings General" page OR "System Info"
18 *
19 * @return bool
20 */
21 function wpbc_is_show_general_setting_options(){ // FixIn: 8.9.4.11.
22
23 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
24 if ( ( isset( $_GET['system_info'] ) ) && ( $_GET['system_info'] == 'show' ) ) {
25 $nonce_gen_time = check_admin_referer( 'wpbc_settings_url_nonce' ); // FixIn: 9.2.2.1.
26 return false;
27 }
28 return true;
29 }
30
31
32
33 /**
34 * Show system info at Booking > Settings General page
35 */
36 function wpbc_settings__system_info( $page_name ){
37
38 if ( 'general_settings' != $page_name ) { return false; }
39
40 if ( wpbc_is_this_demo() ) { return false; }
41
42 if ( wpbc_is_show_general_setting_options() ) { return false; }
43
44 //////////////////////////////////////////////////////////////////////////////
45
46 echo '<div class="clear" style="height:30px;"></div>';
47
48 echo '<span class="metabox-holder">';
49
50 wpbc_settings__system_info__reset_booking_forms();
51
52 wpbc_settings__system_info__generate_php_from_pot();
53
54 wpbc_settings__system_info__show_system_info();
55
56 wpbc_settings__system_info__restore_dismissed_windows();
57
58 wpbc_settings__system_info__show_translation_status();
59
60 wpbc_settings__system_info__update_translations();
61
62 wpbc_settings__system_info__debug_and_tests();
63
64 echo '</span>';
65 }
66 add_action( 'wpbc_hook_settings_page_footer', 'wpbc_settings__system_info' ,10, 1);
67
68
69 /**
70 * System info section - Reset Custom Booking forms
71 *
72 * Link: http://server.com/wp-admin/admin.php?page=wpbc-settings&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) .' &reset=custom_forms#wpbc_general_settings_system_info_metabox
73 *
74 */
75 function wpbc_settings__system_info__reset_booking_forms() {
76
77 if ( ! current_user_can( 'activate_plugins' ) ) {
78 return;
79 }
80 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
81 if ( ( isset( $_GET['reset'] ) ) && ( 'custom_forms' == $_GET['reset'] ) ) { // FixIn: 8.1.3.21.
82
83 wpbc_open_meta_box_section( 'wpbc_general_settings_system_info', 'System Info' );
84
85 global $wpdb;
86 if ( function_exists( 'wpbc_is_table_exists' ) && wpbc_is_table_exists( 'booking_form_structures' ) ) {
87 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
88 $wpdb->query( "DELETE FROM {$wpdb->prefix}booking_form_structures WHERE form_slug <> 'standard'" );
89 }
90
91 wpbc_show_message_in_settings( '<strong>Custom forms</strong> has been reseted!', 'info' );
92
93 wpbc_close_meta_box_section();
94 }
95 }
96
97
98
99 /**
100 * System info section - Generate new translation PHP files from POT file
101 *
102 * // Link: http://server.com/wp-admin/admin.php?page=wpbc-settings&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) .' &pot=1#wpbc_general_settings_system_info_metabox
103 *
104 */
105 function wpbc_settings__system_info__generate_php_from_pot() {
106
107 return;
108
109 if ( ! current_user_can( 'activate_plugins' ) ) {
110 return;
111 }
112
113 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
114 if ( ! empty( $_GET['pot'] ) ) { // FixIn: 8.1.3.21.
115
116 wpbc_open_meta_box_section( 'wpbc_general_settings_system_info', 'System Info' );
117
118 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
119 if ( '1' == $_GET['pot'] ) {
120 wpbc_pot_to_php();
121 }
122
123 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
124 if ( 'erase__wpbc_all_translations' == $_GET['pot'] ) {
125 wpbc_delete_translation_php_files();
126 }
127
128 wpbc_close_meta_box_section();
129 }
130 }
131
132
133 /**
134 * System info section - Update translations
135 *
136 * // Link: http://server.com/wp-admin/admin.php?page=wpbc-settings&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) .' &update_translations=1#wpbc_general_settings_system_info_metabox
137 *
138 */
139 function wpbc_settings__system_info__update_translations() {
140
141 if ( ! current_user_can( 'activate_plugins' ) ) {
142 return;
143 }
144
145 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
146 if ( ( isset( $_GET['update_translations'] ) ) && ( '1' == $_GET['update_translations'] ) ) { // FixIn: 8.1.3.21.
147
148 wpbc_open_meta_box_section( 'wpbc_general_settings_system_info', 'System Info' );
149
150 wpbc_update_translations__from_wp();
151
152 wpbc_close_meta_box_section();
153 }
154 }
155
156
157 /**
158 * System info section - Show translation status
159 *
160 * // Link: http://server.com/wp-admin/admin.php?page=wpbc-settings&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) .' &show_translation_status=1#wpbc_general_settings_system_info_metabox
161 *
162 */
163 function wpbc_settings__system_info__show_translation_status() {
164
165 if ( ! current_user_can( 'activate_plugins' ) ) {
166 return;
167 }
168
169 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
170 if ( isset( $_GET['show_translation_status'] ) ) { // FixIn: 8.1.3.21.
171
172 wpbc_open_meta_box_section( 'wpbc_general_settings_system_info', 'System Info' );
173 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
174 if ( '1' == $_GET['show_translation_status'] ){
175 wpbc_show_translation_status_compare_wpbc_wp();
176 }
177 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
178 if ( '2' == $_GET['show_translation_status'] ){
179 wpbc_show_translation_status_from_wp();
180 }
181 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
182 if ( '3' == $_GET['show_translation_status'] ){
183 wpbc_show_translation_status_from_wpbc();
184 }
185
186 wpbc_close_meta_box_section();
187 }
188 }
189
190
191 /**
192 * System info section - Showing information about system - php, server, active plugins, etc...
193 *
194 * Link: http://server.com/wp-admin/admin.php?page=wpbc-settings&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) .' #wpbc_general_settings_system_info_metabox
195 */
196 function wpbc_settings__system_info__show_system_info(){
197
198 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
199 if ( ( isset( $_GET['booking_system_info'] ) ) && ( $_GET['booking_system_info'] == 'show' ) ) { ?>
200
201 <?php wpbc_open_meta_box_section( 'wpbc_general_settings_system_info', 'System Info' ); ?>
202
203 <?php wpbc_system_info(); ?>
204
205 <?php wpbc_close_meta_box_section();
206 }
207 }
208
209
210 /**
211 * System info section - Restore Dismissed Windows
212 *
213 * // Link: http://server.com/wp-admin/admin.php?page=wpbc-settings&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) .' &restore_dismissed=On#wpbc_general_settings_restore_dismissed_metabox
214 *
215 */
216 function wpbc_settings__system_info__restore_dismissed_windows(){
217
218 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
219 if ( ( isset( $_GET['restore_dismissed'] ) ) && ( $_GET['restore_dismissed'] == 'On' ) ) { // FixIn: 8.1.3.10.
220
221 update_bk_option( 'booking_is_show_powered_by_notice', 'On' );
222 update_bk_option( 'booking_wpdev_copyright_adminpanel', 'On' );
223 update_bk_option( 'booking_menu_go_pro', 'show' );
224
225 global $wpdb;
226
227 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
228 if ( false === $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%booking_win_%'" ) ) { // Delete all users booking windows states.
229 debuge_error( 'Error during deleting user meta at DB', __FILE__, __LINE__ );
230 die();
231 } else {
232
233 wpbc_open_meta_box_section( 'wpbc_general_settings_restore_dismissed', 'Info' );
234
235 ?><h2>All dismissed windows has been restored.</h2><?php
236
237 echo '<div class="clear"></div><hr/><center><a class="button button" href="' . esc_url( wpbc_get_settings_url() ) . '">Reload Page</a></center>';
238
239 wpbc_close_meta_box_section();
240 }
241 }
242 }
243
244
245
246 /**
247 * Show System Info (status) at Booking > Settings General page
248 *
249 */
250 function wpbc_system_info() {
251
252 if ( current_user_can( 'activate_plugins' ) ) { // Only for Administrator or Super admin. More here: https://codex.wordpress.org/Roles_and_Capabilities .
253
254 global $wpdb, $wp_version;
255
256 $all_plugins = get_plugins();
257 $active_plugins = get_option( 'active_plugins' );
258 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
259 $mysql_info = $wpdb->get_results( "SHOW VARIABLES LIKE 'sql_mode'" );
260
261 if ( is_array( $mysql_info ) ) $sql_mode = $mysql_info[0]->Value;
262 if ( empty( $sql_mode ) ) $sql_mode = 'Not set';
263
264 // FixIn: 8.4.7.24.
265 $allow_url_fopen = ( ini_get( 'allow_url_fopen' ) ) ? 'On' : 'Off';
266 $upload_max_filesize = ( ini_get( 'upload_max_filesize' ) ) ? ini_get( 'upload_max_filesize' ) : 'N/A';
267 $post_max_size = ( ini_get( 'post_max_size' ) ) ? ini_get( 'post_max_size' ) : 'N/A';
268 $max_execution_time = ( ini_get( 'max_execution_time' ) ) ? ini_get( 'max_execution_time' ) : 'N/A';
269 $memory_limit = ( ini_get( 'memory_limit' ) ) ? ini_get( 'memory_limit' ) : 'N/A';
270 $memory_usage = ( function_exists( 'memory_get_usage' ) ) ? round( memory_get_usage() / 1024 / 1024, 2 ) . ' Mb' : 'N/A';
271 $exif_read_data = ( is_callable( 'exif_read_data' ) ) ? 'Yes' . " ( V" . substr( phpversion( 'exif' ), 0, 4 ) . ")" : 'No';
272 $iptcparse = ( is_callable( 'iptcparse' ) ) ? 'Yes' : 'No';
273 $xml_parser_create = ( is_callable( 'xml_parser_create' ) ) ? 'Yes' : 'No';
274 $theme = wp_get_theme();
275
276 if ( function_exists( 'is_multisite' ) ) {
277 if ( is_multisite() ) $multisite = 'Yes';
278 else $multisite = 'No';
279 } else { $multisite = 'N/A';
280 }
281
282 $system_info = array(
283 'system_info' => '',
284 'php_info' => '',
285 'active_plugins' => array(), // FixIn: 8.4.4.1.
286 'inactive_plugins' => array() // FixIn: 8.4.4.1.
287 );
288
289 $ver_small_name = wpbc_get_plugin_version_type();
290 if ( class_exists( 'wpdev_bk_multiuser' ) ) $ver_small_name = 'multiuser';
291
292 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
293 $mysql_version = $wpdb->get_var( 'SELECT VERSION() AS version' );
294
295 $system_info['system_info'] = array(
296 'Plugin Update' => ( defined( 'WPDEV_BK_VERSION' ) ) ? WPDEV_BK_VERSION : 'N/A',
297 'Plugin Version' => ucwords( $ver_small_name ),
298 'Plugin Update Date' => gmdate( "Y-m-d", filemtime( WPBC_FILE ) ),
299
300 'Server Default Timezone' => date_default_timezone_get(),
301 'WordPress Timezone' => wp_timezone()->getName(),
302
303 'WP Version' => $wp_version,
304 'WP DEBUG' => ( ( defined('WP_DEBUG') ) && ( WP_DEBUG ) ) ? 'On' : 'Off',
305 'WP DB Version' => get_option( 'db_version' ),
306 'Operating System' => PHP_OS,
307 'Server' => isset( $_SERVER["SERVER_SOFTWARE"] ) ? sanitize_text_field( wp_unslash( $_SERVER["SERVER_SOFTWARE"] ) ) : 'N/A',
308 'PHP Version' => PHP_VERSION,
309 'MYSQL Version' => $mysql_version,
310 'SQL Mode' => $sql_mode,
311 'Memory usage' => $memory_usage,
312 'Site URL' => get_option( 'siteurl' ),
313 'Home URL' => home_url(),
314 'SERVER[HTTP_HOST]' => isset( $_SERVER["HTTP_HOST"] ) ? sanitize_text_field( wp_unslash( $_SERVER["HTTP_HOST"] ) ) : 'N/A',
315 'SERVER[SERVER_NAME]' => isset( $_SERVER["SERVER_NAME"] ) ? sanitize_text_field( wp_unslash( $_SERVER["SERVER_NAME"] ) ) : 'N/A',
316 'Multisite' => $multisite,
317 'Active Theme' => $theme['Name'] . ' ' . $theme['Version']
318 );
319
320 $system_info['php_info'] = array(
321 'PHP Version' => PHP_VERSION,
322 'PHP Memory Limit' => '<strong>' . $memory_limit . '</strong>',
323 'PHP Max Script Execute Time' => '<strong>' . $max_execution_time . '</strong>',
324
325 'PHP Max Post Size' => '<strong>' . $post_max_size . '</strong>',
326 'PHP MAX Input Vars' => '<strong>' . ( ( ini_get( 'max_input_vars' ) ) ? ini_get( 'max_input_vars' ) : 'N/A' ) . '</strong>', //How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately).
327
328 'PHP Max Upload Size' => $upload_max_filesize,
329 'PHP Allow URL fopen' => $allow_url_fopen,
330 'PHP Exif support' => $exif_read_data,
331 'PHP IPTC support' => $iptcparse,
332 'PHP XML support' => $xml_parser_create
333 );
334
335 $system_info['php_info']['PHP cURL'] = ( function_exists('curl_init') ) ? 'On' : 'Off';
336 $system_info['php_info']['Max Nesting Level'] = ( ( ini_get( 'max_input_nesting_level' ) ) ? ini_get( 'max_input_nesting_level' ) : 'N/A' );
337 $system_info['php_info']['Max Time 4 script'] = ( ( ini_get( 'max_input_time' ) ) ? ini_get( 'max_input_time' ) : 'N/A' ); //Maximum amount of time each script may spend parsing request data
338 $system_info['php_info']['Log'] = ( ( ini_get( 'error_log' ) ) ? ini_get( 'error_log' ) : 'N/A' );
339
340 if ( ini_get( "suhosin.get.max_value_length" ) ) {
341
342 $system_info['suhosin_info'] = array();
343 $system_info['suhosin_info']['POST max_array_index_length'] = ( ( ini_get( 'suhosin.post.max_array_index_length' ) ) ? ini_get( 'suhosin.post.max_array_index_length' ) : 'N/A' );
344 $system_info['suhosin_info']['REQUEST max_array_index_length'] = ( ( ini_get( 'suhosin.request.max_array_index_length' ) ) ? ini_get( 'suhosin.request.max_array_index_length' ) : 'N/A' );
345
346 $system_info['suhosin_info']['POST max_totalname_length'] = ( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : 'N/A' );
347 $system_info['suhosin_info']['REQUEST max_totalname_length'] = ( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : 'N/A' );
348
349 $system_info['suhosin_info']['POST max_vars'] = ( ( ini_get( 'suhosin.post.max_vars' ) ) ? ini_get( 'suhosin.post.max_vars' ) : 'N/A' );
350 $system_info['suhosin_info']['REQUEST max_vars'] = ( ( ini_get( 'suhosin.request.max_vars' ) ) ? ini_get( 'suhosin.request.max_vars' ) : 'N/A' );
351
352 $system_info['suhosin_info']['POST max_value_length'] = ( ( ini_get( 'suhosin.post.max_value_length' ) ) ? ini_get( 'suhosin.post.max_value_length' ) : 'N/A' );
353 $system_info['suhosin_info']['REQUEST max_value_length'] = ( ( ini_get( 'suhosin.request.max_value_length' ) ) ? ini_get( 'suhosin.request.max_value_length' ) : 'N/A' );
354
355 $system_info['suhosin_info']['POST max_name_length'] = ( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : 'N/A' );
356 $system_info['suhosin_info']['REQUEST max_varname_length'] = ( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : 'N/A' );
357
358 $system_info['suhosin_info']['POST max_array_depth'] = ( ( ini_get( 'suhosin.post.max_array_depth' ) ) ? ini_get( 'suhosin.post.max_array_depth' ) : 'N/A' );
359 $system_info['suhosin_info']['REQUEST max_array_depth'] = ( ( ini_get( 'suhosin.request.max_array_depth' ) ) ? ini_get( 'suhosin.request.max_array_depth' ) : 'N/A' );
360 }
361
362
363 if ( function_exists('gd_info') ) {
364 $gd_info = gd_info();
365 if ( isset( $gd_info['GD Version'] ) )
366 $gd_info = $gd_info['GD Version'];
367 else
368 $gd_info = wp_json_encode( $gd_info );
369 } else {
370 $gd_info = 'Off';
371 }
372 $system_info['php_info']['PHP GD'] = $gd_info;
373
374 // More here https://docs.woocommerce.com/document/problems-with-large-amounts-of-data-not-saving-variations-rates-etc/
375
376
377 foreach ( $all_plugins as $path => $plugin ) {
378 if ( ( ! empty( $plugin['Name'] ) ) && ( ! empty( $plugin['Version'] ) ) ) {
379 if ( is_plugin_active( $path ) ) {
380 $system_info['active_plugins'][ $plugin['Name'] ] = $plugin['Version'];
381 } else {
382 $system_info['inactive_plugins'][ $plugin['Name'] ] = $plugin['Version'];
383 }
384 }
385 }
386
387 // Showing
388 foreach ( $system_info as $section_name => $section_values ) {
389 ?>
390 <span class="wpdevelop">
391 <table class="table table-striped table-bordered">
392 <thead><tr><th colspan="2" style="border-bottom: 1px solid #eeeeee;padding: 10px;"><?php echo esc_html( strtoupper( $section_name ) ); ?></th></tr></thead>
393 <tbody>
394 <?php
395 if ( !empty( $section_values ) ) {
396 foreach ( $section_values as $key => $value ) {
397 ?>
398 <tr>
399 <td scope="row" style="width:18em;padding:4px 8px;"><?php echo esc_html( $key ); ?></td>
400 <td scope="row" style="padding:4px 8px;"><?php echo esc_html( $value ); ?></td>
401 </tr>
402 <?php
403 }
404 }
405 ?>
406 </tbody>
407 </table>
408 </span>
409 <div class="clear"></div>
410 <?php
411 }
412 ?>
413 <hr>
414 <div style="color:#777;">
415 <h4 style="font-size:1.1em;">Commonly required configuration vars in php.ini file:</h4>
416 <h4>General section:</h4>
417 <pre><code>memory_limit = 256M
418 max_execution_time = 120
419 post_max_size = 8M
420 upload_max_filesize = 8M
421 max_input_vars = 20480
422 post_max_size = 64M</code></pre>
423 <h4>Suhosin section (if installed):</h4>
424 <pre><code>suhosin.post.max_array_index_length = 1024
425 suhosin.post.max_totalname_length = 65535
426 suhosin.post.max_vars = 2048
427 suhosin.post.max_value_length = 1000000
428 suhosin.post.max_name_length = 256
429 suhosin.post.max_array_depth = 1000
430 suhosin.request.max_array_index_length = 1024
431 suhosin.request.max_totalname_length = 65535
432 suhosin.request.max_vars = 2048
433 suhosin.request.max_value_length = 1000000
434 suhosin.request.max_varname_length = 256
435 suhosin.request.max_array_depth = 1000</code></pre>
436 </div>
437 <?php
438 // phpinfo();
439 }
440 }
441
442
443
444 /**
445 * It's for my tests and debugs
446 */
447 function wpbc_settings__system_info__debug_and_tests() {
448
449 if ( 0 ) {
450
451 wpbc_open_meta_box_section( 'wpbc_general_settings_test_debug', 'Test & Debug' );
452
453 //debuge( get_site_transient( 'update_plugins' ) );
454
455 wpbc_close_meta_box_section();
456 }
457
458
459 if (0){
460 /**
461 * Install Plugin.
462 */
463 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
464 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
465 $skin = new WP_Ajax_Upgrader_Skin();
466 $upgrader = new Plugin_Upgrader( $skin );
467 $package = 'https://wpbookingcalendar.com/download/some-plugin.zip';
468 $result = $upgrader->install( $package ); //$package - The full local path or URI of the package
469 }
470
471 if (0) {
472
473 $plugin_slug = 'booking';
474 global $wp_filesystem;
475
476 $plugin_translations = wp_get_installed_translations( 'plugins' );
477
478 $language_updates = wp_get_translation_updates();
479
480 debuge( '$language_updates, $plugin_translations[ $plugin_slug ]', $language_updates, $plugin_translations[ $plugin_slug ] );
481
482 if ( 0 ) {
483 // Remove language files, silently.
484 if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
485 $translations = $plugin_translations[ $plugin_slug ];
486
487 foreach ( $translations as $translation => $data ) {
488 $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
489 $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
490
491 $json_translation_files = glob( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '-*.json' );
492 if ( $json_translation_files ) {
493 array_map( array( $wp_filesystem, 'delete' ), $json_translation_files );
494 }
495 }
496 }
497 }
498 }
499
500 }
501