/**
  * 	show_db_name
  *
  * 	@return void
  */
 public static function show_db_name()
 {
     if (!defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
         echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' . DB_NAME . '</p>';
     }
     if (EE_DEBUG) {
         EEH_Debug_Tools::instance()->show_times();
     }
 }
Esempio n. 2
0
/**
 * 	espresso_load_error_handling
 * 	this function loads EE's class for handling exceptions and errors
 */
function espresso_load_error_handling()
{
    // load debugging tools
    if (WP_DEBUG === TRUE) {
        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
        EEH_Debug_Tools::instance();
    }
    // load error handling
    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
        require_once EE_CORE . 'EE_Error.core.php';
    } else {
        wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso'));
    }
}
 /**
  * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
  *
  * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, but the code execution is done in a manner that could lead to unexpected results (i.e. running to early, or too late in WP or EE loading process).
  *
  * A good test for knowing whether to use this method is:
  * 1. Is there going to be a PHP error if something isn't setup/used correctly? Yes -> use EE_Error::add_error() or throw new EE_Error()
  * 2. If this is loaded before something else, it won't break anything, but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
  *
  * @uses   constant WP_DEBUG test if wp_debug is on or not
  * @param  string $function The function that was called
  * @param  string $message A message explaining what has been done incorrectly
  * @param  string $version The version of Event Espresso where the error was added
  * @param int     $error_type
  * @return void
  */
 public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE)
 {
     if (defined('WP_DEBUG') && WP_DEBUG) {
         EE_Registry::instance()->load_helper('Debug_Tools');
         EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type);
     }
 }
 /**
  *    register_payment_method- makes core aware of this payment method
  *
  * @access public
  * @param string $payment_method_path - full path up to and including payment method folder
  * @return boolean
  */
 public function register_payment_method($payment_method_path = '')
 {
     do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
     $module_ext = '.pm.php';
     // make all separators match
     $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
     // grab and sanitize module name
     $module_dir = basename($payment_method_path);
     // create classname from module directory name
     $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
     // add class prefix
     $module_class = 'EE_PMT_' . $module;
     // does the module exist ?
     if (!is_readable($payment_method_path . DS . $module_class . $module_ext)) {
         $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module);
         EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
         return FALSE;
     }
     if (WP_DEBUG === TRUE) {
         EEH_Debug_Tools::instance()->start_timer();
     }
     // load the module class file
     require_once $payment_method_path . DS . $module_class . $module_ext;
     if (WP_DEBUG === TRUE) {
         EEH_Debug_Tools::instance()->stop_timer("Requiring payment method {$module_class}");
     }
     // verify that class exists
     if (!class_exists($module_class)) {
         $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
         EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
         return FALSE;
     }
     // add to array of registered modules
     $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
     return TRUE;
 }
 /**
  * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
  * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
  * but the code execution is done in a manner that could lead to unexpected results
  * (i.e. running to early, or too late in WP or EE loading process).
  * A good test for knowing whether to use this method is:
  * 1. Is there going to be a PHP error if something isn't setup/used correctly?
  * Yes -> use EE_Error::add_error() or throw new EE_Error()
  * 2. If this is loaded before something else, it won't break anything,
  * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
  *
  * @uses   constant WP_DEBUG test if wp_debug is on or not
  * @param string $function      The function that was called
  * @param string $message       A message explaining what has been done incorrectly
  * @param string $version       The version of Event Espresso where the error was added
  * @param string  $applies_when a version string for when you want the doing_it_wrong notice to begin appearing
  *                              for a deprecated function. This allows deprecation to occur during one version,
  *                              but not have any notices appear until a later version. This allows developers
  *                              extra time to update their code before notices appear.
  * @param int     $error_type
  */
 public static function doing_it_wrong($function, $message, $version, $applies_when = '', $error_type = null)
 {
     if (defined('WP_DEBUG') && WP_DEBUG) {
         EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
     }
 }
 /**
  * Assumes all the files in this folder have the normal naming scheme (namely that their classname
  * is the file's name, plus ".whatever.php".) and adds each of them to the autoloader list.
  * If that's not the case, you'll need to improve this function or just use EEH_File::get_classname_from_filepath_with_standard_filename() directly.
  * Yes this has to scan the directory for files, but it only does it once -- not on EACH
  * time the autoloader is used
  *
  * @param string $folder name, with or without trailing /, doesn't matter
  * @param bool   $recursive
  * @param bool   $debug  **deprecated**
  * @throws \EE_Error
  */
 public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false)
 {
     if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug) {
         EEH_Debug_Tools::instance()->start_timer(basename($folder));
     }
     // make sure last char is a /
     $folder .= $folder[strlen($folder) - 1] !== DS ? DS : '';
     $class_to_filepath_map = array();
     $exclude = array('index');
     //get all the files in that folder that end in php
     $filepaths = glob($folder . '*');
     if (empty($filepaths)) {
         return;
     }
     foreach ($filepaths as $filepath) {
         if (substr($filepath, -4, 4) === '.php') {
             $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath);
             if (!in_array($class_name, $exclude)) {
                 $class_to_filepath_map[$class_name] = $filepath;
             }
         } else {
             if ($recursive) {
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug);
             }
         }
     }
     // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories.
     self::register_autoloader($class_to_filepath_map, false, $debug);
     if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') {
         EEH_Debug_Tools::instance()->stop_timer(basename($folder));
     }
 }