| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpDeveloperModuleMywpError' ) ) : |
| 12 |
|
| 13 |
final class MywpDeveloperModuleMywpError extends MywpDeveloperAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'mywp_error'; |
| 16 |
|
| 17 |
static protected $priority = 10; |
| 18 |
|
| 19 |
public static function mywp_debug_renders( $debug_renders ) { |
| 20 |
|
| 21 |
$debug_renders[ self::$id ] = array( |
| 22 |
'debug_type' => 'mywp', |
| 23 |
'title' => sprintf( '%s Error' , MYWP_NAME ), |
| 24 |
); |
| 25 |
|
| 26 |
return $debug_renders; |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
private static function get_errors() { |
| 31 |
|
| 32 |
$errors = MywpApi::get_errors(); |
| 33 |
|
| 34 |
return $errors; |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
protected static function mywp_developer_debug() { |
| 39 |
|
| 40 |
$errors = self::get_errors(); |
| 41 |
|
| 42 |
echo 'Mywp error = '; |
| 43 |
|
| 44 |
if( empty( $errors ) ) { |
| 45 |
|
| 46 |
return false; |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
foreach( $errors as $key => $val ) { |
| 51 |
|
| 52 |
echo $val . "\n"; |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
protected static function mywp_debug_render() { |
| 59 |
|
| 60 |
$errors = self::get_errors(); |
| 61 |
|
| 62 |
if( empty( $errors ) ) { |
| 63 |
|
| 64 |
printf( '<p>%s</p>' , __( 'No errors.' , 'my-wp' ) ); |
| 65 |
|
| 66 |
} else { |
| 67 |
|
| 68 |
echo '<ul>'; |
| 69 |
|
| 70 |
foreach( $errors as $error ) { |
| 71 |
|
| 72 |
printf( '<li>%s</li>' , $error ); |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
echo '</ul>'; |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
MywpDeveloperModuleMywpError::init(); |
| 85 |
|
| 86 |
endif; |
| 87 |
|