PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/wp-e-commerce/wp-shopping-cart.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 537 lines | 345 code | 95 blank | 97 comment | 70 complexity | 9e4fd0b380789287e55f3a95d2c62b08 MD5 | raw file
  1. <?php
  2. /*
  3. Plugin Name:WP Shopping Cart
  4. Plugin URI: http://www.getshopped.org
  5. Description: A plugin that provides a WordPress Shopping Cart. Visit the <a href='http://getshopped.org/forums'>getshopped forums</a> for support.
  6. Version: 3.7.6.4
  7. Author: Instinct
  8. Author URI: http://www.getshopped.org
  9. */
  10. /**
  11. * WP eCommerce Main Plugin File
  12. * @package wp-e-commerce
  13. */
  14. // this is to make sure it sets up the table name constants correctly on activation
  15. global $wpdb;
  16. define('WPSC_VERSION', '3.7');
  17. define('WPSC_MINOR_VERSION', '54');
  18. define('WPSC_PRESENTABLE_VERSION', '3.7.6.4');
  19. define('WPSC_DEBUG', false);
  20. define('WPSC_GATEWAY_DEBUG', false);
  21. $v1 = str_replace(array('_','-','+'), '.', strtolower($wp_version));
  22. $v1 = str_replace(array('alpha','beta','gamma'), array('a','b','g'), $v1);
  23. $v1 = preg_split("/([a-z]+)/i",$v1,-1, PREG_SPLIT_DELIM_CAPTURE);
  24. array_walk($v1, create_function('&$v', '$v = trim($v,". ");'));
  25. define('IS_WP25', version_compare($v1[0], '2.5', '>='));
  26. define('IS_WP27', version_compare($v1[0], '2.7', '>='));
  27. // // we need to know where we are, rather than assuming where we are
  28. //Define the path to the plugin folder
  29. define('WPSC_FILE_PATH', dirname(__FILE__));
  30. define('WPSC_DIR_NAME', basename(WPSC_FILE_PATH));
  31. $wpsc_siteurl = get_option('siteurl');
  32. if(is_ssl()) {
  33. $wpsc_siteurl = str_replace("http://", "https://", $wpsc_siteurl);
  34. }
  35. $wpsc_plugin_url = WP_CONTENT_URL;
  36. if(is_ssl()) {
  37. $plugin_url_parts = parse_url($wpsc_plugin_url);
  38. $site_url_parts = parse_url($wpsc_siteurl);
  39. if(stristr($plugin_url_parts['host'], $site_url_parts['host']) && stristr($site_url_parts['host'], $plugin_url_parts['host'])) {
  40. $wpsc_plugin_url = str_replace("http://", "https://", $wpsc_plugin_url);
  41. }
  42. }
  43. //Define the URL to the plugin folder
  44. define('WPSC_FOLDER', dirname(plugin_basename(__FILE__)));
  45. define('WPSC_URL', $wpsc_plugin_url.'/plugins/'.WPSC_FOLDER);
  46. if(isset($wpdb->blogid)) {
  47. define('IS_WPMU', 1);
  48. } else {
  49. define('IS_WPMU', 0);
  50. }
  51. /*
  52. load plugin text domain for get_text files. Plugin language will be the same
  53. as wordpress language defined in wp-config.php line 67
  54. */
  55. load_plugin_textdomain('wpsc', false, dirname( plugin_basename(__FILE__) ) . '/languages');
  56. if(!empty($wpdb->prefix)) {
  57. $wp_table_prefix = $wpdb->prefix;
  58. } else if(!empty($table_prefix)) {
  59. $wp_table_prefix = $table_prefix;
  60. }
  61. // Define the database table names
  62. define('WPSC_TABLE_CATEGORY_TM', "{$wp_table_prefix}wpsc_category_tm");
  63. define('WPSC_TABLE_ALSO_BOUGHT', "{$wp_table_prefix}wpsc_also_bought");
  64. define('WPSC_TABLE_CART_CONTENTS', "{$wp_table_prefix}wpsc_cart_contents");
  65. define('WPSC_TABLE_META', "{$wp_table_prefix}wpsc_meta");
  66. define('WPSC_TABLE_CART_ITEM_VARIATIONS', "{$wp_table_prefix}wpsc_cart_item_variations");
  67. define('WPSC_TABLE_CHECKOUT_FORMS', "{$wp_table_prefix}wpsc_checkout_forms");
  68. define('WPSC_TABLE_CURRENCY_LIST', "{$wp_table_prefix}wpsc_currency_list");
  69. define('WPSC_TABLE_DOWNLOAD_STATUS', "{$wp_table_prefix}wpsc_download_status");
  70. define('WPSC_TABLE_ITEM_CATEGORY_ASSOC', "{$wp_table_prefix}wpsc_item_category_assoc");
  71. define('WPSC_TABLE_PRODUCT_CATEGORIES', "{$wp_table_prefix}wpsc_product_categories");
  72. define('WPSC_TABLE_PRODUCT_FILES', "{$wp_table_prefix}wpsc_product_files");
  73. define('WPSC_TABLE_PRODUCT_IMAGES', "{$wp_table_prefix}wpsc_product_images");
  74. define('WPSC_TABLE_PRODUCT_LIST', "{$wp_table_prefix}wpsc_product_list");
  75. define('WPSC_TABLE_PRODUCT_ORDER', "{$wp_table_prefix}wpsc_product_order");
  76. define('WPSC_TABLE_PRODUCT_RATING', "{$wp_table_prefix}wpsc_product_rating");
  77. define('WPSC_TABLE_PRODUCT_VARIATIONS', "{$wp_table_prefix}wpsc_product_variations");
  78. define('WPSC_TABLE_PURCHASE_LOGS', "{$wp_table_prefix}wpsc_purchase_logs");
  79. define('WPSC_TABLE_PURCHASE_STATUSES', "{$wp_table_prefix}wpsc_purchase_statuses");
  80. define('WPSC_TABLE_REGION_TAX', "{$wp_table_prefix}wpsc_region_tax");
  81. define('WPSC_TABLE_SUBMITED_FORM_DATA', "{$wp_table_prefix}wpsc_submited_form_data");
  82. define('WPSC_TABLE_VARIATION_ASSOC', "{$wp_table_prefix}wpsc_variation_assoc");
  83. define('WPSC_TABLE_VARIATION_PROPERTIES', "{$wp_table_prefix}wpsc_variation_properties");
  84. define('WPSC_TABLE_VARIATION_VALUES', "{$wp_table_prefix}wpsc_variation_values");
  85. define('WPSC_TABLE_VARIATION_VALUES_ASSOC', "{$wp_table_prefix}wpsc_variation_values_assoc");
  86. define('WPSC_TABLE_COUPON_CODES', "{$wp_table_prefix}wpsc_coupon_codes");
  87. define('WPSC_TABLE_LOGGED_SUBSCRIPTIONS', "{$wp_table_prefix}wpsc_logged_subscriptions");
  88. define('WPSC_TABLE_PRODUCTMETA', "{$wp_table_prefix}wpsc_productmeta");
  89. define('WPSC_TABLE_CATEGORISATION_GROUPS', "{$wp_table_prefix}wpsc_categorisation_groups");
  90. define('WPSC_TABLE_VARIATION_COMBINATIONS', "{$wp_table_prefix}wpsc_variation_combinations");
  91. define('WPSC_TABLE_CLAIMED_STOCK', "{$wp_table_prefix}wpsc_claimed_stock");
  92. // start including the rest of the plugin here
  93. require_once(WPSC_FILE_PATH.'/wpsc-includes/wpsc_query.php');
  94. require_once(WPSC_FILE_PATH.'/wpsc-includes/variations.class.php');
  95. require_once(WPSC_FILE_PATH.'/wpsc-includes/ajax.functions.php');
  96. require_once(WPSC_FILE_PATH.'/wpsc-includes/misc.functions.php');
  97. require_once(WPSC_FILE_PATH.'/wpsc-includes/mimetype.php');
  98. require_once(WPSC_FILE_PATH.'/wpsc-includes/cart.class.php');
  99. require_once(WPSC_FILE_PATH.'/wpsc-includes/checkout.class.php');
  100. require_once(WPSC_FILE_PATH.'/wpsc-includes/display.functions.php');
  101. require_once(WPSC_FILE_PATH.'/wpsc-includes/pagination.class.php');
  102. require_once(WPSC_FILE_PATH.'/wpsc-includes/shortcode.functions.php');
  103. require_once(WPSC_FILE_PATH.'/wpsc-includes/coupons.class.php');
  104. require_once(WPSC_FILE_PATH.'/wpsc-includes/purchaselogs.class.php');
  105. include_once(WPSC_FILE_PATH."/wpsc-includes/category.functions.php");
  106. include_once(WPSC_FILE_PATH."/wpsc-includes/processing.functions.php");
  107. require_once(WPSC_FILE_PATH."/wpsc-includes/form-display.functions.php");
  108. require_once(WPSC_FILE_PATH."/wpsc-includes/merchant.class.php");
  109. require_once(WPSC_FILE_PATH."/wpsc-includes/meta.functions.php");
  110. require_once(WPSC_FILE_PATH."/wpsc-includes/productfeed.php");
  111. //exit(print_r($v1,true));
  112. if($v1[0] >= 2.8){
  113. require_once(WPSC_FILE_PATH."/wpsc-includes/upgrades.php");
  114. }
  115. if (!IS_WP25) {
  116. require_once(WPSC_FILE_PATH.'/editor.php');
  117. } else {
  118. require_once(WPSC_FILE_PATH.'/js/tinymce3/tinymce.php');
  119. }
  120. if((get_option('wpsc_share_this') == 1) && (get_option('product_list_url') != '')) {
  121. if(stristr(("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']), get_option('product_list_url'))){
  122. include_once(WPSC_FILE_PATH."/share-this.php");
  123. }
  124. }
  125. $wpsc_currency_data = array();
  126. $wpsc_title_data = array();
  127. $GLOBALS['nzshpcrt_imagesize_info'] = __('Note: if this is blank, the image will not be resized', 'wpsc');
  128. $nzshpcrt_log_states[0]['name'] = __('Order Received', 'wpsc');
  129. $nzshpcrt_log_states[1]['name'] = TXT_WPSC_PROCESSING;
  130. $nzshpcrt_log_states[2]['name'] = __('Closed Order', 'wpsc');
  131. require_once(WPSC_FILE_PATH."/currency_converter.inc.php");
  132. require_once(WPSC_FILE_PATH."/shopping_cart_functions.php");
  133. require_once(WPSC_FILE_PATH."/homepage_products_functions.php");
  134. require_once(WPSC_FILE_PATH."/transaction_result_functions.php");
  135. // include_once(WPSC_FILE_PATH.'/submit_checkout_function.php');
  136. require_once(WPSC_FILE_PATH."/admin-form-functions.php");
  137. require_once(WPSC_FILE_PATH."/shipwire_functions.php");
  138. /* widget_section */
  139. include_once(WPSC_FILE_PATH.'/widgets/product_tag_widget.php');
  140. include_once(WPSC_FILE_PATH.'/widgets/shopping_cart_widget.php');
  141. include_once(WPSC_FILE_PATH.'/widgets/donations_widget.php');
  142. include_once(WPSC_FILE_PATH.'/widgets/specials_widget.php');
  143. include_once(WPSC_FILE_PATH.'/widgets/latest_product_widget.php');
  144. include_once(WPSC_FILE_PATH.'/widgets/price_range_widget.php');
  145. include_once(WPSC_FILE_PATH.'/widgets/admin_menu_widget.php');
  146. //include_once(WPSC_FILE_PATH.'/widgets/api_key_widget.php');
  147. if (class_exists('WP_Widget')) {
  148. include_once(WPSC_FILE_PATH.'/widgets/category_widget.28.php');
  149. } else {
  150. include_once(WPSC_FILE_PATH.'/widgets/category_widget.27.php');
  151. }
  152. include_once(WPSC_FILE_PATH.'/image_processing.php');
  153. // if we are in the admin section, include the admin code
  154. if(WP_ADMIN == true) {
  155. require_once(WPSC_FILE_PATH."/wpsc-admin/admin.php");
  156. }
  157. /**
  158. * Code to define where the uploaded files are stored starts here
  159. */
  160. /*
  161. if(IS_WPMU == 1) {
  162. $upload_url = get_option('siteurl').'/files';
  163. $upload_path = ABSPATH.get_option('upload_path');
  164. } else {
  165. if ( !defined('WP_CONTENT_URL') ) {
  166. define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
  167. }
  168. if ( !defined('WP_CONTENT_DIR') ) {
  169. define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content');
  170. }
  171. $upload_path = WP_CONTENT_DIR."/uploads";
  172. $upload_url = WP_CONTENT_URL."/uploads";
  173. }*/
  174. $wp_upload_dir_data = wp_upload_dir();
  175. //echo "<pre>".print_r($wp_upload_dir_data, true)."</pre>";
  176. $upload_path = $wp_upload_dir_data['basedir'];
  177. $upload_url = $wp_upload_dir_data['baseurl'];
  178. if(is_ssl()) {
  179. $upload_url = str_replace("http://", "https://", $upload_url);
  180. }
  181. $wpsc_upload_dir = "{$upload_path}/wpsc/";
  182. $wpsc_file_dir = "{$wpsc_upload_dir}downloadables/";
  183. $wpsc_preview_dir = "{$wpsc_upload_dir}previews/";
  184. $wpsc_image_dir = "{$wpsc_upload_dir}product_images/";
  185. $wpsc_thumbnail_dir = "{$wpsc_upload_dir}product_images/thumbnails/";
  186. $wpsc_category_dir = "{$wpsc_upload_dir}category_images/";
  187. $wpsc_user_uploads_dir = "{$wpsc_upload_dir}user_uploads/";
  188. $wpsc_cache_dir = "{$wpsc_upload_dir}cache/";
  189. $wpsc_upgrades_dir = "{$wpsc_upload_dir}upgrades/";
  190. $wpsc_themes_dir = "{$wpsc_upload_dir}themes/";
  191. define('WPSC_UPLOAD_DIR', $wpsc_upload_dir);
  192. define('WPSC_FILE_DIR', $wpsc_file_dir);
  193. define('WPSC_PREVIEW_DIR', $wpsc_preview_dir);
  194. define('WPSC_IMAGE_DIR', $wpsc_image_dir);
  195. define('WPSC_THUMBNAIL_DIR', $wpsc_thumbnail_dir);
  196. define('WPSC_CATEGORY_DIR', $wpsc_category_dir);
  197. define('WPSC_USER_UPLOADS_DIR', $wpsc_user_uploads_dir);
  198. define('WPSC_CACHE_DIR', $wpsc_cache_dir);
  199. define('WPSC_UPGRADES_DIR', $wpsc_upgrades_dir);
  200. define('WPSC_THEMES_PATH', $wpsc_themes_dir);
  201. /**
  202. * files that are uploaded as part of digital products are not directly downloaded, therefore there is no need for a URL constant for them
  203. */
  204. $wpsc_upload_url = "{$upload_url}/wpsc/";
  205. $wpsc_preview_url = "{$wpsc_upload_url}previews/";
  206. $wpsc_image_url = "{$wpsc_upload_url}product_images/";
  207. $wpsc_thumbnail_url = "{$wpsc_upload_url}product_images/thumbnails/";
  208. $wpsc_category_url = "{$wpsc_upload_url}category_images/";
  209. $wpsc_user_uploads_url = "{$wpsc_upload_url}user_uploads/";
  210. $wpsc_cache_url = "{$wpsc_upload_url}cache/";
  211. $wpsc_upgrades_url = "{$wpsc_upload_url}upgrades/";
  212. $wpsc_themes_url = "{$wpsc_upload_url}themes/";
  213. define('WPSC_UPLOAD_URL', $wpsc_upload_url);
  214. define('WPSC_PREVIEW_URL', $wpsc_preview_url);
  215. define('WPSC_IMAGE_URL', $wpsc_image_url);
  216. define('WPSC_THUMBNAIL_URL', $wpsc_thumbnail_url);
  217. define('WPSC_CATEGORY_URL', $wpsc_category_url);
  218. define('WPSC_USER_UPLOADS_URL', $wpsc_user_uploads_url);
  219. define('WPSC_CACHE_URL', $wpsc_cache_url);
  220. define('WPSC_UPGRADES_URL', $wpsc_upgrades_url);
  221. define('WPSC_THEMES_URL', $wpsc_themes_url);
  222. require_once(WPSC_FILE_PATH.'/wpsc-includes/theme.functions.php');
  223. //Add deprecated functions in this file please
  224. require_once(WPSC_FILE_PATH."/wpsc-includes/deprecated.functions.php");
  225. /*
  226. * This plugin gets the merchants from the merchants directory and
  227. * needs to search the merchants directory for merchants, the code to do this starts here
  228. */
  229. $gateway_directory = WPSC_FILE_PATH.'/merchants';
  230. $nzshpcrt_merchant_list = wpsc_list_dir($gateway_directory);
  231. //exit("<pre>".print_r($nzshpcrt_merchant_list,true)."</pre>");
  232. $num=0;
  233. foreach($nzshpcrt_merchant_list as $nzshpcrt_merchant) {
  234. if(stristr( $nzshpcrt_merchant , '.php' )) {
  235. //echo $nzshpcrt_merchant;
  236. require(WPSC_FILE_PATH."/merchants/".$nzshpcrt_merchant);
  237. }
  238. $num++;
  239. }
  240. /*
  241. * and ends here
  242. */
  243. // include shipping modules here.
  244. $shipping_directory = WPSC_FILE_PATH.'/shipping';
  245. $nzshpcrt_shipping_list = wpsc_list_dir($shipping_directory);
  246. foreach($nzshpcrt_shipping_list as $nzshpcrt_shipping) {
  247. if(stristr( $nzshpcrt_shipping , '.php' )) {
  248. if($nzshpcrt_shipping == 'ups.php'){
  249. if (phpMinV('5')){
  250. require(WPSC_FILE_PATH."/shipping/".$nzshpcrt_shipping);
  251. }
  252. }else{
  253. require(WPSC_FILE_PATH."/shipping/".$nzshpcrt_shipping);
  254. }
  255. }
  256. }
  257. $wpsc_shipping_modules = apply_filters('wpsc_shipping_modules',$wpsc_shipping_modules);
  258. // if the gold cart file is present, include it, this must be done before the admin file is included
  259. if(is_file(WPSC_UPGRADES_DIR . "gold_cart_files/gold_shopping_cart.php")) {
  260. require_once(WPSC_UPGRADES_DIR . "gold_cart_files/gold_shopping_cart.php");
  261. }
  262. // need to sort the merchants here, after the gold ones are included.
  263. if(!function_exists('wpsc_merchant_sort')) {
  264. function wpsc_merchant_sort($a, $b) {
  265. return strnatcmp(strtolower($a['name']), strtolower($b['name']));
  266. }
  267. }
  268. uasort($nzshpcrt_gateways, 'wpsc_merchant_sort');
  269. // make an associative array of references to gateway data.
  270. $wpsc_gateways = array();
  271. foreach((array)$nzshpcrt_gateways as $key => $gateway) {
  272. $wpsc_gateways[$gateway['internalname']] = &$nzshpcrt_gateways[$key];
  273. }
  274. $theme_path = WPSC_FILE_PATH . '/themes/';
  275. if((get_option('wpsc_selected_theme') != '') && (file_exists($theme_path.get_option('wpsc_selected_theme')."/".get_option('wpsc_selected_theme').".php") )) {
  276. include_once(WPSC_FILE_PATH.'/themes/'.get_option('wpsc_selected_theme').'/'.get_option('wpsc_selected_theme').'.php');
  277. }
  278. $current_version_number = get_option('wpsc_version');
  279. if(count(explode(".",$current_version_number)) > 2) {
  280. // in a previous version, I accidentally had the major version number have two dots, and three numbers
  281. // this code rectifies that mistake
  282. $current_version_number_array = explode(".",$current_version_number);
  283. array_pop($current_version_number_array);
  284. $current_version_number = (float)implode(".", $current_version_number_array );
  285. } else if(!is_numeric(get_option('wpsc_version'))) {
  286. $current_version_number = 0;
  287. }
  288. //if there are any upgrades present, include them., thanks to nielo.info and lsdev.biz
  289. if($v1[0] >= 2.8){
  290. $upgrades = get_upgrades();
  291. foreach ($upgrades as $path=>$upgrade) {
  292. $upgrade_file = WPSC_UPGRADES_DIR . '/' . $path;
  293. require_once($upgrade_file);
  294. }
  295. }
  296. include_once(WPSC_FILE_PATH."/wpsc-includes/install_and_update.functions.php");
  297. register_activation_hook(__FILE__, 'wpsc_install');
  298. /**
  299. * Code to define where the uploaded files are stored ends here
  300. */
  301. if(!function_exists('wpsc_start_the_query')) {
  302. function wpsc_start_the_query() {
  303. global $wp_query, $wpsc_query;
  304. $wpsc_query = new WPSC_query();
  305. $post_id = $wp_query->post->ID;
  306. $page_url = get_permalink($post_id);
  307. if(get_option('shopping_cart_url') == $page_url) {
  308. $_SESSION['wpsc_has_been_to_checkout'] = true;
  309. //echo $_SESSION['wpsc_has_been_to_checkout'];
  310. }
  311. }
  312. }
  313. // after init and after when the wp query string is parsed but before anything is displayed
  314. add_action('template_redirect', 'wpsc_start_the_query', 0);
  315. /**
  316. * Check to see if the session exists, if not, start it
  317. */
  318. if((!is_array($_SESSION)) xor (!isset($_SESSION['nzshpcrt_cart'])) xor (!$_SESSION)) {
  319. session_start();
  320. }
  321. if(!function_exists('wpsc_initialisation')){
  322. function wpsc_initialisation() {
  323. global $wpsc_cart, $wpsc_theme_path, $wpsc_theme_url, $wpsc_category_url_cache;
  324. // set the theme directory constant
  325. $file_names = array();
  326. // Check that theme folder exists to prevent fatal timeout error
  327. // which crashes WordPress.
  328. if ( is_dir( WPSC_THEMES_PATH ) ) {
  329. $uploads_dir = @opendir( WPSC_THEMES_PATH );
  330. while ( ( $file = @readdir( $uploads_dir ) ) !== false ) {
  331. //echo "<br />test" . WPSC_THEMES_PATH . $file;
  332. if ( is_dir( WPSC_THEMES_PATH . $file ) && ( $file != "..") && ( $file != "." ) && ( $file != ".svn" ) ) {
  333. $file_names[] = $file;
  334. }
  335. }
  336. }
  337. if(count($file_names) > 0) {
  338. $wpsc_theme_path = WPSC_THEMES_PATH;
  339. $wpsc_theme_url = WPSC_THEMES_URL;
  340. } else {
  341. $wpsc_theme_path = WPSC_FILE_PATH . "/themes/";
  342. $wpsc_theme_url = WPSC_URL. '/themes/';
  343. }
  344. //$theme_path = WPSC_FILE_PATH . "/themes/";
  345. //exit(print_r($file_names,true));
  346. if((get_option('wpsc_selected_theme') == null) || (!file_exists($wpsc_theme_path.get_option('wpsc_selected_theme')))) {
  347. $theme_dir = 'default';
  348. } else {
  349. $theme_dir = get_option('wpsc_selected_theme');
  350. }
  351. define('WPSC_THEME_DIR', $theme_dir);
  352. // initialise the cart session, if it exist, unserialize it, otherwise make it
  353. if(isset($_SESSION['wpsc_cart'])) {
  354. if(is_object($_SESSION['wpsc_cart'])) {
  355. $GLOBALS['wpsc_cart'] = $_SESSION['wpsc_cart'];
  356. } else {
  357. $GLOBALS['wpsc_cart'] = unserialize($_SESSION['wpsc_cart']);
  358. }
  359. if(!is_object($GLOBALS['wpsc_cart']) || (get_class($GLOBALS['wpsc_cart']) != "wpsc_cart")) {
  360. $GLOBALS['wpsc_cart'] = new wpsc_cart;
  361. }
  362. } else {
  363. $GLOBALS['wpsc_cart'] = new wpsc_cart;
  364. }
  365. }
  366. $GLOBALS['wpsc_category_url_cache'] = get_option('wpsc_category_url_cache');
  367. //register_taxonomy('product_tag', 'product');
  368. }
  369. // first plugin hook in wordpress
  370. add_action('plugins_loaded','wpsc_initialisation', 0);
  371. function wpsc_register_post_types() {
  372. register_taxonomy('product_tag', 'wpsc-product');
  373. }
  374. add_action( 'init', 'wpsc_register_post_types', 8 ); // highest priority
  375. switch(get_option('cart_location')) {
  376. case 1:
  377. add_action('wp_list_pages','nzshpcrt_shopping_basket');
  378. break;
  379. case 2:
  380. add_action('the_content', 'nzshpcrt_shopping_basket' , 14);
  381. break;
  382. default:
  383. break;
  384. }
  385. add_action('plugins_loaded', 'widget_wp_shopping_cart_init', 10);
  386. // refresh page urls when permalinks are turned on or altered
  387. add_filter('mod_rewrite_rules', 'wpsc_refresh_page_urls');
  388. if(is_ssl()) {
  389. function wpsc_add_https_to_page_url_options($url) {
  390. return str_replace("http://", "https://", $url);
  391. }
  392. add_filter('option_product_list_url', 'wpsc_add_https_to_page_url_options');
  393. add_filter('option_shopping_cart_url', 'wpsc_add_https_to_page_url_options');
  394. add_filter('option_transact_url', 'wpsc_add_https_to_page_url_options');
  395. add_filter('option_user_account_url', 'wpsc_add_https_to_page_url_options');
  396. }
  397. /**
  398. * This serializes the shopping cart variable as a backup in case the unserialized one gets butchered by various things
  399. */
  400. if(!function_exists('wpsc_serialize_shopping_cart')){
  401. function wpsc_serialize_shopping_cart() {
  402. global $wpdb, $wpsc_start_time, $wpsc_cart, $wpsc_category_url_cache;
  403. if(is_object($wpsc_cart)) {
  404. $wpsc_cart->errors = array();
  405. }
  406. $_SESSION['wpsc_cart'] = serialize($wpsc_cart);
  407. $previous_category_url_cache = get_option('wpsc_category_url_cache');
  408. if($wpsc_category_url_cache != $previous_category_url_cache) {
  409. update_option('wpsc_category_url_cache', $wpsc_category_url_cache);
  410. }
  411. return true;
  412. }
  413. }
  414. add_action('shutdown','wpsc_serialize_shopping_cart');
  415. function wpsc_break_canonical_redirects($redirect_url, $requested_url) {
  416. global $wp_query;
  417. if(is_numeric($wp_query->query_vars['category_id'] )) {
  418. return false;
  419. }
  420. return $redirect_url;
  421. }
  422. add_filter('redirect_canonical', 'wpsc_break_canonical_redirects', 10, 2);
  423. /**
  424. * Update Notice
  425. *
  426. * Displays an update message below the auto-upgrade link in the WordPress admin
  427. * to notify users that they should check the upgrade information and changelog
  428. * before upgrading in case they need to may updates to their theme files.
  429. *
  430. * @package wp-e-commerce
  431. * @since 3.7.6.1
  432. */
  433. function wpsc_update_notice() {
  434. $info_title = __( 'Please Note', 'wpsc' );
  435. $info_text = sprintf( __( 'Before upgrading you should check the <a %s>upgrade information</a> and changelog as you may need to make updates to your template files.', 'wpsc' ), 'href="http://getshopped.org/resources/docs/upgrades/staying-current/" target="_blank"' );
  436. echo '<div style="border-top:1px solid #CCC; margin-top:3px; padding-top:3px; font-weight:normal;"><strong style="color:#CC0000">' . strip_tags( $info_title ) . '</strong>: ' . strip_tags( $info_text, '<br><a><strong><em><span>' ) . '</div>';
  437. }
  438. if ( is_admin() ) {
  439. add_action( 'in_plugin_update_message-' . plugin_basename( __FILE__ ), 'wpsc_update_notice' );
  440. }
  441. ?>