/** * add success message * * @access public * @param string $type whether the message is for a success or error notification * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev * @param string $file the file that the error occurred in - just use __FILE__ * @param string $func the function/method that the error occurred in - just use __FUNCTION__ * @param string $line the line number where the error occurred - just use __LINE__ * @return void */ private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { if (empty($msg)) { EE_Error::doing_it_wrong('EE_Error::add_' . $type . '()', sprintf(__('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), $type, $file, $line), EVENT_ESPRESSO_VERSION); } if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { EE_Error::doing_it_wrong('EE_Error::add_error()', __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), EVENT_ESPRESSO_VERSION); } // get separate user and developer messages if they exist $msg = explode('||', $msg); $user_msg = $msg[0]; $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; $msg = WP_DEBUG ? $dev_msg : $user_msg; // add notice if message exists if (!empty($msg)) { // get error code $notice_code = EE_Error::generate_error_code($file, $func, $line); if (WP_DEBUG && $type == 'errors') { $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; } // add notice. Index by code if it's not blank if ($notice_code) { self::$_espresso_notices[$type][$notice_code] = $msg; } else { self::$_espresso_notices[$type][] = $msg; } add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); } }
/** * add success message * * @access public * @param string $type whether the message is for a success or error notification * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev * @param string $file the file that the error occurred in - just use __FILE__ * @param string $func the function/method that the error occurred in - just use __FUNCTION__ * @param string $line the line number where the error occurred - just use __LINE__ * @return void */ private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { if (empty($msg)) { EE_Error::doing_it_wrong('EE_Error::add_' . $type . '()', 'Notifications are not much use without a message! Please add a message.', EVENT_ESPRESSO_VERSION); } // todo: reimplement the following in 4.5+ // if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { // EE_Error::doing_it_wrong( 'EE_Error::add_error()', 'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', EVENT_ESPRESSO_VERSION ); // } // get separate user and developer messages if they exist $msg = explode('||', $msg); $user_msg = $msg[0]; $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; $msg = WP_DEBUG ? $dev_msg : $user_msg; // add notice if message exists if (!empty($msg)) { // get error code only on error $error_code = $type == 'errors' ? EE_Error::generate_error_code($file, $func, $line) : ''; $error_code = !empty($error_code) ? '<br/><span class="tiny-text">' . $error_code . '</span>' : ''; // add notice self::$_espresso_notices[$type][] = $msg . $error_code; add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); } }