PluginProbe ʕ •ᴥ•ʔ
AI Copilot – Content Generator / 1.2.0
AI Copilot – Content Generator v1.2.0
1.5.4 1.4.21 1.4.18 1.4.19 1.4.20 trunk 1.0.4 1.1.0 1.2.0 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.17 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.9
ai-copilot-content-generator / classes / errors.php
ai-copilot-content-generator / classes Last commit date
tables 1 year ago assets.php 1 year ago baseObject.php 1 year ago cache.php 1 year ago controller.php 1 year ago date.php 1 year ago db.php 1 year ago dispatcher.php 1 year ago errors.php 1 year ago field.php 1 year ago fieldAdapter.php 1 year ago frame.php 1 year ago helper.php 1 year ago html.php 1 year ago installer.php 1 year ago installerDbUpdater.php 1 year ago modInstaller.php 1 year ago model.php 1 year ago module.php 1 year ago req.php 1 year ago response.php 1 year ago table.php 1 year ago uri.php 1 year ago user.php 1 year ago utils.php 1 year ago validator.php 1 year ago view.php 1 year ago
errors.php
101 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 class WaicErrors {
6 const FATAL = 'fatal';
7 const MOD_INSTALL = 'mod_install';
8 private static $errors = array();
9 private static $haveErrors = false;
10
11 public static $current = array();
12 public static $displayed = false;
13
14 public static function push( $error, $type = 'common' ) {
15 if (!isset(self::$errors[$type])) {
16 self::$errors[$type] = array();
17 }
18 if (is_array($error)) {
19 self::$errors[$type] = array_merge(self::$errors[$type], $error);
20 } else {
21 self::$errors[$type][] = $error;
22 }
23 self::$haveErrors = true;
24
25 if ('session' == $type) {
26 self::setSession(self::$errors[$type]);
27 }
28 }
29 public static function setSession( $error ) {
30 $sesErrors = self::getSession();
31 if (empty($sesErrors)) {
32 $sesErrors = array();
33 }
34 if (is_array($error)) {
35 $sesErrors = array_merge($sesErrors, $error);
36 } else {
37 $sesErrors[] = $error;
38 }
39 WaicReq::setVar('sesErrors', $sesErrors, 'session');
40 }
41 public static function init() {
42 $waicErrors = WaicReq::getVar('waicErrors');
43 if (!empty($waicErrors)) {
44 if (!is_array($waicErrors)) {
45 $waicErrors = array( $waicErrors );
46 }
47 $waicErrors = array_map('htmlspecialchars', array_map('stripslashes', array_map('trim', $waicErrors)));
48 if (!empty($waicErrors)) {
49 self::$current = $waicErrors;
50 if (is_admin()) {
51 add_action('admin_notices', array('WaicErrors', 'showAdminErrors'));
52 } else {
53 add_filter('the_content', array('WaicErrors', 'appendErrorsContent'), 99999);
54 }
55 }
56 }
57 }
58 public static function showAdminErrors() {
59 if (self::$current) {
60 foreach (self::$current as $error) {
61 echo '<div class="error notice is-dismissible"><p><strong>' . esc_html($error) . '</strong></p></div>';
62 }
63 }
64 }
65 public static function appendErrorsContent( $content ) {
66 if (!self::$displayed && !empty(self::$current)) {
67 $content = '<div class="toeErrorMsg">' . implode('<br />', self::$current) . '</div>' . $content;
68 self::$displayed = true;
69 }
70 return $content;
71 }
72 public static function getSession() {
73 return WaicReq::getVar('sesErrors', 'session');
74 }
75 public static function clearSession() {
76 WaicReq::clearVar('sesErrors', 'session');
77 }
78 public static function get( $type = '' ) {
79 $res = array();
80 if (!empty(self::$errors)) {
81 if (empty($type)) {
82 foreach (self::$errors as $e) {
83 foreach ($e as $error) {
84 $res[] = $error;
85 }
86 }
87 } else {
88 $res = self::$errors[$type];
89 }
90 }
91 return $res;
92 }
93 public static function haveErrors( $type = '' ) {
94 if (empty($type)) {
95 return self::$haveErrors;
96 } else {
97 return isset(self::$errors[$type]);
98 }
99 }
100 }
101