Merged in feature/280-dev-dev01 (pull request #21)

auto-patch  280-dev-dev01-2024-01-19T16_41_58

* auto-patch  280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
Tony Volpe
2024-01-19 16:44:43 +00:00
parent 2699b5437a
commit be83910651
2125 changed files with 179300 additions and 35639 deletions

View File

@@ -15,6 +15,12 @@ defined( 'ABSPATH' ) || exit;
* WC_Admin_Status Class.
*/
class WC_Admin_Status {
/**
* An instance of the DB log handler list table.
*
* @var WC_Admin_Log_Table_List
*/
private static $db_log_list_table;
/**
* Handles output of the reports page in admin.
@@ -133,15 +139,17 @@ class WC_Admin_Status {
* Show the log page contents for db log handler.
*/
public static function status_logs_db() {
if ( ! empty( $_REQUEST['flush-logs'] ) ) { // WPCS: input var ok, CSRF ok.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce handled in flush_db_logs().
if ( isset( $_REQUEST['flush-logs'] ) ) {
self::flush_db_logs();
}
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['log'] ) ) { // WPCS: input var ok, CSRF ok.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce handled in log_table_bulk_actions().
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['log'] ) ) {
self::log_table_bulk_actions();
}
$log_table_list = new WC_Admin_Log_Table_List();
$log_table_list = self::get_db_log_list_table();
$log_table_list->prepare_items();
include_once __DIR__ . '/views/html-admin-page-status-logs-db.php';
@@ -306,20 +314,38 @@ class WC_Admin_Status {
exit();
}
/**
* Return a stored instance of the DB log list table class.
*
* @return WC_Admin_Log_Table_List
*/
public static function get_db_log_list_table() {
if ( is_null( self::$db_log_list_table ) ) {
self::$db_log_list_table = new WC_Admin_Log_Table_List();
}
return self::$db_log_list_table;
}
/**
* Clear DB log table.
*
* @since 3.0.0
*/
private static function flush_db_logs() {
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-status-logs' ) ) { // WPCS: input var ok, sanitization ok.
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
check_admin_referer( 'bulk-logs' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_die( esc_html__( 'You do not have permission to manage log entries.', 'woocommerce' ) );
}
WC_Log_Handler_DB::flush();
wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );
exit();
$sendback = wp_sanitize_redirect( admin_url( 'admin.php?page=wc-status&tab=logs' ) );
wp_safe_redirect( $sendback );
exit;
}
/**
@@ -328,15 +354,22 @@ class WC_Admin_Status {
* @since 3.0.0
*/
private static function log_table_bulk_actions() {
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-status-logs' ) ) { // WPCS: input var ok, sanitization ok.
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
check_admin_referer( 'bulk-logs' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_die( esc_html__( 'You do not have permission to manage log entries.', 'woocommerce' ) );
}
$log_ids = array_map( 'absint', (array) isset( $_REQUEST['log'] ) ? wp_unslash( $_REQUEST['log'] ) : array() ); // WPCS: input var ok, sanitization ok.
$log_ids = (array) filter_input( INPUT_GET, 'log', FILTER_CALLBACK, array( 'options' => 'absint' ) );
if ( ( isset( $_REQUEST['action'] ) && 'delete' === $_REQUEST['action'] ) || ( isset( $_REQUEST['action2'] ) && 'delete' === $_REQUEST['action2'] ) ) { // WPCS: input var ok, sanitization ok.
$action = self::get_db_log_list_table()->current_action();
if ( 'delete' === $action ) {
WC_Log_Handler_DB::delete( $log_ids );
wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );
$sendback = remove_query_arg( array( 'action', 'action2', 'log', '_wpnonce', '_wp_http_referer' ), wp_get_referer() );
wp_safe_redirect( $sendback );
exit();
}
}