GC_Ajax_Upgrader_Skin::error()
最后更新于:2021-11-26 09:12:36
GC_Ajax_Upgrader_Skin::error( string|GC_Error$errors, mixed$args)Stores an error message about the upgrade.
参数
- $errors
-
(string|GC_Error) (Required) Errors.
- $args
-
(mixed) (Optional) text replacements.
源文件
文件: gc-admin/includes/class-gc-ajax-upgrader-skin.php
public function error( $errors, ...$args ) {
if ( is_string( $errors ) ) {
$string = $errors;
if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
$string = $this->upgrader->strings[ $string ];
}
if ( false !== strpos( $string, '%' ) ) {
if ( ! empty( $args ) ) {
$string = vsprintf( $string, $args );
}
}
// Count existing errors to generate a unique error code.
$errors_count = count( $this->errors->get_error_codes() );
$this->errors->add( 'unknown_upgrade_error_' . ( $errors_count + 1 ), $string );
} elseif ( is_gc_error( $errors ) ) {
foreach ( $errors->get_error_codes() as $error_code ) {
$this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) );
}
}
parent::error( $errors, ...$args );
}