PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.16
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.16
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / updates / update-1.9.0.php

update-1.9.0.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.16, at includes/updates/update-1.9.0.php

42 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Update to 1.9.0.
4 *
5 * Clean up bloated woocommerce-pos log files caused by i18n translation
6 * download spam (thundering herd race condition on missing locales).
7 *
8 * @author Paul Kilmurray <paul@kilbot.com>
9 *
10 * @see http://wcpos.com
11 * @package WCPOS\WooCommercePOS
12 */
13
14 namespace WCPOS\WooCommercePOS;
15
16 $wcpos_log_dir = trailingslashit( wp_upload_dir()['basedir'] ) . 'wc-logs/'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- update script file scope.
17
18 if ( ! is_dir( $wcpos_log_dir ) ) {
19 return;
20 }
21
22 $wcpos_log_files = glob( $wcpos_log_dir . 'woocommerce-pos-*.log' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- update script file scope.
23
24 if ( empty( $wcpos_log_files ) ) {
25 return;
26 }
27
28 $wcpos_deleted_count = 0; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- update script file scope.
29 foreach ( $wcpos_log_files as $wcpos_log_file ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- update script file scope.
30 if ( wp_delete_file( $wcpos_log_file ) || ! file_exists( $wcpos_log_file ) ) {
31 ++$wcpos_deleted_count;
32 }
33 }
34
35 if ( \function_exists( 'wc_get_logger' ) && $wcpos_deleted_count > 0 ) {
36 $wcpos_update_logger = wc_get_logger(); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- update script file scope.
37 $wcpos_update_logger->info(
38 sprintf( 'WCPOS 1.9.0 migration: cleaned up %d POS log file(s) from i18n spam.', $wcpos_deleted_count ),
39 array( 'source' => 'woocommerce-pos' )
40 );
41 }
42