PluginProbe
Booking Calendar / 11.8
Booking Calendar v11.8
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 10.11 10.11.2 10.11.3 All 202 releases
booking / core / admin / wpbc-settings-functions.php

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

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