/**
  * Singleton
  *
  * @param none
  * @return instance of object
  */
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new EPL_Base();
     }
     return self::$instance;
 }
 function __constuct()
 {
     $this->epl = EPL_Base::get_instance();
     add_action('init', array($this, 'create_post_types'));
     add_action('admin_menu', array($this, 'admin_specific'));
     add_action('wp_print_styles', array($this, 'front_specific_styles'), 1, 1);
     add_action('wp_enqueue_scripts', array($this, 'front_specific_js'));
 }
 function _assign_libraries($use_reference = TRUE)
 {
     $epl = EPL_Base::get_instance();
     foreach (array_keys(get_object_vars($epl)) as $key) {
         if (!isset($this->{$key}) and $key != $this->_parent_name) {
             // In some cases using references can cause
             // problems so we'll conditionally use them
             if ($use_reference == TRUE) {
                 $this->{$key} = NULL;
                 // Needed to prevent reference errors with some configurations
                 $this->{$key} = $epl->{$key};
             } else {
                 $this->{$key} = $epl->{$key};
             }
         }
     }
 }
 function __constuct()
 {
     $this->epl = EPL_Base::get_instance();
     add_action('init', array($this, 'create_post_types'));
     add_action('admin_menu', array($this, 'admin_specific'));
     add_action('admin_head', array($this, 'reorder_menu'), 100);
     add_action('wp_print_styles', array($this, 'front_specific_styles'), 1, 1);
     add_action('wp_print_styles', array($this, 'add_custom_css'), 100);
     add_action('wp_enqueue_scripts', array($this, 'front_specific_js'));
     //add_filter( 'wp_handle_upload', array( $this, 'handle_upload' ) ); //passes fielename, url, and post_id that I send from the fileupload form.
     //add_action( 'add_attachment', array( $this, 'handle_upload' ) ); //only passes attachment post id
     add_filter('upload_mimes', array($this, 'mime_types'), 1, 1);
     add_action('init', array($this, 'register_tables'), 1);
     if (!defined('EPL_IS_ADMIN')) {
         define('EPL_IS_ADMIN', is_admin());
     }
     add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     //add_action( 'switch_blog', 'register_epl_tables' );
 }
 /**
  * Make API request
  *
  * @param string $method string API method to request
  * @param array $params Additional request parameters
  * @return array / boolean Response array / boolean false on failure
  */
 public function request($method, $params = array())
 {
     $this->_errors = array();
     if (empty($method)) {
         //Check if API method is not empty
         $this->_errors = array('API method is missing');
         return false;
     }
     $this->erm = EPL_Base::get_instance()->load_model('epl-registration-model');
     $gateway_info = $this->erm->get_gateway_info();
     /*$this->_credentials = array();
       /*    'USER' => $gateway_info['_epl_pp_exp_user'],
           'PWD' => $gateway_info['_epl_pp_exp_pwd'],
           'SIGNATURE' => $gateway_info['_epl_pp_exp_sig'],
       );*/
     if ($gateway_info['_epl_sandbox'] == 0) {
         $this->_endPoint = 'https://api-3t.paypal.com/nvp';
     }
     //Our request parameters
     $requestParams = array('METHOD' => $method, 'VERSION' => $this->_version) + $this->_credentials;
     //Building our NVP string
     $request = http_build_query($requestParams + $params);
     //cURL settings
     $curlOptions = array(CURLOPT_URL => $this->_endPoint, CURLOPT_VERBOSE => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_RETURNTRANSFER => 1, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $request);
     $ch = curl_init();
     curl_setopt_array($ch, $curlOptions);
     //Sending our request - $response will hold the API response
     $response = curl_exec($ch);
     //Checking for cURL errors
     if (curl_errno($ch)) {
         $this->_errors = curl_error($ch);
         curl_close($ch);
         return false;
         //Handle errors
     } else {
         curl_close($ch);
         $responseArray = array();
         parse_str($response, $responseArray);
         // Break the NVP string to an array
         return $responseArray;
     }
 }
 /**
  * Depending on the uri parameters, this function determines which controller to load.
  *
  * @since 1.0.0
  * @param none
  * @return Only when called from the front end, returns short code process result.
  */
 function _route($resource = null)
 {
     epl_log("init", "<pre>" . print_r($resource, true) . "</pre>");
     if (self::$routed) {
         return;
     }
     epl_log("init", "<pre>" . print_r($resource, true) . "</pre>");
     global $valid_controllers, $post;
     //When the shortcode is processed, the page id is ready
     if (!array_key_exists($resource, $valid_controllers)) {
         return false;
     }
     $epl = EPL_Base::get_instance();
     $controller_location = $valid_controllers[$resource]['location'];
     $controller = $epl->load_controller($controller_location);
     self::$routed = true;
     if (!EPL_IS_ADMIN && !isset($_REQUEST['epl_action'])) {
         return $controller->run();
         //doing this for the shortcode
     }
 }
function epl_get_message($code = null)
{
    global $epl_sys_messages;
    if ($epl_sys_messages == '') {
        EPL_Base::get_instance()->load_config('sys-messages');
    }
    return epl_get_element($code, $epl_sys_messages);
}
<?php 
$epl = EPL_Base::get_instance();
$delim = EPL_db_model::get_instance()->delim;
$tmpl = array('table_open' => '<table border="1" cellpadding="0" cellspacing="0" class="epl_lookup_result_table">');
$this->epl->epl_table->set_template($tmpl);
$header = epl_get_field_labels($avail_fields);
$_row = array_fill_keys(array_keys($avail_fields), null);
foreach ($lookup_list as $r) {
    if (strpos($r->field_id, $delim)) {
        $fields = explode($delim, $r->field_id);
        $values = explode($delim, $r->value);
    } else {
        $fields = $r->field_id;
        $values = $r->value;
    }
    $raw = array_combine($fields, $values);
    $row = array_merge($_row, $raw);
    $row = epl_process_fields_for_display($row, $avail_fields);
    $raw['user_id'] = $r->user_id;
    $regis_link = epl_anchor(admin_url('post.php?post=' . $r->regis_id . '&action=edit'), $r->regis_key);
    $select_link = '<a href="#" class="epl_lookup_row_select">Select</a><span class="form_data" style="display:none;">' . json_encode($raw) . '</span>' . ($r->user_id > 0 ? " ({$r->user_id})" : '');
    array_unshift($row, $select_link);
    array_unshift($row, $regis_link);
    $epl->epl_table->add_row($row);
}
array_unshift($header, '');
array_unshift($header, '');
$epl->epl_table->set_heading($header);
echo $epl->epl_table->generate();
 function _route($resource = null, $atts = array())
 {
     if (self::$routed) {
         return;
     }
     global $valid_controllers, $post;
     //When the shortcode is processed, the page id is ready
     if (!array_key_exists($resource, $valid_controllers)) {
         return false;
     }
     $controller_location = $valid_controllers[$resource]['location'];
     $controller = EPL_Base::get_instance()->load_controller($controller_location);
     //self::$routed = true;
     //if ( !EPL_IS_ADMIN && !isset( $_REQUEST['epl_action'] ) ) {
     if (!EPL_IS_ADMIN || $GLOBALS['epl_ajax']) {
         return $controller->run($atts);
         //doing this for the shortcode
     }
 }