*/ class apptivo_ecommerce { var $_cache; var $errors = array(); var $messages = array(); var $plugin_url; var $plugin_path; // Class instances var $cart; var $payment_gateways; var $countries; /** constructor */ function __construct() { // Load class instances $this->cart = new apptivo_ecommerce_cart(); // Cart class, stores the cart contents $this->payment_gateways = new apptivo_ecommerce_payment_gateways(); // Payment gateways class. loads and stores payment methods $this->countries = new apptivo_ecommerce_countries(); // Countries class // Load messages $this->load_messages(); // Hooks add_filter('wp_redirect', array(&$this, 'redirect'), 1, 2); //Payment gateways add_action('plugins_loaded', array( &$this->payment_gateways, 'init' ), 1); // Load payment methods - some may be added by plugins } /*** Get the plugin url */ function plugin_url() { if($this->plugin_url) return $this->plugin_url; if (is_ssl()) : return $this->plugin_url = str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename( dirname(dirname(__FILE__))); else : return $this->plugin_url = WP_PLUGIN_URL . "/" . plugin_basename( dirname(dirname(__FILE__))); endif; } /** * Get the plugin path */ function plugin_path() { if($this->plugin_path) return $this->plugin_path; return $this->plugin_path = WP_PLUGIN_DIR . "/" . plugin_basename( dirname(dirname(__FILE__))); } /** Return the URL with https if SSL is on */ function force_ssl( $url ) { if (is_ssl()) $url = str_replace('http:', 'https:', $url); return $url; } /*** Get an image size */ function get_image_size( $image_size ) { $return = ''; switch ($image_size) : case "product_thumbnail_image_width" : $return = get_option('apptivo_ecommerce_thumbnail_image_width'); break; case "product_thumbnail_image_height" : $return = get_option('apptivo_ecommerce_thumbnail_image_height'); break; case "product_catalog_image_width" : $return = get_option('apptivo_ecommerce_catalog_image_width'); break; case "product_catalog_image_height" : $return = get_option('apptivo_ecommerce_catalog_image_height'); break; case "product_single_image_width" : $return = get_option('apptivo_ecommerce_single_image_width'); break; case "product_single_image_height" : $return = get_option('apptivo_ecommerce_single_image_height'); break; endswitch; return apply_filters( 'apptivo_ecommerce_get_image_size_'.$image_size, $return ); } /*** Load Messages */ function load_messages() { if (isset($_SESSION['errors'])) $this->errors = $_SESSION['errors']; if (isset($_SESSION['messages'])) $this->messages = $_SESSION['messages']; unset($_SESSION['messages']); unset($_SESSION['errors']); } /*** Add an error*/ function add_error( $error,$key='' ) { $this->errors[] = $error.''; } /** * Add a message */ function add_message( $message ) { $this->messages[] = $message; } /** Clear messages and errors from the session data */ function clear_messages() { $this->errors = $this->messages = array(); unset($_SESSION['messages']); unset($_SESSION['errors']); } /*** Get error count */ function error_count() { return sizeof($this->errors); } /*** Get message count */ function message_count() { return sizeof($this->messages); } /** Output the errors and messages */ function show_messages() { if (isset($this->errors) && sizeof($this->errors)>0) : $single_err_msg = get_option('apptivo_ecommerce_single_error_message'); if( $single_err_msg == 'yes'){ echo '