forked from jghazally/WP-e-Commerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-shopping-cart.php
203 lines (163 loc) · 5.24 KB
/
wp-shopping-cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
/**
* Plugin Name: WP e-Commerce
* Plugin URI: http://getshopped.org/
* Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
* Version: 3.8.9.5
* Author: Instinct Entertainment
* Author URI: http://getshopped.org/
**/
/**
* WP_eCommerce
*
* Main WPEC Plugin Class
*
* @package wp-e-commerce
*/
class WP_eCommerce {
private $components = array(
'merchant' => array(),
);
/**
* Start WPEC on plugins loaded
*/
function WP_eCommerce() {
add_action( 'plugins_loaded', array( $this, 'init' ), 8 );
add_action( 'wpsc_components', array( $this, '_register_core_components' ) );
}
/**
* Takes care of loading up WPEC
*/
function init() {
// Previous to initializing
do_action( 'wpsc_pre_init' );
// Initialize
$this->start();
$this->constants();
$this->includes();
$this->load();
// Finished initializing
do_action( 'wpsc_init' );
}
public function _register_core_components( $components ) {
$components['merchant']['core-v2'] = array(
'title' => __( 'WP e-Commerce Merchant API v2', 'wpsc' ),
'includes' =>
WPSC_FILE_PATH . '/wpsc-components/merchant-core-v2/merchant-core-v2.php'
);
return $components;
}
/**
* Initialize the basic WPEC constants
*/
function start() {
// Set the core file path
define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
// Define the path to the plugin folder
define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
// Define the URL to the plugin folder
define( 'WPSC_FOLDER', dirname( plugin_basename( __FILE__ ) ) );
define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
//load text domain
if( !load_plugin_textdomain( 'wpsc', false, '../languages/' ) )
load_plugin_textdomain( 'wpsc', false, dirname( plugin_basename( __FILE__ ) ) . '/wpsc-languages/' );
// Finished starting
do_action( 'wpsc_started' );
}
/**
* Setup the WPEC core constants
*/
function constants() {
// Define globals and constants used by wp-e-commerce
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
// Load the WPEC core constants
wpsc_core_constants();
// Is WordPress Multisite
wpsc_core_is_multisite();
// Start the wpsc session
wpsc_core_load_session();
// Which version of WPEC
wpsc_core_constants_version_processing();
// WPEC Table names and related constants
wpsc_core_constants_table_names();
// Uploads directory info
wpsc_core_constants_uploads();
// Any additional constants can hook in here
do_action( 'wpsc_constants' );
}
/**
* Include the rest of WPEC's files
*/
function includes() {
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
$this->components = apply_filters( 'wpsc_components', $this->components );
foreach ( $this->components as $type => $registered ) {
foreach ( $registered as $component ) {
if ( ! is_array( $component['includes'] ) )
$component['includes'] = array( $component['includes' ] );
foreach ( $component['includes'] as $include ) {
require_once( $include );
}
}
}
// Any additional file includes can hook in here
do_action( 'wpsc_includes' );
}
/**
* Setup the WPEC core
*/
function load() {
// Before setup
do_action( 'wpsc_pre_load' );
// Legacy action
do_action( 'wpsc_before_init' );
// Setup the customer ID just in case to make sure it's set up correctly
_wpsc_action_create_customer_id( 'create' );
// Setup the core WPEC globals
wpsc_core_setup_globals();
// Setup the core WPEC cart
wpsc_core_setup_cart();
// Load the thumbnail sizes
wpsc_core_load_thumbnail_sizes();
// Load the purchase log statuses
wpsc_core_load_purchase_log_statuses();
// Load unique names and checout form types
wpsc_core_load_checkout_data();
// Load the gateways
wpsc_core_load_gateways();
// Load the shipping modules
wpsc_core_load_shipping_modules();
// Set page title array for important WPSC pages
wpsc_core_load_page_titles();
// WPEC is fully loaded
do_action( 'wpsc_loaded' );
}
/**
* WPEC Activation Hook
*/
function install() {
global $wp_version;
if((float)$wp_version < 3.0){
deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourselves
wp_die( __('Looks like you\'re running an older version of WordPress, you need to be running at least WordPress 3.0 to use WP e-Commerce 3.8', 'wpsc'), __('WP e-Commerce 3.8 not compatible', 'wpsc'), array('back_link' => true));
return;
}
define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
$this->constants();
wpsc_install();
}
public function deactivate() {
foreach ( wp_get_schedules() as $cron => $schedule ) {
wp_clear_scheduled_hook( "wpsc_{$cron}_cron_task" );
}
}
}
// Start WPEC
$wpec = new WP_eCommerce();
// Activation
register_activation_hook( __FILE__, array( $wpec, 'install' ) );
register_deactivation_hook( __FILE__, array( $wpec, 'deactivate' ) );
?>