1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44:
<?php
namespace VSP;
if ( ! defined( 'ABSPATH' ) ) {
die;
}
use WP_Error;
/**
* Class Error
*
* @package VSP
* @author Varun Sridharan <varunsridharan23@gmail.com>
*/
class Error extends WP_Error {
/**
* Checks And Returns If This class has errors stored.
*
* @return bool
*/
public function has() {
return ( ! empty( $this->errors ) );
}
/**
* Add an error or append additional message to an existing error.
*
* @param string|int $code Error code.
* @param string $msg Error message.
* @param mixed $arg Optional. Error data.
*
* @return $this
*/
public function add( $code, $msg, $arg = '' ) {
$msg = ( ! is_array( $msg ) ) ? array( $msg ) : $msg;
foreach ( $msg as $m ) {
parent::add( $code, $m, $arg );
}
return $this;
}
}