Changeset 3667
- Timestamp:
- 03/30/2006 11:18:14 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r3665 r3667 340 340 } 341 341 342 class WP_Error { 343 var $errors = array(); 344 345 function WP_Error($code = '', $message = '') { 346 if ( ! empty($code) ) 347 $this->errors[$code][] = $message; 348 } 349 350 function get_error_codes() { 351 if ( empty($this->errors) ) 352 return array(); 353 354 return array_keys($this->errors); 355 } 356 357 function get_error_code() { 358 $codes = $this->get_error_codes(); 359 360 if ( empty($codes) ) 361 return ''; 362 363 return $codes[0]; 364 } 365 366 function get_error_messages($code) { 367 if ( isset($this->errors[$code]) ) 368 return $this->errors[$code]; 369 else 370 return array(); 371 } 372 373 function get_error_message($code = '') { 374 if ( empty($code) ) 375 $code = $this->get_error_code(); 376 $messages = $this->get_error_messages($code); 377 if ( empty($messages) ) 378 return ''; 379 return $messages[0]; 380 } 381 382 function add($code, $message) { 383 $this->errors[$code][] = $message; 384 } 385 } 386 387 function is_wp_error($thing) { 388 if ( is_object($thing) && is_a($thing, 'WP_Error') ) 389 return true; 390 return false; 391 } 392 342 393 ?>
Note: See TracChangeset
for help on using the changeset viewer.