0) { return self::$errors[0]['text']; } return false; } /** * Show the error in wrodpress * * @param string $error * @param string $type * @param string $id */ public static function setError($error = '', $type = 'notice', $id = '') { self::$errors[] = array( 'id' => $id, 'type' => $type, 'text' => $error); } public static function isError() { return (count(self::$errors) > 0); } public static function setMessage($message = '', $id = '') { self::$errors[] = array( 'id' => $id, 'type' => 'success', 'text' => $message); } /** * This hook will show the error in WP header */ public static function hookNotices() { if (is_array(self::$errors)) foreach (self::$errors as $error) { switch ($error['type']) { case 'fatal': self::showError(ucfirst(_SQ_PLUGIN_NAME_ . " " . $error['type']) . ': ' . $error['text'], $error['id']); die(); break; case 'settings': /* switch off option for notifications */ self::showError($error['text'] . " ", $error['id']); break; case 'helpnotice': if (!SQ_Classes_Helpers_Tools::getOption('ignore_warn')) { self::$switch_off = "" . __("Don't bother me!", _SQ_PLUGIN_NAME_) . ""; self::showError($error['text'] . " " . self::$switch_off, $error['id'], 'sq_helpnotice'); } break; case 'success': self::showError($error['text'] . " ", $error['id'], 'sq_success'); break; case 'trial': if (SQ_Classes_Helpers_Tools::getOption('sq_google_alert_trial')) { self::$switch_off = "" . __("Don't bother me!", _SQ_PLUGIN_NAME_) . ""; self::showError($error['text'] . " " . self::$switch_off, $error['id'], 'sq_success'); } break; default: self::showError($error['text'], $error['id']); } } self::$errors = array(); } /** * Show the notices to WP * * @param $message * @param string $type * @return string */ public static function showNotices($message, $type = 'sq_notices') { if (file_exists(_SQ_THEME_DIR_ . 'Notices.php')) { ob_start(); include(_SQ_THEME_DIR_ . 'Notices.php'); $message = ob_get_contents(); ob_end_clean(); } return $message; } /** * Show the notices to WP * * @param $message * @param string $id * @param string $type * * return void */ public static function showError($message, $id = '', $type = 'sq_error') { if (file_exists(_SQ_THEME_DIR_ . 'Notices.php')) { include(_SQ_THEME_DIR_ . 'Notices.php'); } else { echo $message; } } }