WP eCommerce - Version 3.8.13.5

Version Description

  • Fix: Fix potential reflexive XSS issue with add_query_arg() and remove_query_arg() usage. Update is highly recommended.
Download this release

Release Info

Developer JustinSainton
Plugin Icon 128x128 WP eCommerce
Version 3.8.13.5
Comparing to
See all releases

Code changes from version 3.9.2 to 3.8.13.5

Files changed (156) hide show
  1. images/google_checkout.gif +0 -0
  2. readme.md +39 -0
  3. readme.txt +143 -220
  4. wp-shopping-cart.php +44 -59
  5. wpsc-admin/admin-form-functions.php +0 -7
  6. wpsc-admin/admin.php +210 -362
  7. wpsc-admin/ajax-and-init.php +4 -21
  8. wpsc-admin/ajax.php +20 -103
  9. wpsc-admin/css/admin.css +768 -1263
  10. wpsc-admin/css/settingspage.css +0 -3
  11. wpsc-admin/css/xit.gif +0 -0
  12. wpsc-admin/db-upgrades/routines/1.php +25 -20
  13. wpsc-admin/db-upgrades/routines/10.php +0 -134
  14. wpsc-admin/db-upgrades/routines/11.php +0 -83
  15. wpsc-admin/db-upgrades/routines/12.php +0 -55
  16. wpsc-admin/db-upgrades/routines/13.php +0 -54
  17. wpsc-admin/db-upgrades/routines/14.php +0 -28
  18. wpsc-admin/db-upgrades/routines/2.php +98 -79
  19. wpsc-admin/db-upgrades/routines/3.php +14 -10
  20. wpsc-admin/db-upgrades/routines/6.php +0 -1
  21. wpsc-admin/db-upgrades/routines/8.php +3 -2
  22. wpsc-admin/db-upgrades/routines/9.php +0 -13
  23. wpsc-admin/db-upgrades/upgrade.php +10 -17
  24. wpsc-admin/db-upgrades/views/main.php +1 -1
  25. wpsc-admin/display-coupon-add.php +4 -9
  26. wpsc-admin/display-coupon-edit.php +6 -13
  27. wpsc-admin/display-coupons.php +5 -10
  28. wpsc-admin/display-debug.page.php +2 -2
  29. wpsc-admin/display-items.page.php +2 -3
  30. wpsc-admin/display-options-settings.page.php +1 -1
  31. wpsc-admin/display-sales-logs.php +21 -39
  32. wpsc-admin/display-update.page.php +10 -6
  33. wpsc-admin/display-upgrades.page.php +127 -40
  34. wpsc-admin/includes/coupon-list-table-class.php +8 -8
  35. wpsc-admin/includes/display-items-functions.php +510 -800
  36. wpsc-admin/includes/product-functions.php +106 -170
  37. wpsc-admin/includes/product-variation-list-table.class.php +9 -14
  38. wpsc-admin/includes/product-variations-page.class.php +27 -69
  39. wpsc-admin/includes/product-variations.page.php +5 -15
  40. wpsc-admin/includes/purchase-log-action-links.php +0 -482
  41. wpsc-admin/includes/purchase-log-list-table-class.php +13 -56
  42. wpsc-admin/includes/purchase-logs-page/item-details.php +51 -48
  43. wpsc-admin/includes/purchase-logs-page/list-table.php +2 -2
  44. wpsc-admin/includes/purchase-logs-page/upgrade.php +2 -2
  45. wpsc-admin/includes/save-data.functions.php +48 -60
  46. wpsc-admin/includes/settings-tabs/admin.php +2 -8
  47. wpsc-admin/includes/settings-tabs/checkout.php +3 -6
  48. wpsc-admin/includes/settings-tabs/gateway.php +6 -21
  49. wpsc-admin/includes/settings-tabs/general.php +4 -4
  50. wpsc-admin/includes/settings-tabs/import.php +42 -86
  51. wpsc-admin/includes/settings-tabs/marketing.php +0 -11
  52. wpsc-admin/includes/settings-tabs/shipping.php +7 -11
  53. wpsc-admin/includes/settings-tabs/taxes.php +5 -9
  54. wpsc-admin/includes/tax_and_shipping.php +1 -7
  55. wpsc-admin/includes/updating-functions.php +11 -15
  56. wpsc-admin/includes/walker-variation-checklist.php +5 -13
  57. wpsc-admin/init.php +127 -267
  58. wpsc-admin/js/admin.js +70 -244
  59. wpsc-admin/js/media.js +1 -10
  60. wpsc-admin/js/product-variations.js +1 -3
  61. wpsc-admin/js/purchase-log-action-links.js +0 -124
  62. wpsc-admin/js/settings-page.js +10 -21
  63. wpsc-admin/js/variations.js +1 -7
  64. wpsc-admin/js/wp-e-commerce-admin.js +0 -169
  65. wpsc-admin/media.php +1 -1
  66. wpsc-admin/settings-page.php +3 -12
  67. wpsc-admin/users.php +7 -6
  68. wpsc-components/marketplace-core-v1/library/Sputnik.php +11 -15
  69. wpsc-components/marketplace-core-v1/library/Sputnik/API.php +22 -32
  70. wpsc-components/marketplace-core-v1/library/Sputnik/API/Auth.php +4 -2
  71. wpsc-components/marketplace-core-v1/library/Sputnik/Admin.php +119 -133
  72. wpsc-components/marketplace-core-v1/library/Sputnik/List/Install.php +36 -41
  73. wpsc-components/marketplace-core-v1/library/Sputnik/Pointers.php +8 -8
  74. wpsc-components/marketplace-core-v1/library/Sputnik/ThemeUpgrader.php +1 -2
  75. wpsc-components/marketplace-core-v1/library/Sputnik/Theme_Upgrader.php +1 -2
  76. wpsc-components/marketplace-core-v1/library/Sputnik/Updater.php +4 -6
  77. wpsc-components/marketplace-core-v1/library/Sputnik/Upgrader.php +4 -5
  78. wpsc-components/marketplace-core-v1/library/Sputnik/View.php +3 -3
  79. wpsc-components/marketplace-core-v1/library/Sputnik/View/Account.php +13 -13
  80. wpsc-components/marketplace-core-v1/library/Sputnik/View/Auth.php +1 -1
  81. wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser.php +8 -8
  82. wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/Grid.php +47 -56
  83. wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/List.php +18 -18
  84. wpsc-components/marketplace-core-v1/library/Sputnik/View/Info.php +24 -24
  85. wpsc-components/marketplace-core-v1/library/Sputnik/View/Install.php +4 -4
  86. wpsc-components/marketplace-core-v1/library/Sputnik/View/Install/Skin.php +6 -6
  87. wpsc-components/marketplace-core-v1/library/Sputnik/View/Upgrade.php +4 -4
  88. wpsc-components/marketplace-core-v1/marketplace-core-v1.php +11 -2
  89. wpsc-components/marketplace-core-v1/static/admin.css +408 -396
  90. wpsc-components/marketplace-core-v1/static/admin.js +4 -6
  91. wpsc-components/marketplace-core-v1/static/jquery.masonry.js +10 -0
  92. wpsc-components/marketplace-core-v1/static/sputnik.css +17 -15
  93. wpsc-components/marketplace-core-v1/static/sputnik.js +1 -0
  94. wpsc-components/merchant-core-v2/helpers/admin.php +0 -31
  95. wpsc-components/merchant-core-v2/helpers/checkout.php +10 -36
  96. wpsc-components/merchant-core-v2/helpers/gateways.php +17 -41
  97. wpsc-components/merchant-core-v3/classes/http.php +0 -35
  98. wpsc-components/merchant-core-v3/classes/payment-gateway.php +0 -639
  99. wpsc-components/merchant-core-v3/gateways/dg.css +0 -72
  100. wpsc-components/merchant-core-v3/gateways/dg.js +0 -28
  101. wpsc-components/merchant-core-v3/gateways/manual.php +0 -46
  102. wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php +0 -638
  103. wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php +0 -713
  104. wpsc-components/merchant-core-v3/gateways/paypal-pro.php +0 -633
  105. wpsc-components/merchant-core-v3/gateways/php-merchant/common/exception.php +0 -37
  106. wpsc-components/merchant-core-v3/gateways/php-merchant/common/helpers.php +0 -15
  107. wpsc-components/merchant-core-v3/gateways/php-merchant/common/http-curl.php +0 -62
  108. wpsc-components/merchant-core-v3/gateways/php-merchant/common/http.php +0 -11
  109. wpsc-components/merchant-core-v3/gateways/php-merchant/common/php-merchant.php +0 -157
  110. wpsc-components/merchant-core-v3/gateways/php-merchant/common/response.php +0 -39
  111. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-digital-goods.php +0 -80
  112. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout-response.php +0 -124
  113. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout.php +0 -324
  114. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-ipn.php +0 -140
  115. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-pro-response.php +0 -68
  116. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-pro.php +0 -358
  117. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-response.php +0 -104
  118. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal.php +0 -86
  119. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/http-curl.php +0 -31
  120. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/php-merchant.php +0 -180
  121. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/test-accounts.php +0 -22
  122. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal-express-checkout.php +0 -552
  123. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal-ipn.php +0 -90
  124. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal.php +0 -126
  125. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/index.php +0 -60
  126. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/http-curl.php +0 -29
  127. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x1.php +0 -317
  128. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x2.php +0 -116
  129. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x3.php +0 -127
  130. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x4.php +0 -163
  131. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x1.php +0 -403
  132. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x2.php +0 -186
  133. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x3.php +0 -97
  134. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x4.php +0 -115
  135. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x5.php +0 -109
  136. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x6.php +0 -93
  137. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-express-checkout.php +0 -146
  138. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-pro-cert-x1.php +0 -140
  139. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-pro-cert-x2.php +0 -81
  140. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE +0 -399
  141. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/LICENSE +0 -502
  142. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/README +0 -102
  143. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/VERSION +0 -1
  144. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/authentication.php +0 -237
  145. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/autorun.php +0 -99
  146. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/browser.php +0 -1144
  147. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/collector.php +0 -122
  148. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/compatibility.php +0 -166
  149. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/cookies.php +0 -380
  150. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/default_reporter.php +0 -163
  151. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/detached.php +0 -96
  152. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/authentication_documentation.html +0 -378
  153. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/browser_documentation.html +0 -501
  154. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/docs.css +0 -121
  155. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/expectation_documentation.html +0 -476
  156. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/form_testing_documentation.html +0 -19
images/google_checkout.gif ADDED
Binary file
readme.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ WP e-Commerce
2
+ ============
3
+
4
+ About
5
+ -----
6
+
7
+ WP e-Commerce is a free open-source WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.
8
+
9
+ More details about this plugin features can be found on our website at [getshopped.org](http://getshopped.org/features/).
10
+
11
+ User documentation can be found at [docs.getshopped.org](http://docs.getshopped.org).
12
+
13
+ If you're looking for general user support, please submit your support request on [our community support forums](http://getshopped.org/forums/).
14
+
15
+ Development status
16
+ -------------------------
17
+
18
+ * The latest stable version is [3.8.13.4](http://wordpress.org/extend/plugins/wp-e-commerce).
19
+ * Active development version: 3.8.14-dev (branch [master](https://github.com/wp-e-commerce/WP-e-Commerce))
20
+ * [Roadmap for 3.8.14](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Roadmap)
21
+ * [3.8.14 tickets](https://github.com/wp-e-commerce/wp-e-commerce/issues?milestone=12&sort=updated&state=open)
22
+
23
+ How to contribute code
24
+ -----------------------------
25
+ * [Coding standards and code quality](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Coding-Standards-and-Code-Quality)
26
+ * [Submitting code](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Submitting-Code)
27
+ * [Code review](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Code-Review)
28
+ * [Merging pull requests](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Merging-Pull-Requests)
29
+
30
+ How to report issues
31
+ --------------------
32
+ * [Reporting a security issue](wiki/Reporting-a-security-issue)
33
+ * [What makes a perfect issue ticket?](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Creating-issue-tickets)
34
+ * [Issue labels and workflow](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Issue-Labels-and-Workflow)
35
+
36
+ Translating WPEC
37
+ ----------------
38
+ * [How to get involved](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Getting-involved-with-translation)
39
+ * [Current status](https://github.com/wp-e-commerce/wp-e-commerce/wiki/i18n-Status)
readme.txt CHANGED
@@ -1,28 +1,138 @@
1
- === WP eCommerce ===
2
- Contributors: JustinSainton, mufasa
3
- Donate link: https://wpecommerce.org
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
- Requires at least: 3.9
6
- Tested up to: 4.1
7
- Stable tag: 3.9.2
8
 
9
- WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
11
  == Description ==
12
 
13
- Since 2006, we've been helping entrepreneurs just like you realize their goal of selling online. Whether you're hoping to sell digital downloads, physical inventory, or subscriptions and memberships - with WP eCommerce, you're only minutes away from your next sale.
14
-
15
- * Make the plugin your own with CSS and HTML customizations
16
- * Learn quickly with our [video tutorials](http://docs.wpecommerce.org/category/resources/videos/)
17
- * Integration with [dozens of different payment gateways](http://wpecommerce.org/store/premium-plugins/)
18
- * Integrate with many popular WordPress plugins
19
- * Use built-in marketing tools to sell more
20
- * Shipping is easy with built in shipping tools and integration with popular couriers
21
- * Secure check-out with SSL
22
- * Manage your orders and catalogues with powerful built-in tools
23
- * Extend your eCommerce site with [additional modules](http://wpecommerce.org/store/premium-plugins/)
24
- * Integrate with WordPress multisite
25
- * With hundreds of available hooks, developers can make WP eCommerce do anything you can imagine
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  == Installation ==
28
 
@@ -36,174 +146,18 @@ After upgrading from earlier versions look for link "Update Store". This will up
36
 
37
  == Changelog ==
38
 
39
- = 3.9.2 =
40
-
41
- * Fix: Reverted pre_get_posts hook. See [#1444](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1444). This was causing issues with template redirection and selection on search templates.
42
- * Fix: Shipping conflict with target market restrictions on specific categories. See [#1711](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1711).
43
- * Fix: Taxes were broken following some refactoring of the admin saving callbacks.
44
- * Fix: Quick edit was overwriting variation SKUs and sale prices.
45
- * Fix: RSS Feed error.
46
- * Fix: Ensure flat rates settings are pre-populated by default, to avoid notices on new installs.
47
- * Fix: Forcing SSL when no SSL certificate is installed caused some core post type admin pages to fail to load.
48
- * Fix: In some circumstances, the javascript for country/region selection would fail. See [#1404](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1404)
49
-
50
- = 3.9.1 =
51
-
52
- * Fix: Disable 3.0 payment gateway API gateways. Will be re-enabled after more vigorous testing.
53
- * Fix: Check that $wpsc_cart->cart_items is an array, not an object.
54
- * Fix: Improve shipping method property checks in wpsc_cart class. See [#1683](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1683).
55
- * Fix: Add asterix class to required fields for PayPal Pro 2.0.
56
- * Fix: Ensure taxable checkbox can be unchecked. 3.9 regression. See [#1685](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1685).
57
- * Fix: Only show completed purchases in the user account area.
58
- * Fix: Use is_email(), rather than a faulty regex, for checkout email field validation.
59
- * Fix: More than a [handful of faulty variables](https://github.com/wp-e-commerce/WP-e-Commerce/commit/58f2d3ad9698ef496a27a701e5a926e412d55c05) were referenced in wpsc_coupons.
60
- * Fix: Function `wpsc_string_to_boolean` was essentially non functional.
61
- * Fix: Send country and state through to PayPal only if they actually exist.
62
- * Fix: Broken theme-engine activation routine. Would always fail, running 1.0 engine.
63
-
64
- = 3.9 =
65
-
66
- * Fix: Eliminate most usage of number-based inputs in product UI.
67
- * Fix: Fall back to product ID if SKU is not set for Google Analytics reporting.
68
- * Fix: Restored inadvertently removed filter, `wpsc_add_advanced_options`.
69
- * Fix: Ensure price entered for "Free Shipping" threshold is locale-aware.
70
- * Fix: Generally improved metadata saving routines for quick/bulk edit areas.
71
- * Fix: Ensure "Combination of product variants is not available" message is hidden from Grid View.
72
- * Fix: Don't require a shipping method to be selected if you qualify for free shipping.
73
- * Fix: When "Buy Now" button is used, it is now disabled if item is out of stock.
74
- * New: Introduced `wpsc_get_countries` and `wpsc_get_countries_array` filters.
75
- * New: Introduced `wpsc_google_analytics_pushed_product` filter.
76
- * New: Introduced `wpsc_get_downloadable_links` filter.
77
- * New: Added screen option for number of purchase logs to show on a page.
78
- * New: Introduced WPSC_Logging class. Based on WP_Logging.
79
- * New: Customers may now checkout with carts that have a value of $0.
80
- * New: Introduces `wpsc_is_free_cart` filter.
81
- * New: Added 2.0 theme engine component. Defaults off until the 4.0 release, but can be enabled via filter for testing.
82
- * New: Added marketplace component.
83
- * New: Added 3.0 payment gateway API component.
84
- * New: PayPal Digital Goods gateway, updated PayPal Express Checkout, PayPal Pro and Manual Payment gateways.
85
- * New: Product Tags now have proper body classes.
86
- * New: Meta updates, kind of a big deal: We're now using X.X.Y versioning (like WordPress) and we now have unit tests.
87
- * New: Introduce attachments method and filter for WPSC_Purchase_Log_Notification class.
88
- * New: Single Product pages now have ID-based body classes.
89
- * New: Supports Universal Analytics in Google Analytics.
90
- * New: Added `wpsc_checkout_fields` filter for filtering checkout form fields.
91
- * Change: Dates are now optional on coupons. Expiration, specifically, is no longer required. Validation is filterable via `wpsc_coupons_validate_coupon`.
92
- * Change: Refactored purchase log action links, introduced new API for adding links.
93
- * Change: Product page shortcodes, e.g. [productspage], are now stripped from the_excerpt(). Helpful for cleaner looking search results.
94
- * Change: Limit Google Product ID to 50 characters in Google Product Feed. Introduced `wpsc_google_product_feed_product_id`.
95
- * Change: When only one shipping rate is available, it will automatically be selected as the default rate.
96
-
97
- = 3.8.14.4 =
98
-
99
- * Fix: Significant security vulnerability whereby some admin actions were exploitable by unauthorized users. Props to Sucuri for the responsible disclosure.
100
- * Fix: Other less significant security hardening and minor code maintenance.
101
-
102
- = 3.8.14.3 =
103
-
104
- * Fix: Resolve PHP warning in stats logging class.
105
-
106
- = 3.8.14.2 =
107
-
108
- * Fix: Clear country cache automatically.
109
- * Fix: Fixed notices when using quick edit.
110
- * Fix: Fixed html in checkout form.
111
- * Fix: Fixed shipping results not being displayed.
112
- * Fix: Does not show errors when deprecated google checkout is used.
113
- * Fix: Makes sure countries are validated if mandatory.
114
- * Fix: Makes sure the payment gateway checks for first and last name.
115
- * Fix: Only output html for shipping error page.
116
- * Fix: Updated shipping calculator to check for new checkout information and made the calculator more efficient.
117
- * Fix: USPS shipping now works for servers that don't support curl.
118
- * Fix: Personalization forms are correctly initialized in database.
119
- * Fix: Display of products in admin product gallery will display in the order admins want them to.
120
- * New: Updated Polish and Russian language files.
121
- * New: Added filter wpsc_uncategorized_product_category to change uncategorized section.
122
- * New: New hook - wpsc_coupon_add_top and wpsc_coupon_add_bottom for the add coupon section.
123
- * New: New hook - wpsc_element_is_visible to check and see if an element is visible.
124
- * Change: Show region on shipping calculator.
125
- * Change: Billing was accidentally referred to as shipping when billing state and region was a drop down.
126
-
127
- = 3.8.14.1 =
128
-
129
- * Fix: For users with older (3.7.x and older) templates copied into their theme directory, we inadvertently broke the visibility of the shipping calculator.
130
- * Fix: Under similar circumstances, taxes would not properly calculate.
131
- * Fix: Ensured compatibility with the popular "Weight and Destination" shipping module. Note: You may need to go to your Target Markets and re-save the values there to properly flush the cache for this compatibility.
132
- * Fix: Edge case where $0.00 could be returned for a shipping rate.
133
- * Fix: Race condition on AJAX save while submitting purchase.
134
- * Fix: Restored proper functionality on digital downloads.
135
- * Fix: Ensure that UPS and USPS always return proper and expected values. Incrementally improved error handling here.
136
- * Fix: Ensure that shipping method is properly retained if checkout page is refreshed.
137
- * Change: Added "County" as the region label for the UK.
138
-
139
- = 3.8.14 =
140
- * Fix: Improved visitor profiles performance, new infrastructure does not use WordPress Users.
141
- * Fix: When page caching is being used, probability of empty or superfluous visitor profiles being created drastically diminished.
142
- * Fix: Send appropriate addresses to PayPal via PayPal Standard.
143
- * Fix: Ensure that sales tax is not added to non-tax items when using a coupon.
144
- * Fix: Ensure state text field is not visible at the same time as state dropdown.
145
- * Fix: Ensure shortcodes respect display type as overridden by categories. Note: Requires latest Gold Cart release.
146
- * Fix: Ensure that adding a new item to the cart after a coupon code properly reflects that coupon code.
147
- * Fix: Don't create cron events for unknown schedules.
148
- * Fix: Shipping options were disappearing when "same as billing address" were selected.
149
- * Fix: Protect against "Price From: " being zero if a sales price was set without a normal price.
150
- * Fix: Added programmatic and UX checks for conflict where grid/list view could show products with variations without the variation drop-downs, adding an improper product to the cart.
151
- * Fix: Improved shipping rate quote retrieval performance.
152
- * Fix: Sends proper tax amount to PayPal Standard when carts are aggregated.
153
- * Fix: Fixed pagination bug where improper number of paged links were returned.
154
- * Fix: Ensure UPS Environment test mode works.
155
- * Fix: Downloadable products were not being properly added as attachments.
156
- * Fix: "Shipping Same as Billing" could cause products to be shipped to countries which are not allowed.
157
- * Fix: Eliminate undefined index errors on sales log page when checkout fields are removed.
158
- * Fix: Address edge case where purchase notifications are not sent when there are multiple email fields in different checkout form sets.
159
- * Fix: Improved bbPress compatibility.
160
- * Fix: Ensure User Account pages are properly overridable in the template stack.
161
- * Fix: Properly escape classes for Buy Now button classes.
162
- * Fix: Fix IE8 javascript conflicts.
163
- * Fix: Shored up backwards compatibility for Session usage
164
- * Fix: Ensure cart items with variations that are out of stock (and stock limited) don't return a fatal error.
165
- * Fix: Address malformed XML output for shipping quotes from UPS and USPS.
166
- * Fix: Ensure PayPal Express does not show coupons as an empty line item when discounts are not used.
167
- * Fix: A redirection error on our wpsc_scale_image fallback was resolved.
168
- * Fix: Ensure only available countries are shown as available in PayPal Express.
169
- * Fix: Resolved issue whereby amounts over 1,000 (in a given currency) would be incorrectly sent to Google Analytics.
170
- * Fix: Shipping calculator uses information set in user account profile, if set.
171
- * Fix: When PATHINFO Permalinks ("Almost Pretty"), product pages would 404.
172
- * Fix: Ensure 3.7.x -> 3.8.x upgrade routine uses wpdb::prepare() properly.
173
- * New: AJAX API to get and set information about customers.
174
- * New: Visitor API to get and set information about current and past visits.
175
- * New: Introduced WPSC_Claimed_Stock class.
176
- * New: Introduced WPSC_Stats class.
177
- * New: Introduced WPSC_Product/WPSC_Products class.
178
- * New: Introduced WPSC_Countries / WPSC_Region class.
179
- * New: Totally revamped product editing and adding user interface.
180
- * New: Added new Purchase Meta API.
181
- * New: Some compatibility fixes for WordPress 3.9.
182
- * New: Improved extendibility of the Import Settings area.
183
- * New: Improved extendibility for our conditional coupon callbacks.
184
- * Change: Iterated upon WPSC_Country class.
185
- * Change: Improved UK Country Display.
186
- * Change: Improved upgrade routines for currencies and countries.
187
- * Change: Introduced filter for themeable packing slips.
188
- * Change: Modified calculation for total price to ensure coupons don't reduce shipping and tax.
189
- * Change: Improved Checkout workflow and UI.
190
- * Change: Fully remove Google Checkout from WP eCommerce, as it has been deprecated.
191
- * Change: Don't show transaction results to anyone but the purchaser
192
- * Change: Eliminated usage of dynamic CSS and javascript in front-end and admin.
193
- * Change: Couldn't use decimals in product's variation sale price.
194
- * Change: Tons of performance improvements to USPS and UPS.
195
- * Change: Add condition as parameter to wpsc_coupon_rule_property_options action.
196
- * Change: Improved security for our customer cookie hash.
197
- * Change: Don't default to base country of store in checkout fields.
198
- * Change: Taxes class previously regarded regions as unique, when they are not. We now check both region and country where applicable.
199
- * Change: By default, quantity boxes will be shown on new installs.
200
 
201
  = 3.8.13.3 =
202
- * Fix: Users disappear in Network Admin -> Users page (for multisite).
203
  * Fix: User counts are incorrect when there are thousands separators.
204
  * Fix: "Save Product Files" button doesn't like being clicked on.
205
 
206
-
207
  = 3.8.13.2 =
208
  * Fix: Anonymous customers should not be visible in admin UI.
209
  * Fix: Cronjob to purge anonymous customers doesn't work due to memory issues.
@@ -262,7 +216,7 @@ After upgrading from earlier versions look for link "Update Store". This will up
262
  * Change: Remove nusoap
263
  * Change: Improvements to Marketing admin panel
264
  * Change: Improvements to Products List Admin Page
265
- * Fix: WP eCommerce pagination breaks WordPress pagination
266
  * Fix: Wrong thumbnail size in Product Specials widget
267
  * Fix: Filtering by a category also shows all products in subcategories
268
  * Fix: admin.js throwing a Parse Error in Safari
@@ -433,7 +387,7 @@ After upgrading from earlier versions look for link "Update Store". This will up
433
  * Change: Default checkout shipping option to lowest shipping cost of all choices.
434
  * Fix: "Variation Controls" anchor in metabox leads nowhere.
435
  * Fix: AJAX code audit (security)
436
- * Fix: Activating WP eCommerce on a vanilla WordPress installation with pretty permalinks enabled messes up the rewrite rules.
437
  * Fix: Add a space after tilde character to avoid confusion in admin product list.
438
  * Fix: Add new variation sets and terms from Edit Product page doesn't work properly.
439
  * Fix: Additional description is double escaped in product edit page.
@@ -630,7 +584,7 @@ After upgrading from earlier versions look for link "Update Store". This will up
630
  * Fix: Fatal error when trying to include a non-existent admin file.
631
  * Fix: Hide Google Feed information from display
632
  * Fix: Incompatibility with Genesis framework in Product Edit page.
633
- * Fix: Make the WP eCommerce 3.8.x activation/installation routine much more efficient.
634
  * Fix: Mandatory fields in user_log_functions.php are not properly validated.
635
  * Fix: Memory improvement for productfeed.
636
  * Fix: Purchase logs have incorrect time if a timezone is specified in Settings->General.
@@ -776,42 +730,11 @@ After upgrading from earlier versions look for link "Update Store". This will up
776
 
777
  == Frequently Asked Questions ==
778
 
779
- = How do I customize WP eCommerce =
780
-
781
- First of all, you should check out the Presentation settings which are in the Settings -> Store page.
782
-
783
- For advanced users, all of our eCommerce templates and CSS can be moved into your active theme folder for customization. Less advanced users have [several fantastic WP eCommerce consultants](https://wpecommerce.org/hire-an-expert/) to get help from.
784
-
785
- = What payment gateways does WP eCommerce integrate with? =
786
-
787
- Our [Gold Cart plugin](https://wpecommerce.org/store/premium-plugins/gold-cart/) contains nearly a dozen payment gateway options, including Authorize.net, LinkPoint and DPS. Our [Mirijeh integration plugin](https://wpecommerce.org/store/premium-plugins/mijireh-99-payment-gateways-pack/) provides access to nearly one hundred different gateway options. Beyond that, we have individual integration plugins for [Braintree](https://wpecommerce.org/store/premium-plugins/braintree-payment-gateway/), [Stripe](https://wpecommerce.org/store/premium-plugins/stripe/), [Authorize.net SIM](https://wpecommerce.org/store/premium-plugins/authorize-net-sim-payment-gateway-for-wordpress/) and more.
788
-
789
- = I want to integrate a payment gateway that you don't support. Can you help with that? =
790
-
791
- Absolutely! We have a [growing list of trusted consultants](https://wpecommerce.org/hire-an-expert/) who would be happy to partner with you to build a custom gateway. Alternatively, you're more than welcome to request that we build it as a plugin or part of our core plugin. The more requests we get, the more likely we are to build it. If you happen to be a talented developer, we have a great documentation site with helpful information on building payment gateways
792
-
793
- = Which couriers does the plugin integrate with? =
794
-
795
- We have table rate, weight rate and flat rate shipping calculators.
796
-
797
- We also currently integrate with UPS, USPS, Australia Post and Shipwire for real-time shipping rates. We have a premium plugin for [FedEx](https://wpecommerce.org/store/premium-plugins/fedex-shipping-module/) as well.
798
-
799
- = Which multi-lingual plugins is WP eCommerce compatible with? =
800
-
801
- We currently provide basic support for WPML and qTranslate. We're excited about an up-and-coming multi-lingual project called [Babble](https://github.com/cftp/babble). We intend to fully and canonically support Babble as our primary multi-lingual partner in releases to come.
802
-
803
- = Which additional modules are available for use with WP eCommerce? =
804
-
805
- * [Gold Cart](https://wpecommerce.org/store/premium-plugins/gold-cart/) - adds more options, gateways and functionality to your store
806
- * [MP3 Audio Player](https://wpecommerce.org/store/premium-plugins/mp3-player-plugin/) - Preview audio clips on your website
807
- * [NextGen Gallery Buy Now Buttons](https://wpecommerce.org/store/premium-plugins/nextgen-gallery-buy-now-buttons/) - turns your NextGen gallery into an eCommerce solution
808
- * [Members Plugin](https://wpecommerce.org/store/premium-plugins/membership-subscriptions/) - Integrates with PayPal Standard and Authorize.Net, allows you to create a Subscription-Based Product, as well as a "Members-Only" website with paid access to restricted content.
809
-
810
- = How do you provide support? =
811
 
812
- For users who have purchased a premium plugin from us (or a have purchased a [premium support token](https://wpecommerce.org/store/premium-plugins/premium-support-token/)), we offer high-touch, 1-on-1 support from our trained support staff. If you submit a support request here, you'll get a helpful response within 24 hours or less (during business hours).
813
 
814
- For the rest of our users, we do our best to monitor the WordPress.org support forums and respond in as timely a manner as we are able. We appreciate the countless helpful volunteers who also take time to respond to forum posts here.
815
 
816
  == Screenshots ==
817
 
1
+ === WP e-Commerce ===
2
+ Contributors: mufasa, garyc40, JustinSainton
3
+ Donate link: http://getshopped.org
4
  Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
+ Requires at least: 3.7
6
+ Tested up to: 3.8
7
+ Stable tag: 3.8.13.5
8
 
9
+ WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.
10
 
11
  == Description ==
12
 
13
+ We make setting up an ecommerce shop easy, and with over 2.7 Million downloads, we have unparalleled experience.
14
+
15
+ Features:
16
+
17
+ = WordPress Integration =
18
+ * Easy to install WordPress plugin
19
+ * Works with any standards compliant WordPress theme
20
+ * Plays well with other Plugins
21
+ * Supports regular WordPress widgets, as well as a few snazzy ones of our own
22
+ * Utilizes shortcodes and template tags (just like WordPress)
23
+ * Works out-of-the-box with WordPress Multisite (make sure you use sub-domains with your Multisite setup)
24
+
25
+ = 100% Customizable =
26
+ * Use your own HTML & CSS and have complete control over the look and feel of your store
27
+ * Easy to modify templates
28
+
29
+ = Support =
30
+ * Lots of video tutorials
31
+ * Speedy response (through our premium forums)
32
+ * Access to instant support from our community of users
33
+
34
+ = Payment Gateways Integration =
35
+ * Manual Payment (checks/money orders)
36
+ * PayPal Payments Standard
37
+ * PayPal Payments Pro
38
+ * PayPal Express Checkout
39
+ * Google Wallet (Level 2)
40
+ * Chronopay
41
+ * PayPal Payflow Pro (available with Gold Cart)
42
+ * Authorize.net (available with Gold Cart)
43
+ * FirstData/LinkPoint (available with Gold Cart)
44
+ * eWay Payment (available with Gold Cart)
45
+ * iDEAL (available with Gold Cart)
46
+ * BluePay (available with Gold Cart)
47
+ * DPS (available with Gold Cart)
48
+ * Paystation (available with Gold Cart)
49
+ * SagePay (available with Gold Cart)
50
+ * Need a different gateway? We have documentation available for developing your own custom payment gateway
51
+
52
+ = Marketing =
53
+ * Flexible coupon/discount pricing rules
54
+ * Product specific sales
55
+ * Quantity discounts
56
+ * Free shipping options
57
+ * Multi-tier pricing for quantity discounts.
58
+ * Search Engine Friendly URLs
59
+ * New Products widget
60
+ * Cross-sells on product pages
61
+ * Google Sitemap and Google Analytics
62
+ * Uses the popular “Share This” button for easily promoting your products on popular social networking sites
63
+ * Integrates with Google Base
64
+
65
+ = Search Engine Optimization =
66
+ * 100% Search Engine Friendly
67
+ * Meta-information for products and categories
68
+ * RSS feeds for products and categories
69
+ * Integrates with Google (XML site maps and Google Merchant Centre)
70
+ * Integrates with the All in One SEO plugin for WordPress
71
+
72
+ = Internationalization Support =
73
+ * Basic support for popular multi-lingual plugins (qTranslate and WPML)
74
+ * Support for multiple currencies
75
+ * Ability to target specific countries
76
+
77
+ = Shipping =
78
+ * Integrates with UPS, USPS, Australia Post and Shipwire for real-time shipping rates
79
+ * Flexible built-in shipping rate calculators
80
+ * Domestic and global shipping rates
81
+ * Flat rate shipping
82
+ * Table rate shipping
83
+ * Weight rate shipping
84
+
85
+ = Checkout =
86
+ * SSL security support for orders on both front-end and back-end
87
+ * Checkout without account/Guest Checkout
88
+ * Shopping Cart with tax and shipping estimates
89
+ * Option to create account at beginning of checkout
90
+ * Fully customizable checkout page
91
+
92
+ = Managing Orders =
93
+ * Admin dashboard for sales overview
94
+ * Export orders and customers into CSV formats
95
+ * Order history with labels for order processing status
96
+ * Email notifications of orders
97
+ * Print invoices and packing slips
98
+
99
+ = Catalog Management =
100
+ * Single-page product data entry
101
+ * Ability to duplicate products
102
+ * Quickly edit your products from the store front
103
+ * Organize your products with hierarchical categories
104
+ * Batch import/export of catalog
105
+ * Product variation management
106
+ * Downloadable/Digital Products
107
+ * Support for donations
108
+ * Customer Personalized Products
109
+ * Media Manager with automatic image resizing
110
+ * Tax rates per location
111
+ * Basic inventory control
112
+
113
+ = Catalog Browsing =
114
+ * Cross-sells
115
+ * Product listing in list format
116
+ * Product listing in grid format (available with Gold Cart)
117
+ * Breadcrumbs
118
+ * Product Image Zoom-in Capability
119
+ * Stock Availability
120
+ * Multiple Images Per Product (available with Gold Cart)
121
+ * Product comments
122
+ * Filter by Product Tags
123
+ * New Products widget
124
+ * Features Products widget
125
+ * Live updating shopping cart (put it wherever you want)
126
+
127
+ = Additional Modules =
128
+ * Gold Cart & Grid Module – adds more options and functionality to your store
129
+ * Drop Shop – an incredibly snazzy way for buyers to add products to their cart, via a simple drag n drop process.
130
+ * Mp3 Audio Player – Preview audio clips on your website
131
+ * NextGen Gallery Buy Now Buttons – turns your NextGen gallery into an ecommerce solution
132
+ * Product Slider – Display your products in a new and fancy way
133
+ * Members Only Module – Create pay to view subscription sites
134
+
135
+ For more information visit [http://getshopped.org](http://getshopped.org "http://getshopped.org")
136
 
137
  == Installation ==
138
 
146
 
147
  == Changelog ==
148
 
149
+ = 3.8.13.5 =
150
+
151
+ * Fix: Fix potential reflexive XSS issue with add_query_arg() and remove_query_arg() usage. Update is _highly_ recommended.
152
+
153
+ = 3.8.13.4 =
154
+ * Fix: Update PayPal payment gateways to use HTTP 1.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
  = 3.8.13.3 =
157
+ * Fix: Users disappear in Network Admin -> Users page (for multisite)
158
  * Fix: User counts are incorrect when there are thousands separators.
159
  * Fix: "Save Product Files" button doesn't like being clicked on.
160
 
 
161
  = 3.8.13.2 =
162
  * Fix: Anonymous customers should not be visible in admin UI.
163
  * Fix: Cronjob to purge anonymous customers doesn't work due to memory issues.
216
  * Change: Remove nusoap
217
  * Change: Improvements to Marketing admin panel
218
  * Change: Improvements to Products List Admin Page
219
+ * Fix: WP e-Commerce pagination breaks WordPress pagination
220
  * Fix: Wrong thumbnail size in Product Specials widget
221
  * Fix: Filtering by a category also shows all products in subcategories
222
  * Fix: admin.js throwing a Parse Error in Safari
387
  * Change: Default checkout shipping option to lowest shipping cost of all choices.
388
  * Fix: "Variation Controls" anchor in metabox leads nowhere.
389
  * Fix: AJAX code audit (security)
390
+ * Fix: Activating WP e-Commerce on a vanilla WordPress installation with pretty permalinks enabled messes up the rewrite rules.
391
  * Fix: Add a space after tilde character to avoid confusion in admin product list.
392
  * Fix: Add new variation sets and terms from Edit Product page doesn't work properly.
393
  * Fix: Additional description is double escaped in product edit page.
584
  * Fix: Fatal error when trying to include a non-existent admin file.
585
  * Fix: Hide Google Feed information from display
586
  * Fix: Incompatibility with Genesis framework in Product Edit page.
587
+ * Fix: Make the WP e-Commerce 3.8.x activation/installation routine much more efficient.
588
  * Fix: Mandatory fields in user_log_functions.php are not properly validated.
589
  * Fix: Memory improvement for productfeed.
590
  * Fix: Purchase logs have incorrect time if a timezone is specified in Settings->General.
730
 
731
  == Frequently Asked Questions ==
732
 
733
+ = How do I customize WP e-Commerce =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734
 
735
+ First of all you should check out the Presentation settings which are in the Settings->Store page.
736
 
737
+ Advanced users can edit the CSS (and do just about anything). Not so advanced users can hire WP consultants developers and designers from [http://getshopped.org/resources/wp-consultants/](http://getshopped.org/resources/wp-consultants/ "http://getshopped.org/resources/wp-consultants/").
738
 
739
  == Screenshots ==
740
 
wp-shopping-cart.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
- * Plugin Name: WP eCommerce
4
- * Plugin URI: http://wpecommerce.org/
5
- * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
- * Version: 3.9.2
7
- * Author: WP eCommerce
8
- * Author URI: http://wpecommerce.org/
9
  **/
10
 
11
  /**
@@ -17,9 +17,8 @@
17
  */
18
  class WP_eCommerce {
19
  private $components = array(
20
- 'merchant' => array(),
21
- 'marketplace' => array(),
22
- 'theme-engine' => array(),
23
  );
24
 
25
  /**
@@ -28,7 +27,7 @@ class WP_eCommerce {
28
  * @uses add_action() Attaches to 'plugins_loaded' hook
29
  * @uses add_action() Attaches to 'wpsc_components' hook
30
  */
31
- public function __construct() {
32
  add_action( 'plugins_loaded' , array( $this, 'init' ), 8 );
33
  add_filter( 'wpsc_components', array( $this, '_register_core_components' ) );
34
  }
@@ -43,7 +42,7 @@ class WP_eCommerce {
43
  * @uses do_action() Calls 'wpsc_pre_init' which runs before WPEC initializes
44
  * @uses do_action() Calls 'wpsc_init' runs just after WPEC initializes
45
  */
46
- public function init() {
47
  // Previous to initializing
48
  do_action( 'wpsc_pre_init' );
49
 
@@ -61,28 +60,28 @@ class WP_eCommerce {
61
  * New WPSC components API.
62
  *
63
  * Allows for modular coupling of different functionalities within WPSC.
64
- * This is the way we'll be introducing cutting-edge APIs.
65
  *
66
  * @since 3.8.9.5
67
  *
68
- * @param array $components
69
- * @return array $components
70
  */
71
  public function _register_core_components( $components ) {
72
  $components['merchant']['core-v2'] = array(
73
- 'title' => __( 'WP eCommerce Merchant API v2', 'wpsc' ),
74
  'includes' =>
75
  WPSC_FILE_PATH . '/wpsc-components/merchant-core-v2/merchant-core-v2.php'
76
  );
77
 
78
- $components['merchant']['core-v3'] = array(
79
- 'title' => __( 'WP eCommerce Merchant API v3', 'wpsc' ),
80
  'includes' =>
81
- WPSC_FILE_PATH . '/wpsc-components/merchant-core-v3/merchant-core-v3.php'
82
  );
83
 
84
  $components['marketplace']['core-v1'] = array(
85
- 'title' => __( 'WP eCommerce Marketplace API v1', 'wpsc' ),
86
  'includes' =>
87
  WPSC_FILE_PATH . '/wpsc-components/marketplace-core-v1/marketplace-core-v1.php'
88
  );
@@ -91,35 +90,33 @@ class WP_eCommerce {
91
  }
92
 
93
  /**
94
- * Initialize the basic WP eCommerce constants
95
  *
96
  * @uses plugins_url() Retrieves url to plugins directory
97
  * @uses load_plugin_textdomain() Loads plugin transations strings
98
  * @uses plugin_basename() Gets the basename of a plugin (extracts the name of a plugin from its filename)
99
  * @uses do_action() Calls 'wpsc_started' which runs after WPEC has started
100
  */
101
- public function start() {
102
  // Set the core file path
103
  define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
104
 
105
  // Define the path to the plugin folder
106
  define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
107
- define( 'WPSC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
108
 
109
  // Define the URL to the plugin folder
110
- define( 'WPSC_FOLDER', dirname( WPSC_PLUGIN_BASENAME ) );
111
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
112
 
113
  //load text domain
114
- if ( ! load_plugin_textdomain( 'wpsc', false, '../languages/' ) ) {
115
- load_plugin_textdomain( 'wpsc', false, dirname( WPSC_PLUGIN_BASENAME ) . '/wpsc-languages/' );
116
- }
117
 
118
  // Finished starting
119
  do_action( 'wpsc_started' );
120
  }
121
 
122
- public function setup_table_names() {
123
  global $wpdb;
124
  $wpdb->wpsc_meta = WPSC_TABLE_META;
125
  $wpdb->wpsc_also_bought = WPSC_TABLE_ALSO_BOUGHT;
@@ -130,13 +127,11 @@ class WP_eCommerce {
130
  $wpdb->wpsc_currency_list = WPSC_TABLE_CURRENCY_LIST;
131
  $wpdb->wpsc_purchase_logs = WPSC_TABLE_PURCHASE_LOGS;
132
  $wpdb->wpsc_checkout_forms = WPSC_TABLE_CHECKOUT_FORMS;
 
 
133
  $wpdb->wpsc_product_rating = WPSC_TABLE_PRODUCT_RATING;
134
  $wpdb->wpsc_download_status = WPSC_TABLE_DOWNLOAD_STATUS;
135
  $wpdb->wpsc_submitted_form_data = WPSC_TABLE_SUBMITTED_FORM_DATA;
136
- $wpdb->wpsc_cart_itemmeta = WPSC_TABLE_CART_ITEM_META;
137
- $wpdb->wpsc_purchasemeta = WPSC_TABLE_PURCHASE_META;
138
- $wpdb->wpsc_visitors = WPSC_TABLE_VISITORS;
139
- $wpdb->wpsc_visitormeta = WPSC_TABLE_VISITOR_META;
140
  }
141
 
142
  /**
@@ -150,7 +145,7 @@ class WP_eCommerce {
150
  * @uses wpsc_core_constants_uploads() Set the upload related constants
151
  * @uses do_action() Calls 'wpsc_constants' which runs after the WPEC constants are defined
152
  */
153
- public function constants() {
154
  // Define globals and constants used by wp-e-commerce
155
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
156
 
@@ -185,25 +180,18 @@ class WP_eCommerce {
185
  * @uses apply_filters() Calls 'wpsc_components' private merchant components
186
  * @uses do_action() Calls 'wpsc_includes' which runs after WPEC files have been included
187
  */
188
- public function includes() {
189
- require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-util.php' );
190
- require_once( WPSC_FILE_PATH . '/wpsc-includes/customer.php' );
191
- require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-customer.php' );
192
- require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-visitor.php' );
193
- require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-cart-item.php' );
194
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
195
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
196
- require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
197
 
198
  $this->components = apply_filters( 'wpsc_components', $this->components );
199
 
200
  foreach ( $this->components as $type => $registered ) {
201
  foreach ( $registered as $component ) {
202
-
203
- if ( ! is_array( $component['includes'] ) ) {
204
  $component['includes'] = array( $component['includes' ] );
205
- }
206
-
207
  foreach ( $component['includes'] as $include ) {
208
  require_once( $include );
209
  }
@@ -230,7 +218,7 @@ class WP_eCommerce {
230
  * @uses wpsc_core_load_page_titles() Loads the core WPEC pagetitles
231
  * @uses do_action() Calls 'wpsc_loaded' which runs after WPEC is fully loaded
232
  */
233
- public function load() {
234
  // Before setup
235
  do_action( 'wpsc_pre_load' );
236
 
@@ -240,11 +228,9 @@ class WP_eCommerce {
240
  // Setup the core WPEC globals
241
  wpsc_core_setup_globals();
242
 
 
243
  add_action( 'init', '_wpsc_action_setup_customer', 1 );
244
 
245
- // WPEC is ready to use as soon as WordPress and customer is setup and loaded
246
- add_action( 'init', array( &$this, '_wpsc_fire_ready_action' ), 100 );
247
-
248
  // Load the purchase log statuses
249
  wpsc_core_load_purchase_log_statuses();
250
 
@@ -261,11 +247,6 @@ class WP_eCommerce {
261
  do_action( 'wpsc_loaded' );
262
  }
263
 
264
- public function _wpsc_fire_ready_action() {
265
- // WPEC is ready to use as soon as WordPress and customer is setup and loaded
266
- do_action( 'wpsc_ready' );
267
- }
268
-
269
  /**
270
  * WPEC Activation Hook
271
  *
@@ -273,22 +254,26 @@ class WP_eCommerce {
273
  * @uses wp_die() Kills loading and returns the HTML
274
  * @uses wpsc_install() Performs checks to see if this is a clean install or not
275
  */
276
- public function install() {
 
277
 
278
- if ( ! defined( 'WPSC_FILE_PATH' ) ) {
279
- define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
 
280
  }
281
-
282
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
283
  $this->constants();
284
  wpsc_install();
 
285
  }
286
 
287
  /**
288
- * Runs the WPEC deactivation routines.
 
289
  *
290
- * @uses wp_get_schedules() Retrieves all filtered WP_Cron recurrences
291
- * @uses wp_clear_scheduled_hook() Removes any hooks on WP_Cron
292
  */
293
  public function deactivate() {
294
  foreach ( wp_get_schedules() as $cron => $schedule ) {
1
  <?php
2
  /**
3
+ * Plugin Name: WP e-Commerce
4
+ * Plugin URI: http://getshopped.org/
5
+ * 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>
6
+ * Version: 3.8.13.5
7
+ * Author: Instinct Entertainment
8
+ * Author URI: http://getshopped.org/
9
  **/
10
 
11
  /**
17
  */
18
  class WP_eCommerce {
19
  private $components = array(
20
+ 'merchant' => array(),
21
+ 'marketplace' => array(),
 
22
  );
23
 
24
  /**
27
  * @uses add_action() Attaches to 'plugins_loaded' hook
28
  * @uses add_action() Attaches to 'wpsc_components' hook
29
  */
30
+ function __construct() {
31
  add_action( 'plugins_loaded' , array( $this, 'init' ), 8 );
32
  add_filter( 'wpsc_components', array( $this, '_register_core_components' ) );
33
  }
42
  * @uses do_action() Calls 'wpsc_pre_init' which runs before WPEC initializes
43
  * @uses do_action() Calls 'wpsc_init' runs just after WPEC initializes
44
  */
45
+ function init() {
46
  // Previous to initializing
47
  do_action( 'wpsc_pre_init' );
48
 
60
  * New WPSC components API.
61
  *
62
  * Allows for modular coupling of different functionalities within WPSC.
63
+ * This is the way we'll be introducing cutting-edge APIs
64
  *
65
  * @since 3.8.9.5
66
  *
67
+ * @param array $components
68
+ * @return array $components
69
  */
70
  public function _register_core_components( $components ) {
71
  $components['merchant']['core-v2'] = array(
72
+ 'title' => __( 'WP e-Commerce Merchant API v2', 'wpsc' ),
73
  'includes' =>
74
  WPSC_FILE_PATH . '/wpsc-components/merchant-core-v2/merchant-core-v2.php'
75
  );
76
 
77
+ $components['theme-engine']['core-v1'] = array(
78
+ 'title' => __( 'WP e-Commerce Theme Engine v1', 'wpsc' ),
79
  'includes' =>
80
+ WPSC_FILE_PATH . '/wpsc-components/theme-engine-v1/theme-engine-v1.php'
81
  );
82
 
83
  $components['marketplace']['core-v1'] = array(
84
+ 'title' => __( 'WP e-Commerce Marketplace API v1', 'wpsc' ),
85
  'includes' =>
86
  WPSC_FILE_PATH . '/wpsc-components/marketplace-core-v1/marketplace-core-v1.php'
87
  );
90
  }
91
 
92
  /**
93
+ * Initialize the basic WPEC constants
94
  *
95
  * @uses plugins_url() Retrieves url to plugins directory
96
  * @uses load_plugin_textdomain() Loads plugin transations strings
97
  * @uses plugin_basename() Gets the basename of a plugin (extracts the name of a plugin from its filename)
98
  * @uses do_action() Calls 'wpsc_started' which runs after WPEC has started
99
  */
100
+ function start() {
101
  // Set the core file path
102
  define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
103
 
104
  // Define the path to the plugin folder
105
  define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
 
106
 
107
  // Define the URL to the plugin folder
108
+ define( 'WPSC_FOLDER', dirname( plugin_basename( __FILE__ ) ) );
109
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
110
 
111
  //load text domain
112
+ if ( ! load_plugin_textdomain( 'wpsc', false, '../languages/' ) )
113
+ load_plugin_textdomain( 'wpsc', false, dirname( plugin_basename( __FILE__ ) ) . '/wpsc-languages/' );
 
114
 
115
  // Finished starting
116
  do_action( 'wpsc_started' );
117
  }
118
 
119
+ function setup_table_names() {
120
  global $wpdb;
121
  $wpdb->wpsc_meta = WPSC_TABLE_META;
122
  $wpdb->wpsc_also_bought = WPSC_TABLE_ALSO_BOUGHT;
127
  $wpdb->wpsc_currency_list = WPSC_TABLE_CURRENCY_LIST;
128
  $wpdb->wpsc_purchase_logs = WPSC_TABLE_PURCHASE_LOGS;
129
  $wpdb->wpsc_checkout_forms = WPSC_TABLE_CHECKOUT_FORMS;
130
+ $wpdb->wpsc_cart_itemmeta = WPSC_TABLE_CART_ITEM_META; // required for _get_meta_table()
131
+ $wpdb->wpsc_cart_item_meta = WPSC_TABLE_CART_ITEM_META;
132
  $wpdb->wpsc_product_rating = WPSC_TABLE_PRODUCT_RATING;
133
  $wpdb->wpsc_download_status = WPSC_TABLE_DOWNLOAD_STATUS;
134
  $wpdb->wpsc_submitted_form_data = WPSC_TABLE_SUBMITTED_FORM_DATA;
 
 
 
 
135
  }
136
 
137
  /**
145
  * @uses wpsc_core_constants_uploads() Set the upload related constants
146
  * @uses do_action() Calls 'wpsc_constants' which runs after the WPEC constants are defined
147
  */
148
+ function constants() {
149
  // Define globals and constants used by wp-e-commerce
150
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
151
 
180
  * @uses apply_filters() Calls 'wpsc_components' private merchant components
181
  * @uses do_action() Calls 'wpsc_includes' which runs after WPEC files have been included
182
  */
183
+ function includes() {
184
+ require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-init.php' );
 
 
 
 
185
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
186
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
187
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
188
 
189
  $this->components = apply_filters( 'wpsc_components', $this->components );
190
 
191
  foreach ( $this->components as $type => $registered ) {
192
  foreach ( $registered as $component ) {
193
+ if ( ! is_array( $component['includes'] ) )
 
194
  $component['includes'] = array( $component['includes' ] );
 
 
195
  foreach ( $component['includes'] as $include ) {
196
  require_once( $include );
197
  }
218
  * @uses wpsc_core_load_page_titles() Loads the core WPEC pagetitles
219
  * @uses do_action() Calls 'wpsc_loaded' which runs after WPEC is fully loaded
220
  */
221
+ function load() {
222
  // Before setup
223
  do_action( 'wpsc_pre_load' );
224
 
228
  // Setup the core WPEC globals
229
  wpsc_core_setup_globals();
230
 
231
+ // Setup the customer ID just in case to make sure it's set up correctly
232
  add_action( 'init', '_wpsc_action_setup_customer', 1 );
233
 
 
 
 
234
  // Load the purchase log statuses
235
  wpsc_core_load_purchase_log_statuses();
236
 
247
  do_action( 'wpsc_loaded' );
248
  }
249
 
 
 
 
 
 
250
  /**
251
  * WPEC Activation Hook
252
  *
254
  * @uses wp_die() Kills loading and returns the HTML
255
  * @uses wpsc_install() Performs checks to see if this is a clean install or not
256
  */
257
+ function install() {
258
+ global $wp_version;
259
 
260
+ if ( ( float ) $wp_version < 3.0 ) {
261
+ deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourselves
262
+ 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 ) );
263
  }
264
+ define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
265
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
266
  $this->constants();
267
  wpsc_install();
268
+
269
  }
270
 
271
  /**
272
+ * Runs the WPEC deactivation routines which basically just removes the cron
273
+ * jobs that WPEC has set.
274
  *
275
+ * @uses wp_get_schedules() Retrieves all filtered Cron recurrences
276
+ * @uses wp_clear_scheduled_hook() Removes any hooks on cron
277
  */
278
  public function deactivate() {
279
  foreach ( wp_get_schedules() as $cron => $schedule ) {
wpsc-admin/admin-form-functions.php CHANGED
@@ -1,11 +1,4 @@
1
  <?php
2
- /**
3
- * The Admin Form Functions
4
- *
5
- * These are the functions that power administrative forms in the WordPress admin
6
- *
7
- * @package wp-e-commerce
8
- */
9
  function coupon_edit_form($coupon) {
10
 
11
  $conditions = maybe_unserialize($coupon['condition']);
1
  <?php
 
 
 
 
 
 
 
2
  function coupon_edit_form($coupon) {
3
 
4
  $conditions = maybe_unserialize($coupon['condition']);
wpsc-admin/admin.php CHANGED
@@ -25,6 +25,7 @@ require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
25
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
26
  require_once( WPSC_FILE_PATH . '/wpsc-admin/db-upgrades/upgrade.php' );
27
  require_once( WPSC_FILE_PATH . '/wpsc-admin/media.php' );
 
28
 
29
  if ( ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( $_SESSION['wpsc_activate_debug_page'] == true ) ) || ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( constant( 'WPSC_ADD_DEBUG_PAGE' ) == true ) ) )
30
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
@@ -33,10 +34,6 @@ if ( ! get_option( 'wpsc_checkout_form_sets' ) ) {
33
  $form_sets = array( __( 'Default Checkout Forms', 'wpsc' ) );
34
  update_option( 'wpsc_checkout_form_sets', $form_sets );
35
  }
36
-
37
- // if we add and wpec admin javascript will add the localizations
38
- add_filter( 'wpsc_javascript_localizations', '_wpsc_admin_localizations', 1 );
39
-
40
  /**
41
  * wpsc_query_vars_product_list sets the ordering for the edit-products page list
42
  *
@@ -88,7 +85,7 @@ function wpsc_admin_edit_posts_orderby( $orderby_sql ) {
88
  add_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );
89
 
90
  /**
91
- * setting the product & variations per page screen option to between 1 and 999
92
  *
93
  * @since 3.8
94
  * @access public
@@ -101,7 +98,7 @@ add_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );
101
  * @return $value after changes...
102
  */
103
  function wpsc_set_screen_option($status, $option, $value){
104
- if( in_array($option, array ("edit_wpsc_variation_per_page","edit_wpsc_product_per_page", "wpsc_purchases_per_page" )) ){
105
  if ( "edit_wpsc_variation_per_page" == $option ){
106
  global $user_ID;
107
  update_user_option($user_ID,'edit_wpsc-variation_per_page',$value);
@@ -131,7 +128,7 @@ function wpsc_drag_and_drop_ordering($per_page, $post_type){
131
  return $per_page;
132
  }
133
  add_filter( 'request', 'wpsc_query_vars_product_list' );
134
- add_filter( 'edit_posts_per_page' , 'wpsc_drag_and_drop_ordering', 10, 2 );
135
 
136
  /**
137
  * Checks whether to display or hide the update wp-e-commerce link
@@ -262,9 +259,6 @@ function wpsc_admin_pages() {
262
  add_action( 'load-post.php' , 'wpsc_add_help_tabs' );
263
  add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
264
  add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );
265
-
266
- // screen options on Sales Log
267
- add_action( 'load-' . $purchase_logs_page , 'wpsc_add_purchase_logs_screen_option' );
268
  }
269
 
270
  /**
@@ -354,7 +348,7 @@ function wpsc_add_help_tabs() {
354
  $content = '<p><strong>' . __( 'For More Information', 'wpsc' ) . '</strong></p>';
355
  $links = array();
356
  foreach( $tab['links'] as $link => $link_title ) {
357
- $link = 'http://docs.wpecommerce.org/' . $link;
358
  $links[] = '<a target="_blank" href="' . esc_url( $link ) . '">' . esc_html( $link_title ) . '</a>';
359
  }
360
  $content .= '<p>' . implode( '<br />', $links ) . '</p>';
@@ -368,24 +362,6 @@ function wpsc_add_help_tabs() {
368
  }
369
  }
370
 
371
- /**
372
- * This function allows change in number of purchase logs shown on Sales Log (Screen Options).
373
- *
374
- * @since 3.9
375
- * @access public
376
- *
377
- * @uses add_screen_option()
378
- */
379
- function wpsc_add_purchase_logs_screen_option(){
380
-
381
- // setup Screen Option for purchase logs per page
382
- add_screen_option( 'per_page', array(
383
- 'label' => __("Sales Orders", 'wpsc'),
384
- 'default' => 20,
385
- 'option' => 'wpsc_purchases_per_page'
386
- ) );
387
- }
388
-
389
  /**
390
  * Includes purchase logs CSS and JS
391
  *
@@ -395,9 +371,6 @@ function wpsc_add_purchase_logs_screen_option(){
395
  * @uses wp_localize_script() Adds noncing and other data to the logs script
396
  */
397
  function wpsc_admin_include_purchase_logs_css_and_js() {
398
-
399
- _wpsc_enqueue_wp_e_commerce_admin();
400
-
401
  wp_enqueue_script( 'wp-e-commerce-purchase-logs', WPSC_URL . '/wpsc-admin/js/purchase-logs.js', array( 'jquery' ), WPSC_VERSION . '.' . WPSC_MINOR_VERSION );
402
  wp_localize_script( 'wp-e-commerce-purchase-logs', 'WPSC_Purchase_Logs_Admin', array(
403
  'nonce' => wp_create_nonce( 'wpsc_purchase_logs' ),
@@ -408,16 +381,8 @@ function wpsc_admin_include_purchase_logs_css_and_js() {
408
  'sent_message' => _x( 'Email Sent!', 'sending tracking email for purchase log', 'wpsc' ),
409
  'current_view' => empty( $_REQUEST['status'] ) ? 'all' : $_REQUEST['status'],
410
  'current_filter' => empty( $_REQUEST['m'] ) ? '' : $_REQUEST['m'],
411
- 'current_page' => empty( $_REQUEST['paged'] ) ? '' : $_REQUEST['paged'],
412
- ) );
413
-
414
- // Purchase Log Action Links
415
- wp_enqueue_script( 'wpsc-purchase-log-action-links', WPSC_URL . '/wpsc-admin/js/purchase-log-action-links.js', array( 'jquery' ), WPSC_VERSION . '.' . WPSC_MINOR_VERSION );
416
- wp_localize_script( 'wpsc-purchase-log-action-links', 'WPSC_Purchase_Log_Action_Links', array(
417
- 'purchase_log_action_link_nonce' => _wpsc_create_ajax_nonce( 'purchase_log_action_link' ),
418
- 'log_id' => empty( $_REQUEST['id'] ) ? '' : absint( $_REQUEST['id'] )
419
  ) );
420
-
421
  }
422
 
423
  /**
@@ -459,7 +424,7 @@ function wpsc_display_purchase_logs_page() {
459
  * @uses admin_url() Retrieves URL to the WordPress admin
460
  */
461
  function wpsc_product_log_rss_feed() {
462
- echo "<link type='application/rss+xml' href='" . add_query_arg( array( 'rss' => 'true', 'rss_key' => 'key', 'action' => 'purchase_log', 'type' => 'rss' ), admin_url( 'index.php' ) ) . "' title='" . esc_attr__( 'WP eCommerce Purchase Log RSS', 'wpsc' ) . "' rel='alternate' />";
463
  }
464
 
465
  /**
@@ -471,26 +436,19 @@ function wpsc_product_log_rss_feed() {
471
  function wpsc_admin_include_coupon_js() {
472
 
473
  // Variables
474
- $version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
475
-
476
- // global js
477
- _wpsc_enqueue_wp_e_commerce_admin();
478
 
479
  // Coupon CSS
480
  wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
481
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
482
 
483
  // Coupon JS
 
484
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
485
  wp_enqueue_script( 'jquery-ui-datepicker' );
486
- wp_enqueue_style( 'jquery-ui-datepicker' );
487
-
488
  wp_enqueue_script( 'wp-e-commerce-admin_legacy', WPSC_URL . '/wpsc-admin/js/admin-legacy.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-datepicker' ), $version_identifier );
489
 
490
- $admin_color = get_user_option( 'admin_color' );
491
- $scheme = 'classic' === $admin_color ? $admin_color : 'fresh';
492
-
493
- wp_enqueue_style( 'wpsc-jquery-ui-datepicker', WPSC_URL . '/wpsc-admin/css/jquery.ui.datepicker-' . $scheme . '.css', false, $version_identifier );
494
  }
495
 
496
  /**
@@ -503,9 +461,6 @@ function wpsc_admin_include_coupon_js() {
503
  * @uses wp_enqueue_style() Includes and prints out the CSS for the WPEC options page
504
  */
505
  function wpsc_admin_include_optionspage_css_and_js() {
506
-
507
- _wpsc_enqueue_wp_e_commerce_admin();
508
-
509
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
510
  wp_enqueue_script( 'wp-e-commerce-admin-settings-page', WPSC_URL . '/wpsc-admin/js/settings-page.js', array( 'jquery-query' ), $version_identifier );
511
 
@@ -542,18 +497,24 @@ function wpsc_meta_boxes() {
542
  //if a variation page do not show these metaboxes
543
  if ( is_object( $post ) && $post->post_parent == 0 ) {
544
  add_meta_box( 'wpsc_product_variation_forms' , __( 'Variations', 'wpsc' ) , 'wpsc_product_variation_forms' , $pagename, 'normal', 'high' );
 
545
  } else if( is_object( $post ) && $post->post_status == "inherit" ) {
546
  remove_meta_box( 'tagsdiv-product_tag' , 'wpsc-product', 'core' );
 
547
  remove_meta_box( 'wpsc_product_categorydiv' , 'wpsc-product', 'core' );
548
  }
549
 
550
- add_meta_box( 'wpsc_price_control_forms', __('Product Pricing', 'wpsc'), 'wpsc_price_control_forms', $pagename, 'side', 'low' );
551
- add_meta_box( 'wpsc_stock_control_forms', __('Stock Inventory', 'wpsc'), 'wpsc_stock_control_forms', $pagename, 'side', 'low' );
 
552
  add_meta_box( 'wpsc_product_taxes_forms', __('Taxes', 'wpsc'), 'wpsc_product_taxes_forms', $pagename, 'side', 'low' );
553
- add_meta_box( 'wpsc_product_delivery_forms', __('Product Delivery', 'wpsc'), 'wpsc_product_delivery_forms', $pagename, 'normal', 'high' );
554
- add_meta_box( 'wpsc_product_details_forms', __('Product Details', 'wpsc'), 'wpsc_product_details_forms', $pagename, 'normal', 'high' );
555
- }
556
 
 
 
 
 
557
  add_action( 'admin_footer', 'wpsc_meta_boxes' );
558
  add_action( 'admin_enqueue_scripts', 'wpsc_admin_include_css_and_js_refac' );
559
 
@@ -574,6 +535,9 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
574
 
575
  $current_screen = get_current_screen();
576
 
 
 
 
577
  if ( 'dashboard_page_wpsc-sales-logs' == $current_screen->id ) {
578
  // jQuery
579
  wp_enqueue_script( 'jquery' );
@@ -591,10 +555,8 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
591
  $pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
592
 
593
  if ( ( in_array( $pagehook, $pages ) && $post_type == 'wpsc-product' ) || $current_screen->id == 'edit-wpsc_product_category' || $current_screen->id == 'dashboard_page_wpsc-sales-logs' || $current_screen->id == 'dashboard_page_wpsc-purchase-logs' || $current_screen->id == 'settings_page_wpsc-settings' || $current_screen->id == 'wpsc-product_page_wpsc-edit-coupons' || $current_screen->id == 'edit-wpsc-variation' || $current_screen->id == 'wpsc-product-variations-iframe' || ( $pagehook == 'media-upload-popup' && get_post_type( $_REQUEST['post_id'] ) == 'wpsc-product' ) ) {
594
-
595
- _wpsc_enqueue_wp_e_commerce_admin();
596
-
597
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
 
598
  wp_enqueue_script( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/js/admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier, false );
599
  wp_enqueue_script( 'wpsc-sortable-table', WPSC_URL . '/wpsc-admin/js/sortable-table.js', array( 'jquery' ) );
600
 
@@ -609,37 +571,25 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
609
  );
610
  }
611
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
612
-
613
- static $_wpsc_admin_l10n_loaded;
614
-
615
- if ( ! $_wpsc_admin_l10n_loaded ) {
616
- // Localize scripts
617
- wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
618
- 'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
619
- 'save_product_order_nonce' => _wpsc_create_ajax_nonce( 'save_product_order' ),
620
- 'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};',
621
- 'empty_coupon' => esc_html__( 'Please enter a coupon code.', 'wpsc' ),
622
- 'bulk_edit_no_vars' => esc_html__( 'Quick Edit options are limited when editing products that have variations. You will need to edit the variations themselves.', 'wpsc' ),
623
- 'wpsc_core_images_url' => WPSC_CORE_IMAGES_URL,
624
- 'variation_parent_swap' => esc_html_x( 'New Variation Set', 'Variation taxonomy parent', 'wpsc' ),
625
- /* translators : This string is prepended to the 'New Variation Set' string */
626
- 'variation_helper_text' => esc_html_x( 'Choose the Variation Set you want to add variants to. If you\'re creating a new variation set then select', 'Variation helper text', 'wpsc' ),
627
- 'variations_tutorial' => esc_html__( 'Variations allow you to create options for your products. For example, if you\'re selling T-Shirts, they will generally have a "Size" option. Size will be the Variation Set name, and it will be a "New Variant Set". You will then create variants (small, medium, large) which will have the "Variation Set" of Size. Once you have made your set you can use the table on the right to manage them (edit, delete). You will be able to order your variants by dragging and dropping them within their Variation Set.', 'wpsc' ),
628
- /* translators : These strings are dynamically inserted as a drop-down for the Coupon comparison conditions */
629
- 'coupons_compare_or' => esc_html_x( 'OR' , 'Coupon comparison logic', 'wpsc' ),
630
- 'coupons_compare_and' => esc_html_x( 'AND' , 'Coupon comparison logic', 'wpsc' ),
631
- 'meta_downloads_plural' => __( ' downloads', 'live preview for downloads metabox', 'wpsc' ),
632
- 'meta_downloads_singular' => __( ' download' , 'live preview for downloads metabox', 'wpsc' ),
633
- 'wpsc_inline_css_error' => __( 'It is not possible to enable the inline CSS without also enabling the common CSS.' )
634
- ) );
635
-
636
- $_wpsc_admin_l10n_loaded = true;
637
- }
638
-
639
  }
640
  if ( $pagehook == 'wpsc-product-variations-iframe' ) {
641
- _wpsc_enqueue_wp_e_commerce_admin();
642
-
643
  wp_enqueue_script( 'wp-e-commerce-product-variations', WPSC_URL . '/wpsc-admin/js/product-variations.js', array( 'jquery' ), $version_identifier );
644
  wp_localize_script( 'wp-e-commerce-product-variations', 'WPSC_Product_Variations', array(
645
  'product_id' => $_REQUEST['product_id'],
@@ -648,11 +598,8 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
648
  }
649
 
650
  if ( $pagehook == 'media-upload-popup' ) {
651
-
652
  $post = get_post( $_REQUEST['post_id'] );
653
  if ( $post->post_type == 'wpsc-product' && $post->post_parent ) {
654
- _wpsc_enqueue_wp_e_commerce_admin();
655
-
656
  wp_dequeue_script( 'set-post-thumbnail' );
657
  wp_enqueue_script( 'wpsc-set-post-thumbnail', WPSC_URL . '/wpsc-admin/js/set-post-thumbnail.js', array( 'jquery', 'wp-e-commerce-admin' ), $version_identifier );
658
  wp_localize_script( 'wpsc-set-post-thumbnail', 'WPSC_Set_Post_Thumbnail', array(
@@ -669,82 +616,118 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
669
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
670
  }
671
 
672
-
673
  /**
674
- * Adds admin javascript to the wp-e-commerce-admin javascript
675
- *
676
- * @since 3.8.14
677
- *
678
- * @param array array containing key value pairs, keys are turned into javascript globals with thier associated values
679
  *
 
680
  */
681
- function _wpsc_admin_localizations( $localizations ) {
 
 
 
 
682
 
683
- $hidden_boxes = get_option( 'wpsc_hidden_box' );
684
- $hidden_boxes = implode( ',', (array)$hidden_boxes );
685
 
686
- $form_types_option = get_option( 'wpsc_checkout_form_fields' );
687
- if ( ! $form_types_option || ! is_array( $form_types_option ) ) {
688
- $form_types_option = array();
689
- }
690
-
691
- $unique_names_option = get_option( 'wpsc_checkout_unique_names' );
692
- if ( ! $unique_names_option || ! is_array( $unique_names_option ) ) {
693
- $unique_names_option = array();
694
- }
695
 
696
  $form_types = '';
697
- foreach ( $form_types_option as $form_type ) {
698
- $form_types .= '<option value="' . $form_type . '">' . $form_type . '</option>';
699
  }
700
 
701
- $unique_names = '<option value="-1">' . __( 'Select a Unique Name', 'wpsc' ) . '</option>';
702
- foreach ( $unique_names_option as $unique_name ) {
703
- $unique_names .= '<option value="' . $unique_name . '">' . $unique_name . '</option>';
704
  }
705
 
706
- $localizations['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
707
- $localizations['hidden_boxes'] = '"' . esc_js( $hidden_boxes ) . '"';
708
- $localizations['IS_WP27'] = '"' . esc_js( IS_WP27 ) . '"';
709
- $localizations['TXT_WPSC_DELETE'] = '"' . esc_js( __( 'Delete', 'wpsc' ) ) . '"';
710
- $localizations['TXT_WPSC_TEXT'] = '"' . esc_js( __( 'Text', 'wpsc' ) ) . '"';
711
- $localizations['TXT_WPSC_EMAIL'] = '"' . esc_js( __( 'Email', 'wpsc' ) ) . '"';
712
- $localizations['TXT_WPSC_COUNTRY'] = '"' . esc_js( __( 'Country', 'wpsc' ) ) . '"';
713
- $localizations['TXT_WPSC_TEXTAREA'] = '"' . esc_js( __( 'Textarea', 'wpsc' ) ) . '"';
714
- $localizations['TXT_WPSC_HEADING'] = '"' . esc_js( __( 'Heading', 'wpsc' ) ) . '"';
715
- $localizations['TXT_WPSC_COUPON'] = '"' . esc_js( __( 'Coupon', 'wpsc' ) ) . '"';
716
-
717
- $localizations['HTML_FORM_FIELD_TYPES'] = '"' . esc_js( $form_types ) . '"';
718
- $localizations['HTML_FORM_FIELD_UNIQUE_NAMES'] = '"' . esc_js( $unique_names ) . '"';
719
-
720
- $localizations['TXT_WPSC_LABEL'] = '"' . esc_js( __( 'Label', 'wpsc' ) ) . '"';
721
- $localizations['TXT_WPSC_LABEL_DESC'] = '"' . esc_js( __( 'Label Description', 'wpsc' ) ) . '"';
722
- $localizations['TXT_WPSC_ITEM_NUMBER'] = '"' . esc_js( __( 'Item Number', 'wpsc' ) ) . '"';
723
- $localizations['TXT_WPSC_LIFE_NUMBER'] = '"' . esc_js( __( 'Life Number', 'wpsc' ) ) . '"';
724
- $localizations['TXT_WPSC_PRODUCT_CODE'] = '"' . esc_js( __( 'Product Code', 'wpsc' ) ) . '"';
725
- $localizations['TXT_WPSC_PDF'] = '"' . esc_js( __( 'PDF', 'wpsc' ) ) . '"';
726
-
727
- $localizations['TXT_WPSC_AND_ABOVE'] = '"' . esc_js( __( ' and above', 'wpsc' ) ) . '"';
728
- $localizations['TXT_WPSC_IF_PRICE_IS'] = '"' . esc_js( __( 'If price is ', 'wpsc' ) ) . '"';
729
- $localizations['TXT_WPSC_IF_WEIGHT_IS'] = '"' . esc_js( __( 'If weight is ', 'wpsc' ) ) . '"';
730
-
731
- // we only want to add these localizations once, it should happen on the first admin script load
732
- remove_filter( 'wpsc_javascript_localizations', '_wpsc_admin_localizations', 1 );
733
-
734
- return $localizations;
 
 
 
 
 
 
 
 
 
 
 
 
735
  }
736
 
737
- /*
738
- * Enqueue the admin script that applies to applies to all wpsc admin pages
 
 
 
 
 
 
739
  */
740
- function _wpsc_enqueue_wp_e_commerce_admin( ) {
741
- static $already_enqueued = false;
742
- if ( ! $already_enqueued ) {
743
- $version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
744
- wp_enqueue_script( 'wp-e-commerce-admin-js', WPSC_URL . '/wpsc-admin/js/wp-e-commerce-admin.js', false, false, $version_identifier );
745
- wp_localize_script( 'wp-e-commerce-admin-js', 'wpsc_admin_vars', wpsc_javascript_localizations() );
746
- $already_enqueued = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
747
  }
 
 
 
 
 
748
  }
749
 
750
  add_action( 'admin_menu', 'wpsc_admin_pages' );
@@ -856,7 +839,7 @@ function wpsc_dashboard_widget_setup() {
856
 
857
  // Add the dashboard widgets
858
  if ( current_user_can( $news_cap ) )
859
- wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'WP eCommerce News' , 'wpsc' ), 'wpsc_dashboard_news' );
860
  if ( current_user_can( $sales_cap ) )
861
  wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary', 'wpsc' ), 'wpsc_dashboard_widget' );
862
  if ( current_user_can( $quarterly_sales_cap ) )
@@ -911,7 +894,7 @@ add_action( 'wp_dashboard_setup', 'wpsc_dashboard_widget_setup' );
911
  * @uses wp_widget_rss_output() Display the RSS entries in a list
912
  */
913
  function wpsc_dashboard_news() {
914
- $rss = fetch_feed( 'http://wpecommerce.org/feed/?category_name=news' );
915
  $args = array( 'show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items' => 3 );
916
  wp_widget_rss_output( $rss, $args );
917
 
@@ -926,11 +909,11 @@ function wpsc_dashboard_news() {
926
  * @return array The array of prices
927
  */
928
  function wpsc_get_quarterly_summary() {
929
- $firstquarter = (int)get_option( 'wpsc_first_quart' );
930
- $secondquarter = (int)get_option( 'wpsc_second_quart' );
931
- $thirdquarter = (int)get_option( 'wpsc_third_quart' );
932
- $fourthquarter = (int)get_option( 'wpsc_fourth_quart' );
933
- $finalquarter = (int)get_option( 'wpsc_final_quart' );
934
 
935
  $results[] = admin_display_total_price( $thirdquarter + 1, $fourthquarter );
936
  $results[] = admin_display_total_price( $secondquarter + 1, $thirdquarter );
@@ -1083,7 +1066,7 @@ function wpsc_dashboard_4months_widget() {
1083
  $timeranges[2]["start"] = mktime( 0, 0, 0, $this_month - 1, 1, $this_year );
1084
  $timeranges[2]["end"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
1085
  $timeranges[3]["start"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
1086
- $timeranges[3]["end"] = time(); // using mktime here can generate a php runtime warning
1087
 
1088
  $prod_data = array( );
1089
  foreach ( (array)$products as $product ) { //run through products and get each product income amounts and name
@@ -1163,17 +1146,59 @@ function wpsc_fav_action( $actions ) {
1163
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
1164
 
1165
  /**
1166
- * Enqueue the admin scripts
1167
  *
 
1168
  * @uses wp_enqueue_script() Enqueues scripts
1169
  * @uses home_url() Returns the base url for the site
1170
  */
1171
  function wpsc_print_admin_scripts() {
1172
- $version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
1173
- wp_enqueue_script( 'wp-e-commerce-admin', WPSC_CORE_JS_URL . '/wp-e-commerce.js', array( 'jquery' ), $version_identifier );
1174
- wp_localize_script( 'wp-e-commerce-admin', 'wpsc_ajax', wpsc_javascript_localizations() );
1175
  }
1176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1177
  /**
1178
  * wpsc_ajax_ie_save save changes made using inline edit
1179
  *
@@ -1281,12 +1306,12 @@ function _wpsc_action_admin_notices_deprecated_countries_notice() {
1281
  $message = __( 'Yugoslavia is no longer a valid official country name according to <a href="%1$s">ISO 3166</a> while both Serbia and Montenegro have been added to the country list.<br /> As a result, we highly recommend changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wpsc' );
1282
  break;
1283
  case 'UK':
1284
- $message = __( 'Prior to WP eCommerce 3.8.9, in your database, United Kingdom\'s country code is UK and you have already selected that country code as the base country. However, now that you\'re using WP eCommerce version %3$s, it is recommended that you change your base country to the official "GB" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Settings</a> page to make this change.<br />The legacy "UK" item will be marked as "U.K. (legacy)" on the country drop down list. Simply switch to the official "United Kingdom (ISO 3166)" to use the "GB" country code.' , 'wpsc' );
1285
  break;
1286
  case 'AN':
1287
  $message = __( 'Netherlands Antilles is no longer a valid official country name according to <a href="%1$s">ISO 3166</a>.<br />Please consider changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wpsc' );
1288
  case 'TP':
1289
- $message = __( 'Prior to WP eCommerce 3.8.9, in your database, East Timor\'s country code is TP and you have already selected that country code as the base country. However, now that you\'re using WP eCommerce version %3$s, it is recommended that you change your base country to the official "TL" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Settings</a> page to make this change.<br />The legacy "TP" item will be marked as "East Timor (legacy)" on the country drop down list. Simply switch to the official "Timor-Leste (ISO 3166)" to use the "TL" country code.' , 'wpsc' );
1290
  break;
1291
  }
1292
 
@@ -1299,11 +1324,12 @@ function _wpsc_action_admin_notices_deprecated_countries_notice() {
1299
  echo '<div id="wpsc-warning" class="error"><p>' . $message . '</p></div>';
1300
  }
1301
 
1302
- add_action( 'admin_notices' , '_wpsc_action_admin_notices_deprecated_countries_notice' );
1303
- add_action( 'wp_ajax_category_sort_order' , 'wpsc_ajax_set_category_order' );
 
1304
  add_action( 'wp_ajax_variation_sort_order', 'wpsc_ajax_set_variation_order' );
1305
- add_action( 'wp_ajax_wpsc_ie_save' , 'wpsc_ajax_ie_save' );
1306
- add_action( 'in_admin_header' , 'wpsc_add_meta_boxes' );
1307
 
1308
  /**
1309
  * Deletes file associated with a product.
@@ -1384,8 +1410,6 @@ function wpsc_duplicate_product_process( $post, $new_parent_id = false ) {
1384
  // Copy the meta information
1385
  wpsc_duplicate_product_meta( $post->ID, $new_post_id );
1386
 
1387
- do_action( 'wpsc_duplicate_product', $post, $new_post_id );
1388
-
1389
  // Finds children (Which includes product files AND product images), their meta values, and duplicates them.
1390
  wpsc_duplicate_children( $post->ID, $new_post_id );
1391
 
@@ -1445,9 +1469,7 @@ function wpsc_duplicate_product_meta( $id, $new_id ) {
1445
  $sql_query.= implode( ",", $sql_query_sel );
1446
  $sql_query = $wpdb->prepare( $sql_query, $values );
1447
  $wpdb->query( $sql_query );
1448
- clean_post_cache( $new_id );
1449
  }
1450
-
1451
  }
1452
 
1453
  /**
@@ -1461,7 +1483,7 @@ function wpsc_duplicate_product_meta( $id, $new_id ) {
1461
  */
1462
  function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
1463
 
1464
- // Get children products and duplicate them
1465
  $child_posts = get_posts( array(
1466
  'post_parent' => $old_parent_id,
1467
  'post_type' => 'any',
@@ -1470,97 +1492,8 @@ function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
1470
  'order' => 'ASC',
1471
  ) );
1472
 
1473
- foreach ( $child_posts as $child_post ) {
1474
-
1475
- // Duplicate product images and child posts
1476
- if ( 'attachment' == get_post_type( $child_post ) ) {
1477
- wpsc_duplicate_product_image_process( $child_post, $new_parent_id );
1478
- } else {
1479
- wpsc_duplicate_product_process( $child_post, $new_parent_id );
1480
- }
1481
-
1482
- do_action( 'wpsc_duplicate_product_child', $child_post, $new_parent_id );
1483
-
1484
- }
1485
-
1486
- }
1487
-
1488
- /**
1489
- * Duplicates a product image.
1490
- *
1491
- * Uses a portion of code from media_sideload_image() in `wp-admin/includes/media.php`
1492
- * to check file before downloading from URL.
1493
- *
1494
- * @since 3.9.0
1495
- *
1496
- * @uses get_post_type() Gets post type.
1497
- * @uses wp_get_attachment_url() Gets attachment URL.
1498
- * @uses download_url() Download file from URl to temp location.
1499
- * @uses is_wp_error() Is WP error?
1500
- * @uses media_handle_sideload() Handle creation of new attachment and attach to post.
1501
- *
1502
- * @param object $post The post object.
1503
- * @param bool $new_parent_id Optional. The parent post id.
1504
- * @return int Attachment ID.
1505
- */
1506
- function wpsc_duplicate_product_image_process( $child_post, $new_parent_id ) {
1507
-
1508
- if ( 'attachment' == get_post_type( $child_post ) && apply_filters( 'wpsc_duplicate_product_attachment', true, $child_post ) ) {
1509
-
1510
- $file = wp_get_attachment_url( $child_post->ID );
1511
-
1512
- if ( ! empty( $file ) ) {
1513
-
1514
- // Set variables for storage, fix file filename for query strings.
1515
- preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
1516
- $file_array = array();
1517
- $file_array['name'] = basename( $matches[0] );
1518
-
1519
- // Download file to temp location.
1520
- $file_array['tmp_name'] = download_url( $file );
1521
-
1522
- // If error storing temporarily, return the error.
1523
- if ( is_wp_error( $file_array['tmp_name'] ) ) {
1524
- return $file_array['tmp_name'];
1525
- }
1526
-
1527
- // Do the validation and storage stuff.
1528
- $id = media_handle_sideload( $file_array, $new_parent_id );
1529
-
1530
- // If error storing permanently, unlink.
1531
- if ( is_wp_error( $id ) ) {
1532
- @unlink( $file_array['tmp_name'] );
1533
- }
1534
-
1535
- // Re-attribute featured image
1536
- if ( has_post_thumbnail( $new_parent_id ) && $child_post->ID == get_post_thumbnail_id( $new_parent_id ) ) {
1537
- set_post_thumbnail( $new_parent_id, $id );
1538
- }
1539
-
1540
- // Copy attachment data
1541
- $post_data = array(
1542
- 'ID' => $id,
1543
- 'post_content' => $child_post->post_content,
1544
- 'post_title' => $child_post->post_title,
1545
- 'post_excerpt' => $child_post->post_excerpt,
1546
- 'post_status' => $child_post->post_status,
1547
- 'comment_status' => $child_post->comment_status,
1548
- 'ping_status' => $child_post->ping_status,
1549
- 'post_password' => $child_post->post_password,
1550
- 'post_content_filtered' => $child_post->post_content_filtered,
1551
- 'menu_order' => $child_post->menu_order
1552
- );
1553
-
1554
- wp_update_post( $post_data );
1555
-
1556
- // Copy alt text
1557
- update_post_meta( $id, '_wp_attachment_image_alt', get_post_meta( $child_post->ID, '_wp_attachment_image_alt', true ) );
1558
-
1559
- return $id;
1560
-
1561
- }
1562
-
1563
- }
1564
 
1565
  }
1566
 
@@ -1573,12 +1506,12 @@ function wpsc_duplicate_product_image_process( $child_post, $new_parent_id ) {
1573
  * @uses get_option() Gets option from the database given string
1574
  */
1575
  function _wpsc_admin_notices_3dot8dot9() {
1576
- $message = '<p>' . __( 'You are currently using WP eCommerce 3.8.9. There have been major changes in WP eCommerce 3.8.9, so backward-compatibility with existing plugins might not always be guaranteed. If you are unsure, please roll back to 3.8.8.5, and set up a test site with 3.8.9 to make sure WP eCommerce 3.8.9 is compatible with your existing themes and plugins.<br />If you find any incompatibility issues, please <a href="%1$s">report them to us</a> as well as the other plugins or themes\' developers.' , 'wpsc' ) . '</p>';
1577
  $message .= "\n<p>" . __( '<a href="%2$s">Hide this warning</a>', 'wpsc' ) . '</p>';
1578
  $message = sprintf(
1579
  $message,
1580
- 'https://wpecommerce.org/wp-e-commerce-3-8-9-compatibility-issues/',
1581
- add_query_arg( 'dismiss_389_upgrade_notice', 1 )
1582
  );
1583
 
1584
  echo '<div id="wpsc-3.8.9-notice" class="error">' . $message . '</div>';
@@ -1590,52 +1523,6 @@ if ( isset( $_REQUEST['dismiss_389_upgrade_notice'] ) || version_compare( WPSC_V
1590
  if ( ! get_option( 'wpsc_hide_3.8.9_notices' ) )
1591
  add_action( 'admin_notices', '_wpsc_admin_notices_3dot8dot9' );
1592
 
1593
- /**
1594
- * Checks to ensure that shipping is enabled, and one or both of the shipping/billing states are not displayed.
1595
- * If those condtions are met, and the user has not previously dismissed the notice, then we notify them
1596
- * that the shipping calculator now depend on those fields.
1597
- *
1598
- * @access private
1599
- *
1600
- * @uses add_query_arg() Adds argument to the WordPress query
1601
- * @uses update_option() Updates an option in the WordPress database given string and value
1602
- * @uses get_option() Gets option from the database given string
1603
- */
1604
- function _wpsc_admin_notices_3_8_14_1() {
1605
-
1606
- if ( get_option( 'do_not_use_shipping' ) ) {
1607
- return;
1608
- }
1609
-
1610
- global $wpdb;
1611
-
1612
- $state_visibility = $wpdb->get_var( "SELECT COUNT(active) FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE unique_name IN ( 'billingstate', 'shippingstate' ) AND active = '1'" );
1613
-
1614
- if ( '2' === $state_visibility ) {
1615
- return;
1616
- }
1617
-
1618
- $message = '<p>' . __( 'WP eCommerce has been updated, please confirm the checkout field display
1619
- settings are correct for your store.<br><br><i>The visibility of the checkout billing and shipping
1620
- drop downs that show states and provinces is now controlled by the "billingstate" and "shippingstate"
1621
- options set in the <b>Store Settings</b> on the <b>Checkout</b> tab. Prior versions used
1622
- the "billingcountry" and "shippingcountry" settings to control the visibility of the drop downs.</i>' , 'wpsc' ) . '</p>';
1623
- $message .= "\n<p>" . __( '<a href="%s">Hide this warning</a>', 'wpsc' ) . '</p>';
1624
- $message = sprintf(
1625
- $message,
1626
- add_query_arg( 'dismiss_3_8_14_1_upgrade_notice', 1 )
1627
- );
1628
-
1629
- echo '<div id="wpsc-3-8-14-1-notice" class="error">' . $message . '</div>';
1630
- }
1631
-
1632
- if ( isset( $_REQUEST['dismiss_3_8_14_1_upgrade_notice'] ) || version_compare( WPSC_VERSION, '3.9', '>=' ) ) {
1633
- update_option( 'wpsc_hide_3_8_14_1_notices', true );
1634
- }
1635
-
1636
- if ( ! get_option( 'wpsc_hide_3_8_14_1_notices' ) )
1637
- add_action( 'admin_notices', '_wpsc_admin_notices_3_8_14_1' );
1638
-
1639
  /**
1640
  * @todo docs
1641
  * @access private
@@ -1645,14 +1532,14 @@ if ( ! get_option( 'wpsc_hide_3_8_14_1_notices' ) )
1645
  * @uses get_option() Gets option from the database given string
1646
  */
1647
  function _wpsc_admin_notices_3dot8dot11() {
1648
- $message = '<p>' . __( 'You are currently using WPeC %1$s. We introduced a regression in WPeC 3.8.10 which affects your customer user account page. We have included a fix for a <a href="%2$s">bug on the User Account management page</a>. We are able to fix this automatically on most sites, but it appears that you have made changes to your wpsc-user-log.php page. For that reason, we have some <a href="%3$s">simple instructions for you to follow</a> to resolve the issue. We are sorry for the inconvenience.' , 'wpsc' ) . '</p>';
1649
  $message .= "\n<p>" . __( '<a href="%4$s">Hide this warning</a>', 'wpsc' ) . '</p>';
1650
- $message = sprintf(
1651
  $message,
1652
  WPSC_VERSION,
1653
  'https://github.com/wp-e-commerce/WP-e-Commerce/issues/359',
1654
- 'http://docs.wpecommerce.org/documentation/3-8-11-user-logs',
1655
- add_query_arg( 'dismiss_3811_upgrade_notice', 1 )
1656
  );
1657
 
1658
  echo '<div id="wpsc-3.8.11-notice" class="error">' . $message . '</div>';
@@ -1663,42 +1550,3 @@ if ( isset( $_REQUEST['dismiss_3811_upgrade_notice'] ) )
1663
 
1664
  if ( get_option( '_wpsc_3811_user_log_notice' ) )
1665
  add_action( 'admin_notices', '_wpsc_admin_notices_3dot8dot11' );
1666
-
1667
- function _wpsc_notify_google_checkout_deprecation() {
1668
- $gateways = get_option( 'custom_gateway_options', array() );
1669
-
1670
- if ( false !== ( $key = array_search( 'google', $gateways ) ) ) {
1671
- unset( $gateways[ $key ] );
1672
- }
1673
-
1674
- if ( empty( $gateways ) ) {
1675
- $gateways[] = 'wpsc_merchant_testmode';
1676
- }
1677
-
1678
- update_option( 'custom_gateway_options', $gateways );
1679
-
1680
- $message = '<p>' . __( 'Effective November 20th, 2013, Google Checkout was shut down and is no longer processing payments. You are seeing this warning because it appears that Google Checkout was your payment gateway processor. If it was your sole processor, we have enabled the Test Gateway to ensure that orders are coming through on your site, but we highly recommend enabling a proper gateway. If you have no preference, we highly recommend Stripe.' , 'wpsc' ) . '</p>';
1681
-
1682
- echo '<div id="wpsc-3.8.11-notice" class="error">' . $message . '</div>';
1683
- }
1684
-
1685
- if ( in_array( 'google', get_option( 'custom_gateway_options', array() ) ) ) {
1686
- add_action( 'admin_notices', '_wpsc_notify_google_checkout_deprecation' );
1687
- }
1688
-
1689
- /**
1690
- * Adds links to premium support and documentation on WPeCommerce.org
1691
- *
1692
- * @since 3.9.0
1693
- *
1694
- * @param array $links Original links
1695
- * @return array $links Updated links
1696
- */
1697
- function wpsc_support_links( $links ) {
1698
- $links[] = sprintf( '<a href="%s">%s</a>', _x( 'https://wpecommerce.org/premium-support/', 'Premium Support URL', 'wpsc' ), __( 'Premium Support', 'wpsc' ) );
1699
- $links[] = sprintf( '<a href="%s">%s</a>', _x( 'http://docs.wpecommerce.org/', 'Documentation URL', 'wpsc' ), __( 'Documentation', 'wpsc' ) );
1700
-
1701
- return $links;
1702
- }
1703
-
1704
- add_filter( 'plugin_action_links_' . WPSC_PLUGIN_BASENAME, 'wpsc_support_links' );
25
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
26
  require_once( WPSC_FILE_PATH . '/wpsc-admin/db-upgrades/upgrade.php' );
27
  require_once( WPSC_FILE_PATH . '/wpsc-admin/media.php' );
28
+ require_once( WPSC_FILE_PATH . '/wpsc-admin/users.php' );
29
 
30
  if ( ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( $_SESSION['wpsc_activate_debug_page'] == true ) ) || ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( constant( 'WPSC_ADD_DEBUG_PAGE' ) == true ) ) )
31
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
34
  $form_sets = array( __( 'Default Checkout Forms', 'wpsc' ) );
35
  update_option( 'wpsc_checkout_form_sets', $form_sets );
36
  }
 
 
 
 
37
  /**
38
  * wpsc_query_vars_product_list sets the ordering for the edit-products page list
39
  *
85
  add_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );
86
 
87
  /**
88
+ * setting the screen option to between 1 and 999
89
  *
90
  * @since 3.8
91
  * @access public
98
  * @return $value after changes...
99
  */
100
  function wpsc_set_screen_option($status, $option, $value){
101
+ if( in_array($option, array ("edit_wpsc_variation_per_page","edit_wpsc_product_per_page" )) ){
102
  if ( "edit_wpsc_variation_per_page" == $option ){
103
  global $user_ID;
104
  update_user_option($user_ID,'edit_wpsc-variation_per_page',$value);
128
  return $per_page;
129
  }
130
  add_filter( 'request', 'wpsc_query_vars_product_list' );
131
+ add_filter('edit_posts_per_page' , 'wpsc_drag_and_drop_ordering', 10, 2 );
132
 
133
  /**
134
  * Checks whether to display or hide the update wp-e-commerce link
259
  add_action( 'load-post.php' , 'wpsc_add_help_tabs' );
260
  add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
261
  add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );
 
 
 
262
  }
263
 
264
  /**
348
  $content = '<p><strong>' . __( 'For More Information', 'wpsc' ) . '</strong></p>';
349
  $links = array();
350
  foreach( $tab['links'] as $link => $link_title ) {
351
+ $link = 'http://docs.getshopped.org/' . $link;
352
  $links[] = '<a target="_blank" href="' . esc_url( $link ) . '">' . esc_html( $link_title ) . '</a>';
353
  }
354
  $content .= '<p>' . implode( '<br />', $links ) . '</p>';
362
  }
363
  }
364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  /**
366
  * Includes purchase logs CSS and JS
367
  *
371
  * @uses wp_localize_script() Adds noncing and other data to the logs script
372
  */
373
  function wpsc_admin_include_purchase_logs_css_and_js() {
 
 
 
374
  wp_enqueue_script( 'wp-e-commerce-purchase-logs', WPSC_URL . '/wpsc-admin/js/purchase-logs.js', array( 'jquery' ), WPSC_VERSION . '.' . WPSC_MINOR_VERSION );
375
  wp_localize_script( 'wp-e-commerce-purchase-logs', 'WPSC_Purchase_Logs_Admin', array(
376
  'nonce' => wp_create_nonce( 'wpsc_purchase_logs' ),
381
  'sent_message' => _x( 'Email Sent!', 'sending tracking email for purchase log', 'wpsc' ),
382
  'current_view' => empty( $_REQUEST['status'] ) ? 'all' : $_REQUEST['status'],
383
  'current_filter' => empty( $_REQUEST['m'] ) ? '' : $_REQUEST['m'],
384
+ 'current_page' => empty( $_REQUEST['paged']) ? '' : $_REQUEST['paged'],
 
 
 
 
 
 
 
385
  ) );
 
386
  }
387
 
388
  /**
424
  * @uses admin_url() Retrieves URL to the WordPress admin
425
  */
426
  function wpsc_product_log_rss_feed() {
427
+ echo "<link type='application/rss+xml' href='" . add_query_arg( array( 'rss' => 'true', 'rss_key' => 'key', 'action' => 'purchase_log', 'type' => 'rss' ), admin_url( 'index.php' ) ) . "' title='" . esc_attr( 'WP e-Commerce Purchase Log RSS', 'wpsc' ) . "' rel='alternate' />";
428
  }
429
 
430
  /**
436
  function wpsc_admin_include_coupon_js() {
437
 
438
  // Variables
439
+ $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
 
 
 
440
 
441
  // Coupon CSS
442
  wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
443
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
444
 
445
  // Coupon JS
446
+ wp_enqueue_script( 'wp-e-commerce-admin-parameters', admin_url( '/wp-admin/admin.php?wpsc_admin_dynamic_js=true' ), false, $version_identifier );
447
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
448
  wp_enqueue_script( 'jquery-ui-datepicker' );
 
 
449
  wp_enqueue_script( 'wp-e-commerce-admin_legacy', WPSC_URL . '/wpsc-admin/js/admin-legacy.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-datepicker' ), $version_identifier );
450
 
451
+ wp_enqueue_style ( 'wpsc-jquery-ui-datepicker', WPSC_URL . '/wpsc-admin/css/jquery.ui.datepicker-' . get_user_option( 'admin_color' ) . '.css', false, $version_identifier );
 
 
 
452
  }
453
 
454
  /**
461
  * @uses wp_enqueue_style() Includes and prints out the CSS for the WPEC options page
462
  */
463
  function wpsc_admin_include_optionspage_css_and_js() {
 
 
 
464
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
465
  wp_enqueue_script( 'wp-e-commerce-admin-settings-page', WPSC_URL . '/wpsc-admin/js/settings-page.js', array( 'jquery-query' ), $version_identifier );
466
 
497
  //if a variation page do not show these metaboxes
498
  if ( is_object( $post ) && $post->post_parent == 0 ) {
499
  add_meta_box( 'wpsc_product_variation_forms' , __( 'Variations', 'wpsc' ) , 'wpsc_product_variation_forms' , $pagename, 'normal', 'high' );
500
+ add_meta_box( 'wpsc_product_external_link_forms', __( 'Off Site Product link', 'wpsc' ), 'wpsc_product_external_link_forms', $pagename, 'normal', 'high' );
501
  } else if( is_object( $post ) && $post->post_status == "inherit" ) {
502
  remove_meta_box( 'tagsdiv-product_tag' , 'wpsc-product', 'core' );
503
+ remove_meta_box( 'wpsc_product_external_link_forms', 'wpsc-product', 'core' );
504
  remove_meta_box( 'wpsc_product_categorydiv' , 'wpsc-product', 'core' );
505
  }
506
 
507
+ add_meta_box( 'wpsc_product_gallery', __( 'Product Gallery', 'wpsc' ), 'wpsc_product_gallery', $pagename, 'side', 'low' );
508
+ add_meta_box( 'wpsc_price_control_forms', __('Price Control', 'wpsc'), 'wpsc_price_control_forms', $pagename, 'side', 'low' );
509
+ add_meta_box( 'wpsc_stock_control_forms', __('Stock Control', 'wpsc'), 'wpsc_stock_control_forms', $pagename, 'side', 'low' );
510
  add_meta_box( 'wpsc_product_taxes_forms', __('Taxes', 'wpsc'), 'wpsc_product_taxes_forms', $pagename, 'side', 'low' );
511
+ add_meta_box( 'wpsc_additional_desc', __('Additional Description', 'wpsc'), 'wpsc_additional_desc', $pagename, 'normal', 'high' );
512
+ add_meta_box( 'wpsc_product_download_forms', __('Product Download', 'wpsc'), 'wpsc_product_download_forms', $pagename, 'normal', 'high' );
 
513
 
514
+ if ( ! empty( $post->ID ) && ! wpsc_product_has_variations( $post->ID ) )
515
+ add_meta_box( 'wpsc_product_shipping_forms', __('Shipping', 'wpsc'), 'wpsc_product_shipping_forms_metabox', $pagename, 'normal', 'high' );
516
+ add_meta_box( 'wpsc_product_advanced_forms', __('Advanced Settings', 'wpsc'), 'wpsc_product_advanced_forms', $pagename, 'normal', 'high' );
517
+ }
518
  add_action( 'admin_footer', 'wpsc_meta_boxes' );
519
  add_action( 'admin_enqueue_scripts', 'wpsc_admin_include_css_and_js_refac' );
520
 
535
 
536
  $current_screen = get_current_screen();
537
 
538
+ if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) )
539
+ wp_admin_css( 'dashboard' );
540
+
541
  if ( 'dashboard_page_wpsc-sales-logs' == $current_screen->id ) {
542
  // jQuery
543
  wp_enqueue_script( 'jquery' );
555
  $pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
556
 
557
  if ( ( in_array( $pagehook, $pages ) && $post_type == 'wpsc-product' ) || $current_screen->id == 'edit-wpsc_product_category' || $current_screen->id == 'dashboard_page_wpsc-sales-logs' || $current_screen->id == 'dashboard_page_wpsc-purchase-logs' || $current_screen->id == 'settings_page_wpsc-settings' || $current_screen->id == 'wpsc-product_page_wpsc-edit-coupons' || $current_screen->id == 'edit-wpsc-variation' || $current_screen->id == 'wpsc-product-variations-iframe' || ( $pagehook == 'media-upload-popup' && get_post_type( $_REQUEST['post_id'] ) == 'wpsc-product' ) ) {
 
 
 
558
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
559
+ wp_enqueue_script( 'wp-e-commerce-admin-parameters', admin_url( 'admin.php?wpsc_admin_dynamic_js=true' ), false, $version_identifier );
560
  wp_enqueue_script( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/js/admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier, false );
561
  wp_enqueue_script( 'wpsc-sortable-table', WPSC_URL . '/wpsc-admin/js/sortable-table.js', array( 'jquery' ) );
562
 
571
  );
572
  }
573
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
574
+ wp_enqueue_style( 'wp-e-commerce-admin-dynamic', admin_url( "admin.php?wpsc_admin_dynamic_css=true" ), false, $version_identifier, 'all' );
575
+ // Localize scripts
576
+ wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
577
+ 'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
578
+ 'save_product_order_nonce' => _wpsc_create_ajax_nonce( 'save_product_order' ),
579
+ 'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};',
580
+ 'empty_coupon' => esc_html__( 'Please enter a coupon code.', 'wpsc' ),
581
+ 'bulk_edit_no_vars' => esc_html__( 'Quick Edit options are limited when editing products that have variations. You will need to edit the variations themselves.', 'wpsc' ),
582
+ 'wpsc_core_images_url' => WPSC_CORE_IMAGES_URL,
583
+ 'variation_parent_swap' => esc_html_x( 'New Variation Set', 'Variation taxonomy parent', 'wpsc' ),
584
+ /* translators : This string is prepended to the 'New Variation Set' string */
585
+ 'variation_helper_text' => esc_html_x( 'Choose the Variation Set you want to add variants to. If you\'re creating a new variation set then select', 'Variation helper text', 'wpsc' ),
586
+ 'variations_tutorial' => esc_html__( 'Variations allow you to create options for your products. For example, if you\'re selling T-Shirts, they will generally have a "Size" option. Size will be the Variation Set name, and it will be a "New Variant Set". You will then create variants (small, medium, large) which will have the "Variation Set" of Size. Once you have made your set you can use the table on the right to manage them (edit, delete). You will be able to order your variants by dragging and dropping them within their Variation Set.', 'wpsc' ),
587
+ /* translators : These strings are dynamically inserted as a drop-down for the Coupon comparison conditions */
588
+ 'coupons_compare_or' => esc_html_x( 'OR' , 'Coupon comparison logic', 'wpsc' ),
589
+ 'coupons_compare_and' => esc_html_x( 'AND' , 'Coupon comparison logic', 'wpsc' ),
590
+ ) );
 
 
 
 
 
 
 
 
 
 
591
  }
592
  if ( $pagehook == 'wpsc-product-variations-iframe' ) {
 
 
593
  wp_enqueue_script( 'wp-e-commerce-product-variations', WPSC_URL . '/wpsc-admin/js/product-variations.js', array( 'jquery' ), $version_identifier );
594
  wp_localize_script( 'wp-e-commerce-product-variations', 'WPSC_Product_Variations', array(
595
  'product_id' => $_REQUEST['product_id'],
598
  }
599
 
600
  if ( $pagehook == 'media-upload-popup' ) {
 
601
  $post = get_post( $_REQUEST['post_id'] );
602
  if ( $post->post_type == 'wpsc-product' && $post->post_parent ) {
 
 
603
  wp_dequeue_script( 'set-post-thumbnail' );
604
  wp_enqueue_script( 'wpsc-set-post-thumbnail', WPSC_URL . '/wpsc-admin/js/set-post-thumbnail.js', array( 'jquery', 'wp-e-commerce-admin' ), $version_identifier );
605
  wp_localize_script( 'wpsc-set-post-thumbnail', 'WPSC_Set_Post_Thumbnail', array(
616
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
617
  }
618
 
 
619
  /**
620
+ * @todo docs
 
 
 
 
621
  *
622
+ * @uses get_option() Gets an option by name from the WordPress database
623
  */
624
+ function wpsc_admin_dynamic_js() {
625
+ header( 'Content-Type: text/javascript' );
626
+ header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
627
+ header( 'Cache-Control: public, must-revalidate, max-age=86400' );
628
+ header( 'Pragma: public' );
629
 
630
+ $hidden_boxes = get_option( 'wpsc_hidden_box' );
 
631
 
632
+ $form_types1 = get_option( 'wpsc_checkout_form_fields' );
633
+ $unique_names1 = get_option( 'wpsc_checkout_unique_names' );
 
 
 
 
 
 
 
634
 
635
  $form_types = '';
636
+ foreach ( (array)$form_types1 as $form_type ) {
637
+ $form_types .= "<option value='" . $form_type . "'>" . $form_type . "</option>";
638
  }
639
 
640
+ $unique_names = "<option value='-1'>" . __('Select a Unique Name', 'wpsc') . "</option>";
641
+ foreach ( (array)$unique_names1 as $unique_name ) {
642
+ $unique_names.= "<option value='" . $unique_name . "'>" . $unique_name . "</option>";
643
  }
644
 
645
+ $hidden_boxes = implode( ',', (array)$hidden_boxes );
646
+ echo "var base_url = '" . esc_js( site_url() ) . "';\n\r";
647
+ echo "var WPSC_URL = '" . esc_js( WPSC_URL ) . "';\n\r";
648
+ echo "var WPSC_IMAGE_URL = '" . esc_js( WPSC_IMAGE_URL ) . "';\n\r";
649
+ echo "var WPSC_DIR_NAME = '" . esc_js( WPSC_DIR_NAME ) . "';\n\r";
650
+ echo "var WPSC_IMAGE_URL = '" . esc_js( WPSC_IMAGE_URL ) . "';\n\r";
651
+
652
+ // LightBox Configuration start
653
+ echo "var fileLoadingImage = '" . esc_js( WPSC_CORE_IMAGES_URL ) . "/loading.gif';\n\r";
654
+ echo "var fileBottomNavCloseImage = '" . esc_js( WPSC_CORE_IMAGES_URL ) . "/closelabel.gif';\n\r";
655
+ echo "var fileThickboxLoadingImage = '" . esc_js( WPSC_CORE_IMAGES_URL ) . "/loadingAnimation.gif';\n\r";
656
+
657
+ echo "var resizeSpeed = 9;\n\r";
658
+
659
+ echo "var borderSize = 10;\n\r";
660
+
661
+ echo "var hidden_boxes = '" . esc_js( $hidden_boxes ) . "';\n\r";
662
+ echo "var IS_WP27 = '" . esc_js( IS_WP27 ) . "';\n\r";
663
+ echo "var TXT_WPSC_DELETE = '" . esc_js( __( 'Delete', 'wpsc' ) ) . "';\n\r";
664
+ echo "var TXT_WPSC_TEXT = '" . esc_js( __( 'Text', 'wpsc' ) ) . "';\n\r";
665
+ echo "var TXT_WPSC_EMAIL = '" . esc_js( __( 'Email', 'wpsc' ) ) . "';\n\r";
666
+ echo "var TXT_WPSC_COUNTRY = '" . esc_js( __( 'Country', 'wpsc' ) ) . "';\n\r";
667
+ echo "var TXT_WPSC_TEXTAREA = '" . esc_js( __( 'Textarea', 'wpsc' ) ) . "';\n\r";
668
+ echo "var TXT_WPSC_HEADING = '" . esc_js( __( 'Heading', 'wpsc' ) ) . "';\n\r";
669
+ echo "var TXT_WPSC_COUPON = '" . esc_js( __( 'Coupon', 'wpsc' ) ) . "';\n\r";
670
+
671
+ echo "var HTML_FORM_FIELD_TYPES =\" " . esc_js( $form_types ) . "; \" \n\r";
672
+ echo "var HTML_FORM_FIELD_UNIQUE_NAMES = \" " . esc_js( $unique_names ) . "; \" \n\r";
673
+
674
+ echo "var TXT_WPSC_LABEL = '" . esc_js( __( 'Label', 'wpsc' ) ) . "';\n\r";
675
+ echo "var TXT_WPSC_LABEL_DESC = '" . esc_js( __( 'Label Description', 'wpsc' ) ) . "';\n\r";
676
+ echo "var TXT_WPSC_ITEM_NUMBER = '" . esc_js( __( 'Item Number', 'wpsc' ) ) . "';\n\r";
677
+ echo "var TXT_WPSC_LIFE_NUMBER = '" . esc_js( __( 'Life Number', 'wpsc' ) ) . "';\n\r";
678
+ echo "var TXT_WPSC_PRODUCT_CODE = '" . esc_js( __( 'Product Code', 'wpsc' ) ) . "';\n\r";
679
+ echo "var TXT_WPSC_PDF = '" . esc_js( __( 'PDF', 'wpsc' ) ) . "';\n\r";
680
+
681
+ echo "var TXT_WPSC_AND_ABOVE = '" . esc_js( __( ' and above', 'wpsc' ) ) . "';\n\r";
682
+ echo "var TXT_WPSC_IF_PRICE_IS = '" . esc_js( __( 'If price is ', 'wpsc' ) ) . "';\n\r";
683
+ echo "var TXT_WPSC_IF_WEIGHT_IS = '" . esc_js( __( 'If weight is ', 'wpsc' ) ) . "';\n\r";
684
+
685
+ exit();
686
  }
687
 
688
+ if ( isset( $_GET['wpsc_admin_dynamic_js'] ) && ( $_GET['wpsc_admin_dynamic_js'] == 'true' ) ) {
689
+ add_action( "admin_init", 'wpsc_admin_dynamic_js' );
690
+ }
691
+
692
+ /**
693
+ * @todo finish docs
694
+ *
695
+ * @uses apply_filters() Allows manipulation of the flash upload params.
696
  */
697
+ function wpsc_admin_dynamic_css() {
698
+ header( 'Content-Type: text/css' );
699
+ header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
700
+ header( 'Cache-Control: public, must-revalidate, max-age=86400' );
701
+ header( 'Pragma: public' );
702
+ $flash = 0;
703
+ $flash = apply_filters( 'flash_uploader', $flash );
704
+
705
+ if ( $flash = 1 ) {
706
+ ?>
707
+ div.flash-image-uploader {
708
+ display: block;
709
+ }
710
+
711
+ div.browser-image-uploader {
712
+ display: none;
713
+ }
714
+ <?php
715
+ } else {
716
+ ?>
717
+ div.flash-image-uploader {
718
+ display: none;
719
+ }
720
+
721
+ div.browser-image-uploader {
722
+ display: block;
723
+ }
724
+ <?php
725
  }
726
+ exit();
727
+ }
728
+
729
+ if ( isset( $_GET['wpsc_admin_dynamic_css'] ) && ( $_GET['wpsc_admin_dynamic_css'] == 'true' ) ) {
730
+ add_action( "admin_init", 'wpsc_admin_dynamic_css' );
731
  }
732
 
733
  add_action( 'admin_menu', 'wpsc_admin_pages' );
839
 
840
  // Add the dashboard widgets
841
  if ( current_user_can( $news_cap ) )
842
+ wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'WP e-Commerce News' , 'wpsc' ), 'wpsc_dashboard_news' );
843
  if ( current_user_can( $sales_cap ) )
844
  wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary', 'wpsc' ), 'wpsc_dashboard_widget' );
845
  if ( current_user_can( $quarterly_sales_cap ) )
894
  * @uses wp_widget_rss_output() Display the RSS entries in a list
895
  */
896
  function wpsc_dashboard_news() {
897
+ $rss = fetch_feed( 'http://getshopped.org/feed/?category_name=wp-e-commerce-plugin' );
898
  $args = array( 'show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items' => 3 );
899
  wp_widget_rss_output( $rss, $args );
900
 
909
  * @return array The array of prices
910
  */
911
  function wpsc_get_quarterly_summary() {
912
+ (int)$firstquarter = get_option( 'wpsc_first_quart' );
913
+ (int)$secondquarter = get_option( 'wpsc_second_quart' );
914
+ (int)$thirdquarter = get_option( 'wpsc_third_quart' );
915
+ (int)$fourthquarter = get_option( 'wpsc_fourth_quart' );
916
+ (int)$finalquarter = get_option( 'wpsc_final_quart' );
917
 
918
  $results[] = admin_display_total_price( $thirdquarter + 1, $fourthquarter );
919
  $results[] = admin_display_total_price( $secondquarter + 1, $thirdquarter );
1066
  $timeranges[2]["start"] = mktime( 0, 0, 0, $this_month - 1, 1, $this_year );
1067
  $timeranges[2]["end"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
1068
  $timeranges[3]["start"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
1069
+ $timeranges[3]["end"] = mktime();
1070
 
1071
  $prod_data = array( );
1072
  foreach ( (array)$products as $product ) { //run through products and get each product income amounts and name
1146
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
1147
 
1148
  /**
1149
+ * Prits out the admin scripts
1150
  *
1151
+ * @uses is_ssl() Defines if SSL is true
1152
  * @uses wp_enqueue_script() Enqueues scripts
1153
  * @uses home_url() Returns the base url for the site
1154
  */
1155
  function wpsc_print_admin_scripts() {
1156
+ $scheme = is_ssl() ? 'https' : 'http';
1157
+ wp_enqueue_script( 'wp-e-commerce-dynamic', home_url( "/index.php?wpsc_user_dynamic_js=true", $scheme ) );
 
1158
  }
1159
 
1160
+ /**
1161
+ * Update products page URL options when permalink scheme changes.
1162
+ *
1163
+ * @since 3.8.9
1164
+ * @access private
1165
+ *
1166
+ * @uses get_bloginfo() Returns information about your site to be used elsewhere
1167
+ * @uses version_compare() Compares two "PHP-standardized" version number strings
1168
+ * @uses _wpsc_display_permalink_refresh_notice() Display warning on older WordPress versions
1169
+ * @uses wpsc_update_page_urls() Gets the premalinks for product pages and stores for quick reference
1170
+ */
1171
+ function _wpsc_action_permalink_structure_changed() {
1172
+ $wp_version = get_bloginfo( 'version' );
1173
+
1174
+ // see WordPress core trac ticket:
1175
+ // http://core.trac.wordpress.org/ticket/16736
1176
+ // this has been fixed in WordPress 3.3
1177
+ if ( version_compare( $wp_version, '3.3', '<' ) )
1178
+ _wpsc_display_permalink_refresh_notice();
1179
+ add_action( 'admin_notices', 'wpsc_check_permalink_notice' );
1180
+
1181
+ wpsc_update_page_urls( true );
1182
+ }
1183
+
1184
+ /**
1185
+ * Display warning if the user is using WordPress prior to 3.3 because there is a bug with custom
1186
+ * post type and taxonomy permalink generation.
1187
+ *
1188
+ * @since 3.8.9
1189
+ * @access private
1190
+ */
1191
+ function _wpsc_display_permalink_refresh_notice(){
1192
+ ?>
1193
+ <div id="notice" class="error fade">
1194
+ <p>
1195
+ <?php printf( __( 'Due to <a href="%1$s">a bug in WordPress prior to version 3.3</a>, you might run into 404 errors when viewing your products. To work around this, <a href="%2$s">upgrade to WordPress 3.3 or later</a>, or simply click "Save Changes" below a second time.' , 'wpsc' ), 'http://core.trac.wordpress.org/ticket/16736', 'http://codex.wordpress.org/Updating_WordPress' ); ?>
1196
+ </p>
1197
+ </div>
1198
+ <?php
1199
+ }
1200
+
1201
+
1202
  /**
1203
  * wpsc_ajax_ie_save save changes made using inline edit
1204
  *
1306
  $message = __( 'Yugoslavia is no longer a valid official country name according to <a href="%1$s">ISO 3166</a> while both Serbia and Montenegro have been added to the country list.<br /> As a result, we highly recommend changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wpsc' );
1307
  break;
1308
  case 'UK':
1309
+ $message = __( 'Prior to WP e-Commerce 3.8.9, in your database, United Kingdom\'s country code is UK and you have already selected that country code as the base country. However, now that you\'re using WP e-Commerce version %3$s, it is recommended that you change your base country to the official "GB" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Setings</a> page to make this change.<br />The legacy "UK" item will be marked as "U.K. (legacy)" on the country drop down list. Simply switch to the official "United Kingdom (ISO 3166)" to use the "GB" country code.' , 'wpsc' );
1310
  break;
1311
  case 'AN':
1312
  $message = __( 'Netherlands Antilles is no longer a valid official country name according to <a href="%1$s">ISO 3166</a>.<br />Please consider changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wpsc' );
1313
  case 'TP':
1314
+ $message = __( 'Prior to WP e-Commerce 3.8.9, in your database, East Timor\'s country code is TP and you have already selected that country code as the base country. However, now that you\'re using WP e-Commerce version %3$s, it is recommended that you change your base country to the official "TL" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Setings</a> page to make this change.<br />The legacy "TP" item will be marked as "East Timor (legacy)" on the country drop down list. Simply switch to the official "Timor-Leste (ISO 3166)" to use the "TL" country code.' , 'wpsc' );
1315
  break;
1316
  }
1317
 
1324
  echo '<div id="wpsc-warning" class="error"><p>' . $message . '</p></div>';
1325
  }
1326
 
1327
+ add_action( 'admin_notices', '_wpsc_action_admin_notices_deprecated_countries_notice' );
1328
+ add_action( 'permalink_structure_changed' , '_wpsc_action_permalink_structure_changed' );
1329
+ add_action( 'wp_ajax_category_sort_order', 'wpsc_ajax_set_category_order' );
1330
  add_action( 'wp_ajax_variation_sort_order', 'wpsc_ajax_set_variation_order' );
1331
+ add_action( 'wp_ajax_wpsc_ie_save', 'wpsc_ajax_ie_save' );
1332
+ add_action('in_admin_header', 'wpsc_add_meta_boxes');
1333
 
1334
  /**
1335
  * Deletes file associated with a product.
1410
  // Copy the meta information
1411
  wpsc_duplicate_product_meta( $post->ID, $new_post_id );
1412
 
 
 
1413
  // Finds children (Which includes product files AND product images), their meta values, and duplicates them.
1414
  wpsc_duplicate_children( $post->ID, $new_post_id );
1415
 
1469
  $sql_query.= implode( ",", $sql_query_sel );
1470
  $sql_query = $wpdb->prepare( $sql_query, $values );
1471
  $wpdb->query( $sql_query );
 
1472
  }
 
1473
  }
1474
 
1475
  /**
1483
  */
1484
  function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
1485
 
1486
+ //Get children products and duplicate them
1487
  $child_posts = get_posts( array(
1488
  'post_parent' => $old_parent_id,
1489
  'post_type' => 'any',
1492
  'order' => 'ASC',
1493
  ) );
1494
 
1495
+ foreach ( $child_posts as $child_post )
1496
+ wpsc_duplicate_product_process( $child_post, $new_parent_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1497
 
1498
  }
1499
 
1506
  * @uses get_option() Gets option from the database given string
1507
  */
1508
  function _wpsc_admin_notices_3dot8dot9() {
1509
+ $message = '<p>' . __( 'You are currently using WP e-Commerce 3.8.9. There have been major changes in WP e-Commerce 3.8.9, so backward-compatibility with existing plugins might not always be guaranteed. If you are unsure, please roll back to 3.8.8.5, and set up a test site with 3.8.9 to make sure WP e-Commerce 3.8.9 is compatible with your existing themes and plugins.<br />If you find any incompatibility issues, please <a href="%1$s">report them to us</a> as well as the other plugins or themes\' developers.' , 'wpsc' ) . '</p>';
1510
  $message .= "\n<p>" . __( '<a href="%2$s">Hide this warning</a>', 'wpsc' ) . '</p>';
1511
  $message = sprintf(
1512
  $message,
1513
+ 'http://getshopped.org/wp-e-commerce-3-8-9-compatibility-issues/',
1514
+ esc_url( add_query_arg( 'dismiss_389_upgrade_notice', 1 ) )
1515
  );
1516
 
1517
  echo '<div id="wpsc-3.8.9-notice" class="error">' . $message . '</div>';
1523
  if ( ! get_option( 'wpsc_hide_3.8.9_notices' ) )
1524
  add_action( 'admin_notices', '_wpsc_admin_notices_3dot8dot9' );
1525
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1526
  /**
1527
  * @todo docs
1528
  * @access private
1532
  * @uses get_option() Gets option from the database given string
1533
  */
1534
  function _wpsc_admin_notices_3dot8dot11() {
1535
+ $message = '<p>' . __( 'You are currently using WPeC %1$s. We introduced a regression in WPeC 3.8.10 which affects your customer user account page. We have included a fix for a <a href="%2$s">bug on the User Account management page</a>. We are able to fix this automatically on most sites, but it appears that you have made changes to your wpsc-user-log.php page. For that reason, we have some <a href="%3$s">simple instructions for you to follow</a> to resolve the issue. We are sorry for the inconvenience.' , 'wpsc' ) . '</p>';
1536
  $message .= "\n<p>" . __( '<a href="%4$s">Hide this warning</a>', 'wpsc' ) . '</p>';
1537
+ $message = sprintf(
1538
  $message,
1539
  WPSC_VERSION,
1540
  'https://github.com/wp-e-commerce/WP-e-Commerce/issues/359',
1541
+ 'http://docs.getshopped.org/documentation/3-8-11-user-logs',
1542
+ esc_url( add_query_arg( 'dismiss_3811_upgrade_notice', 1 ) )
1543
  );
1544
 
1545
  echo '<div id="wpsc-3.8.11-notice" class="error">' . $message . '</div>';
1550
 
1551
  if ( get_option( '_wpsc_3811_user_log_notice' ) )
1552
  add_action( 'admin_notices', '_wpsc_admin_notices_3dot8dot11' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/ajax-and-init.php CHANGED
@@ -18,11 +18,6 @@
18
  * @uses wpsc_find_purchlog_status_name() Finds name of given status
19
  */
20
  function wpsc_admin_ajax() {
21
-
22
- if ( ! wpsc_is_store_admin() ) {
23
- return;
24
- }
25
-
26
  global $wpdb;
27
 
28
  if ( isset( $_POST['action'] ) && $_POST['action'] == 'product-page-order' ) {
@@ -99,11 +94,6 @@ if ( isset( $_REQUEST['ajax'] ) && isset( $_REQUEST['admin'] ) && ($_REQUEST['aj
99
  * @uses $wpdb WordPress database object for queries
100
  */
101
  function wpsc_change_currency() {
102
-
103
- if ( ! wpsc_is_store_admin() ) {
104
- return;
105
- }
106
-
107
  if ( is_numeric( $_POST['currencyid'] ) ) {
108
  $currency_data = $wpdb->get_results( $wpdb->prepare( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`=%d LIMIT 1", $_POST['currencyid'] ), ARRAY_A );
109
  $price_out = null;
@@ -123,11 +113,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
123
  * @uses $wpdb WordPress database object for queries
124
  */
125
  function wpsc_rearrange_images() {
126
-
127
- if ( ! wpsc_is_store_admin() ) {
128
- return;
129
- }
130
-
131
  global $wpdb;
132
  $images = explode( ",", $_POST['order'] );
133
  $product_id = absint( $_POST['product_id'] );
@@ -170,11 +155,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
170
  * @uses wp_redirect() Redirects to string given as argument
171
  */
172
  function wpsc_clean_categories() {
173
-
174
- if ( ! wpsc_is_store_admin() ) {
175
- return;
176
- }
177
-
178
  global $wpdb, $wp_rewrite;
179
  $sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
180
  $sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
@@ -202,6 +182,8 @@ function wpsc_clean_categories() {
202
  '%d'
203
  );
204
 
 
 
205
  } else if ( $datarow['active'] == 0 ) {
206
  $wpdb->update(
207
  WPSC_TABLE_PRODUCT_CATEGORIES,
@@ -214,6 +196,7 @@ function wpsc_clean_categories() {
214
  '%s',
215
  '%d'
216
  );
 
217
  }
218
  }
219
  $wp_rewrite->flush_rules();
@@ -226,7 +209,7 @@ function wpsc_clean_categories() {
226
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
227
  }
228
 
229
- wp_redirect( $sendback );
230
 
231
  exit();
232
  }
18
  * @uses wpsc_find_purchlog_status_name() Finds name of given status
19
  */
20
  function wpsc_admin_ajax() {
 
 
 
 
 
21
  global $wpdb;
22
 
23
  if ( isset( $_POST['action'] ) && $_POST['action'] == 'product-page-order' ) {
94
  * @uses $wpdb WordPress database object for queries
95
  */
96
  function wpsc_change_currency() {
 
 
 
 
 
97
  if ( is_numeric( $_POST['currencyid'] ) ) {
98
  $currency_data = $wpdb->get_results( $wpdb->prepare( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`=%d LIMIT 1", $_POST['currencyid'] ), ARRAY_A );
99
  $price_out = null;
113
  * @uses $wpdb WordPress database object for queries
114
  */
115
  function wpsc_rearrange_images() {
 
 
 
 
 
116
  global $wpdb;
117
  $images = explode( ",", $_POST['order'] );
118
  $product_id = absint( $_POST['product_id'] );
155
  * @uses wp_redirect() Redirects to string given as argument
156
  */
157
  function wpsc_clean_categories() {
 
 
 
 
 
158
  global $wpdb, $wp_rewrite;
159
  $sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
160
  $sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
182
  '%d'
183
  );
184
 
185
+ $updated;
186
+
187
  } else if ( $datarow['active'] == 0 ) {
188
  $wpdb->update(
189
  WPSC_TABLE_PRODUCT_CATEGORIES,
196
  '%s',
197
  '%d'
198
  );
199
+ $updated;
200
  }
201
  }
202
  $wp_rewrite->flush_rules();
209
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
210
  }
211
 
212
+ wp_redirect( esc_url( $sendback ) );
213
 
214
  exit();
215
  }
wpsc-admin/ajax.php CHANGED
@@ -15,7 +15,6 @@
15
  function _wpsc_ajax_verify_nonce( $ajax_action ) {
16
  // nonce can be passed with name wpsc_nonce or _wpnonce
17
  $nonce = '';
18
-
19
  if ( isset( $_REQUEST['nonce'] ) )
20
  $nonce = $_REQUEST['nonce'];
21
  elseif ( isset( $_REQUEST['_wpnonce'] ) )
@@ -192,32 +191,26 @@ function _wpsc_ajax_add_variation_set() {
192
 
193
  require_once( 'includes/walker-variation-checklist.php' );
194
 
195
- if ( ! version_compare( $GLOBALS['wp_version'], '3.8.3', '>' ) ) {
196
-
197
- /* --- DIRTY HACK START --- */
198
- /*
199
- There's a bug with term cache in WordPress core. See http://core.trac.wordpress.org/ticket/14485. Fixed in 3.9.
200
- The next 3 lines will delete children term cache for wpsc-variation.
201
- Without this hack, the new child variations won't be displayed on "Variations" page and
202
- also won't be displayed in wp_terms_checklist() call below.
203
- */
204
- clean_term_cache( $variation_set_id, 'wpsc-variation' );
205
- delete_option('wpsc-variation_children');
206
- wp_cache_set( 'last_changed', 1, 'terms' );
207
- _get_term_hierarchy('wpsc-variation');
208
- /* --- DIRTY HACK END --- */
209
-
210
- }
211
 
212
  ob_start();
213
-
214
  wp_terms_checklist( (int) $_POST['post_id'], array(
215
  'taxonomy' => 'wpsc-variation',
216
  'descendants_and_self' => $variation_set_id,
217
  'walker' => new WPSC_Walker_Variation_Checklist( $inserted_variants ),
218
  'checked_ontop' => false,
219
  ) );
220
-
221
  $content = ob_get_clean();
222
 
223
  $return = array(
@@ -387,7 +380,8 @@ function _wpsc_ajax_purchase_log_send_tracking_email() {
387
  $message = str_replace( '%trackid%', $trackingid, $message );
388
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
389
 
390
- $email = wpsc_get_buyers_email( $id );
 
391
 
392
  $subject = get_option( 'wpsc_trackingid_subject' );
393
  $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
@@ -411,88 +405,6 @@ function _wpsc_ajax_purchase_log_send_tracking_email() {
411
  return $return;
412
  }
413
 
414
- /**
415
- * Do purchase log action link via AJAX
416
- *
417
- * @since 3.9.0
418
- * @access private
419
- *
420
- * @return array|WP_Error $return Response args if successful, WP_Error if otherwise
421
- */
422
- function _wpsc_ajax_purchase_log_action_link() {
423
-
424
- if ( isset( $_POST['log_id'] ) && isset( $_POST['purchase_log_action_link'] ) && isset( $_POST['purchase_log_action_nonce'] ) ) {
425
-
426
- $log_id = absint( $_POST['log_id'] );
427
- $purchase_log_action_link = sanitize_key( $_POST['purchase_log_action_link'] );
428
-
429
- // Verify action nonce
430
- if ( wp_verify_nonce( $_POST['purchase_log_action_nonce'], 'wpsc_purchase_log_action_ajax_' . $purchase_log_action_link ) ) {
431
-
432
- // Expected to receive success = true by default, or false on error.
433
- $return = apply_filters( 'wpsc_purchase_log_action_ajax-' . $purchase_log_action_link, array( 'success' => null ), $log_id );
434
-
435
- } else {
436
- $return = _wpsc_error_invalid_nonce();
437
- }
438
-
439
- if ( ! is_wp_error( $return ) ) {
440
- $return['log_id'] = $log_id;
441
- $return['purchase_log_action_link'] = $purchase_log_action_link;
442
- $return['success'] = isset( $return['success'] ) ? (bool) $return['success'] : null;
443
- }
444
-
445
- return $return;
446
-
447
- }
448
-
449
- return new WP_Error( 'wpsc_ajax_invalid_purchase_log_action', __( 'Purchase log action failed.', 'wpsc' ) );
450
-
451
- }
452
-
453
- /**
454
- * Handle AJAX clear downloads lock purchase log action
455
- *
456
- * The _wpsc_ajax_purchase_log_action_link() function which triggers this function is nonce
457
- * and capability checked in _wpsc_ajax_handler().
458
- *
459
- * @since 3.9.0
460
- * @access private
461
- *
462
- * @param array $response AJAX response.
463
- * @param int $log_id Purchase log ID.
464
- */
465
- function wpsc_purchase_log_action_ajax_downloads_lock( $response, $log_id ) {
466
-
467
- $response['success'] = wpsc_purchlog_clear_download_items( $log_id );
468
-
469
- return $response;
470
-
471
- }
472
- add_action( 'wpsc_purchase_log_action_ajax-downloads_lock', 'wpsc_purchase_log_action_ajax_downloads_lock', 10, 2 );
473
-
474
-
475
- /**
476
- * Handle AJAX email receipt purchase log action
477
- *
478
- * The _wpsc_ajax_purchase_log_action_link() function which triggers this function is nonce
479
- * and capability checked in _wpsc_ajax_handler().
480
- *
481
- * @since 3.9.0
482
- * @access private
483
- *
484
- * @param array $response AJAX response.
485
- * @param int $log_id Purchase log ID.
486
- */
487
- function wpsc_purchase_log_action_ajax_email_receipt( $response, $log_id ) {
488
-
489
- $response['success'] = wpsc_purchlog_resend_email( $log_id );
490
-
491
- return $response;
492
-
493
- }
494
- add_action( 'wpsc_purchase_log_action_ajax-email_receipt', 'wpsc_purchase_log_action_ajax_email_receipt', 10, 2 );
495
-
496
  /**
497
  * Delete an attached downloadable file via AJAX.
498
  *
@@ -548,6 +460,8 @@ function _wpsc_ajax_remove_product_meta() {
548
  *
549
  * @uses wpsc_purchlog_edit_status() Edits purchase log status
550
  * @uses WP_Error WordPress Error class
 
 
551
  * @uses WPSC_Purchase_Log_List_Table
552
  * @uses WPSC_Purchase_Log_List_Table::prepare_items()
553
  * @uses WPSC_Purchase_Log_List_Table::views()
@@ -562,7 +476,10 @@ function _wpsc_ajax_change_purchase_log_status() {
562
 
563
  $args = array();
564
 
565
- $args['screen'] = 'dashboard_page_wpsc-sales-logs';
 
 
 
566
 
567
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-list-table-class.php' );
568
  $purchaselog_table = new WPSC_Purchase_Log_List_Table( $args );
15
  function _wpsc_ajax_verify_nonce( $ajax_action ) {
16
  // nonce can be passed with name wpsc_nonce or _wpnonce
17
  $nonce = '';
 
18
  if ( isset( $_REQUEST['nonce'] ) )
19
  $nonce = $_REQUEST['nonce'];
20
  elseif ( isset( $_REQUEST['_wpnonce'] ) )
191
 
192
  require_once( 'includes/walker-variation-checklist.php' );
193
 
194
+ /* --- DIRTY HACK START --- */
195
+ /*
196
+ There's a bug with term cache in WordPress core. See http://core.trac.wordpress.org/ticket/14485.
197
+ The next 3 lines will delete children term cache for wpsc-variation.
198
+ Without this hack, the new child variations won't be displayed on "Variations" page and
199
+ also won't be displayed in wp_terms_checklist() call below.
200
+ */
201
+ clean_term_cache( $variation_set_id, 'wpsc-variation' );
202
+ delete_option('wpsc-variation_children');
203
+ wp_cache_set( 'last_changed', 1, 'terms' );
204
+ _get_term_hierarchy('wpsc-variation');
205
+ /* --- DIRTY HACK END --- */
 
 
 
 
206
 
207
  ob_start();
 
208
  wp_terms_checklist( (int) $_POST['post_id'], array(
209
  'taxonomy' => 'wpsc-variation',
210
  'descendants_and_self' => $variation_set_id,
211
  'walker' => new WPSC_Walker_Variation_Checklist( $inserted_variants ),
212
  'checked_ontop' => false,
213
  ) );
 
214
  $content = ob_get_clean();
215
 
216
  $return = array(
380
  $message = str_replace( '%trackid%', $trackingid, $message );
381
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
382
 
383
+ $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
384
+ $email = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id`=%d AND `form_id` = '$email_form_field' LIMIT 1", $id ) );
385
 
386
  $subject = get_option( 'wpsc_trackingid_subject' );
387
  $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
405
  return $return;
406
  }
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  /**
409
  * Delete an attached downloadable file via AJAX.
410
  *
460
  *
461
  * @uses wpsc_purchlog_edit_status() Edits purchase log status
462
  * @uses WP_Error WordPress Error class
463
+ * @uses get_bloginfo() Gets information about your WordPress site
464
+ * @uses set_current_screen() Sets current screen object
465
  * @uses WPSC_Purchase_Log_List_Table
466
  * @uses WPSC_Purchase_Log_List_Table::prepare_items()
467
  * @uses WPSC_Purchase_Log_List_Table::views()
476
 
477
  $args = array();
478
 
479
+ if ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) )
480
+ set_current_screen( 'dashboard_page_wpsc-sales-logs' );
481
+ else
482
+ $args['screen'] = 'dashboard_page_wpsc-sales-logs';
483
 
484
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-list-table-class.php' );
485
  $purchaselog_table = new WPSC_Purchase_Log_List_Table( $args );
wpsc-admin/css/admin.css CHANGED
@@ -1,311 +1,237 @@
1
- /**
2
- * WPSC Admin CSS file
3
- */
4
 
 
5
  table.wp-list-table .column-featured {
6
  width: 30px;
7
  }
8
-
9
  table.wp-list-table .column-price,
10
  table.wp-list-table .column-sale_price {
11
  width: 8%;
12
  }
13
-
14
  table.wp-list-table .column-SKU {
15
  width: 11%;
16
  }
17
-
18
  table.wp-list-table .column-stock {
19
  width: 8%;
20
  }
21
-
22
  table.wp-list-table .column-weight {
23
  width: 7%;
24
  }
25
-
26
  table.wp-list-table .column-cats {
27
  width: 15%;
28
  }
29
 
30
  ul.variation_checkboxes li {
31
- margin: 1px 0 3px;
32
  }
33
-
34
  /* This is the variation meta box stuff need to put it in the correct place - mychelle */
35
-
36
- div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td span {
37
- display: none;
38
  }
39
 
40
- div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.weight {
41
  width: 81px;
42
  }
43
 
44
- div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.stock {
45
  width: 110px;
46
  }
47
 
48
- div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.price {
49
  width: 125px;
50
  }
51
 
52
- div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.post-title {
53
  width: 115px;
54
  }
55
 
56
  .wpsc_ie_stock[disabled] {
57
- background-color: #f6f6f6;
58
  }
59
 
60
  div#wpsc_add_variant_desc,
61
- div#wpsc_add_variation_desc {
62
  float: left;
63
- margin: 33px 0px 30px 20px;
64
  }
65
 
66
- div#wpsc_add_variation_desc {
67
- width: 300px;
68
  }
69
 
70
- div#wpsc_add_variant_desc {
71
- width: 200px;
72
  }
73
 
74
- div#wpsc_add_variant {
75
  float: left;
76
  max-width: 245px;
77
  }
78
 
79
- div #add_new_variation {
80
- float: left;
81
- width: 215px;
82
  }
83
 
84
  input.wpsc_ie_field {
85
  margin-bottom:10px;
86
  }
87
 
88
- .wpsc_ie_save {
89
- margin-bottom: 5px;
90
  }
91
 
92
- .wpsc_trackingid_row {
93
- margin-left: 20px;
94
  }
95
 
96
- ul.children {
97
- padding-left: 5px;
98
  }
99
-
100
- .category_indenter {
101
- float: left;
102
- width: auto;
103
  }
104
 
105
-
106
  /**
107
- * Dashboard Widget CSS
108
- */
109
-
110
- #leftDashboard {
111
- width: 45%;
112
- float: left;
113
- text-align: right;
114
- border-right: 1px #999999 solid;
115
-
116
- }
117
-
118
- #leftDashboard strong {
119
- float: left;
120
  padding-left: 40px;
121
  }
122
-
123
- #rightDashboard strong {
124
- float: left;
125
  padding-left: 40px;
126
  }
 
 
 
 
127
 
128
- #rightDashboard {
129
- width: 45%;
130
- float: right;
131
- text-align: right;
132
  }
133
-
134
- .dashboardWidgetSpecial {
135
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
136
- color: #21759B;
137
- font-size: 15px !important;
 
 
 
138
  margin: 5px 0 5px 0;
139
  }
140
-
141
- .dashboardWidget {
142
- color: #777777;
143
- padding-left: 10px;
144
  padding-right: 30px;
145
- }
146
 
147
- span.wpsc_quart_left {
148
- width: 40%;
149
- float: left;
150
  }
151
-
152
- p.atglance {
153
- color: #777777;
154
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
155
- font-size: 13px;
156
- font-style: italic;
157
  }
158
-
159
- span.wpsc_quart_right {
160
- width: 60%;
161
- float: right;
 
 
 
 
 
162
  text-align: right;
163
  }
164
-
165
- #box span {
166
  border-bottom: 1px solid #999999;
167
  }
168
-
169
- p.quarterly {
170
- color: #21759B;
171
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
172
- font-size: 12px;
173
  line-height: 140%;
174
- margin: 5px 0;
175
- }
176
-
177
- /* End of dashboard widget css */
178
-
179
-
180
- /**
181
- * Display Purchase log Details CSS is HERE
182
- */
183
-
184
- #purchlogs_customfields {
185
- clear: both;
186
- }
187
-
188
- th#date {
189
- width: 120px;
190
  }
191
-
192
- th#purchid {
193
- width: 60px;
194
- }
195
-
196
- th#details {
197
- width: 100px;
198
- }
199
-
200
- th#track {
201
- width: 75px;
202
- }
203
-
204
- th#delete {
205
- width: 60px;
206
- }
207
-
208
- th#status {
209
- width: 200px;
210
- }
211
-
212
- #wpsc_items_ordered {
213
- clear: both;
214
- }
215
-
216
- .wpsc_pushdown_img {
217
- float: left;
218
  }
219
-
220
- #wpsc_purchlogitems_links {
221
- clear: both;
222
  }
223
-
224
- #wpsc_purchlog_order_status {
225
- float: right;
226
- width: 250px;
227
  }
228
-
229
- #wpsc_purchlog_order_status .selector {
230
- margin-top: -.2em;
231
  }
232
-
233
- /* Purchase Log Action Links */
234
-
235
- #wpsc_purchlogitems_links a {
236
- text-decoration: none;
237
- line-height: 14pt;
238
  }
239
-
240
- #wpsc_purchlogitems_links img {
241
- padding-top: 2px;
242
- float: left;
243
  }
244
-
245
- #wpsc_purchlogitems_links li .dashicons {
246
- margin-right: 10px;
247
  }
248
-
249
- #wpsc_purchlogitems_links li a {
250
- position: relative;
251
  }
252
-
253
- #wpsc_purchlogitems_links li a .spinner {
254
- display: none;
255
- float: none;
256
- margin: 0px;
257
- position: absolute;
258
- top: 0px;
259
- left: 0px;
260
  }
261
-
262
- #wpsc_purchlogitems_links li a .dashicons {
263
- color: #888;
264
  }
265
-
266
- #wpsc_purchlogitems_links li a .dashicons-yes {
267
- color: #7ad03a;
268
  }
269
-
270
- #wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-delete .dashicons,
271
- #wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-back .dashicons {
272
- color: #bbb;
273
  }
 
 
274
 
275
- #wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-delete:hover .dashicons,
276
- #wpsc_purchlogitems_links li a .dashicons-no {
277
- color: #c00;
278
  }
279
-
280
- #wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-back:hover .dashicons {
281
- color: #888;
282
  }
283
-
284
- #wpsc_purchlogitems_links li a.doing {
285
- padding-left: 30px;
286
  }
287
 
288
- #wpsc_purchlogitems_links li a.doing .spinner {
289
- display: block;
 
290
  }
291
-
292
- #wpsc_purchlogitems_links li a.doing .dashicons {
293
- display: none;
294
  }
295
-
296
- #wpsc_shipping_details_box {
297
- width: 45%;
298
- float: left;
299
- margin: .4em;
300
- padding: .6em;
301
- margin-right: 5em;
302
  }
303
-
304
- #wpsc_billing_details_box {
305
- width: 35%;
306
- float: left;
307
- margin: .4em;
308
- padding: .6em;
309
  }
310
 
311
  #wpsc_shipping_details_box em.field-blank,
@@ -313,195 +239,96 @@ th#status {
313
  color: #999;
314
  }
315
 
316
- #wpsc_purchlog_searchbox {
317
- width: 100%;
318
- text-align: right;
319
- }
320
 
321
 
322
- /**
 
 
323
  * Display Products CSS starts here
324
- */
325
-
326
  .tablenav select[name="bulkAction"] {
327
- width: 100px;
328
  }
329
-
330
- textarea#additional_description {
331
  border: 1px solid #dfdfdf;
 
332
  }
333
 
334
  #poststuff h3.form_heading {
335
- font-size: 1.1em;
336
  margin: 40px 0px 10px 0px;
337
  padding-left: 0px;
338
  }
339
 
340
  #poststuff h3.form_heading span {
341
- font-size: 0.8em;
342
  }
343
 
344
  div.search-box input#page-search-input {
345
  width: 129px;
 
346
  }
347
 
 
348
  #wpsc_product_list,
349
  table.widefat {
350
- width: 100%;
351
  }
352
 
353
  table.widefat .column-hidden_alerts {
354
- display: none;
355
  }
356
 
357
  #wpsc_product_list .column-cb,
358
  table.widefat .column-cb {
 
359
  vertical-align: middle;
360
  }
361
-
362
- #wpsc_product_list .column-image,
363
- #wpsc_product_list .product-image,
364
- table.widefat .column-image,
365
- table.widefat .product-image {
366
  padding-right: 0px;
367
  width: 42px;
368
  }
369
 
370
- .post-type-wpsc-product table.widefat .column-image img {
371
- max-width: 100%;
372
- max-height: 100%;
373
- width: auto;
374
- height: auto;
375
- }
376
-
377
  #wpsc_product_list .column-categories,
378
- table.widefat .column-categories {
 
379
  padding-right:18px;
380
  }
381
 
382
  #wpsc_product_list tbody tr td.column-title,
383
  table.widefat tbody tr td.column-title {
384
- border-right: none;
385
  }
386
 
387
  #wpsc_product_list tbody tr td.product-image img,
388
  table.widefat tbody tr td.product-image img {
389
  margin-top: 4px;
390
- cursor: move;
391
- }
392
-
393
-
394
- /**
395
- * Product Currency and Quantity Discount Layers
396
- */
397
-
398
- .wpsc-currency-layers {
399
- clear: both;
400
- margin: 0 0 15px 0;
401
- padding: 15px 0 0 0;
402
- }
403
-
404
- .wpsc-quantity-discounts {
405
- clear: both;
406
- margin: 0 0 20px 0;
407
- }
408
-
409
- .wpsc-currency-layers table,
410
- .wpsc-quantity-discounts table {
411
- border-collapse: collapse;
412
- margin: 10px 0;
413
- width: 100%;
414
- }
415
-
416
- .wpsc-quantity-discounts table {
417
- margin-top: 20px;
418
- }
419
-
420
- .wpsc-currency-layers th,
421
- .wpsc-quantity-discounts th {
422
- font-weight: normal;
423
- text-align: left;
424
- vertical-align: bottom;
425
- }
426
-
427
- .wpsc-currency-layers th.price,
428
- .wpsc-quantity-discounts th.price {
429
- width: 30%;
430
- }
431
-
432
- .wpsc-quantity-discounts th.qty {
433
- width: 40%;
434
- }
435
-
436
- .wpsc-quantity-discounts td {
437
- line-height: 28px;
438
- }
439
-
440
- .wpsc-quantity-discounts td.curr {
441
- text-align: right;
442
- }
443
-
444
- .wpsc-currency-layers th.remove,
445
- .wpsc-quantity-discounts th.remove {
446
- width: 20px;
447
- }
448
-
449
- .wpsc-currency-layers td,
450
- .wpsc-quantity-discounts td {
451
- padding: 3px 2px 3px 0px;
452
- }
453
-
454
- .wpsc-currency-layers .newCurrency {
455
- margin: 0px;
456
- width: 95%;
457
- }
458
-
459
- .wpsc-quantity-discounts .qty input {
460
- width: 4em;
461
- }
462
-
463
- .wpsc-currency-layers .newCurrPrice,
464
- .wpsc-quantity-discounts .newCurrPrice {
465
- width: 100%;
466
- }
467
-
468
- .wpsc_delete_currency_layer,
469
- .wpsc-quantity-discounts .remove_line {
470
- color: #bbb;
471
- display: block-inline;
472
- font size: 16px;
473
- line-height: 20px;
474
- margin: 4px 0 0 0;
475
- text-align: center;
476
- width: 20px;
477
- height: 20px;
478
  }
479
 
480
- .wpsc_delete_currency_layer:hover,
481
- .wpsc-quantity-discounts .remove_line:hover {
482
- color: #c00;
483
  }
484
-
485
- div.wpsc_floatleft {
486
- width: 161px;
487
- float: left;
488
  }
489
-
490
  div.wpsc_floatleft label {
491
- line-height: 18px;
492
- white-space: nowrap;
493
- display: block
494
  }
495
 
496
-
497
- /**
498
- * Sortable product styling
499
- */
500
 
501
  table.product_editform {
502
- width: 100%;
503
  }
504
 
 
505
  #wpsc_product_list .ui-sortable-helper,
506
  table.widefat .ui-sortable-helper {
507
  width: 410px;
@@ -509,16 +336,12 @@ table.widefat .ui-sortable-helper {
509
  background-color: #FEFEFE;
510
  }
511
 
512
- #wpsc_product_list .ui-sortable-helper td,
513
- #wpsc_product_list .ui-sortable-helper th,
514
- table.widefat .ui-sortable-helper td,
515
- table.widefat .ui-sortable-helper th {
516
  border-top: 1px solid #DFDFDF;
517
  opacity: .4;
518
  }
519
-
520
- .wpsc-sortable-table-placeholder td,
521
- .product-placeholder {
522
  border-width: 1px;
523
  border-style: dashed;
524
  z-index: 900;
@@ -528,7 +351,7 @@ table.widefat .ui-sortable-helper th {
528
  }
529
 
530
  div#poststuff table tr td {
531
- vertical-align: top;
532
  }
533
 
534
  div#poststuff textarea {
@@ -542,15 +365,16 @@ div.admin_product_name label {
542
 
543
  div.admin_product_name {
544
  position: relative;
545
- height: 30px;
 
546
  background: #ffffff;
 
547
  border: 1px solid #dfdfdf;
 
 
548
  -webkit-border-radius: 6px;
549
- -khtml-border-radius: 6px;
550
- -moz-border-radius: 6px;
551
- border-radius: 6px;
552
  }
553
-
554
  div.admin_product_name input.wpsc_product_name {
555
  border: none;
556
  }
@@ -559,15 +383,16 @@ div.admin_product_name a.shorttag_toggle {
559
  position: absolute;
560
  top: 0px;
561
  right: 0px;
562
- background: url(../../wpsc-core/images/info_icon.jpg) no-repeat scroll 5px 8px;
563
- border-left: 1px solid #DFDFDF;
564
- display: block;
565
- height: 100%;
566
- padding: 0px 3px 0px 3px;
567
- width: 18px;
568
  }
569
 
570
- div#icon_card {
 
571
  float: left;
572
  height: 36px;
573
  margin: 7px 8px 0 0;
@@ -575,38 +400,80 @@ div#icon_card {
575
  background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
576
  }
577
 
578
- /* Can .admin_product_shorttags be deprecated */
579
-
580
  div.admin_product_shorttags {
581
- width: 93%;
582
- min-width: 396px;
583
- max-width: 558px;
 
584
  clear: both;
585
  padding: 6px;
586
  font-size: 8pt;
587
- margin: 0 0 0 6px !important;
588
- border-left: 1px solid #DFDFDF;
589
- border-right: 1px solid #DFDFDF;
590
- border-bottom: 1px solid #DFDFDF;
 
591
  display: none;
 
592
  background-color: #ffffff;
593
  }
594
 
595
  #description {
596
- margin: 0;
 
597
  }
598
 
599
  h4.product_action_link {
600
- margin: 4px 0px 0px 0px;
 
 
 
 
 
 
 
 
601
  display: block;
602
- font-weight: bold;
 
 
 
 
603
  }
604
 
605
 
606
- /**
607
- * Image form styling
608
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
 
 
610
  div.flash-image-uploader {
611
  display: none;
612
  }
@@ -615,100 +482,108 @@ div.flash-image-uploader {
615
  position: relative;
616
  border: none;
617
  }
618
-
619
- #wpbody-content div.flash-image-uploader #media-items .progress {
620
  position: static;
621
- margin: 0 0 6px;
622
  height: 16px;
623
  }
624
 
625
  .ui-selected {
626
- border: 2px dashed #969696;
627
  }
628
 
629
  img.deleteButton {
630
- display: none;
631
- position: absolute;
632
- top: -5px;
633
  right: -1px;
634
- width: 16px;
635
- height: 16px;
636
- cursor: pointer;
637
  }
638
-
639
  a.editButton {
640
- background: #FFFFFF none repeat scroll 0%;
641
- height: 20px;
642
- display: none;
643
- position: absolute;
644
- right: 0px;
645
- top: 0px;
646
- padding-bottom: 3px;
647
- padding-left: 3px;
648
- cursor: pointer;
649
  }
650
 
651
  div.image_settings_box {
652
- position: absolute;
653
- width: 150px;
654
- display: none;
655
  margin: -66px 0px 0px 36px;
656
- padding-top: 2px;
657
- width: 252px;
658
- z-index: 69;
 
 
659
  }
660
 
661
  a.thickbox img {
662
- border: medium none;
663
  }
664
 
665
  img.previewimage {
666
- cursor: move;
667
- height: 60px;
668
- margin-right: 4px;
669
- width: 60px;
670
  }
671
 
672
  div.lower_settings_box {
673
- width: 234px;
674
- background-color: white;
675
- border: 1px solid black;
676
- border-top: 1px solid #CCCCCC;
677
- float: right;
678
  margin: -1px -6px 0px 0px;
679
  padding: 2px 0 0 4px;
680
- background-color: #EAF3FA;
681
  }
682
 
683
  div.upper_settings_box {
684
- width: 250px;
685
- background-color: white;
686
- border: 1px solid black;
687
- padding: 3px 1px 2px 5px;
688
  }
689
 
690
  div.upper_image {
691
- float: left;
692
- padding-left :5px;
693
- margin-left: -5px;
694
- margin-right: -7px;
695
- padding-bottom: 4px;
 
 
 
 
696
  }
697
 
698
- div.upper_txt {
699
- padding-left: 22px;
700
- color: #666666;
701
  }
702
 
703
  div.previewimage {
704
- position: relative;
705
  }
706
 
707
- tr.edit_product_image * {
708
- z-index: 80;
709
  }
710
 
711
- div.browser-image-uploader h4 {
 
 
 
 
712
  margin-bottom: 8px;
713
  }
714
 
@@ -720,32 +595,29 @@ div.image_resize_extra_forms {
720
  width: 100%;
721
  }
722
 
723
- #wpsc_product_category_and_tag_forms table td.itemfirstcol {
724
- padding-left: 3pt;
725
  width: 50%;
726
  }
727
 
 
728
 
729
- /**
730
- * Variations CSS starts
731
- */
732
-
733
- table.product_variation_listing {
734
  margin-bottom: 12px;
735
  }
736
 
737
- table.product_variation_listing th.variation_name {
738
  color: #71A4C8;
739
  font-style: italic;
740
  text-align: left;
741
  padding-bottom: 1px;
742
  }
743
 
744
- table.product_variation_grid {
745
  margin-top: 12px;
746
  }
747
 
748
- table.product_variation_grid th.variation_name {
749
  color: #71A4C8;
750
  font-style: italic;
751
  text-align: left;
@@ -755,14 +627,12 @@ table.product_variation_grid th.variation_name {
755
  div#edit_variations_container {
756
  margin-top: 12px;
757
  }
758
-
759
  table.product_variation_grid {
760
  border-collapse: collapse;
761
  margin-top: 0px;
762
  }
763
 
764
- table.product_variation_grid tr td,
765
- table.product_variation_grid tr th {
766
  border: 1px solid #cccccc;
767
  border-collapse: collapse;
768
  text-align: left;
@@ -781,17 +651,16 @@ table.product_variation_grid tr th.price {
781
  width: 78px;
782
  }
783
 
784
- table.product_variation_grid tr td.variations,
785
- table.product_variation_grid tr th {
786
  padding: 4px 0px 4px 10px;
787
  }
788
 
789
- table.product_variation_grid tr td.variations,
790
- table.product_variation_grid tr th.variations {
791
  width: 300px;
792
  }
793
 
794
- table.product_variation_grid tr td input {
 
795
  padding: 0px 3px 0px 3px;
796
  }
797
 
@@ -800,11 +669,10 @@ table.product_variation_grid tr.group_boundary td {
800
  }
801
 
802
  a.about_this_page_sub {
803
- text-decoration: underline;
804
  }
805
 
806
- table.product_variation_grid tr td,
807
- table.product_variation_grid tr th {
808
  border: 1px solid #cccccc;
809
  border-collapse: collapse;
810
  text-align: left;
@@ -819,14 +687,15 @@ table.product_variation_grid tr.settings_row td {
819
  padding: 0px !important;
820
  }
821
 
 
822
  table.product_variation_grid tr.settings_row td div.variation_settings {
823
  display: none;
824
  border-top: 1px dotted #cccccc;
825
  width: 100%;
826
  min-height: 30px;
827
  padding: 4px 10px;
828
- }
829
 
 
830
  table.product_variation_grid tr th {
831
  border-bottom: 1px solid #969696;
832
  }
@@ -840,23 +709,22 @@ table.product_variation_grid tr th.price {
840
  width: 78px;
841
  }
842
 
843
- table.product_variation_grid tr td.variations,
844
- table.product_variation_grid tr th {
845
  padding: 4px 0px 4px 10px;
846
  }
847
 
848
- table.product_variation_grid tr td.variations,
849
- table.product_variation_grid tr th.variations {
850
  width: 300px;
851
  }
852
 
853
- table.product_variation_grid tr td input {
 
854
  padding: 0px 3px 0px 3px;
855
  }
856
 
857
- table.product_variation_grid tr td input.checkbox {
858
  display: block;
859
- margin: 6px auto;
860
  }
861
 
862
  table.product_variation_grid tr.group_boundary td {
@@ -880,22 +748,22 @@ a.variation_edit_button {
880
  height: 16px;
881
  width: 16px;
882
  margin: 4px auto 0px auto;
 
883
  }
884
 
885
- div.variation_settings div.variation_settings_contents {
886
  padding-left: 10px;
887
  }
888
 
889
  div.select_variation_file {
890
  padding-left: 6px;
891
  }
892
-
893
  div.select_variation_file p {
894
- margin: 0 0 3px;
895
  }
896
 
897
  div.select_variation_file p {
898
- margin: 0 0 3px;
899
  }
900
 
901
  div.select_variation_file p input {
@@ -904,81 +772,78 @@ div.select_variation_file p input {
904
  }
905
 
906
  .variation_checkboxes li {
907
- margin: 0;
908
  }
909
 
910
  .variation_checkboxes ul {
911
- margin-left: 30px;
912
  }
913
 
914
  .js .variation_checkboxes .children {
915
- display: none;
916
  }
917
 
918
  .js .variation_checkboxes .expanded .children {
919
- display: block;
920
  }
921
 
922
  .variation_checkboxes a.expand {
923
- background: url(arrows.png) no-repeat left -108px;
924
- display: inline-block;
925
- height: 15px;
926
- width: 15px;
927
- text-indent: -999em;
928
- vertical-align: middle;
929
  }
930
 
931
  .variation_checkboxes .expanded a.expand {
932
- background-position: left top;
933
  }
934
 
935
  #add-new-variation-set {
936
- margin-bottom: 20px;
937
- display: none;
938
  }
939
 
940
  #add-new-variation-set p {
941
- position: relative;
942
  }
943
 
944
  #add-new-variation-set p.howto {
945
- margin-bottom: 16px;
946
  }
947
 
948
  #add-new-variation-set p label.focus {
949
- color: #666;
950
  }
951
 
952
  #add-new-variation-set p.error label {
953
- color: red;
954
  }
955
 
956
  #add-new-variation-set p label {
957
- color: #000;
958
- cursor: text;
959
- left: 6px;
960
- position: absolute;
961
- top: 4px;
962
  }
963
 
964
  #add-new-variation-set .text-field {
965
- width: 195px;
966
  }
967
 
968
  .variation-set-prototype {
969
- display: none;
970
  }
971
-
972
- /* Variations CSS ends */
973
 
974
  div#side-sortables input[type="file"] {
975
- width: 250px;
976
  }
977
-
978
  .wpsc_product_downloads_header {
979
  margin: 0 0 5px;
980
  }
981
-
982
  .select_product_file,
983
  .edit_select_product_file {
984
  margin-bottom: 0;
@@ -999,58 +864,65 @@ img.wpsc_add_download {
999
  top: 2px;
1000
  }
1001
 
 
 
 
 
 
 
1002
  a.file_delete_button {
1003
- cursor: pointer;
1004
- color: red;
1005
  display: block;
1006
  }
1007
 
1008
  a.delete_button {
1009
- border-color: -moz-use-text-color -moz-use-text-color #FF0000;
1010
- border-style: none none solid;
1011
- border-width: medium medium 1px;
1012
- color: #FF0000;
1013
- font-size: 11px;
1014
- padding: 1px 2px;
1015
- text-decoration: none;
 
 
 
 
 
 
1016
  }
 
 
 
 
1017
 
1018
- .greytext {
1019
- color: #666666;
1020
- }
1021
-
1022
- span.small_italic {
1023
- font-style: italic;
1024
- }
1025
-
1026
- /* Product details form styling ends */
1027
-
1028
- /* Display Products CSS ends here */
1029
-
1030
-
1031
- /**
1032
- * Product Groups styles start here
1033
- */
1034
-
1035
- td.firstcol div.postbox div.inside {
1036
  margin: 0px;
1037
  padding: 0px;
1038
  }
1039
 
1040
- table#productpage {
1041
  width: 100%;
1042
  clear: both;
1043
  border-collapse: collapse;
1044
  }
1045
 
1046
- table#productpage tr td {
1047
  vertical-align: top;
 
1048
  }
1049
 
1050
- table#productpage tr td.secondcol {
 
 
1051
  padding: 0px 2px 0px 16px;
 
1052
  }
1053
 
 
1054
  table.category-edit {
1055
  border-collapse: collapse;
1056
  width: 100%;
@@ -1063,100 +935,93 @@ table.category-edit tr td.column-title {
1063
  width: 450px;
1064
  }
1065
 
 
1066
  div.category-image-container {
1067
  width: 55px;
1068
  height: 30px;
 
1069
  }
1070
 
1071
  div.category-image-container img {
1072
  float: left;
1073
  }
1074
-
1075
  div.category-image-container img.category_indenter {
1076
  margin-right: 3px;
1077
- width: auto;
1078
- float: left;
1079
  }
1080
 
1081
- div#productform {
1082
- display: none;
1083
- width: 99.5%;
1084
- }
1085
 
1086
- div#edititem27 {
1087
- display: none;
1088
- width: 586px;
1089
- }
1090
 
1091
- div#productform table tr td {
1092
- height: 11px !important;
1093
- }
1094
 
1095
- div#blank_item {
1096
- display: block;
1097
- }
1098
 
1099
- #poststuff div#blank_item h3 {
 
 
 
 
 
 
 
 
 
 
 
1100
  margin-top: 0px;
1101
- }
1102
 
1103
- div#additem {
1104
- display: none;
1105
  }
1106
 
1107
- div#productform td.itemfirstcol {
1108
- padding-left: 4px;
1109
- vertical-align: top;
1110
- }
1111
 
1112
- div#productform input.text,
1113
- div#additem input.text {
1114
- width: 386px;
1115
- border: 1px solid #bbb;
 
 
 
 
1116
  }
1117
 
 
1118
  table.category_forms {
1119
  width: 100%;
1120
  }
1121
-
1122
  table.category_forms tr td {
1123
  padding: 0px;
1124
  padding-right: 8px;
1125
  }
1126
-
1127
- table.category_forms tr td textarea {
1128
  width: 386px;
1129
  }
1130
 
1131
- div#edit_variation_values input.text {
1132
- width: 286px !important;
1133
- border: 1px solid #bbb;
1134
- }
1135
 
1136
- input.image_resize {
1137
- position: relative;
1138
- top: 4px;
1139
- }
1140
 
1141
- div#additem table.additem input.wpsc_tag {
1142
- width: 180px;
1143
  }
1144
-
1145
- div#additem label {
1146
  font-style: normal;
1147
  font-size: 0.95em;
1148
  }
1149
 
1150
- .groupItem {
1151
- border-top: 1px solid #bbb;
1152
- width: 385px;
1153
- height: 35px;
 
 
 
 
1154
  clear: both;
 
1155
  padding: 0px 0px 4px 0px;
1156
  }
1157
 
1158
- .groupItem .itemHeader {
1159
- width: 65px;
1160
  line-height: 15px;
1161
  color: #000;
1162
  padding: 4px;
@@ -1166,25 +1031,24 @@ div#additem label {
1166
  clear: both;
1167
  }
1168
 
1169
- .groupItem .itemHeader a {
1170
  margin: 4px 0px 4px 0px;
1171
  font-weight: normal;
1172
  font-size: 11px;
1173
  text-decoration: none;
1174
  }
1175
-
1176
- .sortHelper {
1177
  border: 3px dashed #666;
1178
  width: auto;
1179
  }
1180
-
1181
- .groupWrapper p {
1182
  height: 1px;
1183
  overflow: hidden;
1184
  margin: 0;
1185
  padding: 0;
1186
  }
1187
 
 
1188
  table#productpage tr td.secondcol.product_groups_page {
1189
  padding-left: 16px;
1190
  }
@@ -1194,42 +1058,41 @@ table#productpage tr td.secondcol.product_groups_page h4 {
1194
  margin-top: 20px;
1195
  }
1196
 
1197
- td.product_groups_page #additem .inside,
1198
- td.product_groups_page #productform .inside {
1199
  margin: 0px 0px 15px 0px;
1200
  }
1201
 
1202
  div.editing_this_group {
1203
  margin-top: 8px;
1204
  margin-bottom: 8px;
1205
- width: 100%;
 
1206
  }
1207
 
1208
  td.product_groups_page h4 {
1209
  margin-bottom: 1ex;
1210
  }
1211
-
1212
- #editorcontainer {
1213
- clear: both;
1214
  }
1215
-
1216
  td.product_groups_page td.category_presentation_settings {
1217
  padding-bottom: 1ex;
1218
  }
1219
 
1220
  div.editing_this_group {
1221
- font-size: 8pt;
1222
  }
1223
 
1224
  div.editing_this_group p {
1225
- padding: 4px 4px 4px 8px;
1226
  }
1227
 
1228
  div.editing_this_group dl {
1229
- padding: 4px 4px 4px 8px;
1230
  }
1231
 
1232
- #blank_item a.add_category_link {
 
1233
  display: block;
1234
  margin: 8px 8px 8px 0px;
1235
  text-decoration: underline;
@@ -1239,6 +1102,7 @@ div.product_group {
1239
  margin: 12px 0px 10px 0px;
1240
  }
1241
 
 
1242
  table#wpsc_category_list td div.subcategory img.category_indenter {
1243
  float: left;
1244
  margin: 8px 0px 0px 0px;
@@ -1248,11 +1112,8 @@ table#wpsc_category_list td div.subcategory table.itemlist {
1248
  float: left;
1249
  }
1250
 
1251
- label.select_categorisation_group,
1252
- select#select_categorisation_group,
1253
- a.add_categorisation_group,
1254
- a.edit_categorisation_group,
1255
- #submit_categorisation_form span {
1256
  display: block;
1257
  float: left;
1258
  }
@@ -1269,6 +1130,7 @@ a.edit_categorisation_group,
1269
 
1270
  label.select_categorisation_group {
1271
  padding-top: 4px;
 
1272
  font-size: 11px;
1273
  }
1274
 
@@ -1280,38 +1142,39 @@ a.edit_categorisation_group {
1280
  margin-left: 30px;
1281
  }
1282
 
1283
- div#add_categorisation,
1284
- div#edit_categorisation {
 
1285
  display: none;
1286
  border: 1px solid #BBBBBB;
1287
  padding: 4px;
1288
  margin-top: 6px;
1289
  }
1290
 
1291
- div#add_categorisation br,
1292
- div#edit_categorisation br {
1293
  clear: both;
1294
  }
1295
 
1296
- div#add_categorisation fieldset,
1297
- div#edit_categorisation fieldset {
1298
  width: 230px;
1299
  float: left;
1300
  border: none;
1301
  }
1302
 
1303
- div#add_categorisation fieldset label,
1304
- div#edit_categorisation fieldset label {
1305
  display: block;
1306
  }
1307
 
1308
- ul.categorisation_links {
1309
  list-style-type: none;
1310
  clear: both;
1311
  padding: 0px;
1312
  }
1313
-
1314
- ul.categorisation_links li {
 
 
1315
  display: block;
1316
  float: left;
1317
  list-style-type: none;
@@ -1320,10 +1183,9 @@ ul.categorisation_links li {
1320
  padding: 4px;
1321
  }
1322
 
1323
- ul.categorisation_links li.selected a {
1324
  color: #D54E21;
1325
  }
1326
-
1327
  .multiple-select-container {
1328
  margin-left: 0.5em;
1329
  }
@@ -1338,16 +1200,14 @@ ul.categorisation_links li.selected a {
1338
  padding: 0 0 0 5px;
1339
  position: relative;
1340
  }
1341
-
1342
  .multiple-select input {
1343
  width: inherit;
1344
  }
1345
-
1346
  .multiple-select label {
1347
  display: inherit;
1348
  }
1349
 
1350
- table.category_forms a.delete_button {
1351
  display: block;
1352
  margin: 3px 0px 0px 8px;
1353
  float: left;
@@ -1357,65 +1217,64 @@ table.category_forms td.last_row {
1357
  padding: 16px 0px 0px 0px;
1358
  }
1359
 
1360
- .wpsc_gold_float {
1361
- min-width: 45%;
1362
- float: left;
1363
- max-width: 450px;
 
1364
  }
1365
-
1366
- .wpsc_gold_text {
1367
- width: 70%;
1368
- float: left;
1369
- clear: both;
 
 
 
 
1370
  }
1371
 
1372
- .wpsc_gold_info {
1373
- width: 30%;
1374
- float: right;
1375
  text-align: center;
1376
- font-size: 20px;
1377
  }
 
 
 
1378
 
1379
- .wpsc_gold_module {
1380
- width: 100%;
1381
- float: left;
1382
  border-bottom: 1px solid #DFDFDF;
1383
  }
1384
-
1385
- .wpsc_gold_module strong {
1386
- width: auto;
1387
- float: left;
1388
  }
1389
-
1390
- #visitInstinct {
1391
- float: right;
1392
- margin: 5px 20px 0 0;
1393
  }
1394
 
1395
- #gold_cart_form .postbox p img {
1396
- padding-bottom: 10px;
1397
- }
1398
 
1399
- #wpsc_gold_options_outside {
1400
- width: 400px;
1401
  }
1402
-
1403
- #gold_cart_form .postbox p {
 
 
1404
  padding-left: 4px;
1405
  }
1406
-
1407
- #gold_cart_form .postbox {
1408
- width: 100%;
1409
- max-width: 500px;
1410
  }
1411
-
1412
- #gold_cart_form .postbox p {
1413
- padding-left: 10px;
1414
  }
1415
-
1416
- #gold_cart_form .postbox p label {
1417
- width: 80px;
1418
- float: left;
1419
  }
1420
 
1421
  a.admin_download {
@@ -1425,27 +1284,27 @@ a.admin_download {
1425
  text-decoration: none;
1426
  }
1427
 
1428
- a.admin_download img {
1429
  margin-right: 3px;
1430
  }
1431
 
1432
- a.admin_download span {
1433
  text-decoration: underline;
1434
  }
1435
 
1436
-
1437
- /**
1438
- * Product Groups styles end here
1439
- */
1440
-
1441
- .wpsc_td_note {
1442
- padding-bottom: 0 !important;
1443
  }
1444
 
1445
  .wpsc_purchaselogs_options {
1446
  margin: 0px 0px 8px 0px;
 
1447
  }
1448
 
 
1449
  p.add_new_form_set_forms {
1450
  display: none;
1451
  }
@@ -1453,13 +1312,14 @@ p.add_new_form_set_forms {
1453
  td.product-image a img.attachment-thumbnail {
1454
  height: 38px;
1455
  width: 38px;
 
1456
  }
1457
 
1458
  #wpsc_product_category_and_tag_forms .tagchecklist {
1459
- font-size: 11px;
1460
  }
1461
 
1462
- #categorydiv div {
1463
  margin-top: 4px;
1464
  }
1465
 
@@ -1469,116 +1329,63 @@ a.variation_handle {
1469
  font-size: 15px;
1470
  }
1471
 
1472
- .toplevel_page_wpsc-edit-products .wrap h2 {
1473
- padding-bottom: 0px;
1474
- border-bottom: 1px solid #CCC;
 
1475
  }
1476
-
1477
- #post-body #advanced-sortables {
1478
- margin-right: 300px
1479
  }
1480
-
1481
  #media-buttons #add_audio,
1482
  #media-buttons #add_video,
1483
  #media-buttons #add_media {
1484
- display: none;
1485
  }
1486
-
1487
  .meta-box-sortables-wpec .postbox:hover .handlediv {
1488
  background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
1489
  }
1490
 
 
1491
 
1492
- /**
1493
- * Marketing / coupon page styling
1494
- */
1495
-
1496
- div.modify_coupon {
1497
- border: 1px solid #eeeeee;
1498
- display: none;
1499
- width: 100%;
1500
- }
1501
-
1502
- table.coupon_data {
1503
- width: 100%;
1504
- }
1505
-
1506
- table.add-coupon {
1507
- width: 100%;
1508
- }
1509
-
1510
- table.add-coupon tr th {
1511
- text-align: left;
1512
- padding: 2px 5px 0px 5px;
1513
- border: none;
1514
- }
1515
-
1516
- table.add-coupon tr td {
1517
- text-align: left;
1518
- padding: 2px 5px 2px 5px;
1519
- border: none;
1520
- }
1521
-
1522
- table.add-coupon tr td p {
1523
- padding: 0;
1524
- margin: 5px;
1525
- }
1526
- #table_header {
1527
- font-size: 16px;
1528
- margin-top: 20px;
1529
- font-weight: bold;
1530
- }
1531
-
1532
- table.coupon-list {
1533
  width: 100%;
1534
  }
1535
-
1536
- table.coupon-list th {
1537
- text-align: left;
1538
- }
1539
-
1540
- table.coupon-list tr.toprow td {
1541
- text-align: left;
1542
  font-weight: bold;
1543
  }
 
 
 
1544
 
1545
- table.coupon-list tr td {
1546
- padding: 5px 5px 10px 10px;
1547
- vertical-align: middle;
1548
- }
1549
 
1550
- table.coupon-list tr.alt {
1551
- background-color: #eeeeee;
1552
- }
1553
-
1554
- table.coupon-list tr.alt td {
1555
- background-color: #eeeeee;
1556
- }
1557
-
1558
- table.coupon-list tr.coupon_edit td {
1559
- padding: 0;
1560
- }
1561
 
1562
- td#order_summary_container {
1563
- width: 80px;
 
 
 
 
 
 
 
 
1564
  }
1565
-
1566
- table.category_forms a.delete_button,
1567
- span.delete_button {
1568
- color: #FF0000;
1569
- display: block;
1570
- float: left;
1571
- font-size: 11px;
1572
- margin: 3px 0 0 8px;
1573
- text-decoration: underline;
1574
  }
1575
-
1576
- p span.input_label {
1577
- font-size: 1.2em;
1578
- width: 180px;
1579
- float: left;
1580
- }
1581
-
1582
  a.wpsc_featured_product_toggle {
1583
  display: block;
1584
  height: 18px;
@@ -1586,18 +1393,10 @@ a.wpsc_featured_product_toggle {
1586
  margin: 4px 0px 0px 0px;
1587
  }
1588
 
1589
- .column-featured a {
1590
- background: url(../../wpsc-core/images/core-sprite.png) no-repeat 0 -32px transparent;
1591
- }
1592
-
1593
- .column-featured a.gold-star {
1594
- background-position: 0 -16px;
1595
- }
1596
-
1597
  .column-featured a:active,
1598
- .column-featured a.gold-star:active {
1599
- background-position: 0 0;
1600
- }
1601
 
1602
  div.wpsc_clear {
1603
  clear: both;
@@ -1610,6 +1409,7 @@ div.wpsc_clear {
1610
  position: relative;
1611
  }
1612
 
 
1613
  .wpsc_featured .item_text {
1614
  float: left;
1615
  height: 240px;
@@ -1628,12 +1428,13 @@ div.wpsc_clear {
1628
  height: 240px;
1629
  width: 340px;
1630
  border: 1px solid #FEFAF1;
 
 
1631
  -webkit-border-radius: 18px;
1632
- -moz-border-radius: 18px;
1633
- border-radius: 18px;
1634
  background-repeat: no-repeat;
1635
  }
1636
 
 
1637
  .wpsc_featured .item_text h3 {
1638
  font-size: 1.4em;
1639
  margin: 0px 0px 8px 0px;
@@ -1644,167 +1445,172 @@ div.wpsc_clear {
1644
  line-height: normal;
1645
  display: block;
1646
  margin: 0px 0px 4px 0px;
 
1647
  }
1648
 
1649
  .wpsc_featured .item_text .wpsc_description {
1650
  font-size: 1em;
1651
- line-height: 24px;
1652
- display: block;
1653
- float: left;
1654
  width: auto;
1655
  color: #9B9A96;
1656
- font-family: Georgia, "Bitstream Charter", serif;
1657
  }
1658
 
1659
  .wpsc_featured .item_text .wpsc_description p {
1660
  margin-bottom: 0px;
1661
  }
1662
 
 
1663
  .wpsc_featured .item_text .wpsc_description a {
1664
- color: #9B9A96;
1665
  }
1666
 
1667
  ul.wpsc_categories {
1668
  clear: both;
1669
  }
1670
 
1671
- a.update_variations_action {
1672
- vertical-align: middle;
 
1673
  }
1674
-
1675
  #poststuff .inside p.update-variations {
1676
- display: none;
1677
- margin-top: 1em;
1678
  }
1679
-
1680
- #search-products {
1681
- width: auto;
1682
- float: right;
1683
  }
1684
-
1685
- .productnav {
1686
- height: 30px;
1687
- margin: 6px 0px 4px;
1688
- vertical-align: middle;
1689
  }
1690
 
1691
  #wpsc_stock_control_forms .edit_stock {
1692
- margin-top: 15px;
1693
- line-height: 16px;
1694
  }
1695
-
1696
  #wpsc_stock_control_forms .unpublish_when_none_left,
1697
  #wpsc_stock_control_forms .notify_when_none_left {
1698
- margin: 0.5em 0;
1699
  }
1700
-
1701
  #media-upload form p.help {
1702
- text-align: left;
1703
- clear: both;
1704
  }
 
 
 
 
 
 
 
1705
 
1706
- ul#category_list_li li:hover span.handle {
1707
- cursor: move;
1708
  }
1709
 
 
 
 
 
 
 
 
 
 
1710
  ul#category_list_li li span.handle {
1711
- float: left;
 
1712
  padding: 5px;
 
1713
  }
1714
 
1715
- .category_admin_list_img a.row-title {
1716
  text-decoration: none;
1717
  }
1718
 
 
1719
  .category_admin_list_img:hover div.row-actions {
1720
- visibility: visible;
1721
  }
1722
 
1723
  ul#category_list_li ul {
1724
- margin-left: 15px;
1725
  }
1726
 
1727
  .row-title img {
1728
- width: 30px;
1729
- float: left;
1730
- padding-right: 10px;
1731
  }
1732
-
1733
  .row-title {
1734
- margin-right: 5px;
1735
  }
1736
-
1737
  body.edit-php form#posts-filter {
1738
- min-width: 830px;
1739
  }
1740
-
1741
  input.wpsc_cat_image_size {
1742
- width: 40px
1743
  }
1744
-
1745
  input.wpsc_cat_box {
1746
- width: auto;
1747
- margin: 6px;
1748
- vertical-align: middle;
1749
  }
1750
 
1751
- .wpsc_ie_field {
1752
- width: 100%;
1753
  }
1754
-
1755
  .wpsc_inline_actions .loading_indicator {
1756
- position: relative;
1757
- top: 3px;
1758
- left: 2px;
1759
  visibility: hidden;
1760
  }
1761
-
1762
  table.tags th#image {
1763
- width: 60px;
1764
  }
1765
-
1766
-
1767
- /**
1768
- * Quick and bulk edit product
1769
- */
1770
-
1771
  #wpbody-content .bulk-edit-row-post fieldset.wpsc-cols {
1772
- width: 49%;
1773
- margin-top: 0;
1774
  }
1775
 
1776
  #wpbody-content .quick-edit-row-post .inline-edit-col-left {
1777
- width: 35%;
1778
  }
1779
 
1780
  .bulk-edit-row-post fieldset.inline-edit-col-right label span.title {
1781
- padding-right: 0.5em;
1782
- width: auto;
1783
  }
1784
 
1785
  .wpsc-quick-edit {
1786
- width: 30%;
1787
- float: left;
1788
  }
1789
 
1790
  textarea.tax_input_product_tag {
1791
- width: 50% !important;
1792
- height: 95px !important;
1793
  }
1794
 
1795
  ul.wpsc_product_category-checklist {
1796
- height: 280px;
1797
  }
1798
 
1799
- span.wpsc-quick-edit {
1800
- width: 77px;
1801
- display: block;
1802
- float: left;
1803
  }
1804
-
1805
- .wpsc_var_description {
1806
- margin: 20px 0 0 20px !important;
1807
- color: red;
1808
  }
1809
 
1810
  .ajax-loading {
@@ -1812,185 +1618,173 @@ span.wpsc-quick-edit {
1812
  }
1813
 
1814
  #cart_options .delete {
1815
- color: #c00;
1816
- float: right;
1817
  }
1818
-
1819
  #cart_options .delete:hover {
1820
- color: #D54E21;
1821
  }
1822
 
1823
  .dashboard_page_wpsc-update .wpsc-progress-bar {
1824
- position: relative;
1825
- height: 20px;
1826
- width: 300px;
1827
- border: 1px solid #3a58cf;
1828
- margin: -0.75em 0 27px;
1829
  }
1830
 
1831
  .dashboard_page_wpsc-update .wpsc-progress-bar * {
1832
- position: absolute;
1833
- left: 0;
1834
- top: 0;
1835
- background: #f9f9f9;
1836
- font-size: 12px;
1837
  }
1838
 
1839
  .dashboard_page_wpsc-update .wpsc-progress-bar .block {
1840
- background-color: #527dff;
1841
- z-index: -1;
1842
- height: 20px;
1843
  }
1844
 
1845
  .dashboard_page_wpsc-update .wpsc-progress-bar span {
1846
- display: block;
1847
- left: 310px;
1848
- line-height: 20px;
1849
- width: 200px;
1850
  }
1851
 
1852
  .dashboard_page_wpsc-update .wpsc-progress-bar .eta {
1853
- top: 22px;
1854
- line-height: 15px;
1855
- width: 100%;
1856
  }
1857
 
1858
- .downloadables_float {
1859
  float: right;
1860
- width: 80px;
1861
  vertical-align: middle;
 
1862
  }
1863
 
1864
- .downloadables_headding1 {
1865
  display: inline;
1866
- float: left;
1867
  text-align: left;
1868
  vertical-align: middle;
1869
  width: auto;
1870
  }
1871
 
1872
  img.ajax-feedback-active {
1873
- vertical-align: middle;
1874
- visibility: visible;
1875
  }
1876
 
1877
  .dashboard_page_wpsc-purchase-logs .column-id {
1878
- width: 75px;
1879
  }
1880
 
1881
  .dashboard_page_wpsc-purchase-logs .column-amount {
1882
- width: 100px;
1883
  }
1884
 
1885
- .js table.purchase-logs td.column-status span,
1886
- table.purchase-logs .column-status select {
1887
- display: none;
1888
  }
1889
 
1890
  .js table.purchase-logs .column-status select {
1891
- display: inline-block;
1892
- margin-right: 5px;
1893
  }
1894
 
1895
  table.purchase-logs .column-tracking .empty {
1896
- position: relative;
1897
  }
1898
 
1899
  table.purchase-logs .column-tracking .empty .send-email {
1900
- display: none;
1901
  }
1902
 
1903
  table.purchase-logs .column-tracking .add {
1904
- position: absolute;
1905
- left: 6px;
1906
- top: 4px;
1907
  }
1908
 
1909
  table.purchase-logs .column-tracking {
1910
- width: 200px;
1911
  }
1912
 
1913
  table.purchase-logs .column-tracking input[type="text"] {
1914
- width: 180px;
1915
  }
1916
 
1917
  table.purchase-logs .column-tracking a.save {
1918
- display: none;
1919
- float: right;
1920
  }
1921
 
1922
  table.purchase-logs .column-tracking a.add {
1923
- display: none;
1924
- color: #ccc;
1925
- cursor: text;
1926
  }
1927
 
1928
  table.purchase-logs .column-tracking .empty a.add {
1929
- display: inline;
1930
  }
1931
 
1932
  table.purchase-logs .column-tracking .ajax-feedback {
1933
- display: none;
1934
- float: right;
1935
- margin-top: 5px;
1936
  }
1937
 
1938
  table.purchase-logs .column-tracking .ajax-feedback-active {
1939
- display: inline-block;
1940
  }
1941
 
1942
  table.purchase-logs .column-tracking em.sent {
1943
- color: green;
1944
  }
1945
 
1946
  table.purchase-logs .column-id .delete {
1947
- color: red;
1948
- visibility: hidden;
1949
  }
1950
 
1951
  table.purchase-logs tr:hover .column-id .delete {
1952
- visibility: visible;
1953
  }
1954
 
1955
-
1956
- /**
1957
- * Product Variations
1958
- */
1959
-
1960
  .no-js #wpsc_product_variation_forms iframe {
1961
- height: 300px;
1962
  }
1963
 
1964
  .js #wpsc_product_variation_forms iframe {
1965
- border: 0;
1966
- margin: 0;
1967
- overflow: hidden;
1968
- padding: 0;
1969
- }
1970
-
1971
- #wpsc_product_variation_forms .inside {
1972
- margin: 0;
1973
- padding: 0 12px 0 12px;
1974
  }
1975
 
1976
  #wpsc_product_variation_forms iframe {
1977
- background: transparent;
1978
- width: 100%;
1979
  }
1980
 
1981
  .wpsc-product-variation-iframe {
1982
  min-width: 400px;
1983
- padding: 6px 0 12px 0;
1984
- overflow:hidden;
1985
  }
1986
 
1987
  #wpsc-product-variations-wrapper .tablenav.top {
1988
- margin-top: 0;
1989
  }
1990
 
1991
  .wpsc-save-variations-top {
1992
- float: right;
1993
- margin: 8px 0 5px;
1994
  }
1995
 
1996
  #wpsc-product-variations-wrapper .column-stock input[type="text"],
@@ -1998,11 +1792,12 @@ table.purchase-logs tr:hover .column-id .delete {
1998
  #wpsc-product-variations-wrapper .column-price input[type="text"],
1999
  #wpsc-product-variations-wrapper .column-sale_price input[type="text"],
2000
  #wpsc-product-variations-wrapper .column-sku input[type="text"] {
2001
- width: 100%;
2002
- -webkit-box-sizing: border-box;
2003
- -moz-box-sizing: border-box;
2004
- -o-box-sizing: border-box;
2005
- box-sizing: border-box;
 
2006
  }
2007
 
2008
  #wpsc-product-variations-wrapper .inline-edit-row.column-stock input[type="text"],
@@ -2018,8 +1813,8 @@ table.purchase-logs tr:hover .column-id .delete {
2018
  #wpsc-product-variations-wrapper .column-price,
2019
  #wpsc-product-variations-wrapper .column-sale_price,
2020
  #wpsc-product-variations-wrapper .column-sku {
2021
- text-align: center;
2022
- width: 11%;
2023
  }
2024
 
2025
  #wpsc-product-variations-wrapper .column-stock input,
@@ -2027,12 +1822,11 @@ table.purchase-logs tr:hover .column-id .delete {
2027
  #wpsc-product-variations-wrapper .column-price input,
2028
  #wpsc-product-variations-wrapper .column-sale_price input,
2029
  #wpsc-product-variations-wrapper .column-sku input {
2030
- text-align: right;
2031
  }
2032
 
2033
- .js #wpsc-product-variations-wrapper tbody .active td,
2034
- .js #wpsc-product-variations-wrapper tbody .active th {
2035
- border-bottom-style: dashed;
2036
  }
2037
 
2038
  #wpsc-product-variations-wrapper div.updated,
@@ -2041,11 +1835,11 @@ table.purchase-logs tr:hover .column-id .delete {
2041
  }
2042
 
2043
  .js #wpsc-product-variations-wrapper .wpsc-stock-editor-row {
2044
- display: none;
2045
  }
2046
 
2047
  #wpsc-product-variations-wrapper .wpsc-stock-editor-row td {
2048
- border-bottom-style: solid;
2049
  }
2050
 
2051
  #wpsc-product-variations-wrapper {
@@ -2053,55 +1847,62 @@ table.purchase-logs tr:hover .column-id .delete {
2053
  }
2054
 
2055
  #wpsc-product-variations-wrapper .submit {
2056
- margin: 0;
2057
- padding: 0;
2058
  }
2059
 
2060
  .wpsc-stock-editor .inside {
2061
- overflow: hidden;
2062
  }
2063
 
2064
  .wpsc-stock-editor .wpsc-product-shipping-section {
 
2065
  vertical-align: top;
 
2066
  }
2067
 
2068
  .wpsc-stock-editor .wpsc-form-field {
2069
- clear: both;
2070
- }
2071
-
2072
- .wpsc-stock-editor .wpsc-form-field label {
2073
- width: 150px;
2074
- }
2075
-
2076
- .wpsc-stock-editor .wpsc-form-field input[type="number"] {
2077
- width: 70px;
2078
  }
2079
 
2080
  .wpsc-stock-editor .wpsc-product-shipping-section input[type="text"] {
2081
- text-align: right;
2082
- width: 50px;
2083
  }
2084
 
2085
  .wpsc-product-shipping-weight-dimensions label {
2086
- display: inline-block;
2087
- min-width: 60px;
2088
  }
2089
 
2090
  .wpsc-product-shipping-flat-rate label {
2091
- display: inline-block;
2092
- min-width: 160px;
2093
  }
2094
 
2095
  .wpsc-stock-editor {
2096
- overflow: hidden;
2097
  }
2098
 
2099
  .wpsc-stock-editor select {
2100
- min-width: 100px;
 
 
 
 
 
 
 
 
 
 
2101
  }
2102
 
2103
  .wpsc-product-variations-tabs {
2104
- margin: 0 0 1px 0;
 
 
 
2105
  width: 100%;
2106
  }
2107
 
@@ -2117,7 +1918,7 @@ table.purchase-logs tr:hover .column-id .delete {
2117
 
2118
  .wpsc-product-variations-tabs li {
2119
  float: left;
2120
- margin: 5px 4px 0 0px;
2121
  }
2122
 
2123
  .wpsc-product-variations-tabs a {
@@ -2131,12 +1932,13 @@ table.purchase-logs tr:hover .column-id .delete {
2131
  padding: 5px 7px 3px;
2132
  text-decoration: none;
2133
  vertical-align: middle;
2134
- -webkit-border-top-right-radius: 3px;
2135
- -moz-border-top-right-radius: 3px;
2136
- border-top-right-radius: 3px;
2137
  -webkit-border-top-left-radius: 3px;
2138
- -moz-border-top-left-radius: 3px;
2139
- border-top-left-radius: 3px;
 
2140
  }
2141
 
2142
  .wpsc-product-variations-tabs a:hover {
@@ -2160,13 +1962,8 @@ table.purchase-logs tr:hover .column-id .delete {
2160
  }
2161
 
2162
  .wpsc-save-product-variations.bottom {
2163
- float: none;
2164
- overflow: hidden;
2165
  padding-bottom: 5px;
2166
  }
2167
- .wpsc-save-product-variations.bottom input {
2168
- float: right;
2169
- }
2170
 
2171
  .wpsc-product-variation-thumbnail {
2172
  float: left;
@@ -2174,11 +1971,6 @@ table.purchase-logs tr:hover .column-id .delete {
2174
  width: 50px;
2175
  }
2176
 
2177
- .wpsc-product-variation-thumbnail img {
2178
- max-height: 50px;
2179
- max-width: 50px;
2180
- }
2181
-
2182
  .wpsc-product-variation-title {
2183
  margin-left: 60px;
2184
  }
@@ -2190,16 +1982,15 @@ table.purchase-logs tr:hover .column-id .delete {
2190
 
2191
  .wpsc-button-round {
2192
  padding: 0 0 1px !important;
2193
- height: 28px !important;
2194
  text-align: center;
2195
- width: 28px !important;
2196
- -webkit-border-radius: 14px !important;
2197
- border-radius: 14px !important;
2198
  outline: 0 !important;
2199
  }
2200
 
2201
- /* Make the minus sign look balanced with the plus sign */
2202
-
2203
  .wpsc-button-minus {
2204
  font-weight: bold;
2205
  font-size: 10px !important;
@@ -2223,303 +2014,17 @@ th.right-col {
2223
  padding: 0;
2224
  }
2225
 
2226
- div.new_layer {
2227
- display: block;
2228
- margin-bottom: 10px;
2229
- }
2230
-
2231
- div.new_layer > * {
2232
- display: inline-block;
2233
- vertical-align: middle;
2234
- }
2235
-
2236
- div.new_layer select {
2237
- height: auto !important;
2238
- white-space: nowrap;
2239
  }
2240
 
2241
  body.edit-tags-php img.wpsc_category_image {
2242
- max-width: 256px;
2243
- max-height: 256px;
2244
- min-width: 128px;
2245
  }
2246
 
2247
  .wpsc-width-height-fields label {
2248
  display: inline;
2249
  }
2250
-
2251
-
2252
- /**
2253
- * Live Title Meta Box
2254
- */
2255
-
2256
- .wpsc_metabox_live_title {
2257
- position: absolute;
2258
- right: 30px;
2259
- }
2260
-
2261
- .wpsc_metabox_live_title > * {
2262
- float: right;
2263
- margin: 0px;
2264
- padding: 0px;
2265
- font-style: normal;
2266
- font-size: 13px;
2267
- color: #858585;
2268
- text-shadow: 1px 1px #fff;
2269
- }
2270
-
2271
- #wpsc_product_delivery_metabox_live_title,
2272
- #wpsc_product_details_metabox_live_title {
2273
- left: 170px;
2274
- right: auto;
2275
- }
2276
-
2277
- /**
2278
- * Product Price Meta Box
2279
- */
2280
-
2281
- .wpsc-categorydiv .tabs-panel {
2282
- max-height: none !important;
2283
- overflow: visible !important;
2284
- padding-top: 5px !important;
2285
- padding-bottom: 5px !important;
2286
- }
2287
-
2288
-
2289
- /**
2290
- * Product Delivery
2291
- */
2292
-
2293
- #wpsc_product_delivery-external_link th {
2294
- width: 50px;
2295
- }
2296
-
2297
- #external_link_target {
2298
- padding-top: 21px;
2299
- }
2300
-
2301
- #external_link_target input {
2302
- width: auto;
2303
- }
2304
-
2305
- #external_link_target span {
2306
- margin-left: 10px;
2307
- margin-right: 30px;
2308
- }
2309
-
2310
- #wpsc_product_gallery li {
2311
- float: left;
2312
- margin-right: 10px;
2313
- cursor: move;
2314
- }
2315
-
2316
- /**
2317
- * Digital download table style
2318
- */
2319
-
2320
- #wpsc_digital_download_table {
2321
- margin-top: 10px;
2322
- margin-bottom: 15px;
2323
- }
2324
-
2325
- #wpsc_digital_download_table tfoot {
2326
- display: none;
2327
- }
2328
-
2329
- #wpsc_digital_download_table a,
2330
- #wpsc_digital_download_table img {
2331
- display: inline-block;
2332
- margin-right: 10px;
2333
- }
2334
-
2335
- #wpsc_digital_download_table span {
2336
- display: inline-block;
2337
- vertical-align: middle;
2338
- }
2339
-
2340
- #wpsc_digital_download_table img {
2341
- max-height: 20px;
2342
- vertical-align: middle;
2343
- }
2344
-
2345
- #wpsc_digital_download_action_th {
2346
- width: 120px;
2347
- }
2348
-
2349
-
2350
- /**
2351
- * Custom meta style
2352
- */
2353
-
2354
- #wpsc_product_meta_table {
2355
- margin-bottom: 10px;
2356
- margin-top: 10px;
2357
- }
2358
-
2359
- #wpsc_product_meta_table tfoot {
2360
- display: none;
2361
- }
2362
-
2363
- #wpsc_product_meta_table input {
2364
- width: 100%;
2365
- }
2366
-
2367
- a.wpsc_remove_meta {
2368
- color: red;
2369
- }
2370
-
2371
- #wpsc_custom_meta_name_th {
2372
- width: 250px;
2373
- }
2374
-
2375
- #wpsc_custom_meta_action_th {
2376
- width: 70px;
2377
- }
2378
-
2379
- .wpsc_fileUpload {
2380
- display: inline-block;
2381
- position: relative;
2382
- margin: 10px;
2383
- cursor: pointer;
2384
- }
2385
-
2386
- .wpsc_fileUpload input {
2387
- position: absolute;
2388
- top: 0;
2389
- bottom: 0;
2390
- right: 0;
2391
- left: 0;
2392
- margin: 0;
2393
- padding: 0;
2394
- font-size: 20px;
2395
- cursor: pointer;
2396
- opacity: 0;
2397
- filter: alpha(opacity=0);
2398
- }
2399
-
2400
- #wpsc_sku {
2401
- width: 100%;
2402
- }
2403
-
2404
-
2405
- /**
2406
- * WordPress 3.8 Responsiveness
2407
- */
2408
-
2409
- @media screen and ( max-width: 782px ) {
2410
-
2411
- /**
2412
- * Override responsiveness in variations iframe
2413
- */
2414
-
2415
- /* Buttons */
2416
- .wpsc-product-variation-iframe.wp-core-ui .button,
2417
- .wpsc-product-variation-iframe.wp-core-ui .button.button-large,
2418
- .wpsc-product-variation-iframe.wp-core-ui .button.button-small {
2419
- padding: 0px 10px 1px;
2420
- line-height: 2;
2421
- font-size: 13px;
2422
- vertical-align: top;
2423
- height: 28px;
2424
- margin-bottom: 0px;
2425
- }
2426
-
2427
- .wpsc-product-variation-iframe.wp-core-ui .button:active,
2428
- .wpsc-product-variation-iframe.wp-core-ui .button-large:active,
2429
- .wpsc-product-variation-iframe.wp-core-ui .button-small:active {
2430
- padding-top: 1px;
2431
- padding-bottom: 0;
2432
- }
2433
-
2434
- /* Categories Metabox */
2435
- .wpsc-product-variation-iframe ul.category-tabs {
2436
- margin: 12px 0 5px;
2437
- }
2438
-
2439
- .wpsc-product-variation-iframe ul.category-tabs li.tabs {
2440
- padding: 3px 5px 5px;
2441
- }
2442
-
2443
- /* Subsubsub Nav */
2444
- .wpsc-product-variation-iframe .subsubsub {
2445
- font-size: 13px;
2446
- margin: 8px 0px 0px;
2447
- }
2448
-
2449
- /* Form Tables */
2450
- .wpsc-product-variation-iframe input[type="checkbox"],
2451
- .wpsc-product-variation-iframe .widefat th input[type="checkbox"] {
2452
- padding: 0px;
2453
- }
2454
-
2455
- .wpsc-product-variation-iframe input[type="radio"],
2456
- .wpsc-product-variation-iframe input[type="checkbox"] {
2457
- width: 16px;
2458
- height: 16px;
2459
- }
2460
-
2461
- .wpsc-product-variation-iframe textarea,
2462
- .wpsc-product-variation-iframe input,
2463
- .wpsc-product-variation-iframe select {
2464
- font-size: 14px;
2465
- }
2466
-
2467
- .wpsc-product-variation-iframe input[type=checkbox]:checked:before,
2468
- .wpsc-product-variation-iframe .widefat th input[type=checkbox]:before {
2469
- font-size: 21px;
2470
- margin: -3px 0 0 -4px;
2471
- }
2472
-
2473
- .wpsc-product-variation-iframe input[type="text"],
2474
- .wpsc-product-variation-iframe input[type="search"],
2475
- .wpsc-product-variation-iframe input[type="password"],
2476
- .wpsc-product-variation-iframe input[type="number"] {
2477
- padding: 3px 5px;
2478
- }
2479
-
2480
- .wpsc-product-variation-iframe .tablenav.bottom .displaying-num {
2481
- font-size: 12px;
2482
- }
2483
-
2484
- }
2485
-
2486
-
2487
- /**
2488
- * Pre WordPress 3.8 Compatibility
2489
- */
2490
-
2491
-
2492
- .branch-3-7.wpsc-product-variation-iframe #post-body,
2493
- .branch-3-6.wpsc-product-variation-iframe #post-body {
2494
- background: #f5f5f5;
2495
- background-image: -webkit-gradient(linear,left bottom,left top,from(#f5f5f5),to(#f9f9f9));
2496
- background-image: -webkit-linear-gradient(bottom, #f5f5f5, #f9f9f9);
2497
- background-image: -moz-linear-gradient(bottom, #f5f5f5, #f9f9f9);
2498
- background-image: -o-linear-gradient(bottom, #f5f5f5, #f9f9f9);
2499
- background-image: linear-gradient(to top, #f5f5f5, #f9f9f9);
2500
- }
2501
-
2502
- .branch-3-7.wpsc-product-variation-iframe .widefat td.column-title,
2503
- .branch-3-6.wpsc-product-variation-iframe .widefat td.column-title {
2504
- padding-bottom: 5px;
2505
- }
2506
-
2507
- .branch-3-7 .wpsc-currency-layers td.remove a,
2508
- .branch-3-7 .wpsc-quantity-discounts td.remove a,
2509
- .branch-3-6 .wpsc-currency-layers td.remove a,
2510
- .branch-3-6 .wpsc-quantity-discounts td.remove a {
2511
- background: url(xit.gif) no-repeat 0 0;
2512
- display: inline-block;
2513
- margin-top: 7px;
2514
- overflow: hidden;
2515
- text-indent: -999px;
2516
- width: 10px;
2517
- height: 10px;
2518
- }
2519
-
2520
- .branch-3-7 .wpsc-currency-layers td.remove a:hover,
2521
- .branch-3-7 .wpsc-quantity-discounts td.remove a:hover,
2522
- .branch-3-6 .wpsc-currency-layers td.remove a:hover,
2523
- .branch-3-6 .wpsc-quantity-discounts td.remove a:hover {
2524
- background-position: -10px 0;
2525
- }
1
+ /*
2
+ * This is the new WPSC Admin CSS file
 
3
 
4
+ */
5
  table.wp-list-table .column-featured {
6
  width: 30px;
7
  }
 
8
  table.wp-list-table .column-price,
9
  table.wp-list-table .column-sale_price {
10
  width: 8%;
11
  }
 
12
  table.wp-list-table .column-SKU {
13
  width: 11%;
14
  }
 
15
  table.wp-list-table .column-stock {
16
  width: 8%;
17
  }
 
18
  table.wp-list-table .column-weight {
19
  width: 7%;
20
  }
 
21
  table.wp-list-table .column-cats {
22
  width: 15%;
23
  }
24
 
25
  ul.variation_checkboxes li {
26
+ margin: 1px 0 3px;
27
  }
 
28
  /* This is the variation meta box stuff need to put it in the correct place - mychelle */
29
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td span{
30
+ display:none;
 
31
  }
32
 
33
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.weight{
34
  width: 81px;
35
  }
36
 
37
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.stock{
38
  width: 110px;
39
  }
40
 
41
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.price{
42
  width: 125px;
43
  }
44
 
45
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.post-title{
46
  width: 115px;
47
  }
48
 
49
  .wpsc_ie_stock[disabled] {
50
+ background-color:#f6f6f6;
51
  }
52
 
53
  div#wpsc_add_variant_desc,
54
+ div#wpsc_add_variation_desc{
55
  float: left;
56
+ margin:33px 0px 30px 20px;
57
  }
58
 
59
+ div#wpsc_add_variation_desc{
60
+ width:300px;
61
  }
62
 
63
+ div#wpsc_add_variant_desc{
64
+ width:200px;
65
  }
66
 
67
+ div#wpsc_add_variant{
68
  float: left;
69
  max-width: 245px;
70
  }
71
 
72
+ div #add_new_variation{
73
+ float:left;
74
+ width:215px;
75
  }
76
 
77
  input.wpsc_ie_field {
78
  margin-bottom:10px;
79
  }
80
 
81
+ .wpsc_ie_save{
82
+ margin-bottom:5px;
83
  }
84
 
85
+ .wpsc_trackingid_row{
86
+ margin-left:20px;
87
  }
88
 
89
+ ul.children{
90
+ padding-left:5px;
91
  }
92
+ .category_indenter{
93
+ float:left;
94
+ width:auto;
 
95
  }
96
 
 
97
  /**
98
+ *Dashboard Widget CSS
99
+ *
100
+ */
101
+ #leftDashboard{
102
+ width:45%;
103
+ float:left;
104
+ text-align:right;
105
+ border-right:1px #999999 solid;
106
+
107
+ }
108
+ #leftDashboard strong{
109
+ float:left;
 
110
  padding-left: 40px;
111
  }
112
+ #rightDashboard strong{
113
+ float:left;
 
114
  padding-left: 40px;
115
  }
116
+ #rightDashboard{
117
+ width:45%;
118
+ float:right;
119
+ text-align:right;
120
 
 
 
 
 
121
  }
122
+ .pricedisplay, .salespricedisplay{
123
+ /* width:40%; */
124
+ /*float:left;*/
125
+ }
126
+ .dashboardWidgetSpecial{
127
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
128
+ color:#21759B;
129
+ font-size:15px!important;
130
  margin: 5px 0 5px 0;
131
  }
132
+ .dashboardWidget{
133
+ color:#777777;
134
+ padding-left:10px;
 
135
  padding-right: 30px;
 
136
 
 
 
 
137
  }
138
+ span.wpsc_quart_left{
139
+ width:40%;
140
+ float:left;
 
 
 
141
  }
142
+ p.atglance{
143
+ color:#777777;
144
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
145
+ font-size:13px;
146
+ font-style:italic;
147
+ }
148
+ span.wpsc_quart_right{
149
+ width:60%;
150
+ float:right;
151
  text-align: right;
152
  }
153
+ #box span{
 
154
  border-bottom: 1px solid #999999;
155
  }
156
+ p.quarterly{
157
+ color:#21759B;
158
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
159
+ font-size:12px;
 
160
  line-height: 140%;
161
+ margin:5px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
+ /* end of dashboard widget css */
164
+ /*
165
+ *Display Purchase log Details CSS is HERE
166
+ */
167
+ #purchlogs_customfields{
168
+ clear:both;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
+ th#date{
171
+ width:120px;
 
172
  }
173
+ th#purchid{
174
+ width:60px;
 
 
175
  }
176
+ th#details{
177
+ width:100px;
 
178
  }
179
+ th#name{
180
+ /* width:220px; */
 
 
 
 
181
  }
182
+ th#track{
183
+ width:75px;
 
 
184
  }
185
+ th#delete{
186
+ width:60px;
 
187
  }
188
+ th#status{
189
+ width:200px;
 
190
  }
191
+ .google_checkout_logo{
192
+ padding-right:10px;
 
 
 
 
 
 
193
  }
194
+ #wpsc_items_ordered{
195
+ clear:both;
 
196
  }
197
+ #wpsc_items_ordered h3{
198
+ margin-bottom:0em;
 
199
  }
200
+ .wpsc_pushdown_img {
201
+ float:left;
 
 
202
  }
203
+ #wpsc_purchlogitems_links{
204
+ clear:both;
205
 
 
 
 
206
  }
207
+ #wpsc_purchlog_order_status{
208
+ float:right;
209
+ width:250px;
210
  }
211
+ #wpsc_purchlog_order_status .selector{
212
+ margin-top:-.2em;
 
213
  }
214
 
215
+ #wpsc_purchlogitems_links a{
216
+ text-decoration:none;
217
+ line-height:14pt;
218
  }
219
+ #wpsc_purchlogitems_links img{
220
+ padding-top:2px;
221
+ float:left;
222
  }
223
+ #wpsc_shipping_details_box{
224
+ width:45%;
225
+ float:left;
226
+ margin:.4em;
227
+ padding:.6em;
228
+ margin-right:5em;
 
229
  }
230
+ #wpsc_billing_details_box{
231
+ width:35%;
232
+ float:left;
233
+ margin:.4em;
234
+ padding:.6em;
 
235
  }
236
 
237
  #wpsc_shipping_details_box em.field-blank,
239
  color: #999;
240
  }
241
 
242
+ #wpsc_purchlog_searchbox{
243
+ width:100%;
244
+ text-align:right;
 
245
 
246
 
247
+ }
248
+ /*
249
+ * Display Purchase log Details CSS ends HERE
250
  * Display Products CSS starts here
251
+ */
 
252
  .tablenav select[name="bulkAction"] {
253
+ width:100px;
254
  }
255
+ textarea#additional_description{
 
256
  border: 1px solid #dfdfdf;
257
+ /* width:465px !important; */
258
  }
259
 
260
  #poststuff h3.form_heading {
261
+ font-size:1.1em;
262
  margin: 40px 0px 10px 0px;
263
  padding-left: 0px;
264
  }
265
 
266
  #poststuff h3.form_heading span {
267
+ font-size:0.8em;
268
  }
269
 
270
  div.search-box input#page-search-input {
271
  width: 129px;
272
+
273
  }
274
 
275
+
276
  #wpsc_product_list,
277
  table.widefat {
278
+ width:100%;
279
  }
280
 
281
  table.widefat .column-hidden_alerts {
282
+ display:none;
283
  }
284
 
285
  #wpsc_product_list .column-cb,
286
  table.widefat .column-cb {
287
+ /* width:24px; */
288
  vertical-align: middle;
289
  }
290
+ #wpsc_product_list .column-image, #wpsc_product_list .product-image,
291
+ table.widefat .column-image, table.widefat .product-image {
 
 
 
292
  padding-right: 0px;
293
  width: 42px;
294
  }
295
 
 
 
 
 
 
 
 
296
  #wpsc_product_list .column-categories,
297
+ table.widefat .column-categories{
298
+ /* width: 70px; */
299
  padding-right:18px;
300
  }
301
 
302
  #wpsc_product_list tbody tr td.column-title,
303
  table.widefat tbody tr td.column-title {
304
+ border-right:none;
305
  }
306
 
307
  #wpsc_product_list tbody tr td.product-image img,
308
  table.widefat tbody tr td.product-image img {
309
  margin-top: 4px;
310
+ cursor:move;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  }
312
 
313
+ .newCurrency{
314
+ width:150px;
 
315
  }
316
+ div.wpsc_floatleft{
317
+ width:161px;
318
+ float:left;
 
319
  }
 
320
  div.wpsc_floatleft label {
321
+ line-height: 18px;
322
+ white-space: nowrap;
 
323
  }
324
 
325
+ /* Sortable product styling*/
 
 
 
326
 
327
  table.product_editform {
328
+ width:100%;
329
  }
330
 
331
+
332
  #wpsc_product_list .ui-sortable-helper,
333
  table.widefat .ui-sortable-helper {
334
  width: 410px;
336
  background-color: #FEFEFE;
337
  }
338
 
339
+ #wpsc_product_list .ui-sortable-helper td, #wpsc_product_list .ui-sortable-helper th,
340
+ table.widefat .ui-sortable-helper td, table.widefat .ui-sortable-helper th{
 
 
341
  border-top: 1px solid #DFDFDF;
342
  opacity: .4;
343
  }
344
+ .wpsc-sortable-table-placeholder td, .product-placeholder {
 
 
345
  border-width: 1px;
346
  border-style: dashed;
347
  z-index: 900;
351
  }
352
 
353
  div#poststuff table tr td {
354
+ vertical-align:top;
355
  }
356
 
357
  div#poststuff textarea {
365
 
366
  div.admin_product_name {
367
  position: relative;
368
+
369
+ height: 30px;
370
  background: #ffffff;
371
+
372
  border: 1px solid #dfdfdf;
373
+ -moz-border-radius: 6px;
374
+ -khtml-border-radius: 6px;
375
  -webkit-border-radius: 6px;
376
+ border-radius: 6px;
 
 
377
  }
 
378
  div.admin_product_name input.wpsc_product_name {
379
  border: none;
380
  }
383
  position: absolute;
384
  top: 0px;
385
  right: 0px;
386
+ background:url(../../wpsc-core/images/info_icon.jpg) no-repeat scroll 5px 8px;
387
+ border-left:1px solid #DFDFDF;
388
+ display:block;
389
+ height:100%;
390
+ padding:0px 3px 0px 3px;
391
+ width:18px;
392
  }
393
 
394
+ div#icon_card
395
+ {
396
  float: left;
397
  height: 36px;
398
  margin: 7px 8px 0 0;
400
  background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
401
  }
402
 
 
 
403
  div.admin_product_shorttags {
404
+ width:93%;
405
+ min-width:396px;
406
+ max-width:558px;
407
+
408
  clear: both;
409
  padding: 6px;
410
  font-size: 8pt;
411
+ margin:0 0 0 6px !important;
412
+ border-left:1px solid #DFDFDF;
413
+ border-right:1px solid #DFDFDF;
414
+ border-bottom:1px solid #DFDFDF;
415
+ /* height: 28px; */
416
  display: none;
417
+ _width:396px;
418
  background-color: #ffffff;
419
  }
420
 
421
  #description {
422
+ margin:0;
423
+ /* width:100%; */
424
  }
425
 
426
  h4.product_action_link {
427
+ margin:4px 0px 0px 0px;
428
+ display:block;
429
+ font-weight:bold;
430
+ }
431
+
432
+
433
+
434
+ /* custom meta styling */
435
+ div.product_custom_meta {
436
  display: block;
437
+ width: 100%;
438
+ vertical-align: top;
439
+ }
440
+ div#poststuff div.product_custom_meta input, div#poststuff div.product_custom_meta textarea {
441
+ width: 100%;
442
  }
443
 
444
 
445
+ div.product_custom_meta a.add_more_meta {
446
+ display: block;
447
+ float: left;
448
+ margin-top: 18px;
449
+ margin-left: 4px;
450
+ }
451
+
452
+ div.product_custom_meta a.remove_meta {
453
+ display: block;
454
+ margin-left: 4px;
455
+ }
456
+
457
+
458
+ div.product_custom_meta label {
459
+ display: block;
460
+ width: 170px;
461
+ float: left;
462
+ }
463
+
464
+ div.product_custom_meta label input {
465
+ font-size:13px;
466
+ width: 160px !important;
467
+ margin:1px !important;
468
+ padding:3px !important;
469
+ display: block;
470
+ }
471
+
472
+ div.product_custom_meta br {
473
+ clear: both;
474
+ }
475
 
476
+ /* image form styling */
477
  div.flash-image-uploader {
478
  display: none;
479
  }
482
  position: relative;
483
  border: none;
484
  }
485
+ #wpbody-content div.flash-image-uploader #media-items .progress{
 
486
  position: static;
487
+ margin:0 0 6px;
488
  height: 16px;
489
  }
490
 
491
  .ui-selected {
492
+ border:2px dashed #969696;
493
  }
494
 
495
  img.deleteButton {
496
+ display:none;
497
+ position:absolute;
498
+ top:-5px;
499
  right: -1px;
500
+ width:16px;
501
+ height:16px;
502
+ cursor:pointer;
503
  }
 
504
  a.editButton {
505
+ background:#FFFFFF none repeat scroll 0%;
506
+ height:20px;
507
+ display:none;
508
+ position:absolute;
509
+ right:0px;
510
+ top:0px;
511
+ padding-bottom:3px;
512
+ padding-left:3px;
513
+ cursor:pointer;
514
  }
515
 
516
  div.image_settings_box {
517
+ position:absolute;
518
+ width:150px;
519
+ display:none;
520
  margin: -66px 0px 0px 36px;
521
+ _margin: 0px 0px 0px -30px;
522
+ padding-top:2px;
523
+ width:252px;
524
+ z-index:69;
525
+ _z-index:80;
526
  }
527
 
528
  a.thickbox img {
529
+ border:medium none;
530
  }
531
 
532
  img.previewimage {
533
+ cursor:move;
534
+ height:60px;
535
+ margin-right:4px;
536
+ width:60px;
537
  }
538
 
539
  div.lower_settings_box {
540
+ width:234px;
541
+ background-color:white;
542
+ border:1px solid black;
543
+ border-top:1px solid #CCCCCC;
544
+ float:right;
545
  margin: -1px -6px 0px 0px;
546
  padding: 2px 0 0 4px;
547
+ background-color:#EAF3FA;
548
  }
549
 
550
  div.upper_settings_box {
551
+ width:250px;
552
+ background-color:white;
553
+ border:1px solid black;
554
+ padding:3px 1px 2px 5px;
555
  }
556
 
557
  div.upper_image {
558
+ float:left;
559
+ /* border-bottom:1px solid black; */
560
+ padding-left:5px;
561
+ margin-left:-5px;
562
+ _margin-left:-3px;
563
+ margin-right:-7px;
564
+ padding-bottom:4px;
565
+ _padding-bottom:6px;
566
+ _margin-bottom:-2px;
567
  }
568
 
569
+ div.upper_txt{
570
+ padding-left:22px;
571
+ color:#666666;
572
  }
573
 
574
  div.previewimage {
575
+ position:relative;
576
  }
577
 
578
+ tr.edit_product_image *{
579
+ z-index:80;
580
  }
581
 
582
+ div.browser-image-uploader {
583
+
584
+ }
585
+
586
+ div.browser-image-uploader h4{
587
  margin-bottom: 8px;
588
  }
589
 
595
  width: 100%;
596
  }
597
 
598
+ #wpsc_product_category_and_tag_forms table td.itemfirstcol{
599
+ padding-left:3pt;
600
  width: 50%;
601
  }
602
 
603
+ /* variations CSS starts */
604
 
605
+ table.product_variation_listing{
 
 
 
 
606
  margin-bottom: 12px;
607
  }
608
 
609
+ table.product_variation_listing th.variation_name{
610
  color: #71A4C8;
611
  font-style: italic;
612
  text-align: left;
613
  padding-bottom: 1px;
614
  }
615
 
616
+ table.product_variation_grid{
617
  margin-top: 12px;
618
  }
619
 
620
+ table.product_variation_grid th.variation_name{
621
  color: #71A4C8;
622
  font-style: italic;
623
  text-align: left;
627
  div#edit_variations_container {
628
  margin-top: 12px;
629
  }
 
630
  table.product_variation_grid {
631
  border-collapse: collapse;
632
  margin-top: 0px;
633
  }
634
 
635
+ table.product_variation_grid tr td, table.product_variation_grid tr th {
 
636
  border: 1px solid #cccccc;
637
  border-collapse: collapse;
638
  text-align: left;
651
  width: 78px;
652
  }
653
 
654
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
 
655
  padding: 4px 0px 4px 10px;
656
  }
657
 
658
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
 
659
  width: 300px;
660
  }
661
 
662
+
663
+ table.product_variation_grid tr td input{
664
  padding: 0px 3px 0px 3px;
665
  }
666
 
669
  }
670
 
671
  a.about_this_page_sub {
672
+ text-decoration:underline;
673
  }
674
 
675
+ table.product_variation_grid tr td, table.product_variation_grid tr th {
 
676
  border: 1px solid #cccccc;
677
  border-collapse: collapse;
678
  text-align: left;
687
  padding: 0px !important;
688
  }
689
 
690
+
691
  table.product_variation_grid tr.settings_row td div.variation_settings {
692
  display: none;
693
  border-top: 1px dotted #cccccc;
694
  width: 100%;
695
  min-height: 30px;
696
  padding: 4px 10px;
 
697
 
698
+ }
699
  table.product_variation_grid tr th {
700
  border-bottom: 1px solid #969696;
701
  }
709
  width: 78px;
710
  }
711
 
712
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
 
713
  padding: 4px 0px 4px 10px;
714
  }
715
 
716
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
 
717
  width: 300px;
718
  }
719
 
720
+
721
+ table.product_variation_grid tr td input{
722
  padding: 0px 3px 0px 3px;
723
  }
724
 
725
+ table.product_variation_grid tr td input.checkbox{
726
  display: block;
727
+ margin:6px auto;
728
  }
729
 
730
  table.product_variation_grid tr.group_boundary td {
748
  height: 16px;
749
  width: 16px;
750
  margin: 4px auto 0px auto;
751
+
752
  }
753
 
754
+ div.variation_settings div.variation_settings_contents{
755
  padding-left: 10px;
756
  }
757
 
758
  div.select_variation_file {
759
  padding-left: 6px;
760
  }
 
761
  div.select_variation_file p {
762
+ margin:0 0 3px;
763
  }
764
 
765
  div.select_variation_file p {
766
+ margin:0 0 3px;
767
  }
768
 
769
  div.select_variation_file p input {
772
  }
773
 
774
  .variation_checkboxes li {
775
+ margin:0;
776
  }
777
 
778
  .variation_checkboxes ul {
779
+ margin-left:30px;
780
  }
781
 
782
  .js .variation_checkboxes .children {
783
+ display:none;
784
  }
785
 
786
  .js .variation_checkboxes .expanded .children {
787
+ display:block;
788
  }
789
 
790
  .variation_checkboxes a.expand {
791
+ background:url(arrows.png) no-repeat left -108px;
792
+ display:inline-block;
793
+ height:15px;
794
+ width:15px;
795
+ text-indent:-999em;
796
+ vertical-align:middle;
797
  }
798
 
799
  .variation_checkboxes .expanded a.expand {
800
+ background-position:left top;
801
  }
802
 
803
  #add-new-variation-set {
804
+ margin-bottom:20px;
805
+ display:none;
806
  }
807
 
808
  #add-new-variation-set p {
809
+ position:relative;
810
  }
811
 
812
  #add-new-variation-set p.howto {
813
+ margin-bottom:16px;
814
  }
815
 
816
  #add-new-variation-set p label.focus {
817
+ color:#666;
818
  }
819
 
820
  #add-new-variation-set p.error label {
821
+ color:red;
822
  }
823
 
824
  #add-new-variation-set p label {
825
+ color:#000;
826
+ cursor:text;
827
+ left:6px;
828
+ position:absolute;
829
+ top:4px;
830
  }
831
 
832
  #add-new-variation-set .text-field {
833
+ width:195px;
834
  }
835
 
836
  .variation-set-prototype {
837
+ display:none;
838
  }
839
+ /* variations CSS ends */
 
840
 
841
  div#side-sortables input[type="file"] {
842
+ width:250px;
843
  }
 
844
  .wpsc_product_downloads_header {
845
  margin: 0 0 5px;
846
  }
 
847
  .select_product_file,
848
  .edit_select_product_file {
849
  margin-bottom: 0;
864
  top: 2px;
865
  }
866
 
867
+ div#poststuff table tr.wpsc_product_download_row td {
868
+ padding: 6px 7px;
869
+ vertical-align: middle;
870
+ line-height: 16px;
871
+ }
872
+
873
  a.file_delete_button {
874
+ cursor:pointer;
875
+ color:red;
876
  display: block;
877
  }
878
 
879
  a.delete_button {
880
+ border-color:-moz-use-text-color -moz-use-text-color #FF0000;
881
+ border-style:none none solid;
882
+ border-width:medium medium 1px;
883
+ color:#FF0000;
884
+ font-size:11px;
885
+ padding:1px 2px;
886
+ text-decoration:none;
887
+ }
888
+ .greytext{
889
+ color:#666666;
890
+ }
891
+ span.small_italic{
892
+ font-style: italic;
893
  }
894
+ /* Product details form styling ends */
895
+ /*
896
+ * Display Products CSS ends here
897
+ */
898
 
899
+ /*
900
+ * Product Groups styles start here
901
+ */
902
+ td.firstcol div.postbox div.inside{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
903
  margin: 0px;
904
  padding: 0px;
905
  }
906
 
907
+ table#productpage{
908
  width: 100%;
909
  clear: both;
910
  border-collapse: collapse;
911
  }
912
 
913
+ table#productpage tr td{
914
  vertical-align: top;
915
+ /* padding: 0px 0px 0px 6px; */
916
  }
917
 
918
+ table#productpage tr td.secondcol{
919
+ /* width: 60%; */
920
+ /* margin-left: 20px; */
921
  padding: 0px 2px 0px 16px;
922
+
923
  }
924
 
925
+
926
  table.category-edit {
927
  border-collapse: collapse;
928
  width: 100%;
935
  width: 450px;
936
  }
937
 
938
+
939
  div.category-image-container {
940
  width: 55px;
941
  height: 30px;
942
+
943
  }
944
 
945
  div.category-image-container img {
946
  float: left;
947
  }
 
948
  div.category-image-container img.category_indenter {
949
  margin-right: 3px;
950
+ width:auto;
951
+ float:left;
952
  }
953
 
 
 
 
 
954
 
 
 
 
 
955
 
 
 
 
956
 
 
 
 
957
 
958
+ div#productform{ display: none; width: 99.5%; }
959
+
960
+ div#edititem27{ display: none; width: 586px; }
961
+
962
+ div#productform table tr td{ height: 11px !important; }
963
+
964
+
965
+
966
+
967
+ div#blank_item{ display: block;}
968
+
969
+ #poststuff div#blank_item h3{
970
  margin-top: 0px;
 
971
 
 
 
972
  }
973
 
974
+ div#additem{ display: none;}
 
 
 
975
 
976
+ div#productform td.itemfirstcol{ padding-left:4px; vertical-align: top; }
977
+
978
+
979
+
980
+
981
+ div#productform input.text, div#additem input.text{
982
+ width:386px;
983
+ border:1px solid #bbb;
984
  }
985
 
986
+
987
  table.category_forms {
988
  width: 100%;
989
  }
 
990
  table.category_forms tr td {
991
  padding: 0px;
992
  padding-right: 8px;
993
  }
994
+ table.category_forms tr td textarea {
 
995
  width: 386px;
996
  }
997
 
998
+ div#edit_variation_values input.text{width:286px !important;border:1px solid #bbb;}
 
 
 
999
 
1000
+ input.image_resize{ position: relative; top: 4px; }
 
 
 
1001
 
1002
+ div#additem table.additem input.wpsc_tag{
1003
+ width:180px;
1004
  }
1005
+ div#additem label{
 
1006
  font-style: normal;
1007
  font-size: 0.95em;
1008
  }
1009
 
1010
+
1011
+
1012
+
1013
+
1014
+ .groupItem{
1015
+ border-top:1px solid #bbb;
1016
+ width:385px;
1017
+ height:35px;
1018
  clear: both;
1019
+ /* margin-left:-6px; */
1020
  padding: 0px 0px 4px 0px;
1021
  }
1022
 
1023
+ .groupItem .itemHeader{
1024
+ width:65px;
1025
  line-height: 15px;
1026
  color: #000;
1027
  padding: 4px;
1031
  clear: both;
1032
  }
1033
 
1034
+ .groupItem .itemHeader a{
1035
  margin: 4px 0px 4px 0px;
1036
  font-weight: normal;
1037
  font-size: 11px;
1038
  text-decoration: none;
1039
  }
1040
+ .sortHelper{
 
1041
  border: 3px dashed #666;
1042
  width: auto;
1043
  }
1044
+ .groupWrapper p{
 
1045
  height: 1px;
1046
  overflow: hidden;
1047
  margin: 0;
1048
  padding: 0;
1049
  }
1050
 
1051
+
1052
  table#productpage tr td.secondcol.product_groups_page {
1053
  padding-left: 16px;
1054
  }
1058
  margin-top: 20px;
1059
  }
1060
 
1061
+ td.product_groups_page #additem .inside, td.product_groups_page #productform .inside {
 
1062
  margin: 0px 0px 15px 0px;
1063
  }
1064
 
1065
  div.editing_this_group {
1066
  margin-top: 8px;
1067
  margin-bottom: 8px;
1068
+ /* border-bottom:1px dotted black; */
1069
+ width:100%;
1070
  }
1071
 
1072
  td.product_groups_page h4 {
1073
  margin-bottom: 1ex;
1074
  }
1075
+ #editorcontainer{
1076
+ clear:both;
 
1077
  }
 
1078
  td.product_groups_page td.category_presentation_settings {
1079
  padding-bottom: 1ex;
1080
  }
1081
 
1082
  div.editing_this_group {
1083
+ font-size:8pt;
1084
  }
1085
 
1086
  div.editing_this_group p {
1087
+ padding:4px 4px 4px 8px;
1088
  }
1089
 
1090
  div.editing_this_group dl {
1091
+ padding:4px 4px 4px 8px;
1092
  }
1093
 
1094
+
1095
+ #blank_item a.add_category_link{
1096
  display: block;
1097
  margin: 8px 8px 8px 0px;
1098
  text-decoration: underline;
1102
  margin: 12px 0px 10px 0px;
1103
  }
1104
 
1105
+
1106
  table#wpsc_category_list td div.subcategory img.category_indenter {
1107
  float: left;
1108
  margin: 8px 0px 0px 0px;
1112
  float: left;
1113
  }
1114
 
1115
+
1116
+ label.select_categorisation_group, select#select_categorisation_group, a.add_categorisation_group, a.edit_categorisation_group, #submit_categorisation_form span {
 
 
 
1117
  display: block;
1118
  float: left;
1119
  }
1130
 
1131
  label.select_categorisation_group {
1132
  padding-top: 4px;
1133
+ /* color: #336699; */
1134
  font-size: 11px;
1135
  }
1136
 
1142
  margin-left: 30px;
1143
  }
1144
 
1145
+
1146
+
1147
+ div#add_categorisation, div#edit_categorisation{
1148
  display: none;
1149
  border: 1px solid #BBBBBB;
1150
  padding: 4px;
1151
  margin-top: 6px;
1152
  }
1153
 
1154
+ div#add_categorisation br, div#edit_categorisation br{
 
1155
  clear: both;
1156
  }
1157
 
1158
+
1159
+ div#add_categorisation fieldset, div#edit_categorisation fieldset{
1160
  width: 230px;
1161
  float: left;
1162
  border: none;
1163
  }
1164
 
1165
+ div#add_categorisation fieldset label, div#edit_categorisation fieldset label{
 
1166
  display: block;
1167
  }
1168
 
1169
+ ul.categorisation_links{
1170
  list-style-type: none;
1171
  clear: both;
1172
  padding: 0px;
1173
  }
1174
+ .wpsc_add_new_currency{
1175
+ text-decoration: none;
1176
+ }
1177
+ ul.categorisation_links li{
1178
  display: block;
1179
  float: left;
1180
  list-style-type: none;
1183
  padding: 4px;
1184
  }
1185
 
1186
+ ul.categorisation_links li.selected a{
1187
  color: #D54E21;
1188
  }
 
1189
  .multiple-select-container {
1190
  margin-left: 0.5em;
1191
  }
1200
  padding: 0 0 0 5px;
1201
  position: relative;
1202
  }
 
1203
  .multiple-select input {
1204
  width: inherit;
1205
  }
 
1206
  .multiple-select label {
1207
  display: inherit;
1208
  }
1209
 
1210
+ table.category_forms a.delete_button {
1211
  display: block;
1212
  margin: 3px 0px 0px 8px;
1213
  float: left;
1217
  padding: 16px 0px 0px 0px;
1218
  }
1219
 
1220
+ .wpsc_gold_float{
1221
+ min-width:45%;
1222
+ float:left;
1223
+ max-width:450px;
1224
+ _width:450px;
1225
  }
1226
+ .wpsc_gold_side{
1227
+ margin-top:90px;
1228
+ float:right;
1229
+ width:35%;
1230
+ }
1231
+ .wpsc_gold_text{
1232
+ width:70%;
1233
+ float:left;
1234
+ clear:both;
1235
  }
1236
 
1237
+ .wpsc_gold_info{
1238
+ width:30%;
1239
+ float:right;
1240
  text-align: center;
1241
+ font-size:20px;
1242
  }
1243
+ .wpsc_gold_module{
1244
+ width:100%;
1245
+ float:left;
1246
 
 
 
 
1247
  border-bottom: 1px solid #DFDFDF;
1248
  }
1249
+ .wpsc_gold_module strong{
1250
+ width:auto;
1251
+ float:left;
 
1252
  }
1253
+ #visitInstinct{
1254
+ float:right;
1255
+ margin:5px 20px 0 0;
 
1256
  }
1257
 
 
 
 
1258
 
1259
+ #gold_cart_form .postbox p img{
1260
+ padding-bottom:10px;
1261
  }
1262
+ #wpsc_gold_options_outside{
1263
+ width:400px;
1264
+ }
1265
+ #gold_cart_form .postbox p{
1266
  padding-left: 4px;
1267
  }
1268
+ #gold_cart_form .postbox{
1269
+ width:100%;
1270
+ max-width:500px;
 
1271
  }
1272
+ #gold_cart_form .postbox p{
1273
+ padding-left:10px;
 
1274
  }
1275
+ #gold_cart_form .postbox p label{
1276
+ width:80px;
1277
+ float:left;
 
1278
  }
1279
 
1280
  a.admin_download {
1284
  text-decoration: none;
1285
  }
1286
 
1287
+ a.admin_download img{
1288
  margin-right: 3px;
1289
  }
1290
 
1291
+ a.admin_download span{
1292
  text-decoration: underline;
1293
  }
1294
 
1295
+ /*
1296
+ * Product Groups styles end here
1297
+ */
1298
+ .wpsc_td_note{
1299
+ padding-bottom:0 !important;
 
 
1300
  }
1301
 
1302
  .wpsc_purchaselogs_options {
1303
  margin: 0px 0px 8px 0px;
1304
+
1305
  }
1306
 
1307
+
1308
  p.add_new_form_set_forms {
1309
  display: none;
1310
  }
1312
  td.product-image a img.attachment-thumbnail {
1313
  height: 38px;
1314
  width: 38px;
1315
+
1316
  }
1317
 
1318
  #wpsc_product_category_and_tag_forms .tagchecklist {
1319
+ font-size:11px;
1320
  }
1321
 
1322
+ #categorydiv div{
1323
  margin-top: 4px;
1324
  }
1325
 
1329
  font-size: 15px;
1330
  }
1331
 
1332
+ .toplevel_page_wpsc-edit-products .wrap h2
1333
+ {
1334
+ padding-bottom:0px;
1335
+ border-bottom:1px solid #CCC;
1336
  }
1337
+ #post-body #advanced-sortables
1338
+ {
1339
+ margin-right:300px
1340
  }
 
1341
  #media-buttons #add_audio,
1342
  #media-buttons #add_video,
1343
  #media-buttons #add_media {
1344
+ display:none;
1345
  }
 
1346
  .meta-box-sortables-wpec .postbox:hover .handlediv {
1347
  background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
1348
  }
1349
 
1350
+ /* marketing / coupon page styling */
1351
 
1352
+ div.modify_coupon{ border: 1px solid #eeeeee; display: none; width: 100%; }
1353
+ table.coupon_data{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1354
  width: 100%;
1355
  }
1356
+ table.add-coupon{width:100%;}
1357
+ table.add-coupon tr th{ text-align: left; padding: 2px 5px 0px 5px; border: none;}
1358
+ table.add-coupon tr td{ text-align: left; padding: 2px 5px 2px 5px; border: none;}
1359
+ table.add-coupon tr td p{padding:0;margin:5px;}
1360
+ #table_header{
1361
+ font-size:16px;
1362
+ margin-top:20px;
1363
  font-weight: bold;
1364
  }
1365
+ table.coupon-list{ width: 100%; }
1366
+ table.coupon-list th{ text-align:left;}
1367
+ table.coupon-list tr.toprow td{ text-align: left; font-weight:bold; }
1368
 
1369
+ table.coupon-list tr td{ padding: 5px 5px 10px 10px; vertical-align: middle;}
 
 
 
1370
 
1371
+ table.coupon-list tr.alt{ background-color: #eeeeee; }
 
 
 
 
 
 
 
 
 
 
1372
 
1373
+ table.coupon-list tr.alt td{ background-color: #eeeeee; }
1374
+ table.coupon-list tr.coupon_edit td{ padding:0; }
1375
+ td#order_summary_container{ width: 80px; }
1376
+ table.category_forms a.delete_button, span.delete_button {
1377
+ color:#FF0000;
1378
+ display:block;
1379
+ float:left;
1380
+ font-size:11px;
1381
+ margin:3px 0 0 8px;
1382
+ text-decoration:underline;
1383
  }
1384
+ p span.input_label{
1385
+ font-size:1.2em;
1386
+ width:180px;
1387
+ float:left;
 
 
 
 
 
1388
  }
 
 
 
 
 
 
 
1389
  a.wpsc_featured_product_toggle {
1390
  display: block;
1391
  height: 18px;
1393
  margin: 4px 0px 0px 0px;
1394
  }
1395
 
1396
+ .column-featured a { background:url( '../../wpsc-core/images/core-sprite.png') no-repeat 0 -32px transparent; }
1397
+ .column-featured a.gold-star { background-position:0 -16px; }
 
 
 
 
 
 
1398
  .column-featured a:active,
1399
+ .column-featured a.gold-star:active { background-position:0 0; }
 
 
1400
 
1401
  div.wpsc_clear {
1402
  clear: both;
1409
  position: relative;
1410
  }
1411
 
1412
+
1413
  .wpsc_featured .item_text {
1414
  float: left;
1415
  height: 240px;
1428
  height: 240px;
1429
  width: 340px;
1430
  border: 1px solid #FEFAF1;
1431
+ border-radius: 18px;
1432
+ -moz-border-radius: 18px;
1433
  -webkit-border-radius: 18px;
 
 
1434
  background-repeat: no-repeat;
1435
  }
1436
 
1437
+
1438
  .wpsc_featured .item_text h3 {
1439
  font-size: 1.4em;
1440
  margin: 0px 0px 8px 0px;
1445
  line-height: normal;
1446
  display: block;
1447
  margin: 0px 0px 4px 0px;
1448
+
1449
  }
1450
 
1451
  .wpsc_featured .item_text .wpsc_description {
1452
  font-size: 1em;
1453
+ line-height:24px;
1454
+ display:block;
1455
+ float:left;
1456
  width: auto;
1457
  color: #9B9A96;
1458
+ font-family: Georgia,"Bitstream Charter",serif;
1459
  }
1460
 
1461
  .wpsc_featured .item_text .wpsc_description p {
1462
  margin-bottom: 0px;
1463
  }
1464
 
1465
+
1466
  .wpsc_featured .item_text .wpsc_description a {
1467
+ color:#9B9A96;
1468
  }
1469
 
1470
  ul.wpsc_categories {
1471
  clear: both;
1472
  }
1473
 
1474
+ a.update_variations_action
1475
+ {
1476
+ vertical-align:middle;
1477
  }
 
1478
  #poststuff .inside p.update-variations {
1479
+ display:none;
1480
+ margin-top:1em;
1481
  }
1482
+ #search-products{
1483
+ width:auto;
1484
+ float:right;
 
1485
  }
1486
+ .productnav{
1487
+ height: 30px;
1488
+ margin: 6px 0px 4px;
1489
+ vertical-align: middle;
 
1490
  }
1491
 
1492
  #wpsc_stock_control_forms .edit_stock {
1493
+ margin-top:0.5em;
1494
+ line-height:16px;
1495
  }
 
1496
  #wpsc_stock_control_forms .unpublish_when_none_left,
1497
  #wpsc_stock_control_forms .notify_when_none_left {
1498
+ margin:0.5em 0;
1499
  }
 
1500
  #media-upload form p.help {
1501
+ text-align:left;
1502
+ clear:both;
1503
  }
1504
+ ul#category_list_li, ul.poll-options {
1505
+ }
1506
+ ul#category_list_li li div,
1507
+ ul#category_list_li li div ul li div {
1508
+ }
1509
+ ul#category_list_li li div div,
1510
+ ul#category_list_li li div ul li div div {
1511
 
1512
+ }
1513
+ ul#category_list_li li div:hover div{
1514
  }
1515
 
1516
+ ul#category_list_li li div ul li div:hover div {
1517
+ }
1518
+ ul#category_list_li li {
1519
+ }
1520
+ ul#category_list_li li:hover span.handle {
1521
+ cursor: move;
1522
+ }
1523
+ .edit{
1524
+ }
1525
  ul#category_list_li li span.handle {
1526
+ float:left;
1527
+
1528
  padding: 5px;
1529
+
1530
  }
1531
 
1532
+ .category_admin_list_img a.row-title{
1533
  text-decoration: none;
1534
  }
1535
 
1536
+
1537
  .category_admin_list_img:hover div.row-actions {
1538
+ visibility:visible;
1539
  }
1540
 
1541
  ul#category_list_li ul {
1542
+ margin-left:15px;
1543
  }
1544
 
1545
  .row-title img {
1546
+ width:30px;
1547
+ float:left;
1548
+ padding-right:10px;
1549
  }
 
1550
  .row-title {
1551
+ margin-right:5px;
1552
  }
 
1553
  body.edit-php form#posts-filter {
1554
+ min-width:830px;
1555
  }
 
1556
  input.wpsc_cat_image_size {
1557
+ width:40px
1558
  }
 
1559
  input.wpsc_cat_box {
1560
+ width:auto;
1561
+ margin:6px;
1562
+ vertical-align:middle;
1563
  }
1564
 
1565
+ .wpsc_ie_field{
1566
+ width:100%;
1567
  }
 
1568
  .wpsc_inline_actions .loading_indicator {
1569
+ position:relative;
1570
+ top:3px;
1571
+ left:2px;
1572
  visibility: hidden;
1573
  }
 
1574
  table.tags th#image {
1575
+ width:60px;
1576
  }
1577
+ /* quick and bulk edit product */
 
 
 
 
 
1578
  #wpbody-content .bulk-edit-row-post fieldset.wpsc-cols {
1579
+ width:49%;
1580
+ margin-top:0;
1581
  }
1582
 
1583
  #wpbody-content .quick-edit-row-post .inline-edit-col-left {
1584
+ width:35%;
1585
  }
1586
 
1587
  .bulk-edit-row-post fieldset.inline-edit-col-right label span.title {
1588
+ padding-right:0.5em;
1589
+ width:auto;
1590
  }
1591
 
1592
  .wpsc-quick-edit {
1593
+ width: 30%;
1594
+ float:left;
1595
  }
1596
 
1597
  textarea.tax_input_product_tag {
1598
+ width:50% !important;
1599
+ height: 95px !important;
1600
  }
1601
 
1602
  ul.wpsc_product_category-checklist {
1603
+ height: 280px;
1604
  }
1605
 
1606
+ span.wpsc-quick-edit{
1607
+ width:77px;
1608
+ display: block;
1609
+ float: left;
1610
  }
1611
+ .wpsc_var_description{
1612
+ margin:20px 0 0 20px !important;
1613
+ color:red;
 
1614
  }
1615
 
1616
  .ajax-loading {
1618
  }
1619
 
1620
  #cart_options .delete {
1621
+ color:#c00;
1622
+ float:right;
1623
  }
 
1624
  #cart_options .delete:hover {
1625
+ color:#D54E21;
1626
  }
1627
 
1628
  .dashboard_page_wpsc-update .wpsc-progress-bar {
1629
+ position:relative;
1630
+ height:20px;
1631
+ width:300px;
1632
+ border:1px solid #3a58cf;
1633
+ margin:-0.75em 0 27px;
1634
  }
1635
 
1636
  .dashboard_page_wpsc-update .wpsc-progress-bar * {
1637
+ position:absolute;
1638
+ left:0;
1639
+ top:0;
1640
+ background:#f9f9f9;
1641
+ font-size:12px;
1642
  }
1643
 
1644
  .dashboard_page_wpsc-update .wpsc-progress-bar .block {
1645
+ background-color:#527dff;
1646
+ z-index:-1;
1647
+ height:20px;
1648
  }
1649
 
1650
  .dashboard_page_wpsc-update .wpsc-progress-bar span {
1651
+ display:block;
1652
+ left:310px;
1653
+ line-height:20px;
1654
+ width:200px;
1655
  }
1656
 
1657
  .dashboard_page_wpsc-update .wpsc-progress-bar .eta {
1658
+ top:22px;
1659
+ line-height:15px;
1660
+ width:100%;
1661
  }
1662
 
1663
+ .downloadables_float{
1664
  float: right;
1665
+ width:80px;
1666
  vertical-align: middle;
1667
+
1668
  }
1669
 
1670
+ .downloadables_headding1{
1671
  display: inline;
1672
+ float:left;
1673
  text-align: left;
1674
  vertical-align: middle;
1675
  width: auto;
1676
  }
1677
 
1678
  img.ajax-feedback-active {
1679
+ vertical-align:middle;
1680
+ visibility:visible;
1681
  }
1682
 
1683
  .dashboard_page_wpsc-purchase-logs .column-id {
1684
+ width:75px;
1685
  }
1686
 
1687
  .dashboard_page_wpsc-purchase-logs .column-amount {
1688
+ width:100px;
1689
  }
1690
 
1691
+ .js table.purchase-logs td.column-status span, table.purchase-logs .column-status select {
1692
+ display:none;
 
1693
  }
1694
 
1695
  .js table.purchase-logs .column-status select {
1696
+ display:inline-block;
1697
+ margin-right:5px;
1698
  }
1699
 
1700
  table.purchase-logs .column-tracking .empty {
1701
+ position:relative;
1702
  }
1703
 
1704
  table.purchase-logs .column-tracking .empty .send-email {
1705
+ display:none;
1706
  }
1707
 
1708
  table.purchase-logs .column-tracking .add {
1709
+ position:absolute;
1710
+ left:6px;
1711
+ top:4px;
1712
  }
1713
 
1714
  table.purchase-logs .column-tracking {
1715
+ width:200px;
1716
  }
1717
 
1718
  table.purchase-logs .column-tracking input[type="text"] {
1719
+ width:180px;
1720
  }
1721
 
1722
  table.purchase-logs .column-tracking a.save {
1723
+ display:none;
1724
+ float:right;
1725
  }
1726
 
1727
  table.purchase-logs .column-tracking a.add {
1728
+ display:none;
1729
+ color:#ccc;
1730
+ cursor:text;
1731
  }
1732
 
1733
  table.purchase-logs .column-tracking .empty a.add {
1734
+ display:inline;
1735
  }
1736
 
1737
  table.purchase-logs .column-tracking .ajax-feedback {
1738
+ display:none;
1739
+ float:right;
1740
+ margin-top:5px;
1741
  }
1742
 
1743
  table.purchase-logs .column-tracking .ajax-feedback-active {
1744
+ display:inline-block;
1745
  }
1746
 
1747
  table.purchase-logs .column-tracking em.sent {
1748
+ color:green;
1749
  }
1750
 
1751
  table.purchase-logs .column-id .delete {
1752
+ color:red;
1753
+ visibility:hidden;
1754
  }
1755
 
1756
  table.purchase-logs tr:hover .column-id .delete {
1757
+ visibility:visible;
1758
  }
1759
 
1760
+ /* Product Variations */
 
 
 
 
1761
  .no-js #wpsc_product_variation_forms iframe {
1762
+ height:300px;
1763
  }
1764
 
1765
  .js #wpsc_product_variation_forms iframe {
1766
+ border:0;
1767
+ margin:0;
1768
+ overflow:hidden;
1769
+ padding:0;
 
 
 
 
 
1770
  }
1771
 
1772
  #wpsc_product_variation_forms iframe {
1773
+ background:transparent;
1774
+ width:100%;
1775
  }
1776
 
1777
  .wpsc-product-variation-iframe {
1778
  min-width: 400px;
 
 
1779
  }
1780
 
1781
  #wpsc-product-variations-wrapper .tablenav.top {
1782
+ margin-top:0;
1783
  }
1784
 
1785
  .wpsc-save-variations-top {
1786
+ float:right;
1787
+ margin:8px 0 5px;
1788
  }
1789
 
1790
  #wpsc-product-variations-wrapper .column-stock input[type="text"],
1792
  #wpsc-product-variations-wrapper .column-price input[type="text"],
1793
  #wpsc-product-variations-wrapper .column-sale_price input[type="text"],
1794
  #wpsc-product-variations-wrapper .column-sku input[type="text"] {
1795
+ width:100%;
1796
+
1797
+ box-sizing:border-box;
1798
+ -o-box-sizing:border-box;
1799
+ -moz-box-sizing:border-box;
1800
+ -webkit-box-sizing:border-box;
1801
  }
1802
 
1803
  #wpsc-product-variations-wrapper .inline-edit-row.column-stock input[type="text"],
1813
  #wpsc-product-variations-wrapper .column-price,
1814
  #wpsc-product-variations-wrapper .column-sale_price,
1815
  #wpsc-product-variations-wrapper .column-sku {
1816
+ text-align:center;
1817
+ width:11%;
1818
  }
1819
 
1820
  #wpsc-product-variations-wrapper .column-stock input,
1822
  #wpsc-product-variations-wrapper .column-price input,
1823
  #wpsc-product-variations-wrapper .column-sale_price input,
1824
  #wpsc-product-variations-wrapper .column-sku input {
1825
+ text-align:right;
1826
  }
1827
 
1828
+ .js #wpsc-product-variations-wrapper tbody .active td, .js #wpsc-product-variations-wrapper tbody .active th {
1829
+ border-bottom-style:dashed;
 
1830
  }
1831
 
1832
  #wpsc-product-variations-wrapper div.updated,
1835
  }
1836
 
1837
  .js #wpsc-product-variations-wrapper .wpsc-stock-editor-row {
1838
+ display:none;
1839
  }
1840
 
1841
  #wpsc-product-variations-wrapper .wpsc-stock-editor-row td {
1842
+ border-bottom-style:solid;
1843
  }
1844
 
1845
  #wpsc-product-variations-wrapper {
1847
  }
1848
 
1849
  #wpsc-product-variations-wrapper .submit {
1850
+ margin:0;
1851
+ padding:0;
1852
  }
1853
 
1854
  .wpsc-stock-editor .inside {
1855
+ overflow:hidden;
1856
  }
1857
 
1858
  .wpsc-stock-editor .wpsc-product-shipping-section {
1859
+ display:inline-block;
1860
  vertical-align: top;
1861
+ width:49%;
1862
  }
1863
 
1864
  .wpsc-stock-editor .wpsc-form-field {
1865
+ clear:both;
 
 
 
 
 
 
 
 
1866
  }
1867
 
1868
  .wpsc-stock-editor .wpsc-product-shipping-section input[type="text"] {
1869
+ text-align:right;
1870
+ width:50px;
1871
  }
1872
 
1873
  .wpsc-product-shipping-weight-dimensions label {
1874
+ display:inline-block;
1875
+ min-width:60px;
1876
  }
1877
 
1878
  .wpsc-product-shipping-flat-rate label {
1879
+ display:inline-block;
1880
+ min-width:160px;
1881
  }
1882
 
1883
  .wpsc-stock-editor {
1884
+ overflow:hidden;
1885
  }
1886
 
1887
  .wpsc-stock-editor select {
1888
+ min-width:100px;
1889
+ }
1890
+
1891
+ #wpsc_product_variation_forms .inside {
1892
+ background: #fff;
1893
+ padding: 0;
1894
+ margin: 0;
1895
+ }
1896
+
1897
+ #wpsc_product_variation_forms {
1898
+ overflow: auto !important;
1899
  }
1900
 
1901
  .wpsc-product-variations-tabs {
1902
+ background: #F1F1F1;
1903
+ border-bottom: 1px solid #dfdfdf;
1904
+ padding: 5px 4px 0;
1905
+ margin: 0;
1906
  width: 100%;
1907
  }
1908
 
1918
 
1919
  .wpsc-product-variations-tabs li {
1920
  float: left;
1921
+ margin: 0 4px 0 0;
1922
  }
1923
 
1924
  .wpsc-product-variations-tabs a {
1932
  padding: 5px 7px 3px;
1933
  text-decoration: none;
1934
  vertical-align: middle;
1935
+
1936
+ border-top-left-radius: 3px;
1937
+ border-top-right-radius: 3px;
1938
  -webkit-border-top-left-radius: 3px;
1939
+ -webkit-border-top-right-radius: 3px;
1940
+ -moz-border-top-left-radius: 3px;
1941
+ -moz-border-top-right-radius: 3px;
1942
  }
1943
 
1944
  .wpsc-product-variations-tabs a:hover {
1962
  }
1963
 
1964
  .wpsc-save-product-variations.bottom {
 
 
1965
  padding-bottom: 5px;
1966
  }
 
 
 
1967
 
1968
  .wpsc-product-variation-thumbnail {
1969
  float: left;
1971
  width: 50px;
1972
  }
1973
 
 
 
 
 
 
1974
  .wpsc-product-variation-title {
1975
  margin-left: 60px;
1976
  }
1982
 
1983
  .wpsc-button-round {
1984
  padding: 0 0 1px !important;
1985
+ height: 24px !important;
1986
  text-align: center;
1987
+ width: 24px !important;
1988
+ -webkit-border-radius: 12px !important;
1989
+ border-radius: 12px !important;
1990
  outline: 0 !important;
1991
  }
1992
 
1993
+ /* make the minus sign look balanced with the plus sign */
 
1994
  .wpsc-button-minus {
1995
  font-weight: bold;
1996
  font-size: 10px !important;
2014
  padding: 0;
2015
  }
2016
 
2017
+ div.new_layer,
2018
+ div#table_rate {
2019
+ display:none;
 
 
 
 
 
 
 
 
 
 
2020
  }
2021
 
2022
  body.edit-tags-php img.wpsc_category_image {
2023
+ max-width:256px;
2024
+ max-height:256px;
2025
+ min-width:128px;
2026
  }
2027
 
2028
  .wpsc-width-height-fields label {
2029
  display: inline;
2030
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/css/settingspage.css CHANGED
@@ -133,9 +133,6 @@ table.wpsc-edit-module-options tr td {
133
  border: none;
134
  overflow: initial;
135
  }
136
- .widefat .shipping-module-settings-form td input {
137
- margin-top: -5px;
138
- }
139
  .widefat .shipping-module-settings-form th {
140
  font-family: inherit;
141
  font-size: 12px;
133
  border: none;
134
  overflow: initial;
135
  }
 
 
 
136
  .widefat .shipping-module-settings-form th {
137
  font-family: inherit;
138
  font-size: 12px;
wpsc-admin/css/xit.gif DELETED
Binary file
wpsc-admin/db-upgrades/routines/1.php CHANGED
@@ -21,13 +21,14 @@ function _wpsc_fix_checkout_field_limitation() {
21
  }
22
 
23
  function _wpsc_fix_mexico_currency_sign() {
24
- $country = new WPSC_Country( array(
25
- 'isocode' => 'MX',
26
  'currency' => __( 'Mexican Peso', 'wpsc' ),
27
  'symbol' => __( '$', 'wpsc' ),
28
  'symbol_html' => __( '&#036;', 'wpsc' ),
29
  'has_regions' => '1'
30
  ) );
 
31
  }
32
 
33
  function _wpsc_fix_canadian_province_codes() {
@@ -71,62 +72,65 @@ function _wpsc_fix_canadian_province_codes() {
71
  }
72
 
73
  function _wpsc_fix_colombia_currency() {
74
- $country = new WPSC_Country( array(
75
- 'isocode' => 'CO',
76
  'symbol' => __( '$', 'wpsc' ),
77
  'symbol_html' => __( '&#036;', 'wpsc' ),
78
  ) );
 
79
  }
80
 
81
  function _wpsc_fix_ukraine_currency() {
82
- $country = new WPSC_Country( array(
83
- 'isocode' => 'UA',
84
  'code' => __( 'UAH', 'wpsc' ),
85
  'symbol' => __( '₴', 'wpsc' ),
86
  'symbol_html' => __( '&#8372;', 'wpsc' ),
87
  ) );
 
88
  }
89
 
90
  function _wpsc_fix_russia_currency() {
91
- $country = new WPSC_Country( array(
92
- 'isocode' => 'RU',
93
- 'code' => __( 'RUB', 'wpsc' )
94
- ) );
95
  }
96
 
97
  function _wpsc_fix_belarus_currency() {
98
- $country = new WPSC_Country( array(
99
- 'isocode' => 'BY',
100
- 'code' => __( 'BYR', 'wpsc' )
101
- ) );
102
  }
103
 
104
  function _wpsc_fix_estonia_currency() {
105
- $country = new WPSC_Country( array(
106
- 'isocode' => 'EE',
107
  'currency' => __( 'Euro', 'wpsc' ),
108
  'symbol' => __( '€', 'wpsc' ),
109
  'symbol_html' => __( '&#8364;', 'wpsc' ),
110
  'code' => __( 'EUR', 'wpsc' )
111
  ) );
 
112
  }
113
 
114
  function _wpsc_fix_slovenia_currency() {
115
- $country = new WPSC_Country( array(
116
- 'isocode' => 'SI',
117
  'currency' => __( 'Euro', 'wpsc' ),
118
  'symbol' => __( '€', 'wpsc' ),
119
  'symbol_html' => __( '&#8364;', 'wpsc' ),
120
  'code' => __( 'EUR', 'wpsc' )
121
  ) );
 
122
  }
123
 
124
  function _wpsc_fix_sudan_currency() {
125
- $country = new WPSC_Country( array(
126
- 'isocode' => 'SD',
127
  'currency' => __( 'Sudanese Pound', 'wpsc' ),
128
  'code' => __( 'SDG', 'wpsc' )
129
  ) );
 
130
  }
131
 
132
  function _wpsc_create_south_sudan() {
@@ -139,4 +143,5 @@ function _wpsc_create_south_sudan() {
139
  'continent' => 'africa',
140
  'visible' => 0,
141
  ) );
 
142
  }
21
  }
22
 
23
  function _wpsc_fix_mexico_currency_sign() {
24
+ $country = new WPSC_Country( 'MX', 'isocode' );
25
+ $country->set( array(
26
  'currency' => __( 'Mexican Peso', 'wpsc' ),
27
  'symbol' => __( '$', 'wpsc' ),
28
  'symbol_html' => __( '&#036;', 'wpsc' ),
29
  'has_regions' => '1'
30
  ) );
31
+ $country->save();
32
  }
33
 
34
  function _wpsc_fix_canadian_province_codes() {
72
  }
73
 
74
  function _wpsc_fix_colombia_currency() {
75
+ $country = new WPSC_Country( 'CO', 'isocode' );
76
+ $country->set( array(
77
  'symbol' => __( '$', 'wpsc' ),
78
  'symbol_html' => __( '&#036;', 'wpsc' ),
79
  ) );
80
+ $country->save();
81
  }
82
 
83
  function _wpsc_fix_ukraine_currency() {
84
+ $country = new WPSC_Country( 'UA', 'isocode' );
85
+ $country->set( array(
86
  'code' => __( 'UAH', 'wpsc' ),
87
  'symbol' => __( '₴', 'wpsc' ),
88
  'symbol_html' => __( '&#8372;', 'wpsc' ),
89
  ) );
90
+ $country->save();
91
  }
92
 
93
  function _wpsc_fix_russia_currency() {
94
+ $country = new WPSC_Country( 'RU', 'isocode' );
95
+ $country->set( 'code', __( 'RUB', 'wpsc' ) );
96
+ $country->save();
 
97
  }
98
 
99
  function _wpsc_fix_belarus_currency() {
100
+ $country = new WPSC_Country( 'BY', 'isocode' );
101
+ $country->set( 'code', __( 'BYR', 'wpsc' ) );
102
+ $country->save();
 
103
  }
104
 
105
  function _wpsc_fix_estonia_currency() {
106
+ $country = new WPSC_Country( 'EE', 'isocode' );
107
+ $country->set( array(
108
  'currency' => __( 'Euro', 'wpsc' ),
109
  'symbol' => __( '€', 'wpsc' ),
110
  'symbol_html' => __( '&#8364;', 'wpsc' ),
111
  'code' => __( 'EUR', 'wpsc' )
112
  ) );
113
+ $country->save();
114
  }
115
 
116
  function _wpsc_fix_slovenia_currency() {
117
+ $country = new WPSC_Country( 'SI', 'isocode' );
118
+ $country->set( array(
119
  'currency' => __( 'Euro', 'wpsc' ),
120
  'symbol' => __( '€', 'wpsc' ),
121
  'symbol_html' => __( '&#8364;', 'wpsc' ),
122
  'code' => __( 'EUR', 'wpsc' )
123
  ) );
124
+ $country->save();
125
  }
126
 
127
  function _wpsc_fix_sudan_currency() {
128
+ $country = new WPSC_Country( 'SD', 'isocode' );
129
+ $country->set( array(
130
  'currency' => __( 'Sudanese Pound', 'wpsc' ),
131
  'code' => __( 'SDG', 'wpsc' )
132
  ) );
133
+ $country->save();
134
  }
135
 
136
  function _wpsc_create_south_sudan() {
143
  'continent' => 'africa',
144
  'visible' => 0,
145
  ) );
146
+ $country->save();
147
  }
wpsc-admin/db-upgrades/routines/10.php DELETED
@@ -1,134 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Control database upgrade to version 10
5
- *
6
- * @access private
7
- * @since 3.8.14
8
- *
9
- */
10
- function _wpsc_db_upgrade_10() {
11
- _wpsc_add_region_name_meta();
12
- _wpsc_maybe_create_visitor_tables();
13
- _wpsc_cleanup_visitor_meta_checkout_details();
14
- }
15
-
16
- /**
17
- * 3.8.14 supports country meta and a feature that let's a countries regions be called by the
18
- * proper name. Here we initialize the values.
19
- *
20
- * @access private
21
- * @since 3.8.14
22
- *
23
- */
24
- function _wpsc_add_region_name_meta() {
25
- $wpsc_country = new WPSC_Country( 'US' );
26
- $wpsc_country->set( 'region_label', __( 'State', 'wpsc' ) );
27
-
28
- $wpsc_country = new WPSC_Country( 'CA' );
29
- $wpsc_country->set( 'region_label', __( 'Province', 'wpsc' ) );
30
- }
31
-
32
- /**
33
- * 3.8.14 maintains visitor information in a visitors table, create it
34
- *
35
- * @access private
36
- * @since 3.8.14
37
- *
38
- */
39
- function _wpsc_maybe_create_visitor_tables() {
40
- _wpsc_create_visitor_table();
41
- _wpsc_create_visitor_meta_table();
42
- _wpsc_meta_migrate_anonymous_users();
43
- }
44
-
45
- /**
46
- * starting in 3.8.14 visitors information belongs in the vistor table, not the users table, start
47
- * the migration. This migration could take a very long time so it's done as a cron
48
- *
49
- * @access private
50
- * @since 3.8.14
51
- *
52
- */
53
- function _wpsc_meta_migrate_anonymous_users() {
54
- global $wpdb;
55
-
56
- // get the users table auto increment value, and set the visitor meta auto increment to match.
57
- // we do this so that new customer cookies don't collide with existing customer cookies after
58
- // the migration. Note we can't use max of user id because users may have been deleted.
59
- $sql = 'SHOW TABLE STATUS WHERE NAME = "' . $wpdb->users . '"';
60
- $status = $wpdb->get_results( $sql );
61
-
62
- $wpdb->query( 'ALTER TABLE ' . $wpdb->wpsc_visitors . ' AUTO_INCREMENT = ' . $status[0]->Auto_increment );
63
-
64
- wp_suspend_cache_addition( true );
65
-
66
- $role = get_role( 'wpsc_anonymous' );
67
-
68
- if ( $role ) {
69
- remove_role( 'wpsc_anonymous', __( 'Anonymous', 'wpsc' ) );
70
- }
71
-
72
- wp_schedule_single_event( time() + 5 , 'wpsc_migrate_anonymous_user_cron' );
73
-
74
- }
75
-
76
-
77
- /**
78
- * Create the table for visitors
79
- *
80
- * @since 3.8.14
81
- * @access private
82
- *
83
- */
84
- function _wpsc_create_visitor_table() {
85
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
86
- global $wpdb;
87
- global $charset_collate;
88
-
89
- $sql = 'CREATE TABLE IF NOT EXISTS '. $wpdb->wpsc_visitors .' ('
90
- .'id bigint(20) unsigned NOT NULL AUTO_INCREMENT, '
91
- .'user_id bigint(20) unsigned DEFAULT NULL , '
92
- .'last_active timestamp NULL DEFAULT NULL, '
93
- .'expires timestamp NULL DEFAULT NULL, '
94
- .'created timestamp NULL DEFAULT NULL, '
95
- .'PRIMARY KEY ( `id` ), '
96
- .'KEY user_id ( `user_id` ), '
97
- .'KEY expires ( `expires` ), '
98
- .'KEY last_active ( `last_active` ), '
99
- .'KEY created ( `created` ) '
100
- .') '. $charset_collate;
101
-
102
- dbDelta( $sql );
103
-
104
- _wpsc_create_well_known_visitors();
105
- }
106
-
107
- /**
108
- * Create the meta table for visitor meta
109
- *
110
- * @since 3.8.14
111
- * @access private
112
- *
113
- */
114
- function _wpsc_create_visitor_meta_table() {
115
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
116
- global $wpdb;
117
- global $charset_collate;
118
-
119
- $sql = 'CREATE TABLE IF NOT EXISTS '. $wpdb->wpsc_visitormeta .' ('
120
- .'meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, '
121
- .'wpsc_visitor_id bigint(20) unsigned NOT NULL DEFAULT 0 , '
122
- .'meta_key varchar(255) DEFAULT NULL, '
123
- .'meta_value longtext, '
124
- .'meta_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, '
125
- .'PRIMARY KEY (meta_id), '
126
- .'KEY wpsc_visitor_id (wpsc_visitor_id), '
127
- .'KEY meta_key (meta_key(191)), '
128
- .'KEY meta_value (meta_value(20)), '
129
- .'KEY meta_key_and_value (meta_key(191),meta_value(32)), '
130
- .'KEY meta_timestamp_index ( `meta_timestamp` ) '
131
- .') '. $charset_collate;
132
-
133
- dbDelta( $sql );
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/11.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
- /**
3
- * Control database upgrade to version 11
4
- *
5
- * @access private
6
- * @since 3.8.14
7
- *
8
- */
9
- function _wpsc_db_upgrade_11() {
10
- _wpsc_fix_united_kingdom();
11
- _wpsc_set_legacy_country_meta();
12
- }
13
-
14
- /**
15
- * Reset United Kingdom country data to default, hide ISO code 'UK'
16
- *
17
- * @access private
18
- * @since 3.8.14
19
- */
20
- function _wpsc_fix_united_kingdom() {
21
-
22
- $legacy_ok_country_was_visible = true;
23
-
24
- if ( $wpsc_country = WPSC_Countries::get_country( 'UK' ) ) {
25
-
26
- $legacy_ok_country_was_visible = $wpsc_country->is_visible();
27
-
28
- $wpsc_country = new WPSC_Country(
29
- array(
30
- 'visible' => '0',
31
- 'isocode' => 'UK',
32
- )
33
- );
34
-
35
- $wpsc_country->set( '_is_country_legacy', true );
36
- }
37
-
38
- $wpsc_country = new WPSC_Country(
39
- array(
40
- 'country' => __( 'United Kingdom', 'wpsc' ),
41
- 'isocode' => 'GB',
42
- 'currency' => __( 'Pound Sterling', 'wpsc' ),
43
- 'symbol' => __( '£', 'wpsc' ),
44
- 'symbol_html' => __( '&#163;', 'wpsc' ),
45
- 'code' => __( 'GBP', 'wpsc' ),
46
- 'continent' => 'europe',
47
- 'visible' => $legacy_ok_country_was_visible ? '0' : '1',
48
- 'has_regions' => '0',
49
- 'tax' => '0',
50
- )
51
- );
52
-
53
- //make sure base country is ok after the UK/GB fix
54
- $base_country = get_option( 'base_country', '' );
55
- if ( ! empty( $base_country ) && is_numeric( $base_country ) ) {
56
- $wpsc_country = new WPSC_Country( $base_country );
57
- if ( 'UK' == $wpsc_country->get_isocode() ) {
58
- $wpsc_country = new WPSC_Country( 'GB' );
59
- update_option( 'base_country' , $wpsc_country->get_id() );
60
- }
61
- }
62
-
63
- }
64
-
65
- /**
66
- * Sets meta for countries that no longer exist in their former notation to be considered legacy.
67
- *
68
- * @access private
69
- * @since 3.8.14
70
- */
71
- function _wpsc_set_legacy_country_meta() {
72
- if ( $wpsc_country = WPSC_Countries::get_country( 'YU' ) ) {
73
- $wpsc_country->set( '_is_country_legacy', true );
74
- }
75
-
76
- if ( $wpsc_country = WPSC_Countries::get_country( 'AN' ) ) {
77
- $wpsc_country->set( '_is_country_legacy', true );
78
- }
79
-
80
- if ( $wpsc_country = WPSC_Countries::get_country( 'TP' ) ) {
81
- $wpsc_country->set( '_is_country_legacy', true );
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/12.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Control database upgrade to version 12
4
- *
5
- * @access private
6
- * @since 3.8.14
7
- *
8
- */
9
- function _wpsc_db_upgrade_12() {
10
- _wpsc_fix_billing_country_meta();
11
- _wpsc_fix_shipping_country_meta();
12
- }
13
-
14
- /**
15
- * make sure the billing country meta is stored as individual values not as an array
16
- *
17
- * @access private
18
- * @since 3.8.14
19
- */
20
- function _wpsc_fix_billing_country_meta() {
21
- global $wpdb;
22
-
23
- $sql = 'SELECT * from ' . $wpdb->wpsc_visitormeta . ' WHERE meta_key = "billingcountry"';
24
- $metas = $wpdb->get_results( $sql, OBJECT );
25
-
26
- foreach ( $metas as $meta ) {
27
- $meta_value = maybe_unserialize( $meta->meta_value );
28
- if ( is_array( $meta_value ) ) {
29
- wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'billingregion', $meta_value[1] );
30
- wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'billingcountry', $meta_value[0] );
31
- }
32
- }
33
- }
34
-
35
- /**
36
- * make sure the shipping country meta is stored as individual values not as an array
37
- *
38
- * @access private
39
- * @since 3.8.14
40
- */
41
- function _wpsc_fix_shipping_country_meta() {
42
- global $wpdb;
43
-
44
- $sql = 'SELECT * from ' . $wpdb->wpsc_visitormeta . ' WHERE meta_key = "shippingcountry"';
45
- $metas = $wpdb->get_results( $sql, OBJECT );
46
-
47
- foreach ( $metas as $meta ) {
48
- $meta_value = maybe_unserialize( $meta->meta_value );
49
- if ( is_array( $meta_value ) ) {
50
- wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'shippingregion', $meta_value[1] );
51
- wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'shippingcountry', $meta_value[0] );
52
- }
53
- }
54
- }
55
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/13.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /**
3
- * Control database upgrade to version 13
4
- *
5
- * @access private
6
- * @since 3.8.14
7
- *
8
- */
9
- function _wpsc_db_upgrade_13() {
10
- _wpsc_add_region_label_to_uk();
11
- _wpsc_fix_bad_checkout_form_rows();
12
- }
13
-
14
- /**
15
- * Add the county region label to the uk
16
- *
17
- * @access private
18
- * @since 3.8.14.1
19
- */
20
- function _wpsc_add_region_label_to_uk() {
21
- $wpsc_country = new WPSC_Country( 'GB' );
22
- $wpsc_country->set( 'region_label', __( 'County', 'wpsc' ) );
23
- }
24
-
25
- function _wpsc_fix_bad_checkout_form_rows() {
26
- global $wpdb;
27
-
28
- $rows = $wpdb->get_results( 'SELECT * from '. WPSC_TABLE_CHECKOUT_FORMS . ' WHERE `unique_name` = ""' );
29
-
30
- foreach ( $rows as $index => $row ) {
31
- // look for the unique name to be sure it doesn't already-exist, if it does, make it unique
32
- $new_unique_name = sanitize_title( $row->name );
33
-
34
- $count = $wpdb->get_var( 'SELECT count(*) FROM ' . WPSC_TABLE_CHECKOUT_FORMS . ' WHERE `unique_name` = "' . $new_unique_name .'"' );
35
- $count = intval( $count );
36
- if ( $count ) {
37
- $new_unique_name = sanitize_title( $row->name ) . '-' . ( $count + 1 );
38
- }
39
-
40
- $result = $wpdb->query(
41
- 'UPDATE ' . WPSC_TABLE_CHECKOUT_FORMS
42
- . ' SET `unique_name` = "' . $new_unique_name
43
- . '" WHERE id=' . $row->id
44
- );
45
- }
46
-
47
-
48
- $index = $wpdb->get_results( 'SHOW INDEX FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE KEY_NAME = "unique_name"' );
49
-
50
- if ( ! count( $index ) ) {
51
- // Add the new index
52
- $wpdb->query( 'ALTER TABLE `' . WPSC_TABLE_CHECKOUT_FORMS . '` ADD INDEX ( `unique_name` )' );
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/14.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
- /**
3
- * Control database upgrade to version 14
4
- *
5
- * @access private
6
- * @since 3.9.0
7
- *
8
- */
9
- function _wpsc_db_upgrade_14() {
10
- _wpsc_fix_latvia_currency();
11
- }
12
-
13
- /**
14
- * Change Latvian currency to Euro.
15
- *
16
- * @access private
17
- * @since 3.9.0
18
- */
19
- function _wpsc_fix_latvia_currency() {
20
- $country = new WPSC_Country( array(
21
- 'isocode' => 'LV',
22
- 'currency' => __( 'Euro', 'wpsc' ),
23
- 'symbol' => __( '€', 'wpsc' ),
24
- 'symbol_html' => __( '&#8364;', 'wpsc' ),
25
- 'code' => __( 'EUR', 'wpsc' )
26
- ) );
27
-
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/2.php CHANGED
@@ -44,16 +44,15 @@ function _wpsc_db_upgrade_2() {
44
  }
45
 
46
  function _wpsc_fix_UK_country_code() {
47
- $country = new WPSC_Country( array(
48
- 'isocode' => 'GB',
49
- 'country', __( 'United Kingdom', 'wpsc' )
50
- ) );
51
  }
52
 
53
  function _wpsc_fix_guernsey_country_code() {
54
- $existing_wpsc_country = new WPSC_Country( 'GF' );
55
- // replace the ISO country code in the existing country
56
- $updated_wpsc_country = new WPSC_Country( array( 'id' => $existing_wpsc_country->get_id(), 'isocode' => 'GG', ) );
57
  }
58
 
59
  function _wpsc_new_country_serbia() {
@@ -66,6 +65,7 @@ function _wpsc_new_country_serbia() {
66
  'continent' => 'europe',
67
  'visible' => '0',
68
  ) );
 
69
  }
70
 
71
  function _wpsc_new_country_montenegro() {
@@ -80,6 +80,7 @@ function _wpsc_new_country_montenegro() {
80
  'continent' => 'europe',
81
  'visible' => '0',
82
  ) );
 
83
  }
84
 
85
  function _wpsc_fix_timor_leste_name() {
@@ -94,6 +95,7 @@ function _wpsc_fix_timor_leste_name() {
94
  'continent' => 'asiapacific',
95
  'visible' => '0',
96
  ) );
 
97
  }
98
 
99
  function _wpsc_new_country_aland_islands() {
@@ -108,6 +110,7 @@ function _wpsc_new_country_aland_islands() {
108
  'continent' => 'europe',
109
  'visible' => '0',
110
  ) );
 
111
  }
112
 
113
  function _wpsc_new_country_saint_barthelemy() {
@@ -122,6 +125,7 @@ function _wpsc_new_country_saint_barthelemy() {
122
  'continent' => 'europe',
123
  'visible' => '0',
124
  ) );
 
125
  }
126
 
127
  function _wpsc_new_country_bonaire_et_al() {
@@ -136,6 +140,7 @@ function _wpsc_new_country_bonaire_et_al() {
136
  'continent' => 'southamerica',
137
  'visible' => '0',
138
  ) );
 
139
  }
140
 
141
  function _wpsc_new_country_curacao() {
@@ -150,6 +155,7 @@ function _wpsc_new_country_curacao() {
150
  'continent' => 'southamerica',
151
  'visible' => '0',
152
  ) );
 
153
  }
154
 
155
  function _wpsc_new_country_saint_martin_french() {
@@ -164,6 +170,7 @@ function _wpsc_new_country_saint_martin_french() {
164
  'continent' => 'southamerica',
165
  'visible' => '0',
166
  ) );
 
167
  }
168
 
169
  function _wpsc_new_country_palestinian_territories() {
@@ -178,14 +185,16 @@ function _wpsc_new_country_palestinian_territories() {
178
  'continent' => 'asiapacific',
179
  'visible' => '0',
180
  ) );
 
181
  }
182
 
183
  function _wpsc_update_israeli_new_shekel_symbol() {
184
- $country = new WPSC_Country( array(
185
- 'isocode' => 'IL',
186
  'symbol' => __( '₪', 'wpsc' ),
187
  'symbol_html' => __( '&#8362;', 'wpsc' ),
188
  ) );
 
189
  }
190
 
191
  function _wpsc_new_country_sint_maarten_dutch() {
@@ -200,6 +209,7 @@ function _wpsc_new_country_sint_maarten_dutch() {
200
  'continent' => 'southamerica',
201
  'visible' => '0',
202
  ) );
 
203
  }
204
 
205
  function _wpsc_new_country_french_guiana() {
@@ -214,217 +224,226 @@ function _wpsc_new_country_french_guiana() {
214
  'continent' => 'southamerica',
215
  'visible' => '0',
216
  ) );
 
217
  }
218
 
219
  function _wpsc_fix_netherlands_antille() {
220
- $country = new WPSC_Country( array(
221
- 'isocode' => 'AN',
222
  'symbol' => __( 'ƒ', 'wpsc' ),
223
  'symbol_html' => __( '&#402;', 'wpsc' ),
224
  'continent' => 'southamerica',
225
  ) );
 
226
  }
227
 
228
  function _wpsc_fix_angola_kwanza() {
229
- $country = new WPSC_Country( array(
230
- 'isocode' => 'AO',
231
  'code' => 'AOA',
232
  'currency' => __( 'Angolan Kwanza', 'wpsc' ),
233
  'symbol' => __( 'Kz', 'wpsc' ),
234
  'symbol_html' => __( 'Kz', 'wpsc' ),
235
  ) );
 
236
  }
237
 
238
  function _wpsc_fix_aruban_florin() {
239
- $country = new WPSC_Country( array(
240
- 'isocode' => 'AW',
241
  'currency' => __( 'Aruban Florin', 'wpsc' ),
242
  'symbol' => __( 'Afl.', 'wpsc' ),
243
  'symbol_html' => __( 'Afl.', 'wpsc' ),
244
  ) );
 
245
  }
246
 
247
  function _wpsc_fix_azerbaijani_manat() {
248
- $country = new WPSC_Country( array(
249
- 'isocode' => 'AZ',
250
  'currency' => __('Azerbaijani Manat', 'wpsc'),
251
  'code' => 'AZN',
252
  'symbol' => _x( 'm', 'azerbaijani manat symbol', 'wpsc' ),
253
  'symbol_html' => _x( 'm', 'azerbaijani manat symbol html', 'wpsc' ),
254
  ) );
 
255
  }
256
 
257
  function _wpsc_fix_cyprus_currency() {
258
- $country = new WPSC_Country( array(
259
- 'isocode' => 'CY',
260
  'currency' => __( 'Euro', 'wpsc' ),
261
  'symbol' => __( '€', 'wpsc' ),
262
  'symbol_html' => __( '&#8364;', 'wpsc' ),
263
  'code' => __( 'EUR', 'wpsc' ),
264
  ) );
 
265
  }
266
 
267
  function _wpsc_fix_republic_of_the_congo() {
268
- $country = new WPSC_Country( array(
269
- 'isocode' => 'CG',
270
  'country' => __( 'Republic of the Congo', 'wpsc' ),
271
  ) );
 
272
  }
273
 
274
  function _wpsc_fix_currency_el_salvador() {
275
- $country = new WPSC_Country( array(
276
- 'isocode' => 'SV',
277
  'currency' => __( 'US Dollar', 'wpsc' ),
278
  'symbol' => __( '$', 'wpsc' ),
279
  'symbol_html' => __( '&#036', 'wpsc' ),
280
  'code' => 'USD',
281
  ) );
 
282
  }
283
 
284
  function _wpsc_fix_ghanaian_currency_code() {
285
- $country = new WPSC_Country( array(
286
- 'isocode' => 'GH',
287
  'code' => 'GHS',
288
  ) );
 
289
  }
290
 
291
  function _wpsc_fix_guatemala_currency() {
292
- $country = new WPSC_Country( array(
293
- 'isocode' => 'GT',
294
  'code' => 'GTQ',
295
  ) );
 
296
  }
297
 
298
  function _wpsc_fix_guinea_bissau_currency() {
299
- $country = new WPSC_Country( array(
300
- 'isocode' => 'GW',
301
  'currency' => __( 'CFA Franc BEAC', 'wpsc' ),
302
  'code' => __('XAF', 'wpsc'),
303
  ) );
 
304
  }
305
 
306
  function _wpsc_fix_madagascar_currency() {
307
- $country = new WPSC_Country( array(
308
- 'isocode' => 'MG',
309
  'currency' => __( 'Malagasy Ariary', 'wpsc' ),
310
  'code' => __( 'MGA', 'wpsc' ),
311
  ) );
 
312
  }
313
 
314
  function _wpsc_fix_malta_currency() {
315
- $country = new WPSC_Country( array(
316
- 'isocode' => 'MT',
317
  'currency' => __( 'Euro', 'wpsc' ),
318
  'symbol' => __( '€', 'wpsc' ),
319
  'symbol_html' => __( '&#8364;', 'wpsc' ),
320
  'code' => __( 'EUR', 'wpsc' ),
321
  ) );
 
322
  }
323
 
324
  function _wpsc_fix_mozambique_currency() {
325
- $country = new WPSC_Country( array(
326
- 'isocode' => 'MZ',
327
- 'code' => __( 'MZN', 'wpsc' )
328
- ) );
329
  }
330
 
331
  function _wpsc_fix_nicaragua_currency() {
332
- $country = new WPSC_Country( array(
333
- 'isocode' => 'NI',
334
- 'code' => __( 'NIO', 'wpsc' )
335
- ) );
336
  }
337
 
338
  function _wpsc_fix_romania_currency() {
339
- $country = new WPSC_Country( array(
340
- 'isocode' => 'RO',
341
- 'currency' => __( 'Romanian New Leu', 'wpsc' )
342
- ) );
343
  }
344
 
345
  function _wpsc_fix_san_marino_currency() {
346
- $country = new WPSC_Country( array(
347
- 'isocode' => 'SM',
348
  'currency' => __( 'Euro', 'wpsc' ),
349
  'symbol' => __( '€', 'wpsc' ),
350
  'symbol_html' => __( '&#8364;', 'wpsc' ),
351
  'code' => __( 'EUR', 'wpsc' ),
352
  ) );
 
353
  }
354
 
355
  function _wpsc_fix_somalia_currency() {
356
- $country = new WPSC_Country( array(
357
- 'isocode' => 'SO',
358
- 'code' => __( 'SOS', 'wpsc' )
359
- ) );
360
  }
361
 
362
  function _wpsc_fix_suriname_currency() {
363
- $country = new WPSC_Country( array(
364
- 'isocode' => 'SR',
365
  'currency' => __( 'Surinamese Dollar', 'wpsc' ),
366
  'code' => __( 'SRD', 'wpsc' ),
367
  ) );
 
368
  }
369
 
370
  function _wpsc_fix_taiwan_currency() {
371
- $country = new WPSC_Country( array(
372
- 'isocode' => 'TW',
373
- 'currency' => __( 'New Taiwanese Dollar', 'wpsc' )
374
- ) );
375
  }
376
 
377
  function _wpsc_fix_tajikistan_currency() {
378
- $country = new WPSC_Country( array(
379
- 'isocode' => 'TJ',
380
  'currency' => __( 'Tajikistan Somoni', 'wpsc' ),
381
  'code' => __( 'TJS', 'wpsc' ),
382
  ) );
 
383
  }
384
 
385
  function _wpsc_fix_tunisia_currency() {
386
- $country = new WPSC_Country( array(
387
- 'isocode' => 'TN',
388
- 'currency' => __( 'Tunisian Dollar', 'wpsc' )
389
- ) );
390
  }
391
 
392
  function _wpsc_fix_turkey_currency() {
393
- $country = new WPSC_Country( array(
394
- 'isocode' => 'TR',
395
- 'code' => __( 'TRY', 'wpsc' )
396
- ) );
397
  }
398
 
399
  function _wpsc_fix_uganda_currency() {
400
- $country = new WPSC_Country( array(
401
- 'isocode' => 'UG',
402
- 'code' => __( 'UGX', 'wpsc' )
403
- ) );
404
  }
405
 
406
  function _wpsc_fix_uruguay_currency() {
407
- $country = new WPSC_Country( array(
408
- 'isocode' => 'UY',
409
- 'code' => __( 'UYU', 'wpsc' )
410
- ) );
411
  }
412
 
413
  function _wpsc_fix_venezuela_currency() {
414
- $country = new WPSC_Country( array(
415
- 'isocode' => 'VE',
416
  'currency' => __( 'Venezuelan Bolivar Fuerte', 'wpsc' ),
417
  'code' => __( 'VEF', 'wpsc' ),
418
  ) );
 
419
  }
420
 
421
  function _wpsc_fix_zimbabwe_currency() {
422
- $country = new WPSC_Country( array(
423
- 'isocode' => 'ZW',
424
  'currency' => __( 'US Dollar', 'wpsc' ),
425
  'symbol' => __( '$', 'wpsc' ),
426
  'symbol_html' => __( '&#036', 'wpsc' ),
427
  'code' => 'USD',
428
  'continent' => 'asiapacific',
429
  ) );
 
430
  }
44
  }
45
 
46
  function _wpsc_fix_UK_country_code() {
47
+ $country = new WPSC_Country( 'GB', 'isocode' );
48
+ $country->set( 'country', __( 'United Kingdom', 'wpsc' ) );
49
+ $country->save();
 
50
  }
51
 
52
  function _wpsc_fix_guernsey_country_code() {
53
+ $country = new WPSC_Country( 'GF', 'isocode' );
54
+ $country->set( 'isocode', 'GG' );
55
+ $country->save();
56
  }
57
 
58
  function _wpsc_new_country_serbia() {
65
  'continent' => 'europe',
66
  'visible' => '0',
67
  ) );
68
+ $country->save();
69
  }
70
 
71
  function _wpsc_new_country_montenegro() {
80
  'continent' => 'europe',
81
  'visible' => '0',
82
  ) );
83
+ $country->save();
84
  }
85
 
86
  function _wpsc_fix_timor_leste_name() {
95
  'continent' => 'asiapacific',
96
  'visible' => '0',
97
  ) );
98
+ $country->save();
99
  }
100
 
101
  function _wpsc_new_country_aland_islands() {
110
  'continent' => 'europe',
111
  'visible' => '0',
112
  ) );
113
+ $country->save();
114
  }
115
 
116
  function _wpsc_new_country_saint_barthelemy() {
125
  'continent' => 'europe',
126
  'visible' => '0',
127
  ) );
128
+ $country->save();
129
  }
130
 
131
  function _wpsc_new_country_bonaire_et_al() {
140
  'continent' => 'southamerica',
141
  'visible' => '0',
142
  ) );
143
+ $country->save();
144
  }
145
 
146
  function _wpsc_new_country_curacao() {
155
  'continent' => 'southamerica',
156
  'visible' => '0',
157
  ) );
158
+ $country->save();
159
  }
160
 
161
  function _wpsc_new_country_saint_martin_french() {
170
  'continent' => 'southamerica',
171
  'visible' => '0',
172
  ) );
173
+ $country->save();
174
  }
175
 
176
  function _wpsc_new_country_palestinian_territories() {
185
  'continent' => 'asiapacific',
186
  'visible' => '0',
187
  ) );
188
+ $country->save();
189
  }
190
 
191
  function _wpsc_update_israeli_new_shekel_symbol() {
192
+ $country = new WPSC_Country( 'IL', 'isocode' );
193
+ $country->set( array(
194
  'symbol' => __( '₪', 'wpsc' ),
195
  'symbol_html' => __( '&#8362;', 'wpsc' ),
196
  ) );
197
+ $country->save();
198
  }
199
 
200
  function _wpsc_new_country_sint_maarten_dutch() {
209
  'continent' => 'southamerica',
210
  'visible' => '0',
211
  ) );
212
+ $country->save();
213
  }
214
 
215
  function _wpsc_new_country_french_guiana() {
224
  'continent' => 'southamerica',
225
  'visible' => '0',
226
  ) );
227
+ $country->save();
228
  }
229
 
230
  function _wpsc_fix_netherlands_antille() {
231
+ $country = new WPSC_Country( 'AN', 'isocode' );
232
+ $country->set( array(
233
  'symbol' => __( 'ƒ', 'wpsc' ),
234
  'symbol_html' => __( '&#402;', 'wpsc' ),
235
  'continent' => 'southamerica',
236
  ) );
237
+ $country->save();
238
  }
239
 
240
  function _wpsc_fix_angola_kwanza() {
241
+ $country = new WPSC_Country( 'AO', 'isocode' );
242
+ $country->set( array(
243
  'code' => 'AOA',
244
  'currency' => __( 'Angolan Kwanza', 'wpsc' ),
245
  'symbol' => __( 'Kz', 'wpsc' ),
246
  'symbol_html' => __( 'Kz', 'wpsc' ),
247
  ) );
248
+ $country->save();
249
  }
250
 
251
  function _wpsc_fix_aruban_florin() {
252
+ $country = new WPSC_Country( 'AW', 'isocode' );
253
+ $country->set( array(
254
  'currency' => __( 'Aruban Florin', 'wpsc' ),
255
  'symbol' => __( 'Afl.', 'wpsc' ),
256
  'symbol_html' => __( 'Afl.', 'wpsc' ),
257
  ) );
258
+ $country->save();
259
  }
260
 
261
  function _wpsc_fix_azerbaijani_manat() {
262
+ $country = new WPSC_Country( 'AZ', 'isocode' );
263
+ $country->set( array(
264
  'currency' => __('Azerbaijani Manat', 'wpsc'),
265
  'code' => 'AZN',
266
  'symbol' => _x( 'm', 'azerbaijani manat symbol', 'wpsc' ),
267
  'symbol_html' => _x( 'm', 'azerbaijani manat symbol html', 'wpsc' ),
268
  ) );
269
+ $country->save();
270
  }
271
 
272
  function _wpsc_fix_cyprus_currency() {
273
+ $country = new WPSC_Country( 'CY', 'isocode' );
274
+ $country->set( array(
275
  'currency' => __( 'Euro', 'wpsc' ),
276
  'symbol' => __( '€', 'wpsc' ),
277
  'symbol_html' => __( '&#8364;', 'wpsc' ),
278
  'code' => __( 'EUR', 'wpsc' ),
279
  ) );
280
+ $country->save();
281
  }
282
 
283
  function _wpsc_fix_republic_of_the_congo() {
284
+ $country = new WPSC_Country( 'CG', 'isocode' );
285
+ $country->set( array(
286
  'country' => __( 'Republic of the Congo', 'wpsc' ),
287
  ) );
288
+ $country->save();
289
  }
290
 
291
  function _wpsc_fix_currency_el_salvador() {
292
+ $country = new WPSC_Country( 'SV', 'isocode' );
293
+ $country->set( array(
294
  'currency' => __( 'US Dollar', 'wpsc' ),
295
  'symbol' => __( '$', 'wpsc' ),
296
  'symbol_html' => __( '&#036', 'wpsc' ),
297
  'code' => 'USD',
298
  ) );
299
+ $country->save();
300
  }
301
 
302
  function _wpsc_fix_ghanaian_currency_code() {
303
+ $country = new WPSC_Country( 'GH', 'isocode' );
304
+ $country->set( array(
305
  'code' => 'GHS',
306
  ) );
307
+ $country->save();
308
  }
309
 
310
  function _wpsc_fix_guatemala_currency() {
311
+ $country = new WPSC_Country( 'GT', 'isocode' );
312
+ $country->set( array(
313
  'code' => 'GTQ',
314
  ) );
315
+ $country->save();
316
  }
317
 
318
  function _wpsc_fix_guinea_bissau_currency() {
319
+ $country = new WPSC_Country( 'GW', 'isocode' );
320
+ $country->set( array(
321
  'currency' => __( 'CFA Franc BEAC', 'wpsc' ),
322
  'code' => __('XAF', 'wpsc'),
323
  ) );
324
+ $country->save();
325
  }
326
 
327
  function _wpsc_fix_madagascar_currency() {
328
+ $country = new WPSC_Country( 'MG', 'isocode' );
329
+ $country->set( array(
330
  'currency' => __( 'Malagasy Ariary', 'wpsc' ),
331
  'code' => __( 'MGA', 'wpsc' ),
332
  ) );
333
+ $country->save();
334
  }
335
 
336
  function _wpsc_fix_malta_currency() {
337
+ $country = new WPSC_Country( 'MT', 'isocode' );
338
+ $country->set( array(
339
  'currency' => __( 'Euro', 'wpsc' ),
340
  'symbol' => __( '€', 'wpsc' ),
341
  'symbol_html' => __( '&#8364;', 'wpsc' ),
342
  'code' => __( 'EUR', 'wpsc' ),
343
  ) );
344
+ $country->save();
345
  }
346
 
347
  function _wpsc_fix_mozambique_currency() {
348
+ $country = new WPSC_Country( 'MZ', 'isocode' );
349
+ $country->set( 'code', __( 'MZN', 'wpsc' ) );
350
+ $country->save();
 
351
  }
352
 
353
  function _wpsc_fix_nicaragua_currency() {
354
+ $country = new WPSC_Country( 'NI', 'isocode' );
355
+ $country->set( 'code', __( 'NIO', 'wpsc' ) );
356
+ $country->save();
 
357
  }
358
 
359
  function _wpsc_fix_romania_currency() {
360
+ $country = new WPSC_Country( 'RO', 'isocode' );
361
+ $country->set( 'currency', __( 'Romanian New Leu', 'wpsc' ) );
362
+ $country->save();
 
363
  }
364
 
365
  function _wpsc_fix_san_marino_currency() {
366
+ $country = new WPSC_Country( 'SM', 'isocode' );
367
+ $country->set( array(
368
  'currency' => __( 'Euro', 'wpsc' ),
369
  'symbol' => __( '€', 'wpsc' ),
370
  'symbol_html' => __( '&#8364;', 'wpsc' ),
371
  'code' => __( 'EUR', 'wpsc' ),
372
  ) );
373
+ $country->save();
374
  }
375
 
376
  function _wpsc_fix_somalia_currency() {
377
+ $country = new WPSC_Country( 'SO', 'isocode' );
378
+ $country->set( 'code', __( 'SOS', 'wpsc' ) );
379
+ $country->save();
 
380
  }
381
 
382
  function _wpsc_fix_suriname_currency() {
383
+ $country = new WPSC_Country( 'SR', 'isocode' );
384
+ $country->set( array(
385
  'currency' => __( 'Surinamese Dollar', 'wpsc' ),
386
  'code' => __( 'SRD', 'wpsc' ),
387
  ) );
388
+ $country->save();
389
  }
390
 
391
  function _wpsc_fix_taiwan_currency() {
392
+ $country = new WPSC_Country( 'TW', 'isocode' );
393
+ $country->set( 'currency', __( 'New Taiwanese Dollar', 'wpsc' ) );
394
+ $country->save();
 
395
  }
396
 
397
  function _wpsc_fix_tajikistan_currency() {
398
+ $country = new WPSC_Country( 'TJ', 'isocode' );
399
+ $country->set( array(
400
  'currency' => __( 'Tajikistan Somoni', 'wpsc' ),
401
  'code' => __( 'TJS', 'wpsc' ),
402
  ) );
403
+ $country->save();
404
  }
405
 
406
  function _wpsc_fix_tunisia_currency() {
407
+ $country = new WPSC_Country( 'TN', 'isocode' );
408
+ $country->set( 'currency', __( 'Tunisian Dollar', 'wpsc' ) );
409
+ $country->save();
 
410
  }
411
 
412
  function _wpsc_fix_turkey_currency() {
413
+ $country = new WPSC_Country( 'TR', 'isocode' );
414
+ $country->set( 'code', __( 'TRY', 'wpsc' ) );
415
+ $country->save();
 
416
  }
417
 
418
  function _wpsc_fix_uganda_currency() {
419
+ $country = new WPSC_Country( 'UG', 'isocode' );
420
+ $country->set( 'code', __( 'UGX', 'wpsc' ) );
421
+ $country->save();
 
422
  }
423
 
424
  function _wpsc_fix_uruguay_currency() {
425
+ $country = new WPSC_Country( 'UY', 'isocode' );
426
+ $country->set( 'code', __( 'UYU', 'wpsc' ) );
427
+ $country->save();
 
428
  }
429
 
430
  function _wpsc_fix_venezuela_currency() {
431
+ $country = new WPSC_Country( 'VE', 'isocode' );
432
+ $country->set( array(
433
  'currency' => __( 'Venezuelan Bolivar Fuerte', 'wpsc' ),
434
  'code' => __( 'VEF', 'wpsc' ),
435
  ) );
436
+ $country->save();
437
  }
438
 
439
  function _wpsc_fix_zimbabwe_currency() {
440
+ $country = new WPSC_Country( 'ZW', 'isocode' );
441
+ $country->set( array(
442
  'currency' => __( 'US Dollar', 'wpsc' ),
443
  'symbol' => __( '$', 'wpsc' ),
444
  'symbol_html' => __( '&#036', 'wpsc' ),
445
  'code' => 'USD',
446
  'continent' => 'asiapacific',
447
  ) );
448
+ $country->save();
449
  }
wpsc-admin/db-upgrades/routines/3.php CHANGED
@@ -5,14 +5,18 @@ function _wpsc_db_upgrade_3() {
5
  }
6
 
7
  function _wpsc_maybe_create_UK() {
8
- $country = new WPSC_Country( array(
9
- 'isocode' => 'GB',
10
- 'id' => 138,
11
- 'country' => __( 'United Kingdom', 'wpsc' ),
12
- 'currency' => __( 'Pound Sterling', 'wpsc' ),
13
- 'symbol' => __( '£', 'wpsc' ),
14
- 'symbol_html' => __( '&#163;', 'wpsc' ),
15
- 'code' => __( 'GBP', 'wpsc' ),
16
- 'continent' => 'europe',
17
- ) );
 
 
 
 
18
  }
5
  }
6
 
7
  function _wpsc_maybe_create_UK() {
8
+ $country = new WPSC_Country( 'GB', 'isocode' );
9
+ if ( ! $country->exists() ) {
10
+ $country->set( array(
11
+ 'id' => 138,
12
+ 'country' => __( 'United Kingdom', 'wpsc' ),
13
+ 'currency' => __( 'Pound Sterling', 'wpsc' ),
14
+ 'symbol' => __( '£', 'wpsc' ),
15
+ 'symbol_html' => __( '&#163;', 'wpsc' ),
16
+ 'code' => __( 'GBP', 'wpsc' ),
17
+ 'continent' => 'europe',
18
+ ) );
19
+
20
+ $country->save();
21
+ }
22
  }
wpsc-admin/db-upgrades/routines/6.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
- require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-init.php' );
3
 
4
  function _wpsc_db_upgrade_6() {
5
  _wpsc_maybe_create_meta_tables();
1
  <?php
 
2
 
3
  function _wpsc_db_upgrade_6() {
4
  _wpsc_maybe_create_meta_tables();
wpsc-admin/db-upgrades/routines/8.php CHANGED
@@ -5,8 +5,9 @@ function _wpsc_db_upgrade_8() {
5
  }
6
 
7
  function _wpsc_fix_bulgaria_currency() {
8
- $country = new WPSC_Country( array(
9
- 'isocode' => 'BG',
10
  'code' => __( 'BGN', 'wpsc' ),
11
  ) );
 
12
  }
5
  }
6
 
7
  function _wpsc_fix_bulgaria_currency() {
8
+ $country = new WPSC_Country( 'BG', 'isocode' );
9
+ $country->set( array(
10
  'code' => __( 'BGN', 'wpsc' ),
11
  ) );
12
+ $country->save();
13
  }
wpsc-admin/db-upgrades/routines/9.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-init.php' );
4
-
5
- function _wpsc_db_upgrade_9() {
6
- _wpsc_maybe_create_purchase_meta_tables();
7
- }
8
-
9
- function _wpsc_maybe_create_purchase_meta_tables() {
10
-
11
- _wpsc_create_purchase_meta_table();
12
- _wpsc_meta_migrate_wpsc_purchase();
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/upgrade.php CHANGED
@@ -19,7 +19,7 @@ function _wpsc_maybe_upgrade() {
19
  if ( ! _wpsc_needs_upgrade() )
20
  return;
21
 
22
- for ( $i = $current_db_ver + 1; $i <= WPSC_DB_VERSION; $i++ ) {
23
  $file_path = WPSC_FILE_PATH . '/wpsc-admin/db-upgrades/routines/' . $i . '.php';
24
 
25
  if ( file_exists( $file_path ) )
@@ -28,24 +28,18 @@ function _wpsc_maybe_upgrade() {
28
  if ( ! function_exists( '_wpsc_db_upgrade_' . $i ) )
29
  continue;
30
 
31
- wpsc_core_flush_temporary_data();
32
-
33
  call_user_func( '_wpsc_db_upgrade_' . $i );
34
  update_option( 'wpsc_db_version', $i );
35
-
36
  }
37
-
38
- wpsc_core_flush_temporary_data();
39
-
40
  }
41
 
42
  function _wpsc_upgrade_display_backup_warning() {
43
- $message = __( '<strong>Important:</strong> Before proceeding with the database upgrade, <a href="%1$s">please backup your database and files</a>.<br>We recommend using <a href="%2$s">VaultPress</a> or <a href="%3$s">BackupBuddy</a> to regularly backup your WordPress installation.', 'wpsc' );
44
  $message = sprintf(
45
  $message,
46
  'http://codex.wordpress.org/WordPress_Backups',
47
  'http://vaultpress.com/',
48
- 'http://ithemes.com/member/go.php?r=45982&i=l44'
49
  );
50
  ?>
51
  <div id="wpsc-upgrade-warning" class="updated">
@@ -55,7 +49,7 @@ function _wpsc_upgrade_display_backup_warning() {
55
  }
56
 
57
  function _wpsc_upgrade_display_prompt() {
58
- $message = __( '<strong>WP eCommerce %1$s is almost ready.</strong> Some database routines need to be run before the upgrade is complete. <a href="%2$s">Click here to start!</a>');
59
  $message = sprintf( $message, WPSC_VERSION, admin_url( '?page=wpsc-db-upgrade' ) );
60
  ?>
61
  <div id="wpsc-upgrade-warning" class="error">
@@ -65,7 +59,7 @@ function _wpsc_upgrade_display_prompt() {
65
  }
66
 
67
  function _wpsc_upgrade_display_successful() {
68
- $message = __( 'WP eCommerce has been successfully updated to %s. Enjoy!', 'wpsc' );
69
  $message = sprintf( $message, WPSC_VERSION );
70
  ?>
71
  <div id="wpsc-upgrade-warning" class="updated">
@@ -75,13 +69,12 @@ function _wpsc_upgrade_display_successful() {
75
  }
76
 
77
  function _wpsc_action_admin_notices_db_upgrade() {
78
- if ( ! empty( $_GET['wpsc_db_upgrade_successful'] ) ) {
79
  _wpsc_upgrade_display_successful();
80
- } elseif ( _wpsc_is_db_upgrade_page() ) {
81
  _wpsc_upgrade_display_backup_warning();
82
- } elseif ( _wpsc_needs_upgrade() ) {
83
  _wpsc_upgrade_display_prompt();
84
- }
85
  }
86
  add_action( 'admin_notices', '_wpsc_action_admin_notices_db_upgrade' );
87
 
@@ -150,6 +143,6 @@ function _wpsc_action_load_db_upgrade() {
150
  }
151
 
152
  function _wpsc_callback_display_db_upgrade_page() {
153
- $update_title = sprintf( __( 'Your database needs to be upgraded before you can use WP eCommerce %s', 'wpsc' ), WPSC_VERSION );
154
  include( 'views/main.php' );
155
- }
19
  if ( ! _wpsc_needs_upgrade() )
20
  return;
21
 
22
+ for ( $i = $current_db_ver + 1; $i <= WPSC_DB_VERSION; $i ++ ) {
23
  $file_path = WPSC_FILE_PATH . '/wpsc-admin/db-upgrades/routines/' . $i . '.php';
24
 
25
  if ( file_exists( $file_path ) )
28
  if ( ! function_exists( '_wpsc_db_upgrade_' . $i ) )
29
  continue;
30
 
 
 
31
  call_user_func( '_wpsc_db_upgrade_' . $i );
32
  update_option( 'wpsc_db_version', $i );
 
33
  }
 
 
 
34
  }
35
 
36
  function _wpsc_upgrade_display_backup_warning() {
37
+ $message = __( '<strong>Important:</strong> Before proceeding with the database upgrade, <a href="%1$s">please backup your database and files</a>.<br>We recommend using <a href="%2$s">VaultPress</a> or <a href="%3$s">Backup Buddy</a> to regularly backup your WordPress installation.', 'wpsc' );
38
  $message = sprintf(
39
  $message,
40
  'http://codex.wordpress.org/WordPress_Backups',
41
  'http://vaultpress.com/',
42
+ 'http://ithemes.com/purchase/backupbuddy/'
43
  );
44
  ?>
45
  <div id="wpsc-upgrade-warning" class="updated">
49
  }
50
 
51
  function _wpsc_upgrade_display_prompt() {
52
+ $message = __( '<strong>WP e-Commerce %1$s is almost ready.</strong> Some database routines need to be run before the upgrade is complete. <a href="%2$s">Click here to start!</a>');
53
  $message = sprintf( $message, WPSC_VERSION, admin_url( '?page=wpsc-db-upgrade' ) );
54
  ?>
55
  <div id="wpsc-upgrade-warning" class="error">
59
  }
60
 
61
  function _wpsc_upgrade_display_successful() {
62
+ $message = __( 'WP e-Commerce has been successfully updated to %s. Enjoy!', 'wpsc' );
63
  $message = sprintf( $message, WPSC_VERSION );
64
  ?>
65
  <div id="wpsc-upgrade-warning" class="updated">
69
  }
70
 
71
  function _wpsc_action_admin_notices_db_upgrade() {
72
+ if ( ! empty( $_GET['wpsc_db_upgrade_successful'] ) )
73
  _wpsc_upgrade_display_successful();
74
+ elseif ( _wpsc_is_db_upgrade_page() )
75
  _wpsc_upgrade_display_backup_warning();
76
+ elseif ( _wpsc_needs_upgrade() )
77
  _wpsc_upgrade_display_prompt();
 
78
  }
79
  add_action( 'admin_notices', '_wpsc_action_admin_notices_db_upgrade' );
80
 
143
  }
144
 
145
  function _wpsc_callback_display_db_upgrade_page() {
146
+ $update_title = sprintf( __( 'Your database needs to be upgraded before you can use WP e-Commerce %s', 'wpsc' ), WPSC_VERSION );
147
  include( 'views/main.php' );
148
+ }
wpsc-admin/db-upgrades/views/main.php CHANGED
@@ -1,6 +1,6 @@
1
  <div class="wrap">
2
  <div id="icon-tools" class="icon32"><br></div>
3
- <h2><?php esc_html_e( 'WP eCommerce Database Upgrade', 'wpsc' ); ?></h2>
4
  <form class="wpsc-db-upgrade" action="" method="post">
5
  <h3><?php echo esc_html( $update_title ); ?></h3>
6
  <p><?php esc_html_e( 'Click "Start Database Upgrade" when you are ready.', 'wpsc' ); ?></p>
1
  <div class="wrap">
2
  <div id="icon-tools" class="icon32"><br></div>
3
+ <h2><?php esc_html_e( 'WP e-Commerce Database Upgrade', 'wpsc' ); ?></h2>
4
  <form class="wpsc-db-upgrade" action="" method="post">
5
  <h3><?php echo esc_html( $update_title ); ?></h3>
6
  <p><?php esc_html_e( 'Click "Start Database Upgrade" when you are ready.', 'wpsc' ); ?></p>
wpsc-admin/display-coupon-add.php CHANGED
@@ -1,12 +1,10 @@
1
- <div class="wrap" id="coupon_data">
2
  <div id="add_coupon_box">
3
  <h2><?php _e( 'Add Coupon', 'wpsc' ); ?></h2>
4
  <form name='add_coupon' method="post" action="<?php echo admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
5
  <table class="form-table">
6
  <tbody>
7
 
8
- <?php do_action( 'wpsc_coupon_add_top' ); ?>
9
-
10
  <tr class="form-field">
11
  <th scope="row" valign="top">
12
  <label for="add_coupon_code"><?php _e( 'Coupon Code', 'wpsc' ); ?></label>
@@ -22,8 +20,8 @@
22
  <label for="add-coupon-code"><?php _e( 'Discount', 'wpsc' ); ?></label>
23
  </th>
24
  <td>
25
- <input name="add_discount" step=".01" id="add-coupon-code" type="number" class="small-text" min="0" style="width: 300px" />
26
- <p class="description"><?php _e( 'The discount amount', 'wpsc' ); ?></p>
27
  </td>
28
  </tr>
29
 
@@ -50,7 +48,6 @@
50
  <input name="add_start" id="add_start" type="text" class="regular-text pickdate" style="width: 100px"/>
51
  <span class="description"><?php _e( 'End: ', 'wpsc' ); ?></span>
52
  <input name="add_end" id="add_end" type="text" class="regular-text pickdate" style="width: 100px"/>
53
- <p class="description"><?php _e( 'If date fields are left empty, there will be no expiration on this coupon.', 'wpsc' ); ?></p>
54
  </td>
55
  </tr>
56
 
@@ -121,11 +118,9 @@
121
  </td>
122
  </tr>
123
 
124
- <?php do_action( 'wpsc_coupon_add_bottom' ); ?>
125
-
126
  </tbody>
127
  </table>
128
- <?php wp_nonce_field( 'wpsc_coupon', 'wpsc-coupon-add' ); ?>
129
  <?php submit_button( __( 'Add Coupon', 'wpsc' ), 'primary', 'add_coupon' ); ?>
130
 
131
  </form>
1
+ <div class="wrap" id+"coupon_data">
2
  <div id="add_coupon_box">
3
  <h2><?php _e( 'Add Coupon', 'wpsc' ); ?></h2>
4
  <form name='add_coupon' method="post" action="<?php echo admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
5
  <table class="form-table">
6
  <tbody>
7
 
 
 
8
  <tr class="form-field">
9
  <th scope="row" valign="top">
10
  <label for="add_coupon_code"><?php _e( 'Coupon Code', 'wpsc' ); ?></label>
20
  <label for="add-coupon-code"><?php _e( 'Discount', 'wpsc' ); ?></label>
21
  </th>
22
  <td>
23
+ <input name="add_discount" id="add-coupon-code" type="number" class="small-text" min="0" />
24
+ <span class="description"><?php _e( 'The discount amount', 'wpsc' ); ?></span>
25
  </td>
26
  </tr>
27
 
48
  <input name="add_start" id="add_start" type="text" class="regular-text pickdate" style="width: 100px"/>
49
  <span class="description"><?php _e( 'End: ', 'wpsc' ); ?></span>
50
  <input name="add_end" id="add_end" type="text" class="regular-text pickdate" style="width: 100px"/>
 
51
  </td>
52
  </tr>
53
 
118
  </td>
119
  </tr>
120
 
 
 
121
  </tbody>
122
  </table>
123
+
124
  <?php submit_button( __( 'Add Coupon', 'wpsc' ), 'primary', 'add_coupon' ); ?>
125
 
126
  </form>
wpsc-admin/display-coupon-edit.php CHANGED
@@ -22,8 +22,6 @@ $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUP
22
  <table class="form-table">
23
  <tbody>
24
 
25
- <?php do_action( 'wpsc_coupon_edit_top', $coupon_id, $coupon ); ?>
26
-
27
  <tr class="form-field">
28
  <th scope="row" valign="top">
29
  <label for="edit_coupon_code"><?php _e( 'Coupon Code', 'wpsc' ); ?></label>
@@ -39,8 +37,8 @@ $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUP
39
  <label for="edit_coupon_amount"><?php _e( 'Discount', 'wpsc' ); ?></label>
40
  </th>
41
  <td>
42
- <input name="edit_coupon_amount" id="edit_coupon_amount" type="number" step=".01" value="<?php esc_attr_e( $coupon['value'] ); ?>" class="small-text" min="0" style="width: 300px" />
43
- <p class="description"><?php _e( 'The discount amount', 'wpsc' ); ?></p>
44
  </td>
45
  </tr>
46
 
@@ -67,14 +65,13 @@ $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUP
67
  </th>
68
  <td>
69
  <?php
70
- $start = $coupon['start'] == '0000-00-00 00:00:00' ? '' : get_date_from_gmt( $coupon['start'], 'Y-m-d' );
71
- $end = $coupon['expiry'] == '0000-00-00 00:00:00' ? '' : get_date_from_gmt( $coupon['expiry'], 'Y-m-d' );
72
  ?>
73
  <span class="description"><?php _e( 'Start: ', 'wpsc' ); ?></span>
74
  <input name="edit_coupon_start" id="edit_coupon_start" type="text" value="<?php esc_attr_e( $start ); ?>" class="regular-text pickdate" style="width: 100px"/>
75
  <span class="description"><?php _e( 'End: ', 'wpsc' ); ?></span>
76
  <input name="edit_coupon_end" id="edit_coupon_end" type="text" value="<?php esc_attr_e( $end ); ?>" class="regular-text pickdate" style="width: 100px"/>
77
- <p class="description"><?php _e( 'If date fields are left empty, there will be no expiration on this coupon.', 'wpsc' ); ?></p>
78
  </td>
79
  </tr>
80
 
@@ -144,7 +141,7 @@ $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUP
144
  <option value="item_quantity"<?php selected( 'item_quantity', $condition['property'] ); ?> rel="order"><?php _e( 'Item quantity', 'wpsc' ); ?></option>
145
  <option value="total_quantity"<?php selected( 'total_quantity', $condition['property'] ); ?> rel="order"><?php _e( 'Total quantity', 'wpsc' ); ?></option>
146
  <option value="subtotal_amount"<?php selected( 'subtotal_amount', $condition['property'] ); ?> rel="order"><?php _e( 'Subtotal amount', 'wpsc' ); ?></option>
147
- <?php do_action( 'wpsc_coupon_rule_property_options', $condition['property'] ); ?>
148
  </select>
149
 
150
  <select name="rules[logic][]">
@@ -166,15 +163,11 @@ $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUP
166
  </td>
167
  </tr>
168
 
169
- <?php do_action( 'wpsc_coupon_edit_top', $coupon_id, $coupon ); ?>
170
-
171
  </tbody>
172
  </table>
173
  <input type="hidden" name="coupon_id" value="<?php echo esc_attr( $coupon_id ); ?>"/>
174
  <input type="hidden" name="edit_coupon_is_used" value="<?php echo esc_attr( $coupon['is-used'] ); ?>"/>
175
- <input type="hidden" name="is_edit_coupon" value="true" />
176
-
177
- <?php wp_nonce_field( 'wpsc_coupon', 'wpsc-coupon-edit' ); ?>
178
  <?php submit_button( __( 'Update Coupon', 'wpsc' ), 'primary' ); ?>
179
 
180
  </form>
22
  <table class="form-table">
23
  <tbody>
24
 
 
 
25
  <tr class="form-field">
26
  <th scope="row" valign="top">
27
  <label for="edit_coupon_code"><?php _e( 'Coupon Code', 'wpsc' ); ?></label>
37
  <label for="edit_coupon_amount"><?php _e( 'Discount', 'wpsc' ); ?></label>
38
  </th>
39
  <td>
40
+ <input name="edit_coupon_amount" id="edit_coupon_amount" type="number" value="<?php esc_attr_e( $coupon['value'] ); ?>" class="small-text" min="0" />
41
+ <span class="description"><?php _e( 'The discount amount', 'wpsc' ); ?></span>
42
  </td>
43
  </tr>
44
 
65
  </th>
66
  <td>
67
  <?php
68
+ $start = $coupon['start'] == '0000-00-00 00:00:00' ? '' : get_date_from_gmt( $coupon['start'], 'Y-m-d' );
69
+ $end = $coupon['expiry'] == '0000-00-00 00:00:00' ? '' : get_date_from_gmt( $coupon['expiry'], 'Y-m-d' );
70
  ?>
71
  <span class="description"><?php _e( 'Start: ', 'wpsc' ); ?></span>
72
  <input name="edit_coupon_start" id="edit_coupon_start" type="text" value="<?php esc_attr_e( $start ); ?>" class="regular-text pickdate" style="width: 100px"/>
73
  <span class="description"><?php _e( 'End: ', 'wpsc' ); ?></span>
74
  <input name="edit_coupon_end" id="edit_coupon_end" type="text" value="<?php esc_attr_e( $end ); ?>" class="regular-text pickdate" style="width: 100px"/>
 
75
  </td>
76
  </tr>
77
 
141
  <option value="item_quantity"<?php selected( 'item_quantity', $condition['property'] ); ?> rel="order"><?php _e( 'Item quantity', 'wpsc' ); ?></option>
142
  <option value="total_quantity"<?php selected( 'total_quantity', $condition['property'] ); ?> rel="order"><?php _e( 'Total quantity', 'wpsc' ); ?></option>
143
  <option value="subtotal_amount"<?php selected( 'subtotal_amount', $condition['property'] ); ?> rel="order"><?php _e( 'Subtotal amount', 'wpsc' ); ?></option>
144
+ <?php do_action( 'wpsc_coupon_rule_property_options' ); ?>
145
  </select>
146
 
147
  <select name="rules[logic][]">
163
  </td>
164
  </tr>
165
 
 
 
166
  </tbody>
167
  </table>
168
  <input type="hidden" name="coupon_id" value="<?php echo esc_attr( $coupon_id ); ?>"/>
169
  <input type="hidden" name="edit_coupon_is_used" value="<?php echo esc_attr( $coupon['is-used'] ); ?>"/>
170
+ <input type="hidden" name="is_edit_coupon" value="true"/>
 
 
171
  <?php submit_button( __( 'Update Coupon', 'wpsc' ), 'primary' ); ?>
172
 
173
  </form>
wpsc-admin/display-coupons.php CHANGED
@@ -8,12 +8,10 @@ function wpsc_display_coupons_page() {
8
  * Update / create code that will be abstracted to its own class at some point
9
  */
10
 
11
- if ( isset( $_POST ) && is_array( $_POST ) && ! empty( $_POST ) ) {
12
 
13
  if ( isset( $_POST['add_coupon'] ) && (!isset( $_POST['is_edit_coupon'] ) || !($_POST['is_edit_coupon'] == 'true')) ) {
14
 
15
- check_admin_referer( 'wpsc_coupon', 'wpsc-coupon-add' );
16
-
17
  $coupon_code = $_POST['add_coupon_code'];
18
  $discount = (double)$_POST['add_discount'];
19
  $discount_type = (int)$_POST['add_discount_type'];
@@ -71,8 +69,6 @@ function wpsc_display_coupons_page() {
71
  // update an existing coupon
72
  if ( isset( $_POST['is_edit_coupon'] ) && ($_POST['is_edit_coupon'] == 'true') && !(isset( $_POST['delete_condition'] )) && !(isset( $_POST['submit_condition'] )) ) {
73
 
74
- check_admin_referer( 'wpsc_coupon', 'wpsc-coupon-edit' );
75
-
76
  $rules = isset( $_POST['rules'] ) ? $_POST['rules'] : array();
77
  $new_rules = array();
78
 
@@ -117,9 +113,8 @@ function wpsc_display_coupons_page() {
117
  array( '%d' )
118
  );
119
 
120
- if ( $update ) {
121
- echo "<div class='updated'><p>" . __( 'The coupon has been updated.', 'wpsc' ) . "</p></div>";
122
- }
123
  }
124
  }
125
 
@@ -140,9 +135,9 @@ function wpsc_display_coupons_page() {
140
  $coupons_table = new WPSC_Coupons_List_Table();
141
  $coupons_table->prepare_items(); ?>
142
  <div class="wrap">
143
- <h2><?php _e( 'Coupons', 'wpsc' ); ?><a href="<?php echo add_query_arg( 'wpsc-action', 'add_coupon' ); ?>" class="add-new-h2"><?php _e( 'Add Coupon', 'wpsc' ); ?></a></h2>
144
  <?php do_action( 'wpsc_coupons_page_top' ); ?>
145
- <form id="wpsc-coupons-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
146
 
147
  <input type="hidden" name="post_type" value="wpsc-product" />
148
  <input type="hidden" name="page" value="wpsc-edit-coupons" />
8
  * Update / create code that will be abstracted to its own class at some point
9
  */
10
 
11
+ if ( isset( $_POST ) && is_array( $_POST ) && !empty( $_POST ) ) {
12
 
13
  if ( isset( $_POST['add_coupon'] ) && (!isset( $_POST['is_edit_coupon'] ) || !($_POST['is_edit_coupon'] == 'true')) ) {
14
 
 
 
15
  $coupon_code = $_POST['add_coupon_code'];
16
  $discount = (double)$_POST['add_discount'];
17
  $discount_type = (int)$_POST['add_discount_type'];
69
  // update an existing coupon
70
  if ( isset( $_POST['is_edit_coupon'] ) && ($_POST['is_edit_coupon'] == 'true') && !(isset( $_POST['delete_condition'] )) && !(isset( $_POST['submit_condition'] )) ) {
71
 
 
 
72
  $rules = isset( $_POST['rules'] ) ? $_POST['rules'] : array();
73
  $new_rules = array();
74
 
113
  array( '%d' )
114
  );
115
 
116
+ if ( $update )
117
+ echo "<div class='updated'><p>" . __( 'The coupon has been updated.', 'wpsc' ) . "</p></div>";
 
118
  }
119
  }
120
 
135
  $coupons_table = new WPSC_Coupons_List_Table();
136
  $coupons_table->prepare_items(); ?>
137
  <div class="wrap">
138
+ <h2><?php _e( 'Coupons', 'wpsc' ); ?><a href="<?php echo esc_url( add_query_arg( 'wpsc-action', 'add_coupon' ) ); ?>" class="add-new-h2"><?php _e( 'Add Coupon', 'wpsc' ); ?></a></h2>
139
  <?php do_action( 'wpsc_coupons_page_top' ); ?>
140
+ <form id="wpsc-coupons-filter" method="get" action="<?php echo esc_url( admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ) ); ?>">
141
 
142
  <input type="hidden" name="post_type" value="wpsc-product" />
143
  <input type="hidden" name="page" value="wpsc-edit-coupons" />
wpsc-admin/display-debug.page.php CHANGED
@@ -46,11 +46,11 @@ function wpsc_debug_page() {
46
  <a href='<?php echo $fixpage; ?>'>Fix Purchaselogs</a>
47
  </li>
48
  <li>
49
- <a href='<?php echo wp_nonce_url("?wpsc_admin_action=update_page_urls"); ?>' ><?php _e('Update Page URLs', 'wpsc'); ?></a>
50
  </li>
51
  <li>
52
  <a href='<?php echo wp_nonce_url("?wpsc_admin_action=clean_categories"); ?>'><?php _e('Fix Product Group Permalinks', 'wpsc'); ?></a>
53
- </li>
54
  </ul>
55
  <?php
56
  if ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true) ) {
46
  <a href='<?php echo $fixpage; ?>'>Fix Purchaselogs</a>
47
  </li>
48
  <li>
49
+ <a href='<?php echo wp_nonce_url("?wpsc_admin_action=update_page_urls"); ?>' ><?php _e('Update Page URLs', 'wpsc'); ?></a>
50
  </li>
51
  <li>
52
  <a href='<?php echo wp_nonce_url("?wpsc_admin_action=clean_categories"); ?>'><?php _e('Fix Product Group Permalinks', 'wpsc'); ?></a>
53
+ </li>
54
  </ul>
55
  <?php
56
  if ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true) ) {
wpsc-admin/display-items.page.php CHANGED
@@ -11,6 +11,7 @@
11
 
12
  require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
13
 
 
14
  /**
15
  * wpsc_additional_column_names function.
16
  *
@@ -539,9 +540,7 @@ function wpsc_update_featured_products() {
539
  $status = array_values( $status );
540
  }
541
 
542
- $update = update_option( 'sticky_products', $status );
543
-
544
- do_action( 'wpsc_after_featured_product_update', $update, $status );
545
 
546
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
547
  $json_response = array(
11
 
12
  require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
13
 
14
+
15
  /**
16
  * wpsc_additional_column_names function.
17
  *
540
  $status = array_values( $status );
541
  }
542
 
543
+ update_option( 'sticky_products', $status );
 
 
544
 
545
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
546
  $json_response = array(
wpsc-admin/display-options-settings.page.php CHANGED
@@ -54,7 +54,7 @@ function wpsc_settings_page_update_notification() {
54
  if ( ! isset( $message ) )
55
  _e( 'Settings successfully updated.', 'wpsc' );
56
 
57
- $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'regenerate', 'skipped', 'updated', 'deleted', 'wpsc_downloadcsv', 'rss_key', 'start_timestamp', 'end_timestamp', 'email_buyer_id' ), $_SERVER['REQUEST_URI'] ); ?>
58
  </p></div>
59
 
60
  <?php
54
  if ( ! isset( $message ) )
55
  _e( 'Settings successfully updated.', 'wpsc' );
56
 
57
+ $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array( 'locked', 'regenerate', 'skipped', 'updated', 'deleted', 'wpsc_downloadcsv', 'rss_key', 'start_timestamp', 'end_timestamp', 'email_buyer_id' ), $_SERVER['REQUEST_URI'] ) ); ?>
58
  </p></div>
59
 
60
  <?php
wpsc-admin/display-sales-logs.php CHANGED
@@ -8,26 +8,19 @@
8
  * @since 3.8.8
9
  */
10
 
 
 
11
  class WPSC_Purchase_Log_Page {
12
  private $list_table;
13
  private $output;
14
- public $log_id = 0;
15
 
16
  public function __construct() {
17
  $controller = 'default';
18
  $controller_method = 'controller_default';
19
 
20
- // If individual purchase log, setup ID and action links.
21
- if ( isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) {
22
- $this->log_id = (int) $_REQUEST['id'];
23
- }
24
-
25
  if ( isset( $_REQUEST['c'] ) && method_exists( $this, 'controller_' . $_REQUEST['c'] ) ) {
26
  $controller = $_REQUEST['c'];
27
  $controller_method = 'controller_' . $controller;
28
- } elseif ( isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) {
29
- $controller = 'item_details';
30
- $controller_method = 'controller_item_details';
31
  }
32
 
33
  $this->$controller_method();
@@ -122,7 +115,7 @@ class WPSC_Purchase_Log_Page {
122
  <div class="wrap">
123
  <h2><?php echo esc_html( __('Sales', 'wpsc') ); ?> </h2>
124
  <div class="updated">
125
- <p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wpsc' ), remove_query_arg( 'c' ) ); ?></p>
126
  </div>
127
  </div>
128
  <?php
@@ -247,18 +240,17 @@ class WPSC_Purchase_Log_Page {
247
  <td class="amount"><?php echo wpsc_currency_display( wpsc_purchaselog_details_total() ); ?></td> <!-- TOTAL! -->
248
  </tr>
249
  <?php
250
- do_action( 'wpsc_additional_sales_item_info', wpsc_purchaselog_details_id() );
251
  endwhile;
252
  }
253
 
254
  public function controller_item_details() {
255
-
256
- if ( ! isset( $_REQUEST['id'] ) || ( isset( $_REQUEST['id'] ) && ! is_numeric( $_REQUEST['id'] ) ) ) {
257
- wp_die( __( 'Invalid sales log ID', 'wpsc' ) );
258
- }
259
 
260
  global $purchlogitem;
261
 
 
 
262
  // TODO: seriously get rid of all these badly coded purchaselogs.class.php functions in 4.0
263
  $purchlogitem = new wpsc_purchaselogs_items( $this->log_id );
264
 
@@ -282,21 +274,21 @@ class WPSC_Purchase_Log_Page {
282
  }
283
 
284
  public function controller_packing_slip() {
285
-
286
- if ( ! isset( $_REQUEST['id'] ) || ( isset( $_REQUEST['id'] ) && ! is_numeric( $_REQUEST['id'] ) ) ) {
287
- wp_die( __( 'Invalid sales log ID', 'wpsc' ) );
288
- }
289
 
290
  global $purchlogitem;
291
 
 
 
292
  $purchlogitem = new wpsc_purchaselogs_items( $this->log_id );
293
 
294
  $columns = array(
295
- 'title' => __( 'Item Name', 'wpsc' ),
296
- 'sku' => __( 'SKU', 'wpsc' ),
297
- 'quantity' => __( 'Quantity', 'wpsc' ),
298
- 'price' => __( 'Price', 'wpsc' ),
299
- 'shipping' => __( 'Item Shipping','wpsc' ),
300
  );
301
 
302
  if ( wpec_display_product_tax() ) {
@@ -309,16 +301,7 @@ class WPSC_Purchase_Log_Page {
309
 
310
  register_column_headers( 'wpsc_purchase_log_item_details', $columns );
311
 
312
- if ( file_exists( get_stylesheet_directory() . '/wpsc-packing-slip.php' ) ) {
313
- $packing_slip_file = get_stylesheet_directory() . '/wpsc-packing-slip.php';
314
- } else {
315
- $packing_slip_file = 'includes/purchase-logs-page/packing-slip.php';
316
- }
317
-
318
- $packing_slip_file = apply_filters( 'wpsc_packing_packing_slip_path', $packing_slip_file );
319
-
320
- include( $packing_slip_file );
321
-
322
  exit;
323
  }
324
 
@@ -353,7 +336,7 @@ class WPSC_Purchase_Log_Page {
353
 
354
  if ( ! $current_action || ( 'download_csv' != $current_action && empty( $_REQUEST['post'] ) ) ) {
355
  if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
356
- wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'action', 'action2' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
357
  exit;
358
  }
359
 
@@ -395,10 +378,9 @@ class WPSC_Purchase_Log_Page {
395
  $ids = array_map( 'intval', $_REQUEST['post'] );
396
  $in = implode( ', ', $ids );
397
  $wpdb->query( "DELETE FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE id IN ($in)" );
 
398
  $wpdb->query( "DELETE FROM " . WPSC_TABLE_CART_CONTENTS . " WHERE purchaseid IN ($in)" );
399
  $wpdb->query( "DELETE FROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " WHERE log_id IN ($in)" );
400
- $claimed_query = new WPSC_Claimed_Stock( array( 'cart_id' => $in ) );
401
- $claimed_query->clear_claimed_stock( 0 );
402
 
403
  $sendback = add_query_arg( array(
404
  'paged' => $_REQUEST['last_paged'],
@@ -419,7 +401,7 @@ class WPSC_Purchase_Log_Page {
419
  ), $sendback );
420
  }
421
 
422
- wp_redirect( $sendback );
423
  exit;
424
  }
425
 
@@ -442,7 +424,7 @@ class WPSC_Purchase_Log_Page {
442
  'c' => 'item_details',
443
  'id' => $id,
444
  ), admin_url( 'index.php' ) );
445
- return $location;
446
  }
447
 
448
  }
8
  * @since 3.8.8
9
  */
10
 
11
+
12
+
13
  class WPSC_Purchase_Log_Page {
14
  private $list_table;
15
  private $output;
 
16
 
17
  public function __construct() {
18
  $controller = 'default';
19
  $controller_method = 'controller_default';
20
 
 
 
 
 
 
21
  if ( isset( $_REQUEST['c'] ) && method_exists( $this, 'controller_' . $_REQUEST['c'] ) ) {
22
  $controller = $_REQUEST['c'];
23
  $controller_method = 'controller_' . $controller;
 
 
 
24
  }
25
 
26
  $this->$controller_method();
115
  <div class="wrap">
116
  <h2><?php echo esc_html( __('Sales', 'wpsc') ); ?> </h2>
117
  <div class="updated">
118
+ <p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wpsc' ), esc_url( remove_query_arg( 'c' ) ) ); ?></p>
119
  </div>
120
  </div>
121
  <?php
240
  <td class="amount"><?php echo wpsc_currency_display( wpsc_purchaselog_details_total() ); ?></td> <!-- TOTAL! -->
241
  </tr>
242
  <?php
 
243
  endwhile;
244
  }
245
 
246
  public function controller_item_details() {
247
+ if ( ! isset( $_REQUEST['id'] ) )
248
+ die( __( 'Invalid sales log ID', 'wpsc' ) );
 
 
249
 
250
  global $purchlogitem;
251
 
252
+ $this->log_id = (int) $_REQUEST['id'];
253
+
254
  // TODO: seriously get rid of all these badly coded purchaselogs.class.php functions in 4.0
255
  $purchlogitem = new wpsc_purchaselogs_items( $this->log_id );
256
 
274
  }
275
 
276
  public function controller_packing_slip() {
277
+ if ( ! isset( $_REQUEST['id'] ) )
278
+ die( __( 'Invalid sales log ID', 'wpsc' ) );
 
 
279
 
280
  global $purchlogitem;
281
 
282
+ $this->log_id = (int) $_REQUEST['id'];
283
+
284
  $purchlogitem = new wpsc_purchaselogs_items( $this->log_id );
285
 
286
  $columns = array(
287
+ 'title' => __( 'Item Name','wpsc' ),
288
+ 'sku' => __( 'SKU','wpsc' ),
289
+ 'quantity' => __( 'Quantity','wpsc' ),
290
+ 'price' => __( 'Price','wpsc' ),
291
+ 'shipping' => __( 'Item Shipping','wpsc'),
292
  );
293
 
294
  if ( wpec_display_product_tax() ) {
301
 
302
  register_column_headers( 'wpsc_purchase_log_item_details', $columns );
303
 
304
+ include( 'includes/purchase-logs-page/packing-slip.php' );
 
 
 
 
 
 
 
 
 
305
  exit;
306
  }
307
 
336
 
337
  if ( ! $current_action || ( 'download_csv' != $current_action && empty( $_REQUEST['post'] ) ) ) {
338
  if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
339
+ wp_redirect( esc_url( remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'action', 'action2' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) ) );
340
  exit;
341
  }
342
 
378
  $ids = array_map( 'intval', $_REQUEST['post'] );
379
  $in = implode( ', ', $ids );
380
  $wpdb->query( "DELETE FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE id IN ($in)" );
381
+ $wpdb->query( "DELETE FROM " . WPSC_TABLE_CLAIMED_STOCK . " WHERE cart_id IN ($in)" );
382
  $wpdb->query( "DELETE FROM " . WPSC_TABLE_CART_CONTENTS . " WHERE purchaseid IN ($in)" );
383
  $wpdb->query( "DELETE FROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " WHERE log_id IN ($in)" );
 
 
384
 
385
  $sendback = add_query_arg( array(
386
  'paged' => $_REQUEST['last_paged'],
401
  ), $sendback );
402
  }
403
 
404
+ wp_redirect( esc_url( $sendback ) );
405
  exit;
406
  }
407
 
424
  'c' => 'item_details',
425
  'id' => $id,
426
  ), admin_url( 'index.php' ) );
427
+ return esc_url( $location );
428
  }
429
 
430
  }
wpsc-admin/display-update.page.php CHANGED
@@ -36,7 +36,7 @@ if ( ! get_option( 'wpsc_needs_update', false ) ) {
36
  if ( $product_count > 0 ) {
37
 
38
  function wpsc_display_update_notice() {
39
- echo "<div id='wpsc-warning' class='error fade'><p><strong>" . __( 'WP eCommerce is almost ready.', 'wpsc' ) . "</strong> " . sprintf( __( 'You must <a href="%1$s">update your database</a> to import all of your products.', 'wpsc' ), "admin.php?page=wpsc-update") . "</p></div>";
40
  }
41
 
42
  if ( ! isset( $_GET['page'] ) || $_GET['page'] != 'wpsc-update' )
@@ -48,9 +48,13 @@ if ( ! get_option( 'wpsc_needs_update', false ) ) {
48
  }
49
  }
50
 
 
 
 
 
51
  function wpsc_display_php_version_notice() {
52
  ?>
53
- <div id='wpsc-warning' class='error fade'><p><?php printf( __( 'You are using PHP %s. WP eCommerce %s requires PHP 5.0 or above. Please contact your hosting provider for further assistance.', 'wpsc' ), PHP_VERSION, WPSC_VERSION ); ?></p></div>
54
  <?php
55
  }
56
 
@@ -60,7 +64,7 @@ function wpsc_display_update_page() {
60
  ?>
61
 
62
  <div class="wrap">
63
- <h2><?php esc_html_e( 'Update WP eCommerce', 'wpsc' ); ?> </h2>
64
  <br />
65
  <?php
66
  if ( isset( $_REQUEST['run_updates'] ) ) :
@@ -81,7 +85,7 @@ function wpsc_display_update_page() {
81
  $wpsc_update->run( $function, $message );
82
  }
83
 
84
- echo '<br /><br /><strong>' . esc_html__( 'WP eCommerce updated successfully!', 'wpsc' ) . '</strong><br />';
85
  if( '' != get_option('permalink_structure')){ ?>
86
  <em><?php echo esc_html( sprintf( __( 'Note: It looks like you have custom permalinks, you will need to refresh your permalinks <a href="%s">here</a>', 'wpsc' ) , admin_url( 'options-permalink.php' ) ) ); ?></em>
87
  <?php
@@ -94,7 +98,7 @@ function wpsc_display_update_page() {
94
  else:
95
 
96
 
97
- esc_html_e( 'Your WP eCommerce database needs to be updated for WP eCommerce 3.8. To perform this update, press the button below. It is highly recommended that you back up your database before performing this update.', 'wpsc' );
98
  ?> <br />
99
  <br />
100
  <em><?php esc_html_e( 'Note: If the server times out or runs out of memory, just reload this page, the server will pick up where it left off.', 'wpsc' ); ?></em>
@@ -102,7 +106,7 @@ function wpsc_display_update_page() {
102
 
103
  <form action="" method="post" id="setup">
104
  <input type="hidden" name="run_updates" value="true" id="run_updates">
105
- <p class="step"><input type="submit" class="button" value="<?php esc_attr_e( 'Update WP eCommerce', 'wpsc' ); ?>" name="Submit"></p>
106
  </form>
107
  <?php
108
  endif;
36
  if ( $product_count > 0 ) {
37
 
38
  function wpsc_display_update_notice() {
39
+ echo "<div id='wpsc-warning' class='error fade'><p><strong>" . __( 'WP e-Commerce is almost ready.', 'wpsc' ) . "</strong> " . sprintf( __( 'You must <a href="%1$s">update your database</a> to import all of your products.', 'wpsc' ), "admin.php?page=wpsc-update") . "</p></div>";
40
  }
41
 
42
  if ( ! isset( $_GET['page'] ) || $_GET['page'] != 'wpsc-update' )
48
  }
49
  }
50
 
51
+ if ( version_compare( PHP_VERSION, '5.0.0', '<' ) ) {
52
+ add_action( 'admin_notices', 'wpsc_display_php_version_notice' );
53
+ }
54
+
55
  function wpsc_display_php_version_notice() {
56
  ?>
57
+ <div id='wpsc-warning' class='error fade'><p><?php printf( __( 'You are using PHP %s. WP e-Commerce %s requires PHP 5.0 or above. Please contact your hosting provider for further assistance.', 'wpsc' ), PHP_VERSION, WPSC_VERSION ); ?></p></div>
58
  <?php
59
  }
60
 
64
  ?>
65
 
66
  <div class="wrap">
67
+ <h2><?php esc_html_e( 'Update WP e-Commerce', 'wpsc' ); ?> </h2>
68
  <br />
69
  <?php
70
  if ( isset( $_REQUEST['run_updates'] ) ) :
85
  $wpsc_update->run( $function, $message );
86
  }
87
 
88
+ echo '<br /><br /><strong>' . esc_html__( 'WP e-Commerce updated successfully!', 'wpsc' ) . '</strong><br />';
89
  if( '' != get_option('permalink_structure')){ ?>
90
  <em><?php echo esc_html( sprintf( __( 'Note: It looks like you have custom permalinks, you will need to refresh your permalinks <a href="%s">here</a>', 'wpsc' ) , admin_url( 'options-permalink.php' ) ) ); ?></em>
91
  <?php
98
  else:
99
 
100
 
101
+ esc_html_e( 'Your WP e-Commerce database needs to be updated for WP e-Commerce 3.8. To perform this update, press the button below. It is highly recommended that you back up your database before performing this update.', 'wpsc' );
102
  ?> <br />
103
  <br />
104
  <em><?php esc_html_e( 'Note: If the server times out or runs out of memory, just reload this page, the server will pick up where it left off.', 'wpsc' ); ?></em>
106
 
107
  <form action="" method="post" id="setup">
108
  <input type="hidden" name="run_updates" value="true" id="run_updates">
109
+ <p class="step"><input type="submit" class="button" value="<?php esc_attr_e( 'Update WP e-Commerce', 'wpsc' ); ?>" name="Submit"></p>
110
  </form>
111
  <?php
112
  endif;
wpsc-admin/display-upgrades.page.php CHANGED
@@ -6,72 +6,159 @@ function wpsc_display_upgrades_page() {
6
 
7
  <div class='wrap'>
8
  <div class='metabox-holder wpsc_gold_side'>
9
-
10
- <h2><?php esc_html_e( 'Upgrades', 'wpsc' ); ?></h2>
11
- <div>
12
- <?php if ( defined( 'WPSC_GOLD_MODULE_PRESENT' ) && ( true == WPSC_GOLD_MODULE_PRESENT ) ) {?>
13
- <p><?php esc_html_e( 'Enter your API Username and API Key below.', 'wpsc' ); ?></p>
14
- <p><a href="http://docs.wpecommerce.org/category/extending-your-store/premium-plugins/gold-cart/"><?php esc_html_e( 'For more information visit our documentation page.', 'wpsc' ); ?></a></p>
15
- <?php } ?>
16
- <div class='metabox-holder'>
17
- <form method='post' id='gold_cart_form' action=''>
18
-
19
- <?php
20
- if ( defined( 'WPSC_GOLD_MODULE_PRESENT' ) && ( true == WPSC_GOLD_MODULE_PRESENT ) ) {
21
- do_action( 'wpsc_gold_module_activation_forms' );
22
- } else {
23
- ?>
24
-
25
- <div id='wpsc_gold_options_outside'>
26
- <div class='form-wrap' >
27
- <p>
28
- <?php esc_html_e( "You don't have any Upgrades yet!", 'wpsc' ); ?>
29
- </p>
30
- </div>
31
- </div>
32
- <?php } ?>
33
- </form>
34
- <?php do_meta_boxes('wpsc_upgrade_page', 'top', true); ?>
35
- </div>
36
- </div>
37
-
38
- <strong><?php esc_html_e( 'WP eCommerce Upgrades', 'wpsc' ); ?></strong><br />
39
-
40
- <span><?php esc_html_e( 'Add more functionality to your eCommerce site. Prices may be subject to change.', 'wpsc' ); ?><input type='button' class='button-primary' onclick='window.open ("http://wpecommerce.org/store/premium-plugins/","mywindow");' value='<?php esc_html_e( 'Buy Now', 'wpsc' ); ?>' id='visitInstinct' name='visitInstinct' /></span>
41
 
42
  <br />
43
  <div class='wpsc_gold_module'>
44
  <br />
45
- <a href="https://wpecommerce.org/store/premium-plugins/gold-cart/" target="_blank"><strong><?php esc_html_e( 'Gold Cart', 'wpsc' ); ?></strong></a>
46
  <p class='wpsc_gold_text'><?php esc_html_e( 'Add product search, multiple image upload, gallery view, Grid View and multiple payment gateway options to your shop', 'wpsc' ); ?></p>
 
47
  </div>
48
 
49
  <div class='wpsc_gold_module'>
50
  <br />
51
- <a href="https://wpecommerce.org/store/premium-plugins/membership-subscriptions/" target="_blank"><strong><?php esc_html_e( 'Members Access Plugin', 'wpsc' ); ?></strong></a>
 
 
 
 
 
 
 
52
  <p class='wpsc_gold_text'><?php esc_html_e( 'Create product memberships and sell them in your store. Use these memberships to restrict premium content on your posts and pages creating a "members only" area perfect for: Forums, Images and Movies and Podcasts', 'wpsc' ); ?></p>
 
53
  </div>
54
 
55
  <div class='wpsc_gold_module'>
56
  <br />
57
- <a href="https://wpecommerce.org/store/premium-plugins/nextgen-gallery-buy-now-buttons/" target="_blank"><strong><?php esc_html_e( 'NextGen Gallery Buy Now Buttons', 'wpsc' ); ?> </strong></a>
58
- <p class='wpsc_gold_text'><?php esc_html_e( 'Make your Online photo gallery into an eCommerce solution.', 'wpsc' ); ?></p>
 
59
  </div>
60
 
61
  <div class='wpsc_gold_module'>
62
  <br />
63
- <a href="https://wpecommerce.org/store/premium-plugins/mp3-player-plugin/" target="_blank"><strong><?php esc_html_e( 'JPlayer - MP3 Plugin', 'wpsc' ); ?> </strong></a>
64
- <p class='wpsc_gold_text'><?php esc_html_e( 'MP3 Player Plugin for WordPress', 'wpsc' ); ?></p>
 
65
  </div>
 
66
  <div class='wpsc_gold_module'>
67
  <br />
68
- <a href="https://wpecommerce.org/store/premium-plugins/fedex-shipping-module/" target="_blank"><strong><?php esc_html_e( 'FedEx Plugin', 'wpsc' ); ?> </strong></a>
 
 
 
 
 
 
69
  <p class='wpsc_gold_text'><?php esc_html_e( 'This plugin offers shop owners the ability to provide Fedex Shipping Quotes for products with weights.', 'wpsc' ); ?></p>
 
70
  </div>
71
  </div>
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  </div>
74
 
75
  <?php
76
  }
77
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  <div class='wrap'>
8
  <div class='metabox-holder wpsc_gold_side'>
9
+ <strong><?php esc_html_e( 'WP e-Commerce Upgrades', 'wpsc' ); ?></strong><br />
10
+ <span><?php esc_html_e( 'Add more functionality to your e-Commerce site. Prices may be subject to change.', 'wpsc' ); ?><input type='button' class='button-primary' onclick='window.open ("http://getshopped.org/extend/premium-upgrades/","mywindow");' value='<?php esc_html_e( 'Buy Now', 'wpsc' ); ?>' id='visitInstinct' name='visitInstinct' /></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  <br />
13
  <div class='wpsc_gold_module'>
14
  <br />
15
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/" target="_blank"><strong><?php esc_html_e( 'Gold Cart', 'wpsc' ); ?></strong></a>
16
  <p class='wpsc_gold_text'><?php esc_html_e( 'Add product search, multiple image upload, gallery view, Grid View and multiple payment gateway options to your shop', 'wpsc' ); ?></p>
17
+ <span class='wpsc_gold_info'><?php esc_html_e( '$40', 'wpsc' ); ?></span>
18
  </div>
19
 
20
  <div class='wpsc_gold_module'>
21
  <br />
22
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/dropshop-2010/" target="_blank"><strong><?php esc_html_e( 'DropShop', 'wpsc' ); ?></strong></a>
23
+ <p class='wpsc_gold_text'><?php esc_html_e( 'Impress your customers with our AJAX powered DropShop that lets your customers drag and drop products into their shopping cart', 'wpsc' ); ?></p>
24
+ <span class='wpsc_gold_info'><?php esc_html_e( '$100', 'wpsc' ); ?></span>
25
+ </div>
26
+
27
+ <div class='wpsc_gold_module'>
28
+ <br />
29
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/" target="_blank"><strong><?php esc_html_e( 'Members Access Plugin', 'wpsc' ); ?></strong></a>
30
  <p class='wpsc_gold_text'><?php esc_html_e( 'Create product memberships and sell them in your store. Use these memberships to restrict premium content on your posts and pages creating a "members only" area perfect for: Forums, Images and Movies and Podcasts', 'wpsc' ); ?></p>
31
+ <span class='wpsc_gold_info'><?php esc_html_e( '$49', 'wpsc' ); ?></span>
32
  </div>
33
 
34
  <div class='wpsc_gold_module'>
35
  <br />
36
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/product-slider-2010/" target="_blank"><strong><?php esc_html_e( 'Product Slider', 'wpsc' ); ?> </strong></a>
37
+ <p class='wpsc_gold_text'><?php esc_html_e( 'Display your products in a new and fancy way using the "Product Slider" module.', 'wpsc' ); ?></p>
38
+ <span class='wpsc_gold_info'><?php esc_html_e( '$45', 'wpsc' ); ?></span>
39
  </div>
40
 
41
  <div class='wpsc_gold_module'>
42
  <br />
43
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/nextgen-gallery-buy-now1/" target="_blank"><strong><?php esc_html_e( 'NextGen Gallery Buy Now Buttons', 'wpsc' ); ?> </strong></a>
44
+ <p class='wpsc_gold_text'><?php esc_html_e( 'Make your Online photo gallery into an e-Commerce solution.', 'wpsc' ); ?></p>
45
+ <span class='wpsc_gold_info'><?php esc_html_e( '$10', 'wpsc' ); ?></span>
46
  </div>
47
+
48
  <div class='wpsc_gold_module'>
49
  <br />
50
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/jplayer-mp3-player/" target="_blank"><strong><?php esc_html_e( 'JPlayer - MP3 Plugin', 'wpsc' ); ?> </strong></a>
51
+ <p class='wpsc_gold_text'><?php esc_html_e( 'JPlayer is a Plugin that provides a Javascript powered MP3 player to each product. This is very similar to our alternative MP3 Player except that it uses CSS and Javascript to customize the look and feel of the player making it much easier for you to style it also comes with a range of skins.', 'wpsc' ); ?></p>
52
+ <span class='wpsc_gold_info'><?php esc_html_e( '$40', 'wpsc' ); ?></span>
53
+ </div>
54
+ <div class='wpsc_gold_module'>
55
+ <br />
56
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/fedex-shipping-module/" target="_blank"><strong><?php esc_html_e( 'FedEx Plugin', 'wpsc' ); ?> </strong></a>
57
  <p class='wpsc_gold_text'><?php esc_html_e( 'This plugin offers shop owners the ability to provide Fedex Shipping Quotes for products with weights.', 'wpsc' ); ?></p>
58
+ <span class='wpsc_gold_info'><?php esc_html_e( '$40', 'wpsc' ); ?></span>
59
  </div>
60
  </div>
61
 
62
+ <h2><?php esc_html_e( 'Upgrades', 'wpsc' ); ?></h2>
63
+ <div class='wpsc_gold_float'>
64
+ <p><?php esc_html_e( 'Enter your API Username and API Key below.', 'wpsc' ); ?></p>
65
+ <p><a href="http://docs.getshopped.org/category/extending-your-store/premium-plugins/gold-cart/"><?php esc_html_e( 'For more information visit our documentation page.', 'wpsc' ); ?></a></p>
66
+
67
+ <div class='metabox-holder'>
68
+ <form method='post' id='gold_cart_form' action=''>
69
+
70
+ <?php
71
+ if ( defined( 'WPSC_GOLD_MODULE_PRESENT' ) && ( true == WPSC_GOLD_MODULE_PRESENT ) ) {
72
+ do_action( 'wpsc_gold_module_activation_forms' );
73
+ } else {
74
+ ?>
75
+
76
+ <div id='wpsc_gold_options_outside'>
77
+ <div class='form-wrap' >
78
+ <p>
79
+ <?php esc_html_e( "You don't have any Upgrades yet!", 'wpsc' ); ?>
80
+ </p>
81
+ </div>
82
+
83
+ <h2><?php _e( 'API Key Reset', 'wpsc' ); ?></h2>
84
+ <div class='form-wrap' >
85
+ <p>
86
+ <?php esc_html_e( 'Enter your API name and key to release it from an old site that you no longer use.', 'wpsc' ); ?> <br /><br />
87
+ </p>
88
+ </div>
89
+ </div>
90
+
91
+ <div class='postbox'>
92
+ <h3 class='hndle'><?php esc_html_e( 'API Key Reset', 'wpsc' ); ?></h3>
93
+ <p>
94
+ <label for='activation_name'><?php esc_html_e( 'Name:', 'wpsc' ); ?></label>
95
+ <input class='text' type='text' size='40' value='<?php echo get_option( 'activation_name' ); ?>' name='activation_name' id='activation_name' />
96
+ </p>
97
+ <p>
98
+ <label for='activation_key'><?php esc_html_e( 'API Key:', 'wpsc' ); ?></label>
99
+ <input class='text' type='text' size='40' value='<?php echo get_option( 'activation_key' ); ?>' name='activation_key' id='activation_key' />
100
+ </p>
101
+ <p>
102
+ <input type='hidden' value='true' name='reset_api_key' />
103
+ <input type='submit' class='button-primary' value='<?php esc_html_e( 'Reset API Key', 'wpsc' ); ?>' name='submit_values' />
104
+ </p>
105
+ </div>
106
+
107
+ <?php } ?>
108
+ </form>
109
+ <?php do_meta_boxes('wpsc_upgrade_page', 'top', true); ?>
110
+ </div>
111
+ </div>
112
  </div>
113
 
114
  <?php
115
  }
116
+
117
+ function wpsc_reset_api_key() {
118
+ if ( isset( $_POST['reset_api_key'] ) && ( $_POST['reset_api_key'] == 'true' ) ) {
119
+ if ( $_POST['activation_name'] != null ) {
120
+ $target = "http://instinct.co.nz/wp-goldcart-api/api_register.php?name=" . $_POST['activation_name'] . "&key=" . $_POST['activation_key'] . "&url=" . site_url() . "";
121
+
122
+ $remote_access_fail = false;
123
+ $useragent = 'WP e-Commerce plugin';
124
+
125
+ $activation_name = urlencode( $_POST['activation_name'] );
126
+ $activation_key = urlencode( $_POST['activation_key'] );
127
+ $activation_state = update_option( 'activation_state', "false" );
128
+
129
+ $siteurl = urlencode( site_url() );
130
+ $request = '';
131
+
132
+ $http_request = "GET /wp-goldcart-api/api_register.php?name=$activation_name&key=&url=$siteurl HTTP/1.0\r\n";
133
+ $http_request .= "Host: instinct.co.nz\r\n";
134
+ $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option( 'blog_charset' ) . "\r\n";
135
+ $http_request .= "Content-Length: " . strlen( $request ) . "\r\n";
136
+ $http_request .= "User-Agent: $useragent\r\n";
137
+ $http_request .= "\r\n";
138
+ $http_request .= $request;
139
+
140
+ $response = '';
141
+
142
+ if ( false != ( $fs = @fsockopen( 'instinct.co.nz', 80, $errno, $errstr, 10 ) ) ) {
143
+ fwrite( $fs, $http_request );
144
+
145
+ while ( !feof( $fs ) )
146
+ $response .= fgets( $fs, 1160 ); // One TCP-IP packet
147
+
148
+ fclose( $fs );
149
+ }
150
+
151
+ $response = explode( "\r\n\r\n", $response, 2 );
152
+ $returned_value = (int)trim( $response[1] );
153
+
154
+ update_option( 'activation_name', '' );
155
+ update_option( 'activation_key', '' );
156
+
157
+ echo "<div class='updated'><p align='center'>" . esc_html__( 'Your API key has been Reset', 'wpsc' ) . "</p></div>";
158
+ }
159
+ }
160
+ }
161
+
162
+ add_action( 'wpsc_gold_module_activation', 'wpsc_reset_api_key' );
163
+
164
+ ?>
wpsc-admin/includes/coupon-list-table-class.php CHANGED
@@ -88,9 +88,9 @@ class WPSC_Coupons_List_Table extends WP_List_Table {
88
  $inactive_count = '&nbsp;<span class="count">(' . $this->inactive_count . ')</span>';
89
 
90
  $views = array(
91
- 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( 'status', $base ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'wpsc') . $total_count ),
92
- 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( 'status', '1', $base ), $current === '1' ? ' class="current"' : '', __('Active', 'wpsc') . $active_count ),
93
- 'inactive' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( 'status', '0', $base ), $current === '0' ? ' class="current"' : '', __('Inactive', 'wpsc') . $inactive_count ),
94
  );
95
 
96
  return $views;
@@ -170,18 +170,18 @@ class WPSC_Coupons_List_Table extends WP_List_Table {
170
 
171
  $base = admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons&wpsc-action=edit_coupon&coupon=' . $item['ID'] );
172
 
173
- $coupon = '<strong><a href="' . add_query_arg( array( 'wpsc-action' => 'edit_coupon', 'coupon' => $item['ID'] ) ) . '">' . esc_html( $item['coupon'] ) . '</a></strong>';
174
 
175
  $row_actions = array();
176
 
177
- $row_actions['edit'] = '<a href="' . add_query_arg( array( 'wpsc-action' => 'edit_coupon', 'coupon' => $item['ID'] ) ) . '">' . __( 'Edit', 'wpsc' ) . '</a>';
178
 
179
  if( strtolower( $item['status'] ) == 'active' )
180
- $row_actions['deactivate'] = '<a href="' . add_query_arg( array( 'wpsc-action' => 'deactivate_coupon', 'coupon' => $item['ID'] ) ) . '">' . __( 'Deactivate', 'wpsc' ) . '</a>';
181
  else
182
- $row_actions['activate'] = '<a href="' . add_query_arg( array( 'wpsc-action' => 'activate_coupon', 'coupon' => $item['ID'] ) ) . '">' . __( 'Activate', 'wpsc' ) . '</a>';
183
 
184
- $row_actions['delete'] = '<a href="' . add_query_arg( array( 'wpsc-action' => 'delete_coupon', 'coupon' => $item['ID'] ) ) . '">' . __( 'Delete', 'wpsc' ) . '</a>';
185
 
186
  $row_actions = apply_filters( 'wpsc_coupon_row_actions', $row_actions, $item['ID'] );
187
 
88
  $inactive_count = '&nbsp;<span class="count">(' . $this->inactive_count . ')</span>';
89
 
90
  $views = array(
91
+ 'all' => sprintf( '<a href="%s"%s>%s</a>', esc_url( remove_query_arg( 'status', $base ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'wpsc') . $total_count ),
92
+ 'active' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( 'status', '1', $base ) ), $current === '1' ? ' class="current"' : '', __('Active', 'wpsc') . $active_count ),
93
+ 'inactive' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( 'status', '0', $base ) ), $current === '0' ? ' class="current"' : '', __('Inactive', 'wpsc') . $inactive_count ),
94
  );
95
 
96
  return $views;
170
 
171
  $base = admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons&wpsc-action=edit_coupon&coupon=' . $item['ID'] );
172
 
173
+ $coupon = '<strong><a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'edit_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . esc_html( $item['coupon'] ) . '</a></strong>';
174
 
175
  $row_actions = array();
176
 
177
+ $row_actions['edit'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'edit_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Edit', 'wpsc' ) . '</a>';
178
 
179
  if( strtolower( $item['status'] ) == 'active' )
180
+ $row_actions['deactivate'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'deactivate_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Deactivate', 'wpsc' ) . '</a>';
181
  else
182
+ $row_actions['activate'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'activate_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Activate', 'wpsc' ) . '</a>';
183
 
184
+ $row_actions['delete'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'delete_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Delete', 'wpsc' ) . '</a>';
185
 
186
  $row_actions = apply_filters( 'wpsc_coupon_row_actions', $row_actions, $item['ID'] );
187
 
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -7,7 +7,6 @@
7
  */
8
 
9
  global $wpsc_product_defaults;
10
-
11
  $wpsc_product_defaults = array(
12
  'id' => '0',
13
  'name' => '',
@@ -34,28 +33,32 @@ $wpsc_product_defaults = array(
34
  'no_shipping' => '0',
35
  'thumbnail_image' => '',
36
  'thumbnail_state' => '1',
37
- 'meta' => array(
 
38
  'external_link' => NULL,
39
  'external_link_text' => NULL,
40
  'external_link_target' => NULL,
41
  'merchant_notes' => NULL,
42
  'sku' => NULL,
43
- 'engraved' => '0',
44
  'can_have_uploaded_image' => '0',
45
- 'table_rate_price' => array(
46
- 'quantity' => array(
 
 
47
  0 => '',
48
  ),
49
- 'table_price' => array(
 
50
  0 => '',
51
  ),
52
  ),
53
  ),
54
  );
 
55
 
56
  function wpsc_redirect_variation_update( $location, $post_id ) {
57
  global $post;
58
-
59
  if ( $post->post_parent > 0 && 'wpsc-product' == $post->post_type )
60
  wp_redirect( admin_url( 'post.php?post='.$post->post_parent.'&action=edit' ) );
61
  else
@@ -64,266 +67,209 @@ function wpsc_redirect_variation_update( $location, $post_id ) {
64
  }
65
 
66
  add_filter( 'redirect_post_location', 'wpsc_redirect_variation_update', 10, 2 );
67
-
 
 
 
 
 
 
 
 
 
68
  function wpsc_price_control_forms() {
69
  global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
70
-
71
- $product_data = get_post_custom( $post->ID );
72
  $product_data['meta'] = maybe_unserialize( $product_data );
73
 
74
- foreach ( $product_data['meta'] as $meta_key => $meta_value ) {
75
  $product_data['meta'][$meta_key] = $meta_value[0];
76
- }
77
 
78
  $product_meta = array();
 
 
79
 
80
- if ( ! empty( $product_data['_wpsc_product_metadata'] ) ) {
81
- $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
82
- }
83
-
84
- if ( isset( $product_data['meta']['_wpsc_currency'] ) ) {
85
  $product_alt_currency = maybe_unserialize( $product_data['meta']['_wpsc_currency'] );
86
- }
87
 
88
- if ( ! isset( $product_data['meta']['_wpsc_table_rate_price'] ) ) {
89
  $product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
90
  }
91
-
92
  if ( isset( $product_meta['_wpsc_table_rate_price'] ) ) {
93
- $product_meta['table_rate_price']['state'] = 1;
94
- $product_meta['table_rate_price'] += $product_meta['_wpsc_table_rate_price'];
95
  $product_data['meta']['_wpsc_table_rate_price'] = $product_meta['_wpsc_table_rate_price'];
96
  }
97
 
98
 
99
- if ( ! isset( $product_data['meta']['_wpsc_is_donation'] ) ) {
100
  $product_data['meta']['_wpsc_is_donation'] = $wpsc_product_defaults['donation'];
101
- }
102
 
103
- if ( ! isset( $product_meta['table_rate_price']['state'] ) ) {
104
  $product_meta['table_rate_price']['state'] = null;
105
- }
106
 
107
- if ( ! isset( $product_meta['table_rate_price']['quantity'] ) ) {
108
  $product_meta['table_rate_price']['quantity'] = $wpsc_product_defaults['meta']['table_rate_price']['quantity'][0];
109
- }
110
 
111
- if ( ! isset( $product_data['meta']['_wpsc_price'] ) ) {
112
  $product_data['meta']['_wpsc_price'] = $wpsc_product_defaults['price'];
113
- }
114
 
115
- if ( ! isset( $product_data['special'] ) ) {
116
  $product_data['special'] = $wpsc_product_defaults['special'];
117
- }
118
 
119
- if ( ! isset( $product_data['meta']['_wpsc_special_price'] ) ) {
120
  $product_data['meta']['_wpsc_special_price'] = $wpsc_product_defaults['special_price'];
121
- }
122
 
123
- $product_data['meta']['_wpsc_special_price'] = wpsc_format_number( $product_data['meta']['_wpsc_special_price'] );
 
 
124
 
125
- if ( ! isset( $product_data['meta']['_wpsc_price'] ) ) {
126
  $product_data['meta']['_wpsc_price'] = 0;
127
- }
128
 
129
- $product_data['meta']['_wpsc_price'] = wpsc_format_number( $product_data['meta']['_wpsc_price'] );
 
 
130
 
131
  $currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
132
-
133
- /* Get country name and symbol */
134
- $currency_type = get_option( 'currency_type' );
135
- $country = new WPSC_Country( $currency_type );
136
-
137
- $ct_code = $country->get_currency_code(); // Country currency code
138
- $ct_symb = $country->get_currency_symbol(); // Country symbol
139
-
140
- $price = $product_data['meta']['_wpsc_price'];
141
- $sale_price = $product_data['meta']['_wpsc_special_price'];
142
-
143
- $wp_38 = version_compare( $GLOBALS['wp_version'], '3.8', '>=' );
144
-
145
- $currency_delete_class = $wp_38 ? ' dashicons dashicons-dismiss' : '';
146
- $currency_delete_text = $wp_38 ? '' : 'x';
147
  ?>
148
- <em id="wpsc_product_price_metabox_live_title" class="wpsc_metabox_live_title">
149
- <p>&nbsp;<?php echo esc_html( $ct_symb ); ?><span><?php echo esc_html( $sale_price ); ?></span></p>
150
- <del><?php esc_html_e($ct_symb); ?><span><?php esc_html_e($price) ?></span></del>
151
- </em>
152
- <input type="hidden" id="parent_post" name="parent_post" value="<?php echo $post->post_parent; ?>" />
153
- <?php /* Lots of tedious work is avoided with this little line. */ ?>
154
- <input type="hidden" id="product_id" name="product_id" value="<?php echo $post->ID; ?>" />
155
-
156
- <?php /* Check product if a product has variations */ ?>
157
- <?php if ( wpsc_product_has_children( $post->ID ) ) : ?>
158
- <?php $price = wpsc_product_variation_price_from( $post->ID ); ?>
159
- <p style="margin-top: 6px;"><?php echo sprintf( __( 'This product has variations. To edit the price, please use the <a href="%s">Variation Controls</a>.' , 'wpsc' ), '#wpsc_product_variation_forms' ); ?></p>
160
- <p><?php printf( __( 'Price: %s and above.' , 'wpsc' ), $price ); ?></p>
161
  <?php else: ?>
162
-
163
- <div class='wpsc_floatleft' style="width:100px;">
164
- <label for="wpsc_price"><?php _e( 'Price', 'wpsc' ); ?></label>
165
- <?php echo esc_html( $ct_symb ); ?> <input id="wpsc_price"
166
- type="text"
167
- style="width: 70px;"
168
- name="meta[_wpsc_price]"
169
- value="<?php echo esc_attr( $price ); ?>" />
170
- </div>
171
-
172
- <div class='wpsc_floatleft' style='width:95px; margin-left:30px;'>
173
- <label for='wpsc_sale_price'><?php _e( 'Sale Price', 'wpsc' ); ?></label>
174
- <?php echo esc_html( $ct_symb ); ?> <input id = "wpsc_sale_price"
175
- type="text"
176
- style="width: 70px;"
177
- value="<?php echo esc_attr( $sale_price ); ?>"
178
- name='meta[_wpsc_special_price]' />
179
- </div>
180
-
181
- <div class="wpsc-currency-layers">
182
- <table>
183
- <thead>
184
- <tr>
185
- <th class="type" colspan="2"><?php esc_html_e( 'Alternative Currencies:', 'wpsc' ); ?></th>
186
- <th class="price"><?php esc_html_e( 'Price:', 'wpsc' ); ?></th>
187
- <tr>
188
- </thead>
189
- <tbody>
190
- <?php
191
- if ( isset( $product_alt_currency ) && is_array( $product_alt_currency ) ) :
192
- $i = 0;
193
- foreach ( $product_alt_currency as $iso => $alt_price ) :
194
- $i++;
195
- ?>
196
- <tr class="wpsc_additional_currency">
197
- <td class="remove"><a href="#" class="wpsc_delete_currency_layer<?php echo $currency_delete_class; ?>" rel="<?php echo $iso; ?>"><?php echo $currency_delete_text; ?></a></td>
198
- <td>
199
- <select name="newCurrency[]" class="newCurrency">
200
- <?php foreach ( $currency_data as $currency ) : ?>
201
- <option value="<?php echo absint( $currency['id'] ); ?>" <?php selected( $iso, $currency['isocode'] ); ?>>
202
- <?php echo esc_html( $currency['country'] ); ?> (<?php echo esc_html( $currency['currency'] ); ?>)
203
- </option>
204
- <?php endforeach; ?>
205
- </select>
206
- </td>
207
- <td><input class="newCurrPrice text" size="8" name="newCurrPrice[]" value="<?php echo esc_attr( $alt_price ); ?>" /></td>
208
- </tr>
209
- <?php
210
- endforeach;
211
- endif;
212
- ?>
213
- <tr id="wpsc_currency_row_template" class="template hidden">
214
- <td class="remove"><a href="#" class="wpsc_delete_currency_layer<?php echo $currency_delete_class; ?>"><?php echo $currency_delete_text; ?></a></td>
215
- <td>
216
- <select name="newCurrency[]" class="newCurrency">
217
- <?php foreach ( (array) $currency_data as $currency ) { ?>
218
- <option value="<?php echo absint( $currency['id'] ); ?>">
219
- <?php echo esc_html( $currency['country'] ); ?>
220
- </option>
221
- <?php } ?>
222
- </select>
223
- </td>
224
- <td><input class="newCurrPrice text" size="8" name="newCurrPrice[]" value="0.00" /></td>
225
- </tr>
226
- </tbody>
227
- </table>
228
- <a href="#wpsc_currency_row_template" class="button button-small wpsc_add_new_currency"><?php esc_html_e( 'Add a Currency Option', 'wpsc' ); ?></a>
229
- <?php wp_nonce_field( 'update-options', 'wpsc-update-currency-layers', false ); ?>
230
  </div>
231
-
232
- <div class="wpsc-quantity-discounts">
233
- <table>
234
- <thead>
235
- <tr>
236
- <th class="qty" colspan="2"><?php esc_html_e( 'Quantity:', 'wpsc' ); ?></th>
237
- <th class="curr"><span class="hidden"><?php esc_html_e( 'Currency:', 'wpsc' ); ?><span></th>
238
- <th class="price"><?php esc_html_e( 'Price:', 'wpsc' ); ?></th>
239
- </tr>
240
- </thead>
241
- <tbody>
242
- <?php
243
- if ( count( $product_meta['table_rate_price']['quantity'] ) > 0 ) {
244
- foreach ( (array) $product_meta['table_rate_price']['quantity'] as $key => $quantity ) {
245
- if ( $quantity != '' ) {
246
- $table_price = number_format( $product_meta['table_rate_price']['table_price'][ $key ], 2, '.', '' );
247
- ?>
248
- <tr>
249
- <td class="remove"><a href="#" class="remove_line<?php echo $currency_delete_class; ?>"><?php echo $currency_delete_text; ?></a></td>
250
- <td class="qty">
251
- <input type="text" size="5" value="<?php echo absint( $quantity ); ?>" name="table_rate_price[quantity][]" />
252
- <?php esc_html_e( '+', 'wpsc' ); ?>
253
- </td>
254
- <td class="curr"><?php echo $ct_code . ' ' . $ct_symb; ?></td>
255
- <td><input class="newCurrPrice text" value="<?php echo $table_price; ?>" name="table_rate_price[table_price][]" /></td>
256
- </tr>
257
- <?php
258
- }
259
- }
260
- }
261
- ?>
262
- <tr id="wpsc_quantity_discount_row_template" class="template hidden">
263
- <td class="remove"><a href="#" class="remove_line<?php echo $currency_delete_class; ?>"><?php echo $currency_delete_text; ?></a></td>
264
- <td class="qty">
265
- <input size="5" value="0" name="table_rate_price[quantity][]" />
266
- <?php esc_html_e( '+', 'wpsc' ); ?>
267
- </td>
268
- <td class="curr"><?php echo $ct_code . ' ' . $ct_symb; ?></td>
269
- <td><input size="10"class="newCurrPrice text" value="0" name="table_rate_price[table_price][]" /></td>
270
- </tr>
271
- </tbody>
272
- </table>
273
- <a href="#wpsc_quantity_discount_row_template" class="add_level button button-small"><?php esc_html_e( 'Add a Quantity Discount', 'wpsc' ); ?></a>
274
- <?php wp_nonce_field( 'update-options', 'wpsc-update-quantity-discounts', false ); ?>
275
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
 
277
- <input id="add_form_donation" type="checkbox" name="meta[_wpsc_is_donation]" value="yes" <?php checked( $product_data['meta']['_wpsc_is_donation'], 1 ); ?> />
278
- <label for="add_form_donation"><?php _e( 'Purchase is a donation.', 'wpsc' ) ?></label>
279
- <?php wp_nonce_field( 'update', 'wpsc_product_pricing_nonce' ); ?>
280
-
281
- <?php endif;
282
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
284
  function wpsc_stock_control_forms() {
285
  global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
286
 
287
- $product_data = get_post_custom( $post->ID );
288
  $product_data['meta'] = maybe_unserialize( $product_data );
289
 
290
- foreach ( $product_data['meta'] as $meta_key => $meta_value ) {
291
  $product_data['meta'][$meta_key] = $meta_value[0];
292
- }
293
 
294
  $product_meta = array();
295
-
296
- if ( ! empty( $product_data['_wpsc_product_metadata'] ) ) {
297
  $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
298
- }
299
 
300
  // this is to make sure after upgrading to 3.8.9, products will have
301
  // "notify_when_none_left" enabled by default if "unpublish_when_none_left"
302
  // is enabled.
303
- if ( ! isset( $product_meta['notify_when_none_left'] ) ) {
304
  $product_meta['notify_when_none_left'] = 0;
305
-
306
- if ( ! empty( $product_meta['unpublish_when_none_left'] ) ) {
307
  $product_meta['notify_when_none_left'] = 1;
308
- }
309
  }
310
 
311
- if ( ! isset( $product_meta['unpublish_when_none_left'] ) ) {
312
  $product_meta['unpublish_when_none_left'] = '';
313
- }
314
-
315
- // Display live title if stock is set
316
- if ( isset( $product_data['meta']['_wpsc_stock'] ) && is_numeric( $product_data['meta']['_wpsc_stock'] ) ) {
317
- $live_title = '<em id="wpsc_product_stock_metabox_live_title" class="wpsc_metabox_live_title">';
318
- $live_title .= sprintf( '<p><span>%s</span> %s</p>', wpsc_format_number( $product_data['meta']['_wpsc_stock'], 0 ), _x( 'left in stock', 'live preview of stock remaining in admin', 'wpsc' ) );
319
- $live_title .= '</em>';
320
-
321
- echo $live_title;
322
- }
323
 
324
  if ( ! empty( $product_meta['unpublish_when_none_left'] ) && ! isset( $product_meta['notify_when_none_left'] ) )
 
325
  ?>
326
- <label for="wpsc_sku"><abbr title="<?php esc_attr_e( 'Stock Keeping Unit', 'wpsc' ); ?>"><?php esc_html_e( 'SKU:', 'wpsc' ); ?></abbr></label>
 
327
  <?php
328
  if ( !isset( $product_data['meta']['_wpsc_sku'] ) )
329
  $product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku']; ?><br />
@@ -333,7 +279,7 @@ function wpsc_stock_control_forms() {
333
  if ( !isset( $product_data['meta']['_wpsc_stock'] ) )
334
  $product_data['meta']['_wpsc_stock'] = ''; ?>
335
  <br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ) echo 'checked="checked"'; else echo ''; ?> name='meta[_wpsc_limited_stock]' />
336
- <label for='add_form_quantity_limited' class='small'><?php esc_html_e( 'Product has limited stock', 'wpsc' ); ?></label>
337
  <?php
338
  if ( $post->ID > 0 ) {
339
  if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ) {?>
@@ -342,45 +288,31 @@ function wpsc_stock_control_forms() {
342
  <div class='edit_stock' style='display: none;'><?php
343
  } ?>
344
  <?php if ( wpsc_product_has_children( $post->ID ) ) : ?>
345
- <?php $stock = wpsc_variations_stock_remaining( $post->ID ); ?>
346
- <p><?php echo sprintf( __( 'This product has variations. To edit the quantity, please use the <a href="%s">Variation Controls</a> below.' , 'wpsc' ), '#wpsc_product_variation_forms' ); ?></p>
347
  <p><?php printf( _n( "%s variant item in stock.", "%s variant items in stock.", $stock, 'wpsc' ), $stock ); ?></p>
348
  <?php else: ?>
349
- <div style="margin-bottom:20px;">
350
- <label for="stock_limit_quantity"><?php esc_html_e( 'Quantity in stock', 'wpsc' ); ?></label>
351
- <input type='number' min="0" step="1" style="width:80px; margin-left:50px;"
352
- id="stock_limit_quantity" name='meta[_wpsc_stock]'
353
- size='3' value='<?php echo absint( $product_data['meta']['_wpsc_stock'] ); ?>'
354
- class='stock_limit_quantity' />
355
- </div>
356
-
357
  <?php
358
- $remaining_quantity = wpsc_get_remaining_quantity( $post->ID );
359
- $reserved_quantity = $product_data['meta']['_wpsc_stock'] - $remaining_quantity;
360
- if ( $reserved_quantity ) {
361
- echo '<p><em>';
362
- printf( _n('%s of them is reserved for pending or recently completed orders.',
363
- '%s of them are reserved for pending or recently completed orders.',
364
- $reserved_quantity, 'wpsc'), $reserved_quantity );
365
-
366
- echo '</em></p>';
367
- }
368
  ?>
 
 
369
  <?php endif; ?>
370
-
371
- <p><?php esc_html_e( 'When stock reduces to zero:', 'wpsc' ); ?></p>
372
  <div class='notify_when_none_left'>
373
- <input type='checkbox' id="notify_when_oos"
374
- name='meta[_wpsc_product_metadata][notify_when_none_left]'
375
- class='notify_when_oos'<?php checked( $product_meta['notify_when_none_left'] ); ?> />
376
- <label for="notify_when_oos"><?php esc_html_e( 'Notify site owner via email', 'wpsc' ); ?></label>
377
  </div>
378
  <div class='unpublish_when_none_left'>
379
- <input type='checkbox' id="unpublish_when_oos"
380
- name='meta[_wpsc_product_metadata][unpublish_when_none_left]'
381
- class='unpublish_when_oos'<?php checked( $product_meta['unpublish_when_none_left'] ); ?> />
382
- <label for="unpublish_when_oos"><?php esc_html_e( 'Unpublish product from website', 'wpsc' ); ?></label>
383
-
384
  </div>
385
  </div> <?php
386
  } else { ?>
@@ -390,14 +322,11 @@ function wpsc_stock_control_forms() {
390
  <input type='checkbox' class='notify_when_oos' name='meta[_wpsc_product_metadata][notify_when_none_left]' /> <?php esc_html_e( 'Email site owner if this Product runs out of stock', 'wpsc' ); ?>
391
  <input type='checkbox' class='unpublish_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> <?php esc_html_e( 'Set status to Unpublished if this Product runs out of stock', 'wpsc' ); ?>
392
  </div>
393
- </div>
394
- <?php
395
  }
396
-
397
- wp_nonce_field( 'update', 'wpsc_product_stock_nonce' );
398
-
399
  }
400
-
401
  function wpsc_product_taxes_forms() {
402
  global $post, $wpdb, $wpsc_product_defaults;
403
  $product_data = get_post_custom( $post->ID );
@@ -434,7 +363,7 @@ function wpsc_product_taxes_forms() {
434
  'type' => 'checkbox',
435
  'id' => 'wpec_taxes_taxable',
436
  'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable]',
437
- 'label' => __( 'Product is exempt from taxation.', 'wpsc' )
438
  );
439
 
440
  if ( isset( $product_meta['wpec_taxes_taxable'] ) && 'on' == $product_meta['wpec_taxes_taxable'] ) {
@@ -444,9 +373,9 @@ function wpsc_product_taxes_forms() {
444
  //add taxable amount only for exclusive tax
445
  if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
446
  $taxable_amount_input_settings = array(
447
- 'id' => 'wpec_taxes_taxable_amount',
448
- 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable_amount]',
449
- 'label' => __( 'Taxable Amount', 'wpsc' ),
450
  'description' => __( 'Taxable amount in your currency, not percentage of price.', 'wpsc' ),
451
  );
452
 
@@ -460,21 +389,15 @@ function wpsc_product_taxes_forms() {
460
  }
461
  }// if
462
 
463
- $output = '<a name="wpsc_tax"></a>';
464
- $output .= '<p>'.$wpec_taxes_controller->wpec_taxes_build_input( $taxable_checkbox_settings ).'</p>';
465
- $output .= '<p>'.$wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ).'</p>';
466
- $output .= '<p>';
467
- $output .= ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) ? $wpec_taxes_controller->wpec_taxes_build_input( $taxable_amount_input_settings ) : '';
468
- $output .= '</p>';
469
-
470
- if ( ! $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_enabled() ) {
471
- $output = '<p>' . sprintf( __( 'Taxes are not enabled. See <a href="%s">Settings &gt; Taxes</a>', 'wpsc' ), admin_url( 'options-general.php?page=wpsc-settings&tab=taxes' ) ) . '</p>';
472
- }
473
-
474
- echo $output;
475
-
476
- wp_nonce_field( 'update', 'wpsc_product_tax_nonce' );
477
-
478
  }
479
 
480
  function wpsc_product_variation_forms() {
@@ -484,10 +407,8 @@ function wpsc_product_variation_forms() {
484
  }
485
 
486
  function _wpsc_get_product_variation_form_url( $id = false ) {
487
- if ( ! $id ) {
488
  $id = get_the_ID();
489
- }
490
-
491
  return admin_url( 'admin-ajax.php?action=wpsc_product_variations_table&product_id=' . $id . '&_wpnonce=' . wp_create_nonce( 'wpsc_product_variations_table' ) );
492
  }
493
 
@@ -566,13 +487,9 @@ function wpsc_weight_unit_display( $unit ) {
566
  * @uses wpsc_default_dimension_unit
567
  */
568
  function wpsc_validate_dimension_unit( $unit = '' ) {
569
-
570
  $default_unit = apply_filters( 'wpsc_default_dimension_unit', $unit );
571
-
572
- if ( empty( $unit ) && array_key_exists( $default_unit, wpsc_dimension_units() ) ) {
573
  $unit = $default_unit;
574
- }
575
-
576
  return $unit;
577
  }
578
 
@@ -591,13 +508,9 @@ function wpsc_validate_dimension_unit( $unit = '' ) {
591
  * @uses wpsc_default_weight_unit
592
  */
593
  function wpsc_validate_weight_unit( $unit = '' ) {
594
-
595
  $default_unit = apply_filters( 'wpsc_default_weight_unit', $unit );
596
-
597
- if ( empty( $unit ) && array_key_exists( $default_unit, wpsc_weight_units() ) ) {
598
  $unit = $default_unit;
599
- }
600
-
601
  return $unit;
602
  }
603
 
@@ -618,21 +531,23 @@ function wpsc_product_shipping_forms( $product = false, $field_name_prefix = 'me
618
  $meta = array();
619
 
620
  $defaults = array(
621
- 'weight' => '',
622
- 'weight_unit' => wpsc_validate_weight_unit(),
623
- 'demension_unit' => wpsc_validate_dimension_unit(),
624
- 'dimensions' => array(),
625
- 'shipping' => array(),
626
- 'no_shipping' => '',
627
  'display_weight_as' => '',
628
  );
629
  $dimensions_defaults = array(
 
 
 
630
  'height' => 0,
631
- 'width' => 0,
632
  'length' => 0,
633
  );
634
  $shipping_defaults = array(
635
- 'local' => '',
636
  'international' => '',
637
  );
638
  $meta = array_merge( $defaults, $meta );
@@ -643,74 +558,79 @@ function wpsc_product_shipping_forms( $product = false, $field_name_prefix = 'me
643
 
644
  foreach ( $shipping as $key => &$val ) {
645
  $val = wpsc_format_number( $val );
646
- }
647
 
648
  $weight = wpsc_convert_weight( $weight, 'pound', $weight_unit );
649
 
650
  $dimension_units = wpsc_dimension_units();
651
  $weight_units = wpsc_weight_units();
652
 
653
- // Why we need this????
654
  $measurements = $dimensions;
655
  $measurements['weight'] = $weight;
656
  $measurements['weight_unit'] = $weight_unit;
657
- // End why
658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
  ?>
660
  <div class="wpsc-stock-editor<?php if ( $bulk ) echo ' wpsc-bulk-edit' ?>">
661
  <p class="wpsc-form-field">
662
- <input type="checkbox" id="wpsc-product-no-shipping" name="<?php echo esc_attr( $field_name_prefix ); ?>[no_shipping]" value="1" <?php checked( $no_shipping && ! $bulk ); ?>>
663
- <label for="wpsc-product-no-shipping"><?php _e( 'Product will <em>not</em> be shipped to customer', 'wpsc' ); ?></label>
 
664
  </p>
665
 
666
  <div class="wpsc-product-shipping-section wpsc-product-shipping-weight-dimensions">
667
- <p><strong><?php esc_html_e( 'Calculate Shipping Costs based on measurements', 'wpsc' ); ?></strong></p>
668
-
669
- <!-- WEIGHT INPUT -->
670
- <p class="wpsc-form-field">
671
- <?php if ( $bulk ) : ?>
672
- <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][weight]" value="1" />
673
- <?php endif; ?>
674
- <label for="wpsc-product-shipping-weight"><?php echo esc_html_e( 'Weight', 'wpsc' ); ?></label>
675
- <span class="wpsc-product-shipping-input">
676
- <input type="text" id="wpsc-product-shipping-weight" name="<?php echo esc_attr( $field_name_prefix ); ?>[weight]" value="<?php if ( ! $bulk ) echo esc_attr( wpsc_format_number( $weight ) ); ?>" />
677
- <select id="wpsc-product-shipping-weight-unit" name="<?php echo $field_name_prefix; ?>[weight_unit]">
678
- <?php foreach ( $weight_units as $unit => $unit_label ): ?>
679
- <option value="<?php echo esc_attr( $unit ); ?>" <?php if ( ! $bulk ) selected( $unit, $measurements['weight_unit'] ); ?>><?php echo esc_html( $unit_label ); ?></option>
 
680
  <?php endforeach; ?>
681
  </select>
682
- </span>
683
- </p>
684
- <!-- END WEIGHT INPUT -->
685
-
686
- <!-- DIMENSIONS INPUT -->
687
- <p class="wpsc-form-field">
688
- <?php if ( $bulk ) : ?>
689
- <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][dimensions]" value="1" />
690
- <?php endif; ?>
691
- <label for="wpsc-product-shipping-weight"><?php echo esc_html_e( 'Dimensions', 'wpsc' ); ?></label>
692
- <span class="wpsc-product-shipping-input">
693
- <input placeholder="L" type="text" id="wpsc-product-shipping-length" name="<?php echo esc_attr( $field_name_prefix ); ?>[dimensions][length]" value="<?php if ( !$bulk && $dimensions['length']>0 ) echo esc_attr( wpsc_format_number( $dimensions['length'] ) ); ?>" />&nbsp;&times;&nbsp;
694
- <input placeholder="W" type="text" id="wpsc-product-shipping-width" name="<?php echo esc_attr( $field_name_prefix ); ?>[dimensions][width]" value="<?php if ( !$bulk && $dimensions['width']>0 ) echo esc_attr( wpsc_format_number( $dimensions['width'] ) ); ?>" />&nbsp;&times;&nbsp;
695
- <input placeholder="H" type="text" id="wpsc-product-shipping-height" name="<?php echo esc_attr( $field_name_prefix ); ?>[dimensions][height]" value="<?php if ( !$bulk && $dimensions['height']>0 ) echo esc_attr( wpsc_format_number( $dimensions['height'] ) ); ?>" />
696
- <select id="wpsc-product-shipping-dimensions-unit" name="<?php echo $field_name_prefix; ?>[dimension_unit]">
697
- <?php foreach ( $dimension_units as $unit => $unit_label ): ?>
698
- <option value="<?php echo esc_attr( $unit ); ?>" <?php if ( ! $bulk && isset( $meta['dimension_unit'] ) ) selected( $unit, $meta['dimension_unit'] ); // Dirty code ?>><?php echo esc_html( $unit_label ); ?></option>
699
- <?php endforeach; ?>
700
- </select>
701
- </span>
702
- </p>
703
- <!-- END DEMENSION INPUT -->
704
-
705
  </div>
706
 
707
- <?php
708
- $currency_type = get_option( 'currency_type' );
709
- $country = new WPSC_Country( $currency_type );
710
-
711
- $ct_symb = $country->get_currency_symbol_html();
712
- ?>
713
-
714
  <div class="wpsc-product-shipping-section wpsc-product-shipping-flat-rate">
715
  <p><strong><?php esc_html_e( 'Flat Rate Settings', 'wpsc' ); ?></strong></p>
716
  <p class="wpsc-form-field">
@@ -718,38 +638,27 @@ function wpsc_product_shipping_forms( $product = false, $field_name_prefix = 'me
718
  <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][local]" value="1" />
719
  <?php endif; ?>
720
  <label for="wpsc-product-shipping-flatrate-local"><?php esc_html_e( 'Local Shipping Fee', 'wpsc' ); ?></label>
721
- <span>
722
- <?php echo esc_html( $ct_symb ); ?>
723
- <input type="text" id="wpsc-product-shipping-flatrate-local" name="<?php echo esc_html( $field_name_prefix ); ?>[shipping][local]" value="<?php if ( ! $bulk ) echo $shipping['local']; ?>" />
724
- </span>
725
  </p>
726
  <p class="wpsc-form-field">
727
  <?php if ( $bulk ): ?>
728
  <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][international]" value="1" />
729
  <?php endif; ?>
730
  <label for="wpsc-product-shipping-flatrate-international"><?php esc_html_e( 'International Shipping Fee', 'wpsc' ); ?></label>
731
- <span>
732
- <?php echo esc_html( $ct_symb ); ?>
733
- <input type="text" id="wpsc-product-shipping-flatrate-international" name="<?php echo esc_html( $field_name_prefix ); ?>[shipping][international]" value="<?php if ( ! $bulk ) echo $shipping['international']; ?>" />
734
- </span>
735
  </p>
736
  </div>
737
  </div>
738
- <?php
739
-
740
- wp_nonce_field( 'update', 'wpsc_product_shipping_nonce' );
741
-
742
  }
743
 
744
- /**
745
- * Product Custom Metadata Form
746
- *
747
- * @global $post Instance of WP_Post.
748
- * @global $wpdb Instance of wpdb.
749
- */
750
  function wpsc_product_advanced_forms() {
 
 
751
 
752
- global $post, $wpdb;
 
 
753
 
754
  $delete_nonce = _wpsc_create_ajax_nonce( 'remove_product_meta' );
755
 
@@ -765,201 +674,184 @@ function wpsc_product_advanced_forms() {
765
  ORDER BY
766
  LOWER(meta_key)", ARRAY_A
767
  );
 
 
768
 
769
- $output = '<table id="wpsc_product_meta_table" class="wp-list-table widefat posts">';
770
- $output .= '<thead>';
771
- $output .= '<tr>';
772
- $output .= '<th id="wpsc_custom_meta_name_th">' . _x( 'Name', 'Product meta UI', 'wpsc' ) . '</th>';
773
- $output .= '<th id="wpsc_custom_meta_value_th">' . _x( 'Value', 'Product meta UI', 'wpsc' ) . '</th>';
774
- $output .= '<th id="wpsc_custom_meta_action_th">' . _x( 'Action', 'Product meta UI', 'wpsc' ) . '</th>';
775
- $output .= '</tr>';
776
- $output .= '</thead>';
777
- $output .= '<tfoot>';
778
- $output .= '<tr>';
779
- $output .= '<th>' . _x( 'Name', 'Product meta UI', 'wpsc' ) . '</th>';
780
- $output .= '<th>' . _x( 'Value', 'Product meta UI', 'wpsc' ) . '</th>';
781
- $output .= '<th>' . _x( 'Action', 'Product meta UI', 'wpsc' ) . '</th>';
782
- $output .= '</tr>';
783
- $output .= '</tfood>';
784
-
785
- $output .= '<tbody>';
786
-
787
- if ( empty( $custom_fields ) ) {
788
- $output .= '<tr class="no-meta"><td colspan="3"><p>' . sprintf( __( 'You have no custom metadata. You can set any arbitrary meta you like and access it programatically via the <a href="">Post Meta API</a>.', 'wpsc' ), esc_url( 'https://codex.wordpress.org/Function_Reference/get_post_meta' ) ) . '</p></td></tr>';
789
- } else {
790
- // Display all available metadata
791
- $alternate = false;
792
- foreach ( (array) $custom_fields as $custom_field ) {
793
- $i = $custom_field['meta_id'];
794
- $alternate = ! $alternate;
795
-
796
- $output .= '<tr'. ($alternate ? ' class="alternate"' : '') .'>';
797
- $output .= '<td><input type="text" value="'.esc_attr( $custom_field['meta_key'] ).'" name="custom_meta['.$i.'][name]" id="custom_meta_name_'.$i.'"></input></td>';
798
- $output .= '<td><input type="text" value="'.esc_attr( $custom_field['meta_value'] ).'" name="custom_meta['.$i.'][value]" id="custom_meta_value_'.$i.'"></input></td>';
799
- $output .= '<td><a href="#" data-nonce="'.esc_attr( $delete_nonce ).'" class="wpsc_remove_meta" onclick="wpsc_remove_custom_meta(this,'.$i.')">'.esc_html( 'Delete', 'wpsc' ).'</a></td>';
800
- $output .= '</tr>';
801
- }
802
- }
803
 
804
- // Template for new metadata input
805
- $output .= '<tr id="wpsc_new_meta_template">';
806
- $output .= '<td><input type="text" name="new_custom_meta[name][]" value=""></input></td>';
807
- $output .= '<td><input type="text" name="new_custom_meta[value][]" value=""></input></td>';
808
- $output .= '<td><a href="#" class="wpsc_remove_meta" onclick="wpsc_remove_empty_meta(this)">'.esc_html( 'Delete', 'wpsc' ).'</a></td>';
809
- $output .= '</tr>';
810
 
811
- $output .= '</tbody>';
812
- $output .= '</table>';
 
 
 
813
 
814
- $output .= '<a href="#" class="add_more_meta button button-small" id="wpsc_add_custom_meta">'.esc_html( '+ Add Custom Meta', 'wpsc' ).'</a>';
 
 
815
 
816
- echo $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
818
  }
819
-
820
- /**
821
- * Display Product External Link Meta Box Form Fields.
822
- *
823
- * @global $post Instance of WP_Post.
824
- */
825
  function wpsc_product_external_link_forms() {
826
 
827
- global $post;
828
-
829
- // Get External Link Values
830
- $product_meta = get_post_meta( $post->ID, '_wpsc_product_metadata', true );
831
- $product_meta = wp_parse_args( $product_meta, array(
832
- 'external_link' => '',
833
- 'external_link_text' => '',
834
- 'external_link_target' => ''
835
- ) );
836
 
837
- ?>
838
- <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
839
- <tbody>
840
- <tr class="form-field">
841
- <th valign="top" scope="row"><label for="external_link"><?php esc_html_e( 'URL', 'wpsc' ); ?></label></th>
842
- <td><input type="text" name="meta[_wpsc_product_metadata][external_link]" id="external_link" value="<?php echo esc_url( $product_meta['external_link'] ); ?>" size="50" style="width: 95%" placeholder="http://" /></td>
843
- </tr>
844
- <tr class="form-field">
845
- <th valign="top" scope="row"><label for="external_link_text"><?php esc_html_e( 'Label', 'wpsc' ); ?></label></th>
846
- <td><input type="text" name="meta[_wpsc_product_metadata][external_link_text]" id="external_link_text" value="<?php echo esc_attr( $product_meta['external_link_text'] ); ?>" size="50" style="width: 95%" placeholder="<?php _e( 'Buy Now', 'wpsc' ); ?>" /></td>
847
- </tr>
848
- <tr class="form-field">
849
- <th valign="top" scope="row"><label for="external_link_target"><?php esc_html_e( 'Target', 'wpsc' ); ?></label></th>
850
- <td id="external_link_target">
851
-
852
- <label>
853
- <input type="radio" name="meta[_wpsc_product_metadata][external_link_target]" value=""<?php checked( '', $product_meta['external_link_target'] ); ?> />
854
- <?php _ex( 'Default (set by theme)', 'External product link target', 'wpsc' ); ?>
855
- </label>
856
-
857
- <label>
858
- <input type="radio" name="meta[_wpsc_product_metadata][external_link_target]" value="_self"<?php checked( '_self', $product_meta['external_link_target'] ); ?> />
859
- <?php esc_html_e( 'Force open in same window', 'wpsc' ); ?>
860
- </label>
861
-
862
- <label>
863
- <input type="radio" name="meta[_wpsc_product_metadata][external_link_target]" value="_blank"<?php checked( '_blank', $product_meta['external_link_target'] ); ?> />
864
- <?php esc_html_e( 'Force open in new window', 'wpsc' ); ?>
865
- </label>
866
-
867
- </td>
868
- </tr>
869
- </tbody>
870
- </table>
871
- <em><?php esc_html_e( 'This option overrides the "Buy Now" and "Add to Cart" buttons, replacing them with the link you describe here.', 'wpsc' ); ?></em>
872
- <?php
873
 
874
- wp_nonce_field( 'update', 'wpsc_product_external_link_nonce' );
 
 
 
 
 
 
875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
876
  }
877
-
878
  function wpsc_additional_desc() {
879
  ?>
880
- <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo esc_textarea( get_post_field( 'post_excerpt', get_the_ID() ) ); ?></textarea>
881
- <em><?php _e( 'Short Descriptions are optional hand-crafted summaries of your content that can be used in your theme.', 'wpsc' ); ?></em>
882
  <?php
883
 
884
  }
885
 
886
- /**
887
- * We really need to either bake this functionality in for 3.9.0 or rip it out into Gold Cart or something else.
888
- * So not awesome to have this exposed and unusable.
889
- *
890
- * @param WP_Post $post Product
891
- * @return void
892
- */
893
  function wpsc_product_gallery( $post ) {
894
- // pull the old iframe source for non JS users
895
  $upload_iframe_src = esc_url( get_upload_iframe_src( 'image', $post->ID ) );
896
- // get our gallery image IDs if present
897
- $images = wpsc_get_admin_product_gallery( $post->ID );
898
- // begin HTML output
899
- $output = '<div id="wpsc_product_gallery">';
900
- $output .= '<ul>';
901
- // check for images before beginngin loop
902
- if ( $images ) {
903
- // now loop images
904
- foreach ( $images as $image_id ) {
905
- // get the thumbnail URL
906
- $thumb_url = wp_get_attachment_thumb_url( absint( $image_id ) );
907
- // output each item
908
- $output .= '<li>';
909
- $output .= '<img src="' . esc_url( $thumb_url ) . '">';
910
- $output .= '<input type="hidden" name="wpsc-product-gallery-imgs[]" value="' . absint( $image_id ) . '">';
911
- $output .= '</li>';
912
- }
913
- }
914
- $output .= '</ul>';
915
- $output .= '<div class="clear"></div>';
916
- $output .= '</div>';
917
- // button for old iframe for non JS people
918
- $output .= '<p class="hide-if-no-js">';
919
- $output .= '<a class="button button-small thickbox" title="' . esc_attr__( 'Manage Product Image Gallery...', 'wpsc' ).'" href="' . $upload_iframe_src . '" id="wpsc-manage-product-gallery">';
920
- $output .= esc_html__( 'Manage Product Image Gallery...', 'wpsc' );
921
- $output .= '</a>';
922
- $output .= '</p>';
923
-
924
- // include a nonce for verification
925
- $output .= wp_nonce_field( 'wpec_product_gallery_nonce', 'wpec_product_gallery_nonce', false, false );
926
-
927
- // echo the gallery output
928
- echo $output;
929
  }
930
 
931
-
932
  function wpsc_product_download_forms() {
933
  global $post, $wpdb, $wpsc_product_defaults;
934
  $product_data = get_post_custom( $post->ID );
935
  $output = '';
936
- $product_data['meta'] = array();
937
-
938
  if ( !empty( $product_data['_wpsc_product_metadata'] ) )
939
- $product_data['meta'] = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
940
 
941
  $upload_max = wpsc_get_max_upload_size();
942
  ?>
943
  <?php echo wpsc_select_product_file( $post->ID ); ?>
944
-
945
- <a href="admin.php?wpsc_admin_action=product_files_existing&amp;product_id=<?php echo absint( $post->ID ); ?>" class="thickbox button button-small" title="<?php echo esc_attr( sprintf( __( 'Select all downloadable files for %s', 'wpsc' ), $post->post_title ) ); ?>"><?php esc_html_e( 'Add existing files...', 'wpsc' ); ?></a>
946
-
947
- <div class="wpsc_fileUpload button button-small">
948
- <span><?php esc_html_e('Upload new file...','wpsc'); ?></span>
949
- <input type='file' name='file' class="button button-small" value='' onchange="wpsc_push_v2t(this, '#wpsc_fileupload_path')" />
950
- </div>
951
- <em id="wpsc_fileupload_path"></em>
952
 
953
  <?php
954
  if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
955
  ?>
956
- <br />
957
- <h4><?php esc_html_e( 'Select an MP3 file to upload as a preview', 'wpsc' ) ?></h4>
958
- <input type='file' name='preview_file' value='' /><br />
959
 
960
- <h4><?php esc_html_e( 'Your preview for this product', 'wpsc' ) ?>:</h4>
961
 
962
- <?php
963
  $args = array(
964
  'post_type' => 'wpsc-preview-file',
965
  'post_parent' => $post->ID,
@@ -967,130 +859,49 @@ function wpsc_product_download_forms() {
967
  'post_status' => 'all'
968
  );
969
 
970
- $preview_files = (array) get_posts( $args );
971
 
972
- foreach ( $preview_files as $preview ) {
973
  echo $preview->post_title . '<br />';
974
- }
975
-
976
  ?>
977
- <br />
978
- <?php
979
  }
980
-
981
  $output = apply_filters( 'wpsc_downloads_metabox', $output );
982
  }
983
 
984
  /**
985
- * Product Personalization Form
986
- *
987
- * @global $post Instance of WP_Post.
988
  */
989
- function wpsc_product_personalization_forms() {
990
-
991
- global $post;
992
-
993
- $product_meta = get_post_meta( $post->ID, '_wpsc_product_metadata', true );
994
- $product_meta = wp_parse_args( $product_meta, array(
995
- 'engraved' => 0,
996
- 'can_have_uploaded_image' => 0
997
- ) );
998
-
999
- ?>
1000
- <ul id="wpsc_product_personalization_option">
1001
- <li>
1002
- <input type="checkbox" name="meta[_wpsc_product_metadata][engraved]" <?php checked( $product_meta['engraved'], '1' ); ?> id="add_engrave_text" />
1003
- <label for="add_engrave_text"><?php esc_html_e( 'Users can personalize this product by leaving a message on single product page', 'wpsc' ); ?></label>
1004
- </li>
1005
- <li>
1006
- <input type="checkbox" name="meta[_wpsc_product_metadata][can_have_uploaded_image]" <?php checked( $product_meta['can_have_uploaded_image'], '1' ); ?> id="can_have_uploaded_image" />
1007
- <label for="can_have_uploaded_image"> <?php esc_html_e( 'Users can upload images on single product page to purchase logs.', 'wpsc' ); ?></label>
1008
- </li>
1009
- <?php do_action( 'wpsc_add_advanced_options', $post->ID ); ?>
1010
- </ul>
1011
- <em><?php _e( "Form fields for the customer to personalize this product will be shown on it's single product page.", 'wpsc' ); ?></em>
1012
- <?php
1013
-
1014
- wp_nonce_field( 'update', 'wpsc_product_personalization_nonce' );
1015
 
 
 
 
1016
  }
 
 
 
 
 
1017
 
1018
- function wpsc_product_delivery_forms(){
1019
- $has_variations = wpsc_product_has_variations( get_post()->ID );
1020
 
1021
- $show_if_variation = $has_variations ? 'display: block;' : 'display:none;';
1022
- ?>
1023
- <em id="wpsc_product_delivery_metabox_live_title" class="wpsc_metabox_live_title">
1024
- <p></p>
1025
- </em>
1026
-
1027
- <div id="wpsc_product_delivery_forms" class="categorydiv wpsc-categorydiv">
1028
- <ul id="wpsc_product_delivery_tabs" class="category-tabs">
1029
- <li class="tabs"><a href="#wpsc_product_delivery-shipping"><?php _e( 'Shipping', 'wpsc' ); ?></a></li>
1030
- <li><a href="#wpsc_product_delivery-download"><?php _e( 'Download', 'wpsc' ); ?></a></li>
1031
- <li><a href="#wpsc_product_delivery-external_link"><?php _e( 'External Link', 'wpsc' ); ?></a></li>
1032
- </ul>
1033
-
1034
- <div id="wpsc_product_delivery-shipping" class="tabs-panel" style="display:block;">
1035
- <?php
1036
- if ( ! $has_variations ) {
1037
- wpsc_product_shipping_forms();
1038
- } else {
1039
- echo '<p>' . sprintf( __( 'This product has variations. To edit the shipping, please use the <a href="%s">Variation Controls</a>.', 'wpsc' ), '#wpsc_product_variation_forms' ) . '</p>';
1040
- }
1041
- ?>
1042
- </div>
1043
-
1044
- <div id="wpsc_product_delivery-download" class="tabs-panel" style="display:none;">
1045
- <?php wpsc_product_download_forms(); ?>
1046
- </div>
1047
-
1048
- <div id="wpsc_product_delivery-external_link" class="tabs-panel" style="display: none;">
1049
- <?php wpsc_product_external_link_forms(); ?>
1050
- </div>
1051
- </div>
1052
- <?php
1053
  }
1054
-
1055
- function wpsc_product_details_forms(){
1056
- ?>
1057
- <em id="wpsc_product_details_metabox_live_title" class="wpsc_metabox_live_title">
1058
- <p></p>
1059
- </em>
1060
-
1061
- <div id="wpsc_product_details_forms" class="categorydiv wpsc-categorydiv">
1062
- <ul id="wpsc_product_details_tabs" class="category-tabs">
1063
- <li class="tabs"><a href="#wpsc_product_details-image"><?php _e( 'Image Gallery', 'wpsc' ); ?></a></li>
1064
- <li><a href="#wpsc_product_details-desc"><?php _e( 'Short Description', 'wpsc' ); ?></a></li>
1065
- <li><a href="#wpsc_product_details-personalization"><?php _e( 'Personalization', 'wpsc' ); ?></a></li>
1066
- <li><a href="#wpsc_product_details-meta"><?php _e( 'Metadata', 'wpsc' ); ?></a></li>
1067
- </ul>
1068
-
1069
- <div id="wpsc_product_details-image" class="tabs-panel" style="display: block;">
1070
- <?php wpsc_product_gallery( get_post() ); ?>
1071
- </div>
1072
-
1073
- <div id="wpsc_product_details-desc" class="tabs-panel" style="display: none;">
1074
- <?php wpsc_additional_desc(); ?>
1075
- </div>
1076
-
1077
- <div id="wpsc_product_details-personalization" class="tabs-panel" style="display: none;">
1078
- <?php wpsc_product_personalization_forms(); ?>
1079
- </div>
1080
-
1081
- <div id="wpsc_product_details-meta" class="tabs-panel" style="display: none;">
1082
- <?php wpsc_product_advanced_forms(); ?>
1083
- </div>
1084
- </div>
1085
- <?php
1086
- }
1087
-
1088
  function wpsc_form_multipart_encoding() {
1089
  echo ' enctype="multipart/form-data"';
1090
  }
1091
 
1092
  add_action( 'post_edit_form_tag', 'wpsc_form_multipart_encoding' );
1093
 
 
 
 
 
 
1094
  /*
1095
  * Modifications to Media Gallery
1096
  */
@@ -1221,118 +1032,95 @@ function wpsc_attachment_fields( $form_fields, $post ) {
1221
 
1222
  }
1223
  function wpsc_save_attachment_fields( $post, $attachment ) {
1224
-
1225
- if ( isset( $attachment['wpsc_custom_thumb_w'] ) ) {
1226
  update_post_meta( $post['ID'], '_wpsc_custom_thumb_w', $attachment['wpsc_custom_thumb_w'] );
1227
- }
1228
 
1229
- if ( isset( $attachment['wpsc_custom_thumb_h'] ) ) {
1230
  update_post_meta( $post['ID'], '_wpsc_custom_thumb_h', $attachment['wpsc_custom_thumb_h'] );
1231
- }
1232
 
1233
- if ( isset( $attachment['wpsc_image_size'] ) ) {
1234
  update_post_meta( $post['ID'], '_wpsc_selected_image_size', $attachment['wpsc_image_size'] );
1235
- }
1236
 
1237
  return $post;
1238
  }
1239
 
1240
  /**
1241
- * Save Product Quick Edit Box
1242
- *
1243
- * Saves input for the various meta in the quick edit boxes.
1244
  *
1245
- * @todo UI.
1246
- * @todo Data validation / sanitization / security.
1247
- * @todo AJAX should probably return weight unit.
1248
- *
1249
- * @return int $post_id Post ID.
1250
  */
1251
- function wpsc_save_quickedit_box( $post_id ) {
1252
 
 
1253
  global $doaction;
1254
 
1255
- // Only save product if saving (not autosaving) via AJAX.
1256
- if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || get_post_type( $post_id ) != 'wpsc-product' ) {
1257
  return;
1258
- }
1259
 
1260
- $bulk = isset( $doaction ) && $doaction == 'edit';
1261
 
1262
- // Map post field to meta key.
1263
  $custom_fields = array(
1264
- 'weight' => 'product_metadata',
1265
- 'stock' => 'stock',
1266
- 'price' => 'price',
1267
  'sale_price' => 'special_price',
1268
- 'sku' => 'sku'
1269
  );
1270
 
1271
- // Get product variations (if any).
1272
- $children = get_children( array(
1273
- 'post_parent' => $post_id,
1274
- 'post_type' => 'wpsc-product',
1275
- 'post_status' => 'inherit'
1276
- ) );
1277
- $is_parent = (bool) $children;
1278
-
1279
  foreach ( $custom_fields as $post_key => $meta_key ) {
1280
-
1281
- // Don't update if field is not set or we're bulk updating and the field is left blank.
1282
- if ( ! isset( $_REQUEST[ $post_key ] ) || ( $bulk && empty( $_REQUEST[ $post_key ] ) ) ) {
1283
- continue;
1284
- }
1285
-
1286
- // Don't update if the product has variations and the field is one of the defined custom fields (unless overridden).
1287
- $override_variant = isset( $_REQUEST[ $post_key . '_variant' ] ) && $_REQUEST[ $post_key . '_variant' ] == 'on';
1288
- if ( $is_parent && ! $override_variant && in_array( $post_key, array_keys( $custom_fields ) ) ) {
1289
  continue;
1290
  }
1291
 
1292
- // Select single product or variation IDs.
1293
- if ( $is_parent && count( $children ) > 0 ) {
1294
- $products = wp_list_pluck( $children, 'ID' );
1295
- } else {
1296
- $products = array( $post_id );
1297
  }
1298
 
1299
- foreach ( $products as $post_id ) {
1300
- $value = $_REQUEST[ $post_key ];
1301
-
1302
- // Validate custom field values
1303
  switch ( $post_key ) {
1304
-
1305
  case 'weight':
1306
  $product_meta = get_post_meta( $post_id, '_wpsc_product_metadata', true );
1307
- if ( ! is_array( $product_meta ) ) {
1308
  $product_meta = array();
1309
- }
 
 
1310
 
1311
- // Draft products don't have product metadata set yet
1312
- $weight_unit = isset( $product_meta['weight_unit'] ) ? $product_meta['weight_unit'] : 'pound';
1313
- $weight = wpsc_convert_weight( $value, $weight_unit, 'pound', true );
1314
 
1315
- if ( isset( $product_meta['weight'] ) ) {
1316
- unset( $product_meta['weight'] );
1317
- }
1318
-
1319
- $product_meta['weight'] = $weight;
1320
 
1321
  $value = $product_meta;
1322
  break;
1323
 
1324
  case 'stock':
1325
- if ( ! is_numeric( $value ) ) {
1326
  $value = '';
1327
- }
1328
  break;
1329
 
1330
  case 'sku':
1331
- if ( $value == __( 'N/A', 'wpsc' ) ) {
1332
  $value = '';
1333
- }
1334
  break;
1335
-
1336
  }
1337
 
1338
  update_post_meta( $post_id, "_wpsc_{$meta_key}", $value );
@@ -1340,7 +1128,6 @@ function wpsc_save_quickedit_box( $post_id ) {
1340
  }
1341
 
1342
  return $post_id;
1343
-
1344
  }
1345
 
1346
  /**
@@ -1360,60 +1147,60 @@ function wpsc_quick_edit_boxes( $col_name, $_screen_post_type = null ) {
1360
  ?>
1361
 
1362
  <fieldset class="inline-edit-col-left wpsc-cols">
1363
- <div class="inline-edit-col">
1364
- <div class="inline-edit-group">
1365
  <?php
1366
  switch ( $col_name ) :
1367
  case 'SKU' :
1368
  ?>
1369
- <label style="max-width: 85%" class="alignleft">
1370
- <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'SKU:', 'wpsc' ); ?> </span>
1371
- <input type="text" name="sku" class="wpsc_ie_sku" />
1372
  <input type="checkbox" name="sku_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1373
 
1374
- </label>
1375
- <?php
1376
  break;
1377
  case 'weight' :
1378
  ?>
1379
- <label style="max-width: 85%" class="alignleft">
1380
- <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Weight:', 'wpsc' ); ?> </span>
1381
- <input type="text" name="weight" class="wpsc_ie_weight" />
1382
  <input type="checkbox" name="weight_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1383
- </label>
1384
- <?php
1385
  break;
1386
  case 'stock' :
1387
  ?>
1388
- <label style="max-width: 85%" class="alignleft">
1389
- <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Stock:', 'wpsc' ); ?> </span>
1390
- <input type="text" name="stock" class="wpsc_ie_stock" />
1391
  <input type="checkbox" name="stock_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1392
- </label>
1393
- <?php
1394
  break;
1395
  case 'price' :
1396
  ?>
1397
- <label style="max-width: 85%" class="alignleft">
1398
- <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Price:', 'wpsc' ); ?> </span>
1399
- <input type="text" name="price" class="wpsc_ie_price" />
1400
  <input type="checkbox" name="price_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1401
- </label>
1402
- <?php
1403
  break;
1404
  case 'sale_price' :
1405
  ?>
1406
- <label style="max-width: 85%" class="alignleft">
1407
- <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Sale Price:', 'wpsc' ); ?> </span>
1408
- <input type="text" name="sale_price" class="wpsc_ie_sale_price" />
1409
  <input type="checkbox" name="sale_price_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1410
- </label>
1411
- <?php
1412
  break;
1413
  endswitch;
1414
  ?>
1415
- </div>
1416
- </div>
1417
  </fieldset>
1418
  <?php
1419
  }
@@ -1467,13 +1254,13 @@ function variation_price_field( $variation ) {
1467
  } else{
1468
  ?>
1469
  <tr class="form-field">
1470
- <th scope="row" valign="top">
1471
  <label for="variation_price"><?php esc_html_e( 'Variation Price', 'wpsc' ); ?></label>
1472
- </th>
1473
- <td>
1474
  <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
1475
  <span class="description"><?php esc_html_e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
1476
- </td>
1477
  </tr>
1478
  <?php
1479
  }
@@ -1535,7 +1322,7 @@ add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
1535
 
1536
  /**
1537
  * @todo - Should probably refactor this at some point - very procedural,
1538
- * WAY too many foreach loops for my liking :) But it does the trick
1539
  *
1540
  * @param <type> $term_id
1541
  */
@@ -1554,6 +1341,16 @@ function save_term_prices( $term_id ) {
1554
  // Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
1555
  if ( isset( $_POST["apply_to_current"] ) ) {
1556
 
 
 
 
 
 
 
 
 
 
 
1557
  //Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
1558
  $products_to_mod = get_objects_in_term( $term_id, "wpsc-variation" );
1559
  $product_parents = array( );
@@ -1615,90 +1412,3 @@ function wpsc_delete_variations( $postid ) {
1615
  }
1616
  }
1617
  add_action( 'before_delete_post', 'wpsc_delete_variations' );
1618
-
1619
-
1620
- /**
1621
- * fetch the items for display inside the admin product gallery
1622
- * differs from the original `wpsc_get_product_gallery` in that
1623
- * it only checks the postmeta for an actual gallery generated by
1624
- * the user instead of pulling all attachments
1625
- *
1626
- * @since 3.8.14.2
1627
- *
1628
- * @param integer $product_id the product ID of the product
1629
- * @return array $gallery the attachment IDs of the gallery if present
1630
- */
1631
- function wpsc_get_admin_product_gallery( $product_id = 0 ) {
1632
-
1633
- // grab our meta from the DB
1634
- $gallery = get_post_meta( $product_id, '_wpsc_product_gallery', true );
1635
-
1636
- // no custom gallery was created, so return nothing
1637
- if ( ! $gallery ) {
1638
- return;
1639
- }
1640
-
1641
- // now make sure the IDs present are actual attachments
1642
- // by looping and unsetting them
1643
- //
1644
- // may want to add a MIME type check here, but not sure
1645
- // if that would cause issues if people use non-images
1646
- // in their galleries
1647
- foreach( $gallery as $key => $image_id ) {
1648
- if ( get_post_type( $image_id ) !== 'attachment' ) {
1649
- unset( $gallery[$key] );
1650
- }
1651
- }
1652
-
1653
- // somehow everything in the gallery
1654
- // was not an attachment, so bail
1655
- if ( empty( $gallery ) ) {
1656
- return;
1657
- }
1658
-
1659
- // send it back
1660
- return $gallery;
1661
-
1662
- }
1663
-
1664
- /**
1665
- * save our gallery IDs on post save
1666
- *
1667
- * @since 3.8.14.2
1668
- * @param integer $product_id the post ID being passed
1669
- * @return void
1670
- */
1671
- function wpsc_new_gallery_save( $product_id = 0 ) {
1672
-
1673
- // do our nonce check. ALWAYS A NONCE CHECK
1674
- if ( ! isset( $_POST['wpsc_product_gallery_nonce'] ) || ! wp_verify_nonce( $_POST['wpsc_product_gallery_nonce'], 'wpsc_product_gallery_nonce' ) ) {
1675
- return $product_id;
1676
- }
1677
-
1678
- // set an empty array for the image IDs
1679
- $image_ids = array();
1680
-
1681
- // ok. we have image IDs to work with. do some filtering
1682
- if ( ! empty( $_POST['wpsc-product-gallery-imgs'] ) ) {
1683
- // make sure our IDs are set to an array
1684
- $image_ids = (array) $_POST['wpsc-product-gallery-imgs'];
1685
- // ensure nothing non-numeric got added in
1686
- $image_ids = wp_parse_id_list( $image_ids );
1687
- // filter out any empty items
1688
- $image_ids = array_filter( $image_ids );
1689
- }
1690
-
1691
- // now if we have image IDs left after filtering, save them
1692
- // if not, delete the meta key
1693
- if ( ! empty( $image_ids ) ) {
1694
- update_post_meta( $product_id, '_wpsc_product_gallery', $image_ids );
1695
- } else {
1696
- delete_post_meta( $product_id, '_wpsc_product_gallery' );
1697
- }
1698
-
1699
- // add an action for after the gallery being saved
1700
- // passing the post ID and the image IDs
1701
- do_action( 'wpsc_after_gallery_save', $product_id, $image_ids );
1702
-
1703
- }
1704
- add_action( 'wpsc_edit_product', 'wpsc_new_gallery_save' );
7
  */
8
 
9
  global $wpsc_product_defaults;
 
10
  $wpsc_product_defaults = array(
11
  'id' => '0',
12
  'name' => '',
33
  'no_shipping' => '0',
34
  'thumbnail_image' => '',
35
  'thumbnail_state' => '1',
36
+ 'meta' =>
37
+ array(
38
  'external_link' => NULL,
39
  'external_link_text' => NULL,
40
  'external_link_target' => NULL,
41
  'merchant_notes' => NULL,
42
  'sku' => NULL,
43
+ 'engrave' => '0',
44
  'can_have_uploaded_image' => '0',
45
+ 'table_rate_price' =>
46
+ array(
47
+ 'quantity' =>
48
+ array(
49
  0 => '',
50
  ),
51
+ 'table_price' =>
52
+ array(
53
  0 => '',
54
  ),
55
  ),
56
  ),
57
  );
58
+ add_action( 'admin_head', 'wpsc_css_header' );
59
 
60
  function wpsc_redirect_variation_update( $location, $post_id ) {
61
  global $post;
 
62
  if ( $post->post_parent > 0 && 'wpsc-product' == $post->post_type )
63
  wp_redirect( admin_url( 'post.php?post='.$post->post_parent.'&action=edit' ) );
64
  else
67
  }
68
 
69
  add_filter( 'redirect_post_location', 'wpsc_redirect_variation_update', 10, 2 );
70
+ function wpsc_css_header() {
71
+ global $post_type;
72
+ ?>
73
+ <style type="text/css">
74
+ <?php if ( isset( $_GET['post_type'] ) && ( 'wpsc-product' == $_GET['post_type'] ) || ( !empty( $post_type ) && 'wpsc-product' == $post_type ) ) : ?>
75
+ #icon-edit { background:transparent url('<?php echo WPSC_CORE_IMAGES_URL.'/icon32.png';?>') no-repeat; }
76
+ <?php endif; ?>
77
+ </style>
78
+ <?php
79
+ }
80
  function wpsc_price_control_forms() {
81
  global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
82
+ $product_data = get_post_custom( $post->ID );
 
83
  $product_data['meta'] = maybe_unserialize( $product_data );
84
 
85
+ foreach ( $product_data['meta'] as $meta_key => $meta_value )
86
  $product_data['meta'][$meta_key] = $meta_value[0];
 
87
 
88
  $product_meta = array();
89
+ if ( !empty( $product_data["_wpsc_product_metadata"] ) )
90
+ $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
91
 
92
+ if ( isset( $product_data['meta']['_wpsc_currency'] ) )
 
 
 
 
93
  $product_alt_currency = maybe_unserialize( $product_data['meta']['_wpsc_currency'] );
 
94
 
95
+ if ( !isset( $product_data['meta']['_wpsc_table_rate_price'] ) ) {
96
  $product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
97
  }
 
98
  if ( isset( $product_meta['_wpsc_table_rate_price'] ) ) {
99
+ $product_meta['table_rate_price']['state'] = 1;
100
+ $product_meta['table_rate_price'] += $product_meta['_wpsc_table_rate_price'];
101
  $product_data['meta']['_wpsc_table_rate_price'] = $product_meta['_wpsc_table_rate_price'];
102
  }
103
 
104
 
105
+ if ( !isset( $product_data['meta']['_wpsc_is_donation'] ) )
106
  $product_data['meta']['_wpsc_is_donation'] = $wpsc_product_defaults['donation'];
 
107
 
108
+ if ( !isset( $product_meta['table_rate_price']['state'] ) )
109
  $product_meta['table_rate_price']['state'] = null;
 
110
 
111
+ if ( !isset( $product_meta['table_rate_price']['quantity'] ) )
112
  $product_meta['table_rate_price']['quantity'] = $wpsc_product_defaults['meta']['table_rate_price']['quantity'][0];
 
113
 
114
+ if ( !isset( $product_data['meta']['_wpsc_price'] ) )
115
  $product_data['meta']['_wpsc_price'] = $wpsc_product_defaults['price'];
 
116
 
117
+ if ( !isset( $product_data['special'] ) )
118
  $product_data['special'] = $wpsc_product_defaults['special'];
 
119
 
120
+ if ( !isset( $product_data['meta']['_wpsc_special_price'] ) )
121
  $product_data['meta']['_wpsc_special_price'] = $wpsc_product_defaults['special_price'];
 
122
 
123
+ $product_data['meta']['_wpsc_special_price'] = wpsc_format_number(
124
+ $product_data['meta']['_wpsc_special_price']
125
+ );
126
 
127
+ if ( ! isset( $product_data['meta']['_wpsc_price'] ) )
128
  $product_data['meta']['_wpsc_price'] = 0;
 
129
 
130
+ $product_data['meta']['_wpsc_price'] = wpsc_format_number(
131
+ $product_data['meta']['_wpsc_price']
132
+ );
133
 
134
  $currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  ?>
136
+ <input type="hidden" id="parent_post" name="parent_post" value="<?php echo $post->post_parent; ?>" />
137
+ <?php /* Lots of tedious work is avoided with this little line. */ ?>
138
+ <input type="hidden" id="product_id" name="product_id" value="<?php echo $post->ID; ?>" />
139
+
140
+ <?php /* Check product if a product has variations */ ?>
141
+ <?php if ( wpsc_product_has_children( $post->ID ) ) : ?>
142
+ <?php $price = wpsc_product_variation_price_from( $post->ID ); ?>
143
+ <p><?php echo sprintf( __( 'This Product has variations, to edit the price please use the <a href="%s">Variation Controls</a>.' , 'wpsc' ), '#wpsc_product_variation_forms' ); ?></p>
144
+ <p><?php printf( __( 'Price: %s and above.' , 'wpsc' ) , $price ); ?></p>
 
 
 
 
145
  <?php else: ?>
146
+ <div class='wpsc_floatleft' style="width:85px;">
147
+ <label><?php esc_html_e( 'Price', 'wpsc' ); ?>:</label><br />
148
+ <input type='text' class='text' size='10' name='meta[_wpsc_price]' value='<?php echo esc_attr( $product_data['meta']['_wpsc_price'] ); ?>' />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  </div>
150
+ <div class='wpsc_floatleft' style='display:<?php if ( ( $product_data['special'] == 1 ) ? 'block' : 'none'
151
+ ); ?>; width:85px; margin-left:30px;'>
152
+ <label for='add_form_special'><?php esc_html_e( 'Sale Price', 'wpsc' ); ?>:</label>
153
+ <div id='add_special'>
154
+ <input type='text' size='10' value='<?php echo esc_attr( $product_data['meta']['_wpsc_special_price'] ); ?>' name='meta[_wpsc_special_price]' />
155
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  </div>
157
+ <br style="clear:both" />
158
+ <br style="clear:both" />
159
+ <a href='#' class='wpsc_add_new_currency'><?php esc_html_e( '+ New Currency', 'wpsc' ); ?></a>
160
+ <br />
161
+ <!-- add new currency layer -->
162
+ <div class='new_layer'>
163
+ <label for='newCurrency[]'><?php esc_html_e( 'Currency type', 'wpsc' ); ?>:</label><br />
164
+ <select name='newCurrency[]' class='newCurrency' style='width:42%'>
165
+ <?php
166
+ foreach ( (array)$currency_data as $currency ) {?>
167
+ <option value='<?php echo $currency['id']; ?>' >
168
+ <?php echo htmlspecialchars( $currency['country'] ); ?> (<?php echo $currency['currency']; ?>)
169
+ </option> <?php
170
+ } ?>
171
+ </select>
172
+ <?php esc_html_e( 'Price', 'wpsc' ); ?> :
173
+ <input type='text' class='text' size='8' name='newCurrPrice[]' value='0.00' style='display:inline' />
174
+ <a href='' class='wpsc_delete_currency_layer'><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/cross.png' /></a>
175
+
176
+ </div> <!-- close new_layer -->
177
+ <?php
178
+ if ( isset( $product_alt_currency ) && is_array( $product_alt_currency ) ) :
179
+ $i = 0;
180
+ foreach ( $product_alt_currency as $iso => $alt_price ) {
181
+ $i++; ?>
182
+ <div class='wpsc_additional_currency'>
183
+ <label for='newCurrency[]'><?php esc_html_e( 'Currency type', 'wpsc' ); ?>:</label><br />
184
+ <select name='newCurrency[]' class='newCurrency' style='width:42%'> <?php
185
+ foreach ( $currency_data as $currency ) {
186
+ if ( $iso == $currency['isocode'] )
187
+ $selected = "selected='selected'";
188
+ else
189
+ $selected = ""; ?>
190
+ <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> >
191
+ <?php echo htmlspecialchars( $currency['country'] ); ?> (<?php echo $currency['currency']; ?>)
192
+ </option> <?php
193
+ } ?>
194
+ </select>
195
+ <?php esc_html_e( 'Price:', 'wpsc' ); ?> <input type='text' class='text' size='8' name='newCurrPrice[]' value='<?php echo $alt_price; ?>' style=' display:inline' />
196
+ <a href='' class='wpsc_delete_currency_layer' rel='<?php echo $iso; ?>'><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/cross.png' /></a></div>
197
+ <?php }
198
 
199
+ endif;
 
 
 
 
200
 
201
+ echo "<br style='clear:both' />
202
+ <br/><input id='add_form_donation' type='checkbox' name='meta[_wpsc_is_donation]' value='yes' " . ( isset($product_data['meta']['_wpsc_is_donation']) && ( $product_data['meta']['_wpsc_is_donation'] == 1 ) ? 'checked="checked"' : '' ) . " />&nbsp;<label for='add_form_donation'>" . __( 'This is a donation, checking this box populates the donations widget.', 'wpsc' ) . "</label>";
203
+ ?>
204
+ <br /><br /> <input type='checkbox' value='1' name='table_rate_price[state]' id='table_rate_price' <?php echo ( ( isset($product_meta['table_rate_price']['state']) && (bool)$product_meta['table_rate_price']['state'] == true ) ? 'checked=\'checked\'' : '' ); ?> />
205
+ <label for='table_rate_price'><?php esc_html_e( 'Table Rate Price', 'wpsc' ); ?></label>
206
+ <div id='table_rate'>
207
+ <a class='add_level' style='cursor:pointer;'><?php esc_html_e( '+ Add level', 'wpsc' ); ?></a><br />
208
+ <br style='clear:both' />
209
+ <table>
210
+ <tr>
211
+ <th><?php esc_html_e( 'Quantity In Cart', 'wpsc' ); ?></th>
212
+ <th colspan='2'><?php esc_html_e( 'Discounted Price', 'wpsc' ); ?></th>
213
+ </tr>
214
+ <?php
215
+ if ( count( $product_meta['table_rate_price']['quantity'] ) > 0 ) {
216
+ foreach ( (array)$product_meta['table_rate_price']['quantity'] as $key => $quantity ) {
217
+ if ( $quantity != '' ) {
218
+ $table_price = number_format( $product_meta['table_rate_price']['table_price'][$key], 2, '.', '' );
219
+ ?>
220
+ <tr>
221
+ <td>
222
+ <input type="text" size="5" value="<?php echo $quantity; ?>" name="table_rate_price[quantity][]"/><span class='description'><?php esc_html_e( 'and above', 'wpsc' ); ?></span>
223
+ </td>
224
+ <td>
225
+ <input type="text" size="10" value="<?php echo $table_price; ?>" name="table_rate_price[table_price][]" />
226
+ </td>
227
+ <td><img src="<?php echo WPSC_CORE_IMAGES_URL; ?>/cross.png" class="remove_line" /></td>
228
+ </tr>
229
+ <?php
230
+ }
231
+ }
232
+ }
233
+ ?>
234
+ <tr>
235
+ <td><input type="text" size="5" value="" name="table_rate_price[quantity][]"/><span class='description'><?php esc_html_e( 'and above', 'wpsc' ); ?></span> </td>
236
+ <td><input type='text' size='10' value='' name='table_rate_price[table_price][]'/></td>
237
+ </tr>
238
+ </table>
239
+ </div>
240
+ <?php endif; ?>
241
+ <?php
242
  }
243
  function wpsc_stock_control_forms() {
244
  global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
245
 
246
+ $product_data = get_post_custom( $post->ID );
247
  $product_data['meta'] = maybe_unserialize( $product_data );
248
 
249
+ foreach ( $product_data['meta'] as $meta_key => $meta_value )
250
  $product_data['meta'][$meta_key] = $meta_value[0];
 
251
 
252
  $product_meta = array();
253
+ if ( !empty( $product_data["_wpsc_product_metadata"] ) )
 
254
  $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
 
255
 
256
  // this is to make sure after upgrading to 3.8.9, products will have
257
  // "notify_when_none_left" enabled by default if "unpublish_when_none_left"
258
  // is enabled.
259
+ if ( !isset( $product_meta['notify_when_none_left'] ) ) {
260
  $product_meta['notify_when_none_left'] = 0;
261
+ if ( ! empty( $product_meta['unpublish_when_none_left'] ) )
 
262
  $product_meta['notify_when_none_left'] = 1;
 
263
  }
264
 
265
+ if ( !isset( $product_meta['unpublish_when_none_left'] ) )
266
  $product_meta['unpublish_when_none_left'] = '';
 
 
 
 
 
 
 
 
 
 
267
 
268
  if ( ! empty( $product_meta['unpublish_when_none_left'] ) && ! isset( $product_meta['notify_when_none_left'] ) )
269
+
270
  ?>
271
+
272
+ <label for="wpsc_sku"><abbr title="<?php esc_attr_e( 'Stock Keeping Unit', 'wpsc' ); ?>"><?php esc_html_e( 'SKU:', 'wpsc' ); ?></abbr></label>
273
  <?php
274
  if ( !isset( $product_data['meta']['_wpsc_sku'] ) )
275
  $product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku']; ?><br />
279
  if ( !isset( $product_data['meta']['_wpsc_stock'] ) )
280
  $product_data['meta']['_wpsc_stock'] = ''; ?>
281
  <br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ) echo 'checked="checked"'; else echo ''; ?> name='meta[_wpsc_limited_stock]' />
282
+ <label for='add_form_quantity_limited' class='small'><?php esc_html_e( 'I have limited stock for this Product', 'wpsc' ); ?></label>
283
  <?php
284
  if ( $post->ID > 0 ) {
285
  if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ) {?>
288
  <div class='edit_stock' style='display: none;'><?php
289
  } ?>
290
  <?php if ( wpsc_product_has_children( $post->ID ) ) : ?>
291
+ <?php $stock = wpsc_variations_stock_remaining( $post->ID ); ?>
292
+ <p><?php esc_html_e( 'This Product has variations, to edit the quantity please use the Variation Controls below.' , 'wpsc' ); ?></p>
293
  <p><?php printf( _n( "%s variant item in stock.", "%s variant items in stock.", $stock, 'wpsc' ), $stock ); ?></p>
294
  <?php else: ?>
295
+ <label for="stock_limit_quantity"><?php esc_html_e( 'Quantity:', 'wpsc' ); ?></label>
296
+ <input type='text' id="stock_limit_quantity" name='meta[_wpsc_stock]' size='3' value='<?php echo $product_data['meta']['_wpsc_stock']; ?>' class='stock_limit_quantity' />
 
 
 
 
 
 
297
  <?php
298
+ $remaining_quantity = wpsc_get_remaining_quantity( $post->ID );
299
+ $reserved_quantity = $product_data['meta']['_wpsc_stock'] - $remaining_quantity;
300
+ if($reserved_quantity): ?>
301
+ <p><em>
302
+ <?php
303
+ printf(_n('%s of them is reserved for pending or recently completed orders.', '%s of them are reserved for pending or recently completed orders.', $reserved_quantity, 'wpsc'), $reserved_quantity);
 
 
 
 
304
  ?>
305
+ </em></p>
306
+ <?php endif; ?>
307
  <?php endif; ?>
 
 
308
  <div class='notify_when_none_left'>
309
+ <input type='checkbox' id="notify_when_oos" name='meta[_wpsc_product_metadata][notify_when_none_left]' class='notify_when_oos'<?php checked( $product_meta['notify_when_none_left'] ); ?> />
310
+ <label for="notify_when_oos"><?php esc_html_e( 'Notify site owner if stock runs out', 'wpsc' ); ?></label>
 
 
311
  </div>
312
  <div class='unpublish_when_none_left'>
313
+ <input type='checkbox' id="unpublish_when_oos" name='meta[_wpsc_product_metadata][unpublish_when_none_left]' class='unpublish_when_oos'<?php checked( $product_meta['unpublish_when_none_left'] ); ?> />
314
+ <label for="unpublish_when_oos"><?php esc_html_e( 'Unpublish this Product if stock runs out', 'wpsc' ); ?></label>
315
+ <p><em><?php esc_html_e( 'If stock runs out, this Product will not be available on the shop unless you untick this box or add more stock.', 'wpsc' ); ?></em></p>
 
 
316
  </div>
317
  </div> <?php
318
  } else { ?>
322
  <input type='checkbox' class='notify_when_oos' name='meta[_wpsc_product_metadata][notify_when_none_left]' /> <?php esc_html_e( 'Email site owner if this Product runs out of stock', 'wpsc' ); ?>
323
  <input type='checkbox' class='unpublish_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> <?php esc_html_e( 'Set status to Unpublished if this Product runs out of stock', 'wpsc' ); ?>
324
  </div>
325
+ </div><?php
 
326
  }
327
+ ?>
328
+ <?php
 
329
  }
 
330
  function wpsc_product_taxes_forms() {
331
  global $post, $wpdb, $wpsc_product_defaults;
332
  $product_data = get_post_custom( $post->ID );
363
  'type' => 'checkbox',
364
  'id' => 'wpec_taxes_taxable',
365
  'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable]',
366
+ 'label' => __( 'This product is not taxable.', 'wpsc' )
367
  );
368
 
369
  if ( isset( $product_meta['wpec_taxes_taxable'] ) && 'on' == $product_meta['wpec_taxes_taxable'] ) {
373
  //add taxable amount only for exclusive tax
374
  if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
375
  $taxable_amount_input_settings = array(
376
+ 'id' => 'wpec_taxes_taxable_amount',
377
+ 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable_amount]',
378
+ 'label' => __( 'Taxable Amount', 'wpsc' ),
379
  'description' => __( 'Taxable amount in your currency, not percentage of price.', 'wpsc' ),
380
  );
381
 
389
  }
390
  }// if
391
 
392
+ ?> <a name="wpsc_tax"></a>
393
+ <p><?php echo $wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ); ?></p>
394
+ <p>
395
+ <?php if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ): ?>
396
+ <?php echo $wpec_taxes_controller->wpec_taxes_build_input( $taxable_amount_input_settings );?>
397
+ <?php endif;?>
398
+ </p>
399
+ <p><?php echo $wpec_taxes_controller->wpec_taxes_build_input( $taxable_checkbox_settings ); ?></p>
400
+ <?php
 
 
 
 
 
 
401
  }
402
 
403
  function wpsc_product_variation_forms() {
407
  }
408
 
409
  function _wpsc_get_product_variation_form_url( $id = false ) {
410
+ if ( ! $id )
411
  $id = get_the_ID();
 
 
412
  return admin_url( 'admin-ajax.php?action=wpsc_product_variations_table&product_id=' . $id . '&_wpnonce=' . wp_create_nonce( 'wpsc_product_variations_table' ) );
413
  }
414
 
487
  * @uses wpsc_default_dimension_unit
488
  */
489
  function wpsc_validate_dimension_unit( $unit = '' ) {
 
490
  $default_unit = apply_filters( 'wpsc_default_dimension_unit', $unit );
491
+ if ( empty( $unit ) && array_key_exists( $default_unit, wpsc_dimension_units() ) )
 
492
  $unit = $default_unit;
 
 
493
  return $unit;
494
  }
495
 
508
  * @uses wpsc_default_weight_unit
509
  */
510
  function wpsc_validate_weight_unit( $unit = '' ) {
 
511
  $default_unit = apply_filters( 'wpsc_default_weight_unit', $unit );
512
+ if ( empty( $unit ) && array_key_exists( $default_unit, wpsc_weight_units() ) )
 
513
  $unit = $default_unit;
 
 
514
  return $unit;
515
  }
516
 
531
  $meta = array();
532
 
533
  $defaults = array(
534
+ 'weight' => '',
535
+ 'weight_unit' => wpsc_validate_weight_unit(),
536
+ 'dimensions' => array(),
537
+ 'shipping' => array(),
538
+ 'no_shipping' => '',
 
539
  'display_weight_as' => '',
540
  );
541
  $dimensions_defaults = array(
542
+ 'height_unit' => wpsc_validate_dimension_unit(),
543
+ 'width_unit' => wpsc_validate_dimension_unit(),
544
+ 'length_unit' => wpsc_validate_dimension_unit(),
545
  'height' => 0,
546
+ 'width' => 0,
547
  'length' => 0,
548
  );
549
  $shipping_defaults = array(
550
+ 'local' => '',
551
  'international' => '',
552
  );
553
  $meta = array_merge( $defaults, $meta );
558
 
559
  foreach ( $shipping as $key => &$val ) {
560
  $val = wpsc_format_number( $val );
561
+ }
562
 
563
  $weight = wpsc_convert_weight( $weight, 'pound', $weight_unit );
564
 
565
  $dimension_units = wpsc_dimension_units();
566
  $weight_units = wpsc_weight_units();
567
 
 
568
  $measurements = $dimensions;
569
  $measurements['weight'] = $weight;
570
  $measurements['weight_unit'] = $weight_unit;
 
571
 
572
+ $measurement_fields = array(
573
+ array(
574
+ 'name' => 'weight',
575
+ 'prefix' => '',
576
+ 'label' => __( 'Weight', 'wpsc' ),
577
+ 'value' => $weight,
578
+ 'units' => $weight_units,
579
+ ),
580
+ array(
581
+ 'name' => 'height',
582
+ 'prefix' => '[dimensions]',
583
+ 'label' => __( 'Height', 'wpsc' ),
584
+ 'value' => $dimensions['height'],
585
+ 'units' => $dimension_units,
586
+ ),
587
+ array(
588
+ 'name' => 'width',
589
+ 'prefix' => '[dimensions]',
590
+ 'label' => __( 'Width', 'wpsc' ),
591
+ 'value' => $dimensions['width'],
592
+ 'units' => $dimension_units,
593
+ ),
594
+ array(
595
+ 'name' => 'length',
596
+ 'prefix' => '[dimensions]',
597
+ 'label' => __( 'Length', 'wpsc' ),
598
+ 'value' => $dimensions['length'],
599
+ 'units' => $dimension_units,
600
+ ),
601
+ );
602
  ?>
603
  <div class="wpsc-stock-editor<?php if ( $bulk ) echo ' wpsc-bulk-edit' ?>">
604
  <p class="wpsc-form-field">
605
+ <label><?php esc_html_e( 'Disregard Shipping for this Product', 'wpsc' ); ?></label>&nbsp;&nbsp;
606
+ <label><input type="radio" name="<?php echo $field_name_prefix ?>[no_shipping]" value="1" <?php checked( $no_shipping && ! $bulk ); ?> /> <?php echo esc_html_x( 'Yes', 'disregard shipping', 'wpsc' ); ?></label>&nbsp;&nbsp;
607
+ <label><input type="radio" name="<?php echo $field_name_prefix ?>[no_shipping]" value="0" <?php checked( ! $no_shipping && ! $bulk ); ?> /> <?php echo esc_html_x( 'No', 'disregard shipping', 'wpsc' ); ?></label>&nbsp;&nbsp;
608
  </p>
609
 
610
  <div class="wpsc-product-shipping-section wpsc-product-shipping-weight-dimensions">
611
+ <p><strong><?php esc_html_e( 'Weight and Dimensions', 'wpsc' ); ?></strong></p>
612
+ <?php
613
+ foreach ( $measurement_fields as $field ):
614
+ ?>
615
+ <p class="wpsc-form-field">
616
+ <?php if ( $bulk ): ?>
617
+ <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][<?php echo $field['name'] ?>]" value="1" />
618
+ <?php endif ?>
619
+ <label for="wpsc-product-shipping-<?php echo $field['name']; ?>"><?php echo esc_html( $field['label'] ); ?></label>
620
+ <span class="wpsc-product-shipping-input">
621
+ <input type="text" id="wpsc-product-shipping-<?php echo $field['name']; ?>" name="<?php echo $field_name_prefix . $field['prefix'] . '[' . $field['name'] . ']'; ?>" value="<?php if ( ! $bulk ) echo esc_attr( wpsc_format_number( $field['value'] ) ); ?>" />
622
+ <select name="<?php echo $field_name_prefix . $field['prefix'] . '[' . $field['name'] . '_unit]'; ?>">
623
+ <?php foreach ( $field['units'] as $unit => $unit_label ): ?>
624
+ <option value="<?php echo $unit; ?>" <?php if ( ! $bulk ) selected( $unit, $measurements[$field['name'] . '_unit'] ); ?>><?php echo esc_html( $unit_label ); ?></option>
625
  <?php endforeach; ?>
626
  </select>
627
+ </span>
628
+ </p>
629
+ <?php
630
+ endforeach;
631
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
  </div>
633
 
 
 
 
 
 
 
 
634
  <div class="wpsc-product-shipping-section wpsc-product-shipping-flat-rate">
635
  <p><strong><?php esc_html_e( 'Flat Rate Settings', 'wpsc' ); ?></strong></p>
636
  <p class="wpsc-form-field">
638
  <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][local]" value="1" />
639
  <?php endif; ?>
640
  <label for="wpsc-product-shipping-flatrate-local"><?php esc_html_e( 'Local Shipping Fee', 'wpsc' ); ?></label>
641
+ <input type="text" id="wpsc-product-shipping-flatrate-local" name="<?php echo $field_name_prefix; ?>[shipping][local]" value="<?php if ( ! $bulk ) echo $shipping['local']; ?>" />
 
 
 
642
  </p>
643
  <p class="wpsc-form-field">
644
  <?php if ( $bulk ): ?>
645
  <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][international]" value="1" />
646
  <?php endif; ?>
647
  <label for="wpsc-product-shipping-flatrate-international"><?php esc_html_e( 'International Shipping Fee', 'wpsc' ); ?></label>
648
+ <input type="text" id="wpsc-product-shipping-flatrate-international" name="<?php echo $field_name_prefix; ?>[shipping][international]" value="<?php if ( ! $bulk ) echo $shipping['international']; ?>" />
 
 
 
649
  </p>
650
  </div>
651
  </div>
652
+ <?php
 
 
 
653
  }
654
 
 
 
 
 
 
 
655
  function wpsc_product_advanced_forms() {
656
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
657
+ $product_data = get_post_custom( $post->ID );
658
 
659
+ $product_data['meta'] = $product_meta = array();
660
+ if ( !empty( $product_data['_wpsc_product_metadata'] ) )
661
+ $product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
662
 
663
  $delete_nonce = _wpsc_create_ajax_nonce( 'remove_product_meta' );
664
 
674
  ORDER BY
675
  LOWER(meta_key)", ARRAY_A
676
  );
677
+ if( !isset( $product_meta['engraved'] ) )
678
+ $product_meta['engraved'] = '';
679
 
680
+ if( !isset( $product_meta['can_have_uploaded_image'] ) )
681
+ $product_meta['can_have_uploaded_image'] = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
 
683
+ ?>
 
 
 
 
 
684
 
685
+ <table>
686
+ <tr>
687
+ <td colspan='2' class='itemfirstcol'>
688
+ <strong><?php esc_html_e( 'Custom Meta', 'wpsc' ); ?>:</strong><br />
689
+ <a href='#' class='add_more_meta' onclick="return add_more_meta(this)"><?php esc_html_e( '+ Add Custom Meta', 'wpsc' );?> </a><br /><br />
690
 
691
+ <?php
692
+ foreach ( (array)$custom_fields as $custom_field ) {
693
+ $i = $custom_field['meta_id'];
694
 
695
+ ?>
696
+ <div class='product_custom_meta' id='custom_meta_<?php echo $i; ?>'>
697
+ <?php esc_html_e( 'Name', 'wpsc' ); ?>
698
+ <input type='text' class='text' value='<?php echo $custom_field['meta_key']; ?>' name='custom_meta[<?php echo $i; ?>][name]' id='custom_meta_name_<?php echo $i; ?>'>
699
+ <?php esc_html_e( 'Value', 'wpsc' ); ?>
700
+ <textarea class='text' name='custom_meta[<?php echo $i; ?>][value]' id='custom_meta_value_<?php echo $i; ?>'><?php echo esc_textarea( $custom_field['meta_value'] ); ?></textarea>
701
+ <a href='#' data-nonce="<?php echo esc_attr( $delete_nonce ); ?>" class='remove_meta' onclick='return remove_meta(this, <?php echo $i; ?>)'><?php esc_html_e( 'Delete', 'wpsc' ); ?></a>
702
+ <br />
703
+ </div>
704
+ <?php
705
+ }
706
+ ?>
707
+ <div class='product_custom_meta'>
708
+ <?php esc_html_e( 'Name', 'wpsc' ); ?>: <br />
709
+ <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
710
+ <?php esc_html_e( 'Description', 'wpsc' ); ?>: <br />
711
+ <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
712
+ <br />
713
+ </div>
714
+ </td>
715
+ </tr>
716
+ <tr>
717
+ <td class='itemfirstcol' colspan='2'><br /> <strong><?php esc_html_e( 'Merchant Notes:', 'wpsc' ); ?></strong><br />
718
+
719
+ <textarea cols='40' rows='3' name='meta[_wpsc_product_metadata][merchant_notes]' id='merchant_notes'><?php
720
+ if ( isset( $product_meta['merchant_notes'] ) )
721
+ echo esc_textarea( trim( $product_meta['merchant_notes'] ) );
722
+ ?></textarea>
723
+ <small><?php esc_html_e( 'These notes are only available here.', 'wpsc' ); ?></small>
724
+ </td>
725
+ </tr>
726
+ <tr>
727
+ <td class='itemfirstcol' colspan='2'><br />
728
+ <strong><?php esc_html_e( 'Personalisation Options', 'wpsc' ); ?>:</strong><br />
729
+ <input type='hidden' name='meta[_wpsc_product_metadata][engraved]' value='0' />
730
+ <input type='checkbox' name='meta[_wpsc_product_metadata][engraved]' <?php checked( $product_meta['engraved'], '1' ); ?> id='add_engrave_text' />
731
+ <label for='add_engrave_text'><?php esc_html_e( 'Users can personalize this product by leaving a message on single product page', 'wpsc' ); ?></label>
732
+ <br />
733
+ </td>
734
+ </tr>
735
+ <tr>
736
+ <td class='itemfirstcol' colspan='2'>
737
+ <input type='hidden' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' value='0' />
738
+ <input type='checkbox' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' <?php checked( $product_meta['can_have_uploaded_image'], '1' ); ?> id='can_have_uploaded_image' />
739
+ <label for='can_have_uploaded_image'> <?php esc_html_e( 'Users can upload images on single product page to purchase logs.', 'wpsc' ); ?> </label>
740
+ <br />
741
+ </td>
742
+ </tr>
743
+ <?php
744
+ if ( get_option( 'payment_gateway' ) == 'google' ) {
745
+ ?>
746
+ <tr>
747
+ <td class='itemfirstcol' colspan='2'>
748
 
749
+ <input type='checkbox' <?php echo $product_meta['google_prohibited']; ?> name='meta[_wpsc_product_metadata][google_prohibited]' id='add_google_prohibited' /> <label for='add_google_prohibited'>
750
+ <?php esc_html_e( 'Prohibited <a href="http://checkout.google.com/support/sell/bin/answer.py?answer=75724">by Google?</a>', 'wpsc' ); ?>
751
+ </label><br />
752
+ </td>
753
+ </tr>
754
+ <?php
755
+ }
756
+ do_action( 'wpsc_add_advanced_options', $post->ID );
757
+ ?>
758
+ <tr>
759
+ <td class='itemfirstcol' colspan='2'><br />
760
+ <strong><?php esc_html_e( 'Enable Comments', 'wpsc' ); ?>:</strong><br />
761
+ <select name='meta[_wpsc_product_metadata][enable_comments]'>
762
+ <option value='' <?php echo ( ( isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '' ) ? 'selected' : '' ); ?> ><?php esc_html_e( 'Use Default', 'wpsc' ); ?></option>
763
+ <option value='1' <?php echo ( ( isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '1' ) ? 'selected' : '' ); ?> ><?php esc_html_e( 'Yes', 'wpsc' ); ?></option>
764
+ <option value='0' <?php echo ( ( isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '0' ) ? 'selected' : '' ); ?> ><?php esc_html_e( 'No', 'wpsc' ); ?></option>
765
+ </select>
766
+ <br/><?php esc_html_e( 'Allow users to comment on this Product.', 'wpsc' ); ?>
767
+ </td>
768
+ </tr>
769
+ </table>
770
+ <?php
771
  }
 
 
 
 
 
 
772
  function wpsc_product_external_link_forms() {
773
 
774
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
775
+ $product_data = get_post_custom( $post->ID );
 
 
 
 
 
 
 
776
 
777
+ $product_data['meta'] = $product_meta = array();
778
+ if ( !empty( $product_data['_wpsc_product_metadata'] ) )
779
+ $product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
780
 
781
+ // Get External Link Values
782
+ $external_link_value = isset( $product_meta['external_link'] ) ? $product_meta['external_link'] : '';
783
+ $external_link_text_value = isset( $product_meta['external_link_text'] ) ? $product_meta['external_link_text'] : '';
784
+ $external_link_target_value = isset( $product_meta['external_link_target'] ) ? $product_meta['external_link_target'] : '';
785
+ $external_link_target_value_selected[$external_link_target_value] = ' selected="selected"';
786
+ if ( !isset( $external_link_target_value_selected['_self'] ) ) $external_link_target_value_selected['_self'] = '';
787
+ if ( !isset( $external_link_target_value_selected['_blank'] ) ) $external_link_target_value_selected['_blank'] = '';
788
 
789
+ ?>
790
+ <p><?php esc_html_e( 'If this product is for sale on another website enter the link here. For instance if your product is an MP3 file for sale on iTunes you could put the link here. This option overrides the buy now and add to cart links and takes you to the site linked here. You can also customise the Buy Now text and choose to open the link in a new window.', 'wpsc' ); ?>
791
+ <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
792
+ <tbody>
793
+ <tr class="form-field">
794
+ <th valign="top" scope="row"><label for="external_link"><?php esc_html_e( 'External Link', 'wpsc' ); ?></label></th>
795
+ <td><input type="text" name="meta[_wpsc_product_metadata][external_link]" id="external_link" value="<?php esc_attr_e( $external_link_value ); ?>" size="50" style="width: 95%"></td>
796
+ </tr>
797
+ <tr class="form-field">
798
+ <th valign="top" scope="row"><label for="external_link_text"><?php esc_html_e( 'External Link Text', 'wpsc' ); ?></label></th>
799
+ <td><input type="text" name="meta[_wpsc_product_metadata][external_link_text]" id="external_link_text" value="<?php esc_attr_e( $external_link_text_value ); ?>" size="50" style="width: 95%"></td>
800
+ </tr>
801
+ <tr class="form-field">
802
+ <th valign="top" scope="row"><label for="external_link_target"><?php esc_html_e( 'External Link Target', 'wpsc' ); ?></label></th>
803
+ <td>
804
+ <select id="external_link_target" name="meta[_wpsc_product_metadata][external_link_target]">
805
+ <option value=""><?php _ex( 'Default (set by theme)', 'External product link target', 'wpsc' ); ?></option>
806
+ <option value="_self" <?php echo $external_link_target_value_selected['_self'] ; ?>><?php esc_html_e( 'Open link in the same window', 'wpsc' ); ?></option>
807
+ <option value="_blank" <?php echo $external_link_target_value_selected['_blank'] ; ?>><?php esc_html_e( 'Open link in a new window', 'wpsc' ); ?></option>
808
+ </select>
809
+ </td>
810
+ </tr>
811
+ </tbody>
812
+ </table>
813
+ <?php
814
  }
 
815
  function wpsc_additional_desc() {
816
  ?>
817
+ <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo esc_textarea( get_post_field( 'post_excerpt', get_the_ID() ) ); ?></textarea>
 
818
  <?php
819
 
820
  }
821
 
 
 
 
 
 
 
 
822
  function wpsc_product_gallery( $post ) {
 
823
  $upload_iframe_src = esc_url( get_upload_iframe_src( 'image', $post->ID ) );
824
+ ?>
825
+ <p class="hide-if-no-js"><a title="<? esc_attr_e( 'Add product gallery images', 'wpsc' ); ?>" href="<?php echo $upload_iframe_src; ?>" id="wpsc-manage-product-gallery" class="thickbox"><?php esc_html_e( 'Add product gallery images', 'wpsc' ); ?></a></p>
826
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
827
  }
828
 
 
829
  function wpsc_product_download_forms() {
830
  global $post, $wpdb, $wpsc_product_defaults;
831
  $product_data = get_post_custom( $post->ID );
832
  $output = '';
833
+ $product_data['meta'] = $product_meta = array();
 
834
  if ( !empty( $product_data['_wpsc_product_metadata'] ) )
835
+ $product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
836
 
837
  $upload_max = wpsc_get_max_upload_size();
838
  ?>
839
  <?php echo wpsc_select_product_file( $post->ID ); ?>
840
+ <h4><a href="admin.php?wpsc_admin_action=product_files_existing&amp;product_id=<?php echo $post->ID; ?>" class="thickbox" title="<?php echo esc_attr( sprintf( __( 'Select all downloadable files for %s', 'wpsc' ), $post->post_title ) ); ?>"><?php esc_html_e( 'Select from existing files', 'wpsc' ); ?></a></h4>
841
+ <a name="wpsc_downloads"></a>
842
+ <h4><?php esc_html_e( 'Upload New File', 'wpsc' ); ?>:</h4>
843
+ <input type='file' name='file' value='' /><br /><?php esc_html_e( 'Max Upload Size ', 'wpsc' ); ?>:<span><?php echo $upload_max; ?></span><span><?php esc_html_e( ' - Choose your file, then update this product to save the download.', 'wpsc' ); ?></span><br /><br />
 
 
 
 
844
 
845
  <?php
846
  if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
847
  ?>
848
+ <br />
849
+ <h4><?php esc_html_e( 'Select an MP3 file to upload as a preview', 'wpsc' ) ?></h4>
850
+ <input type='file' name='preview_file' value='' /><br />
851
 
852
+ <h4><?php esc_html_e( 'Your preview for this product', 'wpsc' ) ?>:</h4>
853
 
854
+ <?php
855
  $args = array(
856
  'post_type' => 'wpsc-preview-file',
857
  'post_parent' => $post->ID,
859
  'post_status' => 'all'
860
  );
861
 
862
+ $preview_files = (array)get_posts( $args );
863
 
864
+ foreach ($preview_files as $preview)
865
  echo $preview->post_title . '<br />';
 
 
866
  ?>
867
+ <br />
868
+ <?php
869
  }
 
870
  $output = apply_filters( 'wpsc_downloads_metabox', $output );
871
  }
872
 
873
  /**
874
+ * Adding function to change text for media buttons
 
 
875
  */
876
+ function change_context( $context ) {
877
+ $current_screen = get_current_screen();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
878
 
879
+ if ( $current_screen->id != 'wpsc-product' )
880
+ return $context;
881
+ return __( 'Upload Image%s', 'wpsc' );
882
  }
883
+ function change_link( $link ) {
884
+ global $post_ID;
885
+ $current_screen = get_current_screen();
886
+ if ( $current_screen && $current_screen->id != 'wpsc-product' )
887
+ return $link;
888
 
889
+ $uploading_iframe_ID = $post_ID;
890
+ $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
891
 
892
+ return $media_upload_iframe_src . "&amp;type=image&parent_page=wpsc-edit-products";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
893
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
894
  function wpsc_form_multipart_encoding() {
895
  echo ' enctype="multipart/form-data"';
896
  }
897
 
898
  add_action( 'post_edit_form_tag', 'wpsc_form_multipart_encoding' );
899
 
900
+ if ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) ) {
901
+ add_filter( 'media_buttons_context', 'change_context' );
902
+ add_filter( 'image_upload_iframe_src', "change_link" );
903
+ }
904
+
905
  /*
906
  * Modifications to Media Gallery
907
  */
1032
 
1033
  }
1034
  function wpsc_save_attachment_fields( $post, $attachment ) {
1035
+ if ( isset ( $attachment['wpsc_custom_thumb_w'] ) )
 
1036
  update_post_meta( $post['ID'], '_wpsc_custom_thumb_w', $attachment['wpsc_custom_thumb_w'] );
 
1037
 
1038
+ if ( isset ( $attachment['wpsc_custom_thumb_h'] ) )
1039
  update_post_meta( $post['ID'], '_wpsc_custom_thumb_h', $attachment['wpsc_custom_thumb_h'] );
 
1040
 
1041
+ if ( isset ( $attachment['wpsc_image_size'] ) )
1042
  update_post_meta( $post['ID'], '_wpsc_selected_image_size', $attachment['wpsc_image_size'] );
 
1043
 
1044
  return $post;
1045
  }
1046
 
1047
  /**
1048
+ * wpsc_save_quickedit_box function
1049
+ * Saves input for the various meta in the quick edit boxes
 
1050
  *
1051
+ * @todo UI
1052
+ * @todo Data validation / sanitization / security
1053
+ * @todo AJAX should probably return weight unit
1054
+ * @return $post_id (int) Post ID
 
1055
  */
 
1056
 
1057
+ function wpsc_save_quickedit_box( $post_id ) {
1058
  global $doaction;
1059
 
1060
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || get_post_type( $post_id ) != 'wpsc-product' )
 
1061
  return;
 
1062
 
1063
+ $bulk = isset( $doaction ) && $doaction =='edit';
1064
 
 
1065
  $custom_fields = array(
1066
+ 'weight' => 'product_metadata',
1067
+ 'stock' => 'stock',
1068
+ 'price' => 'price',
1069
  'sale_price' => 'special_price',
1070
+ 'sku' => 'sku',
1071
  );
1072
 
1073
+ $args = array(
1074
+ 'post_parent' => $post_id,
1075
+ 'post_type' => 'wpsc-product',
1076
+ 'post_status' => 'inherit'
1077
+ );
1078
+ $children = get_children($args);
1079
+ $is_parent = (bool)$children;
 
1080
  foreach ( $custom_fields as $post_key => $meta_key ) {
1081
+ $overideVariant = isset($_REQUEST[$post_key.'_variant']) && $_REQUEST[$post_key.'_variant'] == 'on';
1082
+ // don't update if we're bulk updating and the field is left blank, or if the product has children and the field is one of those fields defined below (unles overridden)
1083
+ if ( ! isset( $_REQUEST[$post_key] ) || ( $bulk && empty( $_REQUEST[$post_key] ) ) ||
1084
+ ( $is_parent && in_array( $post_key, array( 'weight', 'stock', 'price', 'special_price' )) && !$overideVariant ) ){
 
 
 
 
 
1085
  continue;
1086
  }
1087
 
1088
+ if($is_parent && count($children) >0){
1089
+ $products = $children;
1090
+ }else{
1091
+ $products = array($post_id);
 
1092
  }
1093
 
1094
+ foreach($products as $product){
1095
+ $value = $_REQUEST[$post_key];
1096
+ if($is_parent) $post_id = $product->ID;
1097
+ else $post_id = $product;
1098
  switch ( $post_key ) {
 
1099
  case 'weight':
1100
  $product_meta = get_post_meta( $post_id, '_wpsc_product_metadata', true );
1101
+ if ( ! is_array( $product_meta ) )
1102
  $product_meta = array();
1103
+ // draft products don't have product metadata set yet
1104
+ $weight_unit = isset( $product_meta["weight_unit"] ) ? $product_meta["weight_unit"] : 'pound';
1105
+ $weight = wpsc_convert_weight( $value, $weight_unit, "pound", true );
1106
 
1107
+ if ( isset( $product_meta["weight"] ) )
1108
+ unset( $product_meta["weight"] );
 
1109
 
1110
+ $product_meta["weight"] = $weight;
 
 
 
 
1111
 
1112
  $value = $product_meta;
1113
  break;
1114
 
1115
  case 'stock':
1116
+ if ( ! is_numeric( $value ) )
1117
  $value = '';
 
1118
  break;
1119
 
1120
  case 'sku':
1121
+ if ( $value == __( 'N/A', 'wpsc' ) )
1122
  $value = '';
 
1123
  break;
 
1124
  }
1125
 
1126
  update_post_meta( $post_id, "_wpsc_{$meta_key}", $value );
1128
  }
1129
 
1130
  return $post_id;
 
1131
  }
1132
 
1133
  /**
1147
  ?>
1148
 
1149
  <fieldset class="inline-edit-col-left wpsc-cols">
1150
+ <div class="inline-edit-col">
1151
+ <div class="inline-edit-group">
1152
  <?php
1153
  switch ( $col_name ) :
1154
  case 'SKU' :
1155
  ?>
1156
+ <label style="max-width: 85%" class="alignleft">
1157
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'SKU:', 'wpsc' ); ?> </span>
1158
+ <input type="text" name="sku" class="wpsc_ie_sku" />
1159
  <input type="checkbox" name="sku_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1160
 
1161
+ </label>
1162
+ <?php
1163
  break;
1164
  case 'weight' :
1165
  ?>
1166
+ <label style="max-width: 85%" class="alignleft">
1167
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Weight:', 'wpsc' ); ?> </span>
1168
+ <input type="text" name="weight" class="wpsc_ie_weight" />
1169
  <input type="checkbox" name="weight_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1170
+ </label>
1171
+ <?php
1172
  break;
1173
  case 'stock' :
1174
  ?>
1175
+ <label style="max-width: 85%" class="alignleft">
1176
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Stock:', 'wpsc' ); ?> </span>
1177
+ <input type="text" name="stock" class="wpsc_ie_stock" />
1178
  <input type="checkbox" name="stock_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1179
+ </label>
1180
+ <?php
1181
  break;
1182
  case 'price' :
1183
  ?>
1184
+ <label style="max-width: 85%" class="alignleft">
1185
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Price:', 'wpsc' ); ?> </span>
1186
+ <input type="text" name="price" class="wpsc_ie_price" />
1187
  <input type="checkbox" name="price_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1188
+ </label>
1189
+ <?php
1190
  break;
1191
  case 'sale_price' :
1192
  ?>
1193
+ <label style="max-width: 85%" class="alignleft">
1194
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Sale Price:', 'wpsc' ); ?> </span>
1195
+ <input type="text" name="sale_price" class="wpsc_ie_sale_price" />
1196
  <input type="checkbox" name="sale_price_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1197
+ </label>
1198
+ <?php
1199
  break;
1200
  endswitch;
1201
  ?>
1202
+ </div>
1203
+ </div>
1204
  </fieldset>
1205
  <?php
1206
  }
1254
  } else{
1255
  ?>
1256
  <tr class="form-field">
1257
+ <th scope="row" valign="top">
1258
  <label for="variation_price"><?php esc_html_e( 'Variation Price', 'wpsc' ); ?></label>
1259
+ </th>
1260
+ <td>
1261
  <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
1262
  <span class="description"><?php esc_html_e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
1263
+ </td>
1264
  </tr>
1265
  <?php
1266
  }
1322
 
1323
  /**
1324
  * @todo - Should probably refactor this at some point - very procedural,
1325
+ * WAY too many foreach loops for my liking :) But it does the trick
1326
  *
1327
  * @param <type> $term_id
1328
  */
1341
  // Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
1342
  if ( isset( $_POST["apply_to_current"] ) ) {
1343
 
1344
+ //Check for flat, percentile or differential
1345
+ $var_price_type = '';
1346
+
1347
+ if ( flat_price( $_POST["variation_price"] ) )
1348
+ $var_price_type = 'flat';
1349
+ elseif ( differential_price( $_POST["variation_price"] ) )
1350
+ $var_price_type = 'differential';
1351
+ elseif ( percentile_price( $_POST["variation_price"] ) )
1352
+ $var_price_type = 'percentile';
1353
+
1354
  //Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
1355
  $products_to_mod = get_objects_in_term( $term_id, "wpsc-variation" );
1356
  $product_parents = array( );
1412
  }
1413
  }
1414
  add_action( 'before_delete_post', 'wpsc_delete_variations' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/includes/product-functions.php CHANGED
@@ -18,10 +18,13 @@ function wpsc_get_max_upload_size(){
18
  * @return nothing
19
  */
20
  function wpsc_admin_submit_product( $post_ID, $post ) {
 
 
 
 
21
 
22
- if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $post->post_type != 'wpsc-product' ) {
23
  return;
24
- }
25
 
26
  //Type-casting ( not so much sanitization, which would be good to do )
27
  $post_data = stripslashes_deep( $_POST );
@@ -33,7 +36,6 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
33
  $post_data['meta'] = (array) $_POST['meta'];
34
  }
35
 
36
-
37
  if ( isset( $post_data['meta']['_wpsc_price'] ) )
38
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
39
 
@@ -44,10 +46,10 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
44
  $post_data['meta']['_wpsc_sku'] = '';
45
  }
46
 
47
- // Update donation setting
48
- if ( isset( $post_data['wpsc_product_pricing_nonce'] ) && wp_verify_nonce( $post_data['wpsc_product_pricing_nonce'], 'update' ) ) {
49
- $post_data['meta']['_wpsc_is_donation'] = isset( $post_data['meta']['_wpsc_is_donation'] ) ? 1 : 0;
50
- }
51
 
52
  if ( ! isset( $post_data['meta']['_wpsc_limited_stock'] ) ){
53
  $post_data['meta']['_wpsc_stock'] = false;
@@ -56,33 +58,17 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
56
  }
57
 
58
  unset($post_data['meta']['_wpsc_limited_stock']);
59
- if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
 
 
60
  if(!isset($post_data['special'])) $post_data['special'] = '';
 
61
 
 
 
62
  $post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
63
  $post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
64
-
65
- // Update Stock Options
66
- if ( isset( $_POST['wpsc_product_stock_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_stock_nonce'], 'update' ) ) {
67
-
68
- $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
69
- 'notify_when_none_left' => 0,
70
- 'unpublish_when_none_left' => 0
71
- ) );
72
- $post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'] );
73
- $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] );
74
-
75
- }
76
-
77
- // Update shipping setting
78
- if ( isset( $_POST['wpsc_product_shipping_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_shipping_nonce'], 'update' ) ) {
79
-
80
- $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
81
- 'no_shipping' => 0
82
- ) );
83
- $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] );
84
-
85
- }
86
 
87
  // Product Weight
88
  if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
@@ -104,29 +90,20 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
104
  }
105
  }
106
 
107
- // Update the table rate prices (quantity discounts)
108
- if ( isset( $post_data['wpsc-update-quantity-discounts'] ) && wp_verify_nonce( $post_data['wpsc-update-quantity-discounts'], 'update-options' ) ) {
109
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
110
 
111
- // If table_rate_price is empty, set empty table rate price arrays
112
- if ( empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] ) ) {
113
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
114
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
115
- }
116
 
117
- // Remove any rates with no quantity or price
118
- if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
119
- foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] as $key => $value ) {
120
- if ( empty( $value ) ) {
121
- unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][ $key ] );
122
- unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][ $key ] );
123
- }
124
- }
125
- foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ) {
126
- if ( empty( $value ) ) {
127
- unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][ $key ] );
128
- unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][ $key ] );
129
- }
130
  }
131
  }
132
  }
@@ -136,68 +113,27 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
136
  $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] );
137
  }
138
 
139
- // Update product taxes
140
- if ( isset( $_POST['wpsc_product_tax_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_tax_nonce'], 'update' ) ) {
141
-
142
- $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
143
- 'wpec_taxes_taxable_amount' => '',
144
- 'wpec_taxes_taxable' => ''
145
- ) );
146
- if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] ) ) {
147
- $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] = wpsc_string_to_float($post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] );
148
- }
149
- $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable'] = $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable'];
150
-
151
- }
152
-
153
- // External Link Options
154
- if ( isset( $_POST['wpsc_product_external_link_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_external_link_nonce'], 'update' ) ) {
155
-
156
- // Parse post meta to ensure default values
157
- $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
158
- 'external_link' => '',
159
- 'external_link_text' => '',
160
- 'external_link_target' => ''
161
- ) );
162
-
163
- }
164
 
165
  // Advanced Options
166
- if ( isset( $_POST['wpsc_product_personalization_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_personalization_nonce'], 'update' ) ) {
167
-
168
- // Parse post meta to ensure default values (especially checkboxes)
169
- $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
170
- 'engraved' => 0,
171
- 'can_have_uploaded_image' => 0
172
- ) );
173
-
174
- $post_data['meta']['_wpsc_product_metadata']['engraved'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['engraved'] );
175
- $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] );
176
 
 
 
 
 
177
  }
178
 
179
  if ( ! isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
180
  $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
181
 
182
- // Fill in any missing meta values with existing values.
183
- $post_data['meta'] = wp_parse_args( $post_data['meta'], array(
184
- '_wpsc_is_donation' => get_product_meta( $product_id, 'is_donation', true )
185
- ) );
186
-
187
- // Fill in any missing product meta values with existing values.
188
- $default_meta_values = wp_parse_args( get_product_meta( $product_id, 'product_metadata', true ), array(
189
- 'notify_when_none_left' => 0,
190
- 'unpublish_when_none_left' => 0,
191
- 'no_shipping' => 0,
192
- 'external_link' => '',
193
- 'external_link_text' => '',
194
- 'external_link_target' => '',
195
- 'engraved' => 0,
196
- 'can_have_uploaded_image' => 0
197
- ) );
198
-
199
- $post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], $default_meta_values );
200
-
201
  $post_data['files'] = $_FILES;
202
 
203
  if(isset($post_data['post_title']) && $post_data['post_title'] != '') {
@@ -227,12 +163,16 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
227
  'thumbnail_state' => null
228
  );
229
 
230
- foreach ( $product_columns as $column => $default ) {
231
- if ( ! isset( $post_data[ $column ] ) ) {
232
- $post_data[ $column ] = '';
 
 
 
 
 
233
  }
234
  }
235
-
236
  // if we succeed, we can do further editing (todo - if_wp_error)
237
 
238
  // if we have no categories selected, assign one.
@@ -246,21 +186,14 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
246
  // and the custom meta
247
  wpsc_update_custom_meta($product_id, $post_data);
248
 
249
-
250
- // Update the alternative currencies
251
- if ( isset( $post_data['wpsc-update-currency-layers'] ) && wp_verify_nonce( $post_data['wpsc-update-currency-layers'], 'update-options' ) ) {
252
-
253
- // Clear currencies before re-saving to make sure deleted currencies are removed
254
- update_product_meta( $product_id, 'currency', array() );
255
-
256
- if ( ! empty( $post_data['newCurrency'] ) ) {
257
- foreach( (array) $post_data['newCurrency'] as $key =>$value ) {
258
- wpsc_update_alt_product_currency( $product_id, $value, $post_data['newCurrPrice'][ $key ] );
259
- }
260
  }
261
  }
262
 
263
- if ( isset( $post_data['files']['file'] ) && $post_data['files']['file']['tmp_name'] != '' ) {
264
  wpsc_item_process_file($product_id, $post_data['files']['file']);
265
  } else {
266
  if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
@@ -290,11 +223,10 @@ function wpsc_pre_update( $data , $postarr ) {
290
  $data['post_status'] = 'inherit';
291
  }
292
 
293
- if ( ! empty( $postarr['meta'] ) && ( ! isset( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) || $postarr['meta']['_wpsc_product_metadata']['enable_comments'] == 0 || empty( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) ) ) {
294
- $data["comment_status"] = "closed";
295
- } else {
296
- $data["comment_status"] = "open";
297
- }
298
 
299
  //Can anyone explain to me why this is here?
300
  if ( isset( $sku ) && ( $sku != '' ) )
@@ -370,6 +302,7 @@ function wpsc_sanitise_product_forms($post_data = null) {
370
 
371
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
372
  $post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
 
373
  if (!isset($post_data['meta']['_wpsc_is_donation'])) $post_data['meta']['_wpsc_is_donation'] = '';
374
  $post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
375
  $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
@@ -441,9 +374,14 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
441
  );
442
 
443
 
444
- foreach ( $product_columns as $column => $default ) {
445
- if ( ! isset( $post_data[ $column ] ) ) {
446
- $post_data[ $column ] = '';
 
 
 
 
 
447
  }
448
  }
449
 
@@ -470,7 +408,13 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
470
  }else {
471
  unstick_post($product_id);
472
  }
473
-
 
 
 
 
 
 
474
  $adding = true;
475
 
476
  // if we succeed, we can do further editing
@@ -512,7 +456,7 @@ function term_id_price($term_id, $parent_price) {
512
  }
513
 
514
  if (strchr($price, '-') ) {
515
- $positive = false;
516
  } else {
517
  $positive = true;
518
  }
@@ -604,7 +548,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
604
  if (!isset($post_data['edit_var_val']))
605
  $post_data['edit_var_val'] = '';
606
 
607
- $variations = (array) $post_data['edit_var_val'];
608
 
609
  // Generate the arrays for variation sets, values and combinations
610
  $wpsc_combinator = new wpsc_variation_combinator($variations);
@@ -622,7 +566,6 @@ function wpsc_edit_product_variations($product_id, $post_data) {
622
 
623
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
624
  $variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
625
-
626
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
627
 
628
  $parent_id = $_REQUEST['product_id'];
@@ -717,8 +660,6 @@ function wpsc_edit_product_variations($product_id, $post_data) {
717
  $currently_associated_vars[] = $current->term_id;
718
  }
719
 
720
- $posted_terms = array();
721
-
722
  foreach ($posted_term as $term=>$val) {
723
  $posted_terms[] = $term;
724
  if(is_array($val)) {
@@ -727,20 +668,14 @@ function wpsc_edit_product_variations($product_id, $post_data) {
727
  }
728
  }
729
  }
730
-
731
  if(!empty($currently_associated_vars)){
732
  $term_ids_to_delete = array();
733
  $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
734
  }
735
-
736
- if(isset($_REQUEST["post_ID"])) {
737
  $post_id = $_REQUEST["post_ID"];
738
- } elseif(isset($_REQUEST["product_id"])) {
739
  $post_id = $_REQUEST["product_id"];
740
- } else {
741
- return;
742
- }
743
-
744
  if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
745
  $post_ids_to_delete = array();
746
 
@@ -774,8 +709,6 @@ function wpsc_edit_product_variations($product_id, $post_data) {
774
  }
775
  }
776
  }
777
- _wpsc_refresh_parent_product_terms( $parent_id );
778
-
779
  }
780
 
781
  function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
@@ -830,14 +763,14 @@ function wpsc_ajax_toggle_publish() {
830
 
831
  function wpsc_update_custom_meta($product_id, $post_data) {
832
 
833
- if ( isset( $post_data['new_custom_meta'] ) && $post_data['new_custom_meta'] != null ) {
834
  foreach((array)$post_data['new_custom_meta']['name'] as $key => $name) {
835
  $value = $post_data['new_custom_meta']['value'][(int)$key];
836
  if(($name != '') && ($value != '')) {
837
  add_post_meta($product_id, $name, $value);
838
  }
839
  }
840
- }
841
 
842
  if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
843
  if($post_data['custom_meta'] != null) {
@@ -856,40 +789,44 @@ function wpsc_update_custom_meta($product_id, $post_data) {
856
  * @param array the file array from $_FILES
857
  * @param array the preview file array from $_FILES
858
  */
859
- function wpsc_item_process_file( $product_id, $submitted_file, $preview_file = null ) {
860
-
861
- add_filter( 'upload_dir', 'wpsc_modify_upload_directory' );
862
-
863
- $time = current_time( 'mysql' );
864
 
865
- if ( $post = get_post( $product_id ) ) {
 
866
  if ( substr( $post->post_date, 0, 4 ) > 0 )
867
  $time = $post->post_date;
868
  }
869
 
870
- $file = wp_handle_upload( $submitted_file, array( 'test_form' => false ), $time );
871
-
872
- if ( isset( $file['error'] ) ) {
873
  return new WP_Error( 'upload_error', $file['error'] );
874
- }
875
 
876
- $name_parts = pathinfo( $file['file'] );
 
 
 
 
 
 
 
877
 
878
  // Construct the attachment array
879
  $attachment = array(
880
- 'post_mime_type' => $file['type'],
881
- 'guid' => $file['url'],
882
- 'post_parent' => $product_id,
883
- 'post_title' => $name_parts['basename'],
884
- 'post_content' => '',
885
- 'post_type' => 'wpsc-product-file',
886
- 'post_status' => 'inherit'
887
  );
888
 
889
  // Save the data
890
- wp_insert_post( $attachment );
891
-
892
- remove_filter( 'upload_dir', 'wpsc_modify_upload_directory' );
893
  }
894
 
895
  function wpsc_modify_upload_directory($input) {
@@ -931,8 +868,7 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
931
  'post_status' => 'any'
932
  );
933
 
934
- $attached_files = (array) get_posts( $args );
935
- $attached_files_by_file = array();
936
 
937
  foreach($attached_files as $key => $attached_file) {
938
  $attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
18
  * @return nothing
19
  */
20
  function wpsc_admin_submit_product( $post_ID, $post ) {
21
+ if ( ! is_admin() )
22
+ return;
23
+
24
+ global $wpdb;
25
 
26
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $post->post_type != 'wpsc-product' )
27
  return;
 
28
 
29
  //Type-casting ( not so much sanitization, which would be good to do )
30
  $post_data = stripslashes_deep( $_POST );
36
  $post_data['meta'] = (array) $_POST['meta'];
37
  }
38
 
 
39
  if ( isset( $post_data['meta']['_wpsc_price'] ) )
40
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
41
 
46
  $post_data['meta']['_wpsc_sku'] = '';
47
  }
48
 
49
+ if( isset( $post_data['meta']['_wpsc_is_donation'] ) )
50
+ $post_data['meta']['_wpsc_is_donation'] = 1;
51
+ else
52
+ $post_data['meta']['_wpsc_is_donation'] = 0;
53
 
54
  if ( ! isset( $post_data['meta']['_wpsc_limited_stock'] ) ){
55
  $post_data['meta']['_wpsc_stock'] = false;
58
  }
59
 
60
  unset($post_data['meta']['_wpsc_limited_stock']);
61
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'] = 0;
62
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
63
+ if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
64
  if(!isset($post_data['special'])) $post_data['special'] = '';
65
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
66
 
67
+ $post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'];
68
+ $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
69
  $post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
70
  $post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
71
+ $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  // Product Weight
74
  if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
90
  }
91
  }
92
 
93
+ // table rate price
94
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
 
95
 
96
+ // if table_rate_price is unticked, wipe the table rate prices
97
+ if ( empty( $post_data['table_rate_price']['state'] ) ) {
98
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
99
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
100
+ }
101
 
102
+ if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
103
+ foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ){
104
+ if(empty($value)){
105
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
106
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
 
 
 
 
 
 
 
 
107
  }
108
  }
109
  }
113
  $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] );
114
  }
115
 
116
+ if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] ) )
117
+ $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] = wpsc_string_to_float(
118
+ $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount']
119
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  // Advanced Options
122
+ if ( isset( $post_data['meta']['_wpsc_product_metadata']['engraved'] ) ) {
123
+ $post_data['meta']['_wpsc_product_metadata']['engraved'] = (int) (bool) $post_data['meta']['_wpsc_product_metadata']['engraved'];
124
+ } else {
125
+ $post_data['meta']['_wpsc_product_metadata']['engraved'] = 0;
126
+ }
 
 
 
 
 
127
 
128
+ if ( isset( $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] ) ) {
129
+ $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int) (bool) $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
130
+ } else {
131
+ $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = 0;
132
  }
133
 
134
  if ( ! isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
135
  $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  $post_data['files'] = $_FILES;
138
 
139
  if(isset($post_data['post_title']) && $post_data['post_title'] != '') {
163
  'thumbnail_state' => null
164
  );
165
 
166
+ foreach($product_columns as $column => $default)
167
+ {
168
+ if (!isset($post_data[$column])) $post_data[$column] = '';
169
+
170
+ if($post_data[$column] !== null) {
171
+ $update_values[$column] = $post_data[$column];
172
+ } else if(($update != true) && ($default !== null)) {
173
+ $update_values[$column] = ($default);
174
  }
175
  }
 
176
  // if we succeed, we can do further editing (todo - if_wp_error)
177
 
178
  // if we have no categories selected, assign one.
186
  // and the custom meta
187
  wpsc_update_custom_meta($product_id, $post_data);
188
 
189
+ //and the alt currency
190
+ if ( ! empty( $post_data['newCurrency'] ) ) {
191
+ foreach( (array) $post_data['newCurrency'] as $key =>$value ){
192
+ wpsc_update_alt_product_currency( $product_id, $value, $post_data['newCurrPrice'][$key] );
 
 
 
 
 
 
 
193
  }
194
  }
195
 
196
+ if($post_data['files']['file']['tmp_name'] != '') {
197
  wpsc_item_process_file($product_id, $post_data['files']['file']);
198
  } else {
199
  if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
223
  $data['post_status'] = 'inherit';
224
  }
225
 
226
+ if ( !empty( $postarr['meta'] ) && ( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] == 0 || empty( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) ) )
227
+ $data["comment_status"] = "closed";
228
+ else
229
+ $data["comment_status"] = "open";
 
230
 
231
  //Can anyone explain to me why this is here?
232
  if ( isset( $sku ) && ( $sku != '' ) )
302
 
303
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
304
  $post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
305
+ $post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
306
  if (!isset($post_data['meta']['_wpsc_is_donation'])) $post_data['meta']['_wpsc_is_donation'] = '';
307
  $post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
308
  $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
374
  );
375
 
376
 
377
+ foreach($product_columns as $column => $default)
378
+ {
379
+ if (!isset($post_data[$column])) $post_data[$column] = '';
380
+
381
+ if($post_data[$column] !== null) {
382
+ $update_values[$column] = $post_data[$column];
383
+ } else if(($update != true) && ($default !== null)) {
384
+ $update_values[$column] = $default;
385
  }
386
  }
387
 
408
  }else {
409
  unstick_post($product_id);
410
  }
411
+ if ($product_id == 0 ) {
412
+ if ( $wp_error ) {
413
+ return new WP_Error('db_insert_error', __( 'Could not insert product into the database', 'wpsc' ), $wpdb->last_error);
414
+ } else {
415
+ return 0;
416
+ }
417
+ }
418
  $adding = true;
419
 
420
  // if we succeed, we can do further editing
456
  }
457
 
458
  if (strchr($price, '-') ) {
459
+ $negative = true;
460
  } else {
461
  $positive = true;
462
  }
548
  if (!isset($post_data['edit_var_val']))
549
  $post_data['edit_var_val'] = '';
550
 
551
+ $variations = (array)$post_data['edit_var_val'];
552
 
553
  // Generate the arrays for variation sets, values and combinations
554
  $wpsc_combinator = new wpsc_variation_combinator($variations);
566
 
567
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
568
  $variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
 
569
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
570
 
571
  $parent_id = $_REQUEST['product_id'];
660
  $currently_associated_vars[] = $current->term_id;
661
  }
662
 
 
 
663
  foreach ($posted_term as $term=>$val) {
664
  $posted_terms[] = $term;
665
  if(is_array($val)) {
668
  }
669
  }
670
  }
 
671
  if(!empty($currently_associated_vars)){
672
  $term_ids_to_delete = array();
673
  $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
674
  }
675
+ if(isset($_REQUEST["post_ID"]))
 
676
  $post_id = $_REQUEST["post_ID"];
677
+ elseif(isset($_REQUEST["product_id"]))
678
  $post_id = $_REQUEST["product_id"];
 
 
 
 
679
  if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
680
  $post_ids_to_delete = array();
681
 
709
  }
710
  }
711
  }
 
 
712
  }
713
 
714
  function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
763
 
764
  function wpsc_update_custom_meta($product_id, $post_data) {
765
 
766
+ if($post_data['new_custom_meta'] != null) {
767
  foreach((array)$post_data['new_custom_meta']['name'] as $key => $name) {
768
  $value = $post_data['new_custom_meta']['value'][(int)$key];
769
  if(($name != '') && ($value != '')) {
770
  add_post_meta($product_id, $name, $value);
771
  }
772
  }
773
+ }
774
 
775
  if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
776
  if($post_data['custom_meta'] != null) {
789
  * @param array the file array from $_FILES
790
  * @param array the preview file array from $_FILES
791
  */
792
+ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = null) {
793
+ global $wpdb;
794
+ add_filter('upload_dir', 'wpsc_modify_upload_directory');
795
+ $overrides = array('test_form'=>false);
 
796
 
797
+ $time = current_time('mysql');
798
+ if ( $post = get_post($product_id) ) {
799
  if ( substr( $post->post_date, 0, 4 ) > 0 )
800
  $time = $post->post_date;
801
  }
802
 
803
+ $file = wp_handle_upload($submitted_file, $overrides, $time);
804
+ if ( isset($file['error']) )
 
805
  return new WP_Error( 'upload_error', $file['error'] );
 
806
 
807
+ $name_parts = pathinfo($file['file']);
808
+ $name = $name_parts['basename'];
809
+
810
+ $url = $file['url'];
811
+ $type = $file['type'];
812
+ $file = $file['file'];
813
+ $title = $name;
814
+ $content = '';
815
 
816
  // Construct the attachment array
817
  $attachment = array(
818
+ 'post_mime_type' => $type,
819
+ 'guid' => $url,
820
+ 'post_parent' => $product_id,
821
+ 'post_title' => $title,
822
+ 'post_content' => $content,
823
+ 'post_type' => "wpsc-product-file",
824
+ 'post_status' => 'inherit'
825
  );
826
 
827
  // Save the data
828
+ $id = wp_insert_post($attachment, $file, $product_id);
829
+ remove_filter('upload_dir', 'wpsc_modify_upload_directory');
 
830
  }
831
 
832
  function wpsc_modify_upload_directory($input) {
868
  'post_status' => 'any'
869
  );
870
 
871
+ $attached_files = (array)get_posts($args);
 
872
 
873
  foreach($attached_files as $key => $attached_file) {
874
  $attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
wpsc-admin/includes/product-variation-list-table.class.php CHANGED
@@ -3,11 +3,6 @@
3
  require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
4
  require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' );
5
 
6
- /**
7
- * Product Variation List Table class
8
- *
9
- * @package wp-e-commerce
10
- */
11
  class WPSC_Product_Variation_List_Table extends WP_List_Table {
12
  private $product_id;
13
  private $object_terms_cache = array();
@@ -172,14 +167,14 @@ class WPSC_Product_Variation_List_Table extends WP_List_Table {
172
  'post' => $item->ID,
173
  'bulk_action_nonce' => wp_create_nonce( 'wpsc_product_variations_bulk_action' ),
174
  ) );
175
- $actions['show'] = '<a class="wpsc-variation-show-link" href="' . $show_url . '" title="' . __( 'Show this variation on the front-end', 'wpsc' ) . '">' . __( 'Publish', 'wpsc' ) . '</a>';
176
  } elseif ( in_array( $item->post_status, array( 'publish', 'inherit' ) ) ) {
177
  $hide_url = add_query_arg( array(
178
  'bulk_action' => 'hide',
179
  'post' => $item->ID,
180
  'bulk_action_nonce' => wp_create_nonce( 'wpsc_product_variations_bulk_action' ),
181
  ) );
182
- $actions['hide'] = '<a class="wpsc-variation-hide-link" href="' . $hide_url . '" title="' . __( 'Mark this variation as draft to hide from the front-end', 'wpsc' ) . '">' . __( 'Mark as Draft', 'wpsc' ) . '</a>';
183
  }
184
 
185
  if ( current_user_can( $post_type_object->cap->delete_post, $item->ID ) ) {
@@ -197,13 +192,13 @@ class WPSC_Product_Variation_List_Table extends WP_List_Table {
197
  $restore_url
198
  );
199
  $restore_url = wp_nonce_url( $restore_url, 'untrash-post_' . $item->ID );
200
- $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . $restore_url . "'>" . __( 'Restore' ) . "</a>";
201
  } elseif ( EMPTY_TRASH_DAYS ) {
202
- $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . $delete_link . "'>" . __( 'Trash' ) . "</a>";
203
  }
204
 
205
  if ( $force_delete )
206
- $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . $delete_link . "'>" . __( 'Delete Permanently' ) . "</a>";
207
  }
208
 
209
  return $actions;
@@ -418,7 +413,7 @@ class WPSC_Product_Variation_List_Table extends WP_List_Table {
418
  <div id="message" class="updated"><p>
419
  <?php
420
  echo join( ' ', $messages ); unset( $messages );
421
- $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
422
  echo '</p></div>';
423
  }
424
 
@@ -443,7 +438,7 @@ class WPSC_Product_Variation_List_Table extends WP_List_Table {
443
  return $actions;
444
  }
445
 
446
- public function bulk_actions( $which = '' ) {
447
  $screen = get_current_screen();
448
 
449
  if ( is_null( $this->_actions ) ) {
@@ -507,11 +502,11 @@ class WPSC_Product_Variation_List_Table extends WP_List_Table {
507
  $avail_post_stati = get_available_post_statuses( 'wpsc-product' );
508
  $post_type_object = get_post_type_object( 'wpsc-product' );
509
  $post_type = $post_type_object->name;
510
- $url_base = add_query_arg( array(
511
  'action' => 'wpsc_product_variations_table',
512
  'product_id' => $_REQUEST['product_id'],
513
  '_wpnonce' => wp_create_nonce( 'wpsc_product_variations_table' ),
514
- ), admin_url( 'admin-ajax.php' ) );
515
 
516
  if ( !empty($locked_post_status) )
517
  return array();
3
  require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
4
  require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' );
5
 
 
 
 
 
 
6
  class WPSC_Product_Variation_List_Table extends WP_List_Table {
7
  private $product_id;
8
  private $object_terms_cache = array();
167
  'post' => $item->ID,
168
  'bulk_action_nonce' => wp_create_nonce( 'wpsc_product_variations_bulk_action' ),
169
  ) );
170
+ $actions['show'] = '<a class="wpsc-variation-show-link" href="' . esc_url( $show_url ) . '" title="' . __( 'Show this variation on the front-end', 'wpsc' ) . '">' . __( 'Publish', 'wpsc' ) . '</a>';
171
  } elseif ( in_array( $item->post_status, array( 'publish', 'inherit' ) ) ) {
172
  $hide_url = add_query_arg( array(
173
  'bulk_action' => 'hide',
174
  'post' => $item->ID,
175
  'bulk_action_nonce' => wp_create_nonce( 'wpsc_product_variations_bulk_action' ),
176
  ) );
177
+ $actions['hide'] = '<a class="wpsc-variation-hide-link" href="' . esc_url( $hide_url ) . '" title="' . __( 'Mark this variation as draft to hide from the front-end', 'wpsc' ) . '">' . __( 'Mark as Draft', 'wpsc' ) . '</a>';
178
  }
179
 
180
  if ( current_user_can( $post_type_object->cap->delete_post, $item->ID ) ) {
192
  $restore_url
193
  );
194
  $restore_url = wp_nonce_url( $restore_url, 'untrash-post_' . $item->ID );
195
+ $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . esc_url( $restore_url ) . "'>" . __( 'Restore' ) . "</a>";
196
  } elseif ( EMPTY_TRASH_DAYS ) {
197
+ $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . esc_url( $delete_link ) . "'>" . __( 'Trash' ) . "</a>";
198
  }
199
 
200
  if ( $force_delete )
201
+ $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . esc_url( $delete_link ) . "'>" . __( 'Delete Permanently' ) . "</a>";
202
  }
203
 
204
  return $actions;
413
  <div id="message" class="updated"><p>
414
  <?php
415
  echo join( ' ', $messages ); unset( $messages );
416
+ $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ) );
417
  echo '</p></div>';
418
  }
419
 
438
  return $actions;
439
  }
440
 
441
+ public function bulk_actions() {
442
  $screen = get_current_screen();
443
 
444
  if ( is_null( $this->_actions ) ) {
502
  $avail_post_stati = get_available_post_statuses( 'wpsc-product' );
503
  $post_type_object = get_post_type_object( 'wpsc-product' );
504
  $post_type = $post_type_object->name;
505
+ $url_base = esc_url( add_query_arg( array(
506
  'action' => 'wpsc_product_variations_table',
507
  'product_id' => $_REQUEST['product_id'],
508
  '_wpnonce' => wp_create_nonce( 'wpsc_product_variations_table' ),
509
+ ), admin_url( 'admin-ajax.php' ) ) );
510
 
511
  if ( !empty($locked_post_status) )
512
  return array();
wpsc-admin/includes/product-variations-page.class.php CHANGED
@@ -1,15 +1,9 @@
1
  <?php
2
 
3
- /**
4
- * The Product Variations page class in the WordPress admin
5
- *
6
- * @package wp-e-commerce
7
- */
8
-
9
  class WPSC_Product_Variations_Page {
10
  private $list_table;
11
  private $parent_id;
12
- private $current_tab;
13
  private $post;
14
 
15
  public function __construct() {
@@ -18,18 +12,8 @@ class WPSC_Product_Variations_Page {
18
  $this->parent_id = absint( $_REQUEST['product_id'] );
19
  set_current_screen();
20
 
21
- if ( ! empty( $_REQUEST['tab'] ) ) {
22
  $this->current_tab = $_REQUEST['tab'];
23
- } else {
24
- $args = array(
25
- 'post_parent' => $this->parent_id,
26
- 'post_type' => 'wpsc-product',
27
- 'post_status' => 'any');
28
-
29
- $number_of_variations = count(get_children($args));
30
-
31
- $this->current_tab = ($number_of_variations > 0) ? 'manage' : 'setup';
32
- }
33
  }
34
 
35
  private function merge_meta_deep( $original, $updated ) {
@@ -52,49 +36,35 @@ class WPSC_Product_Variations_Page {
52
  return $original;
53
  }
54
 
55
- /* */
56
  private function save_variation_meta( $id, $data ) {
57
-
58
  $product_meta = get_product_meta( $id, 'product_metadata', true );
59
-
60
- if ( ! is_array( $product_meta ) ) {
61
  $product_meta = array();
62
- }
63
-
64
  $product_meta = $this->merge_meta_deep( $product_meta, $data['product_metadata'] );
65
 
66
  // convert to pound to maintain backward compat with shipping modules
67
- if ( isset( $data['product_metadata']['weight'] ) || isset( $data['product_metadata']['weight_unit'] ) ) {
68
  $product_meta['weight'] = wpsc_convert_weight( $product_meta['weight'], $product_meta['weight_unit'], 'pound', true );
69
- }
70
 
71
  update_product_meta( $id, 'product_metadata', $product_meta );
72
 
73
- if ( isset( $data['price'] ) ) {
74
  update_product_meta( $id, 'price', wpsc_string_to_float( $data['price'] ) );
75
- }
76
-
77
- if ( isset( $data['sale_price'] ) ) {
78
-
79
- $sale_price = wpsc_string_to_float( $data['sale_price'] );
80
 
81
- if ( is_numeric( $sale_price ) ) {
 
82
  update_product_meta( $id, 'special_price', wpsc_string_to_float( $data['sale_price'] ) );
83
- } else {
84
  update_product_meta( $id, 'special_price', '' );
85
- }
86
- }
87
 
88
- if ( isset( $data['sku'] ) ) {
89
  update_product_meta( $id, 'sku', $data['sku'] );
90
- }
91
 
92
  if ( isset( $data['stock'] ) ) {
93
- if ( is_numeric( $data['stock'] ) ) {
94
- update_product_meta( $id, 'stock', (int) $data['stock'] );
95
- } else {
96
  update_product_meta( $id, 'stock', '' );
97
- }
98
  }
99
  }
100
 
@@ -107,12 +77,7 @@ class WPSC_Product_Variations_Page {
107
  if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
108
  wp_die( __( 'Cheatin&#8217; uh?' ) );
109
 
110
- /* Long-term, we should have a better saving routine here. Can't unset these currently. *
111
- /* That said, the only thing that fails hard if we can't unset it is the checkbox. */
112
  foreach ( $_REQUEST['wpsc_variations'] as $id => $data ) {
113
- if ( ! isset( $data['product_metadata']['no_shipping'] ) ) {
114
- $data['product_metadata']['no_shipping'] = '';
115
- }
116
  $this->save_variation_meta( $id, $data );
117
  }
118
  }
@@ -152,12 +117,11 @@ class WPSC_Product_Variations_Page {
152
  'manage' => _x( 'Manage', 'manage product variations', 'wpsc' ),
153
  'setup' => __( 'Setup', 'wpsc' ),
154
  );
155
-
156
- echo '<ul id="wpsc-product-variations-tabs" class="category-tabs">';
157
  foreach ( $tabs as $tab => $title ) {
158
- $class = ( $tab == $this->current_tab ) ? ' class="tabs"' : '';
159
  $item = '<li' . $class . '>';
160
- $item .= '<a href="' . add_query_arg( 'tab', $tab ) . '">' . esc_html( $title ) . '</a></li> ';
161
  echo $item;
162
  }
163
  echo '</ul>';
@@ -189,7 +153,7 @@ class WPSC_Product_Variations_Page {
189
  '_wp_http_referer',
190
  'updated',
191
  ) );
192
- wp_redirect( add_query_arg( 'tab', 'manage', $sendback ) );
193
  exit;
194
  }
195
 
@@ -217,7 +181,7 @@ class WPSC_Product_Variations_Page {
217
 
218
  $trashed++;
219
  }
220
- return add_query_arg( array( 'trashed' => $trashed, 'ids' => join( ',', $post_ids ) ) );
221
  }
222
 
223
  public function process_bulk_action_untrash( $post_ids ) {
@@ -232,7 +196,7 @@ class WPSC_Product_Variations_Page {
232
 
233
  $untrashed++;
234
  }
235
- return add_query_arg( 'untrashed', $untrashed );
236
  }
237
 
238
  public function process_bulk_action_delete( $post_ids ) {
@@ -253,7 +217,7 @@ class WPSC_Product_Variations_Page {
253
  }
254
  $deleted++;
255
  }
256
- return add_query_arg( 'deleted', $deleted );
257
  }
258
 
259
  public function process_bulk_action_hide( $post_ids ) {
@@ -265,7 +229,7 @@ class WPSC_Product_Variations_Page {
265
  ) );
266
  $updated ++;
267
  }
268
- return add_query_arg( 'updated', $updated );
269
  }
270
 
271
  public function process_bulk_action_show( $post_ids ) {
@@ -277,7 +241,7 @@ class WPSC_Product_Variations_Page {
277
  ) );
278
  $updated ++;
279
  }
280
- return add_query_arg( 'updated', $updated );
281
  }
282
 
283
  private function save_bulk_edited_items() {
@@ -313,18 +277,12 @@ class WPSC_Product_Variations_Page {
313
  unset( $data['product_metadata']['weight_unit'] );
314
  }
315
 
316
- if ( empty( $fields['measurements']['dimensions'] ) ) {
317
- foreach ( array( 'height', 'width', 'length' ) as $field ) {
318
  unset( $data['product_metadata']['dimensions'][$field] );
319
  unset( $data['product_metadata']['dimensions'][$field . '_unit'] );
320
- }
321
- } else {
322
- foreach ( array( 'height', 'width', 'length' ) as $field ) {
323
- $data['product_metadata']['dimensions'][$field . '_unit'] = "cm";
324
  }
325
  }
326
-
327
- unset( $data['product_metadata']['dimensions_unit'] );
328
  }
329
 
330
  unset( $data['post'] );
@@ -344,7 +302,7 @@ class WPSC_Product_Variations_Page {
344
  'post',
345
  'last_paged'
346
  ), $sendback );
347
- $sendback = add_query_arg( 'updated', count( $ids ), $sendback );
348
  wp_redirect( $sendback );
349
  exit;
350
  }
@@ -376,7 +334,7 @@ class WPSC_Product_Variations_Page {
376
  if ( ! empty( $post_ids ) && is_callable( array( $this, $callback ) ) )
377
  $sendback = $this->$callback( $post_ids );
378
 
379
- $sendback = remove_query_arg( array(
380
  '_wp_http_referer',
381
  'bulk_action',
382
  'bulk_action2',
@@ -384,7 +342,7 @@ class WPSC_Product_Variations_Page {
384
  'confirm',
385
  'post',
386
  'last_paged'
387
- ), $sendback );
388
 
389
  _wpsc_refresh_parent_product_terms( $this->parent_id );
390
  _wpsc_add_refresh_variation_parent_term_hooks();
@@ -420,4 +378,4 @@ function _wpsc_admin_html_begin() {
420
  <head>
421
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
422
  <?php
423
- }
1
  <?php
2
 
 
 
 
 
 
 
3
  class WPSC_Product_Variations_Page {
4
  private $list_table;
5
  private $parent_id;
6
+ private $current_tab = 'manage';
7
  private $post;
8
 
9
  public function __construct() {
12
  $this->parent_id = absint( $_REQUEST['product_id'] );
13
  set_current_screen();
14
 
15
+ if ( ! empty( $_REQUEST['tab'] ) )
16
  $this->current_tab = $_REQUEST['tab'];
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
  private function merge_meta_deep( $original, $updated ) {
36
  return $original;
37
  }
38
 
 
39
  private function save_variation_meta( $id, $data ) {
 
40
  $product_meta = get_product_meta( $id, 'product_metadata', true );
41
+ if ( ! is_array( $product_meta ) )
 
42
  $product_meta = array();
 
 
43
  $product_meta = $this->merge_meta_deep( $product_meta, $data['product_metadata'] );
44
 
45
  // convert to pound to maintain backward compat with shipping modules
46
+ if ( isset( $data['product_metadata']['weight'] ) || isset( $data['product_metadata']['weight_unit'] ) )
47
  $product_meta['weight'] = wpsc_convert_weight( $product_meta['weight'], $product_meta['weight_unit'], 'pound', true );
 
48
 
49
  update_product_meta( $id, 'product_metadata', $product_meta );
50
 
51
+ if ( isset( $data['price'] ) )
52
  update_product_meta( $id, 'price', wpsc_string_to_float( $data['price'] ) );
 
 
 
 
 
53
 
54
+ if ( isset( $data['sale_price'] ) )
55
+ if ( is_numeric( $data['sale_price'] ) )
56
  update_product_meta( $id, 'special_price', wpsc_string_to_float( $data['sale_price'] ) );
57
+ else
58
  update_product_meta( $id, 'special_price', '' );
 
 
59
 
60
+ if ( isset( $data['sku'] ) )
61
  update_product_meta( $id, 'sku', $data['sku'] );
 
62
 
63
  if ( isset( $data['stock'] ) ) {
64
+ if ( is_numeric( $data['stock'] ) )
65
+ update_product_meta( $id, 'stock', absint( $data['stock'] ) );
66
+ else
67
  update_product_meta( $id, 'stock', '' );
 
68
  }
69
  }
70
 
77
  if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
78
  wp_die( __( 'Cheatin&#8217; uh?' ) );
79
 
 
 
80
  foreach ( $_REQUEST['wpsc_variations'] as $id => $data ) {
 
 
 
81
  $this->save_variation_meta( $id, $data );
82
  }
83
  }
117
  'manage' => _x( 'Manage', 'manage product variations', 'wpsc' ),
118
  'setup' => __( 'Setup', 'wpsc' ),
119
  );
120
+ echo '<ul class="wpsc-product-variations-tabs">';
 
121
  foreach ( $tabs as $tab => $title ) {
122
+ $class = ( $tab == $this->current_tab ) ? ' class="active"' : '';
123
  $item = '<li' . $class . '>';
124
+ $item .= '<a href="' . esc_url( add_query_arg( 'tab', $tab ) ) . '">' . esc_html( $title ) . '</a></li>';
125
  echo $item;
126
  }
127
  echo '</ul>';
153
  '_wp_http_referer',
154
  'updated',
155
  ) );
156
+ wp_redirect( esc_url( add_query_arg( 'tab', 'manage', $sendback ) ) );
157
  exit;
158
  }
159
 
181
 
182
  $trashed++;
183
  }
184
+ return esc_url( add_query_arg( array( 'trashed' => $trashed, 'ids' => join( ',', $post_ids ) ) ) );
185
  }
186
 
187
  public function process_bulk_action_untrash( $post_ids ) {
196
 
197
  $untrashed++;
198
  }
199
+ return esc_url( add_query_arg( 'untrashed', $untrashed ) );
200
  }
201
 
202
  public function process_bulk_action_delete( $post_ids ) {
217
  }
218
  $deleted++;
219
  }
220
+ return esc_url( add_query_arg( 'deleted', $deleted ) );
221
  }
222
 
223
  public function process_bulk_action_hide( $post_ids ) {
229
  ) );
230
  $updated ++;
231
  }
232
+ return esc_url( add_query_arg( 'updated', $updated ) );
233
  }
234
 
235
  public function process_bulk_action_show( $post_ids ) {
241
  ) );
242
  $updated ++;
243
  }
244
+ return esc_url( add_query_arg( 'updated', $updated ) );
245
  }
246
 
247
  private function save_bulk_edited_items() {
277
  unset( $data['product_metadata']['weight_unit'] );
278
  }
279
 
280
+ foreach ( array( 'height', 'width', 'length' ) as $field ) {
281
+ if ( empty( $fields['measurements'][$field] ) ) {
282
  unset( $data['product_metadata']['dimensions'][$field] );
283
  unset( $data['product_metadata']['dimensions'][$field . '_unit'] );
 
 
 
 
284
  }
285
  }
 
 
286
  }
287
 
288
  unset( $data['post'] );
302
  'post',
303
  'last_paged'
304
  ), $sendback );
305
+ $sendback = esc_url( add_query_arg( 'updated', count( $ids ), $sendback ) );
306
  wp_redirect( $sendback );
307
  exit;
308
  }
334
  if ( ! empty( $post_ids ) && is_callable( array( $this, $callback ) ) )
335
  $sendback = $this->$callback( $post_ids );
336
 
337
+ $sendback = esc_url( remove_query_arg( array(
338
  '_wp_http_referer',
339
  'bulk_action',
340
  'bulk_action2',
342
  'confirm',
343
  'post',
344
  'last_paged'
345
+ ), $sendback ) );
346
 
347
  _wpsc_refresh_parent_product_terms( $this->parent_id );
348
  _wpsc_add_refresh_variation_parent_term_hooks();
378
  <head>
379
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
380
  <?php
381
+ }
wpsc-admin/includes/product-variations.page.php CHANGED
@@ -30,23 +30,13 @@ var userSettings = {
30
  }
31
  </style>
32
  </head>
33
- <?php
34
-
35
- $admin_body_class = ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );
36
- $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) );
37
- $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
38
- $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
39
-
40
- ?>
41
- <body class="no-js wp-admin wp-core-ui wpsc-product-variation-iframe<?php echo $admin_body_class; ?>">
42
  <script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>
43
 
44
- <div id="post-body">
45
- <div id="wpsc-product-variations-wrapper" class="categorydiv wpsc-categorydiv">
46
- <?php $this->display_tabs(); ?>
47
- <div class="wpsc-product-variations-tab-content tabs-panel">
48
- <?php $this->display_current_tab(); ?>
49
- </div>
50
  </div>
51
  </div>
52
 
30
  }
31
  </style>
32
  </head>
33
+ <body class="no-js wp-admin wp-core-ui wpsc-product-variation-iframe">
 
 
 
 
 
 
 
 
34
  <script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>
35
 
36
+ <div id="wpsc-product-variations-wrapper">
37
+ <?php $this->display_tabs(); ?>
38
+ <div class="wpsc-product-variations-tab-content">
39
+ <?php $this->display_current_tab(); ?>
 
 
40
  </div>
41
  </div>
42
 
wpsc-admin/includes/purchase-log-action-links.php DELETED
@@ -1,482 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Purchase Log Action Links Class
5
- *
6
- * Manages and displays a links of action links when editing a puchase log.
7
- *
8
- * @package wp-e-commerce
9
- * @since 3.9.0
10
- *
11
- * @link https://github.com/wp-e-commerce/WP-e-Commerce/pull/1562
12
- */
13
- class WPSC_Purchase_Log_Action_Links {
14
-
15
- /**
16
- * Purchase Log ID.
17
- *
18
- * @since 3.9.0
19
- * @access private
20
- * @var int
21
- */
22
- protected $log_id;
23
-
24
- /**
25
- * An array of WPSC_Purchase_Log_Action_Link objects.
26
- *
27
- * @since 3.9.0
28
- * @access private
29
- * @var array
30
- */
31
- protected $links;
32
-
33
- /**
34
- * Setup all action links.
35
- *
36
- * @since 3.9.0
37
- *
38
- * @param int $log_id Purchase log ID.
39
- */
40
- public function __construct( $log_id ) {
41
-
42
- $this->log_id = absint( $log_id );
43
-
44
- // Create and validate links.
45
- $this->_create_links();
46
- $this->_validate_links();
47
-
48
- }
49
-
50
- /**
51
- * Create Action Links
52
- *
53
- * Packing slip and email receipt links are available by default.
54
- * Action links are filterable via the 'wpsc_purchlogitem_links' filter which passes the purchase log ID.
55
- * Delete and back links are always required and added after the filter.
56
- *
57
- * @since 3.9.0
58
- * @access private
59
- */
60
- private function _create_links() {
61
-
62
- // Add default links.
63
- if ( wpsc_purchlogs_have_downloads_locked() != false ) {
64
- $this->links[] = $this->get_downloads_lock_link();
65
- }
66
- $this->links[] = $this->get_packing_slip_link();
67
- $this->links[] = $this->get_email_receipt_link();
68
-
69
- // Filter action links.
70
- $this->links = apply_filters( 'wpsc_purchlogitem_links', $this->links, $this->log_id );
71
-
72
- // Add delete and back links.
73
- $this->links[] = $this->_get_delete_link();
74
- $this->links[] = $this->_get_back_link();
75
-
76
- }
77
-
78
- /**
79
- * Validate Links
80
- *
81
- * Validates all links are WPSC_Purchase_Log_Action_Link objects.
82
- *
83
- * @since 3.9.0
84
- * @access private
85
- */
86
- private function _validate_links() {
87
-
88
- $this->links = array_map( array( $this, '_validate_link' ), $this->links );
89
- $this->links = array_filter( $this->links );
90
-
91
- }
92
-
93
- /**
94
- * Validate Link
95
- *
96
- * Validates a WPSC_Purchase_Log_Action_Link object.
97
- *
98
- * @since 3.9.0
99
- * @access private
100
- *
101
- * @todo Check that the WPSC_Purchase_Log_Action_Link ID is unique and reject if not - maybe not here.
102
- *
103
- * @param WPSC_Purchase_Log_Action_Link $action_link Action link object.
104
- * @return WPSC_Purchase_Log_Action_Link|boolean If valid, the action link object, otherwise false.
105
- */
106
- private function _validate_link( $action_link ) {
107
-
108
- if ( is_a( $action_link, 'WPSC_Purchase_Log_Action_Link' ) ) {
109
- return $action_link;
110
- }
111
-
112
- return false;
113
-
114
- }
115
-
116
- /**
117
- * Downloads Lock Action Link
118
- *
119
- * @since 3.9.0
120
- * @access private
121
- *
122
- * @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
123
- */
124
- private function get_downloads_lock_link() {
125
-
126
- return new WPSC_Purchase_Log_Action_Link( 'downloads_lock', wpsc_purchlogs_have_downloads_locked(), $this->log_id, array(
127
- 'ajax' => true,
128
- 'dashicon' => 'dashicons-lock'
129
- ) );
130
-
131
- }
132
-
133
- /**
134
- * View Packing Slip Action Link
135
- *
136
- * @since 3.9.0
137
- * @access private
138
- *
139
- * @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
140
- */
141
- private function get_packing_slip_link() {
142
-
143
- return new WPSC_Purchase_Log_Action_Link( 'packing_slip', __( 'View Packing Slip', 'wpsc' ), $this->log_id, array(
144
- 'url' => esc_url( add_query_arg( array(
145
- 'c' => 'packing_slip',
146
- 'id' => $this->log_id
147
- ) ) ),
148
- 'dashicon' => 'dashicons-format-aside',
149
- 'attributes' => array(
150
- 'target' => 'wpsc_packing_slip'
151
- )
152
- ) );
153
-
154
- }
155
-
156
- /**
157
- * Resend Email Receipt Action Link
158
- *
159
- * @since 3.9.0
160
- * @access private
161
- *
162
- * @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
163
- */
164
- private function get_email_receipt_link() {
165
-
166
- return new WPSC_Purchase_Log_Action_Link( 'email_receipt', __( 'Resend Receipt to Buyer', 'wpsc' ), $this->log_id, array(
167
- 'ajax' => true,
168
- 'dashicon' => 'dashicons-migrate dashicons-email-alt'
169
- ) );
170
-
171
- }
172
-
173
- /**
174
- * Delete Action Link
175
- *
176
- * @since 3.9.0
177
- * @access private
178
- *
179
- * @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
180
- */
181
- private function _get_delete_link() {
182
-
183
- return new WPSC_Purchase_Log_Action_Link( 'delete', _x( 'Remove this record', 'purchase log action link', 'wpsc' ), $this->log_id, array(
184
- 'dashicon' => 'dashicons-dismiss',
185
- 'attributes' => array(
186
- 'onclick' => "if ( confirm('" . esc_js( sprintf( __( "You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete.", 'wpsc' ), wpsc_purchaselog_details_date() ) ) . "') ) { return true; } return false;"
187
- )
188
- ) );
189
-
190
- }
191
-
192
- /**
193
- * Back Action Link
194
- *
195
- * @since 3.9.0
196
- * @access private
197
- *
198
- * @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
199
- */
200
- private function _get_back_link() {
201
-
202
- return new WPSC_Purchase_Log_Action_Link( 'back', _x( 'Go Back', 'purchase log action link', 'wpsc' ), $this->log_id, array(
203
- 'url' => wp_get_referer(),
204
- 'dashicon' => 'dashicons-arrow-left-alt'
205
- ) );
206
-
207
- }
208
-
209
- /**
210
- * Display Link List Items
211
- *
212
- * @since 3.9.0
213
- *
214
- * Outputs action links as a series of list item tags to be included in an HTML list.
215
- */
216
- public function display_link_list_items() {
217
-
218
- foreach ( $this->links as $link ) {
219
- echo '<li>' . $link->get_link_display() . '</li>';
220
- }
221
-
222
- }
223
-
224
- }
225
-
226
- /**
227
- * Purchase Log Action Link Class
228
- *
229
- * Creates, styles and handles a purchase log action link.
230
- *
231
- * @since 3.9.0
232
- */
233
- class WPSC_Purchase_Log_Action_Link {
234
-
235
- /**
236
- * Action Link ID.
237
- *
238
- * @since 3.9.0
239
- * @access private
240
- * @var string
241
- */
242
- private $id;
243
-
244
- /**
245
- * Action Link Title Text.
246
- *
247
- * @since 3.9.0
248
- * @access private
249
- * @var string
250
- */
251
- private $title;
252
-
253
- /**
254
- * Purchase Log ID.
255
- *
256
- * @since 3.9.0
257
- * @access private
258
- * @var int
259
- */
260
- private $log_id;
261
-
262
- /**
263
- * Action Link Settings.
264
- *
265
- * @since 3.9.0
266
- * @access private
267
- * @var array
268
- */
269
- private $args;
270
-
271
- /**
272
- * Define the action link.
273
- *
274
- * @since 3.9.0
275
- *
276
- * @param string $id Action link ID (will be sanitized).
277
- * @param string $title Link text.
278
- * @param array $args Action link settings.
279
- */
280
- public function __construct( $id, $title, $log_id, $args = array() ) {
281
-
282
- $this->id = sanitize_key( $id );
283
- $this->title = $title;
284
- $this->log_id = absint( $log_id );
285
- $this->args = $this->_validate_settings( $args );
286
-
287
- }
288
-
289
- /**
290
- * Validate Settings
291
- *
292
- * Checks settings and adds defaults where required.
293
- *
294
- * The 'attributes' setting allows additional attributes to be added to the link tag if required.
295
- * 'title' and 'href' attributes are removed as these are created via the 'url' and 'description' settings.
296
- *
297
- * Any class attributes are added to the 'wpsc-purchlog-action-{$id}' class we generate.
298
- *
299
- * @since 3.9.0
300
- * @access private
301
- *
302
- * @param array $args Supplied settings.
303
- * @return array Validated settings.
304
- */
305
- private function _validate_settings( $args ) {
306
-
307
- $args = wp_parse_args( $args, array(
308
- 'url' => '',
309
- 'description' => '',
310
- 'dashicon' => '',
311
- 'attributes' => array(),
312
- 'ajax' => false
313
- ) );
314
-
315
- // Use title if no description.
316
- if ( empty( $args['description'] ) ) {
317
- $args['description'] = $this->title;
318
- }
319
-
320
- // Use default arrow dashicon if none specified.
321
- if ( empty( $args['dashicon'] ) ) {
322
- $args['dashicon'] = 'dashicons-arrow-right-alt';
323
- }
324
-
325
- // Remove href and title attributes.
326
- if ( is_array( $args['attributes'] ) ) {
327
- if ( array_key_exists( 'title', $args['attributes'] ) ) {
328
- unset( $args['attributes']['title'] );
329
- }
330
- if ( array_key_exists( 'href', $args['attributes'] ) ) {
331
- unset( $args['attributes']['href'] );
332
- }
333
- } else {
334
- $args['attributes'] = array();
335
- }
336
-
337
- // Add class and append any extra classes.
338
- if ( ! array_key_exists( 'class', $args['attributes'] ) ) {
339
- $args['attributes']['class'] = '';
340
- }
341
- $args['attributes']['class'] = 'wpsc-purchlog-action-link ' . trim( $this->get_html_class() . ' ' . $args['attributes']['class'] );
342
-
343
- // Add AJAX class
344
- if ( $args['ajax'] ) {
345
- $args['attributes']['class'] .= ' is-ajax';
346
- }
347
-
348
- return $args;
349
-
350
- }
351
-
352
- /**
353
- * Get HTML Class
354
- *
355
- * @since 3.9.0
356
- *
357
- * @return string Action link class.
358
- */
359
- public function get_html_class() {
360
-
361
- return 'wpsc-purchlog-action-link-' . sanitize_html_class( $this->id );
362
-
363
- }
364
-
365
- /**
366
- * Get Link Display
367
- *
368
- * @since 3.9.0
369
- *
370
- * @return string HTML action link.
371
- */
372
- public function get_link_display() {
373
-
374
- return sprintf( '<a href="%s" title="%s" %s>%s%s</a>',
375
- esc_attr( $this->get_link_url() ),
376
- esc_attr( $this->args['description'] ),
377
- $this->_get_link_attributes_string(),
378
- $this->_get_dashicon_display(),
379
- esc_html( $this->title )
380
- );
381
-
382
- }
383
-
384
- /**
385
- * Get Link URL
386
- *
387
- * Returns the custom URL if specified.
388
- * Otherwise returns a callback URL.
389
- *
390
- * @since 3.9.0
391
- *
392
- * @return string URL.
393
- */
394
- public function get_link_url() {
395
-
396
- // Custom URL
397
- if ( ! empty( $this->args['url'] ) ) {
398
- return $this->args['url'];
399
- }
400
-
401
- // Callback URL
402
- $url = add_query_arg( array( 'wpsc_purchase_log_action' => $this->id, 'id' => $this->log_id ) );
403
- $url = wp_nonce_url( $url, 'wpsc_purchase_log_action_' . $this->id );
404
-
405
- return $url;
406
-
407
- }
408
-
409
- /**
410
- * Get Link Attributes String
411
- *
412
- * @since 3.9.0
413
- * @access private
414
- *
415
- * @return string Link attributes HTML.
416
- */
417
- private function _get_link_attributes_string() {
418
-
419
- $atts = array();
420
- foreach ( $this->args['attributes'] as $att => $val ) {
421
- $att_key = sanitize_html_class( $att );
422
-
423
- // Don't override attributes that we set elsewhere
424
- if ( in_array( $att_key, array( 'href', 'title' ) ) ) {
425
- continue;
426
- }
427
-
428
- $atts[] = $att_key . '="' . esc_attr( $val ) . '"';
429
- }
430
-
431
- // Data attributes for JS/AJAX
432
- $atts[] = 'data-purchase-log-action="' . esc_attr( $this->id ) . '"';
433
- $atts[] = 'data-nonce="' . esc_attr( wp_create_nonce( 'wpsc_purchase_log_action_ajax_' . $this->id ) ) . '"';
434
-
435
- return implode( ' ', $atts );
436
-
437
- }
438
-
439
- /**
440
- * Get Dashicon Display
441
- *
442
- * @since 3.9.0
443
- * @access private
444
- *
445
- * @return string Dashicon HTML element.
446
- */
447
- private function _get_dashicon_display() {
448
-
449
- return '<span class="dashicons ' . $this->_sanitize_html_classes( $this->args['dashicon'] ) . '"></span>';
450
-
451
- }
452
-
453
- /**
454
- * Sanitize HTML Classes
455
- *
456
- * Handles sanitizing multiple classes provided as a string.
457
- *
458
- * @since 3.9.0
459
- * @access private
460
- *
461
- * @param string|array $classes Classes.
462
- * @return string Santized classes.
463
- */
464
- private function _sanitize_html_classes( $classes ) {
465
-
466
- // Convert multiple classes string to an array.
467
- if ( ! is_array( $classes ) && strpos( $classes, ' ' ) !== false ) {
468
- $classes = explode( ' ', $classes );
469
- }
470
-
471
- // Sanitize and return multiple classes.
472
- if ( is_array( $classes ) ) {
473
- $classes = array_map( 'sanitize_html_class', $classes );
474
- return implode( ' ', $classes );
475
- }
476
-
477
- // Sanitize single class.
478
- return sanitize_html_class( $classes );
479
-
480
- }
481
-
482
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/includes/purchase-log-list-table-class.php CHANGED
@@ -20,9 +20,6 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
20
 
21
  public function __construct( $args = array() ) {
22
  $args['plural'] = 'purchase-logs';
23
-
24
- $this->set_per_page( $this->set_purchase_logs_per_page_by_user() );
25
-
26
  parent::__construct( $args );
27
 
28
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
@@ -49,14 +46,6 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
49
  $this->views = false;
50
  }
51
 
52
- private function set_purchase_logs_per_page_by_user() {
53
-
54
- $per_page = get_user_meta( get_current_user_id(), 'wpsc_purchases_per_page', true );
55
-
56
- return empty( $per_page ) || $per_page < 1 ? 20 : $per_page;
57
- }
58
-
59
- // Override the default Purchase Logs Per Page
60
  public function set_per_page( $per_page ) {
61
  $this->per_page = (int) $per_page;
62
  }
@@ -89,28 +78,20 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
89
  ) AS item_count';
90
 
91
  $search_terms = empty( $_REQUEST['s'] ) ? array() : explode( ' ', $_REQUEST['s'] );
92
- $search_sql = array();
93
-
94
  foreach ( $checkout_fields as $field ) {
95
- $table_as = 's' . $i;
96
  $select_as = str_replace('billing', '', $field->unique_name );
97
  $selects[] = $table_as . '.value AS ' . $select_as;
98
- $joins[] = $wpdb->prepare( "LEFT OUTER JOIN " . WPSC_TABLE_SUBMITTED_FORM_DATA . " AS {$table_as} ON {$table_as}.log_id = p.id AND {$table_as}.form_id = %d", $field->id );
99
 
100
  // build search term queries for first name, last name, email
101
  foreach ( $search_terms as $term ) {
 
 
 
102
 
103
- if ( version_compare( $GLOBALS['wp_version'], '4.0', '>=' ) ) {
104
- $escaped_term = esc_sql( like_escape( $term ) );
105
- } else {
106
- $escaped_term = esc_sql( $wpdb->esc_like( $term ) );
107
- }
108
-
109
- if ( ! array_key_exists( $term, $search_sql ) ) {
110
- $search_sql[ $term ] = array();
111
- }
112
-
113
- $search_sql[ $term ][] = $table_as . ".value LIKE '%" . $escaped_term . "%'";
114
  }
115
 
116
  $i++;
@@ -118,10 +99,10 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
118
 
119
  // combine query phrases into a single query string
120
  foreach ( $search_terms as $term ) {
121
- $search_sql[ $term ][] = "p.track_id = '" . esc_sql( $term ) . "'";
122
  if ( is_numeric( $term ) )
123
- $search_sql[ $term ][] = 'p.id = ' . esc_sql( $term );
124
- $search_sql[ $term ] = '(' . implode( ' OR ', $search_sql[ $term ] ) . ')';
125
  }
126
  $search_sql = implode( ' AND ', array_values( $search_sql ) );
127
 
@@ -178,7 +159,6 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
178
  }
179
 
180
  $total_where = apply_filters( 'wpsc_manage_purchase_logs_total_where', $this->where );
181
-
182
  if ( $this->status == 'all' ) {
183
  $total_where .= ' AND p.processed IN (2, 3, 4) ';
184
  }
@@ -186,7 +166,6 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
186
  $total_sql = "
187
  SELECT SUM(totalprice)
188
  FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
189
- {$this->joins}
190
  WHERE {$total_where}
191
  ";
192
 
@@ -259,7 +238,6 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
259
  $sql = "
260
  SELECT DISTINCT YEAR(FROM_UNIXTIME(date)) AS year, MONTH(FROM_UNIXTIME(date)) AS month
261
  FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
262
- {$this->joins}
263
  WHERE {$this->where_no_filter}
264
  ORDER BY date DESC
265
  ";
@@ -434,32 +412,11 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
434
  }
435
 
436
  public function column_customer( $item ) {
437
-
438
- $name = '';
439
-
440
- if ( isset( $item->firstname ) ) {
441
- $name .= $item->firstname;
442
- }
443
-
444
- if ( isset( $item->lastname ) ) {
445
- $name .= ' ' . $item->lastname;
446
- }
447
-
448
- $name = trim( $name );
449
-
450
- if ( empty( $name ) ) {
451
- $name = apply_filters( 'wpsc_purchase_log_list_no_name', __( 'No name provided', 'wpsc' ), $item );
452
- }
453
-
454
-
455
- ?>
456
  <strong>
457
- <a class="row-title" href="<?php echo esc_url( $this->item_url( $item ) ); ?>" title="<?php esc_attr_e( 'View order details', 'wpsc' ) ?>"><?php echo esc_html( $name ); ?></a>
458
  </strong><br />
459
-
460
- <?php if ( isset( $item->email ) ) : ?>
461
- <small><?php echo make_clickable( $item->email ); ?></small>
462
- <?php endif; ?>
463
  <?php
464
  }
465
 
20
 
21
  public function __construct( $args = array() ) {
22
  $args['plural'] = 'purchase-logs';
 
 
 
23
  parent::__construct( $args );
24
 
25
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
46
  $this->views = false;
47
  }
48
 
 
 
 
 
 
 
 
 
49
  public function set_per_page( $per_page ) {
50
  $this->per_page = (int) $per_page;
51
  }
78
  ) AS item_count';
79
 
80
  $search_terms = empty( $_REQUEST['s'] ) ? array() : explode( ' ', $_REQUEST['s'] );
81
+ $search_sql = array();
 
82
  foreach ( $checkout_fields as $field ) {
83
+ $table_as = 's' . $i;
84
  $select_as = str_replace('billing', '', $field->unique_name );
85
  $selects[] = $table_as . '.value AS ' . $select_as;
86
+ $joins[] = $wpdb->prepare( "LEFT OUTER JOIN " . WPSC_TABLE_SUBMITTED_FORM_DATA . " AS {$table_as} ON {$table_as}.log_id = p.id AND {$table_as}.form_id = %d", $field->id );
87
 
88
  // build search term queries for first name, last name, email
89
  foreach ( $search_terms as $term ) {
90
+ $escaped_term = esc_sql( like_escape( $term ) );
91
+ if ( ! array_key_exists( $term, $search_sql ) )
92
+ $search_sql[$term] = array();
93
 
94
+ $search_sql[$term][] = $table_as . ".value LIKE '%" . $escaped_term . "%'";
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
  $i++;
99
 
100
  // combine query phrases into a single query string
101
  foreach ( $search_terms as $term ) {
102
+ $search_sql[$term][] = "p.track_id = '" . esc_sql( $term ) . "'";
103
  if ( is_numeric( $term ) )
104
+ $search_sql[$term][] = 'p.id = ' . esc_sql( $term );
105
+ $search_sql[$term] = '(' . implode( ' OR ', $search_sql[$term] ) . ')';
106
  }
107
  $search_sql = implode( ' AND ', array_values( $search_sql ) );
108
 
159
  }
160
 
161
  $total_where = apply_filters( 'wpsc_manage_purchase_logs_total_where', $this->where );
 
162
  if ( $this->status == 'all' ) {
163
  $total_where .= ' AND p.processed IN (2, 3, 4) ';
164
  }
166
  $total_sql = "
167
  SELECT SUM(totalprice)
168
  FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
 
169
  WHERE {$total_where}
170
  ";
171
 
238
  $sql = "
239
  SELECT DISTINCT YEAR(FROM_UNIXTIME(date)) AS year, MONTH(FROM_UNIXTIME(date)) AS month
240
  FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
 
241
  WHERE {$this->where_no_filter}
242
  ORDER BY date DESC
243
  ";
412
  }
413
 
414
  public function column_customer( $item ) {
415
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  <strong>
417
+ <a class="row-title" href="<?php echo esc_url( $this->item_url( $item ) ); ?>" title="<?php esc_attr_e( 'View order details', 'wpsc' ) ?>"><?php echo esc_html( $item->firstname . ' ' . $item->lastname ); ?></a>
418
  </strong><br />
419
+ <small><?php echo make_clickable( $item->email ); ?></small>
 
 
 
420
  <?php
421
  }
422
 
wpsc-admin/includes/purchase-logs-page/item-details.php CHANGED
@@ -17,9 +17,8 @@
17
 
18
  <div id='post-body'>
19
  <?php if ( wpsc_has_purchlog_shipping() ): ?>
20
- <?php do_action( 'wpsc_shipping_details_top', $this->log_id ); ?>
21
  <div id='wpsc_shipping_details_box'>
22
- <h3><?php esc_html_e( 'Shipping Address', 'wpsc' ); ?></h3>
23
  <blockquote>
24
  <strong>
25
  <?php echo ( wpsc_display_purchlog_shipping_name() != "" ) ? wpsc_display_purchlog_shipping_name() . "<br />" : '<span class="field-blank">' . __( 'Anonymous', 'wpsc' ) . '</span>' ; ?>
@@ -30,34 +29,24 @@
30
  <?php echo ( wpsc_display_purchlog_shipping_country() != "" ) ? wpsc_display_purchlog_shipping_country() . "<br />" : '<span class="field-blank">' . __( 'Country not specified', 'wpsc' ) . '</span>' ; ?>
31
  </blockquote>
32
  <h4><?php esc_html_e( 'Shipping Details', 'wpsc' ); ?></h4>
33
- <blockquote>
34
- <strong><?php esc_html_e( 'Shipping Method:', 'wpsc' ); ?></strong> <?php echo wpsc_display_purchlog_shipping_method(); ?><br />
35
- <strong><?php esc_html_e( 'Shipping Option:', 'wpsc' ); ?></strong> <?php echo wpsc_display_purchlog_shipping_option(); ?><br />
36
- <?php $purchase_weight = wpsc_purchlogs_get_weight_text(); ?>
37
- <?php if ( ! empty( $purchase_weight ) ) { ?>
38
- <strong><?php esc_html_e( 'Purchase Weight:', 'wpsc' ); ?></strong> <?php echo $purchase_weight; ?><br />
39
- <?php } ?>
40
- <?php if ( wpsc_purchlogs_has_tracking() ) { ?>
41
- <strong><?php echo esc_html_x( 'Tracking ID:', 'purchase log', 'wpsc' ); ?></strong> <?php echo wpsc_purchlogitem_trackid(); ?><br />
42
-
43
- <?php $tracking_status = wpsc_purchlogitem_trackstatus(); ?>
44
- <?php if ( ! empty ( $tracking_status ) ) { ?>
45
- <strong><?php esc_html_e( 'Shipping Status:', 'wpsc' ); ?></strong> <?php echo $tracking_status ?><br />
46
- <?php } ?>
47
-
48
- <?php $tracking_history = wpsc_purchlogitem_trackhistory(); ?>
49
- <?php if ( ! empty ( $tracking_history ) ) { ?>
50
- <strong><?php esc_html_e( 'Track History:', 'wpsc' ); ?></strong> <?php echo $tracking_history; ?><br />
51
- <?php } ?>
52
-
53
- <?php } ?>
54
- </blockquote>
55
- <?php do_action( 'wpsc_shipping_details_bottom', $this->log_id ); ?>
56
  </div>
57
  <?php endif ?>
58
 
59
  <div id='wpsc_billing_details_box'>
60
- <?php do_action( 'wpsc_billing_details_top', $this->log_id ); ?>
61
  <h3><?php esc_html_e( 'Billing Details', 'wpsc' ); ?></h3>
62
  <blockquote>
63
  <strong>
@@ -69,19 +58,18 @@
69
  <?php echo ( wpsc_display_purchlog_buyers_country() != "" ) ? wpsc_display_purchlog_buyers_country() . "<br />" : '<span class="field-blank">' . __( 'Country not specified', 'wpsc' ) . '</span>' ; ?>
70
  </blockquote>
71
  <h4><?php esc_html_e( 'Payment Details', 'wpsc' ); ?></h4>
72
- <blockquote>
73
- <strong><?php esc_html_e( 'Phone:', 'wpsc' ); ?> </strong><?php echo ( wpsc_display_purchlog_buyers_phone() != "" ) ? wpsc_display_purchlog_buyers_phone() : __( '<em class="field-blank">not provided</em>', 'wpsc' ); ?><br />
74
  <strong><?php esc_html_e( 'Email:', 'wpsc' ); ?> </strong>
75
- <a href="mailto:<?php echo wpsc_display_purchlog_buyers_email(); ?>?subject=<?php echo rawurlencode( sprintf( __( 'Message from %s', 'wpsc' ), site_url() ) ); ?>">
76
- <?php echo ( wpsc_display_purchlog_buyers_email() != "" ) ? wpsc_display_purchlog_buyers_email() : __( '<em class="field-blank">not provided</em>', 'wpsc' ); ?>
77
- </a>
78
- <br />
79
- <strong><?php esc_html_e( 'Payment Method:', 'wpsc' ); ?> </strong><?php echo wpsc_display_purchlog_paymentmethod(); ?><br />
80
- <?php if ( wpsc_display_purchlog_display_howtheyfoundus() ) : ?>
81
- <strong><?php esc_html_e( 'How User Found Us:', 'wpsc' ); ?> </strong><?php echo wpsc_display_purchlog_howtheyfoundus(); ?><br />
82
- <?php endif; ?>
83
- </blockquote>
84
- <?php do_action( 'wpsc_billing_details_bottom', $this->log_id ); ?>
85
  </div>
86
 
87
  <div id='wpsc_items_ordered'>
@@ -137,12 +125,21 @@
137
  <input type='hidden' name='wpsc_admin_action' value='purchlogs_update_notes' />
138
  <input type="hidden" name="wpsc_purchlogs_update_notes_nonce" id="wpsc_purchlogs_update_notes_nonce" value="<?php echo wp_create_nonce( 'wpsc_purchlogs_update_notes' ); ?>" />
139
  <input type='hidden' name='purchlog_id' value='<?php echo $this->log_id; ?>' />
140
- <p><textarea name="purchlog_notes" rows="3" wrap="virtual" id="purchlog_notes" style="width:100%;"><?php echo esc_textarea( wpsc_display_purchlog_notes() ); ?></textarea></p>
141
- <div><input class="button" type="submit" name="button" id="button" value="<?php _e( 'Update Notes', 'wpsc' ); ?>" /></div>
 
 
 
 
 
 
 
 
142
  </form>
143
  </div>
144
  </div>
145
  </div>
 
146
 
147
  <?php $this->purchase_logs_checkout_fields(); ?>
148
  <?php do_action( 'wpsc_purchlogitem_metabox_end', $this->log_id ); ?>
@@ -150,16 +147,22 @@
150
  </div>
151
  </div>
152
 
153
- <div id="wpsc_purchlogitems_links">
154
  <h3><?php esc_html_e( 'Actions', 'wpsc' ); ?></h3>
155
  <?php do_action( 'wpsc_purchlogitem_links_start' ); ?>
156
- <ul>
157
- <?php
158
- require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-action-links.php' );
159
- $action_links = new WPSC_Purchase_Log_Action_Links( $this->log_id );
160
- $action_links->display_link_list_items();
161
- ?>
162
- </ul>
 
 
 
 
 
163
  </div>
 
164
 
165
  </div>
17
 
18
  <div id='post-body'>
19
  <?php if ( wpsc_has_purchlog_shipping() ): ?>
 
20
  <div id='wpsc_shipping_details_box'>
21
+ <h3><?php esc_html_e( 'Shipping Details', 'wpsc' ); ?></h3>
22
  <blockquote>
23
  <strong>
24
  <?php echo ( wpsc_display_purchlog_shipping_name() != "" ) ? wpsc_display_purchlog_shipping_name() . "<br />" : '<span class="field-blank">' . __( 'Anonymous', 'wpsc' ) . '</span>' ; ?>
29
  <?php echo ( wpsc_display_purchlog_shipping_country() != "" ) ? wpsc_display_purchlog_shipping_country() . "<br />" : '<span class="field-blank">' . __( 'Country not specified', 'wpsc' ) . '</span>' ; ?>
30
  </blockquote>
31
  <h4><?php esc_html_e( 'Shipping Details', 'wpsc' ); ?></h4>
32
+ <p>
33
+ <?php esc_html_e( 'Shipping Method:', 'wpsc' ); ?> <?php echo wpsc_display_purchlog_shipping_method(); ?>
34
+ </p>
35
+ <p>
36
+ <?php esc_html_e( 'Shipping Option:', 'wpsc' ); ?> <?php echo wpsc_display_purchlog_shipping_option(); ?>
37
+ </p>
38
+ <?php if( wpsc_purchlogs_has_tracking() ) : ?>
39
+ <p>
40
+ <?php echo esc_html_x( 'Tracking ID:', 'purchase log', 'wpsc' ); ?> <?php echo wpsc_purchlogitem_trackid(); ?><br />
41
+ <?php esc_html_e( 'Shipping Status:', 'wpsc' ); ?> <?php echo wpsc_purchlogitem_trackstatus(); ?><br />
42
+ <?php esc_html_e( 'Track History:', 'wpsc' ); ?> <?php echo wpsc_purchlogitem_trackhistory(); ?>
43
+ </p>
44
+ <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
45
  </div>
46
  <?php endif ?>
47
 
48
  <div id='wpsc_billing_details_box'>
49
+ <?php do_action( 'wpsc_billing_details_top' ); ?>
50
  <h3><?php esc_html_e( 'Billing Details', 'wpsc' ); ?></h3>
51
  <blockquote>
52
  <strong>
58
  <?php echo ( wpsc_display_purchlog_buyers_country() != "" ) ? wpsc_display_purchlog_buyers_country() . "<br />" : '<span class="field-blank">' . __( 'Country not specified', 'wpsc' ) . '</span>' ; ?>
59
  </blockquote>
60
  <h4><?php esc_html_e( 'Payment Details', 'wpsc' ); ?></h4>
61
+ <p><strong><?php esc_html_e( 'Phone:', 'wpsc' ); ?> </strong><?php echo ( wpsc_display_purchlog_buyers_phone() != "" ) ? wpsc_display_purchlog_buyers_phone() : __( '<em class="field-blank">not provided</em>', 'wpsc' ); ?></p>
62
+ <p>
63
  <strong><?php esc_html_e( 'Email:', 'wpsc' ); ?> </strong>
64
+ <a href="mailto:<?php echo wpsc_display_purchlog_buyers_email(); ?>?subject=<?php echo rawurlencode( sprintf( __( 'Message from %s', 'wpsc' ), site_url() ) ); ?>">
65
+ <?php echo ( wpsc_display_purchlog_buyers_email() != "" ) ? wpsc_display_purchlog_buyers_email() : __( '<em class="field-blank">not provided</em>', 'wpsc' ); ?>
66
+ </a>
67
+ </p>
68
+ <p><strong><?php esc_html_e( 'Payment Method:', 'wpsc' ); ?> </strong><?php echo wpsc_display_purchlog_paymentmethod(); ?></p>
69
+ <?php if(wpsc_display_purchlog_display_howtheyfoundus()) : ?>
70
+ <p><strong><?php esc_html_e( 'How User Found Us:', 'wpsc' ); ?> </strong><?php echo wpsc_display_purchlog_howtheyfoundus(); ?></p>
71
+ <?php endif; ?>
72
+ <?php do_action( 'wpsc_billing_details_bottom'); ?>
 
73
  </div>
74
 
75
  <div id='wpsc_items_ordered'>
125
  <input type='hidden' name='wpsc_admin_action' value='purchlogs_update_notes' />
126
  <input type="hidden" name="wpsc_purchlogs_update_notes_nonce" id="wpsc_purchlogs_update_notes_nonce" value="<?php echo wp_create_nonce( 'wpsc_purchlogs_update_notes' ); ?>" />
127
  <input type='hidden' name='purchlog_id' value='<?php echo $this->log_id; ?>' />
128
+ <p>
129
+ <textarea name="purchlog_notes" rows="3" wrap="virtual" id="purchlog_notes" style="width:100%;"><?php
130
+ if ( isset( $_POST['purchlog_notes'] ) ) {
131
+ echo esc_textarea( stripslashes( $_POST['purchlog_notes'] ) );
132
+ } else {
133
+ echo wpsc_display_purchlog_notes();
134
+ }
135
+ ?></textarea>
136
+ </p>
137
+ <p><input class="button" type="submit" name="button" id="button" value="<?php _e( 'Update Notes', 'wpsc' ); ?>" /></p>
138
  </form>
139
  </div>
140
  </div>
141
  </div>
142
+ <!-- End Order Notes (by Ben) -->
143
 
144
  <?php $this->purchase_logs_checkout_fields(); ?>
145
  <?php do_action( 'wpsc_purchlogitem_metabox_end', $this->log_id ); ?>
147
  </div>
148
  </div>
149
 
150
+ <div id='wpsc_purchlogitems_links'>
151
  <h3><?php esc_html_e( 'Actions', 'wpsc' ); ?></h3>
152
  <?php do_action( 'wpsc_purchlogitem_links_start' ); ?>
153
+ <?php if ( wpsc_purchlogs_have_downloads_locked() != false ): ?>
154
+ <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/lock_open.png' alt='<?php _e( 'clear lock icon', 'wpsc' ); ?>' />&ensp;<a href='<?php echo esc_url( add_query_arg( 'wpsc_admin_action', 'clear_locks' ) ); ?>'><?php echo wpsc_purchlogs_have_downloads_locked(); ?></a><br /><br class='small' />
155
+ <?php endif; ?>
156
+ <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/printer.png' alt='<?php _e( 'printer icon', 'wpsc' ); ?>' />&ensp;<a target="_blank" href='<?php echo esc_url( add_query_arg( 'c', 'packing_slip' ) ); ?>'><?php esc_html_e( 'View Packing Slip', 'wpsc' ); ?></a>
157
+ <br /><br class='small' />
158
+ <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/email_go.png' alt='<?php _e( 'email icon', 'wpsc' ); ?>' />&ensp;<a href='<?php echo esc_url( add_query_arg( 'email_buyer_id', $this->log_id ) ); ?>'><?php esc_html_e('Resend Receipt to Buyer', 'wpsc'); ?></a>
159
+
160
+ <br /><br class='small' />
161
+ <a class='submitdelete' title='<?php echo esc_attr(__( 'Remove this log', 'wpsc' )); ?>' href='<?php echo wp_nonce_url("admin.php?wpsc_admin_action=delete_purchlog&amp;purchlog_id=".$this->log_id, 'delete_purchlog_' .$this->log_id); ?>' onclick="if ( confirm(' <?php echo esc_js(sprintf( __("You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete.",'wpsc'), wpsc_purchaselog_details_date() )) ?>') ) { return true;}return false;"><img src='<?php echo WPSC_CORE_IMAGES_URL . "/cross.png"; ?>' alt='<?php _e( 'delete icon', 'wpsc' ); ?>' /> &nbsp;<?php _e('Remove this record', 'wpsc') ?></a>
162
+
163
+ <br /><br class='small' />&emsp;&ensp; <a href='<?php echo esc_attr( wp_get_referer() ); ?>'><?php _e('Go Back', 'wpsc'); ?></a>
164
+ <br /><br />
165
  </div>
166
+ <br />
167
 
168
  </div>
wpsc-admin/includes/purchase-logs-page/list-table.php CHANGED
@@ -24,11 +24,11 @@
24
  <?php endif ?>
25
 
26
  <?php if( get_option( 'wpsc_purchaselogs_fixed' ) == false || ( wpsc_check_uniquenames() ) ): ?>
27
- <div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __( 'When upgrading the WP eCommerce Plugin from 3.6.* to 3.7, it is required that you associate your checkout form fields with the new Purchase Logs system. To do so please <a href="%s">click here</a>', 'wpsc' ), add_query_arg( 'c', 'upgrade_purchase_logs_3_7' ) ); ?></span></div>
28
  <?php endif; ?>
29
 
30
  <?php if ( $this->needs_update() ): ?>
31
- <div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __( 'It has been detected that some of your purchase logs were not updated properly when you upgrade to WP eCommerce %s. Please <a href="%s">click here</a> to fix this problem.', 'wpsc' ), WPSC_VERSION, add_query_arg( 'c', 'upgrade_purchase_logs_3_8' ) ); ?></span></div>
32
  <?php endif; ?>
33
 
34
  <form id="purchase-logs-search" method-"get" action="">
24
  <?php endif ?>
25
 
26
  <?php if( get_option( 'wpsc_purchaselogs_fixed' ) == false || ( wpsc_check_uniquenames() ) ): ?>
27
+ <div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __( 'When upgrading the WP e-Commerce Plugin from 3.6.* to 3.7 it is required that you associate your checkout form fields with the new Purchase Logs system. To do so please <a href="%s">Click Here</a>', 'wpsc' ), esc_url( add_query_arg( 'c', 'upgrade_purchase_logs_3_7' ) ) ); ?></span></div>
28
  <?php endif; ?>
29
 
30
  <?php if ( $this->needs_update() ): ?>
31
+ <div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __( 'It has been detected that some of your purchase logs were not updated properly when you upgrade to WP e-Commerce %s. Please <a href="%s">click here</a> to fix this problem.', 'wpsc' ), WPSC_VERSION, esc_url( add_query_arg( 'c', 'upgrade_purchase_logs_3_8' ) ) ); ?></span></div>
32
  <?php endif; ?>
33
 
34
  <form id="purchase-logs-search" method-"get" action="">
wpsc-admin/includes/purchase-logs-page/upgrade.php CHANGED
@@ -4,10 +4,10 @@
4
 
5
  <?php if ( $numChanged != 0 && $numQueries != 0 ): ?>
6
  <div class="updated">
7
- <p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wpsc' ), remove_query_arg( 'c' ) ); ?></p>
8
  </div>
9
  <?php else: ?>
10
- <p><?php _e( 'Upgrading to WP eCommerce 3.7 and later requires you to run this fix once. The following boxes correspond to the form fields in your current checkout page. All you have to do is select from the drop-down menu box what each of the following fields represent. Sorry for any inconvenience caused, but we\'re sure you\'ll agree that the new purchase logs are worth this minor hassle.', 'wpsc' ); ?> </p>
11
 
12
  <div class="metabox-holder" style="width:700px">
13
  <form action='' method='post'>
4
 
5
  <?php if ( $numChanged != 0 && $numQueries != 0 ): ?>
6
  <div class="updated">
7
+ <p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wpsc' ), esc_url( remove_query_arg( 'c' ) ) ); ?></p>
8
  </div>
9
  <?php else: ?>
10
+ <p><?php _e( 'Upgrading to WP e-Commerce 3.7 and later requires you to run this fix once. The following boxes correspond to the form fields in your current checkout page. All you have to do is select from the drop-down menu box what each of the following fields represent. Sorry for any inconvenience caused, but we\'re sure you\'ll agree that the new purchase logs are worth this minor hassle.', 'wpsc' ); ?> </p>
11
 
12
  <div class="metabox-holder" style="width:700px">
13
  <form action='' method='post'>
wpsc-admin/includes/save-data.functions.php CHANGED
@@ -12,17 +12,14 @@ function wpsc_ajax_set_variation_order(){
12
  $parent_id = $_POST['parent_id'];
13
 
14
  $result = true;
15
- foreach( $sort_order as $key => $value ) {
16
-
17
- if ( empty( $value ) ) {
18
  continue;
19
- }
20
 
21
  $value = preg_replace( '/[^0-9]/', '', $value );
22
 
23
- if ( ! wpsc_update_meta( $value, 'sort_order', $key, 'wpsc_variation' ) ) {
24
  $result = false;
25
- }
26
  }
27
  }
28
 
@@ -80,30 +77,27 @@ function wpsc_custom_category_columns( $columns ) {
80
 
81
  return $columns;
82
  }
83
-
84
  /**
85
- * Custom Category Column Data
86
- *
87
- * Adds images to the custom category column.
88
- *
89
- * @param string $string Column output.
90
- * @param string $column_name Column name.
91
- * @param string $term_id Term ID.
92
- * @return string Updated column output.
93
  */
 
94
  function wpsc_custom_category_column_data( $string, $column_name, $term_id ) {
95
- if ( 'image' == $column_name ) {
96
- $term = get_term_by( 'id', $term_id, 'wpsc_product_category' );
97
- $image = wpsc_get_categorymeta( $term_id, 'image' );
 
 
 
 
 
 
 
 
 
98
 
99
- $format = '<img src="%s" title="%s" alt="%2$s" width="30" height="30" />';
100
- if ( ! empty( $image ) ) {
101
- $string = sprintf( $format, WPSC_CORE_IMAGES_URL . $image, esc_attr( $term->name ) );
102
- } else {
103
- $string = sprintf( $format, WPSC_CORE_IMAGES_URL . '/no-image-uploaded.gif', esc_attr( $term->name ) );
104
- }
105
- }
106
- return $string;
107
  }
108
 
109
  /**
@@ -157,7 +151,7 @@ function wpsc_admin_category_forms_add() {
157
  <h3><?php esc_html_e('Advanced Store Settings', 'wpsc'); ?></h3>
158
  <h4><?php esc_html_e('Presentation Settings', 'wpsc'); ?></h4>
159
  <p class='description'><?php esc_html_e( 'These settings override the general presentation settings found in Settings &gt; Store &gt; Presentation.', 'wpsc' ); ?></p>
160
- <div style="margin: 15px 0 15px 0">
161
  <label for='image'><?php esc_html_e( 'Category Image' , 'wpsc' ); ?></label>
162
  <input type='file' name='image' value='' />
163
  </div>
@@ -175,23 +169,20 @@ function wpsc_admin_category_forms_add() {
175
  <fieldset class="wpsc-width-height-fields">
176
  <legend class="screen-reader-text"><span><?php esc_html_e( 'Thumbnail Size', 'wpsc' ); ?></span></legend>
177
  <label for="image_width"><?php esc_html_e( 'Width', 'wpsc' ); ?></label>
178
- <input name="image_width" type="number" step="1" min="0" id="image_width" value="<?php if ( isset( $category['image_width'] ) ) echo esc_attr( $category['image_width'] ); ?>" class="small-text" style="width: 70px">
179
  <label for="large_size_h"><?php esc_html_e( 'Height', 'wpsc' ); ?></label>
180
- <input name="image_height" type="number" step="1" min="0" id="image_height" value="<?php if ( isset( $category['image_height'] ) ) echo esc_attr( $category['image_height'] ); ?>" class="small-text" style="width: 70px">
181
  </fieldset>
182
  </div>
183
  <?php endif;?>
184
 
185
  <!-- START OF TARGET MARKET SELECTION -->
186
  <?php
187
-
188
  $category_id = '';
 
 
189
 
190
- if ( isset( $_GET['tag_ID'] ) ) {
191
- $category_id = absint( $_GET['tag_ID'] );
192
- }
193
-
194
- $countrylist = WPSC_Countries::get_countries_array( true, true );
195
  $selectedCountries = wpsc_get_meta( $category_id, 'target_market', 'wpsc_category' );
196
  ?>
197
  <h4><?php esc_html_e( 'Restrict to Target Markets', 'wpsc' )?></h4>
@@ -247,8 +238,8 @@ function wpsc_admin_category_forms_add() {
247
  <?php $uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' ); ?>
248
  <div>
249
  <label><?php esc_html_e( 'Address to calculate shipping with', 'wpsc' ); ?></label>
250
- <label><input type="radio" value="0" name="uses_billing_address" <?php checked( $uses_billing_address, 0 ); ?> /> <?php esc_html_e( 'Shipping Address (default)', 'wpsc' ); ?></label>
251
- <label><input type="radio" value="1" name="uses_billing_address" <?php checked( $uses_billing_address, 1 ); ?> /> <?php esc_html_e( 'Billing Address', 'wpsc' ); ?></label>
252
  <p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wpsc' ); ?></p>
253
  </div>
254
 
@@ -313,9 +304,9 @@ function wpsc_admin_category_forms_edit() {
313
  $display_type = isset( $category['display_type'] ) ? $category['display_type'] : '';
314
  ?>
315
  <select name='display_type'>
316
- <option value='default'<?php selected( $display_type, 'default' ); ?>><?php esc_html_e( 'Default View', 'wpsc' ); ?></option>
317
- <option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php selected( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wpsc'); ?></option>
318
- <option value='grid' <?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php selected( $display_type, 'grid' ); ?>><?php esc_html_e( 'Grid View', 'wpsc' ); ?></option>
319
  </select><br />
320
  </td>
321
  </tr>
@@ -383,7 +374,7 @@ function wpsc_admin_category_forms_edit() {
383
  </td>
384
  </tr>
385
  <?php
386
- $countrylist = WPSC_Countries::get_countries_array( true, true );
387
  $selectedCountries = wpsc_get_meta( $category_id,'target_market','wpsc_category' );
388
  ?>
389
  <tr>
@@ -457,8 +448,8 @@ function wpsc_admin_category_forms_edit() {
457
  <label><?php esc_html_e( 'Address to calculate shipping with', 'wpsc' ); ?></label>
458
  </th>
459
  <td>
460
- <label><input type="radio" class="wpsc_cat_box" value="0" name="uses_billing_address" <?php echo ( ( $uses_billing_address != true ) ? 'checked="checked"' : '' ); ?> /> <?php esc_html_e( 'Shipping Address (default)', 'wpsc' ); ?></label><br />
461
- <label><input type="radio" class="wpsc_cat_box" value="1" name="uses_billing_address" <?php echo ( ( $uses_billing_address == true ) ? 'checked="checked"' : '' ); ?> /> <?php esc_html_e( 'Billing Address', 'wpsc' ); ?></label>
462
  <p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wpsc' ); ?></p>
463
  </td>
464
  </tr>
@@ -500,9 +491,9 @@ function wpsc_save_category_set( $category_id, $tt_id ) {
500
  //Good to here
501
  if ( isset( $_POST['tag_ID'] ) ) {
502
  //Editing
503
- $category_id = (int) $_POST['tag_ID'];
504
- $category = get_term_by( 'id', $category_id, 'wpsc_product_category' );
505
- $url_name = $category->slug;
506
 
507
  }
508
  if ( isset( $_POST['deleteimage'] ) && $_POST['deleteimage'] == 1 ) {
@@ -514,9 +505,9 @@ function wpsc_save_category_set( $category_id, $tt_id ) {
514
  if ( ! empty( $_POST['height'] ) && is_numeric( $_POST['height'] ) && ! empty( $_POST['width'] ) && is_numeric( $_POST['width'] ) && $image == null ) {
515
  $imagedata = wpsc_get_categorymeta( $category_id, 'image' );
516
  if ( $imagedata != null ) {
517
- $height = (int) $_POST['height'];
518
- $width = (int) $_POST['width'];
519
- $imagepath = WPSC_CATEGORY_DIR . $imagedata;
520
  $image_output = WPSC_CATEGORY_DIR . $imagedata;
521
  image_processing( $imagepath, $image_output, $width, $height );
522
  }
@@ -526,20 +517,18 @@ function wpsc_save_category_set( $category_id, $tt_id ) {
526
  wpsc_update_categorymeta( $category_id, 'active', '1' );
527
  wpsc_update_categorymeta( $category_id, 'order', '0' );
528
 
529
- if ( isset( $_POST['display_type'] ) ) {
530
  wpsc_update_categorymeta( $category_id, 'display_type', esc_sql( stripslashes( $_POST['display_type'] ) ) );
531
- }
532
 
533
- if ( isset( $_POST['image_height'] ) ) {
534
- wpsc_update_categorymeta( $category_id, 'image_height', (int) $_POST['image_height'] );
535
- }
536
 
537
- if ( isset( $_POST['image_width'] ) ) {
538
- wpsc_update_categorymeta( $category_id, 'image_width', (int) $_POST['image_width'] );
539
- }
540
 
541
  if ( ! empty( $_POST['use_additional_form_set'] ) ) {
542
  wpsc_update_categorymeta( $category_id, 'use_additional_form_set', $_POST['use_additional_form_set'] );
 
543
  } else {
544
  wpsc_delete_categorymeta( $category_id, 'use_additional_form_set' );
545
  }
@@ -557,10 +546,9 @@ function wpsc_save_category_set( $category_id, $tt_id ) {
557
  $countryList = $wpdb->get_col( "SELECT `id` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" );
558
 
559
  if ( $AllSelected != true ){
560
- $posted_countries = array_map( 'intval', $_POST['countrylist2'] );
561
- $unselectedCountries = array_diff( $countryList, $posted_countries );
562
  //find the countries that are selected
563
- $selectedCountries = array_intersect( $countryList, $posted_countries );
564
  wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries );
565
  }
566
 
12
  $parent_id = $_POST['parent_id'];
13
 
14
  $result = true;
15
+ foreach( $sort_order as $key=>$value ){
16
+ if ( empty( $value ) )
 
17
  continue;
 
18
 
19
  $value = preg_replace( '/[^0-9]/', '', $value );
20
 
21
+ if( ! wpsc_update_meta( $value, 'sort_order', $key, 'wpsc_variation' ) )
22
  $result = false;
 
23
  }
24
  }
25
 
77
 
78
  return $columns;
79
  }
 
80
  /**
81
+ * wpsc_custom_category_column_data
82
+ * Adds images to the custom category column
83
+ * @param (array) column_name | column name
84
+ * @return nada
 
 
 
 
85
  */
86
+
87
  function wpsc_custom_category_column_data( $string, $column_name, $term_id ) {
88
+ global $wpdb;
89
+
90
+ $image = wpsc_get_categorymeta( $term_id, 'image' );
91
+ $name = get_term_by( 'id', $term_id, 'wpsc_product_category' );
92
+ $name = $name->name;
93
+
94
+ if ( ! empty( $image ) )
95
+ $image = "<img src='" . WPSC_CATEGORY_URL . $image . "' title='" . esc_attr( $name ) . "' alt='" . esc_attr( $name ) . "' width='30' height='30' />";
96
+ else
97
+ $image = "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . esc_attr( $name ) . "' alt='" . esc_attr( $name ) . "' width='30' height='30' />";
98
+
99
+ return $image;
100
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  /**
151
  <h3><?php esc_html_e('Advanced Store Settings', 'wpsc'); ?></h3>
152
  <h4><?php esc_html_e('Presentation Settings', 'wpsc'); ?></h4>
153
  <p class='description'><?php esc_html_e( 'These settings override the general presentation settings found in Settings &gt; Store &gt; Presentation.', 'wpsc' ); ?></p>
154
+ <div class="form-field">
155
  <label for='image'><?php esc_html_e( 'Category Image' , 'wpsc' ); ?></label>
156
  <input type='file' name='image' value='' />
157
  </div>
169
  <fieldset class="wpsc-width-height-fields">
170
  <legend class="screen-reader-text"><span><?php esc_html_e( 'Thumbnail Size', 'wpsc' ); ?></span></legend>
171
  <label for="image_width"><?php esc_html_e( 'Width', 'wpsc' ); ?></label>
172
+ <input name="image_width" type="number" step="1" min="0" id="image_width" value="<?php if ( isset( $category['image_width'] ) ) echo esc_attr( $category['image_width'] ); ?>" class="small-text">
173
  <label for="large_size_h"><?php esc_html_e( 'Height', 'wpsc' ); ?></label>
174
+ <input name="image_height" type="number" step="1" min="0" id="image_height" value="<?php if ( isset( $category['image_height'] ) ) echo esc_attr( $category['image_height'] ); ?>" class="small-text">
175
  </fieldset>
176
  </div>
177
  <?php endif;?>
178
 
179
  <!-- START OF TARGET MARKET SELECTION -->
180
  <?php
 
181
  $category_id = '';
182
+ if ( isset( $_GET["tag_ID"] ) )
183
+ $category_id = $_GET["tag_ID"];
184
 
185
+ $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ", ARRAY_A);
 
 
 
 
186
  $selectedCountries = wpsc_get_meta( $category_id, 'target_market', 'wpsc_category' );
187
  ?>
188
  <h4><?php esc_html_e( 'Restrict to Target Markets', 'wpsc' )?></h4>
238
  <?php $uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' ); ?>
239
  <div>
240
  <label><?php esc_html_e( 'Address to calculate shipping with', 'wpsc' ); ?></label>
241
+ <label><input type='radio' value='1' name='uses_billing_address' <?php echo ( ( $uses_billing_address == true ) ? "checked='checked'" : "" ); ?> /> <?php esc_html_e( 'Billing Address', 'wpsc' ); ?></label>
242
+ <label><input type='radio' value='0' name='uses_billing_address' <?php echo ( ( $uses_billing_address != true ) ? "checked='checked'" : "" ); ?> /> <?php esc_html_e( 'Default Setting', 'wpsc' ); ?></label>
243
  <p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wpsc' ); ?></p>
244
  </div>
245
 
304
  $display_type = isset( $category['display_type'] ) ? $category['display_type'] : '';
305
  ?>
306
  <select name='display_type'>
307
+ <option value='default'<?php checked( $display_type, 'default' ); ?>><?php esc_html_e( 'Default View', 'wpsc' ); ?></option>
308
+ <option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php checked( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wpsc'); ?></option>
309
+ <option value='grid' <?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php checked( $display_type, 'grid' ); ?>><?php esc_html_e( 'Grid View', 'wpsc' ); ?></option>
310
  </select><br />
311
  </td>
312
  </tr>
374
  </td>
375
  </tr>
376
  <?php
377
+ $countrylist = $wpdb->get_results( "SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A );
378
  $selectedCountries = wpsc_get_meta( $category_id,'target_market','wpsc_category' );
379
  ?>
380
  <tr>
448
  <label><?php esc_html_e( 'Address to calculate shipping with', 'wpsc' ); ?></label>
449
  </th>
450
  <td>
451
+ <label><input type='radio' class='wpsc_cat_box' value='0' name='uses_billing_address' <?php echo ( ( $uses_billing_address != true ) ? "checked='checked'" : "" ); ?> /> <?php esc_html_e( 'Default Setting', 'wpsc' ); ?></label>
452
+ <label><input type='radio' class='wpsc_cat_box' value='1' name='uses_billing_address' <?php echo ( ( $uses_billing_address == true ) ? "checked='checked'" : "" ); ?> /> <?php esc_html_e( 'Billing Address', 'wpsc' ); ?></label>
453
  <p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wpsc' ); ?></p>
454
  </td>
455
  </tr>
491
  //Good to here
492
  if ( isset( $_POST['tag_ID'] ) ) {
493
  //Editing
494
+ $category_id = $_POST['tag_ID'];
495
+ $category = get_term_by( 'id', $category_id, 'wpsc_product_category' );
496
+ $url_name = $category->slug;
497
 
498
  }
499
  if ( isset( $_POST['deleteimage'] ) && $_POST['deleteimage'] == 1 ) {
505
  if ( ! empty( $_POST['height'] ) && is_numeric( $_POST['height'] ) && ! empty( $_POST['width'] ) && is_numeric( $_POST['width'] ) && $image == null ) {
506
  $imagedata = wpsc_get_categorymeta( $category_id, 'image' );
507
  if ( $imagedata != null ) {
508
+ $height = $_POST['height'];
509
+ $width = $_POST['width'];
510
+ $imagepath = WPSC_CATEGORY_DIR . $imagedata;
511
  $image_output = WPSC_CATEGORY_DIR . $imagedata;
512
  image_processing( $imagepath, $image_output, $width, $height );
513
  }
517
  wpsc_update_categorymeta( $category_id, 'active', '1' );
518
  wpsc_update_categorymeta( $category_id, 'order', '0' );
519
 
520
+ if ( isset( $_POST['display_type'] ) )
521
  wpsc_update_categorymeta( $category_id, 'display_type', esc_sql( stripslashes( $_POST['display_type'] ) ) );
 
522
 
523
+ if ( isset( $_POST['image_height'] ) )
524
+ wpsc_update_categorymeta( $category_id, 'image_height', absint( $_POST['image_height'] ) );
 
525
 
526
+ if ( isset( $_POST['image_width'] ) )
527
+ wpsc_update_categorymeta( $category_id, 'image_width', absint($_POST['image_width'] ) );
 
528
 
529
  if ( ! empty( $_POST['use_additional_form_set'] ) ) {
530
  wpsc_update_categorymeta( $category_id, 'use_additional_form_set', $_POST['use_additional_form_set'] );
531
+ //exit('<pre>'.print_r($_POST,1).'</pre>');
532
  } else {
533
  wpsc_delete_categorymeta( $category_id, 'use_additional_form_set' );
534
  }
546
  $countryList = $wpdb->get_col( "SELECT `id` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" );
547
 
548
  if ( $AllSelected != true ){
549
+ $unselectedCountries = array_diff( $countryList, $_POST['countrylist2'] );
 
550
  //find the countries that are selected
551
+ $selectedCountries = array_intersect( $countryList, $_POST['countrylist2'] );
552
  wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries );
553
  }
554
 
wpsc-admin/includes/settings-tabs/admin.php CHANGED
@@ -1,11 +1,5 @@
1
  <?php
2
 
3
- /**
4
- * The Admin Settings Tab class
5
- *
6
- * @package wp-e-commerce
7
- */
8
-
9
  class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab {
10
  public function display() {
11
  ?>
@@ -14,7 +8,7 @@ class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab {
14
  <tr>
15
  <th scope="row"><?php esc_html_e( 'Max downloads per file', 'wpsc' ); ?>: </th>
16
  <td>
17
- <input type="number" min="0" size="10" value="<?php echo esc_attr( get_option('max_downloads') ); ?>" name="wpsc_options[max_downloads]" />
18
  </td>
19
  </tr>
20
  <?php
@@ -150,4 +144,4 @@ class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab {
150
  </table>
151
  <?php
152
  }
153
- }
1
  <?php
2
 
 
 
 
 
 
 
3
  class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab {
4
  public function display() {
5
  ?>
8
  <tr>
9
  <th scope="row"><?php esc_html_e( 'Max downloads per file', 'wpsc' ); ?>: </th>
10
  <td>
11
+ <input type="number" size="10" value="<?php echo esc_attr( get_option('max_downloads') ); ?>" name="wpsc_options[max_downloads]" />
12
  </td>
13
  </tr>
14
  <?php
144
  </table>
145
  <?php
146
  }
147
+ }
wpsc-admin/includes/settings-tabs/checkout.php CHANGED
@@ -21,7 +21,7 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
21
  $this->user_field_types = array('text','textarea','heading','select','radio','checkbox');
22
 
23
  if ( ! isset( $this->checkout_sets[$this->current_checkout_set] ) ) {
24
- wp_redirect( remove_query_arg( 'checkout_set' ) );
25
  exit;
26
  }
27
 
@@ -77,7 +77,7 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
77
  }
78
 
79
  if ( isset( $_POST['checkout_set'] ) ) {
80
- $_SERVER['REQUEST_URI'] = add_query_arg( 'checkout_set', $_POST['checkout_set'] );
81
  }
82
 
83
  if ( ! isset( $_POST['form_name'] ) && ! isset( $_POST['new_field_name'] ) )
@@ -163,7 +163,6 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
163
  'active' => empty( $_POST['new_field_display'][$key] ) ? 0 : 1,
164
  'mandatory' => empty( $_POST['new_field_mandatory'][$key] ) ? 0 : 1,
165
  'checkout_set' => $this->current_checkout_set,
166
- 'unique_name' => sanitize_title( $name ),
167
  );
168
 
169
  $data_format = array(
@@ -171,8 +170,6 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
171
  '%s', // type
172
  '%s', // active
173
  '%s', // mandatory
174
- '%s', // checkout set
175
- '%s', // unique name
176
  );
177
 
178
  if ( isset( $new_field_orders[$key] ) ) {
@@ -367,7 +364,7 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
367
  <label for='require_register2'><?php _e( 'Users can checkout without a user account', 'wpsc' );?></label><br />
368
  <input type='radio' value='1' name='wpsc_options[require_register]' id='require_register1' <?php checked( $this->require_register, 1 ); ?> />
369
  <label for='require_register1'><?php _e( 'Users must register before checking out', 'wpsc' );?></label>
370
- <p class='description'><?php esc_attr_e( 'Enabling this will also turn on "Membership: Anyone can register" from within WordPress Settings > General if it\'s not already enabled', 'wpsc' ); ?></p>
371
  </td>
372
  </tr>
373
 
21
  $this->user_field_types = array('text','textarea','heading','select','radio','checkbox');
22
 
23
  if ( ! isset( $this->checkout_sets[$this->current_checkout_set] ) ) {
24
+ wp_redirect( esc_url( remove_query_arg( 'checkout_set' ) ) );
25
  exit;
26
  }
27
 
77
  }
78
 
79
  if ( isset( $_POST['checkout_set'] ) ) {
80
+ $_SERVER['REQUEST_URI'] = esc_url( add_query_arg( 'checkout_set', $_POST['checkout_set'] ) );
81
  }
82
 
83
  if ( ! isset( $_POST['form_name'] ) && ! isset( $_POST['new_field_name'] ) )
163
  'active' => empty( $_POST['new_field_display'][$key] ) ? 0 : 1,
164
  'mandatory' => empty( $_POST['new_field_mandatory'][$key] ) ? 0 : 1,
165
  'checkout_set' => $this->current_checkout_set,
 
166
  );
167
 
168
  $data_format = array(
170
  '%s', // type
171
  '%s', // active
172
  '%s', // mandatory
 
 
173
  );
174
 
175
  if ( isset( $new_field_orders[$key] ) ) {
364
  <label for='require_register2'><?php _e( 'Users can checkout without a user account', 'wpsc' );?></label><br />
365
  <input type='radio' value='1' name='wpsc_options[require_register]' id='require_register1' <?php checked( $this->require_register, 1 ); ?> />
366
  <label for='require_register1'><?php _e( 'Users must register before checking out', 'wpsc' );?></label>
367
+ <p class='description'><?php esc_attr_e( 'If users must register, you must also turn on "Membership: Anyone can register" from within WordPress Settings &gt; General', 'wpsc' ); ?></p>
368
  </td>
369
  </tr>
370
 
wpsc-admin/includes/settings-tabs/gateway.php CHANGED
@@ -24,11 +24,11 @@ class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
24
  $location = isset( $_REQUEST['current_url'] ) ? $_REQUEST['current_url'] : $_SERVER['REQUEST_URI'];
25
  $gateway = ! empty( $gateway ) ? $gateway : '';
26
 
27
- return add_query_arg( array(
28
  'tab' => 'gateway',
29
  'page' => 'wpsc-settings',
30
  'payment_gateway_id' => $gateway
31
- ), $location );
32
  }
33
 
34
  public function display_payment_gateway_settings_form( $selected_gateway = null ) {
@@ -91,8 +91,10 @@ class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
91
  </tbody>
92
  </table>
93
  <?php submit_button( __( 'Save Changes' ) ); ?>
94
- <h4><?php _e( 'WP eCommerce Recommends', 'wpsc' ); ?></h4>
95
  <a style="border-bottom:none;" href="https://www.paypal.com/nz/mrb/pal=LENKCHY6CU2VY" target="_blank"><img src="<?php echo WPSC_CORE_IMAGES_URL; ?>/paypal-referal.gif" border="0" alt="<?php esc_attr_e( 'Sign up for PayPal and start accepting credit card payments instantly.', 'wpsc' ); ?>" /></a>
 
 
96
  <?php
97
  }
98
 
@@ -138,11 +140,8 @@ class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
138
  }
139
 
140
  private function gateway_list() {
141
-
142
  $gateways = apply_filters( 'wpsc_settings_get_gateways', array() );
143
 
144
- usort( $gateways, apply_filters( 'wpsc_settings_get_gateways_sort_callback', array( $this, 'gateway_usort_callback' ), $gateways, $this ) );
145
-
146
  $selected_gateway = (string) get_user_option( 'wpsc_settings_selected_payment_gateway', get_current_user_id() );
147
 
148
  foreach ( $gateways as $gateway ) {
@@ -150,21 +149,7 @@ class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
150
  }
151
  }
152
 
153
- /**
154
- * Usort callback used to order gateways by their name.
155
- *
156
- * @param array $a A gateway array.
157
- * @param array $b A different gateway array.
158
- *
159
- * @since 3.9.0
160
- *
161
- * @return bool True if $b should be ordered after $a based on its name.
162
- */
163
- private function gateway_usort_callback( $a, $b ) {
164
- return $a['name'] > $b['name'];
165
- }
166
-
167
  public function callback_submit_options() {
168
  do_action( 'wpsc_submit_gateway_options' );
169
  }
170
- }
24
  $location = isset( $_REQUEST['current_url'] ) ? $_REQUEST['current_url'] : $_SERVER['REQUEST_URI'];
25
  $gateway = ! empty( $gateway ) ? $gateway : '';
26
 
27
+ return esc_url( add_query_arg( array(
28
  'tab' => 'gateway',
29
  'page' => 'wpsc-settings',
30
  'payment_gateway_id' => $gateway
31
+ ), $location ) );
32
  }
33
 
34
  public function display_payment_gateway_settings_form( $selected_gateway = null ) {
91
  </tbody>
92
  </table>
93
  <?php submit_button( __( 'Save Changes' ) ); ?>
94
+ <h4><?php _e( 'WP e-Commerce Recommends', 'wpsc' ); ?></h4>
95
  <a style="border-bottom:none;" href="https://www.paypal.com/nz/mrb/pal=LENKCHY6CU2VY" target="_blank"><img src="<?php echo WPSC_CORE_IMAGES_URL; ?>/paypal-referal.gif" border="0" alt="<?php esc_attr_e( 'Sign up for PayPal and start accepting credit card payments instantly.', 'wpsc' ); ?>" /></a>
96
+ <a style="border-bottom:none;" href="http://checkout.google.com/sell/?promo=seinstinct" target="_blank"><img src="https://checkout.google.com/buyer/images/google_checkout.gif" border="0" alt="<?php esc_attr_e( 'Sign up for Google Checkout', 'wpsc' ); ?>" /></a>
97
+
98
  <?php
99
  }
100
 
140
  }
141
 
142
  private function gateway_list() {
 
143
  $gateways = apply_filters( 'wpsc_settings_get_gateways', array() );
144
 
 
 
145
  $selected_gateway = (string) get_user_option( 'wpsc_settings_selected_payment_gateway', get_current_user_id() );
146
 
147
  foreach ( $gateways as $gateway ) {
149
  }
150
  }
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  public function callback_submit_options() {
153
  do_action( 'wpsc_submit_gateway_options' );
154
  }
155
+ }
wpsc-admin/includes/settings-tabs/general.php CHANGED
@@ -61,7 +61,7 @@ class WPSC_Settings_Tab_General extends WPSC_Settings_Tab {
61
 
62
  <?php
63
  /* START OF TARGET MARKET SELECTION */
64
- $countrylist = WPSC_Countries::get_countries_array( true, true );
65
  ?>
66
  <tr>
67
  <th scope="row">
@@ -75,7 +75,7 @@ class WPSC_Settings_Tab_General extends WPSC_Settings_Tab {
75
  } else {
76
  ?>
77
  <span>
78
- <?php printf( __( 'Select: <a href="%1$s" class="wpsc-select-all" title="All">All</a> <a href="%2$s" class="wpsc-select-none" title="None">None</a>' , 'wpsc') , add_query_arg( array( 'selected_all' => 'all' ) ), add_query_arg( array( 'selected_all' => 'none' ) ) ); ?>
79
  </span><br />
80
  <div id='wpsc-target-markets' class='ui-widget-content multiple-select'>
81
  <?php foreach ( (array)$countrylist as $country ) : ?>
@@ -97,8 +97,8 @@ class WPSC_Settings_Tab_General extends WPSC_Settings_Tab {
97
  </tr>
98
 
99
  <?php
100
- $stock_keeping_time = wpsc_get_stock_keeping_time();
101
- $stock_keeping_interval = wpsc_get_stock_keeping_interval();
102
  ?>
103
  <tr>
104
  <th scope="row">
61
 
62
  <?php
63
  /* START OF TARGET MARKET SELECTION */
64
+ $countrylist = $wpdb->get_results( "SELECT id,country,visible FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ", ARRAY_A );
65
  ?>
66
  <tr>
67
  <th scope="row">
75
  } else {
76
  ?>
77
  <span>
78
+ <?php printf( __( 'Select: <a href="%1$s" class="wpsc-select-all" title="All">All</a> <a href="%2$s" class="wpsc-select-none" title="None">None</a>' , 'wpsc') , esc_url( add_query_arg( array( 'selected_all' => 'all' ) ) ), esc_url( add_query_arg( array( 'selected_all' => 'none' ) ) ) ); ?>
79
  </span><br />
80
  <div id='wpsc-target-markets' class='ui-widget-content multiple-select'>
81
  <?php foreach ( (array)$countrylist as $country ) : ?>
97
  </tr>
98
 
99
  <?php
100
+ $stock_keeping_time = get_option( 'wpsc_stock_keeping_time', 1 );
101
+ $stock_keeping_interval = get_option( 'wpsc_stock_keeping_interval', 'day' );
102
  ?>
103
  <tr>
104
  <th scope="row">
wpsc-admin/includes/settings-tabs/import.php CHANGED
@@ -1,40 +1,21 @@
1
  <?php
2
 
3
  class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
4
-
5
- private $file = false;
6
- private $step = 1;
7
- private $display_data = array();
8
- private $completed = false;
9
- private $default_fields = array();
10
 
11
  public function __construct() {
12
-
13
  parent::__construct();
14
 
15
  $file = get_transient( 'wpsc_settings_tab_import_file' );
16
-
17
- if ( $file ) {
18
  $this->file = $file;
19
- }
20
 
21
  $this->step = empty( $_REQUEST['step'] ) ? 1 : (int) $_REQUEST['step'];
22
-
23
- if ( $this->step < 1 || $this->step > 3 ) {
24
  $this->step = 1;
25
- }
26
-
27
- $this->default_fields = apply_filters( 'wpsc_product_import_default_fields', array(
28
- 'column_name' => __( 'Product Name' , 'wpsc' ),
29
- 'column_description' => __( 'Description' , 'wpsc' ),
30
- 'column_additional_description' => __( 'Additional Description', 'wpsc' ),
31
- 'column_price' => __( 'Price' , 'wpsc' ),
32
- 'column_sku' => __( 'SKU' , 'wpsc' ),
33
- 'column_weight' => __( 'Weight' , 'wpsc' ),
34
- 'column_weight_unit' => __( 'Weight Unit' , 'wpsc' ),
35
- 'column_quantity' => __( 'Stock Quantity' , 'wpsc' ),
36
- 'column_quantity_limited' => __( 'Stock Quantity Limit' , 'wpsc' )
37
- ) );
38
 
39
  switch ( $this->step ) {
40
  case 2:
@@ -50,7 +31,6 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
50
 
51
  private function prepare_import_columns() {
52
  $this->hide_update_message();
53
-
54
  ini_set( 'auto_detect_line_endings', 1 );
55
  $handle = @fopen( $this->file, 'r' );
56
 
@@ -58,74 +38,64 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
58
  $this->reset_state();
59
  return;
60
  }
61
-
62
  $rows = array();
63
-
64
- while ( count( $rows ) < 5 && ( false !== ( $data = fgetcsv( $handle ) ) ) ) {
65
  array_push( $rows, $data );
66
  }
67
 
68
  $sample_row_data = array();
69
-
70
  foreach ( $rows as $row => $columns ) {
71
  foreach ( $columns as $column => $data ) {
72
-
73
- if ( ! isset( $sample_row_data[ $column ] ) ) {
74
- $sample_row_data[ $column ] = array();
75
- }
76
-
77
- array_push( $sample_row_data[ $column ], $data );
78
  }
79
  }
80
 
81
  $categories = get_terms( 'wpsc_product_category', 'hide_empty=0' );
82
 
83
  $this->display_data = array(
84
- 'sample_row_data' => $sample_row_data,
85
- 'categories' => $categories,
86
  );
87
  }
88
 
89
  private function reset_state() {
90
  delete_transient( 'wpsc_settings_tab_import_file' );
91
- $this->file = false;
92
- $this->completed = false;
93
  $this->display_data = array();
94
  }
95
 
96
  private function import_data() {
97
  ini_set( 'auto_detect_line_endings', 1 );
98
-
99
- $handle = @fopen( $this->file, 'r' );
100
-
101
  if ( ! $handle ) {
102
  $this->reset_state();
103
  return;
104
  }
105
 
106
- $length = filesize( $this->file );
107
 
108
  $column_map = array_flip( $_POST['value_name'] );
109
-
110
  extract( $column_map, EXTR_SKIP );
111
 
112
  $record_count = 0;
113
 
114
  while ( $row = @fgetcsv( $handle, $length, ',' ) ) {
115
-
116
  $product = array(
117
- 'post_title' => isset( $row[ $column_name ] ) ? $row[ $column_name ] : '',
118
- 'content' => isset( $row[ $column_description ] ) ? $row[ $column_description ] : '',
119
- 'price' => isset( $row[ $column_price ] ) ? str_replace( '$', '', $row[ $column_price ] ) : 0,
120
- 'weight' => isset( $row[ $column_weight ] ) ? $row[ $column_weight] : '',
121
- 'weight_unit' => isset( $row[ $column_weight_unit ] ) ? $row[ $column_weight_unit ] : '',
122
- 'additional_description' => isset( $row[ $column_additional_description ] ) ? $row[ $column_additional_description ] : '',
123
  'pnp' => null,
124
  'international_pnp' => null,
125
  'file' => null,
126
  'image' => '0',
127
- 'quantity_limited' => isset( $row[ $column_quantity_limited ] ) ? $row[ $column_quantity_limited ] : '',
128
- 'quantity' => isset( $row[ $column_quantity ] ) ? $row[ $column_quantity ] : null,
129
  'special' => null,
130
  'special_price' => null,
131
  'display_frontpage' => null,
@@ -148,23 +118,13 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
148
  )
149
  );
150
 
151
- $product = apply_filters( 'wpsc_product_import_row', $product, $row, $this );
152
-
153
- if ( empty( $product['post_title'] ) && apply_filters( 'wpsc_product_import_require_title', true, $product, $row, $this ) ) {
154
- continue;
155
- }
156
-
157
  $product = wpsc_sanitise_product_forms( $product );
158
-
159
  // status needs to be set here because wpsc_sanitise_product_forms overwrites it :/
160
  $product['post_status'] = $_POST['post_status'];
161
-
162
  $product_id = wpsc_insert_product( $product );
163
-
164
- if ( (int) $_POST['category'] > 0 ) {
165
- wp_set_object_terms( $product_id , array( (int) $_POST['category'] ) , 'wpsc_product_category' );
166
  }
167
-
168
  $record_count += 1;
169
  }
170
 
@@ -185,9 +145,8 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
185
  }
186
  }
187
 
188
- if ( $this->completed ) {
189
  return array( 'step' => 1 );
190
- }
191
 
192
  return array( 'step' => $this->step + 1 );
193
  }
@@ -207,7 +166,7 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
207
  </tr>
208
  </thead>
209
  <tbody>
210
- <?php foreach ( $sample_row_data as $key => $sample_data ) : ?>
211
  <tr>
212
  <td>
213
  <p><?php printf( __('Column %s', 'wpsc' ), $this->num_to_alphacolumn( $key ) ); ?></p>
@@ -227,16 +186,16 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
227
  </td>
228
  <td>
229
  <p>
230
- <select name='value_name[<?php echo $key; ?>]'>
231
- <?php
232
- $i = 0;
233
- foreach ( $this->default_fields as $value => $label ) :
234
- ?>
235
- <option <?php selected( $key, $i ); ?> value='<?php echo esc_attr( $value ); ?>'><?php echo esc_html( $label ); ?></option>
236
- <?php
237
- $i++;
238
- endforeach;
239
- ?>
240
  </select>
241
  </p>
242
  </td>
@@ -277,16 +236,14 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
277
  </table>
278
  <input type="hidden" name="step" value="3" />
279
  <input type='submit' value='<?php echo esc_html_x( 'Import Products', 'import csv', 'wpsc' ); ?>' class='button-primary'>
 
280
  <?php
281
  }
282
 
283
  private function num_to_alphacolumn($n) {
284
  // from http://stackoverflow.com/questions/3302857/algorithm-to-get-the-excel-like-column-name-of-a-number
285
-
286
- for( $r = ""; $n >= 0; $n = intval( $n / 26 ) - 1 ) {
287
  $r = chr( $n % 26 + 0x41) . $r;
288
- }
289
-
290
  return $r;
291
  }
292
 
@@ -305,7 +262,6 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
305
  </td>
306
  </tr>
307
  </table>
308
-
309
  <?php submit_button( esc_html_x( 'Upload', 'import csv', 'wpsc' ) ); ?>
310
 
311
  <h4><?php _e( 'Useful Information', 'wpsc' ); ?></h4>
@@ -315,7 +271,7 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
315
  <td>
316
  <?php _e( 'Columns supported are, in their default order:', 'wpsc'); ?><br />
317
  <code>
318
- <?php echo implode( ', ', $this->default_fields ); ?>
319
  </code>
320
  </td>
321
  </tr>
@@ -323,7 +279,7 @@ class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
323
  <th><?php _e( 'Understood Weight Units', 'wpsc' ); ?></th>
324
  <td>
325
  <?php _e( 'Metric', 'wpsc' ); ?>: <code>kilogram</code>,<code>kilograms</code>,<code>kg</code>,<code>kgs</code>,<code>gram</code>,<code>grams</code>,<code>g</code>,<code>gs</code><br />
326
- <?php _e( 'Imperial', 'wpsc' ); ?>: <code>ounce</code>,<code>ounces</code>,<code>oz</code>,<code>pound</code>,<code>pounds</code>,<code>lb</code>,<code>lbs</code>
327
  </td>
328
  </tr>
329
  <tr>
1
  <?php
2
 
3
  class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
4
+ private $file = false;
5
+ private $step = 1;
6
+ private $display_data = array();
7
+ private $completed = false;
 
 
8
 
9
  public function __construct() {
 
10
  parent::__construct();
11
 
12
  $file = get_transient( 'wpsc_settings_tab_import_file' );
13
+ if ( $file )
 
14
  $this->file = $file;
 
15
 
16
  $this->step = empty( $_REQUEST['step'] ) ? 1 : (int) $_REQUEST['step'];
17
+ if ( $this->step < 1 || $this->step > 3 )
 
18
  $this->step = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  switch ( $this->step ) {
21
  case 2:
31
 
32
  private function prepare_import_columns() {
33
  $this->hide_update_message();
 
34
  ini_set( 'auto_detect_line_endings', 1 );
35
  $handle = @fopen( $this->file, 'r' );
36
 
38
  $this->reset_state();
39
  return;
40
  }
 
41
  $rows = array();
42
+ while ( count($rows) < 5 && ( $data = fgetcsv($handle) ) !== FALSE ) {
 
43
  array_push( $rows, $data );
44
  }
45
 
46
  $sample_row_data = array();
 
47
  foreach ( $rows as $row => $columns ) {
48
  foreach ( $columns as $column => $data ) {
49
+ if ( ! isset( $sample_row_data[$column] ) )
50
+ $sample_row_data[$column] = array();
51
+ array_push( $sample_row_data[$column], $data );
 
 
 
52
  }
53
  }
54
 
55
  $categories = get_terms( 'wpsc_product_category', 'hide_empty=0' );
56
 
57
  $this->display_data = array(
58
+ 'sample_row_data' => $sample_row_data,
59
+ 'categories' => $categories,
60
  );
61
  }
62
 
63
  private function reset_state() {
64
  delete_transient( 'wpsc_settings_tab_import_file' );
65
+ $this->file = false;
66
+ $this->completed = false;
67
  $this->display_data = array();
68
  }
69
 
70
  private function import_data() {
71
  ini_set( 'auto_detect_line_endings', 1 );
72
+ $handle = @fopen( $this->file, 'r' );
 
 
73
  if ( ! $handle ) {
74
  $this->reset_state();
75
  return;
76
  }
77
 
78
+ $length = filesize( $this->file );
79
 
80
  $column_map = array_flip( $_POST['value_name'] );
 
81
  extract( $column_map, EXTR_SKIP );
82
 
83
  $record_count = 0;
84
 
85
  while ( $row = @fgetcsv( $handle, $length, ',' ) ) {
 
86
  $product = array(
87
+ 'post_title' => isset( $row[$column_name] ) ? $row[$column_name] : '',
88
+ 'content' => isset( $row[$column_description] ) ? $row[$column_description] : '',
89
+ 'additional_description' => isset( $row[$column_additional_description] ) ? $row[$column_additional_description] : '',
90
+ 'price' => isset( $row[$column_price] ) ? str_replace( '$', '', $row[$column_price] ) : 0,
91
+ 'weight' => isset( $row[$column_weight] ) ? $row[$column_weight] : '',
92
+ 'weight_unit' => isset( $row[$column_weight_unit] ) ? $row[$column_weight_unit] : '',
93
  'pnp' => null,
94
  'international_pnp' => null,
95
  'file' => null,
96
  'image' => '0',
97
+ 'quantity_limited' => isset( $row[$column_quantity_limited] ) ? $row[$column_quantity_limited] : '',
98
+ 'quantity' => isset( $row[$column_quantity] ) ? $row[$column_quantity] : null,
99
  'special' => null,
100
  'special_price' => null,
101
  'display_frontpage' => null,
118
  )
119
  );
120
 
 
 
 
 
 
 
121
  $product = wpsc_sanitise_product_forms( $product );
 
122
  // status needs to be set here because wpsc_sanitise_product_forms overwrites it :/
123
  $product['post_status'] = $_POST['post_status'];
 
124
  $product_id = wpsc_insert_product( $product );
125
+ if ( (int)$_POST['category'] > 0 ) {
126
+ wp_set_object_terms( $product_id , array( (int)$_POST['category'] ) , 'wpsc_product_category' );
 
127
  }
 
128
  $record_count += 1;
129
  }
130
 
145
  }
146
  }
147
 
148
+ if ( $this->completed )
149
  return array( 'step' => 1 );
 
150
 
151
  return array( 'step' => $this->step + 1 );
152
  }
166
  </tr>
167
  </thead>
168
  <tbody>
169
+ <?php foreach ( $sample_row_data as $key => $sample_data ): ?>
170
  <tr>
171
  <td>
172
  <p><?php printf( __('Column %s', 'wpsc' ), $this->num_to_alphacolumn( $key ) ); ?></p>
186
  </td>
187
  <td>
188
  <p>
189
+ <select name='value_name[<?php echo $key; ?>]'>
190
+ <option <?php selected( $key, 0 ); ?> value='column_name' ><?php esc_html_e( 'Product Name' , 'wpsc' ); ?></option>
191
+ <option <?php selected( $key, 1 ); ?> value='column_description' ><?php esc_html_e( 'Description' , 'wpsc' ); ?></option>
192
+ <option <?php selected( $key, 2 ); ?> value='column_additional_description'><?php esc_html_e( 'Additional Description', 'wpsc' ); ?></option>
193
+ <option <?php selected( $key, 3 ); ?> value='column_price' ><?php esc_html_e( 'Price' , 'wpsc' ); ?></option>
194
+ <option <?php selected( $key, 4 ); ?> value='column_sku' ><?php esc_html_e( 'SKU' , 'wpsc' ); ?></option>
195
+ <option <?php selected( $key, 5 ); ?> value='column_weight' ><?php esc_html_e( 'Weight' , 'wpsc' ); ?></option>
196
+ <option <?php selected( $key, 6 ); ?> value='column_weight_unit' ><?php esc_html_e( 'Weight Unit' , 'wpsc' ); ?></option>
197
+ <option <?php selected( $key, 7 ); ?> value='column_quantity' ><?php esc_html_e( 'Stock Quantity' , 'wpsc' ); ?></option>
198
+ <option <?php selected( $key, 8 ); ?> value='column_quantity_limited' ><?php esc_html_e( 'Stock Quantity Limit' , 'wpsc' ); ?></option>
199
  </select>
200
  </p>
201
  </td>
236
  </table>
237
  <input type="hidden" name="step" value="3" />
238
  <input type='submit' value='<?php echo esc_html_x( 'Import Products', 'import csv', 'wpsc' ); ?>' class='button-primary'>
239
+
240
  <?php
241
  }
242
 
243
  private function num_to_alphacolumn($n) {
244
  // from http://stackoverflow.com/questions/3302857/algorithm-to-get-the-excel-like-column-name-of-a-number
245
+ for( $r = ""; $n >= 0; $n = intval( $n / 26 ) - 1 )
 
246
  $r = chr( $n % 26 + 0x41) . $r;
 
 
247
  return $r;
248
  }
249
 
262
  </td>
263
  </tr>
264
  </table>
 
265
  <?php submit_button( esc_html_x( 'Upload', 'import csv', 'wpsc' ) ); ?>
266
 
267
  <h4><?php _e( 'Useful Information', 'wpsc' ); ?></h4>
271
  <td>
272
  <?php _e( 'Columns supported are, in their default order:', 'wpsc'); ?><br />
273
  <code>
274
+ <?php _e( 'Product Name, Description, Additional Description, Price, SKU, Weight, Weight Unit, Stock Quantity, Stock Quantity Limited', 'wpsc' ); ?>
275
  </code>
276
  </td>
277
  </tr>
279
  <th><?php _e( 'Understood Weight Units', 'wpsc' ); ?></th>
280
  <td>
281
  <?php _e( 'Metric', 'wpsc' ); ?>: <code>kilogram</code>,<code>kilograms</code>,<code>kg</code>,<code>kgs</code>,<code>gram</code>,<code>grams</code>,<code>g</code>,<code>gs</code><br />
282
+ <?php _e( 'Imperial', 'wpsc' ); ?>: <code>ounce</code>,<code>once</code>,<code>ounces</code>,<code>oz</code>,<code>pound</code>,<code>pounds</code>,<code>lb</code>,<code>lbs</code>
283
  </td>
284
  </tr>
285
  <tr>
wpsc-admin/includes/settings-tabs/marketing.php CHANGED
@@ -168,17 +168,6 @@ class WPSC_Settings_Tab_Marketing extends WPSC_Settings_Tab {
168
  <span class='description'><?php _e( 'e.g. <code>UA-XXXXX-Y</code>', 'wpsc' ); ?></span>
169
  </td>
170
  </tr>
171
- <tr>
172
- <th>
173
- <?php _e( 'Universal Analytics', 'wpsc' ); ?>
174
- </th>
175
- <td>
176
- <label>
177
- <input value="1" <?php checked( '1', get_option( 'wpsc_ga_use_universal' ) ); ?> type="checkbox" name="wpsc_ga_use_universal" />
178
- <?php printf( __( 'Use <a%s>Universal Analytics</a> tracking code', 'wpsc' ), ' href="https://support.google.com/analytics/answer/2790010?hl=en-GB&ref_topic=6010376" target="universal_analytics"' ); ?>
179
- </label>
180
- </td>
181
- </tr>
182
  <tr>
183
  <th>
184
  <?php _e( 'Tracking Code Present', 'wpsc' ); ?>
168
  <span class='description'><?php _e( 'e.g. <code>UA-XXXXX-Y</code>', 'wpsc' ); ?></span>
169
  </td>
170
  </tr>
 
 
 
 
 
 
 
 
 
 
 
171
  <tr>
172
  <th>
173
  <?php _e( 'Tracking Code Present', 'wpsc' ); ?>
wpsc-admin/includes/settings-tabs/shipping.php CHANGED
@@ -53,15 +53,11 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
53
  }
54
  }
55
 
56
- if ( isset( $_POST['wpsc_options']['shipping_discount_value'] ) ) {
57
- update_option( 'shipping_discount_value', wpsc_string_to_float( $_POST['wpsc_options']['shipping_discount_value'] ) );
58
- }
59
-
60
  if ( ! get_option( 'do_not_use_shipping' ) && ! get_option( 'custom_shipping_options' ) && ! ( bool ) get_option( 'shipwire' ) ) {
61
  update_option( 'do_not_use_shipping', '1' );
62
  return array( 'shipping_disabled' => 1 );
63
  } else {
64
- $_SERVER['REQUEST_URI'] = remove_query_arg( 'shipping_disabled' );
65
  }
66
  }
67
 
@@ -107,7 +103,7 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
107
  'shipping_module_id' => $shipping->getInternalName(),
108
  ), $location );
109
  $location .= '#wpsc-shipping-module-options';
110
- return $location;
111
  }
112
 
113
  public function display() {
@@ -168,7 +164,7 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
168
  <input type='hidden' value='0' name='wpsc_options[shipwire]' />
169
  <input type='checkbox' onclick='jQuery("#wpsc_shipwire_setting").toggle( jQuery(this).prop("checked") );' value='1' name='wpsc_options[shipwire]' id='shipwire' <?php checked( '1', get_option( 'shipwire' ) ); ?> />
170
  <label for='shipwire'><?php _e( 'Enable Shipwire Integration', 'wpsc' ); ?></label>
171
- <p class='description'><?php printf( __( '<a href="%1$s" target="_blank">Shipwire</a> provide e-commerce fulfillment warehouses. WP eCommerce can integrate stock inventory and shipping tracking with their service.', 'wpsc' ), 'http://www.shipwire.com/' ); ?></p>
172
  </td>
173
  </tr>
174
  <?php
@@ -210,7 +206,7 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
210
  </td>
211
  </tr>
212
  <?php
213
- $currency_data = WPSC_Countries::get_currency_data( get_option( 'currency_type' ), true );
214
  if ( $currency_data['symbol'] != '' ) {
215
  $currency_sign = $currency_data['symbol_html'];
216
  } else {
@@ -237,11 +233,11 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
237
  <td>&nbsp;</td>
238
  <td colspan="2">
239
  <?php
240
- $value = wpsc_format_number( get_option( 'shipping_discount_value' ) );
241
  ?>
242
  <div <?php echo $shipping_discount_settings; ?> id='shipping_discount_value'>
243
 
244
- <?php printf( __( 'Sales over or equal to %1$s<input type="text" size="6" name="wpsc_options[shipping_discount_value]" value="%2$s" id="shipping_discount_value" /> will receive free shipping.', 'wpsc' ), $currency_sign, esc_attr( $value ) ); ?>
245
  </div>
246
  </td>
247
  </tr>
@@ -250,7 +246,7 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
250
  <?php submit_button( __( 'Save Changes' ) ); ?>
251
 
252
  <h3><?php _e( 'Shipping Modules', 'wpsc' ) ?></h3>
253
- <p class='description'><?php _e( 'To enable shipping in WP eCommerce you must select which shipping methods you want to enable on your site.', 'wpsc' ); ?></p>
254
  <p class='description'>
255
  <strong><?php _e( 'Tip', 'wpsc' ); ?></strong>:
256
  <?php printf( __( 'For fixed-price shipping options such as "Pickup - $0, Overnight - $10, Same day - $20, etc.", install our free <a href="%1$s">Fixed Rate Shipping</a> plugin.', 'wpsc' ), 'http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/' ); ?>
53
  }
54
  }
55
 
 
 
 
 
56
  if ( ! get_option( 'do_not_use_shipping' ) && ! get_option( 'custom_shipping_options' ) && ! ( bool ) get_option( 'shipwire' ) ) {
57
  update_option( 'do_not_use_shipping', '1' );
58
  return array( 'shipping_disabled' => 1 );
59
  } else {
60
+ $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( 'shipping_disabled' ) );
61
  }
62
  }
63
 
103
  'shipping_module_id' => $shipping->getInternalName(),
104
  ), $location );
105
  $location .= '#wpsc-shipping-module-options';
106
+ return esc_url( $location );
107
  }
108
 
109
  public function display() {
164
  <input type='hidden' value='0' name='wpsc_options[shipwire]' />
165
  <input type='checkbox' onclick='jQuery("#wpsc_shipwire_setting").toggle( jQuery(this).prop("checked") );' value='1' name='wpsc_options[shipwire]' id='shipwire' <?php checked( '1', get_option( 'shipwire' ) ); ?> />
166
  <label for='shipwire'><?php _e( 'Enable Shipwire Integration', 'wpsc' ); ?></label>
167
+ <p class='description'><?php printf( __( '<a href="%1$s" target="_blank">Shipwire</a> provide e-commerce fulfillment warehouses. WP e-Commerce can integrate stock inventory and shipping tracking with their service.', 'wpsc' ), 'http://www.shipwire.com/' ); ?></p>
168
  </td>
169
  </tr>
170
  <?php
206
  </td>
207
  </tr>
208
  <?php
209
+ $currency_data = $wpdb->get_row( $wpdb->prepare( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", get_option( 'currency_type' ) ), ARRAY_A );
210
  if ( $currency_data['symbol'] != '' ) {
211
  $currency_sign = $currency_data['symbol_html'];
212
  } else {
233
  <td>&nbsp;</td>
234
  <td colspan="2">
235
  <?php
236
+ $value = esc_attr( get_option( 'shipping_discount_value' ) );
237
  ?>
238
  <div <?php echo $shipping_discount_settings; ?> id='shipping_discount_value'>
239
 
240
+ <?php printf( __( 'Sales over or equal to %1$s<input type="text" size="6" name="wpsc_options[shipping_discount_value]" value="%2$s" id="shipping_discount_value" /> will receive free shipping.', 'wpsc' ), $currency_sign, $value ); ?>
241
  </div>
242
  </td>
243
  </tr>
246
  <?php submit_button( __( 'Save Changes' ) ); ?>
247
 
248
  <h3><?php _e( 'Shipping Modules', 'wpsc' ) ?></h3>
249
+ <p class='description'><?php _e( 'To enable shipping in WP e-Commerce you must select which shipping methods you want to enable on your site.', 'wpsc' ); ?></p>
250
  <p class='description'>
251
  <strong><?php _e( 'Tip', 'wpsc' ); ?></strong>:
252
  <?php printf( __( 'For fixed-price shipping options such as "Pickup - $0, Overnight - $10, Same day - $20, etc.", install our free <a href="%1$s">Fixed Rate Shipping</a> plugin.', 'wpsc' ), 'http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/' ); ?>
wpsc-admin/includes/settings-tabs/taxes.php CHANGED
@@ -117,7 +117,7 @@ class WPSC_Settings_Tab_Taxes extends WPSC_Settings_Tab {
117
  <td>
118
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) echo 'checked="checked"'; ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
119
  <label for='wpec_taxes_logic_1'>
120
- <?php esc_html_e( 'Apply tax when Billing and Shipping Region is the same as Tax Rate', 'wpsc' ); ?>
121
  </label>
122
  <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
123
  <?php
@@ -137,11 +137,11 @@ class WPSC_Settings_Tab_Taxes extends WPSC_Settings_Tab {
137
  </div>
138
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) echo 'checked="checked"'; ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
139
  <label for='wpec_taxes_logic_2'>
140
- <?php esc_html_e( 'Apply tax when Billing Region is the same as Tax Rate', 'wpsc' ); ?>
141
  </label><br />
142
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) echo 'checked="checked"'; ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
143
  <label for='wpec_taxes_logic_3'>
144
- <?php esc_html_e( 'Apply tax when Shipping Region is the same as Tax Rate', 'wpsc' ); ?>
145
  </label>
146
  </td>
147
  </tr>
@@ -180,13 +180,9 @@ class WPSC_Settings_Tab_Taxes extends WPSC_Settings_Tab {
180
  <div id='wpec-taxes-bands-container'>
181
  <h3><?php esc_html_e( 'Tax Bands', 'wpsc' ); ?></h3>
182
  <div id='wpec-taxes-bands'>
183
- <div class="updated inline">
184
- <p><?php _e( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis. Please visit the product page to apply your Tax Band.', 'wpsc' ); ?></p>
185
- </div>
186
  <?php if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) : ?>
187
- <div class="error inline">
188
- <p><?php _e( 'Warning: Tax Bands do not take effect when product prices are tax exclusive.', 'wpsc' ); ?></p>
189
- </div>
190
  <?php endif; ?>
191
  <table class='widefat page fixed ui-sortable'>
192
  <thead>
117
  <td>
118
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) echo 'checked="checked"'; ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
119
  <label for='wpec_taxes_logic_1'>
120
+ <?php esc_html_e( 'Apply tax when Billing and Shipping Country is the same as Tax Rate', 'wpsc' ); ?>
121
  </label>
122
  <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
123
  <?php
137
  </div>
138
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) echo 'checked="checked"'; ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
139
  <label for='wpec_taxes_logic_2'>
140
+ <?php esc_html_e( 'Apply tax when Billing Country is the same as Tax Rate', 'wpsc' ); ?>
141
  </label><br />
142
  <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) echo 'checked="checked"'; ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
143
  <label for='wpec_taxes_logic_3'>
144
+ <?php esc_html_e( 'Apply tax when Shipping Country is the same as Tax Rate', 'wpsc' ); ?>
145
  </label>
146
  </td>
147
  </tr>
180
  <div id='wpec-taxes-bands-container'>
181
  <h3><?php esc_html_e( 'Tax Bands', 'wpsc' ); ?></h3>
182
  <div id='wpec-taxes-bands'>
183
+ <p><?php _e( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis. Please visit the product page to apply your Tax Band.', 'wpsc' ); ?></p>
 
 
184
  <?php if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) : ?>
185
+ <p class="form-invalid"><?php _e( 'Warning: Tax Bands do not take affect when product prices are tax exclusive.', 'wpsc' ); ?></p>
 
 
186
  <?php endif; ?>
187
  <table class='widefat page fixed ui-sortable'>
188
  <thead>
wpsc-admin/includes/tax_and_shipping.php CHANGED
@@ -1,10 +1,4 @@
1
  <?php
2
-
3
- /**
4
- * The HTML outputting the tax and shipping form
5
- *
6
- * @package wp-e-commerce
7
- */
8
  global $wpdb;
9
  $changes_made = false;
10
  $country_isocode = preg_match( "/[a-zA-Z]{2,4}/", $_GET['isocode'] ) ? $_GET['isocode'] : get_option( 'base_country' );
@@ -63,4 +57,4 @@ $base_region = get_option('base_region');
63
  <input type='hidden' name='wpsc_admin_action' value='change_region_tax' />
64
  <input class='button-secondary' type='submit' name='submit' value='<?php esc_attr_e( 'Save Changes', 'wpsc' );?>' />
65
  </form>
66
- </div>
1
  <?php
 
 
 
 
 
 
2
  global $wpdb;
3
  $changes_made = false;
4
  $country_isocode = preg_match( "/[a-zA-Z]{2,4}/", $_GET['isocode'] ) ? $_GET['isocode'] : get_option( 'base_country' );
57
  <input type='hidden' name='wpsc_admin_action' value='change_region_tax' />
58
  <input class='button-secondary' type='submit' name='submit' value='<?php esc_attr_e( 'Save Changes', 'wpsc' );?>' />
59
  </form>
60
+ </div>
wpsc-admin/includes/updating-functions.php CHANGED
@@ -46,7 +46,7 @@ class WPSC_Update {
46
  do_action( 'wpsc_update_timeout_terminate' );
47
  $location = remove_query_arg( array( 'start_over', 'eta', 'current_percent' ) );
48
  $location = add_query_arg( 'run_updates', 1, $location );
49
- $location = apply_filters( 'wpsc_update_terminate_location', $location );
50
  ?>
51
  <script type="text/javascript">
52
  location.href = "<?php echo $location; ?>"
@@ -57,15 +57,13 @@ class WPSC_Update {
57
  }
58
 
59
  public function run( $function, $message = '' ) {
60
-
61
- if ( $message ) {
62
  echo "<p>{$message}</p>";
63
- }
64
 
65
  if ( empty( $this->stages[$function] ) ) {
66
  call_user_func( 'wpsc_' . $function );
67
- $this->stages[ $function ] = true;
68
- set_transient( 'wpsc_update_progress', $this->stages, WEEK_IN_SECONDS );
69
  }
70
  }
71
  }
@@ -113,13 +111,12 @@ class WPSC_Update_Progress {
113
  $location = add_query_arg( 'eta', $this->eta, $location );
114
  else
115
  $location = remove_query_arg( 'eta', $location );
116
- return $location;
117
  }
118
 
119
  private function print_eta() {
120
  echo '<div class="eta">';
121
- _e( 'Estimated time left:', 'wpsc' );
122
- echo ' ';
123
  if ( $this->eta == 0 )
124
  _e( 'Under a minute', 'wpsc' );
125
  else
@@ -183,8 +180,7 @@ function wpsc_update_step( $i, $total ) {
183
  $processed = $i - $count + 1;
184
  $eta = floor( ( $total - $i ) * ( $now - $start ) / ( $processed * 60 ) );
185
  echo '<div class="eta">';
186
- _e( 'Estimated time left:', 'wpsc' );
187
- echo ' ';
188
  if ( $eta == 0 )
189
  _e( 'Under a minute', 'wpsc' );
190
  else
@@ -425,7 +421,7 @@ function wpsc_convert_products_to_posts() {
425
  $product['order'] = $wpdb->get_var( $wpdb->prepare( "
426
  SELECT order FROM " . WPSC_TABLE_PRODUCT_ORDER . "
427
  WHERE product_id = %d
428
- ", $product['id'] ) );
429
 
430
  $product_post_values['menu_order'] = $product['order'];
431
 
@@ -446,7 +442,7 @@ function wpsc_convert_products_to_posts() {
446
  WHERE `product_id` = %d
447
  AND `meta_value` != ''", $product['id'] );
448
 
449
- $product_meta = $wpdb->get_results( $product_meta_sql, ARRAY_A );
450
 
451
  $post_data = array();
452
 
@@ -865,8 +861,8 @@ function wpsc_update_database() {
865
  $has_taxes = ($value["Field"] == "wpec_taxes_total" || $value["Field"] == "wpec_taxes_rate") ? true: false;
866
  }
867
  if (!$has_taxes) {
868
- $add_fields = $wpdb->query( "ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_total decimal(11,2)" );
869
- $add_fields = $wpdb->query( "ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_rate decimal(11,2)" );
870
  }
871
  }
872
  /*
46
  do_action( 'wpsc_update_timeout_terminate' );
47
  $location = remove_query_arg( array( 'start_over', 'eta', 'current_percent' ) );
48
  $location = add_query_arg( 'run_updates', 1, $location );
49
+ $location = esc_url( apply_filters( 'wpsc_update_terminate_location', $location ) );
50
  ?>
51
  <script type="text/javascript">
52
  location.href = "<?php echo $location; ?>"
57
  }
58
 
59
  public function run( $function, $message = '' ) {
60
+ if ( $message )
 
61
  echo "<p>{$message}</p>";
 
62
 
63
  if ( empty( $this->stages[$function] ) ) {
64
  call_user_func( 'wpsc_' . $function );
65
+ $this->stages[$function] = true;
66
+ set_transient( 'wpsc_update_progress', $this->stages, 604800 );
67
  }
68
  }
69
  }
111
  $location = add_query_arg( 'eta', $this->eta, $location );
112
  else
113
  $location = remove_query_arg( 'eta', $location );
114
+ return esc_url( $location );
115
  }
116
 
117
  private function print_eta() {
118
  echo '<div class="eta">';
119
+ _e( 'Estimated time left:', 'wpsc' ) . ' ';
 
120
  if ( $this->eta == 0 )
121
  _e( 'Under a minute', 'wpsc' );
122
  else
180
  $processed = $i - $count + 1;
181
  $eta = floor( ( $total - $i ) * ( $now - $start ) / ( $processed * 60 ) );
182
  echo '<div class="eta">';
183
+ _e( 'Estimated time left:', 'wpsc' ) . ' ';
 
184
  if ( $eta == 0 )
185
  _e( 'Under a minute', 'wpsc' );
186
  else
421
  $product['order'] = $wpdb->get_var( $wpdb->prepare( "
422
  SELECT order FROM " . WPSC_TABLE_PRODUCT_ORDER . "
423
  WHERE product_id = %d
424
+ " ), $product['id'] );
425
 
426
  $product_post_values['menu_order'] = $product['order'];
427
 
442
  WHERE `product_id` = %d
443
  AND `meta_value` != ''", $product['id'] );
444
 
445
+ $product_meta = $wpdb->get_results( $product_meta_sql, ARRAY_A);
446
 
447
  $post_data = array();
448
 
861
  $has_taxes = ($value["Field"] == "wpec_taxes_total" || $value["Field"] == "wpec_taxes_rate") ? true: false;
862
  }
863
  if (!$has_taxes) {
864
+ $add_fields = $wpdb->query($wpdb->prepare("ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_total decimal(11,2)"));
865
+ $add_fields = $wpdb->query($wpdb->prepare("ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_rate decimal(11,2)"));
866
  }
867
  }
868
  /*
wpsc-admin/includes/walker-variation-checklist.php CHANGED
@@ -10,28 +10,20 @@ class WPSC_Walker_Variation_Checklist extends Walker_Category_Checklist {
10
  $this->highlighted = $highlighted;
11
  }
12
 
13
- public function start_el( &$output, $category, $depth = 0, $args = array(), $current_object_id = 0 ) {
14
- extract( $args );
15
-
16
- if ( empty( $taxonomy ) ) {
17
  $taxonomy = 'category';
18
- }
19
-
20
- if ( empty( $selected_cats ) ) {
21
- $selected_cats = array();
22
- }
23
 
24
- $checked = in_array( $category->term_id, $selected_cats );
25
  $input_class = ( $depth === 0 ) ? ' class="variation-set"' : '';
26
- $li_classes = array( 'wpsc-variation-checklist-item' );
27
-
28
  if ( $depth === 0 && wpsc_is_doing_ajax( 'add_variation_set' ) ) {
29
  $li_classes[] = 'ajax';
30
  $li_classes[] = 'expanded';
31
  } elseif ( in_array( $category->term_id, $this->highlighted ) ) {
32
  $li_classes[] = 'ajax';
33
  }
34
-
35
  ob_start();
36
  ?>
37
  <li id="<?php echo esc_attr( $taxonomy ); ?>-<?php echo $category->term_id; ?>" class="<?php echo implode( ' ', $li_classes ); ?>">
10
  $this->highlighted = $highlighted;
11
  }
12
 
13
+ public function start_el(&$output, $category, $depth, $args) {
14
+ extract($args);
15
+ if ( empty($taxonomy) )
 
16
  $taxonomy = 'category';
 
 
 
 
 
17
 
18
+ $checked = in_array( $category->term_id, $selected_cats );
19
  $input_class = ( $depth === 0 ) ? ' class="variation-set"' : '';
20
+ $li_classes = array( 'wpsc-variation-checklist-item' );
 
21
  if ( $depth === 0 && wpsc_is_doing_ajax( 'add_variation_set' ) ) {
22
  $li_classes[] = 'ajax';
23
  $li_classes[] = 'expanded';
24
  } elseif ( in_array( $category->term_id, $this->highlighted ) ) {
25
  $li_classes[] = 'ajax';
26
  }
 
27
  ob_start();
28
  ?>
29
  <li id="<?php echo esc_attr( $taxonomy ); ?>-<?php echo $category->term_id; ?>" class="<?php echo implode( ' ', $li_classes ); ?>">
wpsc-admin/init.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
- function wpsc_ajax_sales_quarterly() {
3
-
4
- if ( ! wpsc_is_store_admin() ) {
5
- return;
6
- }
7
 
 
8
  $lastdate = sanitize_text_field( $_POST['add_start'] );
9
  $date = preg_split( '/-/', $lastdate );
10
  if ( !isset( $date[0] ) )
@@ -56,7 +52,7 @@ function wpsc_ajax_toggle_published() {
56
 
57
  $status = (wpsc_toggle_publish_status( $product_id )) ? ('true') : ('false');
58
  $sendback = add_query_arg( 'flipped', "1", wp_get_referer() );
59
- wp_redirect( $sendback );
60
  exit();
61
  }
62
 
@@ -70,10 +66,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
70
  */
71
  function wpsc_duplicate_product() {
72
 
73
- if ( ! wpsc_is_store_admin() ) {
74
- return;
75
- }
76
-
77
  // Get the original post
78
  $id = absint( $_GET['product'] );
79
  $post = get_post( $id );
@@ -84,7 +76,7 @@ function wpsc_duplicate_product() {
84
 
85
  $duplicated = true;
86
  $sendback = wp_get_referer();
87
- $sendback = add_query_arg( 'duplicated', (int) $duplicated, $sendback );
88
 
89
  wp_redirect( $sendback );
90
  exit();
@@ -97,16 +89,10 @@ if ( isset( $_GET['wpsc_admin_action'] ) && ( $_GET['wpsc_admin_action'] == 'dup
97
  add_action( 'admin_init', 'wpsc_duplicate_product' );
98
 
99
  function wpsc_purchase_log_csv() {
100
-
101
- if ( ! wpsc_is_store_admin() ) {
102
- return;
103
- }
104
-
105
  global $wpdb, $wpsc_gateways;
106
  get_currentuserinfo();
107
  $count = 0;
108
-
109
- if ( 'key' == $_REQUEST['rss_key'] ) {
110
  if ( isset( $_REQUEST['start_timestamp'] ) && isset( $_REQUEST['end_timestamp'] ) ) {
111
  $start_timestamp = $_REQUEST['start_timestamp'];
112
  $end_timestamp = $_REQUEST['end_timestamp'];
@@ -249,11 +235,6 @@ if ( isset( $_GET['purchase_log_csv'] ) && ( 'true' == $_GET['purchase_log_csv']
249
  add_action( 'admin_init', 'wpsc_purchase_log_csv' );
250
 
251
  function wpsc_admin_sale_rss() {
252
-
253
- if ( ! wpsc_is_store_admin() ) {
254
- return;
255
- }
256
-
257
  global $wpdb;
258
  if ( ($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log") ) {
259
  $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!='' ORDER BY `date` DESC";
@@ -264,10 +245,10 @@ function wpsc_admin_sale_rss() {
264
  $output .= "<?xml version='1.0'?>\n\r";
265
  $output .= "<rss version='2.0'>\n\r";
266
  $output .= " <channel>\n\r";
267
- $output .= " <title>" . _x( 'WP eCommerce Product Log', 'admin rss product feed', 'wpsc' ) . "</title>\n\r";
268
  $output .= " <link>" . admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "</link>\n\r";
269
- $output .= " <description>" . _x( 'This is the WP eCommerce Product Log RSS feed', 'admin rss product feed', 'wpsc' ) . "</description>\n\r";
270
- $output .= " <generator>" . _x( 'WP eCommerce Plugin', 'admin rss product feed', 'wpsc' ) . "</generator>\n\r";
271
 
272
  foreach ( (array)$purchase_log as $purchase ) {
273
  $purchase_link = admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "&amp;purchaseid=" . $purchase['id'];
@@ -288,212 +269,74 @@ function wpsc_admin_sale_rss() {
288
  }
289
  }
290
 
291
- if ( isset( $_GET['action'] ) && ( 'purchase_log' == $_GET['action'] ) ) {
292
  add_action( 'admin_init', 'wpsc_admin_sale_rss' );
293
- }
294
 
295
  /**
296
- * Do Purchase Log Actions
297
- *
298
- * All purchase log actions are capability and nonce checked before calling
299
- * the relevent 'wpsc_purchase_log_action-{wpsc_purchase_log_action}' hook.
300
- *
301
- * @since 3.9.0
302
  */
303
- function wpsc_do_purchase_log_actions() {
304
-
305
- if ( ! wpsc_is_store_admin() ) {
306
- return;
307
- }
308
-
309
- if ( isset( $_GET['wpsc_purchase_log_action'] ) && isset( $_GET['id'] ) && isset( $_GET['_wpnonce'] ) ) {
310
- $wpsc_purchase_log_action = sanitize_key( $_GET['wpsc_purchase_log_action'] );
311
-
312
- if ( wp_verify_nonce( $_GET['_wpnonce'], 'wpsc_purchase_log_action_' . $wpsc_purchase_log_action ) ) {
313
-
314
- do_action( 'wpsc_purchase_log_action-' . $wpsc_purchase_log_action, absint( $_GET['id'] ) );
315
-
316
- }
317
  }
318
 
319
- }
320
- add_action( 'admin_init', 'wpsc_do_purchase_log_actions' );
321
-
322
- /**
323
- * Handle clear downloads lock purchase log action
324
- *
325
- * The 'wpsc_purchase_log_action-downloads_lock' action hook which calls this function is nonce and capability checked
326
- * in wpsc_do_purchase_log_actions() before triggering do_action( 'wpsc_purchase_log_action-downloads_lock' ).
327
- *
328
- * @since 3.9.0
329
- *
330
- * @param int $log_id Purchase log ID.
331
- */
332
- function wpsc_purchase_log_action_downloads_lock( $log_id ) {
333
-
334
- wpsc_purchlog_clear_download_items( $log_id );
335
-
336
- // Redirect back to purchase logs list
337
- $sendback = wp_get_referer();
338
- $sendback = add_query_arg( 'cleared', 1, $sendback );
339
- wp_redirect( $sendback );
340
- exit();
341
-
342
- }
343
- add_action( 'wpsc_purchase_log_action-downloads_lock', 'wpsc_purchase_log_action_downloads_lock' );
344
-
345
- /**
346
- * Handle delete purchase log action
347
- *
348
- * The 'wpsc_purchase_log_action-delete' action hook which calls this function is nonce and capability checked
349
- * in wpsc_do_purchase_log_actions() before triggering do_action( 'wpsc_purchase_log_action-delete' ).
350
- *
351
- * @since 3.9.0
352
- *
353
- * @param int $log_id Purchase log ID.
354
- */
355
- function wpsc_purchase_log_action_delete( $log_id ) {
356
-
357
- $log = new WPSC_Purchase_Log( $log_id );
358
- $deleted = $log->delete();
359
-
360
- // Redirect back to purchase logs list
361
  $sendback = wp_get_referer();
362
- $sendback = remove_query_arg( array( 'c', 'id' ), $sendback );
363
- $sendback = add_query_arg( 'deleted', absint( $deleted ), $sendback );
364
- wp_redirect( $sendback );
365
- exit();
366
-
367
- }
368
- add_action( 'wpsc_purchase_log_action-delete', 'wpsc_purchase_log_action_delete' );
369
-
370
- /**
371
- * Handle email receipt purchase log action
372
- *
373
- * The 'wpsc_purchase_log_action-email_receipt' action hook which calls this function is nonce and capability checked
374
- * in wpsc_do_purchase_log_actions() before triggering do_action( 'wpsc_purchase_log_action-email_receipt' ).
375
- *
376
- * @since 3.9.0
377
- *
378
- * @param int $log_id Purchase log ID.
379
- */
380
- function wpsc_purchase_log_action_email_receipt( $log_id ) {
381
 
382
- $sent = wpsc_purchlog_resend_email( $log_id );
 
383
 
384
- // Redirect back to purchase logs list
385
- $sendback = wp_get_referer();
386
- $sendback = add_query_arg( 'sent', absint( $sent ), $sendback );
387
- wp_redirect( $sendback );
388
  exit();
389
-
390
- }
391
- add_action( 'wpsc_purchase_log_action-email_receipt', 'wpsc_purchase_log_action_email_receipt' );
392
-
393
- /**
394
- * Resend Purchase Log Email
395
- *
396
- * @param int|string $log_id Required. Purchase log ID (empty string is deprecated).
397
- * @return boolean Sent successfully.
398
- */
399
- function wpsc_purchlog_resend_email( $log_id = '' ) {
400
-
401
- if ( ! wpsc_is_store_admin() ) {
402
- return;
403
- }
404
-
405
- global $wpdb;
406
-
407
- // Deprecate empty purchase log ID parameter.
408
- if ( $log_id == '' ) {
409
- _wpsc_doing_it_wrong( 'wpsc_purchlog_resend_email', __( '$log_id parameter requires a numeric purchase log ID.', 'wpsc' ), '3.9.0' );
410
-
411
- // Support redirect for legacy purposes for the moment
412
- $sendback = add_query_arg( 'sent', 0, wp_get_referer() );
413
- wp_redirect( $sendback );
414
- exit();
415
-
416
- }
417
-
418
- $log_id = absint( $log_id );
419
-
420
- if ( $log_id > 0 ) {
421
-
422
- $wpec_taxes_controller = new wpec_taxes_controller();
423
-
424
- if ( is_numeric( $log_id ) ) {
425
- $purchase_log = new WPSC_Purchase_Log( $log_id );
426
- return wpsc_send_customer_email( $purchase_log );
427
- }
428
-
429
- }
430
-
431
- return false;
432
-
433
  }
434
 
435
- // Deprecate resending purchase log email receipt via URL query
436
  if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_id'] ) ) {
437
- _wpsc_doing_it_wrong( 'wpsc_purchlog_resend_email', __( 'Do not trigger resend purchase log email action via email_buyer_id URL query. Instead use the Purchase Log Action Links API.', 'wpsc' ), '3.9.0' );
438
  }
439
 
440
- /**
441
- * Clear Purchase Log Download Locks
442
- *
443
- * @param string $log_id Required. Purchase log ID (empty string is deprecated).
444
- * @return boolean
445
- */
446
- function wpsc_purchlog_clear_download_items( $log_id = '' ) {
447
-
448
- if ( ! wpsc_is_store_admin() ) {
449
- return;
450
- }
451
-
452
  global $wpdb;
 
 
 
453
 
454
- // Deprecate empty purchase log ID parameter.
455
- if ( $log_id == '' ) {
456
- _wpsc_doing_it_wrong( 'wpsc_purchlog_clear_download_items', __( '$log_id parameter requires a numeric purchase log ID.', 'wpsc' ), '3.9.0' );
457
- return false;
458
- }
459
-
460
- $log_id = absint( $log_id );
461
-
462
- if ( $log_id > 0 ) {
463
-
464
- $downloadable_items = (array) $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` = %d", $log_id ), ARRAY_A );
465
-
466
- $wpdb->update( WPSC_TABLE_DOWNLOAD_STATUS, array( 'ip_number' => '' ), array( 'purchid' => $log_id ), '%s', '%d' );
467
 
468
  $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
469
- $email_address = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = '{$email_form_field}' LIMIT 1", $log_id ) );
470
-
471
- foreach ( $downloadable_items as $downloadable_item ) {
472
- $download_links .= add_query_arg( 'downloadid', $downloadable_item['uniqueid'], home_url() ) . "\n";
 
 
 
 
473
  }
474
 
475
- wp_mail( $email_address, __( 'The administrator has unlocked your file', 'wpsc' ), str_replace( "[download_links]", $download_links, __( 'Dear CustomerWe are pleased to advise you that your order has been updated and your downloads are now active.Please download your purchase using the links provided below.[download_links]Thank you for your custom.', 'wpsc' ) ), "From: " . get_option( 'return_email' ) );
476
 
477
- return true;
478
 
479
- }
480
 
481
- return false;
 
 
482
 
 
 
 
483
  }
484
 
485
- // Deprecate clearing purchase log download locks via URL query
486
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks') ) {
487
- _wpsc_doing_it_wrong( 'wpsc_purchlog_clear_download_items', __( 'Do not trigger clear purchase log download locks action via wpsc_admin_action = clear_locks URL query. Instead use the Purchase Log Action Links API.', 'wpsc' ), '3.9.0' );
488
  }
489
 
490
  //bulk actions for purchase log
491
  function wpsc_purchlog_bulk_modify() {
492
-
493
- if ( ! wpsc_is_store_admin() ) {
494
- return;
495
- }
496
-
497
  if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
498
  if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
499
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
@@ -503,12 +346,8 @@ function wpsc_purchlog_bulk_modify() {
503
  } elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) {
504
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
505
 
506
- $log = new WPSC_Purchase_Log( $purchlogid );
507
- $deleted_log = $log->delete();
508
- if ( $deleted_log ) {
509
- $deleted++;
510
- }
511
-
512
  }
513
  }
514
  }
@@ -525,7 +364,7 @@ function wpsc_purchlog_bulk_modify() {
525
  if ( isset( $_POST['view_purchlogs_by_status'] ) ) {
526
  $sendback = add_query_arg( 'view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback );
527
  }
528
- wp_redirect( $sendback );
529
  exit();
530
  }
531
 
@@ -533,57 +372,70 @@ if ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'
533
  add_action( 'admin_init', 'wpsc_purchlog_bulk_modify' );
534
  }
535
 
536
- /**
537
- * Update Purchase Log Notes
538
- *
539
- * @param int $purchlog_id Purchase log ID.
540
- * @param string $purchlog_notes Notes.
541
- */
542
- function wpsc_purchlogs_update_notes( $purchlog_id = 0, $purchlog_notes = '' ) {
543
- if ( isset( $_POST['wpsc_purchlogs_update_notes_nonce'] ) && wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
544
- if ( 0 == $purchlog_id && isset( $_POST['purchlog_id'] ) && '' == $purchlog_notes ) {
545
  $purchlog_id = absint( $_POST['purchlog_id'] );
546
  $purchlog_notes = stripslashes( $_POST['purchlog_notes'] );
547
  }
548
-
549
- if ( $purchlog_id > 0 ) {
550
- $purchase_log = new WPSC_Purchase_Log( $purchlog_id );
551
- $purchase_log->set( 'notes', $purchlog_notes );
552
- $purchase_log->save();
553
- }
554
- }
555
- }
556
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && $_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) {
 
 
 
 
 
 
 
 
 
557
  add_action( 'admin_init', 'wpsc_purchlogs_update_notes' );
558
- }
559
 
560
- /**
561
- * Delete a purchase log
562
- *
563
- * @deprecated Use WPSC_Purchase_Log->delete() instead.
564
- *
565
- * @param int|string $purchlog_id Required. Purchase log ID (empty string is deprecated).
566
- * @return boolean Deleted successfully.
567
- */
568
- function wpsc_delete_purchlog( $purchlog_id = '' ) {
569
 
 
 
570
  global $wpdb;
 
571
 
572
- // Deprecate empty purchase log ID parameter.
573
  if ( $purchlog_id == '' ) {
574
- _wpsc_doing_it_wrong( 'wpsc_delete_purchlog', __( '$purchlog_id parameter requires a numeric purchase log ID.', 'wpsc' ), '3.9.0' );
575
- return false;
 
 
 
 
 
576
  }
577
 
578
- $log = new WPSC_Purchase_Log( $purchlog_id );
 
 
579
 
580
- return $log->delete();
581
 
 
 
 
 
 
 
 
 
 
582
  }
583
 
584
- // Deprecate deleting purchase log via URL query
585
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'delete_purchlog' ) ) {
586
- _wpsc_doing_it_wrong( 'wpsc_delete_purchlog', __( 'Do not trigger delete purchase log action via wpsc_admin_action = delete_purchlog URL query. Instead use the Purchase Log Action Links API.', 'wpsc' ), '3.9.0' );
587
  }
588
 
589
  function wpsc_update_option_product_category_hierarchical_url() {
@@ -613,7 +465,7 @@ add_filter( 'sanitize_option_grid_number_per_row', '_wpsc_action_sanitize_option
613
  function _wpsc_action_update_option_require_register( $old_value, $new_value ) {
614
  if ( $new_value == 1 && ! get_option( 'users_can_register' ) ) {
615
  update_option( 'users_can_register', 1 );
616
- $message = __( 'You wanted to require your customers to log in before checking out. However, the WordPress setting <a href="%s">"Anyone can register"</a> was disabled. WP eCommerce has enabled that setting for you automatically.', 'wpsc' );
617
  $message = sprintf( $message, admin_url( 'options-general.php' ) );
618
  add_settings_error( 'require_register', 'users_can_register_turned_on', $message, 'updated' );
619
  }
@@ -647,10 +499,7 @@ add_action( 'update_option_users_can_register', '_wpsc_action_update_option_user
647
  * @return nothing
648
  */
649
  function wpsc_update_page_urls( $auto = false ) {
650
-
651
- if ( ! wpsc_is_store_admin() ) {
652
- return;
653
- }
654
 
655
  wpsc_update_permalink_slugs();
656
  wpsc_core_load_page_titles();
@@ -664,7 +513,7 @@ function wpsc_update_page_urls( $auto = false ) {
664
  if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
665
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
666
 
667
- wp_redirect( $sendback );
668
  exit();
669
  }
670
  }
@@ -673,11 +522,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
673
 
674
  //change the regions tax settings
675
  function wpsc_change_region_tax() {
676
-
677
- if ( ! wpsc_is_store_admin() ) {
678
- return;
679
- }
680
-
681
  global $wpdb;
682
  if ( is_array( $_POST['region_tax'] ) ) {
683
  foreach ( $_POST['region_tax'] as $region_id => $tax ) {
@@ -709,10 +553,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
709
  function wpsc_product_files_existing() {
710
  //List all product_files, with checkboxes
711
 
712
- if ( ! wpsc_is_store_admin() ) {
713
- return;
714
- }
715
-
716
  $product_id = absint( $_GET["product_id"] );
717
  $file_list = wpsc_uploaded_files();
718
 
@@ -730,7 +570,7 @@ function wpsc_product_files_existing() {
730
 
731
  $output = "<span class='admin_product_notes select_product_note '>" . esc_html__( 'Choose a downloadable file for this product:', 'wpsc' ) . "</span><br>";
732
  $output .= "<form method='post' class='product_upload'>";
733
- $output .= '<div class="ui-widget-content multiple-select select_product_file" style="width:100%">';
734
  $num = 0;
735
  foreach ( (array)$file_list as $file ) {
736
  $num++;
@@ -761,6 +601,31 @@ function wpsc_product_files_existing() {
761
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing') )
762
  add_action( 'admin_init', 'wpsc_product_files_existing' );
763
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
  function wpsc_update_variations() {
765
  $product_id = absint( $_POST["product_id"] );
766
  $product_type_object = get_post_type_object('wpsc-product');
@@ -768,7 +633,7 @@ function wpsc_update_variations() {
768
  return;
769
 
770
  //Setup postdata
771
- $post_data = array();
772
  $post_data['edit_var_val'] = isset( $_POST['edit_var_val'] ) ? $_POST["edit_var_val"] : '';
773
 
774
  //Add or delete variations
@@ -811,7 +676,7 @@ function wpsc_delete_variation_set() {
811
  'variation_id'
812
  ), $sendback );
813
 
814
- wp_redirect( $sendback );
815
  exit();
816
  }
817
 
@@ -819,11 +684,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-variation-set' ==
819
  add_action( 'admin_init', 'wpsc_delete_variation_set' );
820
 
821
  function wpsc_backup_theme() {
822
-
823
- if ( ! wpsc_is_store_admin() ) {
824
- return;
825
- }
826
-
827
  $wp_theme_path = get_stylesheet_directory();
828
  wpsc_recursive_copy( $wp_theme_path, WPSC_THEME_BACKUP_DIR );
829
  $_SESSION['wpsc_themes_backup'] = true;
@@ -851,7 +711,7 @@ function wpsc_delete_coupon(){
851
  $sendback = add_query_arg( 'deleted', $deleted, $sendback );
852
 
853
  $sendback = remove_query_arg( array( 'deleteid', 'wpsc_admin_action' ), $sendback );
854
- wp_redirect( $sendback );
855
  exit();
856
  }
857
 
1
  <?php
 
 
 
 
 
2
 
3
+ function wpsc_ajax_sales_quarterly() {
4
  $lastdate = sanitize_text_field( $_POST['add_start'] );
5
  $date = preg_split( '/-/', $lastdate );
6
  if ( !isset( $date[0] ) )
52
 
53
  $status = (wpsc_toggle_publish_status( $product_id )) ? ('true') : ('false');
54
  $sendback = add_query_arg( 'flipped', "1", wp_get_referer() );
55
+ wp_redirect( esc_url( $sendback ) );
56
  exit();
57
  }
58
 
66
  */
67
  function wpsc_duplicate_product() {
68
 
 
 
 
 
69
  // Get the original post
70
  $id = absint( $_GET['product'] );
71
  $post = get_post( $id );
76
 
77
  $duplicated = true;
78
  $sendback = wp_get_referer();
79
+ $sendback = esc_url( add_query_arg( 'duplicated', (int)$duplicated, $sendback ) );
80
 
81
  wp_redirect( $sendback );
82
  exit();
89
  add_action( 'admin_init', 'wpsc_duplicate_product' );
90
 
91
  function wpsc_purchase_log_csv() {
 
 
 
 
 
92
  global $wpdb, $wpsc_gateways;
93
  get_currentuserinfo();
94
  $count = 0;
95
+ if ( 'key' == $_REQUEST['rss_key'] && current_user_can( 'manage_options' ) ) {
 
96
  if ( isset( $_REQUEST['start_timestamp'] ) && isset( $_REQUEST['end_timestamp'] ) ) {
97
  $start_timestamp = $_REQUEST['start_timestamp'];
98
  $end_timestamp = $_REQUEST['end_timestamp'];
235
  add_action( 'admin_init', 'wpsc_purchase_log_csv' );
236
 
237
  function wpsc_admin_sale_rss() {
 
 
 
 
 
238
  global $wpdb;
239
  if ( ($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log") ) {
240
  $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!='' ORDER BY `date` DESC";
245
  $output .= "<?xml version='1.0'?>\n\r";
246
  $output .= "<rss version='2.0'>\n\r";
247
  $output .= " <channel>\n\r";
248
+ $output .= " <title>" . _x( 'WP e-Commerce Product Log', 'admin rss product feed', 'wpsc' ) . "</title>\n\r";
249
  $output .= " <link>" . admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "</link>\n\r";
250
+ $output .= " <description>" . _x( 'This is the WP e-Commerce Product Log RSS feed', 'admin rss product feed', 'wpsc' ) . "</description>\n\r";
251
+ $output .= " <generator>" . _x( 'WP e-Commerce Plugin', 'admin rss product feed', 'wpsc' ) . "</generator>\n\r";
252
 
253
  foreach ( (array)$purchase_log as $purchase ) {
254
  $purchase_link = admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "&amp;purchaseid=" . $purchase['id'];
269
  }
270
  }
271
 
272
+ if ( isset( $_GET['action'] ) && ( 'purchase_log' == $_GET['action'] ) )
273
  add_action( 'admin_init', 'wpsc_admin_sale_rss' );
 
274
 
275
  /**
276
+ * Purchase log ajax code starts here
 
 
 
 
 
277
  */
278
+ function wpsc_purchlog_resend_email() {
279
+ global $wpdb;
280
+ $log_id = $_REQUEST['email_buyer_id'];
281
+ $wpec_taxes_controller = new wpec_taxes_controller();
282
+ if ( is_numeric( $log_id ) ) {
283
+ $purchase_log = new WPSC_Purchase_Log( $log_id );
284
+ $sent = wpsc_send_customer_email( $purchase_log );
 
 
 
 
 
 
 
285
  }
286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  $sendback = wp_get_referer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
+ if ( isset( $sent ) )
290
+ $sendback = add_query_arg( 'sent', $sent, $sendback );
291
 
292
+ wp_redirect( esc_url( $sendback ) );
 
 
 
293
  exit();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  }
295
 
 
296
  if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_id'] ) ) {
297
+ add_action( 'admin_init', 'wpsc_purchlog_resend_email' );
298
  }
299
 
300
+ function wpsc_purchlog_clear_download_items() {
 
 
 
 
 
 
 
 
 
 
 
301
  global $wpdb;
302
+ if ( is_numeric( $_GET['purchaselog_id'] ) ) {
303
+ $purchase_id = (int)$_GET['purchaselog_id'];
304
+ $downloadable_items = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` = %d", $purchase_id ), ARRAY_A );
305
 
306
+ $wpdb->update( WPSC_TABLE_DOWNLOAD_STATUS, array( 'ip_number' => '' ), array( 'purchid' => $purchase_id ), '%s', '%d' );
307
+ $cleared = true;
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
310
+ $email_address = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = '{$email_form_field}' LIMIT 1", $purchase_id ) );
311
+
312
+ foreach ( (array) $downloadable_items as $downloadable_item ) {
313
+ $download_links .= esc_url( add_query_arg(
314
+ 'downloadid',
315
+ $downloadable_item['uniqueid'],
316
+ home_url()
317
+ ) ) . "\n";
318
  }
319
 
 
320
 
321
+ wp_mail( $email_address, __( 'The administrator has unlocked your file', 'wpsc' ), str_replace( "[download_links]", $download_links, __( 'Dear CustomerWe are pleased to advise you that your order has been updated and your downloads are now active.Please download your purchase using the links provided below.[download_links]Thank you for your custom.', 'wpsc' ) ), "From: " . get_option( 'return_email' ) );
322
 
323
+ $sendback = wp_get_referer();
324
 
325
+ if ( isset( $cleared ) ) {
326
+ $sendback = add_query_arg( 'cleared', $cleared, $sendback );
327
+ }
328
 
329
+ wp_redirect( esc_url( $sendback ) );
330
+ exit();
331
+ }
332
  }
333
 
 
334
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks') ) {
335
+ add_action( 'admin_init', 'wpsc_purchlog_clear_download_items' );
336
  }
337
 
338
  //bulk actions for purchase log
339
  function wpsc_purchlog_bulk_modify() {
 
 
 
 
 
340
  if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
341
  if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
342
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
346
  } elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) {
347
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
348
 
349
+ wpsc_delete_purchlog( $purchlogid );
350
+ $deleted++;
 
 
 
 
351
  }
352
  }
353
  }
364
  if ( isset( $_POST['view_purchlogs_by_status'] ) ) {
365
  $sendback = add_query_arg( 'view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback );
366
  }
367
+ wp_redirect( esc_url( $sendback ) );
368
  exit();
369
  }
370
 
372
  add_action( 'admin_init', 'wpsc_purchlog_bulk_modify' );
373
  }
374
 
375
+ /* Start Order Notes (by Ben) */
376
+ function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' ) {
377
+ global $wpdb;
378
+ if ( wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
379
+ if ( ($purchlog_id == '') && ($purchlog_notes == '') ) {
 
 
 
 
380
  $purchlog_id = absint( $_POST['purchlog_id'] );
381
  $purchlog_notes = stripslashes( $_POST['purchlog_notes'] );
382
  }
383
+ $wpdb->update(
384
+ WPSC_TABLE_PURCHASE_LOGS,
385
+ array(
386
+ 'notes' => $purchlog_notes
387
+ ),
388
+ array(
389
+ 'id' => $purchlog_id
390
+ ),
391
+ array(
392
+ '%s'
393
+ ),
394
+ array(
395
+ '%d'
396
+ )
397
+ );
398
+ }
399
+ }
400
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) )
401
  add_action( 'admin_init', 'wpsc_purchlogs_update_notes' );
 
402
 
403
+ /* End Order Notes (by Ben) */
 
 
 
 
 
 
 
 
404
 
405
+ //delete a purchase log
406
+ function wpsc_delete_purchlog( $purchlog_id='' ) {
407
  global $wpdb;
408
+ $deleted = 0;
409
 
 
410
  if ( $purchlog_id == '' ) {
411
+ $purchlog_id = absint( $_GET['purchlog_id'] );
412
+ check_admin_referer( 'delete_purchlog_' . $purchlog_id );
413
+ }
414
+
415
+ $purchlog_status = $wpdb->get_var( $wpdb->prepare( "SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= %d", $purchlog_id ) );
416
+ if ( $purchlog_status == 5 || $purchlog_status == 1 ) {
417
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = %d AND `cart_submitted` = '1'", $purchlog_id ) );
418
  }
419
 
420
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchlog_id ) );
421
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` IN (%d)", $purchlog_id ) );
422
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = %d LIMIT 1", $purchlog_id ) );
423
 
424
+ $deleted = 1;
425
 
426
+ if ( is_numeric( $_GET['purchlog_id'] ) ) {
427
+ $sendback = wp_get_referer();
428
+ $sendback = remove_query_arg( array( 'c', 'id' ), $sendback );
429
+ if ( isset( $deleted ) ) {
430
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
431
+ }
432
+ wp_redirect( esc_url( $sendback ) );
433
+ exit();
434
+ }
435
  }
436
 
437
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) {
438
+ add_action( 'admin_init', 'wpsc_delete_purchlog' );
 
439
  }
440
 
441
  function wpsc_update_option_product_category_hierarchical_url() {
465
  function _wpsc_action_update_option_require_register( $old_value, $new_value ) {
466
  if ( $new_value == 1 && ! get_option( 'users_can_register' ) ) {
467
  update_option( 'users_can_register', 1 );
468
+ $message = __( 'You wanted to require your customers to log in before checking out. However, the WordPress setting <a href="%s">"Anyone can register"</a> was disabled. WP e-Commerce has enabled that setting for you automatically.', 'wpsc' );
469
  $message = sprintf( $message, admin_url( 'options-general.php' ) );
470
  add_settings_error( 'require_register', 'users_can_register_turned_on', $message, 'updated' );
471
  }
499
  * @return nothing
500
  */
501
  function wpsc_update_page_urls( $auto = false ) {
502
+ global $wpdb;
 
 
 
503
 
504
  wpsc_update_permalink_slugs();
505
  wpsc_core_load_page_titles();
513
  if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
514
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
515
 
516
+ wp_redirect( esc_url( $sendback ) );
517
  exit();
518
  }
519
  }
522
 
523
  //change the regions tax settings
524
  function wpsc_change_region_tax() {
 
 
 
 
 
525
  global $wpdb;
526
  if ( is_array( $_POST['region_tax'] ) ) {
527
  foreach ( $_POST['region_tax'] as $region_id => $tax ) {
553
  function wpsc_product_files_existing() {
554
  //List all product_files, with checkboxes
555
 
 
 
 
 
556
  $product_id = absint( $_GET["product_id"] );
557
  $file_list = wpsc_uploaded_files();
558
 
570
 
571
  $output = "<span class='admin_product_notes select_product_note '>" . esc_html__( 'Choose a downloadable file for this product:', 'wpsc' ) . "</span><br>";
572
  $output .= "<form method='post' class='product_upload'>";
573
+ $output .= "<div class='ui-widget-content multiple-select select_product_file'>";
574
  $num = 0;
575
  foreach ( (array)$file_list as $file ) {
576
  $num++;
601
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing') )
602
  add_action( 'admin_init', 'wpsc_product_files_existing' );
603
 
604
+ function wpsc_google_shipping_settings() {
605
+ if ( isset( $_POST['submit'] ) ) {
606
+ foreach ( (array)$_POST['google_shipping'] as $key => $country ) {
607
+ if ( $country == 'on' ) {
608
+ $google_shipping_country[] = $key;
609
+ $updated++;
610
+ }
611
+ }
612
+ update_option( 'google_shipping_country', $google_shipping_country );
613
+ $sendback = wp_get_referer();
614
+ $sendback = remove_query_arg( 'googlecheckoutshipping', $sendback );
615
+
616
+ if ( isset( $updated ) ) {
617
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
618
+ }
619
+
620
+ wp_redirect( esc_url( $sendback ) );
621
+ exit();
622
+ }
623
+ }
624
+
625
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) {
626
+ add_action( 'admin_init', 'wpsc_google_shipping_settings' );
627
+ }
628
+
629
  function wpsc_update_variations() {
630
  $product_id = absint( $_POST["product_id"] );
631
  $product_type_object = get_post_type_object('wpsc-product');
633
  return;
634
 
635
  //Setup postdata
636
+ $post_data = array( );
637
  $post_data['edit_var_val'] = isset( $_POST['edit_var_val'] ) ? $_POST["edit_var_val"] : '';
638
 
639
  //Add or delete variations
676
  'variation_id'
677
  ), $sendback );
678
 
679
+ wp_redirect( esc_url( $sendback ) );
680
  exit();
681
  }
682
 
684
  add_action( 'admin_init', 'wpsc_delete_variation_set' );
685
 
686
  function wpsc_backup_theme() {
 
 
 
 
 
687
  $wp_theme_path = get_stylesheet_directory();
688
  wpsc_recursive_copy( $wp_theme_path, WPSC_THEME_BACKUP_DIR );
689
  $_SESSION['wpsc_themes_backup'] = true;
711
  $sendback = add_query_arg( 'deleted', $deleted, $sendback );
712
 
713
  $sendback = remove_query_arg( array( 'deleteid', 'wpsc_admin_action' ), $sendback );
714
+ wp_redirect( esc_url( $sendback ) );
715
  exit();
716
  }
717
 
wpsc-admin/js/admin.js CHANGED
@@ -10,7 +10,7 @@
10
  data['wpsc_action'] = data['action'];
11
  data['action'] = 'wpsc_ajax';
12
 
13
- return $.post( ajaxurl, data, handler, 'json' );
14
  };
15
 
16
  /**
@@ -24,7 +24,7 @@
24
  data['wpsc_action'] = data['action'];
25
  data['action'] = 'wpsc_ajax';
26
 
27
- return $.get( ajaxurl, data, handler, 'json' );
28
  };
29
 
30
  if( pagenow == 'edit-wpsc_product_category' ) {
@@ -36,14 +36,16 @@
36
  parent_id: 0
37
  };
38
 
39
- jQuery.post( ajaxurl, data );
40
  }
41
 
42
  var submit_handlers = [];
43
 
44
  var disable_ajax_submit = function() {
45
  var t = $('#submit');
46
-
 
 
47
  if (t.data('events'))
48
  submit_handlers = t.data('events').click;
49
  t.off('click');
@@ -63,10 +65,6 @@
63
  };
64
 
65
  $(function(){
66
- if ( 'undefined' === typeof WPSC_Term_List_Levels ) {
67
- return;
68
- }
69
-
70
  var table = $('body.edit-tags-php .wp-list-table');
71
  table.find('tbody tr').each(function(){
72
  var t = $(this),
@@ -159,26 +157,12 @@
159
 
160
  }(jQuery));
161
 
162
- jQuery(document).ready(function($){
163
- $( '#wpsc_price' ).on( 'change', wpsc_update_price_live_preview );
164
- $( '#wpsc_sale_price' ).on( 'change', wpsc_update_price_live_preview );
165
-
166
  jQuery('td.hidden_alerts img').each(function(){
167
  var t = jQuery(this);
168
  t.appendTo(t.parents('tr').find('td.column-title strong'));
169
  });
170
 
171
-
172
- jQuery( '#stock_limit_quantity' ).change( function(){
173
- wpsc_push_v2t( '#stock_limit_quantity', '#wpsc_product_stock_metabox_live_title > p > span' );
174
- });
175
-
176
- jQuery( 'em.wpsc_metabox_live_title' ).each( function( i, v ) {
177
- var $em = jQuery( this ), $parent = $em.parents( 'div.postbox' ), $h3 = $parent.find( 'h3' );
178
- $em.appendTo( $h3 );
179
-
180
- });
181
-
182
  /* Coupon edit functionality */
183
  jQuery('.modify_coupon').hide();
184
  jQuery('.wpsc_edit_coupon').click(function(){
@@ -195,77 +179,36 @@ jQuery(document).ready(function($){
195
  });
196
  jQuery("form[name='add_coupon']").submit(function() {
197
  var title = jQuery("form[name='add_coupon'] input[name='add_coupon_code']").val();
198
- if ( title === '' ) {
199
  jQuery('<div id="notice" class="error"><p>' + wpsc_adminL10n.empty_coupon + '</p></div>').insertAfter('div.wrap > h2').delay(2500).hide(350);
200
  return false;
201
  }
202
  });
203
 
204
- /*
205
- Alternative Currencies
206
- Trigger and handle UI events for adding and removing currency layers.
207
- */
208
-
209
- var currencyRowTemplate = jQuery( '.wpsc-currency-layers tr.template' ).remove().removeClass( 'template hidden' ).removeAttr( 'id' );
210
-
211
- // Hide table if empty
212
- if ( jQuery( '.wpsc-currency-layers tbody tr' ).length === 0 ) {
213
- jQuery( '.wpsc-currency-layers table' ).hide();
214
- }
215
-
216
- // Add new currency layer
217
- jQuery( '.wpsc-currency-layers' ).on( 'click', 'a.wpsc_add_new_currency', function( e ) {
218
- jQuery( this ).siblings( 'table' ).show();
219
- jQuery( '.wpsc-currency-layers tbody' ).append( currencyRowTemplate.clone() );
220
- e.preventDefault();
221
- });
222
-
223
- // Delete currency layer in admin product page
224
- jQuery( '.wpsc-currency-layers' ).on( 'click', 'a.wpsc_delete_currency_layer', function( e ) {
225
- var currencyRow = jQuery( this ).closest( 'tr' );
226
- currencyRow.find( 'input' ).val( '' );
227
- currencyRow.find( 'select' ).val( '' );
228
- if ( currencyRow.siblings().length === 0 ) {
229
- currencyRow.closest( 'table' ).hide();
230
- }
231
- currencyRow.remove();
232
- e.preventDefault();
233
- });
234
-
235
- /*
236
- Quantity Discounts
237
- Trigger and handle UI events for adding and removing quantity dicounts.
238
- */
239
 
240
- var qtyRowTemplate = jQuery( '.wpsc-quantity-discounts tr.template' ).remove().removeClass( 'template hidden' ).removeAttr( 'id' );
241
 
242
- // Hide table if empty
243
- if ( jQuery( '.wpsc-quantity-discounts tbody tr' ).length === 0 ) {
244
- jQuery( '.wpsc-quantity-discounts table' ).hide();
245
- }
246
-
247
- // Add new row to rate table
248
- jQuery( '.wpsc-quantity-discounts' ).on( 'click', '.add_level', function( e ) {
249
- jQuery( this ).siblings( 'table' ).show();
250
- added = jQuery( '.wpsc-quantity-discounts tbody' ).append( qtyRowTemplate.clone() );
251
- e.preventDefault();
252
  });
253
 
254
- // Remove a row from rate table
255
- jQuery( '.wpsc-quantity-discounts' ).on( 'click', '.remove_line', function( e ) {
256
- var qtyRow = jQuery( this ).closest( 'tr' );
257
- qtyRow.find( 'input' ).val( '' );
258
- if ( qtyRow.siblings().length === 0 ) {
259
- qtyRow.closest( 'table' ).hide();
260
- }
261
- qtyRow.remove();
262
- e.preventDefault();
263
  });
264
 
265
- /*
266
- As far as I can tell, WP provides no good way of unsetting elements in the bulk edit area...
267
- tricky jQuery action will do for now....not ideal whatsoever, nor eternally stable.
268
- */
269
  if( pagenow == 'edit-wpsc-product' ) {
270
  jQuery('.inline-edit-password-input').closest('.inline-edit-group').css('display', 'none');
271
  var vcl = jQuery('.inline-edit-col input[name="tax_input[wpsc-variation][]"]').css('display', 'none');
@@ -310,7 +253,7 @@ jQuery(document).ready(function($){
310
  jQuery('th.column-stock input, td.stock input').each(function(){
311
  this.disabled = ! checked;
312
  });
313
- };
314
 
315
  if (limited_stock_checkbox.size() > 0) {
316
  toggle_stock_fields(limited_stock_checkbox.is(':checked'));
@@ -321,6 +264,14 @@ jQuery(document).ready(function($){
321
  toggle_stock_fields(limited_stock_checkbox.is(':checked'));
322
  });
323
 
 
 
 
 
 
 
 
 
324
  jQuery("#custom_tax_checkbox").on( 'click', function(){
325
  if (this.checked) {
326
  jQuery("#custom_tax").show();
@@ -330,6 +281,14 @@ jQuery(document).ready(function($){
330
  }
331
  });
332
 
 
 
 
 
 
 
 
 
333
  jQuery( '.wpsc_featured_product_toggle' ).on( 'click', function(){
334
  post_values = {
335
  product_id : jQuery( this ).parents( 'tr' ).attr( 'id' ).replace( 'post-', '' ),
@@ -384,9 +343,9 @@ jQuery(document).ready(function($){
384
  if ( jQuery( 'select[name="rules[operator][]"]', prototype ).length === 0 ) {
385
  operator_box.append("<option value='and'>" + wpsc_adminL10n.coupons_compare_and + "</option>");
386
  operator_box.append("<option value='or'>" + wpsc_adminL10n.coupons_compare_or + "</option>");
387
- prototype.prepend(operator_box);
388
  }
389
 
 
390
  prototype.find('select').val('');
391
  prototype.find('input').val('');
392
  prototype.css( { 'opacity' : '0' } );
@@ -429,170 +388,37 @@ jQuery(document).ready(function($){
429
 
430
  return false;
431
  });
432
-
433
- jQuery( '#wpsc_product_details_forms .category-tabs a, #wpsc_product_delivery_forms .category-tabs a' ).click(function(event){
434
- var $this = jQuery(this), href = $this.attr('href');
435
-
436
- $this.closest('ul').find('li').removeClass('tabs');
437
- $this.closest('li').addClass('tabs');
438
- $this.closest('div').find('.tabs-panel').hide();
439
- jQuery(href).show();
440
- event.preventDefault();
441
- });
442
-
443
- // Meta table
444
- var meta_inp_tem = jQuery('#wpsc_new_meta_template').remove().removeAttr('id');
445
-
446
- jQuery('#wpsc_add_custom_meta').click(function(){
447
- if ( jQuery( 'tr.no-meta' ).is( ':visible' ) ) {
448
- jQuery( 'tr.no-meta' ).hide();
449
- }
450
-
451
- jQuery('#wpsc_product_meta_table tbody').append(meta_inp_tem.clone());
452
- event.preventDefault();
453
- });
454
-
455
- // Init delivery metabox live title
456
- if (jQuery('#wpsc_product_delivery_forms').length > 0){
457
- jQuery('#wpsc_product_delivery_forms input, #wpsc_product_delivery_forms select').change(wpsc_update_delivery_metabox_live_title);
458
- wpsc_update_delivery_metabox_live_title();
459
- }
460
-
461
- // Init product details metabox live title
462
- if (jQuery('#wpsc_product_details_forms').length > 0){
463
- jQuery('#wpsc_product_details_forms a').click(wpsc_update_product_details_metabox_live_title);
464
- wpsc_update_product_details_metabox_live_title();
465
- }
466
-
467
- wpsc_update_price_live_preview();
468
  });
469
 
 
 
 
 
470
 
471
- // Remove new/empty custom meta input row
472
- function wpsc_remove_empty_meta(caller){
473
- jQuery(caller).closest('tr').remove();
474
-
475
- wpsc_update_product_details_metabox_live_title();
476
-
477
- if ( ! jQuery( '#wpsc_product_meta_table tbody tr' ).not( '.no-meta' ).length ) {
478
- jQuery( 'tr.no-meta' ).show();
479
- }
480
-
481
- event.preventDefault();
482
  }
483
 
484
  // function for removing custom meta
485
- function wpsc_remove_custom_meta(caller, meta_id) {
486
- var post_data = {
487
- action : 'remove_product_meta',
488
- 'meta_id' : meta_id,
489
- nonce : jQuery(caller).data('nonce')
490
- };
491
-
492
- var response_handler = function(response) {
493
- if (! response.is_successful) {
494
- alert(response.error.messages.join("\n"));
495
- return;
496
- }
497
- jQuery(caller).closest('tr').remove();
498
- };
499
-
500
- jQuery.wpsc_post(post_data, response_handler);
501
- wpsc_update_product_details_metabox_live_title();
502
-
503
- if ( ! jQuery( '#wpsc_product_meta_table tbody tr' ).not( '.no-meta' ).length ) {
504
- jQuery( 'tr.no-meta' ).show();
505
- }
506
-
507
- event.preventDefault();
508
- }
509
-
510
- // Copy value of caller to target text
511
- function wpsc_push_v2t(caller, target_slt){
512
- jQuery(target_slt).text(jQuery(caller).val());
513
- }
514
-
515
- function wpsc_update_price_live_preview(){
516
- var price = jQuery('#wpsc_price').val();
517
- var sale_price = jQuery('#wpsc_sale_price').val();
518
-
519
- if (sale_price > 0){
520
- jQuery('#wpsc_product_price_metabox_live_title>p>span').text(sale_price);
521
- jQuery('#wpsc_product_price_metabox_live_title>del>span').text(price);
522
- jQuery('#wpsc_product_price_metabox_live_title>del').show();
523
- } else {
524
- jQuery('#wpsc_product_price_metabox_live_title>p>span').text(price);
525
- jQuery('#wpsc_product_price_metabox_live_title>del').hide();
526
- }
527
- }
528
-
529
- // Compose and update live title for shipping metabox
530
- function wpsc_update_delivery_metabox_live_title(){
531
-
532
- if ( ! jQuery('#wpsc_product_delivery_forms').length ) {
533
- return;
534
- }
535
-
536
- var weight = jQuery('#wpsc-product-shipping-weight').val();
537
- var weight_unit = jQuery('#wpsc-product-shipping-weight-unit').val();
538
- var length = jQuery('#wpsc-product-shipping-length').val();
539
- var width = jQuery('#wpsc-product-shipping-width').val();
540
- var height = jQuery('#wpsc-product-shipping-height').val();
541
- var dimensions_unit = jQuery('#wpsc-product-shipping-dimensions-unit').val();
542
- var number_of_downloads = jQuery('.wpsc_product_download_row').length;
543
-
544
- var vol = Math.round( ( length * width * height ) * 100) / 100; // Round up to two decimal
545
- var downloads_name = ( number_of_downloads !== 1 ) ? wpsc_adminL10n.meta_downloads_plural : wpsc_adminL10n.meta_downloads_singular;
546
- var output = '';
547
-
548
- if ( jQuery( '.wpsc-product-shipping-section' ).length ) {
549
- output += weight + ' ' + weight_unit + ', ' + vol + ' ' + dimensions_unit + '<sup>3</sup>, ';
550
- }
551
-
552
- output += number_of_downloads + downloads_name;
553
-
554
- jQuery( '#wpsc_product_delivery_metabox_live_title > p' ).html( output );
555
- }
556
-
557
- function wpsc_update_product_details_metabox_live_title(){
558
- if (jQuery('#wpsc_product_details_forms').length <= 0) return;
559
-
560
- var number_of_photos = jQuery('#wpsc_product_gallery img').length;
561
- var number_of_meta = jQuery('#wpsc_product_meta_table tbody tr').not('.no-meta').length;
562
-
563
- var output = number_of_photos + ' images, ';
564
- output += number_of_meta + ' metadata';
565
-
566
- jQuery('#wpsc_product_details_metabox_live_title>p').html(output);
567
- }
568
-
569
- function wpsc_update_product_gallery_tab(obj){
570
- var output, url;
571
-
572
- output = '<div id="wpsc_product_gallery">';
573
- output += '<ul>';
574
-
575
- for (var i = 0; i < obj.length; i++) {
576
-
577
- if ( 'undefined' !== typeof obj[i].sizes.thumbnail ) {
578
- url = obj[i].sizes.thumbnail.url;
579
- } else {
580
- url = obj[i].sizes.full.url;
581
  }
 
 
582
 
583
- output += '<li>';
584
- output += '<img src="' + url + '">';
585
- output += '<input type="hidden" name="wpsc-product-gallery-imgs[]" value="' + obj[i].id + '">';
586
-
587
- output += '</li>';
588
- }
589
-
590
- output += '</ul>';
591
- output += '<div class="clear"></div>';
592
- output += '</div>';
593
-
594
- jQuery('#wpsc_product_gallery').replaceWith(output);
595
- wpsc_update_product_details_metabox_live_title();
596
  }
597
 
598
  var prevElement = null;
@@ -602,11 +428,11 @@ function hideOptionElement(id, option) {
602
  if (prevOption == option) {
603
  return;
604
  }
605
- if (prevElement !== null) {
606
  prevElement.style.display = "none";
607
  }
608
 
609
- if (id === null) {
610
  prevElement = null;
611
  } else {
612
  prevElement = document.getElementById(id);
@@ -648,4 +474,4 @@ function show_status_box(id,image_id) {
648
  document.getElementById(image_id).src = wpsc_adminL10n.wpsc_core_images_url + '/icon_window_expand.gif';
649
  }
650
  return false;
651
- }
10
  data['wpsc_action'] = data['action'];
11
  data['action'] = 'wpsc_ajax';
12
 
13
+ return $.post(ajaxurl, data, handler, 'json');
14
  };
15
 
16
  /**
24
  data['wpsc_action'] = data['action'];
25
  data['action'] = 'wpsc_ajax';
26
 
27
+ return $.get(ajaxurl, data, handler, 'json');
28
  };
29
 
30
  if( pagenow == 'edit-wpsc_product_category' ) {
36
  parent_id: 0
37
  };
38
 
39
+ jQuery.post(ajaxurl, data);
40
  }
41
 
42
  var submit_handlers = [];
43
 
44
  var disable_ajax_submit = function() {
45
  var t = $('#submit');
46
+ console.log(t);
47
+ console.log(t.data('events'));
48
+ console.log(t.data('events').click);
49
  if (t.data('events'))
50
  submit_handlers = t.data('events').click;
51
  t.off('click');
65
  };
66
 
67
  $(function(){
 
 
 
 
68
  var table = $('body.edit-tags-php .wp-list-table');
69
  table.find('tbody tr').each(function(){
70
  var t = $(this),
157
 
158
  }(jQuery));
159
 
160
+ jQuery(document).ready(function(){
 
 
 
161
  jQuery('td.hidden_alerts img').each(function(){
162
  var t = jQuery(this);
163
  t.appendTo(t.parents('tr').find('td.column-title strong'));
164
  });
165
 
 
 
 
 
 
 
 
 
 
 
 
166
  /* Coupon edit functionality */
167
  jQuery('.modify_coupon').hide();
168
  jQuery('.wpsc_edit_coupon').click(function(){
179
  });
180
  jQuery("form[name='add_coupon']").submit(function() {
181
  var title = jQuery("form[name='add_coupon'] input[name='add_coupon_code']").val();
182
+ if ( title == '') {
183
  jQuery('<div id="notice" class="error"><p>' + wpsc_adminL10n.empty_coupon + '</p></div>').insertAfter('div.wrap > h2').delay(2500).hide(350);
184
  return false;
185
  }
186
  });
187
 
188
+ //new currency JS in admin product page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
+ var firstclick = true;
191
 
192
+ jQuery('#wpsc_price_control_forms').on( 'click', 'a.wpsc_add_new_currency', function( event ){
193
+ if(firstclick == true){
194
+ jQuery('div.new_layer').show();
195
+ html = jQuery('div.new_layer').html();
196
+ firstclick = false;
197
+ }else{
198
+ jQuery('div.new_layer').after('<div>'+html+'</div>');
199
+ }
200
+ event.preventDefault();
 
201
  });
202
 
203
+ //delete currency layer in admin product page
204
+ jQuery('#wpsc_price_control_forms').on( 'click', 'a.wpsc_delete_currency_layer', function(event){
205
+ jQuery(this).prev('input').val('');
206
+ jQuery(this).prev('select').val('');
207
+ jQuery(this).parent('div:first').hide();
208
+ event.preventDefault();
 
 
 
209
  });
210
 
211
+ //As far as I can tell, WP provides no good way of unsetting elements in the bulk edit area...tricky jQuery action will do for now....not ideal whatsoever, nor eternally stable.
 
 
 
212
  if( pagenow == 'edit-wpsc-product' ) {
213
  jQuery('.inline-edit-password-input').closest('.inline-edit-group').css('display', 'none');
214
  var vcl = jQuery('.inline-edit-col input[name="tax_input[wpsc-variation][]"]').css('display', 'none');
253
  jQuery('th.column-stock input, td.stock input').each(function(){
254
  this.disabled = ! checked;
255
  });
256
+ }
257
 
258
  if (limited_stock_checkbox.size() > 0) {
259
  toggle_stock_fields(limited_stock_checkbox.is(':checked'));
264
  toggle_stock_fields(limited_stock_checkbox.is(':checked'));
265
  });
266
 
267
+ jQuery("#table_rate_price").on( 'click', function(){
268
+ if (this.checked) {
269
+ jQuery("#table_rate").show();
270
+ } else {
271
+ jQuery("#table_rate").hide();
272
+ }
273
+ });
274
+
275
  jQuery("#custom_tax_checkbox").on( 'click', function(){
276
  if (this.checked) {
277
  jQuery("#custom_tax").show();
281
  }
282
  });
283
 
284
+ jQuery( 'div#table_rate' ).on( 'click', '.add_level', function(){
285
+ added = jQuery(this).parent().children('table').append('<tr><td><input type="text" size="10" value="" name="table_rate_price[quantity][]"/> and above</td><td><input type="text" size="10" value="" name="table_rate_price[table_price][]"/></td></tr>');
286
+ });
287
+
288
+ jQuery( 'div#table_rate' ).on( 'click', '.remove_line', function(){
289
+ jQuery(this).parent().parent('tr').remove();
290
+ });
291
+
292
  jQuery( '.wpsc_featured_product_toggle' ).on( 'click', function(){
293
  post_values = {
294
  product_id : jQuery( this ).parents( 'tr' ).attr( 'id' ).replace( 'post-', '' ),
343
  if ( jQuery( 'select[name="rules[operator][]"]', prototype ).length === 0 ) {
344
  operator_box.append("<option value='and'>" + wpsc_adminL10n.coupons_compare_and + "</option>");
345
  operator_box.append("<option value='or'>" + wpsc_adminL10n.coupons_compare_or + "</option>");
 
346
  }
347
 
348
+
349
  prototype.find('select').val('');
350
  prototype.find('input').val('');
351
  prototype.css( { 'opacity' : '0' } );
388
 
389
  return false;
390
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  });
392
 
393
+ // function for adding more custom meta
394
+ function add_more_meta(e) {
395
+ var current_meta_forms = jQuery(e).parent().children("div.product_custom_meta:last"), // grab the form container
396
+ new_meta_forms = current_meta_forms.clone(); // clone the form container
397
 
398
+ new_meta_forms.find('input, textarea').val('');
399
+ current_meta_forms.after(new_meta_forms); // append it after the container of the clicked element
400
+ return false;
 
 
 
 
 
 
 
 
401
  }
402
 
403
  // function for removing custom meta
404
+ function remove_meta(e, meta_id) {
405
+ var t = jQuery(e),
406
+ current_meta_form = t.parent("div.product_custom_meta"), // grab the form container
407
+ post_data = {
408
+ action : 'remove_product_meta',
409
+ 'meta_id' : meta_id,
410
+ nonce : t.data('nonce')
411
+ },
412
+ response_handler = function(response) {
413
+ if (! response.is_successful) {
414
+ alert(response.error.messages.join("\n"));
415
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
417
+ jQuery("div#custom_meta_"+meta_id).remove();
418
+ };
419
 
420
+ jQuery.wpsc_post(post_data, response_handler);
421
+ return false;
 
 
 
 
 
 
 
 
 
 
 
422
  }
423
 
424
  var prevElement = null;
428
  if (prevOption == option) {
429
  return;
430
  }
431
+ if (prevElement != null) {
432
  prevElement.style.display = "none";
433
  }
434
 
435
+ if (id == null) {
436
  prevElement = null;
437
  } else {
438
  prevElement = document.getElementById(id);
474
  document.getElementById(image_id).src = wpsc_adminL10n.wpsc_core_images_url + '/icon_window_expand.gif';
475
  }
476
  return false;
477
+ }
wpsc-admin/js/media.js CHANGED
@@ -152,8 +152,6 @@
152
  } else {
153
  this.set( resp.obj, { parse: true } );
154
  }
155
-
156
- wpsc_update_product_gallery_tab(resp.obj);
157
  },
158
  error: function( resp ) {
159
  alert( resp.error.messages.join( "\n" ) );
@@ -183,7 +181,6 @@
183
  },
184
 
185
  sync: function( method, collection, options ) {
186
-
187
  var data;
188
  options = options ? _.clone( options ) : {};
189
 
@@ -208,7 +205,6 @@
208
  items : this.pluck( 'id' ),
209
  postId: this.postId
210
  }, options.data );
211
-
212
  break;
213
 
214
  case 'create':
@@ -349,7 +345,7 @@
349
  // hack the Remove thumbnail link so that it refreshes the variation iframe
350
  // after the AJAX request is processed
351
  WPRemoveThumbnail = function(nonce){
352
- $.post( ajaxurl, {
353
  action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
354
  }, function(str){
355
  if ( str == '0' ) {
@@ -392,10 +388,5 @@
392
 
393
  frame.open();
394
  });
395
- // make our gallery sortable
396
- $( 'div#wpsc_product_gallery' ).find( 'ul' ).sortable({
397
- cursor: 'move',
398
- revert: 300,
399
- }).disableSelection();
400
  });
401
  }(jQuery));
152
  } else {
153
  this.set( resp.obj, { parse: true } );
154
  }
 
 
155
  },
156
  error: function( resp ) {
157
  alert( resp.error.messages.join( "\n" ) );
181
  },
182
 
183
  sync: function( method, collection, options ) {
 
184
  var data;
185
  options = options ? _.clone( options ) : {};
186
 
205
  items : this.pluck( 'id' ),
206
  postId: this.postId
207
  }, options.data );
 
208
  break;
209
 
210
  case 'create':
345
  // hack the Remove thumbnail link so that it refreshes the variation iframe
346
  // after the AJAX request is processed
347
  WPRemoveThumbnail = function(nonce){
348
+ $.post(ajaxurl, {
349
  action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
350
  }, function(str){
351
  if ( str == '0' ) {
388
 
389
  frame.open();
390
  });
 
 
 
 
 
391
  });
392
  }(jQuery));
wpsc-admin/js/product-variations.js CHANGED
@@ -8,12 +8,10 @@
8
  $(function(){
9
  resize_iframe();
10
 
11
- $('.wpsc-variation-stock-editor-link').click( function( event ) {
12
  var parent = $(this).closest('tr'),
13
  target_row = parent.next('.wpsc-stock-editor-row');
14
 
15
- event.preventDefault();
16
-
17
  target_row.show();
18
  parent.addClass('active');
19
  resize_iframe();
8
  $(function(){
9
  resize_iframe();
10
 
11
+ $('.wpsc-variation-stock-editor-link').click(function(){
12
  var parent = $(this).closest('tr'),
13
  target_row = parent.next('.wpsc-stock-editor-row');
14
 
 
 
15
  target_row.show();
16
  parent.addClass('active');
17
  resize_iframe();
wpsc-admin/js/purchase-log-action-links.js DELETED
@@ -1,124 +0,0 @@
1
-
2
- ( function( $ ) {
3
-
4
- /**
5
- * Purchase Log Action Links
6
- */
7
- $.extend( WPSC_Purchase_Log_Action_Links, {
8
-
9
- /**
10
- * Setup purchase log action links and event handlers.
11
- *
12
- * @since 3.9.0
13
- */
14
- init : function() {
15
-
16
- $( function() {
17
- var wrapper = $( '#wpsc_purchlogitems_links ul' );
18
-
19
- // Add spinners to AJAX links
20
- wrapper.find( 'a.wpsc-purchlog-action-link.is-ajax' ).each( function() {
21
- $( this ).prepend( $( '<span class="spinner" />' ) );
22
- } );
23
-
24
- wrapper.on( 'click', 'a.wpsc-purchlog-action-link.is-ajax', WPSC_Purchase_Log_Action_Links.event_ajax_link_clicked );
25
- } );
26
-
27
- },
28
-
29
- /**
30
- * Handle purchase log action link click.
31
- *
32
- * @since 3.9.0
33
- */
34
- event_ajax_link_clicked : function( e ) {
35
-
36
- var action = $( this ).data( 'purchase-log-action' );
37
- var nonce = $( this ).data( 'nonce' );
38
-
39
- if ( action ) {
40
-
41
- // Only do AJAX request if not already doing it.
42
- if ( ! $( this ).hasClass( 'doing' ) ) {
43
-
44
- var post_data = {
45
- 'action' : 'purchase_log_action_link',
46
- 'purchase_log_action_link' : action,
47
- 'purchase_log_action_nonce' : nonce,
48
- 'log_id' : WPSC_Purchase_Log_Action_Links.log_id,
49
- 'nonce' : WPSC_Purchase_Log_Action_Links.purchase_log_action_link_nonce
50
- };
51
-
52
- $( this ).addClass( 'doing' );
53
- $.wpsc_post( post_data, WPSC_Purchase_Log_Action_Links.ajax_callback );
54
-
55
- }
56
-
57
- e.preventDefault();
58
-
59
- }
60
-
61
- },
62
-
63
- /**
64
- * Handle purchase log action AJAX response.
65
- *
66
- * @since 3.9.0
67
- */
68
- ajax_callback : function( response ) {
69
-
70
- // If AJAX successful and purchase log action successful.
71
- if ( response.is_successful && response.obj.success ) {
72
-
73
- var dashicon = $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link-' + response.obj.purchase_log_action_link + ' .dashicons' );
74
- var dashicon_class = dashicon.attr( 'class' );
75
-
76
- // Successful notification.
77
- dashicon.removeClass().addClass( 'dashicons dashicons-yes' );
78
- setTimeout( function() {
79
- dashicon.removeClass().addClass( dashicon_class );
80
- }, 3000 );
81
-
82
- // Remove spinner
83
- $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link.doing' ).removeClass( 'doing' );
84
-
85
- } else {
86
-
87
- // Ideally we'd always like to know which link was clicked, but we don't
88
- // so just clear all spinners and only clear specific spinner if AJAX response was processed.
89
-
90
- var dashicon = $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link.doing .dashicons' );
91
- if ( response.is_successful ) {
92
- dashicon = $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link-' + response.obj.purchase_log_action_link + ' .dashicons' );
93
- }
94
- var dashicon_class = dashicon.attr( 'class' );
95
-
96
- if ( response.obj.success != null ) {
97
-
98
- // Failure notification.
99
- dashicon.removeClass().addClass( 'dashicons dashicons-no' );
100
- setTimeout( function() {
101
- dashicon.removeClass().addClass( dashicon_class );
102
- }, 3000 );
103
-
104
- } else {
105
- dashicon.removeClass().addClass( dashicon_class );
106
- }
107
-
108
- // Remove spinner.
109
- $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link.doing' ).removeClass( 'doing' );
110
-
111
- // Show error message.
112
- if ( typeof response.error !== 'undefined' ) {
113
- alert( response.error.messages.join( "\n" ) );
114
- }
115
-
116
- }
117
-
118
- }
119
-
120
- } );
121
-
122
- } )( jQuery );
123
-
124
- WPSC_Purchase_Log_Action_Links.init();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/js/settings-page.js CHANGED
@@ -920,7 +920,7 @@
920
  event_edit_shipping_module : function() {
921
  var element = $(this),
922
  shipping_module_id = element.closest('.wpsc-select-shipping').data('shipping-id'),
923
- spinner = element.children('.ajax-feedback'),
924
  post_data = {
925
  action : 'shipping_module_settings_form',
926
  'shipping_module_id' : shipping_module_id,
@@ -929,7 +929,7 @@
929
  ajax_callback = function(response) {
930
  if (! response.is_successful) {
931
  alert(response.error.messages.join("\n"));
932
- return false;
933
  }
934
 
935
  if (history.pushState) {
@@ -937,20 +937,14 @@
937
  history.pushState({url : new_url}, '', new_url);
938
  }
939
  spinner.toggleClass('ajax-feedback-active');
940
-
941
  $('#wpsc_shipping_settings_' + shipping_module_id + '_form').remove();
942
- $('#wpsc_shipping_settings_'+ shipping_module_id).show( 400 );
943
  $('#wpsc_shipping_settings_'+ shipping_module_id + '_container').append(response.obj.content);
944
 
945
  };
946
 
947
- if ( $( '#wpsc_shipping_settings_' + shipping_module_id + '_form' ).is( ':visible' ) ) {
948
- return false;
949
- }
950
-
951
  spinner.toggleClass('ajax-feedback-active');
952
  $.wpsc_post(post_data, ajax_callback);
953
-
954
  return false;
955
  },
956
 
@@ -961,14 +955,13 @@
961
  event_edit_shipping_module_cancel : function() {
962
  var element = $(this),
963
  shipping_module_id = element.closest('.wpsc-select-shipping').data('shipping-id');
964
-
965
  if (history.pushState) {
966
  var new_url = '?page=wpsc-settings&tab=' + WPSC_Settings_Page.current_tab;
967
  history.pushState({'url' : new_url}, '', new_url);
968
  }
969
  $('#wpsc_shipping_settings_' + shipping_module_id + '_form').remove();
970
- $('#wpsc_shipping_settings_' + shipping_module_id).hide( 400 );
971
-
972
  return false;
973
  },
974
 
@@ -995,7 +988,7 @@
995
  spinner.toggleClass('ajax-feedback-active');
996
  };
997
  spinner.toggleClass('ajax-feedback-active');
998
- $.post( ajaxurl, post_data, ajax_callback, 'json' );
999
  return false;
1000
  },
1001
 
@@ -1031,9 +1024,9 @@
1031
  nonce : WPSC_Settings_Page.payment_gateway_settings_form_nonce
1032
  },
1033
  ajax_callback = function(response) {
1034
- if ( ! response.is_successful ) {
1035
  alert(response.error.messages.join("\n"));
1036
- return false;
1037
  }
1038
 
1039
  if (history.pushState) {
@@ -1042,14 +1035,10 @@
1042
  }
1043
  spinner.toggleClass('ajax-feedback-active');
1044
  $('#gateway_settings_' + payment_gateway_id + '_form').remove();
1045
- $('#wpsc_gateway_settings_'+ payment_gateway_id).show( 400 );
1046
  $('#wpsc_gateway_settings_'+ payment_gateway_id + '_container').append(response.obj.content);
1047
  };
1048
 
1049
- if ( $( '#gateway_settings_' + payment_gateway_id + '_form' ).is( ':visible' ) ) {
1050
- return false;
1051
- }
1052
-
1053
  spinner.toggleClass('ajax-feedback-active');
1054
  $.wpsc_post(post_data, ajax_callback);
1055
  return false;
@@ -1062,7 +1051,7 @@
1062
  history.pushState({'url' : new_url}, '', new_url);
1063
  }
1064
  $('#gateway_settings_' + payment_gateway_id + '_form').remove();
1065
- $('#wpsc_gateway_settings_' + payment_gateway_id).hide( 400 );
1066
  return false;
1067
  }
1068
  };
920
  event_edit_shipping_module : function() {
921
  var element = $(this),
922
  shipping_module_id = element.closest('.wpsc-select-shipping').data('shipping-id'),
923
+ spinner = element.siblings('.ajax-feedback'),
924
  post_data = {
925
  action : 'shipping_module_settings_form',
926
  'shipping_module_id' : shipping_module_id,
929
  ajax_callback = function(response) {
930
  if (! response.is_successful) {
931
  alert(response.error.messages.join("\n"));
932
+ return;
933
  }
934
 
935
  if (history.pushState) {
937
  history.pushState({url : new_url}, '', new_url);
938
  }
939
  spinner.toggleClass('ajax-feedback-active');
 
940
  $('#wpsc_shipping_settings_' + shipping_module_id + '_form').remove();
941
+ $('#wpsc_shipping_settings_'+ shipping_module_id).show();
942
  $('#wpsc_shipping_settings_'+ shipping_module_id + '_container').append(response.obj.content);
943
 
944
  };
945
 
 
 
 
 
946
  spinner.toggleClass('ajax-feedback-active');
947
  $.wpsc_post(post_data, ajax_callback);
 
948
  return false;
949
  },
950
 
955
  event_edit_shipping_module_cancel : function() {
956
  var element = $(this),
957
  shipping_module_id = element.closest('.wpsc-select-shipping').data('shipping-id');
958
+ console.log('cancel', shipping_module_id);
959
  if (history.pushState) {
960
  var new_url = '?page=wpsc-settings&tab=' + WPSC_Settings_Page.current_tab;
961
  history.pushState({'url' : new_url}, '', new_url);
962
  }
963
  $('#wpsc_shipping_settings_' + shipping_module_id + '_form').remove();
964
+ $('#wpsc_shipping_settings_' + shipping_module_id).hide();
 
965
  return false;
966
  },
967
 
988
  spinner.toggleClass('ajax-feedback-active');
989
  };
990
  spinner.toggleClass('ajax-feedback-active');
991
+ $.post(ajaxurl, post_data, ajax_callback, 'json');
992
  return false;
993
  },
994
 
1024
  nonce : WPSC_Settings_Page.payment_gateway_settings_form_nonce
1025
  },
1026
  ajax_callback = function(response) {
1027
+ if (! response.is_successful) {
1028
  alert(response.error.messages.join("\n"));
1029
+ return;
1030
  }
1031
 
1032
  if (history.pushState) {
1035
  }
1036
  spinner.toggleClass('ajax-feedback-active');
1037
  $('#gateway_settings_' + payment_gateway_id + '_form').remove();
1038
+ $('#wpsc_gateway_settings_'+ payment_gateway_id).show();
1039
  $('#wpsc_gateway_settings_'+ payment_gateway_id + '_container').append(response.obj.content);
1040
  };
1041
 
 
 
 
 
1042
  spinner.toggleClass('ajax-feedback-active');
1043
  $.wpsc_post(post_data, ajax_callback);
1044
  return false;
1051
  history.pushState({'url' : new_url}, '', new_url);
1052
  }
1053
  $('#gateway_settings_' + payment_gateway_id + '_form').remove();
1054
+ $('#wpsc_gateway_settings_' + payment_gateway_id).hide();
1055
  return false;
1056
  }
1057
  };
wpsc-admin/js/variations.js CHANGED
@@ -58,13 +58,7 @@ var wpsc_refresh_variation_iframe = function() {
58
  };
59
 
60
  (function($) {
61
-
62
  $(function(){
63
-
64
- if ( 'undefined' === typeof WPSC_Term_List_Levels ) {
65
- return;
66
- }
67
-
68
  var table = $('body.edit-tags-php .wp-list-table');
69
  table.find('tbody tr').each(function(){
70
  var t = $(this);
@@ -93,6 +87,6 @@ var wpsc_refresh_variation_iframe = function() {
93
  sort_order: order,
94
  parent_id: 0
95
  };
96
- jQuery.post( ajaxurl, data );
97
  };
98
  })(jQuery);
58
  };
59
 
60
  (function($) {
 
61
  $(function(){
 
 
 
 
 
62
  var table = $('body.edit-tags-php .wp-list-table');
63
  table.find('tbody tr').each(function(){
64
  var t = $(this);
87
  sort_order: order,
88
  parent_id: 0
89
  };
90
+ jQuery.post(ajaxurl, data);
91
  };
92
  })(jQuery);
wpsc-admin/js/wp-e-commerce-admin.js DELETED
@@ -1,169 +0,0 @@
1
- ///////////////////////////////////////////////////////////////////////////////////////////////
2
- // This section is used to create the globals that were originally defined in the
3
- // dynamic-js file pre 3.8.14. Note that variables also also exist in the "wpsc_ajax" structure.
4
- // To add a new global property that can be referenced in the script see the hook
5
- // wpsc_javascript_localizations in wpsc-core/wpsc-functions.php
6
- //
7
-
8
- /**
9
- * Legacy javascript variables for WP-e-Commerce
10
- *
11
- * These WPeC WordPress localized vars were in use prior to release 3.8.14, and are explicitly
12
- * declared here for maximum backwards compatibility. For admin related js vars added after
13
- * version 3.8.14 use the following utility function to access the localized variables.
14
- *
15
- * wpsc_admin_var_get ( name )
16
- * wpsc_admin_var_set ( name, value )
17
- * wpsc_admin_var_isset ( name, value );
18
- *
19
- */
20
-
21
- if ( typeof wpsc_admin_vars !== undefined ) {
22
- var ajaxurl = wpsc_admin_vars['ajaxurl'];
23
- var base_url = wpsc_admin_vars['base_url'];
24
- var WPSC_URL = wpsc_admin_vars['WPSC_URL'];
25
- var WPSC_IMAGE_URL = wpsc_admin_vars['WPSC_IMAGE_URL'];
26
- var fileThickboxLoadingImage = wpsc_admin_vars['fileThickboxLoadingImage'];
27
- var hidden_boxes = wpsc_admin_vars['hidden_boxes'];
28
- var IS_WP27 = wpsc_admin_vars['IS_WP27'];
29
- var TXT_WPSC_DELETE = wpsc_admin_vars['TXT_WPSC_DELETE'];
30
- var TXT_WPSC_TEXT = wpsc_admin_vars['TXT_WPSC_TEXT'];
31
- var TXT_WPSC_EMAIL = wpsc_admin_vars['TXT_WPSC_EMAIL'];
32
- var TXT_WPSC_COUNTRY = wpsc_admin_vars['TXT_WPSC_COUNTRY'];
33
- var TXT_WPSC_TEXTAREA = wpsc_admin_vars['TXT_WPSC_TEXTAREA'];
34
- var TXT_WPSC_HEADING = wpsc_admin_vars['TXT_WPSC_HEADING'];
35
- var TXT_WPSC_COUPON = wpsc_admin_vars['TXT_WPSC_COUPON'];
36
- var HTML_FORM_FIELD_TYPES = wpsc_admin_vars['HTML_FORM_FIELD_TYPES'];
37
- var HTML_FORM_FIELD_UNIQUE_NAMES = wpsc_admin_vars['HTML_FORM_FIELD_UNIQUE_NAMES'];
38
- var TXT_WPSC_LABEL = wpsc_admin_vars['TXT_WPSC_LABEL'];
39
- var TXT_WPSC_LABEL_DESC = wpsc_admin_vars['TXT_WPSC_LABEL_DESC'];
40
- var TXT_WPSC_ITEM_NUMBER = wpsc_admin_vars['TXT_WPSC_ITEM_NUMBER'];
41
- var TXT_WPSC_LIFE_NUMBER = wpsc_admin_vars['TXT_WPSC_LIFE_NUMBER'];
42
- var TXT_WPSC_PRODUCT_CODE = wpsc_admin_vars['TXT_WPSC_PRODUCT_CODE'];
43
- var TXT_WPSC_PDF = wpsc_admin_vars['TXT_WPSC_PDF'];
44
- var TXT_WPSC_AND_ABOVE = wpsc_admin_vars['TXT_WPSC_AND_ABOVE'];
45
- var TXT_WPSC_IF_PRICE_IS = wpsc_admin_vars['TXT_WPSC_IF_PRICE_IS'];
46
- var TXT_WPSC_IF_WEIGHT_IS = wpsc_admin_vars['TXT_WPSC_IF_WEIGHT_IS'];
47
- }
48
- ///////////////////////////////////////////////////////////////////////////////////////////////
49
-
50
- /**
51
- * check if a localized WPeC value is set
52
- *
53
- * @since 3.8.14
54
- *
55
- * @param string name name of localized variable
56
- *
57
- * @returns boolean true if the var is set, false otherwise
58
- *
59
- */
60
- function wpsc_admin_var_isset( name ) {
61
- if ( typeof wpsc_admin_vars !== undefined ) {
62
- return wpsc_admin_vars[name] !== undefined;
63
- }
64
-
65
- return false;
66
- }
67
-
68
- /**
69
- * get the value of a localized WPeC value if it is set
70
- *
71
- * @since 3.8.14
72
- *
73
- * @param string name name of localized variable
74
- *
75
- * @returns varies value of the var set
76
- *
77
- */
78
- function wpsc_admin_var_get( name ) {
79
- if ( typeof wpsc_admin_vars !== undefined ) {
80
- return wpsc_admin_vars[name];
81
- }
82
-
83
- return undefined;
84
- }
85
-
86
- /**
87
- * change the value of a localized WPeC var
88
- *
89
- * @since 3.8.14
90
- *
91
- * @param string name name of localized variable
92
- * @param varies value value of the var being set
93
- *
94
- * @returns varies value of the var being set
95
- *
96
- */
97
- function wpsc_admin_var_set( name, value ) {
98
- if ( typeof wpsc_admin_vars !== undefined ) {
99
- wpsc_admin_vars[name] = value;
100
- return value;
101
- }
102
-
103
- return undefined;
104
- }
105
-
106
-
107
- ///////////////////////////////////////////////////////////////////////////////////////////////
108
- // Setting up the WPEC customer identifier
109
- //
110
- // When WPEC generates a page it sets a 'customer cookie' into the browser. This cookie is a
111
- // persistent identifier that connects a user's session to their cart or other profile data a
112
- // store may need to work correctly.
113
- //
114
- // When page caching or a CDN is in place WPEC does not get to set the cookie because
115
- // the page is served without the overhead of computing the page contents.
116
- // This means that the first GET/POST request, including requests using AJAX are required to
117
- // initialize the customer identifier
118
- //
119
- // Because browsers may execute these requests in parallel the probability of multiple unique
120
- // cookies being set is very high. This means that in the absence of the logic below WPEC would
121
- // have to create multiple unique profiles as each of the parallel requests are executed. This
122
- // can cause data when one request uses one profile and the other request uses a different profile.
123
- // It could also cause performance issues on the back-end, and create a potentially resource
124
- // intensive and wasteful situation.
125
- //
126
- // The mitigation for this issue is to look for the customer identifier when this script first
127
- // runs. If the identifier is not found, initiate a very quick synchronous AJAX request. This
128
- // happens before any other processing takes place. This request should create the unique
129
- // customer identifier before it is required by other processing.
130
- //
131
-
132
- // a global variable used to hold the current users visitor id,
133
- // if you are going to user it always check to be sure it is not false
134
- var wpsc_visitor_id = false;
135
-
136
- if ( ! ( document.cookie.indexOf("wpsc_customer_cookie") >= 0 ) ) {
137
- if ( ! ( document.cookie.indexOf("wpsc_attempted_validate") >= 0 ) ) {
138
- // create a cookie to signal that we have attempted validation. If we find the cookie is set
139
- // we don't re-attempt validation. This means will only try to validate once and not slow down
140
- // subsequent page views.
141
-
142
- // The lack of expiration date means the cookie will be deleted when the browser
143
- // is closed, so the next time the visitor attempts to access the site they will
144
- // attempt to revalidate
145
- var now = new Date();
146
- document.cookie="wpsc_attempted_validate="+now;
147
-
148
- var wpsc_http = new XMLHttpRequest();
149
- wpsc_http.overrideMimeType( "application/json" );
150
-
151
- // open setup and send the request in synchronous mode
152
- wpsc_http.open( "POST", ajaxurl + "?action=wpsc_validate_customer", false );
153
- wpsc_http.setRequestHeader( "Content-type", "application/json; charset=utf-8" );
154
-
155
- // Note that we cannot set a timeout on synchronous requests due to XMLHttpRequest limitations
156
- wpsc_http.send();
157
-
158
- // we did the request in synchronous mode so we don't need the on load or ready state change events to check the result
159
- if (wpsc_http.status == 200) {
160
- var result = JSON.parse( wpsc_http.responseText );
161
- if ( result.valid && result.id ) {
162
- wpsc_visitor_id = result.id;
163
- }
164
- }
165
- }
166
- }
167
- // end of setting up the WPEC customer identifier
168
- ///////////////////////////////////////////////////////////////////////////////////////////////
169
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/media.php CHANGED
@@ -15,7 +15,7 @@ function _wpsc_action_enqueue_media_scripts() {
15
  $id = $post->ID;
16
 
17
  $gallery = _wpsc_get_product_gallery_json( $id );
18
- wp_enqueue_script( 'wpsc-media', WPSC_URL . '/wpsc-admin/js/media.js', array( 'media-editor', 'wp-e-commerce-admin', 'jquery-ui-sortable', 'post' ), WPSC_VERSION );
19
  wp_localize_script( 'wpsc-media', 'WPSC_Media', array(
20
  'l10n' => array(
21
  'productMediaTitle' => __( 'Add Images to Product Gallery', 'wpsc' ),
15
  $id = $post->ID;
16
 
17
  $gallery = _wpsc_get_product_gallery_json( $id );
18
+ wp_enqueue_script( 'wpsc-media', WPSC_URL . '/wpsc-admin/js/media.js', array( 'media-editor', 'wp-e-commerce-admin', 'post' ), WPSC_VERSION );
19
  wp_localize_script( 'wpsc-media', 'WPSC_Media', array(
20
  'l10n' => array(
21
  'productMediaTitle' => __( 'Add Images to Product Gallery', 'wpsc' ),
wpsc-admin/settings-page.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * WP eCommerce Settings Page API.
4
  *
5
  * Third-party plugin / theme developers can add their own tabs to WPEC store settings page.
6
  *
@@ -396,7 +396,7 @@ final class WPSC_Settings_Page {
396
  set_transient( 'settings_errors', get_settings_errors(), 30 );
397
  $query_args['settings-updated'] = true;
398
  }
399
- wp_redirect( add_query_arg( $query_args ) );
400
  exit;
401
  }
402
  }
@@ -448,7 +448,7 @@ final class WPSC_Settings_Page {
448
  private function submit_url() {
449
  $location = add_query_arg( 'tab', $this->current_tab_id );
450
  $location = apply_filters( 'wpsc_settings_page_submit_url', $location, $this, $this->current_tab );
451
- return $location;
452
  }
453
 
454
  /**
@@ -579,12 +579,6 @@ final class WPSC_Settings_Page {
579
  else
580
  update_option( 'wpsc_ga_tracking_id', '' );
581
 
582
- if ( isset( $_POST['wpsc_ga_use_universal'] ) && $_POST['wpsc_ga_use_universal'] == '1' ) {
583
- update_option( 'wpsc_ga_use_universal', 1 );
584
- } else {
585
- update_option( 'wpsc_ga_use_universal', 0 );
586
- }
587
-
588
  }
589
 
590
  if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
@@ -641,9 +635,6 @@ final class WPSC_Settings_Page {
641
  );
642
  }
643
  }
644
-
645
- WPSC_Countries::clear_cache();
646
- wpsc_core_flush_temporary_data();
647
  }
648
  $previous_currency = get_option( 'currency_type' );
649
 
1
  <?php
2
  /**
3
+ * WP e-Commerce Settings Page API.
4
  *
5
  * Third-party plugin / theme developers can add their own tabs to WPEC store settings page.
6
  *
396
  set_transient( 'settings_errors', get_settings_errors(), 30 );
397
  $query_args['settings-updated'] = true;
398
  }
399
+ wp_redirect( esc_url( add_query_arg( $query_args ) ) );
400
  exit;
401
  }
402
  }
448
  private function submit_url() {
449
  $location = add_query_arg( 'tab', $this->current_tab_id );
450
  $location = apply_filters( 'wpsc_settings_page_submit_url', $location, $this, $this->current_tab );
451
+ return esc_url( $location );
452
  }
453
 
454
  /**
579
  else
580
  update_option( 'wpsc_ga_tracking_id', '' );
581
 
 
 
 
 
 
 
582
  }
583
 
584
  if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
635
  );
636
  }
637
  }
 
 
 
638
  }
639
  $previous_currency = get_option( 'currency_type' );
640
 
wpsc-admin/users.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
- _wpsc_deprecated_file(
3
- __FILE__,
4
- '3.9',
5
- '',
6
- __( 'The sole function that existed in users.php has now been deprecated.', 'wpsc' )
7
- );
 
1
  <?php
2
+
3
+ add_action( 'user_profile_update_errors', '_wpsc_action_user_update_errors', 10, 3 );
4
+
5
+ function _wpsc_action_user_update_errors( $errors, $update, $user ) {
6
+ if ( $user->role == 'wpsc_anonymous' )
7
+ unset( $errors->errors['empty_email'] );
8
+ }
wpsc-components/marketplace-core-v1/library/Sputnik.php CHANGED
@@ -16,29 +16,29 @@ class Sputnik {
16
  /**
17
  * Minimum version of WordPress that Sputnik requires
18
  */
19
- const MINVERSION = '3.9';
20
 
21
  /**
22
  * Base URI for store URLs
23
  */
24
- const SITE_BASE = 'https://wpecommerce.org';
25
 
26
  /**
27
  * Base URI for API URLs
28
  */
29
- const API_BASE = 'https://wpecommerce.org/wpec';
30
 
31
  /**
32
  * OAuth client key
33
  */
34
- const OAUTH_KEY = 'k7q3lu9LeOJc';
35
 
36
  /**
37
  * OAuth client secret
38
  *
39
  * Not so secret any more.
40
  */
41
- const OAUTH_SECRET = '8jjSVN54VFhraZttr8pDsCdnogqE22Sq299zTRdFDL2hEUIq';
42
 
43
  /**
44
  * Path to Sputnik
@@ -111,10 +111,8 @@ class Sputnik {
111
 
112
  foreach ( $cart_contents as $product ) {
113
  $download_link = get_post_meta( $product->prodid, '_download_url', true );
114
- if ( !empty ( $download_link) ) {
115
- $download_link = esc_url( add_query_arg( 'marketplace', Sputnik_API::domain(), $download_link ) );
116
- $products .= "\n" . '<a href="' . $download_link . '">Download ' . $product->name . '</a>' . "\n";
117
- }
118
  }
119
 
120
  return $message . $products;
@@ -145,7 +143,7 @@ class Sputnik {
145
  die;
146
  }
147
 
148
- public static function add_download_link_page( $purchase_log_object, $sessionid, $display_to_screen ) {
149
  if ( ! $display_to_screen )
150
  return;
151
 
@@ -155,10 +153,8 @@ class Sputnik {
155
 
156
  foreach ( $cart_contents as $product ) {
157
  $download_link = get_post_meta( $product->prodid, '_download_url', true );
158
- if ( !empty ( $download_link) ) {
159
- $download_link = esc_url( add_query_arg( 'marketplace', Sputnik_API::domain(), $download_link ) );
160
- $products .= "\n" . '<a href="' . $download_link . '">Download ' . $product->name . '</a>' . "\n";
161
- }
162
  }
163
 
164
  echo $products;
@@ -339,7 +335,7 @@ class Sputnik {
339
  $cart_contents = json_decode( stripslashes( $_POST['cart_contents'] ) );
340
 
341
  //Unset purchase log ID, since we're inserting a new one.
342
- $data = (array) $data;
343
 
344
  unset( $data['id'] );
345
 
16
  /**
17
  * Minimum version of WordPress that Sputnik requires
18
  */
19
+ const MINVERSION = '3.2';
20
 
21
  /**
22
  * Base URI for store URLs
23
  */
24
+ const SITE_BASE = 'http://getshopped.org';
25
 
26
  /**
27
  * Base URI for API URLs
28
  */
29
+ const API_BASE = 'http://getshopped.org/wpec';
30
 
31
  /**
32
  * OAuth client key
33
  */
34
+ const OAUTH_KEY = 'NuDmOncs1pNb';
35
 
36
  /**
37
  * OAuth client secret
38
  *
39
  * Not so secret any more.
40
  */
41
+ const OAUTH_SECRET = 'Gf25Y3G2zoPGtFfiARoHCy1tWFDYqi9E1Wrhrp3tSkR4Tuht';
42
 
43
  /**
44
  * Path to Sputnik
111
 
112
  foreach ( $cart_contents as $product ) {
113
  $download_link = get_post_meta( $product->prodid, '_download_url', true );
114
+ $download_link = esc_url( add_query_arg( 'marketplace', Sputnik_API::domain(), $download_link ) );
115
+ $products .= "\n" . '<a href="' . $download_link . '">Download ' . $product->name . '</a>' . "\n";
 
 
116
  }
117
 
118
  return $message . $products;
143
  die;
144
  }
145
 
146
+ public function add_download_link_page( $purchase_log_object, $sessionid, $display_to_screen ) {
147
  if ( ! $display_to_screen )
148
  return;
149
 
153
 
154
  foreach ( $cart_contents as $product ) {
155
  $download_link = get_post_meta( $product->prodid, '_download_url', true );
156
+ $download_link = esc_url( add_query_arg( 'marketplace', Sputnik_API::domain(), $download_link ) );
157
+ $products .= "\n" . '<a href="' . $download_link . '">Download ' . $product->name . '</a>' . "\n";
 
 
158
  }
159
 
160
  echo $products;
335
  $cart_contents = json_decode( stripslashes( $_POST['cart_contents'] ) );
336
 
337
  //Unset purchase log ID, since we're inserting a new one.
338
+ $data = ( array ) $data;
339
 
340
  unset( $data['id'] );
341
 
wpsc-components/marketplace-core-v1/library/Sputnik/API.php CHANGED
@@ -7,11 +7,11 @@ class Sputnik_API {
7
  protected static $auth = null;
8
 
9
  /**
10
- * For sites like WPeCommerce.org that will distribute Sputnik with a plugin to sell WP plugins,
11
  * we override the domain. This is because we need to ensure Baikonur receives the Saas domain,
12
  * not the end-user domain. Only relevant where Sputnik is available to an end-user, not a Saas.
13
  */
14
- protected static $domain_override = 'https://wpecommerce.org';
15
 
16
  public static function get_all($page = 1, $params = null) {
17
  $url = '/';
@@ -22,22 +22,17 @@ class Sputnik_API {
22
  return self::request($url, $params);
23
  }
24
 
25
- public static function search( $query, $params = null, $page = 1 ) {
26
- $url = '/';
27
-
28
- if ( $page !== 1 ) {
29
- $url = sprintf( '/page/%d', $page );
30
  }
31
-
32
- $extra = array(
33
- 'query' => $query
34
  );
35
 
36
- $params = array_merge( $params, $extra );
37
-
38
- return self::request( $url, $params );
39
- }
40
-
41
 
42
  public static function get_single($name, $user = 0) {
43
  $params = array(
@@ -123,7 +118,7 @@ class Sputnik_API {
123
  <head>
124
  <title><?php _e( 'Redirecting ...', 'wpsc' ); ?></title>
125
  <script type="text/javascript">
126
- parent.location = '<?php echo wp_validate_redirect( $return_url ); ?>';
127
  window.close();
128
  </script>
129
  </head>
@@ -191,44 +186,39 @@ class Sputnik_API {
191
  return $response;
192
  }
193
 
 
194
  /* Helper Methods */
195
  public static function request($url, $params = null, $args = array()) {
 
 
196
 
197
- if ( ! empty( $params ) ) {
198
- $url = add_query_arg( $params, $url );
199
- }
200
-
201
- $defaults = array( 'method' => 'GET' );
202
-
203
- $args = wp_parse_args( $args, $defaults );
204
 
205
- if ( strpos( $url, 'http' ) !== 0 ) {
206
  $url = Sputnik::API_BASE . $url;
207
  }
208
 
209
- $args['timeout'] = 25;
210
- $args['headers']['user-agent'] = 'WP eCommerce Marketplace: ' . WPSC_VERSION;
211
  $args['headers']['X-WP-Domain'] = self::domain();
212
 
213
  $request = wp_remote_request( $url, $args );
214
 
215
- if ( is_wp_error( $request ) ) {
216
- throw new Exception( $request->get_error_message() );
217
  }
218
 
219
- if ( $request['response']['code'] != 200 ) {
220
  throw new Exception($request['body'], $request['response']['code']);
221
  }
222
-
223
  $result = json_decode($request['body']);
224
 
225
  if ($result === null) {
226
  throw new Exception($request['body'], $request['response']['code']);
227
  }
228
-
229
  $request['body'] = $result;
230
 
231
-
232
  return $request;
233
  }
234
 
7
  protected static $auth = null;
8
 
9
  /**
10
+ * For sites like GetShopped that will distribute Sputnik with a plugin to sell WP plugins,
11
  * we override the domain. This is because we need to ensure Baikonur receives the Saas domain,
12
  * not the end-user domain. Only relevant where Sputnik is available to an end-user, not a Saas.
13
  */
14
+ protected static $domain_override = 'http://getshopped.org';
15
 
16
  public static function get_all($page = 1, $params = null) {
17
  $url = '/';
22
  return self::request($url, $params);
23
  }
24
 
25
+ public static function search($query, $page = 1) {
26
+ $url = '/search';
27
+ if ($page !== 1) {
28
+ $url = sprintf('/search/page/%d', $page);
 
29
  }
30
+ $params = array(
31
+ 'query' => $query
 
32
  );
33
 
34
+ return self::request($url, $params);
35
+ }
 
 
 
36
 
37
  public static function get_single($name, $user = 0) {
38
  $params = array(
118
  <head>
119
  <title><?php _e( 'Redirecting ...', 'wpsc' ); ?></title>
120
  <script type="text/javascript">
121
+ parent.location = '<?php echo $return_url; ?>';
122
  window.close();
123
  </script>
124
  </head>
186
  return $response;
187
  }
188
 
189
+
190
  /* Helper Methods */
191
  public static function request($url, $params = null, $args = array()) {
192
+ if ( ! empty( $params ) )
193
+ $url = esc_url_raw( add_query_arg( $params, $url ) );
194
 
195
+ $defaults = array('method' => 'GET');
196
+ $args = wp_parse_args($args, $defaults);
 
 
 
 
 
197
 
198
+ if (strpos($url, 'http') !== 0) {
199
  $url = Sputnik::API_BASE . $url;
200
  }
201
 
202
+ $args['timeout'] = 25;
203
+
204
  $args['headers']['X-WP-Domain'] = self::domain();
205
 
206
  $request = wp_remote_request( $url, $args );
207
 
208
+ if (is_wp_error($request)) {
209
+ throw new Exception($request->get_error_message());
210
  }
211
 
212
+ if ($request['response']['code'] != 200) {
213
  throw new Exception($request['body'], $request['response']['code']);
214
  }
 
215
  $result = json_decode($request['body']);
216
 
217
  if ($result === null) {
218
  throw new Exception($request['body'], $request['response']['code']);
219
  }
 
220
  $request['body'] = $result;
221
 
 
222
  return $request;
223
  }
224
 
wpsc-components/marketplace-core-v1/library/Sputnik/API/Auth.php CHANGED
@@ -109,8 +109,7 @@ class Sputnik_API_Auth {
109
 
110
  protected function http($url, $method, $postfields = NULL) {
111
  $args = array(
112
- 'method' => $method,
113
- 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION
114
  );
115
 
116
  switch ($method) {
@@ -124,6 +123,9 @@ class Sputnik_API_Auth {
124
  $args['headers'] = array( 'X-WP-Domain' => Sputnik_API::domain() );
125
 
126
  $response = wp_remote_request($url, $args);
 
 
 
127
 
128
  if (is_wp_error($response)) {
129
  throw new Exception($response->get_error_message());
109
 
110
  protected function http($url, $method, $postfields = NULL) {
111
  $args = array(
112
+ 'method' => $method,
 
113
  );
114
 
115
  switch ($method) {
123
  $args['headers'] = array( 'X-WP-Domain' => Sputnik_API::domain() );
124
 
125
  $response = wp_remote_request($url, $args);
126
+ //echo '<pre />' . debug_print_backtrace();
127
+ //echo '<pre />' . print_r( $url, 1 );
128
+ //echo '<pre />' . print_r( $response, 1 );
129
 
130
  if (is_wp_error($response)) {
131
  throw new Exception($response->get_error_message());
wpsc-components/marketplace-core-v1/library/Sputnik/Admin.php CHANGED
@@ -21,11 +21,6 @@ class Sputnik_Admin {
21
  }
22
 
23
  public static function init() {
24
-
25
- if ( ! wpsc_is_store_admin() ) {
26
- return;
27
- }
28
-
29
  add_action('admin_print_styles', array(__CLASS__, 'styles'));
30
  add_action('admin_print_scripts', array(__CLASS__, 'scripts'));
31
 
@@ -40,7 +35,7 @@ class Sputnik_Admin {
40
  $redirect_url = '';
41
  if ( ! empty( $_REQUEST['oauth_buy'] ) ) {
42
  $redirect_url = self::build_url( array( 'oauth' => 'callback' ) );
43
- $redirect_url = add_query_arg( 'oauth_buy', $_REQUEST['oauth_buy'], $redirect_url );
44
  }
45
  Sputnik_API::auth_request( $redirect_url );
46
  }
@@ -95,7 +90,7 @@ class Sputnik_Admin {
95
  return;
96
  }
97
  ?>
98
- <div class="error"><p><?php _e('The following plugins are disabled:', 'wpsc') ?></p>
99
  <ul>
100
  <?php
101
  foreach ($invalid as $plugin) {
@@ -104,10 +99,10 @@ class Sputnik_Admin {
104
  }
105
  switch ($plugin['sputnik_error']) {
106
  case 'not_purchased':
107
- $error = __('Not purchased', 'wpsc');
108
  break;
109
  default:
110
- $error = __('Unknown error', 'wpsc');
111
  break;
112
  }
113
  ?>
@@ -127,18 +122,11 @@ class Sputnik_Admin {
127
  if (empty($data['Sputnik ID'])) {
128
  return $meta;
129
  }
130
- echo '<a class="sputnik-plugin-row-note" href="' . self::build_url() . '"><span class="powered">' . __( 'Powered by WPEConomy', 'wpsc' ) . '</span><span class="corner"></span></a>';
131
  return $meta;
132
  }
133
 
134
  public static function admin_head_page() {
135
-
136
- if ( ! wpsc_is_store_admin() ) {
137
- return;
138
- }
139
-
140
- add_filter( 'admin_body_class', array( __CLASS__, 'admin_body_class' ) );
141
-
142
  if (self::$page === 'dash') {
143
  self::$list_table = new Sputnik_List_Install();
144
  $pagenum = self::$list_table->get_pagenum();
@@ -153,28 +141,16 @@ class Sputnik_Admin {
153
  add_action('sputnik_messages', array(__CLASS__, 'admin_notices'));
154
  }
155
 
156
- public static function admin_body_class( $classes ) {
157
- return $classes . 'plugin-install-php';
158
- }
159
-
160
  public static function load_page() {
161
  //Sputnik_API::auth_or_redirect();
162
  }
163
 
164
  public static function styles() {
165
- wp_enqueue_style('sputnik', plugins_url( 'static/sputnik.css', Sputnik::$path . '/wpsc-marketplace' ), false, '20141202');
166
- ?>
167
- <style type="text/css">
168
- span#wpsc-extensions-menu-link {
169
- font-weight: bold;
170
- color: <?php self::get_marketplace_link_color(); ?>;
171
- }
172
- </style>
173
- <?php
174
  }
175
 
176
  public static function scripts() {
177
- wp_enqueue_script('sputnik_js', plugins_url( 'static/sputnik.js', Sputnik::$path . '/wpsc-marketplace' ), array('jquery', 'common'), '20141202' );
178
  }
179
 
180
  public static function connect_notice() {
@@ -193,14 +169,14 @@ class Sputnik_Admin {
193
  <?php _e( '<strong>WPEConomy is now installed!</strong> &#8211; Get started by linking with your account!', 'wpsc' ); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
194
  <?php _e( "If you haven't created an account yet, don't worry, you will be prompted to do so.", 'wpsc') ?>
195
  </p>
196
- <a href="<?php echo esc_html( $oauth_url ); ?>" class="thickbox button button-primary thickbox`"><?php _e( 'Link your account now', 'wpsc' ); ?></a>
197
  </div>
198
  <?php
199
  }
200
 
201
  public static function admin_notices() {
202
  if ( isset( $_GET['payment_cancelled'] ) ) {
203
- self::print_message( __( 'Payment cancelled.', 'wpsc' ) );
204
  }
205
  }
206
 
@@ -227,12 +203,11 @@ class Sputnik_Admin {
227
  }
228
 
229
  public static function menu() {
230
- $hooks[] = add_submenu_page( 'edit.php?post_type=wpsc-product', _x( 'Extensions', 'page title', 'wpsc' ), _x( '<span id="wpsc-extensions-menu-link">Extensions</span>', 'menu title', 'wpsc' ), 'install_plugins', 'sputnik', array( __CLASS__, 'page' ) );
231
  $hooks[] = 'plugin-install.php';
232
-
233
- foreach ( $hooks as $hook ) {
234
- add_action( "admin_print_styles-$hook" , array( __CLASS__, 'page_styles' ) );
235
- add_action( "admin_print_scripts-$hook", array( __CLASS__, 'page_scripts' ) );
236
  }
237
  }
238
 
@@ -242,7 +217,7 @@ class Sputnik_Admin {
242
  if (!empty($args)) {
243
  $url = add_query_arg( $args, $url );
244
  }
245
- return $url;
246
  }
247
 
248
  public static function build_account_url($args = array()) {
@@ -250,50 +225,39 @@ class Sputnik_Admin {
250
  if (!empty($args)) {
251
  $url = add_query_arg( $args, $url );
252
  }
253
- return $url;
254
  }
255
 
256
  public static function page_styles() {
257
  self::$page_is_current = true;
258
- wp_enqueue_style('wpsc-marketplace-page', plugins_url( 'static/admin.css', Sputnik::$path . '/wpsc-marketplace' ), array( 'thickbox' ), '20141109' );
259
- }
260
-
261
- public static function get_marketplace_link_color() {
262
- global $_wp_admin_css_colors;
263
-
264
- $_color = get_user_option( 'admin_color' );
265
-
266
- if ( empty( $_color ) || ! isset( $_wp_admin_css_colors[ $_color ] ) ) {
267
- $_color = 'fresh';
268
- }
269
-
270
- $color = $_wp_admin_css_colors[ $_color ];
271
-
272
- if ( in_array( $_color, array( 'blue', 'coffee', 'ectoplasm', 'ocean', 'sunrise' ) ) ) {
273
- echo isset( $color->icon_colors['focus'] ) ? $color->icon_colors['focus'] : '';
274
- } else {
275
- echo isset( $color->colors[ 3 ] ) ? $color->colors[ 3 ] : '';
276
  }
 
 
277
  }
278
 
279
  public static function page_scripts() {
280
- wp_enqueue_script( 'jquery-masonry' );
281
  wp_enqueue_script( 'paypal', 'https://www.paypalobjects.com/js/external/dg.js' );
282
- wp_enqueue_script( 'wpsc-marketplace-js', plugins_url( 'static/admin.js', Sputnik::$path . '/wpsc-marketplace' ), array( 'jquery', 'jquery-masonry', 'thickbox', 'paypal' ), '20141109' );
283
 
284
  $l10n = array(
285
- 'plugin_information' => __( 'Plugin Information:', 'wpsc' ),
286
- 'ays' => __( 'Are you sure you want to install this plugin?', 'wpsc' )
287
  );
288
 
289
  if ( ! empty( $_REQUEST['oauth_buy'] ) ) {
290
- $plugin = Sputnik::get_plugin( $_REQUEST['oauth_buy'] );
291
- $status = self::install_status( $plugin );
292
- $l10n['buy_id'] = $plugin->slug;
293
  $l10n['buy_href'] = $status['url'];
294
  }
295
 
296
- wp_localize_script( 'wpsc-marketplace-js', 'sputnikL10n', $l10n );
297
  }
298
 
299
  public static function page() {
@@ -344,7 +308,7 @@ class Sputnik_Admin {
344
  }
345
  } catch (Exception $e) {
346
  status_header(500);
347
- iframe_header( __('Plugin Install', 'wpsc') );
348
  echo $e->getMessage();
349
  iframe_footer();
350
  die();
@@ -358,12 +322,12 @@ class Sputnik_Admin {
358
  'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
359
 
360
  $plugins_section_titles = array(
361
- 'description' => _x('Description', 'Plugin installer section title', 'wpsc'),
362
- 'installation' => _x('Installation', 'Plugin installer section title', 'wpsc'),
363
- 'faq' => _x('FAQ', 'Plugin installer section title', 'wpsc'),
364
- 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'wpsc'),
365
- 'changelog' => _x('Changelog', 'Plugin installer section title', 'wpsc'),
366
- 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'wpsc')
367
  );
368
 
369
  //Sanitize HTML
@@ -394,7 +358,7 @@ class Sputnik_Admin {
394
 
395
  global $body_id;
396
  $body_id = 'sputnik-plugin-information';
397
- iframe_header( __('Plugin Install', 'wpsc') );
398
  ?>
399
  <div class="alignleft fyi">
400
  <h1><?php echo $api->name ?></h1>
@@ -406,21 +370,21 @@ class Sputnik_Admin {
406
  case 'purchase':
407
  default:
408
  if ( $status['url'] )
409
- echo '<a href="' . $status['url'] . '" target="_parent" id="' . $plugin . '" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy &amp; Install', 'wpsc'), $api->price) . '</a>';
410
  break;
411
  case 'install':
412
  if ( $status['url'] )
413
- echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'wpsc') . '">' . __('Install Now', 'wpsc') . '</a>';
414
  break;
415
  case 'update_available':
416
  if ( $status['url'] )
417
- echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'wpsc') .'</a>';
418
  break;
419
  case 'newer_installed':
420
- echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'wpsc'), $status['version']) . '</a>';
421
  break;
422
  case 'latest_installed':
423
- echo '<a>' . __('Latest Version Installed', 'wpsc') . '</a>';
424
  break;
425
  }
426
  ?>
@@ -452,43 +416,43 @@ class Sputnik_Admin {
452
  echo "</ul>\n";
453
  echo "</div>\n";
454
  ?>
455
- <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI', 'wpsc') ?></h2>
456
  <ul>
457
  <?php if ( ! empty($api->version) ) : ?>
458
- <li><strong><?php _e('Version:', 'wpsc') ?></strong> <?php echo $api->version ?></li>
459
  <?php endif; if ( ! empty($api->author) ) : ?>
460
- <li><strong><?php _e('Author:', 'wpsc') ?></strong> <?php echo $api->author ?></li>
461
  <?php endif; if ( ! empty($api->last_updated) ) : ?>
462
- <li><strong><?php _e('Last Updated:', 'wpsc') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
463
- printf( __('%s ago', 'wpsc'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
464
  <?php endif; if ( ! empty($api->requires) ) : ?>
465
- <li><strong><?php _e('Requires WordPress Version:', 'wpsc') ?></strong> <?php printf(__('%s or higher', 'wpsc'), $api->requires) ?></li>
466
  <?php endif; if ( ! empty($api->tested) ) : ?>
467
- <li><strong><?php _e('Compatible up to:', 'wpsc') ?></strong> <?php echo $api->tested ?></li>
468
  <?php endif; if ( ! empty($api->requires_wpec) ) : ?>
469
- <li><strong><?php _e('Requires WPeC Version:', 'wpsc') ?></strong> <?php printf(__('%s or higher', 'wpsc'), $api->requires_wpec) ?></li>
470
  <?php endif; if ( ! empty($api->tested_wpec) ) : ?>
471
- <li><strong><?php _e('Compatible up to WPEC Version:', 'wpsc') ?></strong> <?php echo $api->tested_wpec ?></li>
472
  <?php endif; if ( ! empty($api->downloaded) ) : ?>
473
- <li><strong><?php _e('Downloaded:', 'wpsc') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded, 'wpsc'), number_format_i18n($api->downloaded)) ?></li>
474
  <?php endif; if ( ! empty($api->homepage) ) : ?>
475
- <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;', 'wpsc') ?></a></li>
476
  <?php endif; ?>
477
  </ul>
478
  </div>
479
  <div id="section-holder" class="wrap">
480
  <?php
481
  if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
482
- echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.', 'wpsc') . '</p></div>';
483
 
484
  else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
485
- echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.', 'wpsc') . '</p></div>';
486
 
487
  else if ( !empty($api->requires_wpec) && version_compare( substr( WPSC_VERSION, 0, strlen($api->requires_wpec)), $api->requires_wpec, '<') )
488
- echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WP eCommerce.', 'wpsc') . '</p></div>';
489
 
490
  else if ( !empty($api->tested_wpec) && version_compare( substr( WPSC_VERSION, 0, strlen($api->tested_wpec)), $api->tested_wpec, '<') )
491
- echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your version of WP eCommerce.', 'wpsc') . '</p></div>';
492
 
493
  foreach ( $api->sections as $section_name => $content ) {
494
  if ( isset( $plugins_section_titles[ $section_name ] ) )
@@ -614,8 +578,9 @@ class Sputnik_Admin {
614
  'oauth' => 'request',
615
  'oauth_buy' => $api->slug,
616
  'TB_iframe' => true,
617
- 'height' => 600,
618
- 'width' => 800
 
619
  ) );
620
 
621
  return compact('status', 'url', 'version');
@@ -624,8 +589,8 @@ class Sputnik_Admin {
624
  protected static function header( $account ) {
625
  if ($account !== false) {
626
  $tabs = array(
627
- 'dash' => __('Store', 'wpsc'),
628
- 'account' => __('Your Account', 'wpsc'),
629
  );
630
  $hrefs = array(
631
  'dash' => self::build_url(),
@@ -636,11 +601,27 @@ class Sputnik_Admin {
636
  }
637
  ?>
638
  <div class="wrap" id="sputnik-page">
639
- <h2><?php _e( 'Marketplace', 'wpsc' ); ?></h2>
 
 
640
  <?php
641
  do_action('sputnik_messages');
642
  }
643
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
  protected static function other_pages() {
645
  global $tab;
646
 
@@ -654,7 +635,7 @@ class Sputnik_Admin {
654
  delete_option('sputnik_oauth_request');
655
  }
656
  elseif ( $e->getCode() !== 1 ) {
657
- echo '<p>' . sprintf(__('Problem: %s', 'wpsc'), $e->getMessage() ). '</p>';
658
  }
659
  }
660
 
@@ -668,34 +649,35 @@ class Sputnik_Admin {
668
  <?php echo get_avatar($account->email) ?>
669
  <p class="lead-in">Logged in as</p>
670
  <h3><?php echo esc_html($account->name) ?></h3>
671
- <p><?php printf(__('<a href="%s">Log out</a> of your account', 'wpsc'), self::build_url(array('oauth' => 'reset'))) ?></p>
672
  </div>
673
  <div class="block">
674
  <p>Email: <code><?php echo $account->email ?></code></p>
675
  <?php if ( $tab != 'purchased' ): ?>
676
- <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'wpsc'), count( self::$list_table->items )) ?></p>
677
  <?php endif; ?>
678
- <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'wpsc'), count( $account->purchased ) ) ?></p>
679
  </div>
680
  </div>
681
  <?php
682
  }
683
  self::$list_table->views();
684
  self::$list_table->display();
 
685
  }
686
 
687
  /**
688
  * Output the main landing page for the Sputnik administration screen.
689
  */
690
  protected static function dashboard() { ?>
691
- <p><?php _e('Some text about WPEconomy goes here! This will eventually be replaced with a dashboard-like interface, including latest news, etc.', 'wpsc'); ?></p>
692
 
693
- <h4><?php _e('Search', 'wpsc') ?></h4>
694
- <p class="install-help"><?php _e('Search for plugins by keyword.', 'wpsc') ?></p>
695
  <?php Sputnik_Admin::search_form(); ?>
696
 
697
  <h4><?php _e('Popular tags') ?></h4>
698
- <p class="install-help"><?php _e('You may also browse based on the most popular tags on the store:', 'wpsc') ?></p>
699
  <?php
700
  echo '<p class="popular-tags">';
701
 
@@ -712,7 +694,7 @@ class Sputnik_Admin {
712
  'count' => $tag->count
713
  );
714
  }
715
- echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin', 'wpsc'), 'multiple_text' => __('%s plugins', 'wpsc') ) );
716
  }
717
  catch (Exception $e) {
718
  echo $e->getMessage();
@@ -740,7 +722,8 @@ class Sputnik_Admin {
740
  }
741
  else {
742
  self::header('Account', $account);
743
- echo '<p>' . sprintf(__('Problem: %s', 'wpsc'), $e->getMessage()) . '</p>';
 
744
 
745
  return;
746
  }
@@ -753,25 +736,26 @@ class Sputnik_Admin {
753
  <?php echo get_avatar($account->email) ?>
754
  <p class="lead-in">Logged in as</p>
755
  <h3><?php echo esc_html($account->name) ?></h3>
756
- <p><?php printf(__('<a href="%s">Log out</a> of your account', 'wpsc'), self::build_url(array('oauth' => 'reset'))) ?></p>
757
  </div>
758
  <div class="block">
759
  <p>Email: <code><?php echo $account->email ?></code></p>
760
- <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'wpsc'), count($account->purchased)) ?></p>
761
- <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'wpsc'), count(self::$list_table->items)) ?></p>
762
  </div>
763
  </div>
764
 
765
  <?php
766
  self::$list_table->views();
767
  self::$list_table->display();
 
768
  }
769
 
770
  protected static function auth() {
771
  $oauth_url = self::build_url(array('oauth' => 'request', 'TB_iframe' => true));
772
 
773
  if ( isset( $_GET['auth'] ) && $_GET['auth'] == 'denied' ) {
774
- self::print_message( __( 'Authorization cancelled.', 'wpsc' ) );
775
  }
776
  }
777
 
@@ -815,7 +799,7 @@ class Sputnik_Admin {
815
  $install_url = add_query_arg('_wpnonce', wp_create_nonce('sputnik_install-plugin_' . $product_slug), $install_url);
816
  $install_url = add_query_arg(array('TB_iframe' => true), $install_url);
817
 
818
- self::iframe_closer( self::build_url( array('run-installer' => urlencode( $install_url ) ) ), __( 'Installing ... ', 'wpsc' ) );
819
  }
820
 
821
  /**
@@ -828,19 +812,19 @@ class Sputnik_Admin {
828
 
829
  $cancelled_url = self::build_url( array( 'payment_cancelled' => true ) );
830
 
831
- self::iframe_closer( $cancelled_url, __( 'Payment Cancelled', 'wpsc' ) );
832
  }
833
 
834
  protected static function install($id) {
835
 
836
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
837
 
838
  try {
839
  $api = Sputnik::get_plugin($id);
840
  }
841
  catch (Exception $e) {
842
  status_header(500);
843
- iframe_header( __('Plugin Install', 'wpsc') );
844
  echo $e->getMessage();
845
  iframe_footer();
846
  die();
@@ -852,7 +836,7 @@ class Sputnik_Admin {
852
  }
853
 
854
  if ( ! current_user_can('install_plugins') )
855
- wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'wpsc'));
856
 
857
  include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
858
 
@@ -860,42 +844,44 @@ class Sputnik_Admin {
860
 
861
  global $body_id;
862
  $body_id = 'sputnik-install';
863
- iframe_header( __('Plugin Install', 'wpsc') );
864
 
865
- $title = sprintf( __('Installing Plugin: %s', 'wpsc'), $api->name . ' ' . $api->version );
866
  $nonce = 'sputnik_install-plugin_' . $id;
867
  $url = 'update.php?action=install-plugin&plugin=' . $id;
868
  if ( isset($_GET['from']) )
869
  $url .= '&from=' . urlencode(stripslashes($_GET['from']));
870
 
871
- $type = 'web'; //Install plugin type, From Web or an Upload.
 
 
 
872
 
873
- if ( in_array( 'theme', $api->categories ) ) {
874
  $upgrader = new Sputnik_ThemeUpgrader( new Sputnik_Upgrader_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
875
- } else {
876
  $upgrader = new Sputnik_Upgrader( new Sputnik_Upgrader_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
877
- }
878
 
879
- $upgrader->install( $api->download_link );
880
 
881
  iframe_footer();
882
  die();
883
  }
884
 
885
  protected static function upgrade($file) {
886
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
887
 
888
  try {
889
  $data = Sputnik::get_from_file($file);
890
  if ($data === null) {
891
- throw new Exception(__('Plugin not found', 'wpsc'));
892
  }
893
  $id = $data['Sputnik ID'];
894
  $api = Sputnik::get_plugin($id);
895
  }
896
  catch (Exception $e) {
897
  status_header(500);
898
- iframe_header( __('Update Plugin', 'wpsc') );
899
  echo $e->getMessage();
900
  iframe_footer();
901
  die();
@@ -907,7 +893,7 @@ class Sputnik_Admin {
907
  }
908
 
909
  if ( ! current_user_can('install_plugins') )
910
- wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'wpsc'));
911
 
912
  include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
913
 
@@ -915,9 +901,9 @@ class Sputnik_Admin {
915
 
916
  global $body_id;
917
  $body_id = 'sputnik-upgrade';
918
- iframe_header( __('Update Plugin', 'wpsc') );
919
 
920
- $title = sprintf( __('Updating Plugin: %s', 'wpsc'), $api->name . ' ' . $api->version );
921
  $nonce = 'sputnik_upgrade-plugin_' . $id;
922
  $url = 'update.php?action=upgrade-plugin&plugin=' . $id;
923
  if ( isset($_GET['from']) )
@@ -959,7 +945,7 @@ class Sputnik_Admin {
959
  */
960
  public static function iframe_closer( $redirect_url, $title = null ) {
961
  if (empty($title)) {
962
- $title = __('Redirecting...', 'wpsc');
963
  }
964
  ?>
965
  <!DOCTYPE html><html>
@@ -986,7 +972,7 @@ class Sputnik_Admin {
986
 
987
  $url = self::build_url(array('upgrade' => $file));
988
  // wp_nonce_url also does a esc_html, so do it ourselves
989
- $url = add_query_arg('_wpnonce', wp_create_nonce('sputnik_upgrade-plugin_' . $file), $url);
990
  wp_redirect($url);
991
 
992
  die();
21
  }
22
 
23
  public static function init() {
 
 
 
 
 
24
  add_action('admin_print_styles', array(__CLASS__, 'styles'));
25
  add_action('admin_print_scripts', array(__CLASS__, 'scripts'));
26
 
35
  $redirect_url = '';
36
  if ( ! empty( $_REQUEST['oauth_buy'] ) ) {
37
  $redirect_url = self::build_url( array( 'oauth' => 'callback' ) );
38
+ $redirect_url = esc_url_raw( add_query_arg( 'oauth_buy', $_REQUEST['oauth_buy'], $redirect_url ) );
39
  }
40
  Sputnik_API::auth_request( $redirect_url );
41
  }
90
  return;
91
  }
92
  ?>
93
+ <div class="error"><p><?php _e('The following plugins are disabled:', 'sputnik') ?></p>
94
  <ul>
95
  <?php
96
  foreach ($invalid as $plugin) {
99
  }
100
  switch ($plugin['sputnik_error']) {
101
  case 'not_purchased':
102
+ $error = __('Not purchased', 'sputnik');
103
  break;
104
  default:
105
+ $error = __('Unknown error', 'sputnik');
106
  break;
107
  }
108
  ?>
122
  if (empty($data['Sputnik ID'])) {
123
  return $meta;
124
  }
125
+ echo '<a class="sputnik-plugin-row-note" href="' . self::build_url() . '"><span class="powered">' . __('Powered by WPEConomy', 'sputnik') . '</span><span class="corner"></span></a>';
126
  return $meta;
127
  }
128
 
129
  public static function admin_head_page() {
 
 
 
 
 
 
 
130
  if (self::$page === 'dash') {
131
  self::$list_table = new Sputnik_List_Install();
132
  $pagenum = self::$list_table->get_pagenum();
141
  add_action('sputnik_messages', array(__CLASS__, 'admin_notices'));
142
  }
143
 
 
 
 
 
144
  public static function load_page() {
145
  //Sputnik_API::auth_or_redirect();
146
  }
147
 
148
  public static function styles() {
149
+ wp_enqueue_style('sputnik', plugins_url( 'static/sputnik.css', Sputnik::$path . '/wpsc-marketplace' ), false, '20110924');
 
 
 
 
 
 
 
 
150
  }
151
 
152
  public static function scripts() {
153
+ wp_enqueue_script('sputnik_js', plugins_url( 'static/sputnik.js', Sputnik::$path . '/wpsc-marketplace' ), array('jquery', 'common'), '20110924' );
154
  }
155
 
156
  public static function connect_notice() {
169
  <?php _e( '<strong>WPEConomy is now installed!</strong> &#8211; Get started by linking with your account!', 'wpsc' ); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
170
  <?php _e( "If you haven't created an account yet, don't worry, you will be prompted to do so.", 'wpsc') ?>
171
  </p>
172
+ <a href="<?php echo esc_html( $oauth_url ); ?>" class="thickbox button button-primary thickbox`"><?php _e( 'Link your account now', 'sputnik' ); ?></a>
173
  </div>
174
  <?php
175
  }
176
 
177
  public static function admin_notices() {
178
  if ( isset( $_GET['payment_cancelled'] ) ) {
179
+ self::print_message( __( 'Payment cancelled.', 'sputnik' ) );
180
  }
181
  }
182
 
203
  }
204
 
205
  public static function menu() {
206
+ $hooks[] = add_submenu_page( 'edit.php?post_type=wpsc-product', _x('Add-Ons', 'page title', 'sputnik'), _x('Add-Ons', 'menu title', 'sputnik'), 'install_plugins', 'sputnik', array(__CLASS__, 'page') );
207
  $hooks[] = 'plugin-install.php';
208
+ foreach ($hooks as $hook) {
209
+ add_action("admin_print_styles-$hook", array(__CLASS__, 'page_styles'));
210
+ add_action("admin_print_scripts-$hook", array(__CLASS__, 'page_scripts'));
 
211
  }
212
  }
213
 
217
  if (!empty($args)) {
218
  $url = add_query_arg( $args, $url );
219
  }
220
+ return esc_url_raw( $url );
221
  }
222
 
223
  public static function build_account_url($args = array()) {
225
  if (!empty($args)) {
226
  $url = add_query_arg( $args, $url );
227
  }
228
+ return esc_url_raw( $url );
229
  }
230
 
231
  public static function page_styles() {
232
  self::$page_is_current = true;
233
+ wp_enqueue_style('sputnik-page', plugins_url( 'static/admin.css', Sputnik::$path . '/wpsc-marketplace' ), array('thickbox'), '20110924');
234
+ ?>
235
+ <style type-"text/css">
236
+ #sputnik-page .icon32 {
237
+ background: url(<?php echo WPSC_CORE_IMAGES_URL; ?>/icon32.png) no-repeat left center;
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
239
+ </style>
240
+ <?php
241
  }
242
 
243
  public static function page_scripts() {
244
+ wp_enqueue_script('jquery-masonry', plugins_url( 'static/jquery.masonry.js', Sputnik::$path . '/wpsc-marketplace' ), array('jquery'), '20110901' );
245
  wp_enqueue_script( 'paypal', 'https://www.paypalobjects.com/js/external/dg.js' );
246
+ wp_enqueue_script('sputnik_js', plugins_url( 'static/admin.js', Sputnik::$path . '/wpsc-marketplace' ), array( 'jquery', 'jquery-masonry', 'thickbox', 'paypal' ), '20110924' );
247
 
248
  $l10n = array(
249
+ 'plugin_information' => __('Plugin Information:', 'sputnik'),
250
+ 'ays' => __('Are you sure you want to install this plugin?', 'sputnik')
251
  );
252
 
253
  if ( ! empty( $_REQUEST['oauth_buy'] ) ) {
254
+ $plugin = Sputnik::get_plugin( $_REQUEST['oauth_buy'] );
255
+ $status = self::install_status( $plugin );
256
+ $l10n['buy_id'] = $plugin->slug;
257
  $l10n['buy_href'] = $status['url'];
258
  }
259
 
260
+ wp_localize_script('sputnik_js', 'sputnikL10n', $l10n );
261
  }
262
 
263
  public static function page() {
308
  }
309
  } catch (Exception $e) {
310
  status_header(500);
311
+ iframe_header( __('Plugin Install', 'sputnik') );
312
  echo $e->getMessage();
313
  iframe_footer();
314
  die();
322
  'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
323
 
324
  $plugins_section_titles = array(
325
+ 'description' => _x('Description', 'Plugin installer section title', 'sputnik'),
326
+ 'installation' => _x('Installation', 'Plugin installer section title', 'sputnik'),
327
+ 'faq' => _x('FAQ', 'Plugin installer section title', 'sputnik'),
328
+ 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'sputnik'),
329
+ 'changelog' => _x('Changelog', 'Plugin installer section title', 'sputnik'),
330
+ 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'sputnik')
331
  );
332
 
333
  //Sanitize HTML
358
 
359
  global $body_id;
360
  $body_id = 'sputnik-plugin-information';
361
+ iframe_header( __('Plugin Install', 'sputnik') );
362
  ?>
363
  <div class="alignleft fyi">
364
  <h1><?php echo $api->name ?></h1>
370
  case 'purchase':
371
  default:
372
  if ( $status['url'] )
373
+ echo '<a href="' . $status['url'] . '" target="_parent" id="' . $plugin . '" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy &amp; Install', 'sputnik'), $api->price) . '</a>';
374
  break;
375
  case 'install':
376
  if ( $status['url'] )
377
+ echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'sputnik') . '">' . __('Install Now', 'sputnik') . '</a>';
378
  break;
379
  case 'update_available':
380
  if ( $status['url'] )
381
+ echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'sputnik') .'</a>';
382
  break;
383
  case 'newer_installed':
384
+ echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'sputnik'), $status['version']) . '</a>';
385
  break;
386
  case 'latest_installed':
387
+ echo '<a>' . __('Latest Version Installed', 'sputnik') . '</a>';
388
  break;
389
  }
390
  ?>
416
  echo "</ul>\n";
417
  echo "</div>\n";
418
  ?>
419
+ <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI', 'sputnik') ?></h2>
420
  <ul>
421
  <?php if ( ! empty($api->version) ) : ?>
422
+ <li><strong><?php _e('Version:', 'sputnik') ?></strong> <?php echo $api->version ?></li>
423
  <?php endif; if ( ! empty($api->author) ) : ?>
424
+ <li><strong><?php _e('Author:', 'sputnik') ?></strong> <?php echo $api->author ?></li>
425
  <?php endif; if ( ! empty($api->last_updated) ) : ?>
426
+ <li><strong><?php _e('Last Updated:', 'sputnik') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
427
+ printf( __('%s ago', 'sputnik'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
428
  <?php endif; if ( ! empty($api->requires) ) : ?>
429
+ <li><strong><?php _e('Requires WordPress Version:', 'sputnik') ?></strong> <?php printf(__('%s or higher', 'sputnik'), $api->requires) ?></li>
430
  <?php endif; if ( ! empty($api->tested) ) : ?>
431
+ <li><strong><?php _e('Compatible up to:', 'sputnik') ?></strong> <?php echo $api->tested ?></li>
432
  <?php endif; if ( ! empty($api->requires_wpec) ) : ?>
433
+ <li><strong><?php _e('Requires WPeC Version:', 'sputnik') ?></strong> <?php printf(__('%s or higher', 'sputnik'), $api->requires_wpec) ?></li>
434
  <?php endif; if ( ! empty($api->tested_wpec) ) : ?>
435
+ <li><strong><?php _e('Compatible up to WPEC Version:', 'sputnik') ?></strong> <?php echo $api->tested_wpec ?></li>
436
  <?php endif; if ( ! empty($api->downloaded) ) : ?>
437
+ <li><strong><?php _e('Downloaded:', 'sputnik') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded, 'sputnik'), number_format_i18n($api->downloaded)) ?></li>
438
  <?php endif; if ( ! empty($api->homepage) ) : ?>
439
+ <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;', 'sputnik') ?></a></li>
440
  <?php endif; ?>
441
  </ul>
442
  </div>
443
  <div id="section-holder" class="wrap">
444
  <?php
445
  if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
446
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.', 'sputnik') . '</p></div>';
447
 
448
  else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
449
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.', 'sputnik') . '</p></div>';
450
 
451
  else if ( !empty($api->requires_wpec) && version_compare( substr( WPSC_VERSION, 0, strlen($api->requires_wpec)), $api->requires_wpec, '<') )
452
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WP E-Commerce.', 'sputnik') . '</p></div>';
453
 
454
  else if ( !empty($api->tested_wpec) && version_compare( substr( WPSC_VERSION, 0, strlen($api->tested_wpec)), $api->tested_wpec, '<') )
455
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your version of WP E-Commerce.', 'sputnik') . '</p></div>';
456
 
457
  foreach ( $api->sections as $section_name => $content ) {
458
  if ( isset( $plugins_section_titles[ $section_name ] ) )
578
  'oauth' => 'request',
579
  'oauth_buy' => $api->slug,
580
  'TB_iframe' => true,
581
+ 'height' => 550,
582
+ 'width' => 640,
583
+ 'modal' => 'true'
584
  ) );
585
 
586
  return compact('status', 'url', 'version');
589
  protected static function header( $account ) {
590
  if ($account !== false) {
591
  $tabs = array(
592
+ 'dash' => __('Store', 'sputnik'),
593
+ 'account' => __('Your Account', 'sputnik'),
594
  );
595
  $hrefs = array(
596
  'dash' => self::build_url(),
601
  }
602
  ?>
603
  <div class="wrap" id="sputnik-page">
604
+ <?php screen_icon(); ?>
605
+ <h2>Marketplace <?php self::account_link(); ?>
606
+ </h2>
607
  <?php
608
  do_action('sputnik_messages');
609
  }
610
 
611
+ protected static function footer() {?>
612
+ <div id="sputnik-footer">
613
+ <p class="logo-holder"><a href="http://wpeconomy.org/" class="renku-logo-no-img">Marketplace Powered by WPEconomy</a></p>
614
+ <nav><p><a href="http://www.wpeconomy.org/documentation/developers/">Developer Tools</a> | <a href="http://twitter.com/WPEconomy">@WPEconomy</a> | <a href="http://www.wpeconomy.org/documentation/marketplace/faqs/">FAQ</a></p></nav>
615
+ </div>
616
+ </div>
617
+ <?php
618
+ }
619
+
620
+ protected static function account_link() {
621
+ if ( Sputnik::account_is_linked() && 'dash' == self::$page )
622
+ echo '<a href="edit.php?post_type=wpsc-product&amp;page=sputnik-account" class="add-new-h2">Your Account</a>';
623
+ }
624
+
625
  protected static function other_pages() {
626
  global $tab;
627
 
635
  delete_option('sputnik_oauth_request');
636
  }
637
  elseif ( $e->getCode() !== 1 ) {
638
+ echo '<p>' . sprintf(__('Problem: %s', 'sputnik'), $e->getMessage() ). '</p>';
639
  }
640
  }
641
 
649
  <?php echo get_avatar($account->email) ?>
650
  <p class="lead-in">Logged in as</p>
651
  <h3><?php echo esc_html($account->name) ?></h3>
652
+ <p><?php printf(__('<a href="%s">Log out</a> of your account', 'sputnik'), self::build_url(array('oauth' => 'reset'))) ?></p>
653
  </div>
654
  <div class="block">
655
  <p>Email: <code><?php echo $account->email ?></code></p>
656
  <?php if ( $tab != 'purchased' ): ?>
657
+ <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'sputnik'), count( self::$list_table->items )) ?></p>
658
  <?php endif; ?>
659
+ <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'sputnik'), count( $account->purchased ) ) ?></p>
660
  </div>
661
  </div>
662
  <?php
663
  }
664
  self::$list_table->views();
665
  self::$list_table->display();
666
+ self::footer();
667
  }
668
 
669
  /**
670
  * Output the main landing page for the Sputnik administration screen.
671
  */
672
  protected static function dashboard() { ?>
673
+ <p><?php _e('Some text about WPEconomy goes here! This will eventually be replaced with a dashboard-like interface, including latest news, etc.', 'sputnik'); ?></p>
674
 
675
+ <h4><?php _e('Search', 'sputnik') ?></h4>
676
+ <p class="install-help"><?php _e('Search for plugins by keyword.', 'sputnik') ?></p>
677
  <?php Sputnik_Admin::search_form(); ?>
678
 
679
  <h4><?php _e('Popular tags') ?></h4>
680
+ <p class="install-help"><?php _e('You may also browse based on the most popular tags on the store:', 'sputnik') ?></p>
681
  <?php
682
  echo '<p class="popular-tags">';
683
 
694
  'count' => $tag->count
695
  );
696
  }
697
+ echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin', 'sputnik'), 'multiple_text' => __('%s plugins', 'sputnik') ) );
698
  }
699
  catch (Exception $e) {
700
  echo $e->getMessage();
722
  }
723
  else {
724
  self::header('Account', $account);
725
+ echo '<p>' . sprintf(__('Problem: %s', 'sputnik'), $e->getMessage()) . '</p>';
726
+ self::footer();
727
 
728
  return;
729
  }
736
  <?php echo get_avatar($account->email) ?>
737
  <p class="lead-in">Logged in as</p>
738
  <h3><?php echo esc_html($account->name) ?></h3>
739
+ <p><?php printf(__('<a href="%s">Log out</a> of your account', 'sputnik'), self::build_url(array('oauth' => 'reset'))) ?></p>
740
  </div>
741
  <div class="block">
742
  <p>Email: <code><?php echo $account->email ?></code></p>
743
+ <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'sputnik'), count($account->purchased)) ?></p>
744
+ <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'sputnik'), count(self::$list_table->items)) ?></p>
745
  </div>
746
  </div>
747
 
748
  <?php
749
  self::$list_table->views();
750
  self::$list_table->display();
751
+ self::footer();
752
  }
753
 
754
  protected static function auth() {
755
  $oauth_url = self::build_url(array('oauth' => 'request', 'TB_iframe' => true));
756
 
757
  if ( isset( $_GET['auth'] ) && $_GET['auth'] == 'denied' ) {
758
+ self::print_message( __( 'Authorization cancelled.', 'sputnik' ) );
759
  }
760
  }
761
 
799
  $install_url = add_query_arg('_wpnonce', wp_create_nonce('sputnik_install-plugin_' . $product_slug), $install_url);
800
  $install_url = add_query_arg(array('TB_iframe' => true), $install_url);
801
 
802
+ self::iframe_closer( self::build_url(array('run-installer' => urlencode($install_url))), __( 'Installing ... ', 'sputnik' ) );
803
  }
804
 
805
  /**
812
 
813
  $cancelled_url = self::build_url( array( 'payment_cancelled' => true ) );
814
 
815
+ self::iframe_closer( $cancelled_url, __( 'Payment Cancelled', 'sputnik' ) );
816
  }
817
 
818
  protected static function install($id) {
819
 
820
+ include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
821
 
822
  try {
823
  $api = Sputnik::get_plugin($id);
824
  }
825
  catch (Exception $e) {
826
  status_header(500);
827
+ iframe_header( __('Plugin Install', 'sputnik') );
828
  echo $e->getMessage();
829
  iframe_footer();
830
  die();
836
  }
837
 
838
  if ( ! current_user_can('install_plugins') )
839
+ wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik'));
840
 
841
  include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
842
 
844
 
845
  global $body_id;
846
  $body_id = 'sputnik-install';
847
+ iframe_header( __('Plugin Install', 'sputnik') );
848
 
849
+ $title = sprintf( __('Installing Plugin: %s', 'sputnik'), $api->name . ' ' . $api->version );
850
  $nonce = 'sputnik_install-plugin_' . $id;
851
  $url = 'update.php?action=install-plugin&plugin=' . $id;
852
  if ( isset($_GET['from']) )
853
  $url .= '&from=' . urlencode(stripslashes($_GET['from']));
854
 
855
+ $type = 'web'; //Install plugin type, From Web or an Upload.erro
856
+
857
+ ini_set( 'display_errors', '1' );
858
+ error_reporting( E_ALL );
859
 
860
+ if ( in_array( 'theme', $api->categories ) )
861
  $upgrader = new Sputnik_ThemeUpgrader( new Sputnik_Upgrader_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
862
+ else
863
  $upgrader = new Sputnik_Upgrader( new Sputnik_Upgrader_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
 
864
 
865
+ $upgrader->install($api->download_link);
866
 
867
  iframe_footer();
868
  die();
869
  }
870
 
871
  protected static function upgrade($file) {
872
+ include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
873
 
874
  try {
875
  $data = Sputnik::get_from_file($file);
876
  if ($data === null) {
877
+ throw new Exception(__('Plugin not found', 'sputnik'));
878
  }
879
  $id = $data['Sputnik ID'];
880
  $api = Sputnik::get_plugin($id);
881
  }
882
  catch (Exception $e) {
883
  status_header(500);
884
+ iframe_header( __('Update Plugin', 'sputnik') );
885
  echo $e->getMessage();
886
  iframe_footer();
887
  die();
893
  }
894
 
895
  if ( ! current_user_can('install_plugins') )
896
+ wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik'));
897
 
898
  include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
899
 
901
 
902
  global $body_id;
903
  $body_id = 'sputnik-upgrade';
904
+ iframe_header( __('Update Plugin', 'sputnik') );
905
 
906
+ $title = sprintf( __('Updating Plugin: %s', 'sputnik'), $api->name . ' ' . $api->version );
907
  $nonce = 'sputnik_upgrade-plugin_' . $id;
908
  $url = 'update.php?action=upgrade-plugin&plugin=' . $id;
909
  if ( isset($_GET['from']) )
945
  */
946
  public static function iframe_closer( $redirect_url, $title = null ) {
947
  if (empty($title)) {
948
+ $title = __('Redirecting...', 'sputnik');
949
  }
950
  ?>
951
  <!DOCTYPE html><html>
972
 
973
  $url = self::build_url(array('upgrade' => $file));
974
  // wp_nonce_url also does a esc_html, so do it ourselves
975
+ $url = esc_url_raw( add_query_arg('_wpnonce', wp_create_nonce('sputnik_upgrade-plugin_' . $file), $url) );
976
  wp_redirect($url);
977
 
978
  die();
wpsc-components/marketplace-core-v1/library/Sputnik/List/Install.php CHANGED
@@ -55,7 +55,7 @@ class Sputnik_List_Install extends WP_List_Table {
55
 
56
  case 'search':
57
  $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
58
- $api = Sputnik_API::search( urlencode( $term ), array( 'browse' => $tab ), $paged );
59
  break;
60
 
61
  case 'account':
@@ -106,7 +106,7 @@ class Sputnik_List_Install extends WP_List_Table {
106
 
107
  echo '<p>';
108
  if ( $tab == 'purchased' )
109
- printf( __( "You haven't purchased any extensions yet. <a href='%s'>Browse our extensions marketplace.</a>", 'wpsc' ), Sputnik_Admin::build_url() );
110
  else
111
  _e( 'No plugins match your request.', 'wpsc' );
112
  echo '</p>';
@@ -151,6 +151,7 @@ class Sputnik_List_Install extends WP_List_Table {
151
  }
152
 
153
  public function display_grid() {
 
154
 
155
  $this->display_tablenav( 'top' );
156
  ?>
@@ -245,14 +246,10 @@ class Sputnik_List_Install extends WP_List_Table {
245
 
246
  foreach ( (array) $this->items as $plugin ) {
247
  $plugin->title = wp_kses( $plugin->name, $plugins_allowedtags );
248
-
249
- //Limit description to 400char, and sanitize.
250
- $plugin->description = wp_kses( $plugin->description, $plugins_allowedtags );
251
-
252
- if ( strlen( $plugin->description ) > 400 ) {
253
  $plugin->description = mb_substr( $plugin->description, 0, 400 ) . '&#8230;';
254
- }
255
-
256
  //remove any trailing entities
257
  $plugin->description = preg_replace( '/&[^;\s]{0,6}$/', '', $plugin->description );
258
  //strip leading/trailing & multiple consecutive lines
@@ -263,16 +260,16 @@ class Sputnik_List_Install extends WP_List_Table {
263
  $plugin->version = wp_kses( $plugin->version, $plugins_allowedtags );
264
  $plugin->price = sprintf('$%.2f', $plugin->price);
265
  if ($plugin->price === '$0.00') {
266
- $plugin->price = _x( 'Free', 'plugin price', 'wpsc' );
267
  }
268
 
269
- if ( ! empty( $plugin->author ) ) {
 
270
  $plugin->author = ' <cite>' . sprintf( __( 'By %s', 'wpsc' ), $plugin->author ) . '.</cite>';
271
- }
272
 
273
  $plugin->author = wp_kses( $plugin->author, $plugins_allowedtags );
274
 
275
- switch ( $this->view ) {
276
  case 'list':
277
  self::display_row($plugin, $style);
278
  break;
@@ -304,8 +301,8 @@ class Sputnik_List_Install extends WP_List_Table {
304
  break;
305
  case 'install':
306
  if ( $status['url'] ) {
307
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']);
308
- $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
309
  . esc_attr(sprintf(__( 'Install %s', 'wpsc' ), $name)) . '">' . __('Install', 'wpsc' ) . '</a>';
310
  }
311
  else {
@@ -315,8 +312,8 @@ class Sputnik_List_Install extends WP_List_Table {
315
  break;
316
  case 'update_available':
317
  if ( $status['url'] ) {
318
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']);
319
- $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
320
  . esc_attr(sprintf(__( 'Update to version %s', 'wpsc' ), $status['version'])) . '">' . __('Update', 'wpsc' ) . '</a>';
321
  }
322
  else {
@@ -364,7 +361,7 @@ class Sputnik_List_Install extends WP_List_Table {
364
 
365
  protected static function display_as_grid($plugin, $style) {
366
 
367
- $name = strip_tags( $plugin->name );
368
  $action_links = array();
369
  $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
370
  . '" class="thickbox button info" title="' .
@@ -384,7 +381,7 @@ class Sputnik_List_Install extends WP_List_Table {
384
  break;
385
  case 'install':
386
  if ( $status['url'] ) {
387
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']);
388
  $purchase_link = '<a class="button install status" href="' . $status['url'] . '" title="'
389
  . esc_attr(sprintf(__( 'Install %s', 'wpsc' ), $name)) . '">' . __('Install', 'wpsc' ) . '</a>';
390
  }
@@ -395,7 +392,7 @@ class Sputnik_List_Install extends WP_List_Table {
395
  break;
396
  case 'update_available':
397
  if ( $status['url'] ) {
398
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']);
399
  $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
400
  . esc_attr(sprintf(__( 'Update to version %s', 'wpsc' ), $status['version'])) . '">' . __('Update', 'wpsc' ) . '</a>';
401
  }
@@ -414,30 +411,28 @@ class Sputnik_List_Install extends WP_List_Table {
414
 
415
  $action_links = apply_filters( 'sputnik_install_grid_action_links', $action_links, $plugin );
416
 
417
- $thumb = '';
418
-
419
- if ( ! empty( $plugin->thumb ) ) {
 
420
  $thumb = $plugin->thumb;
421
- }
422
-
423
- $thumb = apply_filters( 'wpsc_marketplace_plugin_thumbnail_img_src', $thumb, $plugin );
424
  ?>
425
  <div>
426
  <div class="sputnik-plugin<?php if ( ! empty( $plugin->thumb ) ) echo ' has-thumb'; ?>">
427
  <div class="sputnik-card">
428
- <h4><?php echo $name ?><span class="price"><?php echo $plugin->price ?></span></h4>
429
-
430
- <?php
431
- if ( ! empty( $thumb ) ) :
432
- ?>
433
  <div class="sputnik-plugin-thumb">
434
- <img src="<?php echo esc_url( $thumb ) ?>" alt="<?php echo esc_attr( $name ) ?> Thumbnail">
435
  </div>
436
- <?php
437
- endif;
438
- ?>
439
  <div class="sputnik-plugin-details">
440
- <p><?php echo $plugin->description; ?></p>
 
 
441
  <?php if ( isset( $plugin->rating ) && isset( $plugin->rating->count ) ): ?>
442
  <div class="footer" style="display:none">
443
  <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wpsc' ), number_format_i18n( $plugin->rating->count ) ) ?>">
@@ -459,12 +454,12 @@ class Sputnik_List_Install extends WP_List_Table {
459
  <?php endif; ?>
460
  </div>
461
  </div>
462
- <div class="sputnik-plugin-actions">
463
- <?php if ( !empty( $action_links ) ) echo implode( ' ', $action_links ); ?>
464
- <?php echo $purchase_link; ?>
465
- </div>
466
  </div>
467
  </div>
468
  <?php
469
  }
470
- }
55
 
56
  case 'search':
57
  $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
58
+ $api = Sputnik_API::search($term);
59
  break;
60
 
61
  case 'account':
106
 
107
  echo '<p>';
108
  if ( $tab == 'purchased' )
109
+ printf( __( "You haven't purchased any add-ons yet. <a href='%s'>Browse our add-on collection.</a>", 'wpsc' ), Sputnik_Admin::build_url() );
110
  else
111
  _e( 'No plugins match your request.', 'wpsc' );
112
  echo '</p>';
151
  }
152
 
153
  public function display_grid() {
154
+ extract( $this->_args );
155
 
156
  $this->display_tablenav( 'top' );
157
  ?>
246
 
247
  foreach ( (array) $this->items as $plugin ) {
248
  $plugin->title = wp_kses( $plugin->name, $plugins_allowedtags );
249
+ //Limit description to 400char, and remove any HTML.
250
+ $plugin->description = strip_tags( $plugin->description );
251
+ if ( strlen( $plugin->description ) > 400 )
 
 
252
  $plugin->description = mb_substr( $plugin->description, 0, 400 ) . '&#8230;';
 
 
253
  //remove any trailing entities
254
  $plugin->description = preg_replace( '/&[^;\s]{0,6}$/', '', $plugin->description );
255
  //strip leading/trailing & multiple consecutive lines
260
  $plugin->version = wp_kses( $plugin->version, $plugins_allowedtags );
261
  $plugin->price = sprintf('$%.2f', $plugin->price);
262
  if ($plugin->price === '$0.00') {
263
+ $plugin->price = _x('Free', 'plugin price', 'wpsc' );
264
  }
265
 
266
+ $plugin->author = $plugin->author;
267
+ if (!empty($plugin->author))
268
  $plugin->author = ' <cite>' . sprintf( __( 'By %s', 'wpsc' ), $plugin->author ) . '.</cite>';
 
269
 
270
  $plugin->author = wp_kses( $plugin->author, $plugins_allowedtags );
271
 
272
+ switch ($this->view) {
273
  case 'list':
274
  self::display_row($plugin, $style);
275
  break;
301
  break;
302
  case 'install':
303
  if ( $status['url'] ) {
304
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']);
305
+ $purchase_link = '<a class="button install" href="' . esc_url( $status['url'] ) . '" title="'
306
  . esc_attr(sprintf(__( 'Install %s', 'wpsc' ), $name)) . '">' . __('Install', 'wpsc' ) . '</a>';
307
  }
308
  else {
312
  break;
313
  case 'update_available':
314
  if ( $status['url'] ) {
315
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']);
316
+ $purchase_link = '<a class="button install" href="' . esc_url( $status['url'] ) . '" title="'
317
  . esc_attr(sprintf(__( 'Update to version %s', 'wpsc' ), $status['version'])) . '">' . __('Update', 'wpsc' ) . '</a>';
318
  }
319
  else {
361
 
362
  protected static function display_as_grid($plugin, $style) {
363
 
364
+ $name = strip_tags( $plugin->name . ' ' . $plugin->version );
365
  $action_links = array();
366
  $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
367
  . '" class="thickbox button info" title="' .
381
  break;
382
  case 'install':
383
  if ( $status['url'] ) {
384
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']);
385
  $purchase_link = '<a class="button install status" href="' . $status['url'] . '" title="'
386
  . esc_attr(sprintf(__( 'Install %s', 'wpsc' ), $name)) . '">' . __('Install', 'wpsc' ) . '</a>';
387
  }
392
  break;
393
  case 'update_available':
394
  if ( $status['url'] ) {
395
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']);
396
  $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
397
  . esc_attr(sprintf(__( 'Update to version %s', 'wpsc' ), $status['version'])) . '">' . __('Update', 'wpsc' ) . '</a>';
398
  }
411
 
412
  $action_links = apply_filters( 'sputnik_install_grid_action_links', $action_links, $plugin );
413
 
414
+ $thumb = false;
415
+ if ( empty( $plugin->thumb ) )
416
+ $thumb = WPSC_CORE_THEME_URL . '/wpsc-images/noimage.png';
417
+ else
418
  $thumb = $plugin->thumb;
 
 
 
419
  ?>
420
  <div>
421
  <div class="sputnik-plugin<?php if ( ! empty( $plugin->thumb ) ) echo ' has-thumb'; ?>">
422
  <div class="sputnik-card">
423
+ <?php
424
+ if ( $thumb !== false ):
425
+ ?>
 
 
426
  <div class="sputnik-plugin-thumb">
427
+ <img src="<?php echo esc_url($thumb) ?>" alt="<?php echo esc_attr($name) ?> Thumbnail">
428
  </div>
429
+ <?php
430
+ endif;
431
+ ?>
432
  <div class="sputnik-plugin-details">
433
+ <h4><?php echo $name ?></h4>
434
+ <span class="price"><?php echo $plugin->price ?></span>
435
+ <p><?php echo $plugin->description ?></p>
436
  <?php if ( isset( $plugin->rating ) && isset( $plugin->rating->count ) ): ?>
437
  <div class="footer" style="display:none">
438
  <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wpsc' ), number_format_i18n( $plugin->rating->count ) ) ?>">
454
  <?php endif; ?>
455
  </div>
456
  </div>
457
+ </div>
458
+ <div class="sputnik-plugin-actions">
459
+ <?php if ( !empty( $action_links ) ) echo implode( ' ', $action_links ); ?>
460
+ <?php echo $purchase_link; ?>
461
  </div>
462
  </div>
463
  <?php
464
  }
465
+ }
wpsc-components/marketplace-core-v1/library/Sputnik/Pointers.php CHANGED
@@ -12,10 +12,10 @@ class Sputnik_Pointers {
12
 
13
  $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
14
 
15
- if ( ! in_array( 'wpsc_marketplace_pointer', $dismissed ) && current_user_can( 'install_plugins' ) ) {
16
- $enqueue = true;
17
- add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_footer_scripts' ) );
18
- }
19
 
20
  if ( $enqueue ) {
21
  // Enqueue pointers
@@ -25,16 +25,16 @@ class Sputnik_Pointers {
25
  }
26
 
27
  public static function print_footer_scripts() {
28
- $content = '<h3>' . __( 'New Feature: WPeC Extensions' ) . '</h3>';
29
- $content .= '<p>' . __( 'Ever wanted to be able to find an extension for your WP eCommerce store and purchase, install and activate it right from WordPress? Now you can!', 'wpsc' ) . '</p>';
30
- $content .= '<p>' . __( 'Find the latest and greatest free and premium plugins from the WP eCommerce community in our <a href="' . Sputnik_Admin::build_url() . '">Extensions Marketplace</a>.', 'wpsc' ) . '</p>';
31
  ?>
32
  <script type="text/javascript">// <![CDATA[
33
  jQuery(document).ready(function($) {
34
  var wpsc_target;
35
 
36
  $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik"]').attr( 'id', 'marketplace-link' );
37
-
38
  wpsc_target = $('#menu-posts-wpsc-product').hasClass('wp-has-current-submenu') ? $('#marketplace-link') : $('#menu-posts-wpsc-product');
39
 
40
  wpsc_target.pointer({
12
 
13
  $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
14
 
15
+ if ( ! in_array( 'wpsc_marketplace_pointer', $dismissed ) ) {
16
+ $enqueue = true;
17
+ add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_footer_scripts' ) );
18
+ }
19
 
20
  if ( $enqueue ) {
21
  // Enqueue pointers
25
  }
26
 
27
  public static function print_footer_scripts() {
28
+ $content = '<h3>' . __( 'New Feature: WPeC Add-Ons' ) . '</h3>';
29
+ $content .= '<p>' . __( 'Ever wanted to be able to find an extension for your e-commerce store, purchase, install and activate it right from WordPress? Now you can!', 'wpsc' ) . '</p>';
30
+ $content .= '<p>' . __( 'Find the latest and greatest free and premium plugins from the WP E-Commerce community in our <a href="' . Sputnik_Admin::build_url() . '">Add-Ons page</a>.', 'wpsc' ) . '</p>';
31
  ?>
32
  <script type="text/javascript">// <![CDATA[
33
  jQuery(document).ready(function($) {
34
  var wpsc_target;
35
 
36
  $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik"]').attr( 'id', 'marketplace-link' );
37
+
38
  wpsc_target = $('#menu-posts-wpsc-product').hasClass('wp-has-current-submenu') ? $('#marketplace-link') : $('#menu-posts-wpsc-product');
39
 
40
  wpsc_target.pointer({
wpsc-components/marketplace-core-v1/library/Sputnik/ThemeUpgrader.php CHANGED
@@ -33,8 +33,7 @@ class Sputnik_ThemeUpgrader extends Theme_Upgrader {
33
  'timeout' => $timeout,
34
  'stream' => true,
35
  'filename' => $tmpfname,
36
- 'headers' => array( 'X-WP-Domain' => Sputnik_API::domain() ),
37
- 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION
38
  );
39
 
40
  Sputnik_API::sign_download($url, $args);
33
  'timeout' => $timeout,
34
  'stream' => true,
35
  'filename' => $tmpfname,
36
+ 'headers' => array( 'X-WP-Domain' => Sputnik_API::domain() )
 
37
  );
38
 
39
  Sputnik_API::sign_download($url, $args);
wpsc-components/marketplace-core-v1/library/Sputnik/Theme_Upgrader.php CHANGED
@@ -33,8 +33,7 @@ class Sputnik_ThemeUpgrader extends Theme_Upgrader {
33
  'timeout' => $timeout,
34
  'stream' => true,
35
  'filename' => $tmpfname,
36
- 'headers' => array( 'X-WP-Domain' => Sputnik_API::domain() ),
37
- 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION
38
  );
39
 
40
  Sputnik_API::sign_download($url, $args);
33
  'timeout' => $timeout,
34
  'stream' => true,
35
  'filename' => $tmpfname,
36
+ 'headers' => array( 'X-WP-Domain' => Sputnik_API::domain() )
 
37
  );
38
 
39
  Sputnik_API::sign_download($url, $args);
wpsc-components/marketplace-core-v1/library/Sputnik/Updater.php CHANGED
@@ -41,10 +41,9 @@ class Sputnik_Updater {
41
  $options = array(
42
  'headers' => array(
43
  'X-WP-Domain' => self::domain(),
44
- ),
45
- 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION
46
  );
47
- $url = add_query_arg('plugins', urlencode(json_encode($data)), $url);
48
  $req = wp_remote_get($url, $options);
49
  if (is_wp_error($req) || $req['response']['code'] !== 200) {
50
  return $plugins;
@@ -115,10 +114,9 @@ class Sputnik_Updater {
115
  $options = array(
116
  'headers' => array(
117
  'X-WP-Domain' => self::domain(),
118
- ),
119
- 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION
120
  );
121
- $url = add_query_arg( 'themes', urlencode( json_encode( $data ) ), $url );
122
  $req = wp_remote_get( $url, $options );
123
  if (is_wp_error($req) || $req['response']['code'] !== 200) {
124
  return $themes;
41
  $options = array(
42
  'headers' => array(
43
  'X-WP-Domain' => self::domain(),
44
+ )
 
45
  );
46
+ $url = esc_url_raw( add_query_arg('plugins', urlencode(json_encode($data)), $url) );
47
  $req = wp_remote_get($url, $options);
48
  if (is_wp_error($req) || $req['response']['code'] !== 200) {
49
  return $plugins;
114
  $options = array(
115
  'headers' => array(
116
  'X-WP-Domain' => self::domain(),
117
+ )
 
118
  );
119
+ $url = esc_url_raw( add_query_arg( 'themes', urlencode( json_encode( $data ) ), $url ) );
120
  $req = wp_remote_get( $url, $options );
121
  if (is_wp_error($req) || $req['response']['code'] !== 200) {
122
  return $themes;
wpsc-components/marketplace-core-v1/library/Sputnik/Upgrader.php CHANGED
@@ -30,11 +30,10 @@ class Sputnik_Upgrader extends Plugin_Upgrader {
30
  return new WP_Error('http_no_file', __('Could not create Temporary file.'));
31
 
32
  $args = array(
33
- 'timeout' => $timeout,
34
- 'stream' => true,
35
- 'filename' => $tmpfname,
36
- 'headers' => array( 'X-WP-Domain' => Sputnik_API::domain() ),
37
- 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION
38
  );
39
 
40
  Sputnik_API::sign_download($url, $args);
30
  return new WP_Error('http_no_file', __('Could not create Temporary file.'));
31
 
32
  $args = array(
33
+ 'timeout' => $timeout,
34
+ 'stream' => true,
35
+ 'filename' => $tmpfname,
36
+ 'headers' => array( 'X-WP-Domain' => Sputnik_API::domain() )
 
37
  );
38
 
39
  Sputnik_API::sign_download($url, $args);
wpsc-components/marketplace-core-v1/library/Sputnik/View.php CHANGED
@@ -30,8 +30,8 @@ abstract class Sputnik_View {
30
  }
31
  if ($account !== false) {
32
  $tabs = array(
33
- 'dash' => __('Store', 'wpsc'),
34
- 'account' => __('Your Account', 'wpsc'),
35
  );
36
  $hrefs = array(
37
  'dash' => Sputnik_Admin::build_url(),
@@ -72,7 +72,7 @@ abstract class Sputnik_View {
72
  protected function footer() {?>
73
  <div id="sputnik-footer">
74
  <p class="logo-holder"><a href="http://wpeconomy.org/" class="renku-logo">WPEconomy</a></p>
75
- <nav><p><a href="http://www.wpeconomy.org/documentation/developers/"><?php _e('Developer Tools', 'wpsc') ?></a> | <a href="http://twitter.com/WPEconomy">@WPEconomy</a> | <a href="http://www.wpeconomy.org/documentation/marketplace/faqs/"><?php _e('FAQ', 'wpsc') ?></a></p></nav>
76
  </div>
77
  </div>
78
  <?php
30
  }
31
  if ($account !== false) {
32
  $tabs = array(
33
+ 'dash' => __('Store', 'sputnik'),
34
+ 'account' => __('Your Account', 'sputnik'),
35
  );
36
  $hrefs = array(
37
  'dash' => Sputnik_Admin::build_url(),
72
  protected function footer() {?>
73
  <div id="sputnik-footer">
74
  <p class="logo-holder"><a href="http://wpeconomy.org/" class="renku-logo">WPEconomy</a></p>
75
+ <nav><p><a href="http://www.wpeconomy.org/documentation/developers/"><?php _e('Developer Tools', 'sputnik') ?></a> | <a href="http://twitter.com/WPEconomy">@WPEconomy</a> | <a href="http://www.wpeconomy.org/documentation/marketplace/faqs/"><?php _e('FAQ', 'sputnik') ?></a></p></nav>
76
  </div>
77
  </div>
78
  <?php
wpsc-components/marketplace-core-v1/library/Sputnik/View/Account.php CHANGED
@@ -22,14 +22,14 @@ class Sputnik_View_Account extends Sputnik_View_Browser {
22
  <div class="account-card">
23
  <div class="block">
24
  <?php echo get_avatar($account->email) ?>
25
- <p class="lead-in"><?php _e('Logged in as', 'wpsc') ?></p>
26
  <h3><?php echo esc_html($account->name) ?></h3>
27
- <p><?php printf(__('<a href="%s">Log out</a> of your account', 'wpsc'), Sputnik_Admin::build_url(array('oauth' => 'reset'))) ?></p>
28
  </div>
29
  <div class="block">
30
- <p><?php printf(__('Email: %s', 'wpsc'), '<code>' . $account->email . '</code>') ?></p>
31
- <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'wpsc'), count($account->purchased)) ?></p>
32
- <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'wpsc'), $this->count) ?></p>
33
  </div>
34
  </div>
35
 
@@ -46,8 +46,8 @@ class Sputnik_View_Account extends Sputnik_View_Browser {
46
 
47
  public function get_tabs() {
48
  $tabs = array();
49
- $tabs['purchased'] = __( 'Purchased Plugins', 'wpsc' );
50
- $tabs['yours'] = __( 'Your Plugins', 'wpsc' );
51
  return $tabs;
52
  }
53
 
@@ -76,8 +76,8 @@ class Sputnik_View_Account extends Sputnik_View_Browser {
76
  if ($tab === 'yours') {
77
  $api['body'][] = (object) array(
78
  'slug' => '__add_new',
79
- 'name' => __('Add Your Plugin', 'wpsc'),
80
- 'description' => __('List your plugin on the WPEconomy store. Read our developer documentation and get started!', 'wpsc'),
81
  'rating' => (object) array('average' => 0, 'count' => 0),
82
  'price' => 0,
83
  'version' => '',
@@ -116,10 +116,10 @@ class Sputnik_View_Account extends Sputnik_View_Browser {
116
  global $tab;
117
  echo '<p>';
118
  if ($tab === 'yours') {
119
- _e( "You haven't created any plugins yet. Check out our <a href='http://developer.renku.me/'>developer documentation</a> to find out how!", 'wpsc' );
120
  }
121
  else {
122
- printf(__( "You haven't purchased any plugins yet. Why not <a href='%s'>buy some</a>?", 'wpsc' ), Sputnik_Admin::build_url());
123
  }
124
  echo '</p>';
125
  }
@@ -132,8 +132,8 @@ class Sputnik_View_Account extends Sputnik_View_Browser {
132
  $actions[] = sprintf(
133
  '<a href="%s" class="button edit" title="%s">%s</a>',
134
  sprintf(Sputnik::SITE_BASE . '/plugins/%d/edit/', $plugin->product_id),
135
- esc_attr(sprintf(_x('Edit %s', 'Edit button title', 'wpsc'), $plugin->name)),
136
- _x('Edit', 'Edit button text', 'wpsc')
137
  );
138
  return $actions;
139
  }
22
  <div class="account-card">
23
  <div class="block">
24
  <?php echo get_avatar($account->email) ?>
25
+ <p class="lead-in"><?php _e('Logged in as', 'sputnik') ?></p>
26
  <h3><?php echo esc_html($account->name) ?></h3>
27
+ <p><?php printf(__('<a href="%s">Log out</a> of your account', 'sputnik'), Sputnik_Admin::build_url(array('oauth' => 'reset'))) ?></p>
28
  </div>
29
  <div class="block">
30
+ <p><?php printf(__('Email: %s', 'sputnik'), '<code>' . $account->email . '</code>') ?></p>
31
+ <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'sputnik'), count($account->purchased)) ?></p>
32
+ <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'sputnik'), $this->count) ?></p>
33
  </div>
34
  </div>
35
 
46
 
47
  public function get_tabs() {
48
  $tabs = array();
49
+ $tabs['purchased'] = __( 'Purchased Plugins', 'sputnik' );
50
+ $tabs['yours'] = __( 'Your Plugins', 'sputnik' );
51
  return $tabs;
52
  }
53
 
76
  if ($tab === 'yours') {
77
  $api['body'][] = (object) array(
78
  'slug' => '__add_new',
79
+ 'name' => __('Add Your Plugin', 'sputnik'),
80
+ 'description' => __('List your plugin on the WPEconomy store. Read our developer documentation and get started!', 'sputnik'),
81
  'rating' => (object) array('average' => 0, 'count' => 0),
82
  'price' => 0,
83
  'version' => '',
116
  global $tab;
117
  echo '<p>';
118
  if ($tab === 'yours') {
119
+ _e( "You haven't created any plugins yet. Check out our <a href='http://developer.renku.me/'>developer documentation</a> to find out how!", 'sputnik' );
120
  }
121
  else {
122
+ printf(__( "You haven't purchased any plugins yet. Why not <a href='%s'>buy some</a>?", 'sputnik' ), Sputnik_Admin::build_url());
123
  }
124
  echo '</p>';
125
  }
132
  $actions[] = sprintf(
133
  '<a href="%s" class="button edit" title="%s">%s</a>',
134
  sprintf(Sputnik::SITE_BASE . '/plugins/%d/edit/', $plugin->product_id),
135
+ esc_attr(sprintf(_x('Edit %s', 'Edit button title', 'sputnik'), $plugin->name)),
136
+ _x('Edit', 'Edit button text', 'sputnik')
137
  );
138
  return $actions;
139
  }
wpsc-components/marketplace-core-v1/library/Sputnik/View/Auth.php CHANGED
@@ -18,7 +18,7 @@ class Sputnik_View_Auth extends Sputnik_View {
18
  }
19
  public function render() {
20
  if ( isset( $_GET['auth'] ) && $_GET['auth'] == 'denied' ) {
21
- Sputnik_Admin::add_message( __( 'Account linking cancelled. Please note that you need to link your account in order to access the store.', 'wpsc' ) );
22
  }
23
 
24
  $this->header();
18
  }
19
  public function render() {
20
  if ( isset( $_GET['auth'] ) && $_GET['auth'] == 'denied' ) {
21
+ Sputnik_Admin::add_message( __( 'Account linking cancelled. Please note that you need to link your account in order to access the store.', 'sputnik' ) );
22
  }
23
 
24
  $this->header();
wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser.php CHANGED
@@ -56,14 +56,14 @@ class Sputnik_View_Browser extends Sputnik_View {
56
 
57
  global $tab;
58
  $tabs = array();
59
- $tabs['dashboard'] = __( 'Search', 'wpsc' );
60
  if ( 'search' == $tab )
61
- $tabs['search'] = __( 'Search Results', 'wpsc' );
62
- $tabs['featured'] = _x( 'Featured', 'Plugin Installer', 'wpsc' );
63
- $tabs['popular'] = _x( 'Popular', 'Plugin Installer', 'wpsc' );
64
- $tabs['new'] = _x( 'Newest', 'Plugin Installer', 'wpsc' );
65
- $tabs['updated'] = _x( 'Recently Updated', 'Plugin Installer', 'wpsc' );
66
- $tabs['price'] = _x( 'Lowest Priced', 'Plugin Installer', 'wpsc' );
67
  return $tabs;
68
  }
69
 
@@ -99,7 +99,7 @@ class Sputnik_View_Browser extends Sputnik_View {
99
  }
100
 
101
  public function no_items() {
102
- echo '<p>' . __( 'No plugins match your request.', 'wpsc' ) . '</p>';
103
  }
104
 
105
  public function footer() {
56
 
57
  global $tab;
58
  $tabs = array();
59
+ $tabs['dashboard'] = __( 'Search', 'sputnik' );
60
  if ( 'search' == $tab )
61
+ $tabs['search'] = __( 'Search Results', 'sputnik' );
62
+ $tabs['featured'] = _x( 'Featured', 'Plugin Installer', 'sputnik' );
63
+ $tabs['popular'] = _x( 'Popular', 'Plugin Installer', 'sputnik' );
64
+ $tabs['new'] = _x( 'Newest', 'Plugin Installer', 'sputnik' );
65
+ $tabs['updated'] = _x( 'Recently Updated', 'Plugin Installer', 'sputnik' );
66
+ $tabs['price'] = _x( 'Lowest Priced', 'Plugin Installer', 'sputnik' );
67
  return $tabs;
68
  }
69
 
99
  }
100
 
101
  public function no_items() {
102
+ echo '<p>' . __( 'No plugins match your request.', 'sputnik' ) . '</p>';
103
  }
104
 
105
  public function footer() {
wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/Grid.php CHANGED
@@ -70,8 +70,8 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
70
 
71
  public function view_switcher() {
72
  $modes = array(
73
- 'list' => __('List View', 'wpsc'),
74
- 'grid' => __('Grid View', 'wpsc')
75
  );
76
  $current_mode = $this->parent->view_type;
77
  ?>
@@ -135,7 +135,7 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
135
  if ( 'top' == $which ) { ?>
136
  <div class="tablenav top">
137
  <div class="alignright account">
138
- <?php printf(__('Logged in as %s', 'wpsc'), '<a href="' . menu_page_url( 'sputnik-account', false ) . '" class="account-link">' . $account->name . '</a>') ?>
139
  <?php
140
  if ($tab === 'search') {
141
  ?>
@@ -168,11 +168,11 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
168
 
169
  public function get_columns() {
170
  return array(
171
- 'name' => _x( 'Name', 'plugin name', 'wpsc' ),
172
- 'version' => __( 'Version', 'wpsc' ),
173
- 'price' => __( 'Action', 'wpsc' ),
174
- 'rating' => __( 'Rating', 'wpsc' ),
175
- 'description' => __( 'Description', 'wpsc' ),
176
  );
177
  }
178
 
@@ -208,11 +208,12 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
208
  $plugin->version = wp_kses( $plugin->version, $plugins_allowedtags );
209
  $plugin->price = sprintf('$%.2f', $plugin->price);
210
  if ($plugin->price === '$0.00') {
211
- $plugin->price = _x('Free', 'plugin price', 'wpsc');
212
  }
213
 
 
214
  if (!empty($plugin->author))
215
- $plugin->author = ' <cite>' . sprintf( __( 'By %s', 'wpsc' ), $plugin->author ) . '.</cite>';
216
 
217
  $plugin->author = wp_kses( $plugin->author, $plugins_allowedtags );
218
 
@@ -221,11 +222,11 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
221
  }
222
 
223
  protected function display_row($plugin, $style) {
224
- $name = strip_tags( $plugin->name );
225
  $action_links = array();
226
  $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
227
  . '" class="thickbox button info" title="' .
228
- esc_attr( sprintf( __( 'More information about %s', 'wpsc' ), $name ) ) . '">' . __( 'Details', 'wpsc' ) . '</a>';
229
 
230
  $purchase_link = $plugin->price;
231
 
@@ -233,8 +234,8 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
233
  $status = 'addown';
234
  $name = $plugin->name;
235
  $action_links = array();
236
- $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __( 'Documentation', 'wpsc' ) . '</a>';
237
- $purchase_link = '<a class="button-primary addown status" href="' . Sputnik::SITE_BASE . '/plugins/add/">' . esc_html__('Add Now', 'wpsc') . '</a>';
238
  }
239
  elseif ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
240
  $status = Sputnik_Admin::install_status( $plugin );
@@ -242,36 +243,36 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
242
  switch ( $status['status'] ) {
243
  case 'purchase':
244
  if ( $status['url'] ) {
245
- $purchase_link = '<a id="' . $plugin->slug .'" class="button-primary buy status" href="' . $status['url'] . '" title="'
246
- . esc_attr(sprintf(__( 'Buy %s', 'wpsc'), $name)) . '">' . __('Buy Now', 'wpsc') . '</a>';
247
  }
248
  break;
249
  case 'install':
250
  if ( $status['url'] ) {
251
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600 ), $status['url']);
252
  $purchase_link = '<a class="button install status" href="' . $status['url'] . '" title="'
253
- . esc_attr(sprintf(__( 'Install %s', 'wpsc'), $name)) . '">' . __('Install', 'wpsc') . '</a>';
254
  }
255
  else {
256
- $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">'
257
- . __('Install', 'wpsc') . '</span>';
258
  }
259
  break;
260
  case 'update_available':
261
  if ( $status['url'] ) {
262
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']);
263
- $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
264
- . esc_attr(sprintf(__( 'Update to version %s', 'wpsc'), $status['version'])) . '">' . __('Update', 'wpsc') . '</a>';
265
  }
266
  else {
267
- $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">'
268
- . __('Update', 'wpsc') . '</span>';
269
  }
270
  break;
271
  case 'latest_installed':
272
  case 'newer_installed':
273
- $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'wpsc') . ' ">'
274
- . __('Installed', 'wpsc') . '</span>';
275
  break;
276
  }
277
  }
@@ -284,42 +285,32 @@ class Sputnik_View_Browser_Grid extends WP_List_Table {
284
  }
285
  ?>
286
  <div>
287
- <div class="sputnik-plugin<?php if ( ! empty( $plugin->thumb ) ) echo ' has-thumb'; ?>">
288
  <div class="sputnik-card">
289
- <h4><?php echo $name ?><span class="price"><?php echo $plugin->price ?></span></h4>
290
-
291
- <?php
292
- if ( ! empty( $thumb ) ) :
293
- ?>
294
  <div class="sputnik-plugin-thumb">
295
- <img src="<?php echo esc_url( $thumb ) ?>" alt="<?php echo esc_attr( $name ) ?> Thumbnail">
296
  </div>
297
- <?php
298
- endif;
299
- ?>
300
  <div class="sputnik-plugin-details">
301
- <p><?php echo $plugin->description; ?></p>
302
- <?php if ( isset( $plugin->rating ) && isset( $plugin->rating->count ) ): ?>
303
- <div class="footer" style="display:none">
304
- <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wpsc' ), number_format_i18n( $plugin->rating->count ) ) ?>">
305
- <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average) ?>px"></div>
306
- <?php
307
- $star_url = admin_url( 'images/stars.png?v=20110615' );
308
- ?>
309
- <div class="star star5"><img src="<?php echo $star_url; ?>" alt="" /></div>
310
- <div class="star star4"><img src="<?php echo $star_url; ?>" alt="" /></div>
311
- <div class="star star3"><img src="<?php echo $star_url; ?>" alt="" /></div>
312
- <div class="star star2"><img src="<?php echo $star_url; ?>" alt="" /></div>
313
- <div class="star star1"><img src="<?php echo $star_url; ?>" alt="" /></div>
314
- </div>
315
  </div>
316
- <?php endif; ?>
317
  </div>
318
  </div>
319
- <div class="sputnik-plugin-actions">
320
- <?php if ( !empty( $action_links ) ) echo implode( ' ', $action_links ); ?>
321
- <?php echo $purchase_link; ?>
322
- </div>
323
  </div>
324
  </div>
325
  <?php
70
 
71
  public function view_switcher() {
72
  $modes = array(
73
+ 'list' => __('List View', 'sputnik'),
74
+ 'grid' => __('Grid View', 'sputnik')
75
  );
76
  $current_mode = $this->parent->view_type;
77
  ?>
135
  if ( 'top' == $which ) { ?>
136
  <div class="tablenav top">
137
  <div class="alignright account">
138
+ <?php printf(__('Logged in as %s', 'sputnik'), '<a href="' . menu_page_url( 'sputnik-account', false ) . '" class="account-link">' . $account->name . '</a>') ?>
139
  <?php
140
  if ($tab === 'search') {
141
  ?>
168
 
169
  public function get_columns() {
170
  return array(
171
+ 'name' => _x( 'Name', 'plugin name', 'sputnik' ),
172
+ 'version' => __( 'Version', 'sputnik' ),
173
+ 'price' => __( 'Action', 'sputnik' ),
174
+ 'rating' => __( 'Rating', 'sputnik' ),
175
+ 'description' => __( 'Description', 'sputnik' ),
176
  );
177
  }
178
 
208
  $plugin->version = wp_kses( $plugin->version, $plugins_allowedtags );
209
  $plugin->price = sprintf('$%.2f', $plugin->price);
210
  if ($plugin->price === '$0.00') {
211
+ $plugin->price = _x('Free', 'plugin price', 'sputnik');
212
  }
213
 
214
+ $plugin->author = $plugin->author;
215
  if (!empty($plugin->author))
216
+ $plugin->author = ' <cite>' . sprintf( __( 'By %s', 'sputnik' ), $plugin->author ) . '.</cite>';
217
 
218
  $plugin->author = wp_kses( $plugin->author, $plugins_allowedtags );
219
 
222
  }
223
 
224
  protected function display_row($plugin, $style) {
225
+ $name = strip_tags( $plugin->name . ' ' . $plugin->version );
226
  $action_links = array();
227
  $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
228
  . '" class="thickbox button info" title="' .
229
+ esc_attr( sprintf( __( 'More information about %s', 'sputnik' ), $name ) ) . '">' . __( 'Details', 'sputnik' ) . '</a>';
230
 
231
  $purchase_link = $plugin->price;
232
 
234
  $status = 'addown';
235
  $name = $plugin->name;
236
  $action_links = array();
237
+ $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __( 'Documentation', 'sputnik' ) . '</a>';
238
+ $purchase_link = '<a class="button-primary addown status" href="' . Sputnik::SITE_BASE . '/plugins/add/">' . esc_html__('Add Now', 'sputnik') . '</a>';
239
  }
240
  elseif ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
241
  $status = Sputnik_Admin::install_status( $plugin );
243
  switch ( $status['status'] ) {
244
  case 'purchase':
245
  if ( $status['url'] ) {
246
+ $purchase_link = '<a id="' . $plugin->slug .'" class="button-primary buy status" href="' . esc_url( $status['url'] ) . '" title="'
247
+ . esc_attr(sprintf(__( 'Buy %s', 'sputnik'), $name)) . '">' . __('Buy Now', 'sputnik') . '</a>';
248
  }
249
  break;
250
  case 'install':
251
  if ( $status['url'] ) {
252
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), esc_url( $status['url']) );
253
  $purchase_link = '<a class="button install status" href="' . $status['url'] . '" title="'
254
+ . esc_attr(sprintf(__( 'Install %s', 'sputnik'), $name)) . '">' . __('Install', 'sputnik') . '</a>';
255
  }
256
  else {
257
+ $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">'
258
+ . __('Install', 'sputnik') . '</span>';
259
  }
260
  break;
261
  case 'update_available':
262
  if ( $status['url'] ) {
263
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']);
264
+ $purchase_link = '<a class="button install" href="' . esc_url( $status['url'] ) . '" title="'
265
+ . esc_attr(sprintf(__( 'Update to version %s', 'sputnik'), $status['version'])) . '">' . __('Update', 'sputnik') . '</a>';
266
  }
267
  else {
268
+ $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">'
269
+ . __('Update', 'sputnik') . '</span>';
270
  }
271
  break;
272
  case 'latest_installed':
273
  case 'newer_installed':
274
+ $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'sputnik') . ' ">'
275
+ . __('Installed', 'sputnik') . '</span>';
276
  break;
277
  }
278
  }
285
  }
286
  ?>
287
  <div>
288
+ <div class="sputnik-plugin<?php if ($thumb !== false) echo ' has-thumb'; if ($status === 'addown') echo ' addown'; ?>">
289
  <div class="sputnik-card">
290
+ <?php
291
+ if ($thumb !== false):
292
+ ?>
 
 
293
  <div class="sputnik-plugin-thumb">
294
+ <img src="<?php echo esc_url($thumb) ?>" alt="<?php echo esc_attr($name) ?> Thumbnail">
295
  </div>
296
+ <?php
297
+ endif;
298
+ ?>
299
  <div class="sputnik-plugin-details">
300
+ <h4><?php echo $name ?></h4>
301
+ <span class="price"><?php echo $plugin->price ?></span>
302
+ <p><?php echo $plugin->description ?></p>
303
+ <div class="footer">
304
+ <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'sputnik' ), number_format_i18n( $plugin->rating->count ) ) ?>">
305
+ <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average) ?>px"></div>
 
 
 
 
 
 
 
 
306
  </div>
307
+ </div>
308
  </div>
309
  </div>
310
+ </div>
311
+ <div class="sputnik-plugin-actions">
312
+ <?php if ( !empty( $action_links ) ) echo implode( ' ', $action_links ); ?>
313
+ <?php echo $purchase_link; ?>
314
  </div>
315
  </div>
316
  <?php
wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/List.php CHANGED
@@ -11,7 +11,7 @@ class Sputnik_View_Browser_List extends Sputnik_View_Browser_Grid {
11
  $action_links = array();
12
  $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
13
  . '" class="button thickbox info" title="' .
14
- esc_attr( sprintf( __( 'More information about %s', 'wpsc' ), $name ) ) . '">' . __( 'Details' ) . '</a>';
15
 
16
  $purchase_link = $plugin->price;
17
 
@@ -19,8 +19,8 @@ class Sputnik_View_Browser_List extends Sputnik_View_Browser_Grid {
19
  $status = 'addown';
20
  $style['name'] .= ' class="addown"';
21
  $action_links = array();
22
- $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __( 'Documentation', 'wpsc' ) . '</a>';
23
- $purchase_link = '<a class="button-primary addown" href="' . Sputnik::SITE_BASE . '/plugins/add/" title="Add New Plugin">' . esc_html__('Add Now', 'wpsc') . '</a>';
24
  }
25
  elseif ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
26
  $status = Sputnik_Admin::install_status( $plugin );
@@ -28,36 +28,36 @@ class Sputnik_View_Browser_List extends Sputnik_View_Browser_Grid {
28
  switch ( $status['status'] ) {
29
  case 'purchase':
30
  if ( $status['url'] ) {
31
- $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy" href="' . $status['url'] . '" title="'
32
- . esc_attr(sprintf(__( 'Buy %s', 'wpsc'), $name)) . '">' . sprintf(__('<span>%s</span> Buy Now</a>', 'wpsc'), $plugin->price);
33
  }
34
  break;
35
  case 'install':
36
  if ( $status['url'] ) {
37
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600 ), $status['url']);
38
- $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
39
- . esc_attr(sprintf(__( 'Install %s', 'wpsc'), $name)) . '">' . __('Install', 'wpsc') . '</a>';
40
  }
41
  else {
42
- $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">'
43
- . __('Install', 'wpsc') . '</span>';
44
  }
45
  break;
46
  case 'update_available':
47
  if ( $status['url'] ) {
48
- $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600 ), $status['url']);
49
- $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="'
50
- . esc_attr(sprintf(__( 'Update to version %s', 'wpsc'), $status['version'])) . '">' . __('Update', 'wpsc') . '</a>';
51
  }
52
  else {
53
- $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">'
54
- . __('Update', 'wpsc') . '</span>';
55
  }
56
  break;
57
  case 'latest_installed':
58
  case 'newer_installed':
59
- $purchase_link = '<span title="' . esc_attr__('This plugin is already installed and is up to date', 'wpsc') . ' ">'
60
- . __('Installed', 'wpsc') . '</span>';
61
  break;
62
  }
63
  }
@@ -71,7 +71,7 @@ class Sputnik_View_Browser_List extends Sputnik_View_Browser_Grid {
71
  <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $plugin->version; ?></td>
72
  <td class="vers column-price"<?php echo $style['price']; ?>><?php echo $purchase_link; ?></td>
73
  <td class="vers column-rating"<?php echo $style['rating']; ?>>
74
- <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wpsc' ), number_format_i18n( $plugin->rating->count ) ) ?>">
75
  <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average) ?>px"></div>
76
  </div>
77
  </td>
11
  $action_links = array();
12
  $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
13
  . '" class="button thickbox info" title="' .
14
+ esc_attr( sprintf( __( 'More information about %s', 'sputnik' ), $name ) ) . '">' . __( 'Details' ) . '</a>';
15
 
16
  $purchase_link = $plugin->price;
17
 
19
  $status = 'addown';
20
  $style['name'] .= ' class="addown"';
21
  $action_links = array();
22
+ $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __( 'Documentation', 'sputnik' ) . '</a>';
23
+ $purchase_link = '<a class="button-primary addown" href="' . Sputnik::SITE_BASE . '/plugins/add/" title="Add New Plugin">' . esc_html__('Add Now', 'sputnik') . '</a>';
24
  }
25
  elseif ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
26
  $status = Sputnik_Admin::install_status( $plugin );
28
  switch ( $status['status'] ) {
29
  case 'purchase':
30
  if ( $status['url'] ) {
31
+ $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy" href="' . esc_url( $status['url'] ) . '" title="'
32
+ . esc_attr(sprintf(__( 'Buy %s', 'sputnik'), $name)) . '">' . sprintf(__('<span>%s</span> Buy Now</a>', 'sputnik'), $plugin->price);
33
  }
34
  break;
35
  case 'install':
36
  if ( $status['url'] ) {
37
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']);
38
+ $purchase_link = '<a class="button install" href="' . esc_url( $status['url'] ) . '" title="'
39
+ . esc_attr(sprintf(__( 'Install %s', 'sputnik'), $name)) . '">' . __('Install', 'sputnik') . '</a>';
40
  }
41
  else {
42
+ $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">'
43
+ . __('Install', 'sputnik') . '</span>';
44
  }
45
  break;
46
  case 'update_available':
47
  if ( $status['url'] ) {
48
+ $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), esc_url( $status['url'] ) );
49
+ $purchase_link = '<a class="button install" href="' . esc_url( $status['url'] ) . '" title="'
50
+ . esc_attr(sprintf(__( 'Update to version %s', 'sputnik'), $status['version'])) . '">' . __('Update', 'sputnik') . '</a>';
51
  }
52
  else {
53
+ $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">'
54
+ . __('Update', 'sputnik') . '</span>';
55
  }
56
  break;
57
  case 'latest_installed':
58
  case 'newer_installed':
59
+ $purchase_link = '<span title="' . esc_attr__('This plugin is already installed and is up to date', 'sputnik') . ' ">'
60
+ . __('Installed', 'sputnik') . '</span>';
61
  break;
62
  }
63
  }
71
  <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $plugin->version; ?></td>
72
  <td class="vers column-price"<?php echo $style['price']; ?>><?php echo $purchase_link; ?></td>
73
  <td class="vers column-rating"<?php echo $style['rating']; ?>>
74
+ <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'sputnik' ), number_format_i18n( $plugin->rating->count ) ) ?>">
75
  <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average) ?>px"></div>
76
  </div>
77
  </td>
wpsc-components/marketplace-core-v1/library/Sputnik/View/Info.php CHANGED
@@ -19,7 +19,7 @@ class Sputnik_View_Info extends Sputnik_View_Mini {
19
  protected $api;
20
 
21
  public function __construct() {
22
- parent::__construct( __('Plugin Information', 'wpsc') );
23
  $this->plugin = $_GET['info'];
24
 
25
  try {
@@ -28,7 +28,7 @@ class Sputnik_View_Info extends Sputnik_View_Mini {
28
  }
29
  catch (Exception $e) {
30
  status_header(500);
31
- iframe_header( __('', 'wpsc') );
32
  echo $e->getMessage();
33
  iframe_footer();
34
  die();
@@ -48,12 +48,12 @@ class Sputnik_View_Info extends Sputnik_View_Mini {
48
  'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
49
 
50
  $plugins_section_titles = array(
51
- 'description' => _x('Description', 'Plugin installer section title', 'wpsc'),
52
- 'installation' => _x('Installation', 'Plugin installer section title', 'wpsc'),
53
- 'faq' => _x('FAQ', 'Plugin installer section title', 'wpsc'),
54
- 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'wpsc'),
55
- 'changelog' => _x('Changelog', 'Plugin installer section title', 'wpsc'),
56
- 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'wpsc')
57
  );
58
  //Sanitize HTML
59
  $api->sections = (array) $api->sections;
@@ -92,21 +92,21 @@ class Sputnik_View_Info extends Sputnik_View_Mini {
92
  case 'purchase':
93
  default:
94
  if ( $status['url'] )
95
- echo '<a href="' . $status['url'] . '" target="_parent" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy &amp; Install', 'wpsc'), $api->price) . '</a>';
96
  break;
97
  case 'install':
98
  if ( $status['url'] )
99
- echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'wpsc') . '">' . __('Install Now', 'wpsc') . '</a>';
100
  break;
101
  case 'update_available':
102
  if ( $status['url'] )
103
- echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'wpsc') .'</a>';
104
  break;
105
  case 'newer_installed':
106
- echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'wpsc'), $status['version']) . '</a>';
107
  break;
108
  case 'latest_installed':
109
- echo '<a>' . __('Latest Version Installed', 'wpsc') . '</a>';
110
  break;
111
  }
112
  ?>
@@ -137,23 +137,23 @@ class Sputnik_View_Info extends Sputnik_View_Mini {
137
  echo "</ul>\n";
138
  echo "</div>\n";
139
  ?>
140
- <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI', 'wpsc') ?></h2>
141
  <ul>
142
  <?php if ( ! empty($api->version) ) : ?>
143
- <li><strong><?php _e('Version:', 'wpsc') ?></strong> <?php echo $api->version ?></li>
144
  <?php endif; if ( ! empty($api->author) ) : ?>
145
- <li><strong><?php _e('Author:', 'wpsc') ?></strong> <?php echo $api->author ?></li>
146
  <?php endif; if ( ! empty($api->last_updated) ) : ?>
147
- <li><strong><?php _e('Last Updated:', 'wpsc') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
148
- printf( __('%s ago', 'wpsc'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
149
  <?php endif; if ( ! empty($api->requires) ) : ?>
150
- <li><strong><?php _e('Requires WordPress Version:', 'wpsc') ?></strong> <?php printf(__('%s or higher', 'wpsc'), $api->requires) ?></li>
151
  <?php endif; if ( ! empty($api->tested) ) : ?>
152
- <li><strong><?php _e('Compatible up to:', 'wpsc') ?></strong> <?php echo $api->tested ?></li>
153
  <?php endif; if ( ! empty($api->downloaded) ) : ?>
154
- <li><strong><?php _e('Downloaded:', 'wpsc') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded, 'wpsc'), number_format_i18n($api->downloaded)) ?></li>
155
  <?php endif; if ( ! empty($api->homepage) ) : ?>
156
- <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;', 'wpsc') ?></a></li>
157
  <?php endif; ?>
158
  </ul>
159
 
@@ -161,10 +161,10 @@ class Sputnik_View_Info extends Sputnik_View_Mini {
161
  <div id="section-holder" class="wrap">
162
  <?php
163
  if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
164
- echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.', 'wpsc') . '</p></div>';
165
 
166
  else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
167
- echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.', 'wpsc') . '</p></div>';
168
 
169
  foreach ( $api->sections as $section_name => $content ) {
170
  if ( isset( $plugins_section_titles[ $section_name ] ) )
19
  protected $api;
20
 
21
  public function __construct() {
22
+ parent::__construct( __('Plugin Information', 'sputnik') );
23
  $this->plugin = $_GET['info'];
24
 
25
  try {
28
  }
29
  catch (Exception $e) {
30
  status_header(500);
31
+ iframe_header( __('', 'sputnik') );
32
  echo $e->getMessage();
33
  iframe_footer();
34
  die();
48
  'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
49
 
50
  $plugins_section_titles = array(
51
+ 'description' => _x('Description', 'Plugin installer section title', 'sputnik'),
52
+ 'installation' => _x('Installation', 'Plugin installer section title', 'sputnik'),
53
+ 'faq' => _x('FAQ', 'Plugin installer section title', 'sputnik'),
54
+ 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'sputnik'),
55
+ 'changelog' => _x('Changelog', 'Plugin installer section title', 'sputnik'),
56
+ 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'sputnik')
57
  );
58
  //Sanitize HTML
59
  $api->sections = (array) $api->sections;
92
  case 'purchase':
93
  default:
94
  if ( $status['url'] )
95
+ echo '<a href="' . $status['url'] . '" target="_parent" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy &amp; Install', 'sputnik'), $api->price) . '</a>';
96
  break;
97
  case 'install':
98
  if ( $status['url'] )
99
+ echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'sputnik') . '">' . __('Install Now', 'sputnik') . '</a>';
100
  break;
101
  case 'update_available':
102
  if ( $status['url'] )
103
+ echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'sputnik') .'</a>';
104
  break;
105
  case 'newer_installed':
106
+ echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'sputnik'), $status['version']) . '</a>';
107
  break;
108
  case 'latest_installed':
109
+ echo '<a>' . __('Latest Version Installed', 'sputnik') . '</a>';
110
  break;
111
  }
112
  ?>
137
  echo "</ul>\n";
138
  echo "</div>\n";
139
  ?>
140
+ <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI', 'sputnik') ?></h2>
141
  <ul>
142
  <?php if ( ! empty($api->version) ) : ?>
143
+ <li><strong><?php _e('Version:', 'sputnik') ?></strong> <?php echo $api->version ?></li>
144
  <?php endif; if ( ! empty($api->author) ) : ?>
145
+ <li><strong><?php _e('Author:', 'sputnik') ?></strong> <?php echo $api->author ?></li>
146
  <?php endif; if ( ! empty($api->last_updated) ) : ?>
147
+ <li><strong><?php _e('Last Updated:', 'sputnik') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
148
+ printf( __('%s ago', 'sputnik'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
149
  <?php endif; if ( ! empty($api->requires) ) : ?>
150
+ <li><strong><?php _e('Requires WordPress Version:', 'sputnik') ?></strong> <?php printf(__('%s or higher', 'sputnik'), $api->requires) ?></li>
151
  <?php endif; if ( ! empty($api->tested) ) : ?>
152
+ <li><strong><?php _e('Compatible up to:', 'sputnik') ?></strong> <?php echo $api->tested ?></li>
153
  <?php endif; if ( ! empty($api->downloaded) ) : ?>
154
+ <li><strong><?php _e('Downloaded:', 'sputnik') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded, 'sputnik'), number_format_i18n($api->downloaded)) ?></li>
155
  <?php endif; if ( ! empty($api->homepage) ) : ?>
156
+ <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;', 'sputnik') ?></a></li>
157
  <?php endif; ?>
158
  </ul>
159
 
161
  <div id="section-holder" class="wrap">
162
  <?php
163
  if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
164
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.', 'sputnik') . '</p></div>';
165
 
166
  else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
167
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.', 'sputnik') . '</p></div>';
168
 
169
  foreach ( $api->sections as $section_name => $content ) {
170
  if ( isset( $plugins_section_titles[ $section_name ] ) )
wpsc-components/marketplace-core-v1/library/Sputnik/View/Install.php CHANGED
@@ -22,13 +22,13 @@ class Sputnik_View_Install extends Sputnik_View_Mini {
22
  protected $api = null;
23
 
24
  public function __construct() {
25
- parent::__construct(__('Plugin Install', 'wpsc'));
26
  $this->id = $_GET['install'];
27
- $this->title = __('Installing Plugin: %s', 'wpsc');
28
  }
29
 
30
  protected function prepare() {
31
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
32
 
33
  try {
34
  $this->api = $api = Sputnik::get_plugin($this->id);
@@ -48,7 +48,7 @@ class Sputnik_View_Install extends Sputnik_View_Mini {
48
  }
49
 
50
  if ( ! current_user_can('install_plugins') )
51
- wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'wpsc'));
52
 
53
  check_admin_referer($this->nonce_prefix . $this->api->slug);
54
 
22
  protected $api = null;
23
 
24
  public function __construct() {
25
+ parent::__construct(__('Plugin Install', 'sputnik'));
26
  $this->id = $_GET['install'];
27
+ $this->title = __('Installing Plugin: %s', 'sputnik');
28
  }
29
 
30
  protected function prepare() {
31
+ include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
32
 
33
  try {
34
  $this->api = $api = Sputnik::get_plugin($this->id);
48
  }
49
 
50
  if ( ! current_user_can('install_plugins') )
51
+ wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik'));
52
 
53
  check_admin_referer($this->nonce_prefix . $this->api->slug);
54
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Install/Skin.php CHANGED
@@ -16,7 +16,7 @@ class Sputnik_View_Install_Skin extends WP_Upgrader_Skin {
16
 
17
  function before() {
18
  if ( ! empty( $this->api ) ) {
19
- $asset_type = $this->api->is_theme ? 'theme' : 'plugin';
20
  $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the %s <strong>%s %s</strong>.'), $asset_type, $this->api->name, $this->api->version);
21
  }
22
 
@@ -34,23 +34,23 @@ class Sputnik_View_Install_Skin extends WP_Upgrader_Skin {
34
  // One-Click flow
35
  if (!empty($_GET['also']) && $_GET['also'] == 'activate') {
36
  if (!$this->result || is_wp_error($this->result)) {
37
- show_message(__('Cannot activate plugin.', 'wpsc'));
38
  }
39
  else {
40
- show_message(__('Activating the plugin&#8230;', 'wpsc'));
41
  echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=0&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) .'"></iframe>';
42
  }
43
  }
44
  else {
45
- $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin', 'wpsc') . '" target="_parent">' . __('Activate Plugin', 'wpsc') . '</a>';
46
 
47
  if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
48
- $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network', 'wpsc') . '" target="_parent">' . __('Network Activate', 'wpsc') . '</a>';
49
  unset( $install_actions['activate_plugin'] );
50
  }
51
  }
52
 
53
- $install_actions['store'] = '<a href="' . Sputnik_Admin::build_url() . '" title="' . esc_attr__('Return to Store', 'wpsc') . '" target="_parent" class="close">' . __('Return to Store', 'wpsc') . '</a>';
54
 
55
 
56
  if (!$this->result || is_wp_error($this->result)) {
16
 
17
  function before() {
18
  if ( ! empty( $this->api ) ) {
19
+ $asset_type = $this->api->is_theme ? 'theme' : 'plugin';
20
  $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the %s <strong>%s %s</strong>.'), $asset_type, $this->api->name, $this->api->version);
21
  }
22
 
34
  // One-Click flow
35
  if (!empty($_GET['also']) && $_GET['also'] == 'activate') {
36
  if (!$this->result || is_wp_error($this->result)) {
37
+ show_message(__('Cannot activate plugin.', 'sputnik'));
38
  }
39
  else {
40
+ show_message(__('Activating the plugin&#8230;', 'sputnik'));
41
  echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=0&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) .'"></iframe>';
42
  }
43
  }
44
  else {
45
+ $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin', 'sputnik') . '" target="_parent">' . __('Activate Plugin', 'sputnik') . '</a>';
46
 
47
  if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
48
+ $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network', 'sputnik') . '" target="_parent">' . __('Network Activate', 'sputnik') . '</a>';
49
  unset( $install_actions['activate_plugin'] );
50
  }
51
  }
52
 
53
+ $install_actions['store'] = '<a href="' . Sputnik_Admin::build_url() . '" title="' . esc_attr__('Return to Store', 'sputnik') . '" target="_parent" class="close">' . __('Return to Store', 'sputnik') . '</a>';
54
 
55
 
56
  if (!$this->result || is_wp_error($this->result)) {
wpsc-components/marketplace-core-v1/library/Sputnik/View/Upgrade.php CHANGED
@@ -17,11 +17,11 @@ class Sputnik_View_Upgrade extends Sputnik_View_Install {
17
 
18
  public function __construct() {
19
  parent::__construct();
20
- $this->title = __('Update Plugin', 'wpsc');
21
 
22
  $this->body_id = 'sputnik-upgrade';
23
  $this->nonce_prefix = 'sputnik_upgrade-plugin_';
24
- $this->title_format = __('Updating Plugin: %s', 'wpsc');
25
  }
26
 
27
  protected function prepare() {
@@ -29,13 +29,13 @@ class Sputnik_View_Upgrade extends Sputnik_View_Install {
29
  $this->file = $_GET['upgrade'];
30
  $data = Sputnik::get_from_file($file);
31
  if ($data === null) {
32
- throw new Exception(__('Plugin not found', 'wpsc'));
33
  }
34
  $this->id = $data['Sputnik ID'];
35
  }
36
  catch (Exception $e) {
37
  status_header(500);
38
- iframe_header( __('Update Plugin', 'wpsc') );
39
  echo $e->getMessage();
40
  iframe_footer();
41
  die();
17
 
18
  public function __construct() {
19
  parent::__construct();
20
+ $this->title = __('Update Plugin', 'sputnik');
21
 
22
  $this->body_id = 'sputnik-upgrade';
23
  $this->nonce_prefix = 'sputnik_upgrade-plugin_';
24
+ $this->title_format = __('Updating Plugin: %s', 'sputnik');
25
  }
26
 
27
  protected function prepare() {
29
  $this->file = $_GET['upgrade'];
30
  $data = Sputnik::get_from_file($file);
31
  if ($data === null) {
32
+ throw new Exception(__('Plugin not found', 'sputnik'));
33
  }
34
  $this->id = $data['Sputnik ID'];
35
  }
36
  catch (Exception $e) {
37
  status_header(500);
38
+ iframe_header( __('Update Plugin', 'sputnik') );
39
  echo $e->getMessage();
40
  iframe_footer();
41
  die();
wpsc-components/marketplace-core-v1/marketplace-core-v1.php CHANGED
@@ -1,8 +1,17 @@
1
  <?php
2
 
3
- add_action( 'wpsc_includes', 'wpsc_beta_marketplace_bootstrap', 12 );
 
 
 
 
 
 
 
 
 
 
4
 
5
- function wpsc_beta_marketplace_bootstrap() {
6
  if ( ! class_exists( 'Sputnik' ) ) {
7
  require_once( dirname( __FILE__ ) . '/library/Sputnik.php' );
8
  Sputnik::$path = dirname( __FILE__ );
1
  <?php
2
 
3
+ if ( ! empty( $_GET['wpsc_enable_marketplace'] ) )
4
+ update_option( '_wpsc_enable_marketplace', true );
5
+
6
+ if ( ! empty( $_GET['wpsc_disable_marketplace'] ) )
7
+ update_option( '_wpsc_enable_marketplace', false );
8
+
9
+ add_action( 'wpsc_includes', 'wpec_beta_marketplace_bootstrap', 12 );
10
+
11
+ function wpec_beta_marketplace_bootstrap() {
12
+ if ( ! get_option( '_wpsc_enable_marketplace', false ) )
13
+ return;
14
 
 
15
  if ( ! class_exists( 'Sputnik' ) ) {
16
  require_once( dirname( __FILE__ ) . '/library/Sputnik.php' );
17
  Sputnik::$path = dirname( __FILE__ );
wpsc-components/marketplace-core-v1/static/admin.css CHANGED
@@ -1,95 +1,108 @@
1
- body.wpsc-product_page_sputnik #TB_iframeContent {
2
- margin: -1px 0 -4px 0
3
- }
4
-
5
- #sputnik-page .sep {
6
- margin: 0 12px 0 0;
7
- font-size: 23px;
8
- }
9
-
10
- #sputnik-page h3 {
11
- color: #999;
12
- font-size: 23px;
13
- line-height: 29px;
14
- font-weight: normal;
15
- margin: 0 0 0 40px;
16
- padding: 9px 15px 4px 0;
17
- }
18
-
19
- #sputnik-page .account-link {
20
- margin-right: 8px;
21
- }
22
-
23
- #sputnik-page .aux-links {
24
- float: right;
25
- clear: both;
26
- margin: 10px;
27
- }
28
-
29
- #sputnik-header p {
30
- margin-top: 0;
31
- margin-bottom: 0;
32
- }
33
-
34
- #sputnik-header a, #sputnik-footer a {
35
- text-decoration: none;
36
- }
37
-
38
- #sputnik-header a:hover, #sputnik-footer a:hover {
39
- color: #f00;
40
- }
41
-
42
- #sputnik-footer {
43
- margin-top: 10px;
44
- text-align: center;
45
- border-top: 1px solid #DFDFDF;
46
-
47
- overflow: auto;
48
- padding: 10px 20px;
49
-
50
- background: #fcfcfc;
51
- background: -moz-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
52
- background: -webkit-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
53
- background: -ms-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
54
- background: -o-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
55
- background: radial-gradient(top, #F0F0F0, #FFFFFF 80%);
56
- }
57
-
58
- #sputnik-footer .logo-holder {
59
- float: left;
60
- }
61
-
62
- #sputnik-footer .renku-logo {
63
- background: url("logo.png") no-repeat scroll center center transparent;
64
- text-indent: -9999px;
65
- width: 47px;
66
- height: 22px;
67
- display: block;
68
- }
69
-
70
- #sputnik-footer nav {
71
- float: right;
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  #sputnik-auth, #sputnik-page .connect-error {
75
  font-size: 20px;
 
76
  line-height: 1.6em;
77
  color: #777;
78
  max-width: 500px;
79
  }
 
 
 
 
 
 
80
 
81
- #sputnik-auth .buttons {
82
- text-align: right;
83
- }
84
-
85
- #sputnik-auth .button {
86
- font-size: 15px !important;
87
- }
88
-
89
- #sputnik-page .connect-error {
90
- clear: both;
91
- }
92
-
93
  #sputnik-page a.view-as-list,
94
  #sputnik-page a.view-as-grid {
95
  background-image: url('icons.png'), linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
@@ -99,30 +112,27 @@ body.wpsc-product_page_sputnik #TB_iframeContent {
99
  background-image: url('icons.png'), -ms-linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
100
  background-repeat: no-repeat, repeat-x, repeat-x, repeat-x, repeat-x;
101
  }
102
-
103
  #sputnik-page a.view-as-list {
104
  background-position: right 2px, left top;
105
  padding: 6px 32px 6px 6px;
106
  }
107
-
108
  #sputnik-page a.view-as-grid {
109
  background-position: 31px -69px, left top;
110
  padding: 7px 32px 6px 7px;
111
  }
112
-
113
  #sputnik-page .tablenav-pages {
114
  display: none;
115
  }
116
-
117
  #sputnik-page .tablenav {
118
  margin-top: 0;
119
  height: auto;
120
  position: relative;
 
121
  }
122
-
123
  .grid-view {
124
  margin: 0 0 15px;
125
  clear: both;
 
126
  }
127
 
128
  /* Buy buttons */
@@ -142,138 +152,146 @@ body.wpsc-product_page_sputnik #TB_iframeContent {
142
  }
143
 
144
  .sputnik-plugin {
 
145
  padding: 0;
146
- margin: 15px 25px 5px 0;
147
  float: left;
148
- max-width: 100%;
149
- height: 375px;
150
- width: 283px;
151
- }
152
-
153
- .sputnik-card {}
154
-
155
- .sputnik-plugin-details {
156
- height: 60px;
157
- }
158
-
159
- .sputnik-card h4 {
160
- font-size: 1.25em;
161
- margin: 1.33em .2em .5em;
162
- color: #444;
163
- font-weight: normal;
164
- }
165
-
166
- .sputnik-card h4 span {
167
- font-size: .8em;
168
- float: right;
169
- font-style: italic;
170
- }
171
-
172
- .sputnik-plugin-details .footer {
173
- position: absolute;
174
- width: 176px;
175
- bottom: 0;
176
- right: 12px;
177
- height: 20px;
178
- padding: 8px 0;
179
- background: #F9F9F9;
180
- line-height: 19px;
181
- }
182
-
183
- .sputnik-plugin-details .price {
184
- position: absolute;
185
- right: 12px;
186
- top: 10px;
187
- }
188
-
189
- .sputnik-plugin-details .footer .star-holder {
190
- position: absolute;
191
- right: 0;
192
- }
193
-
194
- .sputnik-plugin-actions {
195
- margin: 10px 2px;
196
- line-height: 22px;
197
- }
198
-
199
- .sputnik-plugin-actions .button {
200
- display: inline-block;
201
- }
202
-
203
- .sputnik-plugin-actions .status {
204
- float: right;
205
- }
206
-
207
- .sputnik-plugin .sputnik-card {
208
- -o-transition: 0.4s;
209
- -moz-transition: 0.4s;
210
- -webkit-transition: 0.4s;
211
- }
212
-
213
- .sputnik-plugin .sputnik-plugin-thumb img {
214
- display: table-cell;
215
- border: 1px solid #cfcfcf;
216
- box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.22);
217
- }
218
-
219
- .sputnik-plugin.has-thumb .sputnik-plugin-thumb {
220
- margin-top: 0;
221
- }
222
-
223
- .sputnik-button {
224
- background: rgb(215, 215, 215);
225
- background: rgba(255, 255, 255, 0.5);
226
- background: -moz-linear-gradient(
227
- center top, rgba(255, 255, 255, 0.5) 0pt,
228
- rgba(235, 235, 235, 0.5) 50%,
229
- rgba(215, 215, 215, 0.5) 52%,
230
- rgba(240, 240, 240, 0.5) 100%)
231
- repeat scroll 0 0 transparent;
232
- background: -webkit-gradient(
233
- linear, left top, left bottom,
234
- color-stop(0, rgba(255, 255, 255, 0.5)),
235
- color-stop(0.5, rgba(235, 235, 235, 0.5)),
236
- color-stop(0.52, rgba(215, 215, 215, 0.5)),
237
- color-stop(1, rgba(240, 240, 240, 0.5)))
238
- repeat scroll 0 0 transparent;
239
-
240
- border: 1px solid rgba(165, 175, 185, 0.75);
241
- box-shadow: 0 0 2px rgba(255, 255, 255, 0.65) inset;
242
- color: #000;
243
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
244
- padding: 4px 12px;
245
- border-radius: 3px;
246
- margin-bottom: 1.3em;
247
- cursor: pointer;
248
- display: inline-block;
249
- text-decoration: none;
250
- }
251
-
252
- .sputnik-button:hover {
253
- color: #000;
254
- }
255
-
256
- .sputnik-button.buy, .sputnik-button.install {
257
- background: #55a802 55%;
258
- background: -moz-linear-gradient(center top, #93c85e 30%, #55a802 55%) repeat scroll 0 0 transparent;
259
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0.3, #93c85e), color-stop(0.55, #55a802)) repeat scroll 0 0 transparent;
260
- border-color: #3A7404;
261
- color: #fff;
262
- text-shadow: 0 -1px 0 #3a7404;
263
- }
264
-
265
- .sputnik-button.disabled {
266
- border: 1px solid rgba(165, 175, 185, 0.5);
267
- cursor: default;
268
- color: #888;
269
- }
270
-
271
- .sputnik-button span {
272
- border-right: 1px solid rgba(255, 255, 255, 0.3);
273
- padding-right: 6px;
274
- margin-right: 5px;
275
- display: inline-block;
276
- }
 
 
 
 
 
 
 
277
 
278
  /* iframed windows */
279
  .toplevel_page_sputnik #TB_iframeContent {
@@ -284,166 +302,160 @@ body.wpsc-product_page_sputnik #TB_iframeContent {
284
  }
285
 
286
  #sputnik-plugin-information {
 
287
  min-height: 100%;
288
  margin: 0;
289
  padding: 0;
290
  }
291
 
292
- #sputnik-plugin-information #plugin-information-header {
293
- margin: 0;
294
- padding: 0 5px;
295
- font-weight: bold;
296
- position: relative;
297
- height: auto;
298
- border: 0;
299
- background: transparent;
300
- }
301
-
302
- #sputnik-plugin-information ul#sidemenu {
303
- font-weight: normal;
304
- margin: 0;
305
- padding: 0;
306
- float: none;
307
- }
308
-
309
- #sputnik-plugin-information #sidemenu li {
310
- display: block;
311
- text-align: left;
312
- }
313
-
314
- #sputnik-plugin-information #sidemenu a {
315
- color: #ddd;
316
- background: transparent;
317
- border: none;
318
- float: none;
319
- padding: 0;
320
- }
321
-
322
- #sputnik-plugin-information #sidemenu a.current {
323
- color: #fff;
324
- font-weight: bold;
325
- }
326
-
327
- #sputnik-plugin-information .mainheader {
328
- }
329
-
330
- /* Install sidemenu */
331
- #sputnik-plugin-information p.action-button {
332
- width: 100%;
333
- padding-bottom: 0;
334
- margin-bottom: 10px;
335
- margin-top: 10px;
336
- -webkit-border-top-left-radius: 3px;
337
- -webkit-border-bottom-left-radius: 3px;
338
- border-top-left-radius: 3px;
339
- border-bottom-left-radius: 3px;
340
- }
341
-
342
- #sputnik-plugin-information .action-button a {
343
- text-align: center;
344
- font-weight: bold;
345
- text-decoration: none;
346
- display: block;
347
- line-height: 2em;
348
- }
349
-
350
- #sputnik-plugin-information #section-header h2 {
351
- clear: none !important;
352
- margin-right: 200px;
353
- }
354
-
355
- #sputnik-plugin-information .fyi {
356
- position: fixed;
357
- margin: 0;
358
- padding: 0 10px;
359
- width: 225px;
360
- height: 100%;
361
- background-color: #333;
362
- color: #aaa;
363
- }
364
-
365
- #sputnik-plugin-information .fyi a {
366
- color: #fff;
367
- }
368
-
369
- #sputnik-plugin-information .fyi h1 {
370
- font-size: 1.6em;
371
- margin-bottom: 0;
372
- margin-right: 0;
373
- padding: 10px 0;
374
- }
375
-
376
- #sputnik-plugin-information .fyi h2.mainheader {
377
- display: none;
378
- }
379
-
380
- #sputnik-plugin-information .fyi ul {
381
- padding: 10px 5px 10px 7px;
382
- margin: 0;
383
- list-style: none;
384
- -webkit-border-bottom-left-radius: 3px;
385
- border-bottom-left-radius: 3px;
386
- }
387
-
388
- #sputnik-plugin-information .fyi li {
389
- margin-right: 0;
390
- }
391
-
392
- #sputnik-plugin-information .fyi strong {
393
- color: #bbb;
394
- }
395
-
396
- #sputnik-plugin-information #section-holder {
397
- padding: 10px;
398
- margin: 0 0 0 255px;
399
- }
400
-
401
- #sputnik-plugin-information #section-holder img {
402
- max-width: 100%;
403
- }
404
-
405
- #sputnik-plugin-information .section ul,
406
- #sputnik-plugin-information .section ol {
407
- margin-left: 16px;
408
- list-style-type: square;
409
- list-style-image: none;
410
- }
411
-
412
- #sputnik-plugin-information #section-screenshots ol {
413
- list-style: none;
414
- margin: 0;
415
- text-align: center;
416
- }
417
-
418
- #sputnik-plugin-information #section-screenshots li {
419
- margin-bottom: 18px;
420
- }
421
-
422
- #sputnik-plugin-information #section-screenshots li img {
423
- vertical-align: text-top;
424
- max-width: 100%;
425
- width: auto;
426
- height: auto;
427
- border: 1px solid #ccc;
428
- padding: 7px;
429
- }
430
-
431
- #sputnik-plugin-information #section-screenshots li p {
432
- font-style: italic;
433
- padding-left: 20px;
434
- padding-bottom: 2em;
435
- }
436
-
437
- #sputnik-plugin-information #section-screenshots ol,
438
- #sputnik-plugin-information .updated,
439
- #sputnik-plugin-information pre {
440
- margin-right: 0;
441
- }
442
-
443
- #sputnik-plugin-information pre {
444
- padding: 7px;
445
- overflow: auto;
446
- }
447
 
448
  /* Account page */
449
  #sputnik-page .account-card {
@@ -454,27 +466,27 @@ body.wpsc-product_page_sputnik #TB_iframeContent {
454
  padding: 10px;
455
  margin-top: 20px;
456
  }
457
- #sputnik-page .account-card .block {
458
- width: 50%;
459
- max-width: 400px;
460
- float: left;
461
- }
462
- #sputnik-page .account-card img {
463
- float: left;
464
- background: #fff;
465
- padding: 5px;
466
- border: 1px solid #ddd;
467
- }
468
- #sputnik-page .account-card h3, #sputnik-page .account-card p {
469
- margin-left: 130px;
470
- }
471
- #sputnik-page .account-card .lead-in {
472
- margin-top: 0.5em;
473
- margin-bottom: 0;
474
- }
475
- #sputnik-page .account-card .stat strong {
476
- font-size: 16px;
477
- }
478
  #sputnik-page table.widefat tr td {
479
  vertical-align: middle;
480
- }
1
+ #screen-options-link-wrap, #contextual-help-link-wrap {
2
+ }
3
+ #screen-meta a.show-settings {
4
+
5
+ }
6
+
7
+ /*#sputnik-footer {
8
+ background: url("header.png") repeat scroll 0 0 #AB0108;
9
+ background: rgba(0, 0, 255, 0.1);
10
+ height: 50px;
11
+ margin: 25px -15px 10px 0;
12
+ padding: 0 24px 0 10px;
13
+
14
+ color: rgba(255, 255, 255, 0.49);
15
+ font-size: 13px;
16
+ line-height: 50px;
17
+
18
+ border-radius: 8px 0 0 8px;
19
+ -moz-border-radius: 8px 0 0 8px;
20
+ -webkit-border-radius: 8px 0 0 8px;
21
+ }*/
22
+
23
+ #sputnik-page .sep {
24
+ margin: 0 12px 0 0;
25
+ font-size: 23px;
26
+ }
27
+
28
+ #sputnik-page h3 {
29
+ color: #999;
30
+ font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
31
+ font-size: 23px;
32
+ line-height: 29px;
33
+ font-weight: normal;
34
+ margin: 0 0 0 40px;
35
+ padding: 9px 15px 4px 0;
36
+ }
37
+
38
+ #sputnik-page .account-link {
39
+ margin-right: 8px;
40
+ }
41
+
42
+ #sputnik-page .aux-links {
43
+ float: right;
44
+ clear: both;
45
+ margin: 10px;
46
+ }
47
+ #sputnik-header p {
48
+ margin-top: 0;
49
+ margin-bottom: 0;
50
+ }
51
+
52
+ #sputnik-header a, #sputnik-footer a {
53
+ /*color: rgba(255, 255, 255, 0.78);*/
54
+ text-decoration: none;
55
+ }
56
+ #sputnik-header a:hover, #sputnik-footer a:hover {
57
+ color: #f00;
58
+ }
59
+
60
+ #sputnik-footer {
61
+ margin-top: 10px;
62
+ text-align: center;
63
+ border-top: 1px solid #DFDFDF;
64
+
65
+ overflow: auto;
66
+ padding: 10px 20px;
67
+
68
+ background: #fcfcfc;
69
+ background: -moz-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
70
+ background: -webkit-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
71
+ background: -ms-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
72
+ background: -o-radial-gradient(top, #F0F0F0, #FFFFFF 80%);
73
+ background: radial-gradient(top, #F0F0F0, #FFFFFF 80%);
74
+ }
75
+ #sputnik-footer .logo-holder {
76
+ float: left;
77
+ }
78
+ #sputnik-footer .renku-logo {
79
+ background: url("logo.png") no-repeat scroll center center transparent;
80
+ text-indent: -9999px;
81
+ width: 47px;
82
+ height: 22px;
83
+ display: block;
84
+ }
85
+ #sputnik-footer nav {
86
+ float: right;
87
+ }
88
 
89
  #sputnik-auth, #sputnik-page .connect-error {
90
  font-size: 20px;
91
+ font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
92
  line-height: 1.6em;
93
  color: #777;
94
  max-width: 500px;
95
  }
96
+ #sputnik-auth .buttons {
97
+ text-align: right;
98
+ }
99
+ #sputnik-auth .button {
100
+ font-size: 15px !important;
101
+ }
102
 
103
+ #sputnik-page .connect-error {
104
+ clear: both;
105
+ }
 
 
 
 
 
 
 
 
 
106
  #sputnik-page a.view-as-list,
107
  #sputnik-page a.view-as-grid {
108
  background-image: url('icons.png'), linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
112
  background-image: url('icons.png'), -ms-linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
113
  background-repeat: no-repeat, repeat-x, repeat-x, repeat-x, repeat-x;
114
  }
 
115
  #sputnik-page a.view-as-list {
116
  background-position: right 2px, left top;
117
  padding: 6px 32px 6px 6px;
118
  }
 
119
  #sputnik-page a.view-as-grid {
120
  background-position: 31px -69px, left top;
121
  padding: 7px 32px 6px 7px;
122
  }
 
123
  #sputnik-page .tablenav-pages {
124
  display: none;
125
  }
 
126
  #sputnik-page .tablenav {
127
  margin-top: 0;
128
  height: auto;
129
  position: relative;
130
+ bottom: 18px;
131
  }
 
132
  .grid-view {
133
  margin: 0 0 15px;
134
  clear: both;
135
+ overflow: auto;
136
  }
137
 
138
  /* Buy buttons */
152
  }
153
 
154
  .sputnik-plugin {
155
+ width: 200px;
156
  padding: 0;
157
+ margin: 10px 25px 5px 0;
158
  float: left;
159
+ height: 244px;
160
+ }
161
+ .sputnik-card {
162
+ width: 200px;
163
+ height: 234px;
164
+ border: 1px solid #cfcfcf;
165
+ box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.22);
166
+
167
+ position: relative;
168
+ overflow: hidden;
169
+ }
170
+ .sputnik-plugin-details {
171
+ height: 214px;
172
+ width: 176px;
173
+ background: #F9F9F9;
174
+ padding: 10px 12px;
175
+ overflow: hidden;
176
+ position: absolute;
177
+ }
178
+ .sputnik-plugin-details h4 {
179
+ margin: 0 0 14px;
180
+ width: 75%;
181
+ }
182
+ .sputnik-plugin-details .footer {
183
+ position: absolute;
184
+ width: 176px;
185
+ bottom: 0;
186
+ right: 12px;
187
+ height: 20px;
188
+ padding: 8px 0;
189
+ background: #F9F9F9;
190
+ line-height: 19px;
191
+ }
192
+ .sputnik-plugin-details .price {
193
+ position: absolute;
194
+ right: 12px;
195
+ top: 10px;
196
+ }
197
+ .sputnik-plugin-details .footer .star-holder {
198
+ position: absolute;
199
+ right: 0;
200
+ }
201
+ .sputnik-plugin-actions {
202
+ width: 200px;
203
+ margin: 10px 2px;
204
+ line-height: 22px;
205
+ }
206
+ .sputnik-plugin-actions .button {
207
+ display: inline-block;
208
+ }
209
+ .sputnik-plugin-actions .status {
210
+ float: right;
211
+ }
212
+
213
+ .sputnik-plugin .sputnik-card {
214
+ -o-transition: 0.4s;
215
+ -moz-transition: 0.4s;
216
+ -webkit-transition: 0.4s;
217
+ }
218
+ .sputnik-plugin .sputnik-plugin-thumb {
219
+ display: table-cell;
220
+ text-align: center;
221
+ vertical-align: middle;
222
+ width: 200px;
223
+ height: 200px;
224
+ margin-top: 25px;
225
+ }
226
+ .sputnik-plugin.has-thumb .sputnik-plugin-thumb {
227
+ margin-top: 0;
228
+ }
229
+ .sputnik-plugin .sputnik-plugin-thumb img {
230
+ max-width: 100%;
231
+ max-height: 100%;
232
+ }
233
+ .sputnik-plugin .sputnik-plugin-details {
234
+ top: 200px;
235
+ background: rgba(250,250,250,0.7);
236
+ -o-transition: 0.4s;
237
+ -moz-transition: 0.4s;
238
+ -webkit-transition: 0.4s;
239
+ }
240
+ .sputnik-plugin:hover .sputnik-plugin-details {
241
+ top: 0;
242
+ background: #F9F9F9;
243
+ }
244
+
245
+ .sputnik-button {
246
+ background: rgb(215, 215, 215);
247
+ background: rgba(255, 255, 255, 0.5);
248
+ background: -moz-linear-gradient(
249
+ center top, rgba(255, 255, 255, 0.5) 0pt,
250
+ rgba(235, 235, 235, 0.5) 50%,
251
+ rgba(215, 215, 215, 0.5) 52%,
252
+ rgba(240, 240, 240, 0.5) 100%)
253
+ repeat scroll 0 0 transparent;
254
+ background: -webkit-gradient(
255
+ linear, left top, left bottom,
256
+ color-stop(0, rgba(255, 255, 255, 0.5)),
257
+ color-stop(0.5, rgba(235, 235, 235, 0.5)),
258
+ color-stop(0.52, rgba(215, 215, 215, 0.5)),
259
+ color-stop(1, rgba(240, 240, 240, 0.5)))
260
+ repeat scroll 0 0 transparent;
261
+
262
+ border: 1px solid rgba(165, 175, 185, 0.75);
263
+ box-shadow: 0 0 2px rgba(255, 255, 255, 0.65) inset;
264
+ color: #000;
265
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
266
+ padding: 4px 12px;
267
+ border-radius: 3px;
268
+ margin-bottom: 1.3em;
269
+ cursor: pointer;
270
+ display: inline-block;
271
+ text-decoration: none;
272
+ }
273
+ .sputnik-button:hover {
274
+ color: #000;
275
+ }
276
+ .sputnik-button.buy, .sputnik-button.install {
277
+ background: #55a802 55%;
278
+ background: -moz-linear-gradient(center top, #93c85e 30%, #55a802 55%) repeat scroll 0 0 transparent;
279
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0.3, #93c85e), color-stop(0.55, #55a802)) repeat scroll 0 0 transparent;
280
+ border-color: #3A7404;
281
+ color: #fff;
282
+ text-shadow: 0 -1px 0 #3a7404;
283
+ }
284
+ .sputnik-button.disabled {
285
+ border: 1px solid rgba(165, 175, 185, 0.5);
286
+ cursor: default;
287
+ color: #888;
288
+ }
289
+ .sputnik-button span {
290
+ border-right: 1px solid rgba(255, 255, 255, 0.3);
291
+ padding-right: 6px;
292
+ margin-right: 5px;
293
+ display: inline-block;
294
+ }
295
 
296
  /* iframed windows */
297
  .toplevel_page_sputnik #TB_iframeContent {
302
  }
303
 
304
  #sputnik-plugin-information {
305
+ background: url('fyi-back.png') repeat-y #fff;
306
  min-height: 100%;
307
  margin: 0;
308
  padding: 0;
309
  }
310
 
311
+ #sputnik-plugin-information #plugin-information-header {
312
+ margin: 0;
313
+ padding: 0 5px;
314
+ font-weight: bold;
315
+ position: relative;
316
+ height: auto;
317
+ border: 0;
318
+ background: transparent;
319
+ }
320
+ #sputnik-plugin-information ul#sidemenu {
321
+ font-weight: normal;
322
+ margin: 0;
323
+ padding: 0;
324
+ float: none;
325
+ }
326
+ #sputnik-plugin-information #sidemenu li {
327
+ display: block;
328
+ text-align: left;
329
+ }
330
+ #sputnik-plugin-information #sidemenu a {
331
+ color: #ddd;
332
+ background: transparent;
333
+ border: none;
334
+ float: none;
335
+ padding: 0;
336
+ }
337
+ #sputnik-plugin-information #sidemenu a.current {
338
+ color: #fff;
339
+ font-weight: bold;
340
+ }
341
+
342
+ #sputnik-plugin-information .mainheader {
343
+ }
344
+
345
+ /* Install sidemenu */
346
+ #sputnik-plugin-information p.action-button {
347
+ width: 100%;
348
+ padding-bottom: 0;
349
+ margin-bottom: 10px;
350
+ margin-top: 10px;
351
+ -webkit-border-top-left-radius: 3px;
352
+ -webkit-border-bottom-left-radius: 3px;
353
+ border-top-left-radius: 3px;
354
+ border-bottom-left-radius: 3px;
355
+ }
356
+
357
+ #sputnik-plugin-information .action-button a {
358
+ text-align: center;
359
+ font-weight: bold;
360
+ text-decoration: none;
361
+ display: block;
362
+ line-height: 2em;
363
+ }
364
+
365
+ #sputnik-plugin-information #section-header h2 {
366
+ clear: none !important;
367
+ margin-right: 200px;
368
+ }
369
+
370
+ #sputnik-plugin-information .fyi {
371
+ position: fixed;
372
+ margin: 0;
373
+ padding: 0 10px;
374
+ width: 225px;
375
+ height: 100%;
376
+ background-color: #333;
377
+ color: #aaa;
378
+ }
379
+
380
+ #sputnik-plugin-information .fyi a {
381
+ color: #fff;
382
+ }
383
+
384
+ #sputnik-plugin-information .fyi h1 {
385
+ font-size: 1.6em;
386
+ margin-bottom: 0;
387
+ margin-right: 0;
388
+ padding: 10px 0;
389
+ }
390
+
391
+ #sputnik-plugin-information .fyi h2.mainheader {
392
+ display: none;
393
+ }
394
+
395
+ #sputnik-plugin-information .fyi ul {
396
+ padding: 10px 5px 10px 7px;
397
+ margin: 0;
398
+ list-style: none;
399
+ -webkit-border-bottom-left-radius: 3px;
400
+ border-bottom-left-radius: 3px;
401
+ }
402
+
403
+ #sputnik-plugin-information .fyi li {
404
+ margin-right: 0;
405
+ }
406
+
407
+ #sputnik-plugin-information .fyi strong {
408
+ color: #bbb;
409
+ }
410
+
411
+ #sputnik-plugin-information #section-holder {
412
+ padding: 10px;
413
+ margin-left: 260px;
414
+ margin-top: 0;
415
+ }
416
+
417
+ #sputnik-plugin-information .section ul,
418
+ #sputnik-plugin-information .section ol {
419
+ margin-left: 16px;
420
+ list-style-type: square;
421
+ list-style-image: none;
422
+ }
423
+
424
+ #sputnik-plugin-information #section-screenshots ol {
425
+ list-style: none;
426
+ margin: 0;
427
+ text-align: center;
428
+ }
429
+
430
+ #sputnik-plugin-information #section-screenshots li {
431
+ margin-bottom: 18px;
432
+ }
433
+
434
+ #sputnik-plugin-information #section-screenshots li img {
435
+ vertical-align: text-top;
436
+ max-width: 100%;
437
+ width: auto;
438
+ height: auto;
439
+ border: 1px solid #ccc;
440
+ padding: 7px;
441
+ }
442
+
443
+ #sputnik-plugin-information #section-screenshots li p {
444
+ font-style: italic;
445
+ padding-left: 20px;
446
+ padding-bottom: 2em;
447
+ }
448
+
449
+ #sputnik-plugin-information #section-screenshots ol,
450
+ #sputnik-plugin-information .updated,
451
+ #sputnik-plugin-information pre {
452
+ margin-right: 0;
453
+ }
454
+
455
+ #sputnik-plugin-information pre {
456
+ padding: 7px;
457
+ overflow: auto;
458
+ }
 
 
 
 
 
 
 
459
 
460
  /* Account page */
461
  #sputnik-page .account-card {
466
  padding: 10px;
467
  margin-top: 20px;
468
  }
469
+ #sputnik-page .account-card .block {
470
+ width: 50%;
471
+ max-width: 400px;
472
+ float: left;
473
+ }
474
+ #sputnik-page .account-card img {
475
+ float: left;
476
+ background: #fff;
477
+ padding: 5px;
478
+ border: 1px solid #ddd;
479
+ }
480
+ #sputnik-page .account-card h3, #sputnik-page .account-card p {
481
+ margin-left: 130px;
482
+ }
483
+ #sputnik-page .account-card .lead-in {
484
+ margin-top: 0.5em;
485
+ margin-bottom: 0;
486
+ }
487
+ #sputnik-page .account-card .stat strong {
488
+ font-size: 16px;
489
+ }
490
  #sputnik-page table.widefat tr td {
491
  vertical-align: middle;
492
+ }
wpsc-components/marketplace-core-v1/static/admin.js CHANGED
@@ -10,10 +10,8 @@ jQuery(document).ready(function($) {
10
  dg.startFlow(sputnikL10n.buy_href);
11
  }
12
  $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik-account"]').parent('li').remove();
13
-
14
  $('.grid-view').masonry({
15
- selector: '.plugin',
16
- gutter: 15
17
  });
18
 
19
  $('#rateme').mousemove(function (event) {
@@ -23,7 +21,7 @@ jQuery(document).ready(function($) {
23
  $('#rateme .star-rating').width($(this).data('rating') * 20);
24
  }).click(function (event) {
25
  var score = Sputnik.rating_from_event(event);
26
- jQuery.post( ajaxurl, {
27
  action: 'sputnik_rate',
28
  rating: score,
29
  product: $(this).data('productid')
@@ -38,8 +36,8 @@ jQuery(document).ready(function($) {
38
 
39
  var href = $(this).attr('href');
40
  var dim = Sputnik.window_dimensions();
41
- href += '&width=' + Math.min(Math.max(dim[0] - 50, 300), 800)
42
- + '&height=' + Math.min(Math.max(dim[1] - 100, 250), 600);
43
  tb_show('', href);
44
  this.blur();
45
 
10
  dg.startFlow(sputnikL10n.buy_href);
11
  }
12
  $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik-account"]').parent('li').remove();
 
13
  $('.grid-view').masonry({
14
+ selector: '.plugin'
 
15
  });
16
 
17
  $('#rateme').mousemove(function (event) {
21
  $('#rateme .star-rating').width($(this).data('rating') * 20);
22
  }).click(function (event) {
23
  var score = Sputnik.rating_from_event(event);
24
+ jQuery.post(ajaxurl, {
25
  action: 'sputnik_rate',
26
  rating: score,
27
  product: $(this).data('productid')
36
 
37
  var href = $(this).attr('href');
38
  var dim = Sputnik.window_dimensions();
39
+ href += '&width=' + Math.min(Math.max(dim[0] - 50, 300), 700)
40
+ + '&height=' + Math.min(Math.max(dim[1] - 100, 250), 550);
41
  tb_show('', href);
42
  this.blur();
43
 
wpsc-components/marketplace-core-v1/static/jquery.masonry.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jQuery Masonry v2.0.110901
3
+ * A dynamic layout plugin for jQuery
4
+ * The flip-side of CSS Floats
5
+ * http://masonry.desandro.com
6
+ *
7
+ * Licensed under the MIT license.
8
+ * Copyright 2011 David DeSandro
9
+ */
10
+ (function(a,b,c){var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()};var f=["position","height"];b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[],this.reloadItems();var d=this.element[0].style;this.originalStyle={};for(var e=0,g=f.length;e<g;e++){var h=f[e];this.originalStyle[h]=d[h]||""}this.element.css({position:"relative"}),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={};var i=b(document.createElement("div"));this.element.prepend(i),this.offset.y=Math.round(i.position().top),this.options.isRTL?(i.css({"float":"right",display:"inline-block"}),this.offset.x=Math.round(this.element.outerWidth()-i.position().left)):this.offset.x=Math.round(i.position().left),i.remove();var j=this;setTimeout(function(){j.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){j.resize()})},_init:function(a){this._getColumns("masonry"),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,c){var d,e,f,g,h,i;for(var j=0,k=a.length;j<k;j++){d=b(a[j]),e=Math.ceil(d.outerWidth(!0)/this.columnWidth),e=Math.min(e,this.cols);if(e===1)this._placeBrick(d,this.colYs);else{f=this.cols+1-e,g=[];for(i=0;i<f;i++)h=this.colYs.slice(i,i+e),g[i]=Math.max.apply(Math,h);this._placeBrick(d,g)}}var l={};l.height=Math.max.apply(Math,this.colYs)-this.offset.y,this.options.isFitWidth&&(l.width=this.cols*this.columnWidth-this.options.gutterWidth),this.styleQueue.push({$el:this.element,style:l});var m=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",n=this.options.animationOptions,o;for(j=0,k=this.styleQueue.length;j<k;j++)o=this.styleQueue[j],o.$el[m](o.style,n);this.styleQueue=[],c&&c.call(a),this.isLaidOut=!0},_getColumns:function(){var a=this.options.isFitWidth?this.element.parent():this.element,b=a.width();this.columnWidth=this.options.columnWidth||this.$bricks.outerWidth(!0)||b,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((b+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(a,b){var c=Math.min.apply(Math,b),d=0;for(var e=0,f=b.length;e<f;e++)if(b[e]===c){d=e;break}var g={top:c};g[this.horizontalDirection]=this.columnWidth*d+this.offset.x,this.styleQueue.push({$el:a,style:g});var h=c+a.outerHeight(!0),i=this.cols+1-f;for(e=0;e<i;e++)this.colYs[d+e]=h},resize:function(){var a=this.cols;this._getColumns("masonry"),this.cols!==a&&this._reLayout()},_reLayout:function(a){var b=this.cols;this.colYs=[];while(b--)this.colYs.push(this.offset.y);this.layout(this.$bricks,a)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(a){this.reloadItems(),this._init(a)},appended:function(a,b,c){if(b){this._filterFindBricks(a).css({top:this.element.height()});var d=this;setTimeout(function(){d._appended(a,c)},1)}else this._appended(a,c)},_appended:function(a,b){var c=this._getBricks(a);this.$bricks=this.$bricks.add(c),this.layout(c,b)},remove:function(a){this.$bricks=this.$bricks.not(a),a.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var c=this.element[0].style;for(var d=0,e=f.length;d<e;d++){var g=f[d];c[g]=this.originalStyle[g]}this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),b(a).unbind(".masonry")}},b.fn.imagesLoaded=function(a){function h(){--e<=0&&this.src!==f&&(setTimeout(g),d.unbind("load error",h))}function g(){a.call(b,d)}var b=this,d=b.find("img").add(b.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";e||g(),d.bind("load error",h).each(function(){if(this.complete||this.complete===c){var a=this.src;this.src=f,this.src=a}});return b};var g=function(a){this.console&&console.error(a)};b.fn.masonry=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"masonry");if(!d)g("cannot call methods on masonry prior to initialization; attempted to call method '"+a+"'");else{if(!b.isFunction(d[a])||a.charAt(0)==="_"){g("no such method '"+a+"' for masonry instance");return}d[a].apply(d,c)}})}else this.each(function(){var c=b.data(this,"masonry");c?(c.option(a||{}),c._init()):b.data(this,"masonry",new b.Mason(a,this))});return this}})(window,jQuery);
wpsc-components/marketplace-core-v1/static/sputnik.css CHANGED
@@ -8,21 +8,23 @@ div.sputnik-message {
8
  padding: 1px 12px;
9
  position: relative;
10
  }
11
- div.sputnik-message p {
12
- padding: 2px;
13
- margin: 0.5em 0px;
14
- font-size: 14px;
15
- line-height: 1.5em;
16
- }
17
- div.sputnik-message .button {
18
- position: absolute;
19
- right: 12px;
20
- top: 10px;
21
- font-size: 20px;
22
- padding: 0px 15px 2px;
23
- line-height: 41px;
24
- height: 43px;
25
- }
 
 
26
  .sputnik-plugin-row-note {
27
  display: block;
28
  float: right;
8
  padding: 1px 12px;
9
  position: relative;
10
  }
11
+ div.sputnik-message p {
12
+ padding: 2px;
13
+ margin: 0.5em 0px;
14
+ font-size: 14px;
15
+ line-height: 1.5em;
16
+ }
17
+ div.sputnik-message .button {
18
+ position: absolute;
19
+ right: 12px;
20
+ top: 10px;
21
+ font-size: 20px;
22
+ padding: 0px 15px 2px;
23
+ line-height: 41px;
24
+ height: 43px;
25
+ }
26
+
27
+
28
  .sputnik-plugin-row-note {
29
  display: block;
30
  float: right;
wpsc-components/marketplace-core-v1/static/sputnik.js CHANGED
@@ -1,4 +1,5 @@
1
  jQuery(document).ready(function($) {
2
  $('.sputnik-message').insertAfter( $('div.wrap h2:first') );
 
3
  $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik-account"]').parent('li').remove();
4
  });
1
  jQuery(document).ready(function($) {
2
  $('.sputnik-message').insertAfter( $('div.wrap h2:first') );
3
+ //$('#menu-posts-wpsc-product').before('<li class="wp-not-current-submenu wp-menu-separator"><div class="separator"></div></li>');
4
  $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik-account"]').parent('li').remove();
5
  });
wpsc-components/merchant-core-v2/helpers/admin.php CHANGED
@@ -26,37 +26,6 @@ add_filter(
26
  2
27
  );
28
 
29
- /**
30
- * Filters deprecated gateways out of available gateways list.
31
- *
32
- * Only occurs if there is a 3.0 API replacement for the gateway and it is not currently active.
33
- * Note: Pro Hosted and Pro are not the same thing.
34
- *
35
- * @since 3.9.0
36
- *
37
- * @param array $gateways Original list of gateways.
38
- * @return array Modified list of gateways.
39
- */
40
- function wpsc_filter_deprecated_v2_gateways( $gateways ) {
41
-
42
- $deprecated_gateways = array(
43
- 'manual',
44
- 'paypal-pro',
45
- 'paypal-express-checkout'
46
- );
47
-
48
- // Loops through available gateways, checks if available gateway is both inactive and deprecated, and removes it.
49
- foreach ( $gateways as $index => $gateway ) {
50
- if ( in_array( $gateway['id'], $deprecated_gateways ) && ! in_array( $gateway['id'], get_option( 'custom_gateway_options', array() ) ) ) {
51
- unset( $gateways[ $index ] );
52
- }
53
- }
54
-
55
- return $gateways;
56
- }
57
-
58
- add_filter( 'wpsc_settings_get_gateways', 'wpsc_filter_deprecated_v2_gateways', 25 );
59
-
60
  function _wpsc_filter_merchant_v2_gateway_form( $form, $selected_gateway ) {
61
  global $nzshpcrt_gateways;
62
 
26
  2
27
  );
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  function _wpsc_filter_merchant_v2_gateway_form( $form, $selected_gateway ) {
30
  global $nzshpcrt_gateways;
31
 
wpsc-components/merchant-core-v2/helpers/checkout.php CHANGED
@@ -2,50 +2,24 @@
2
 
3
  add_filter( 'wpsc_get_gateway_list', '_wpsc_filter_merchant_v2_get_gateway_list' );
4
 
5
- /**
6
- * Get Gateway List
7
- *
8
- * HTML to display radio button list of payment gateways.
9
- *
10
- * @return string Payment gateways HTML.
11
- *
12
- * @uses apply_filters() Calls 'wpsc_gateway_image'.
13
- * @uses wpsc_have_gateways() Are there any gateways?
14
- * @uses wpsc_the_gateway() Setup gateway data.
15
- * @uses wpsc_gateway_name() Gateway display name.
16
- * @uses wpsc_gateway_internal_name() Gateway internal name.
17
- * @uses wpsc_gateway_is_checked() Gateway radio button checked attribute.
18
- * @uses wpsc_show_gateway_image() Show gateway image?
19
- * @uses wpsc_gateway_image_url() Gateway image URL
20
- * @uses wpsc_gateway_form_field_style() Adds class to show/hide fields based on selected gateway.
21
- * @uses wpsc_gateway_form_fields() Addition fields for the gateway.
22
- */
23
  function _wpsc_filter_merchant_v2_get_gateway_list() {
24
  ob_start();
25
- while ( wpsc_have_gateways() ) :
26
- wpsc_the_gateway();
27
- $gateway_name = wpsc_gateway_name();
28
- ?>
29
- <div class="custom_gateway <?php echo sanitize_html_class( wpsc_gateway_internal_name() ); ?>">
30
- <label><input type="radio" value="<?php echo wpsc_gateway_internal_name(); ?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway" />
31
- <?php if ( ! empty( $gateway_name ) ) { ?>
32
- <span class="custom_gateway_name"><?php echo $gateway_name; ?></span>
33
- <?php } ?>
34
- <?php
35
- if ( wpsc_show_gateway_image() ) :
36
- $gateway_image = '<img src="' . esc_url( wpsc_gateway_image_url() ) . '" alt="' . esc_attr( $gateway_name ) . '" class="custom_gateway_image" />';
37
  echo apply_filters( 'wpsc_gateway_image', $gateway_image, wpsc_gateway_internal_name() );
38
- endif;
39
- ?>
40
  </label>
 
41
  <?php if ( wpsc_gateway_form_fields() ) : ?>
42
- <table class="wpsc_checkout_table <?php echo wpsc_gateway_form_field_style(); ?>">
43
- <?php echo wpsc_gateway_form_fields(); ?>
44
  </table>
45
  <?php endif; ?>
46
  </div>
47
- <?php
48
- endwhile;
49
  return ob_get_clean();
50
  }
51
 
2
 
3
  add_filter( 'wpsc_get_gateway_list', '_wpsc_filter_merchant_v2_get_gateway_list' );
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  function _wpsc_filter_merchant_v2_get_gateway_list() {
6
  ob_start();
7
+ while ( wpsc_have_gateways() ) : wpsc_the_gateway(); ?>
8
+ <div class="custom_gateway">
9
+ <label><input type="radio" value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name(); ?>
10
+ <?php if ( wpsc_show_gateway_image() ):
11
+ $gateway_image = '<img src="' . esc_url( wpsc_gateway_image_url() ) . '" alt="' . esc_attr( wpsc_gateway_name() ) . '" style="position:relative; top:5px;" />';
 
 
 
 
 
 
 
12
  echo apply_filters( 'wpsc_gateway_image', $gateway_image, wpsc_gateway_internal_name() );
13
+ endif; ?>
 
14
  </label>
15
+
16
  <?php if ( wpsc_gateway_form_fields() ) : ?>
17
+ <table class='wpsc_checkout_table <?php echo wpsc_gateway_form_field_style();?>'>
18
+ <?php echo wpsc_gateway_form_fields();?>
19
  </table>
20
  <?php endif; ?>
21
  </div>
22
+ <?php endwhile;
 
23
  return ob_get_clean();
24
  }
25
 
wpsc-components/merchant-core-v2/helpers/gateways.php CHANGED
@@ -67,12 +67,7 @@ function wpsc_gateway_image_url(){
67
 
68
  /**
69
  * Return the current gateway's name.
70
- *
71
- * @return string The current gateway's name.
72
- *
73
- * @uses $wpsc_gateway Global array of gateways.
74
- * @uses wpsc_show_gateway_image() Checks if gateway has an image.
75
- * @uses apply_filters() Calls 'wpsc_gateway_name'.
76
  */
77
  function wpsc_gateway_name() {
78
  global $wpsc_gateway;
@@ -80,55 +75,36 @@ function wpsc_gateway_name() {
80
 
81
  $payment_gateway_names = get_option( 'payment_gateway_names' );
82
 
83
- // Use gateway internal name if set
84
- if ( isset( $payment_gateway_names[ $wpsc_gateway->gateway['internalname'] ] ) && ( $payment_gateway_names[ $wpsc_gateway->gateway['internalname'] ] != '' || wpsc_show_gateway_image() ) ) {
85
- $display_name = $payment_gateway_names[ $wpsc_gateway->gateway['internalname'] ];
86
- }
87
-
88
- $display_name = apply_filters( 'wpsc_gateway_name', $display_name, $wpsc_gateway->gateway );
89
-
90
- // If no display name or image, use default
91
- if ( $display_name == '' && ! wpsc_show_gateway_image() ) {
92
- $display_name = __( 'Credit Card', 'wpsc' );
93
- }
94
-
95
- return $display_name;
96
- }
97
-
98
- /**
99
- * WPSC Default Gateway Name Filter
100
- *
101
- * This filter overrides the display name of a gateway
102
- *
103
- * @param string $display_name Gateway display name.
104
- * @param array $gateway Gateway details.
105
- * @return string Filtered gateway name.
106
- *
107
- * @uses wpsc_show_gateway_image() Checks if gateway has an image.
108
- */
109
- function _wpsc_gateway_name_filter( $display_name, $gateway ) {
110
- if ( empty( $display_name ) && isset( $gateway['payment_type'] ) && ! wpsc_show_gateway_image() ) {
111
- switch ( $gateway['payment_type'] ) {
112
- case 'paypal':
113
- case 'paypal_pro':
114
- case 'wpsc_merchant_paypal_pro';
115
  $display_name = __( 'PayPal', 'wpsc' );
116
  break;
117
 
118
- case 'manual_payment':
119
  $display_name = __( 'Manual Payment', 'wpsc' );
120
  break;
121
 
122
- case 'credit_card':
 
 
 
 
123
  default:
124
  $display_name = __( 'Credit Card', 'wpsc' );
125
  break;
126
  }
127
  }
 
 
 
128
  return $display_name;
129
  }
130
 
131
- add_filter( 'wpsc_gateway_name', '_wpsc_gateway_name_filter', 10, 2 );
132
 
133
  /**
134
  * Return the current gateway's internal name
67
 
68
  /**
69
  * Return the current gateway's name.
70
+ * @return string The current gateway's name.
 
 
 
 
 
71
  */
72
  function wpsc_gateway_name() {
73
  global $wpsc_gateway;
75
 
76
  $payment_gateway_names = get_option( 'payment_gateway_names' );
77
 
78
+ if ( isset( $payment_gateway_names[$wpsc_gateway->gateway['internalname']] ) && ( $payment_gateway_names[$wpsc_gateway->gateway['internalname']] != '' || wpsc_show_gateway_image() ) ) {
79
+ $display_name = $payment_gateway_names[$wpsc_gateway->gateway['internalname']];
80
+ } elseif ( isset( $wpsc_gateway->gateway['payment_type'] ) ) {
81
+ switch ( $wpsc_gateway->gateway['payment_type'] ) {
82
+ case "paypal":
83
+ case "paypal_pro":
84
+ case "wpsc_merchant_paypal_pro";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  $display_name = __( 'PayPal', 'wpsc' );
86
  break;
87
 
88
+ case "manual_payment":
89
  $display_name = __( 'Manual Payment', 'wpsc' );
90
  break;
91
 
92
+ case "google_checkout":
93
+ $display_name = __( 'Google Wallet', 'wpsc' );
94
+ break;
95
+
96
+ case "credit_card":
97
  default:
98
  $display_name = __( 'Credit Card', 'wpsc' );
99
  break;
100
  }
101
  }
102
+ if ( $display_name == '' && !wpsc_show_gateway_image() ) {
103
+ $display_name = __( 'Credit Card', 'wpsc' );
104
+ }
105
  return $display_name;
106
  }
107
 
 
108
 
109
  /**
110
  * Return the current gateway's internal name
wpsc-components/merchant-core-v3/classes/http.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
-
3
- require_once( WPSC_MERCHANT_V3_PATH . '/gateways/php-merchant/common/http.php' );
4
-
5
- class WPSC_Payment_Gateway_HTTP extends PHP_Merchant_HTTP {
6
- protected function request( $url, $fields = '', $args = array() ) {
7
- $defaults = array(
8
- 'follow' => true,
9
- 'method' => 'GET',
10
- 'ssl_verify' => false,
11
- 'body' => '',
12
- 'httpversion' => '1.1',
13
- 'timeout' => 60,
14
- );
15
-
16
- $args = array_merge( $defaults, $args );
17
- $args['body'] = $fields;
18
-
19
- $response = wp_remote_request( $url, $args );
20
-
21
- if ( is_wp_error( $response ) )
22
- throw new PHP_Merchant_Exception( PHPME_HTTP_REQUEST_FAILED, $response->get_error_message() );
23
-
24
- return $response['body'];
25
- }
26
-
27
- public function post( $url, $fields = '', $args = array() ) {
28
- $args['method'] = 'POST';
29
- return $this->request( esc_url_raw( $url ), $fields, $args );
30
- }
31
-
32
- public function get( $url, $fields = '', $args = array() ) {
33
- return $this->request( esc_url_raw( $url ), $fields, $args );
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/classes/payment-gateway.php DELETED
@@ -1,639 +0,0 @@
1
- <?php
2
-
3
- final class WPSC_Payment_Gateways {
4
-
5
- /**
6
- * Contain a key-value array of gateway names and gateway class names
7
- *
8
- * @access private
9
- * @static
10
- * @var array
11
- * @since 3.9
12
- */
13
- private static $gateways = array();
14
-
15
- /**
16
- * Contain an array of payment gateway objects
17
- *
18
- * @access private
19
- * @static
20
- * @var array
21
- * @since 3.9
22
- */
23
- private static $instances = array();
24
-
25
- /**
26
- * Contains the cached metadata of the registered payment gateways, so that the
27
- * plugin doesn't have to load the gateway's files to determine its metadata
28
- *
29
- * @access private
30
- * @static
31
- *
32
- * @since 3.9
33
- *
34
- * @var array
35
- */
36
- private static $payment_gateway_cache = array();
37
-
38
- /**
39
- * Contains the names of active gateways that use this API
40
- *
41
- * @access private
42
- * @static
43
- * @since 3.9
44
- *
45
- * @var array
46
- */
47
- private static $active_gateways = array();
48
-
49
- /**
50
- * Return a particular payment gateway object
51
- *
52
- * @access public
53
- * @param string $gateway Name of the payment gateway you want to get
54
- * @return object
55
- * @since 3.9
56
- */
57
- public static function &get( $gateway, $meta = false ) {
58
- if ( empty( self::$instances[$gateway] ) ) {
59
- if ( ! $meta )
60
- $meta = self::$gateways[$gateway];
61
- require_once( $meta['path'] );
62
- $class_name = $meta['class'];
63
- $options = array(
64
- 'http_client' => new WPSC_Payment_Gateway_HTTP(),
65
- );
66
- if ( ! class_exists( $class_name ) ) {
67
- $error = new WP_Error( 'wpsc_invalid_payment_gateway', sprintf( __( 'Invalid payment gateway: Class %s does not exist.', 'wpsc' ), $class_name ) );
68
- return $error;
69
- }
70
-
71
- self::$instances[$gateway] = new $class_name( $options );
72
- }
73
-
74
- return self::$instances[$gateway];
75
- }
76
-
77
- public static function init() {
78
- add_action( 'wpsc_submit_gateway_options', array( 'WPSC_Payment_Gateway_Setting', 'action_update_payment_gateway_settings' ) );
79
-
80
- if ( ! defined( 'WPSC_PAYMENT_GATEWAY_DEBUG' ) || WPSC_PAYMENT_GATEWAY_DEBUG == false )
81
- add_action( 'wp_loaded', array( 'WPSC_Payment_Gateways', 'action_save_payment_gateway_cache' ), 99 );
82
- else
83
- WPSC_Payment_Gateways::flush_cache();
84
-
85
- WPSC_Payment_Gateways::register_dir( WPSC_MERCHANT_V3_PATH . '/gateways' );
86
-
87
- if ( isset( $_REQUEST['payment_gateway'] ) && isset( $_REQUEST['payment_gateway_callback'] ) && self::is_registered( $_REQUEST['payment_gateway'] ) )
88
- add_action( 'init', array( 'WPSC_Payment_Gateways', 'action_process_callbacks' ) );
89
- }
90
-
91
- public static function action_process_callbacks() {
92
- $gateway = self::get( $_REQUEST['payment_gateway'] );
93
- $function_name = "callback_{$_REQUEST['payment_gateway_callback']}";
94
- $callback = array( $gateway, $function_name );
95
-
96
- if ( is_callable( $callback ) )
97
- $gateway->$function_name();
98
- }
99
-
100
- /**
101
- * Check to see whether a gateway is registered using this new API
102
- *
103
- * @access public
104
- * @since 3.9
105
- *
106
- * @param string $gateway Gateway name (derived from the filename without .php extension)
107
- * @return bool True if it's already registered.
108
- */
109
- public static function is_registered( $gateway ) {
110
- return ! empty( self::$gateways[$gateway] );
111
- }
112
-
113
- /**
114
- * Automatically scan a directory for payment gateways and load the classes.
115
- *
116
- * The structure of this directory should follow the same rules of the wp-content/plugins
117
- * structure.
118
- *
119
- * All of the files inside the directory will be assumed as payment gateway modules.
120
- * Files with the same name as those sub-folders will be included as payment
121
- * gateway modules.
122
- *
123
- * For example, if we have the following directory structure:
124
- * payment-gateways/
125
- * |-- test-gateway-1.php
126
- * |-- test-gateway-2.php
127
- * |-- some-folder/
128
- * |-- class.php
129
- * |-- functions.php
130
- *
131
- * The following files will be loaded as payment gateway modules: test-gateway-1.php,
132
- * test-gateway-2.php
133
- * See WPSC_Payment_Gateways::register_file() for file and class naming convention
134
- *
135
- * @access public
136
- * @since 3.9
137
- * @uses WPSC_Payment_Gateways::register_file()
138
- *
139
- * @param string $dir Path to the directory
140
- * @param string $main_file File name of the class to load
141
- * @return mixed Return true if successfully loaded all the payment gateway in
142
- * the directory.
143
- * Otherwise return a WP_Error object.
144
- */
145
- public static function register_dir( $dir, $main_file = '' ) {
146
- $dir = trailingslashit( $dir );
147
- $main_file = basename( $dir ) . '.php';
148
-
149
- // scan files in dir
150
- $files = scandir( $dir );
151
-
152
- if ( in_array( $main_file, $files ) )
153
- return self::register_file( $dir . $main_file );
154
-
155
- foreach ( $files as $file ) {
156
- $path = $dir . $file;
157
-
158
- if ( pathinfo( $path, PATHINFO_EXTENSION ) != 'php' || in_array( $file, array( '.', '..' ) ) || is_dir( $path ) )
159
- continue;
160
-
161
- $return = self::register_file( $path );
162
-
163
- if ( is_wp_error( $return ) )
164
- return $return;
165
- }
166
- }
167
-
168
- /**
169
- * Register a file as a payment gateway module.
170
- *
171
- * The payment gateway inside the file must be defined as a subclass of WPSC_Payment_Gateway.
172
- *
173
- * The file name should be lowercase, using hyphens or underscores between words
174
- * instead of spaces. The class name must have "WPSC_Payment_Gateway_" as the
175
- * prefix, followed by the file name, in which words are capitalized and connected
176
- * by underscore.
177
- *
178
- * For example, if the file name is "paypal-pro.php", then the class name inside
179
- * the file must be WPSC_Payment_Gateway_Paypal_Pro.
180
- *
181
- * @access public
182
- * @since 3.9
183
- * @see WPSC_Payment_Gateways::register_dir()
184
- *
185
- * @param string $file Absolute path to the file containing the payment gateway
186
- * class
187
- * @return mixed Return true if the file is successfully included and contains
188
- * a valid class. Otherwise, a WP_Error object is returned.
189
- */
190
- public static function register_file( $file ) {
191
- if ( empty( self::$payment_gateway_cache ) )
192
- self::$payment_gateway_cache = get_option( 'wpsc_payment_gateway_cache', array() );
193
- $filename = basename( $file, '.php' );
194
-
195
- // payment gateway already exists in cache
196
- if ( isset( self::$payment_gateway_cache[$filename] ) ) {
197
- self::$gateways[$filename] = self::$payment_gateway_cache[$filename];
198
- return true;
199
- }
200
-
201
- // if payment gateway is not in cache, load metadata
202
- $classname = ucwords( str_replace( '-', ' ', $filename ) );
203
- $classname = 'WPSC_Payment_Gateway_' . str_replace( ' ', '_', $classname );
204
-
205
- $meta = array(
206
- 'class' => $classname,
207
- 'path' => $file,
208
- 'internalname' => $filename, // compat with older API
209
- );
210
-
211
- $gateway = self::get( $filename, $meta );
212
-
213
- if ( is_wp_error( $gateway ) )
214
- return $gateway;
215
-
216
- $meta['name'] = $gateway->get_title();
217
- $meta['image'] = $gateway->get_image_url();
218
- $meta['mark'] = $gateway->get_mark_html();
219
- self::$gateways[$filename] = $meta;
220
-
221
- return true;
222
- }
223
-
224
- /**
225
- * Updates the payment gateway cache when it's changed.
226
- *
227
- * This function is hooked into WordPress' wp_loaded action
228
- *
229
- * @access public
230
- * @static
231
- * @since 3.9
232
- *
233
- * @return void
234
- */
235
- public static function action_save_payment_gateway_cache() {
236
- if ( self::$payment_gateway_cache != self::$gateways )
237
- update_option( 'wpsc_payment_gateway_cache', self::$gateways );
238
- }
239
-
240
- /**
241
- * Flush the payment gateways cache.
242
- *
243
- * @access public
244
- * @static
245
- * @since 3.9
246
- * @return void
247
- */
248
- public static function flush_cache() {
249
- delete_option( 'wpsc_payment_gateway_cache' );
250
- }
251
-
252
- /**
253
- * Gets metadata of a certain payment gateway. This is better than calling WPSC_Payment_Gateways->get( $gateway_name )->get_title()
254
- * and the likes of it, since it doesn't require the gateway itself to be loaded.
255
- *
256
- * @access public
257
- * @static
258
- * @since 3.9
259
- *
260
- * @param string $gateway
261
- * @return mixed Array containing the metadata. If the gateway is not registered,
262
- * returns false.
263
- */
264
- public static function get_meta( $gateway ) {
265
- return isset( self::$gateways[$gateway] ) ? self::$gateways[$gateway] : false;
266
- }
267
-
268
- /**
269
- *
270
- * Return an array containing registered gateway names.
271
- *
272
- * @access public
273
- * @since 3.9
274
- *
275
- * @return array
276
- */
277
- public static function get_gateways() {
278
- return array_keys( self::$gateways );
279
- }
280
-
281
- public static function get_active_gateways() {
282
- if ( empty( self::$active_gateways ) ) {
283
- $selected_gateways = get_option( 'custom_gateway_options', array() );
284
- $registered_gateways = self::get_gateways();
285
- self::$active_gateways = array_intersect( $selected_gateways, $registered_gateways );
286
- }
287
-
288
- return apply_filters( 'wpsc_get_active_gateways', array_values( self::$active_gateways ) );
289
- }
290
-
291
- /**
292
- * No instantiation for this class
293
- *
294
- * @access private
295
- * @since 3.9
296
- *
297
- */
298
- private function __construct() {}
299
- }
300
-
301
- abstract class WPSC_Payment_Gateway {
302
-
303
- /**
304
- * Object that allows manipulation of payment gateway settings in a consistent
305
- * manner
306
- *
307
- * @access public
308
- * @var WPSC_Payment_Gateway_Setting
309
- */
310
- public $setting;
311
-
312
- public $purchase_log;
313
-
314
- public $checkout_data;
315
-
316
- public $currency_code;
317
-
318
- public $title;
319
-
320
- /**
321
- * Return the title of the payment gateway. For this to work, $this->title must
322
- * be set already.
323
- *
324
- * It is recommended that the payment gateway title be properly localized using __()
325
- *
326
- * @access public
327
- * @since 3.9
328
- * @see __()
329
- *
330
- * @return string
331
- */
332
- public function get_title() {
333
- $title = empty( $this->title ) ? '' : $this->title;
334
- return apply_filters( 'wpsc_payment_gateway_title', $title );
335
- }
336
-
337
- /**
338
- * Display the payment gateway settings form as seen in WP eCommerce Settings area.
339
- * This method must be overridden by subclasses.
340
- *
341
- * @abstract
342
- * @access public
343
- * @since 3.9
344
- *
345
- * @return void
346
- */
347
- public function setup_form() {
348
- $checkout_field_types = array(
349
- 'billing' => __( 'Billing Fields', 'wpsc' ),
350
- 'shipping' => __( 'Shipping Fields', 'wpsc' ),
351
- );
352
-
353
- $fields = array(
354
- 'firstname' => __( 'First Name', 'wpsc' ),
355
- 'lastname' => __( 'Last Name', 'wpsc' ),
356
- 'address' => __( 'Address', 'wpsc' ),
357
- 'city' => __( 'City', 'wpsc' ),
358
- 'state' => __( 'State', 'wpsc' ),
359
- 'country' => __( 'Country', 'wpsc' ),
360
- 'postcode' => __( 'Postal Code', 'wpsc' ),
361
- );
362
- $checkout_form = WPSC_Checkout_Form::get();
363
- foreach ( $checkout_field_types as $field_type => $title ): ?>
364
- <tr>
365
- <td colspan="2">
366
- <h4><?php echo esc_html( $title ); ?></h4>
367
- </td>
368
- </tr>
369
- <?php foreach ( $fields as $field_name => $field_title ):
370
- $unique_name = $field_type . $field_name;
371
- $selected_id = $this->setting->get( "checkout_field_{$unique_name}", $checkout_form->get_field_id_by_unique_name( $unique_name ) );
372
- ?>
373
- <tr>
374
- <td>
375
- <label for="manual-form-<?php echo esc_attr( $unique_name ); ?>"><?php echo esc_html( $field_title ); ?></label>
376
- </td>
377
- <td>
378
- <select name="<?php echo $this->setting->get_field_name( "checkout_field_{$unique_name}" ); ?>" id="manual-form-<?php echo esc_attr( $unique_name ); ?>">
379
- <?php $checkout_form->field_drop_down_options( $selected_id ); ?>
380
- </select>
381
- </td>
382
- </tr>
383
- <?php endforeach;
384
- endforeach;
385
- }
386
-
387
- /**
388
- * Process and send payment details to payment gateways
389
- *
390
- * @abstract
391
- * @access public
392
- * @since 3.9
393
- *
394
- * @return void
395
- */
396
- abstract public function process();
397
-
398
- /**
399
- * Returns the URL to the logo of the payment gateway (or any representative image).
400
- *
401
- * @access public
402
- * @since 3.9
403
- *
404
- * @return mixed False if there's no image defined.
405
- */
406
- public function get_image_url() {
407
- return false;
408
- }
409
-
410
- /**
411
- * Returns the HTML of the logo of the payment gateway.
412
- *
413
- * @access public
414
- * @since 3.9
415
- *
416
- * @return mixed False if there's no html defined.
417
- */
418
- public function get_mark_html() {
419
- return false;
420
- }
421
-
422
- public function set_purchase_log( &$purchase_log ) {
423
- $this->purchase_log = &$purchase_log;
424
- $this->checkout_data = new WPSC_Checkout_Form_Data( $purchase_log->get( 'id' ) );
425
- }
426
-
427
- public function get_currency_code() {
428
- if ( ! $this->currency_code ) {
429
- $country = new WPSC_Country( get_option( 'currency_type' ) );
430
- $currency = $country->get( 'currency_code' );
431
- } else {
432
- $currency = $this->currency_code;
433
- }
434
-
435
- return $currency;
436
- }
437
-
438
- public function get_notification_url() {
439
- return add_query_arg( 'wpsc_action', 'gateway_notification', (get_option( 'siteurl' ) . "/index.php" ) );
440
- }
441
-
442
- public function get_transaction_results_url() {
443
- return get_option( 'transact_url' );
444
- }
445
-
446
- public function get_shopping_cart_url() {
447
- return get_option( 'shopping_cart_url' );
448
- }
449
-
450
- public function get_shopping_cart_payment_url() {
451
- return _wpsc_maybe_activate_theme_engine_v2() ? wpsc_get_checkout_url( 'payment' ) : get_option( 'shopping_cart_url' );
452
- }
453
-
454
- public function get_products_page_url() {
455
- return get_option( 'product_list_url' );
456
- }
457
-
458
- public function go_to_transaction_results() {
459
- //Now to do actions once the payment has been attempted
460
- switch ( $this->purchase_log->get( 'processed' ) ) {
461
- case 3:
462
- // payment worked
463
- do_action('wpsc_payment_successful');
464
- break;
465
- case 1:
466
- // payment declined
467
- do_action('wpsc_payment_failed');
468
- break;
469
- case 2:
470
- // something happened with the payment
471
- do_action('wpsc_payment_incomplete');
472
- break;
473
- }
474
-
475
- $transaction_url_with_sessionid = add_query_arg( 'sessionid', $this->purchase_log->get( 'sessionid' ), get_option( 'transact_url' ) );
476
- wp_redirect( $transaction_url_with_sessionid );
477
-
478
- exit();
479
- }
480
-
481
- /**
482
- * Payment gateway constructor. Should use WPSC_Payment_Gateways::get( $gateway_name ) instead.
483
- *
484
- * @access public
485
- * @return WPSC_Payment_Gateway
486
- */
487
- public function __construct() {
488
- $this->setting = new WPSC_Payment_Gateway_Setting( get_class( $this ) );
489
- }
490
- }
491
-
492
- class WPSC_Payment_Gateway_Setting {
493
- /**
494
- * Contain settings of the payment gateway
495
- *
496
- * @access private
497
- * @var array
498
- */
499
- private $settings;
500
-
501
- /**
502
- * Contain unsaved settings of the payment gateway. This is useful when the saving of the settings
503
- * are deferred.
504
- *
505
- * @access private
506
- * @var array
507
- */
508
- private $unsaved_settings = array();
509
-
510
- /**
511
- * Name of the gateway
512
- *
513
- * @access private
514
- * @var string
515
- */
516
- private $gateway_name = '';
517
-
518
- /**
519
- * Name of the option containing all the settings in WP DB
520
- *
521
- * @access private
522
- * @var string
523
- */
524
- private $option_name = '';
525
-
526
- /**
527
- * Save settings when the payment gateway setup form is updated
528
- *
529
- * @access public
530
- * @static
531
- * @return void
532
- *
533
- * @since 3.9
534
- */
535
- public static function action_update_payment_gateway_settings() {
536
- if ( ! empty( $_POST['wpsc_payment_gateway_settings'] ) )
537
- foreach ( $_POST['wpsc_payment_gateway_settings'] as $gateway_name => $new_settings ) {
538
- $settings = new WPSC_Payment_Gateway_Setting( $gateway_name );
539
- $settings->merge( $new_settings );
540
- }
541
- }
542
-
543
- /**
544
- * Constructor
545
- *
546
- * @access public
547
- *
548
- * @param string $gateway_name Name of the gateway
549
- * @return WPSC_Payment_Gateway
550
- */
551
- public function __construct( $gateway_name_or_class ) {
552
- $name = str_replace( 'wpsc_payment_gateway_', '', strtolower( $gateway_name_or_class ) );
553
- $name = str_replace( array( ' ', '-' ), '_', $name );
554
- $this->gateway_name = $name;
555
- $this->option_name = 'wpsc_payment_gateway_' . $this->gateway_name;
556
- }
557
-
558
- /**
559
- * Lazy load the settings from the DB when necessary
560
- *
561
- * @access private
562
- * @return void
563
- */
564
- private function lazy_load() {
565
- if ( is_null( $this->settings ) )
566
- $this->settings = get_option( $this->option_name, array() );
567
- }
568
-
569
- /**
570
- * Get the value of a setting
571
- *
572
- * @param string $setting
573
- * @return mixed
574
- * @since 3.9
575
- */
576
- public function get( $setting, $default = false ) {
577
- $this->lazy_load();
578
- return isset( $this->settings[$setting] ) ? $this->settings[$setting] : $default;
579
- }
580
-
581
- /**
582
- * Set the value of a setting
583
- *
584
- * @param string $setting
585
- * @param mixed $value
586
- * @param bool $defer True if you want to defer saving the settings array to the database
587
- * @return void
588
- * @since 3.9
589
- */
590
- public function set( $setting, $value, $defer = false ) {
591
- $this->lazy_load();
592
- $this->unsaved_settings[$setting] = $value;
593
- if ( ! $defer )
594
- $this->save();
595
- }
596
-
597
- /**
598
- * Overwrite current settings with an array of settings
599
- *
600
- * @access public
601
- * @param string $settings Settings that you want to overwrite upon current settings
602
- * @param string $defer Optional. Defaults to false. True if you want to defer
603
- * saving the settings array to the database.
604
- * @return void
605
- * @since 3.9
606
- */
607
- public function merge( $settings, $defer = false ) {
608
- $this->lazy_load();
609
- $this->unsaved_settings = array_merge( $this->unsaved_settings, $settings );
610
- if ( ! $defer )
611
- $this->save();
612
- }
613
-
614
- /**
615
- * Returns the field name of the setting on payment gateway setup form
616
- *
617
- * @access public
618
- * @param string $setting Setting names
619
- * @return string
620
- * @since 3.9
621
- */
622
- public function get_field_name( $setting ) {
623
- return "wpsc_payment_gateway_settings[{$this->gateway_name}][{$setting}]";
624
- }
625
-
626
- /**
627
- * Save the settings into the database
628
- *
629
- * @return void
630
- * @since 3.9
631
- */
632
- public function save() {
633
- $this->settings = array_merge( $this->settings, $this->unsaved_settings );
634
- $this->unsaved_settings = array();
635
- update_option( $this->option_name, $this->settings );
636
- }
637
- }
638
-
639
- WPSC_Payment_Gateways::init();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/dg.css DELETED
@@ -1,72 +0,0 @@
1
- /*
2
- * Digital Goods Lightbox CSS code
3
- */
4
- p {
5
- display: block;
6
- position: relative;
7
- top: 33%;
8
- text-transform:
9
- uppercase;
10
- color: #084482;
11
- text-align: center;
12
- font-style: italic;
13
- font-weight: bold;
14
- font-size: 12px;
15
- font-family: arial, helvetica, sans-serif;
16
- }
17
- img {
18
- display: block;
19
- position: absolute;
20
- left: 46%;
21
- top: 46%;
22
- }
23
- #left_frame {
24
- margin-top: 15px;
25
- position: relative;
26
- width: 370px;
27
- height: 330px;
28
- background: top left;
29
- }
30
- #right_frame {
31
- margin: 0 15px 15px 15px;
32
- padding: 10px 10px 0 0;
33
- width: 350px;
34
- height: 325px;
35
- background: top right;
36
- }
37
- #right_bottom {
38
- bottom: -12px;
39
- left: 0px;
40
- margin: 0 0 0 10px;
41
- padding: 0px 5px 10px 10px;
42
- position: absolute;
43
- width: 350px;
44
- background: bottom right;
45
- }
46
- #left_bottom {
47
- bottom: -10px;
48
- left: 0px;
49
- margin: 0 0 0 -20px;
50
- padding: 0;
51
- position: relative;
52
- height: 12px;
53
- width: 100px;
54
- background: bottom left;
55
- }
56
- #left_frame, #right_frame, #right_bottom, #left_bottom {
57
- background-image: url(https://www.paypal.com/en_US/i/scr/scr_dg_sliding_door_bdr_wf.png);
58
- background-color: transparent;
59
- background-repeat: no-repeat;
60
- }
61
-
62
- @media only screen and (max-device-width : 568px) {
63
- #left_frame,
64
- #right_frame,
65
- #right_bottom {
66
- width: 96%;
67
- }
68
- #left_frame,
69
- #right_frame {
70
- height: 96%;
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/dg.js DELETED
@@ -1,28 +0,0 @@
1
- /*
2
- * PayPal for Digital Goods script
3
- */
4
- (function($) {
5
- $(window).load(function() {
6
- // Declare variables/doom elements
7
- var $checkout_btn = $( '.wpsc-checkout-form-button' ),
8
- $rd_btn = $( 'input[value="paypal-digital-goods"]' ),
9
- $inputs = $( 'input[type="radio"]' ),
10
- $form = $( '#wpsc-checkout-form' );
11
-
12
- // Change the id of the checkout button
13
- $checkout_btn.attr( 'id', 'submitBtn' );
14
-
15
- // Gateway selection changed
16
- $inputs.on( 'change', function() {
17
- if ( $rd_btn.is( ':checked' ) ) {
18
- // Starts the DG Flow
19
- var dg = new PAYPAL.apps.DGFlow( {
20
- trigger: 'submitBtn'
21
- } );
22
- } else {
23
- $form.attr( 'target', '' );
24
- }
25
- } );
26
- } );
27
-
28
- } )( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/manual.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class WPSC_Payment_Gateway_Manual extends WPSC_Payment_Gateway {
4
- /**
5
- * Constructor of Manual Payment Gateway
6
- *
7
- * @access public
8
- * @since 3.9
9
- */
10
- public function __construct() {
11
- parent::__construct();
12
- $this->title = __( 'Manual Payment Gateway 3.0', 'wpsc' );
13
- }
14
-
15
- /**
16
- * Displays the setup form
17
- *
18
- * @access public
19
- * @since 3.9
20
- * @uses WPSC_Checkout_Form::get()
21
- * @uses WPSC_Checkout_Form::field_drop_down_options()
22
- * @uses WPSC_Checkout_Form::get_field_id_by_unique_name()
23
- * @uses WPSC_Payment_Gateway_Setting::get()
24
- *
25
- * @return void
26
- */
27
- public function setup_form() {
28
- ?>
29
- <tr>
30
- <td colspan="2">
31
- <p>
32
- <label for="wpsc-manual-gateway-setup"><?php _e( 'Instructions', 'wpsc' ); ?></label><br />
33
- <textarea id="wpsc-manual-gateway-setup" cols='' rows='10' name='<?php echo esc_attr( $this->setting->get_field_name( 'payment_instructions' ) ); ?>'><?php echo esc_textarea( wp_unslash( $this->setting->get( 'payment_instructions' ) ) ); ?></textarea><br />
34
- <small><?php _e('Enter the payment instructions that you wish to display to your customers when they make a purchase.', 'wpsc'); ?></small><br />
35
- <small><?php _e('For example, this is where you the Shop Owner might enter your bank account details or address so that your customer can make their manual payment.', 'wpsc'); ?></small>
36
- </p>
37
- </td>
38
- </tr>
39
- <?php
40
- }
41
-
42
- public function process() {
43
- $this->purchase_log->set( 'processed', WPSC_PAYMENT_STATUS_RECEIVED )->save();
44
- $this->go_to_transaction_results();
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php DELETED
@@ -1,638 +0,0 @@
1
- <?php
2
- require_once( 'paypal-express-checkout.php' );
3
-
4
- /**
5
- * The PayPal Express Checkout Gateway class
6
- *
7
- */
8
-
9
- class WPSC_Payment_Gateway_Paypal_Digital_Goods extends WPSC_Payment_Gateway_Paypal_Express_Checkout
10
- {
11
- const SANDBOX_URL = 'https://www.sandbox.paypal.com/incontext?token=';
12
- const LIVE_URL = 'https://www.paypal.com/incontext?token=';
13
- public $gateway;
14
-
15
- /**
16
- * Constructor of PayPal Express Checkout Gateway
17
- *
18
- * @param array $options
19
- * @return void
20
- *
21
- * @since 3.9
22
- */
23
- public function __construct( $options ) {
24
-
25
- require_once( 'php-merchant/gateways/paypal-digital-goods.php' );
26
- $this->gateway = new PHP_Merchant_Paypal_Digital_Goods( $options );
27
-
28
- // Now that the gateway is created, call parent constructor
29
- parent::__construct( $options );
30
-
31
- $this->title = __( 'PayPal ExpressCheckout for Digital Goods', 'wpsc' );
32
-
33
- $this->gateway->set_options( array(
34
- 'api_username' => $this->setting->get( 'api_username' ),
35
- 'api_password' => $this->setting->get( 'api_password' ),
36
- 'api_signature' => $this->setting->get( 'api_signature' ),
37
- 'cancel_url' => $this->get_cancel_url(),
38
- 'currency' => $this->get_currency_code(),
39
- 'test' => (bool) $this->setting->get( 'sandbox_mode' ),
40
- 'address_override' => 1,
41
- 'solution_type' => 'mark',
42
- 'cart_logo' => $this->setting->get( 'cart_logo' ),
43
- 'cart_border' => $this->setting->get( 'cart_border' ),
44
- ) );
45
-
46
- add_action( 'wp_enqueue_scripts', array( $this, 'dg_script' ) );
47
-
48
- add_filter( 'wpsc_purchase_log_gateway_data', array( get_parent_class( $this ), 'filter_purchase_log_gateway_data' ), 10, 2 );
49
-
50
- add_filter(
51
- 'wpsc_payment_method_form_fields',
52
- array( $this, 'filter_unselect_default' ), 100 , 1
53
- );
54
- }
55
-
56
- /**
57
- * WordPress Enqueue for the Dgital Goods Script and CSS file
58
- *
59
- * @return void
60
- *
61
- * @since 3.9
62
- */
63
- public function dg_script() {
64
- if ( wpsc_is_checkout() ) {
65
- wp_enqueue_script( 'dg-script', 'https://www.paypalobjects.com/js/external/dg.js' );
66
- wp_enqueue_script( 'dg-script-internal', WPSC_URL . '/wpsc-components/merchant-core-v3/gateways/dg.js', array( 'jquery' ) );
67
- }
68
- }
69
-
70
-
71
- /**
72
- * No payment gateway is selected by default
73
- *
74
- * @access public
75
- * @since 3.9
76
- *
77
- * @param array $fields
78
- *
79
- * @return array
80
- */
81
- public function filter_unselect_default( $fields ) {
82
- foreach ( $fields as $i=>$field ) {
83
- $fields[ $i ][ 'checked' ] = false;
84
- }
85
-
86
- return $fields;
87
- }
88
-
89
- /**
90
- * Return the PayPal return URL
91
- *
92
- * @return string
93
- *
94
- * @since 3.9
95
- */
96
- protected function get_return_url() {
97
- $redirect = add_query_arg( array(
98
- 'sessionid' => $this->purchase_log->get( 'sessionid' ),
99
- 'payment_gateway' => 'paypal-digital-goods',
100
- 'payment_gateway_callback' => 'return_url_redirect',
101
- ),
102
- get_option( 'transact_url' )
103
- );
104
- return apply_filters( 'wpsc_paypal_digital_goods_return_url_redirect', $redirect, $this );
105
- }
106
-
107
- /**
108
- * PayPal Lightbox Form redirection for the Return URL
109
- *
110
- * @return void
111
- *
112
- * @since 3.9
113
- */
114
- public function callback_return_url_redirect() {
115
- // Session id
116
- if ( ! isset( $_GET['sessionid'] ) ) {
117
- return;
118
- } else {
119
- $sessionid = $_GET['sessionid'];
120
- }
121
-
122
- // Page Styles
123
- wp_register_style( 'ppdg-iframe', plugins_url( 'dg.css', __FILE__ ) );
124
-
125
- // Return a redirection page
126
- ?>
127
- <html>
128
- <head>
129
- <title><?php _e( 'Processing...', 'wpsc' ); ?></title>
130
- <?php wp_print_styles( 'ppdg-iframe' ); ?>
131
- </head>
132
- <body>
133
- <div id="left_frame">
134
- <div id="right_frame">
135
- <p id="message">
136
- <?php _e( 'Processing Order', 'wpsc'); ?>
137
- <?php $location = esc_js( $this->get_original_return_url( $sessionid ) ); ?>
138
- </p>
139
- <img src="https://www.paypal.com/en_US/i/icon/icon_animated_prog_42wx42h.gif" alt="Processing..." />
140
- <div id="right_bottom">
141
- <div id="left_bottom">
142
- </div>
143
- </div>
144
- </div>
145
- </div>
146
- <script type="text/javascript">
147
- setTimeout('if (window!=top) {top.location.replace("<?php echo $location; ?>");}else{location.replace("<?php echo $location; ?>");}', 1500);
148
- </script>
149
- </body>
150
- </html>
151
- <?php
152
- exit();
153
- }
154
-
155
- /**
156
- * Return the original (real) Return URL
157
- *
158
- * @param integer $session_id
159
- *
160
- * @return string
161
- *
162
- * @since 3.9
163
- */
164
- protected function get_original_return_url( $session_id ) {
165
- $location = add_query_arg( array(
166
- 'sessionid' => $session_id,
167
- 'token' => $_REQUEST['token'],
168
- 'PayerID' => $_REQUEST['PayerID'],
169
- 'payment_gateway' => 'paypal-digital-goods',
170
- 'payment_gateway_callback' => 'confirm_transaction',
171
- ),
172
- get_option( 'transact_url' )
173
- );
174
- return apply_filters( 'wpsc_paypal_digital_goods_return_url', $location );
175
- }
176
-
177
- /**
178
- * Return the Cancel URL
179
- *
180
- * @return string
181
- *
182
- * @since 3.9
183
- */
184
- protected function get_cancel_url() {
185
- $redirect = add_query_arg( array(
186
- 'payment_gateway' => 'paypal-digital-goods',
187
- 'payment_gateway_callback' => 'cancel_url_redirect',
188
- ),
189
- get_option( 'transact_url' )
190
- );
191
- return apply_filters( 'wpsc_paypal_digital_goods_cancel_url_redirect', $redirect );
192
- }
193
-
194
- /**
195
- * PayPal Lightbox Form redirection for the Cancel URL
196
- *
197
- * @return void
198
- *
199
- * @since 3.9
200
- */
201
- public function callback_cancel_url_redirect() {
202
- // Page Styles
203
- wp_register_style( 'ppdg-iframe', plugins_url( 'dg.css', __FILE__ ) );
204
-
205
- // Return a redirection page
206
- ?>
207
- <html>
208
- <head>
209
- <title><?php _e( 'Processing...', 'wpsc' ); ?></title>
210
- <?php wp_print_styles( 'ppdg-iframe' ); ?>
211
- </head>
212
- <body>
213
- <div id="left_frame">
214
- <div id="right_frame">
215
- <p id="message">
216
- <?php _e( 'Cancelling Order', 'ppdg'); ?>
217
- <?php $location = html_entity_decode( $this->get_original_cancel_url() ); ?>
218
- </p>
219
- <img src="https://www.paypal.com/en_US/i/icon/icon_animated_prog_42wx42h.gif" alt="Processing..." />
220
- <div id="right_bottom">
221
- <div id="left_bottom">
222
- </div>
223
- </div>
224
- </div>
225
- </div>
226
- <script type="text/javascript">
227
- setTimeout('if (window!=top) {top.location.replace("<?php echo $location; ?>");}else{location.replace("<?php echo $location; ?>");}', 1500);
228
- </script>
229
- </body>
230
- </html>
231
- <?php
232
- exit();
233
- }
234
-
235
- /**
236
- * Return the original (real) Cancel URL
237
- *
238
- * @param integer $session_id
239
- *
240
- * @return string
241
- *
242
- * @since 3.9
243
- */
244
- protected function get_original_cancel_url() {
245
- return apply_filters( 'wpsc_paypal_digital_goods_cancel_url', $this->get_shopping_cart_payment_url() );
246
- }
247
-
248
- /**
249
- * Return the notify URL
250
- *
251
- * @return string
252
- *
253
- * @since 3.9
254
- */
255
- protected function get_notify_url() {
256
- $location = add_query_arg( array(
257
- 'payment_gateway' => 'paypal-digital-goods',
258
- 'payment_gateway_callback' => 'ipn',
259
- ), home_url( 'index.php' ) );
260
-
261
- return apply_filters( 'wpsc_paypal_express_checkout_notify_url', $location );
262
- }
263
-
264
- /**
265
- * IPN Callback function
266
- *
267
- * @return void
268
- *
269
- * @since 3.9
270
- */
271
- public function callback_ipn() {
272
- $ipn = new PHP_Merchant_Paypal_IPN( false, (bool) $this->setting->get( 'sandbox_mode', false ) );
273
-
274
- if ( $ipn->is_verified() ) {
275
- $sessionid = $ipn->get( 'message_id' );
276
- $this->set_purchase_log_for_callbacks( $sessionid );
277
-
278
- if ( $ipn->is_payment_denied() ) {
279
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::PAYMENT_DECLINED );
280
- } elseif ( $ipn->is_payment_refunded() ) {
281
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::REFUNDED );
282
- } elseif ( $ipn->is_payment_completed() ) {
283
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
284
- } elseif ( $ipn->is_payment_pending() ) {
285
- if ( $ipn->is_payment_refund_pending() )
286
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::REFUND_PENDING );
287
- else
288
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
289
- }
290
-
291
- $this->purchase_log->save();
292
- transaction_results( $sessionid, false );
293
- }
294
-
295
- exit;
296
- }
297
-
298
- /**
299
- * Confirm Transaction Callback
300
- *
301
- * @return null
302
- *
303
- * @since 3.9
304
- */
305
- public function callback_confirm_transaction() {
306
-
307
- if ( ! isset( $_GET['sessionid'] ) || ! isset( $_GET['token'] ) || ! isset( $_GET['PayerID'] ) ) {
308
- return;
309
- }
310
-
311
- $this->set_purchase_log_for_callbacks();
312
-
313
- $this->callback_process_confirmed_payment();
314
- }
315
-
316
- /**
317
- * Process the transaction through the PayPal APIs
318
- *
319
- * @since 3.9
320
- */
321
- public function callback_process_confirmed_payment() {
322
- $args = array_map( 'urldecode', $_GET );
323
- extract( $args, EXTR_SKIP );
324
-
325
- if ( ! isset( $sessionid ) || ! isset( $token ) || ! isset( $PayerID ) ) {
326
- return;
327
- }
328
-
329
- $this->set_purchase_log_for_callbacks();
330
-
331
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
332
- $options = array(
333
- 'token' => $token,
334
- 'payer_id' => $PayerID,
335
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
336
- 'invoice' => $this->purchase_log->get( 'sessionid' ) . '-' . $this->purchase_log->get( 'id' ),
337
- );
338
- $options += $this->checkout_data->get_gateway_data();
339
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
340
-
341
- if ( $this->setting->get( 'ipn', false ) ) {
342
- $options['notify_url'] = $this->get_notify_url();
343
- }
344
-
345
- // GetExpressCheckoutDetails
346
- $details = $this->gateway->get_details_for( $token );
347
- $this->log_payer_details( $details );
348
-
349
- $response = $this->gateway->purchase( $options );
350
- $this->log_protection_status( $response );
351
- $location = remove_query_arg( 'payment_gateway_callback' );
352
-
353
- if ( $response->has_errors() ) {
354
- wpsc_update_customer_meta( 'paypal_express_checkout_errors', $response->get_errors() );
355
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_paypal_error' ) );
356
- } elseif ( $response->is_payment_completed() || $response->is_payment_pending() ) {
357
- $location = remove_query_arg( 'payment_gateway' );
358
-
359
- if ( $response->is_payment_completed() ) {
360
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
361
- } else {
362
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
363
- }
364
-
365
- $this->purchase_log->set( 'transactid', $response->get( 'transaction_id' ) )
366
- ->set( 'date', time() )
367
- ->save();
368
- } else {
369
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_generic_error' ) );
370
- }
371
-
372
- wp_redirect( $location );
373
- exit;
374
-
375
- }
376
-
377
- /**
378
- * PayPal Lightbox Form redirection for the Error Page
379
- *
380
- * @return void
381
- *
382
- * @since 3.9
383
- */
384
- public function callback_display_paypal_error_redirect() {
385
- // Redirect Location
386
- $location = add_query_arg( array(
387
- 'payment_gateway' => 'paypal-digital-goods',
388
- 'payment_gateway_callback' => 'display_paypal_error',
389
- ), base64_decode( $_GET['return_url'] ) );
390
-
391
- // Page Styles
392
- wp_register_style( 'ppdg-iframe', plugins_url( 'dg.css', __FILE__ ) );
393
-
394
- // Return a redirection page
395
- ?>
396
- <html>
397
- <head>
398
- <title><?php __( 'Processing...', 'wpsc' ); ?></title>
399
- <?php wp_print_styles( 'ppdg-iframe' ); ?>
400
- </head>
401
- <body>
402
- <div id="left_frame">
403
- <div id="right_frame">
404
- <p id="message">
405
- <?php _e( 'Processing Order', 'wpsc'); ?>
406
- </p>
407
- <img src="https://www.paypal.com/en_US/i/icon/icon_animated_prog_42wx42h.gif" alt="Processing..." />
408
- <div id="right_bottom">
409
- <div id="left_bottom">
410
- </div>
411
- </div>
412
- </div>
413
- </div>
414
- <script type="text/javascript">
415
- setTimeout('if (window!=top) {top.location.replace("<?php echo $location; ?>");}else{location.replace("<?php echo $location; ?>");}', 1500);
416
- </script>
417
- </body>
418
- </html>
419
- <?php
420
- exit();
421
-
422
-
423
- }
424
-
425
- public function callback_display_paypal_error() {
426
- add_filter( 'wpsc_get_transaction_html_output', array( $this, 'filter_paypal_error_page' ) );
427
- }
428
-
429
- public function callback_display_generic_error() {
430
- add_filter( 'wpsc_get_transaction_html_output', array( $this, 'filter_generic_error_page' ) );
431
- }
432
-
433
- /**
434
- * Error Page Template
435
- *
436
- * @since 3.9
437
- */
438
- public function filter_paypal_error_page() {
439
- $errors = wpsc_get_customer_meta( 'paypal_express_checkout_errors' );
440
- ob_start();
441
- ?>
442
- <p>
443
- <?php _e( 'Sorry, your transaction could not be processed by PayPal. Please contact the site administrator. The following errors are returned:', 'wpsc' ); ?>
444
- </p>
445
- <ul>
446
- <?php foreach ( $errors as $error ): ?>
447
- <li><?php echo esc_html( $error['details'] ) ?> (<?php echo esc_html( $error['code'] ); ?>)</li>
448
- <?php endforeach; ?>
449
- </ul>
450
- <p><a href="<?php echo esc_url( $this->get_shopping_cart_payment_url() ); ?>"><?php _e( 'Click here to go back to the checkout page.', 'wpsc' ) ?></a></p>
451
- <?php
452
- $output = apply_filters( 'wpsc_paypal_express_checkout_gateway_error_message', ob_get_clean(), $errors );
453
- return $output;
454
- }
455
-
456
- /**
457
- * Generic Error Page Template
458
- *
459
- * @since 3.9
460
- */
461
- public function filter_generic_error_page() {
462
- ob_start();
463
- ?>
464
- <p><?php _e( 'Sorry, but your transaction could not be processed by PayPal for some reason. Please contact the site administrator.', 'wpsc' ); ?></p>
465
- <p><a href="<?php echo esc_attr( $this->get_shopping_cart_payment_url() ); ?>"><?php _e( 'Click here to go back to the checkout page.', 'wpsc' ) ?></a></p>
466
- <?php
467
- $output = apply_filters( 'wpsc_paypal_express_checkout_generic_error_message', ob_get_clean() );
468
- return $output;
469
- }
470
-
471
- /**
472
- * Settings Form Template
473
- *
474
- * @since 3.9
475
- */
476
- public function setup_form() {
477
- $paypal_currency = $this->get_currency_code();
478
- ?>
479
- <!-- Account Credentials -->
480
- <tr>
481
- <td colspan="2">
482
- <h4><?php _e( 'Account Credentials', 'wpsc' ); ?></h4>
483
- </td>
484
- </tr>
485
- <tr>
486
- <td>
487
- <label for="wpsc-paypal-express-api-username"><?php _e( 'API Username', 'wpsc' ); ?></label>
488
- </td>
489
- <td>
490
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_username' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_username' ) ); ?>" id="wpsc-paypal-express-api-username" />
491
- </td>
492
- </tr>
493
- <tr>
494
- <td>
495
- <label for="wpsc-paypal-express-api-password"><?php _e( 'API Password', 'wpsc' ); ?></label>
496
- </td>
497
- <td>
498
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_password' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_password' ) ); ?>" id="wpsc-paypal-express-api-password" />
499
- </td>
500
- </tr>
501
- <tr>
502
- <td>
503
- <label for="wpsc-paypal-express-api-signature"><?php _e( 'API Signature', 'wpsc' ); ?></label>
504
- </td>
505
- <td>
506
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_signature' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_signature' ) ); ?>" id="wpsc-paypal-express-api-signature" />
507
- </td>
508
- </tr>
509
- <tr>
510
- <td>
511
- <label><?php _e( 'Sandbox Mode', 'wpsc' ); ?></label>
512
- </td>
513
- <td>
514
- <label><input <?php checked( $this->setting->get( 'sandbox_mode' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'sandbox_mode' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
515
- <label><input <?php checked( (bool) $this->setting->get( 'sandbox_mode' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'sandbox_mode' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
516
- </td>
517
- </tr>
518
- <tr>
519
- <td>
520
- <label><?php _e( 'IPN', 'wpsc' ); ?></label>
521
- </td>
522
- <td>
523
- <label><input <?php checked( $this->setting->get( 'ipn' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'ipn' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
524
- <label><input <?php checked( (bool) $this->setting->get( 'ipn' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'ipn' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
525
- </td>
526
- </tr>
527
-
528
- <!-- Cart Customization -->
529
- <tr>
530
- <td colspan="2">
531
- <label><h4><?php _e( 'Cart Customization', 'wpsc'); ?></h4></label>
532
- </td>
533
- </tr>
534
- <tr>
535
- <td>
536
- <label for="wpsc-paypal-express-cart-logo"><?php _e( 'Merchant Logo', 'wpsc' ); ?></label>
537
- </td>
538
- <td>
539
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'cart_logo' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'cart_logo' ) ); ?>" id="wpsc-paypal-express-cart-logo" />
540
- </td>
541
- </tr>
542
- <tr>
543
- <td>
544
- <label for="wpsc-paypal-express-cart-border"><?php _e( 'Cart Border Color', 'wpsc' ); ?></label>
545
- </td>
546
- <td>
547
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'cart_border' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'cart_border' ) ); ?>" id="wpsc-paypal-express-cart-border" />
548
- </td>
549
- </tr>
550
-
551
- <!-- Currency Conversion -->
552
- <?php if ( ! $this->is_currency_supported() ): ?>
553
- <tr>
554
- <td colspan="2">
555
- <h4><?php _e( 'Currency Conversion', 'wpsc' ); ?></h4>
556
- </td>
557
- </tr>
558
- <tr>
559
- <td colspan="2">
560
- <p><?php _e( 'Your base currency is currently not accepted by PayPal. As a result, before a payment request is sent to Paypal, WP eCommerce has to convert the amounts into one of Paypal supported currencies. Please select your preferred currency below.', 'wpsc' ); ?></p>
561
- </td>
562
- </tr>
563
- <tr>
564
- <td>
565
- <label for "wpsc-paypal-express-currency"><?php _e( 'Paypal Currency', 'wpsc' ); ?></label>
566
- </td>
567
- <td>
568
- <select name="<?php echo esc_attr( $this->setting->get_field_name( 'currency' ) ); ?>" id="wpsc-paypal-express-currency">
569
- <?php foreach ($this->gateway->get_supported_currencies() as $currency): ?>
570
- <option <?php selected( $currency, $paypal_currency ); ?> value="<?php echo esc_attr( $currency ); ?>"><?php echo esc_html( $currency ); ?></option>
571
- <?php endforeach ?>
572
- </select>
573
- </td>
574
- </tr>
575
- <?php endif ?>
576
-
577
- <!-- Error Logging -->
578
- <tr>
579
- <td colspan="2">
580
- <h4><?php _e( 'Error Logging', 'wpsc' ); ?></h4>
581
- </td>
582
- </tr>
583
- <tr>
584
- <td>
585
- <label><?php _e( 'Enable Debugging', 'wpsc' ); ?></label>
586
- </td>
587
- <td>
588
- <label><input <?php checked( $this->setting->get( 'debugging' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
589
- <label><input <?php checked( (bool) $this->setting->get( 'debugging' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
590
- </td>
591
- </tr>
592
- <?php
593
- }
594
-
595
- /**
596
- * Process the SetExpressCheckout API Call
597
- *
598
- * @param array $args
599
- * @return void
600
- *
601
- * @since 3.9
602
- */
603
- public function process( $args = array() ) {
604
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
605
- $options = array(
606
- 'return_url' => $this->get_return_url(),
607
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
608
- 'invoice' => $this->purchase_log->get( 'sessionid' ) . '-' . $this->purchase_log->get( 'id' ),
609
- 'address_override' => 1,
610
- );
611
- $options += $this->checkout_data->get_gateway_data();
612
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
613
-
614
- if ( $this->setting->get( 'ipn', false ) ) {
615
- $options['notify_url'] = $this->get_notify_url();
616
- }
617
-
618
- $response = $this->gateway->setup_purchase( $options );
619
-
620
- if ( $response->is_successful() ) {
621
- $url = ( $this->setting->get( 'sandbox_mode' ) ? self::SANDBOX_URL : self::LIVE_URL ) . $response->get( 'token' );
622
- } else {
623
- $this->log_error( $response );
624
- $url = add_query_arg( array(
625
- 'payment_gateway' => 'paypal-digital-goods',
626
- 'payment_gateway_callback' => 'display_paypal_error_redirect',
627
- 'return_url' => base64_encode( $this->get_return_url() ),
628
- ), $this->get_return_url() );
629
- }
630
-
631
- if( ! isset( $args['return_only'] ) || $args['return_only'] !== true ) {
632
- wp_redirect( $url );
633
- exit;
634
- }
635
-
636
- return $url;
637
- }
638
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php DELETED
@@ -1,713 +0,0 @@
1
- <?php
2
- /**
3
- * The PayPal Express Checkout Gateway class
4
- *
5
- */
6
-
7
- class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway {
8
- public $sandbox_url = 'https://www.sandbox.paypal.com/webscr';
9
- public $live_url = 'https://www.paypal.com/cgi-bin/webscr';
10
- private $gateway;
11
-
12
- /**
13
- * Constructor of PayPal Express Checkout Gateway
14
- *
15
- * @param array $options
16
- * @return void
17
- *
18
- * @since 3.9
19
- */
20
- public function __construct( $options ) {
21
- parent::__construct();
22
- $this->title = __( 'PayPal Express Checkout 3.0', 'wpsc' );
23
-
24
- require_once( 'php-merchant/gateways/paypal-express-checkout.php' );
25
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $options );
26
- $this->gateway->set_options( array(
27
- 'api_username' => $this->setting->get( 'api_username' ),
28
- 'api_password' => $this->setting->get( 'api_password' ),
29
- 'api_signature' => $this->setting->get( 'api_signature' ),
30
- 'cancel_url' => $this->get_shopping_cart_payment_url(),
31
- 'currency' => $this->get_currency_code(),
32
- 'test' => (bool) $this->setting->get( 'sandbox_mode' ),
33
- 'address_override' => 1,
34
- 'solution_type' => 'mark',
35
- 'cart_logo' => $this->setting->get( 'cart_logo' ),
36
- 'cart_border' => $this->setting->get( 'cart_border' ),
37
- ) );
38
-
39
- add_filter( 'wpsc_purchase_log_gateway_data', array( $this, 'filter_purchase_log_gateway_data' ), 10, 2 );
40
- add_filter(
41
- 'wpsc_payment_method_form_fields',
42
- array( $this, 'filter_unselect_default' ), 100 , 1
43
- );
44
- }
45
-
46
- /**
47
- * Returns the HTML of the logo of the payment gateway.
48
- *
49
- * @access public
50
- * @return string
51
- *
52
- * @since 3.9
53
- */
54
- public function get_mark_html() {
55
- $html = '<a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="' . esc_attr__( 'How PayPal Works' ) . '" onclick="javascript:window.open(\'https://www.paypal.com/webapps/mpp/paypal-popup\',\'WIPaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700\'); return false;"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg" border="0" alt="PayPal Logo"></a>';
56
-
57
- return apply_filters( 'wpsc_paypal-ec_mark_html', $html );
58
- }
59
-
60
- /**
61
- * No payment gateway is selected by default
62
- *
63
- * @access public
64
- * @param array $fields
65
- * @return array
66
- *
67
- * @since 3.9
68
- */
69
- public function filter_unselect_default( $fields ) {
70
- foreach ( $fields as $i=>$field ) {
71
- $fields[ $i ][ 'checked' ] = false;
72
- }
73
-
74
- return $fields;
75
- }
76
-
77
- /**
78
- * Returns the PayPal redirect URL
79
- *
80
- * @param array $data Arguments to encode with the URL
81
- * @return string
82
- *
83
- * @since 3.9
84
- */
85
- public function get_redirect_url( $data = array() ) {
86
-
87
- // Select either the Sandbox or the Live URL
88
- if ( $this->setting->get( 'sandbox_mode' ) ) {
89
- $url = $this->sandbox_url;
90
- } else {
91
- $url = $this->live_url;
92
- }
93
-
94
- // Common Vars
95
- $common = array(
96
- 'cmd' => '_express-checkout',
97
- 'useraction' => 'commit',
98
- );
99
-
100
- if ( wp_is_mobile() ) {
101
- $common['cmd'] = '_express-checkout-mobile';
102
- }
103
-
104
- // Merge the two arrays
105
- $data = array_merge( $data, $common );
106
-
107
- // Build the URL
108
- $url = add_query_arg( $data, $url );
109
-
110
- return $url;
111
- }
112
-
113
- /**
114
- * Purchase Log Filter for Gateway Data
115
- *
116
- * @param array $gateway_data
117
- * @param array $data
118
- * @return array
119
- *
120
- * @since 3.9
121
- */
122
- public static function filter_purchase_log_gateway_data( $gateway_data, $data ) {
123
- // Because paypal express checkout API doesn't have full support for discount, we have to manually add an item here
124
- if ( isset( $gateway_data['discount'] ) && (float) $gateway_data['discount'] != 0 ) {
125
- $i =& $gateway_data['items'];
126
- $d =& $gateway_data['discount'];
127
- $s =& $gateway_data['subtotal'];
128
-
129
- // If discount amount is larger than or equal to the item total, we need to set item total to 0.01
130
- // because Paypal does not accept 0 item total.
131
- if ( $d >= $gateway_data['subtotal'] ) {
132
- $d = $s - 0.01;
133
-
134
- // if there's shipping, we'll take 0.01 from there
135
- if ( ! empty( $gateway_data['shipping'] ) ) {
136
- $gateway_data['shipping'] -= 0.01;
137
- } else {
138
- $gateway_data['amount'] = 0.01;
139
- }
140
- }
141
-
142
- $s -= $d;
143
-
144
- $i[] = array(
145
- 'name' => __( 'Discount', 'wpsc' ),
146
- 'amount' => - $d,
147
- 'quantity' => 1,
148
- );
149
- }
150
- return $gateway_data;
151
- }
152
-
153
- /**
154
- * Returns the URL of the Return Page after the PayPal Checkout
155
- *
156
- * @return string
157
- */
158
- protected function get_return_url() {
159
- $location = add_query_arg( array(
160
- 'sessionid' => $this->purchase_log->get( 'sessionid' ),
161
- 'payment_gateway' => 'paypal-express-checkout',
162
- 'payment_gateway_callback' => 'confirm_transaction',
163
- ),
164
- get_option( 'transact_url' )
165
- );
166
- return apply_filters( 'wpsc_paypal_express_checkout_return_url', $location, $this );
167
- }
168
-
169
- /**
170
- * Returns the URL of the IPN Page
171
- *
172
- * @return string
173
- */
174
- protected function get_notify_url() {
175
- $location = add_query_arg( array(
176
- 'payment_gateway' => 'paypal-express-checkout',
177
- 'payment_gateway_callback' => 'ipn',
178
- ), home_url( 'index.php' ) );
179
-
180
- return apply_filters( 'wpsc_paypal_express_checkout_notify_url', $location );
181
- }
182
-
183
- /**
184
- * Creates a new Purchase Log entry and set it to the current object
185
- *
186
- * @return null
187
- */
188
- protected function set_purchase_log_for_callbacks( $sessionid = false ) {
189
- // Define the sessionid if it's not passed
190
- if ( $sessionid === false ) {
191
- $sessionid = $_REQUEST['sessionid'];
192
- }
193
-
194
- // Create a new Purchase Log entry
195
- $purchase_log = new WPSC_Purchase_Log( $sessionid, 'sessionid' );
196
-
197
- if ( ! $purchase_log->exists() ) {
198
- return null;
199
- }
200
-
201
- // Set the Purchase Log for the gateway object
202
- $this->set_purchase_log( $purchase_log );
203
- }
204
-
205
- /**
206
- * IPN Callback function
207
- *
208
- * @return void
209
- */
210
- public function callback_ipn() {
211
- $ipn = new PHP_Merchant_Paypal_IPN( false, (bool) $this->setting->get( 'sandbox_mode', false ) );
212
-
213
- if ( $ipn->is_verified() ) {
214
- $sessionid = $ipn->get( 'invoice' );
215
- $this->set_purchase_log_for_callbacks( $sessionid );
216
-
217
- if ( $ipn->is_payment_denied() ) {
218
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::PAYMENT_DECLINED );
219
- } elseif ( $ipn->is_payment_refunded() ) {
220
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::REFUNDED );
221
- } elseif ( $ipn->is_payment_completed() ) {
222
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
223
- } elseif ( $ipn->is_payment_pending() ) {
224
- if ( $ipn->is_payment_refund_pending() ) {
225
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::REFUND_PENDING );
226
- } else {
227
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
228
- }
229
- }
230
-
231
- $this->purchase_log->save();
232
- transaction_results( $sessionid, false );
233
- }
234
-
235
- exit;
236
- }
237
-
238
- /**
239
- * Confirm Transaction Callback
240
- *
241
- * @return bool
242
- *
243
- * @since 3.9
244
- */
245
- public function callback_confirm_transaction() {
246
- if ( ! isset( $_REQUEST['sessionid'] ) || ! isset( $_REQUEST['token'] ) || ! isset( $_REQUEST['PayerID'] ) ) {
247
- return false;
248
- }
249
-
250
- // Set the Purchase Log
251
- $this->set_purchase_log_for_callbacks();
252
-
253
- // Display the Confirmation Page
254
- $this->do_transaction();
255
- }
256
-
257
- /**
258
- * Process the transaction through the PayPal APIs
259
- *
260
- * @since 3.9
261
- */
262
- public function do_transaction() {
263
- $args = array_map( 'urldecode', $_GET );
264
- extract( $args, EXTR_SKIP );
265
-
266
- if ( ! isset( $sessionid ) || ! isset( $token ) || ! isset( $PayerID ) ) {
267
- return;
268
- }
269
-
270
- $this->set_purchase_log_for_callbacks();
271
-
272
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
273
- $options = array(
274
- 'token' => $token,
275
- 'payer_id' => $PayerID,
276
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
277
- 'invoice' => $this->purchase_log->get( 'id' ),
278
- );
279
- $options += $this->checkout_data->get_gateway_data();
280
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
281
-
282
- if ( $this->setting->get( 'ipn', false ) ) {
283
- $options['notify_url'] = $this->get_notify_url();
284
- }
285
-
286
- // GetExpressCheckoutDetails
287
- $details = $this->gateway->get_details_for( $token );
288
- $this->log_payer_details( $details );
289
-
290
- $response = $this->gateway->purchase( $options );
291
- $this->log_protection_status( $response );
292
- $location = remove_query_arg( 'payment_gateway_callback' );
293
-
294
- if ( $response->has_errors() ) {
295
- $errors = $response->get_params();
296
-
297
- if ( isset( $errors['L_ERRORCODE0'] ) && '10486' == $errors['L_ERRORCODE0'] ) {
298
- wp_redirect( $this->get_redirect_url( array( 'token' => $token ) ) );
299
- exit;
300
- }
301
-
302
- wpsc_update_customer_meta( 'paypal_express_checkout_errors', $response->get_errors() );
303
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_paypal_error' ) );
304
-
305
- } elseif ( $response->is_payment_completed() || $response->is_payment_pending() ) {
306
- $location = remove_query_arg( 'payment_gateway' );
307
-
308
- if ( $response->is_payment_completed() ) {
309
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
310
- } else {
311
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
312
- }
313
-
314
- $this->purchase_log->set( 'transactid', $response->get( 'transaction_id' ) )
315
- ->set( 'date', time() )
316
- ->save();
317
- } else {
318
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_generic_error' ) );
319
- }
320
-
321
- wp_redirect( $location );
322
- exit;
323
- }
324
-
325
- public function callback_display_paypal_error() {
326
- add_filter( 'wpsc_get_transaction_html_output', array( $this, 'filter_paypal_error_page' ) );
327
- }
328
-
329
- public function callback_display_generic_error() {
330
- add_filter( 'wpsc_get_transaction_html_output', array( $this, 'filter_generic_error_page' ) );
331
- }
332
-
333
- /**
334
- * Records the Payer ID, Payer Status and Shipping Status to the Purchase
335
- * Log on GetExpressCheckout Call
336
- *
337
- * @return void
338
- */
339
- public function log_payer_details( $details ) {
340
- if ( isset( $details->get( 'payer' )->id ) && !empty( $details->get( 'payer' )->id ) ) {
341
- $payer_id = $details->get( 'payer' )->id;
342
- } else {
343
- $payer_id = 'not set';
344
- }
345
- if ( isset( $details->get( 'payer' )->status ) && !empty( $details->get( 'payer' )->status ) ) {
346
- $payer_status = $details->get( 'payer' )->status;
347
- } else {
348
- $payer_status = 'not set';
349
- }
350
- if ( isset( $details->get( 'payer' )->shipping_status ) && !empty( $details->get( 'payer' )->shipping_status ) ) {
351
- $payer_shipping_status = $details->get( 'payer' )->shipping_status;
352
- } else {
353
- $payer_shipping_status = 'not set';
354
- }
355
- $paypal_log = array(
356
- 'payer_id' => $payer_id,
357
- 'payer_status' => $payer_status,
358
- 'shipping_status' => $payer_shipping_status,
359
- 'protection' => null,
360
- );
361
-
362
- wpsc_update_purchase_meta( $this->purchase_log->get( 'id' ), 'paypal_ec_details' , $paypal_log );
363
- }
364
-
365
- /**
366
- * Records the Protection Eligibility status to the Purchase Log on
367
- * DoExpressCheckout Call
368
- *
369
- * @return void
370
- */
371
- public function log_protection_status( $response ) {
372
- $params = $response->get_params();
373
-
374
- $elg = $params['PAYMENTINFO_0_PROTECTIONELIGIBILITY'];
375
- $paypal_log = wpsc_get_purchase_meta( $this->purchase_log->get( 'id' ), 'paypal_ec_details', true );
376
- $paypal_log['protection'] = $elg;
377
- wpsc_update_purchase_meta( $this->purchase_log->get( 'id' ), 'paypal_ec_details' , $paypal_log );
378
- }
379
-
380
- public function callback_process_confirmed_payment() {
381
- $args = array_map( 'urldecode', $_GET );
382
- extract( $args, EXTR_SKIP );
383
-
384
- if ( ! isset( $sessionid ) || ! isset( $token ) || ! isset( $PayerID ) ) {
385
- return;
386
- }
387
-
388
- $this->set_purchase_log_for_callbacks();
389
-
390
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
391
- $options = array(
392
- 'token' => $token,
393
- 'payer_id' => $PayerID,
394
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
395
- 'invoice' => $this->purchase_log->get( 'id' ),
396
- );
397
- $options += $this->checkout_data->get_gateway_data();
398
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
399
-
400
- if ( $this->setting->get( 'ipn', false ) ) {
401
- $options['notify_url'] = $this->get_notify_url();
402
- }
403
-
404
- // GetExpressCheckoutDetails
405
- $details = $this->gateway->get_details_for( $token );
406
- $this->log_payer_details( $details );
407
-
408
- $response = $this->gateway->purchase( $options );
409
- $this->log_protection_status( $response );
410
- $location = remove_query_arg( 'payment_gateway_callback' );
411
-
412
- if ( $response->has_errors() ) {
413
- wpsc_update_customer_meta( 'paypal_express_checkout_errors', $response->get_errors() );
414
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_paypal_error' ) );
415
- } elseif ( $response->is_payment_completed() || $response->is_payment_pending() ) {
416
- $location = remove_query_arg( 'payment_gateway' );
417
-
418
- if ( $response->is_payment_completed() ) {
419
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
420
- } else {
421
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
422
- }
423
-
424
- $this->purchase_log->set( 'transactid', $response->get( 'transaction_id' ) )
425
- ->set( 'date', time() )
426
- ->save();
427
- } else {
428
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_generic_error' ) );
429
- }
430
-
431
- wp_redirect( $location );
432
- exit;
433
- }
434
-
435
- /**
436
- * Error Page Template
437
- *
438
- * @since 3.9
439
- */
440
- public function filter_paypal_error_page() {
441
- $errors = wpsc_get_customer_meta( 'paypal_express_checkout_errors' );
442
- ob_start();
443
- ?>
444
- <p>
445
- <?php _e( 'Sorry, your transaction could not be processed by PayPal. Please contact the site administrator. The following errors are returned:' , 'wpsc' ); ?>
446
- </p>
447
- <ul>
448
- <?php foreach ( $errors as $error ): ?>
449
- <li><?php echo esc_html( $error['details'] ) ?> (<?php echo esc_html( $error['code'] ); ?>)</li>
450
- <?php endforeach; ?>
451
- </ul>
452
- <p><a href="<?php echo esc_url( $this->get_shopping_cart_payment_url() ); ?>"><?php ( 'Click here to go back to the checkout page.') ?></a></p>
453
- <?php
454
- $output = apply_filters( 'wpsc_paypal_express_checkout_gateway_error_message', ob_get_clean(), $errors );
455
- return $output;
456
- }
457
-
458
- /**
459
- * Generic Error Page Template
460
- *
461
- * @since 3.9
462
- */
463
- public function filter_generic_error_page() {
464
- ob_start();
465
- ?>
466
- <p><?php _e( 'Sorry, but your transaction could not be processed by PayPal for some reason. Please contact the site administrator.' , 'wpsc' ); ?></p>
467
- <p><a href="<?php echo esc_attr( $this->get_shopping_cart_payment_url() ); ?>"><?php _e( 'Click here to go back to the checkout page.', 'wpsc' ) ?></a></p>
468
- <?php
469
- $output = apply_filters( 'wpsc_paypal_express_checkout_generic_error_message', ob_get_clean() );
470
- return $output;
471
- }
472
-
473
- /**
474
- * Settings Form Template
475
- *
476
- * @since 3.9
477
- */
478
- public function setup_form() {
479
- $paypal_currency = $this->get_currency_code();
480
- ?>
481
-
482
- <!-- Account Credentials -->
483
- <tr>
484
- <td colspan="2">
485
- <h4><?php _e( 'Account Credentials', 'wpsc' ); ?></h4>
486
- </td>
487
- </tr>
488
- <tr>
489
- <td>
490
- <label for="wpsc-paypal-express-api-username"><?php _e( 'API Username', 'wpsc' ); ?></label>
491
- </td>
492
- <td>
493
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_username' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_username' ) ); ?>" id="wpsc-paypal-express-api-username" />
494
- </td>
495
- </tr>
496
- <tr>
497
- <td>
498
- <label for="wpsc-paypal-express-api-password"><?php _e( 'API Password', 'wpsc' ); ?></label>
499
- </td>
500
- <td>
501
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_password' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_password' ) ); ?>" id="wpsc-paypal-express-api-password" />
502
- </td>
503
- </tr>
504
- <tr>
505
- <td>
506
- <label for="wpsc-paypal-express-api-signature"><?php _e( 'API Signature', 'wpsc' ); ?></label>
507
- </td>
508
- <td>
509
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_signature' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_signature' ) ); ?>" id="wpsc-paypal-express-api-signature" />
510
- </td>
511
- </tr>
512
- <tr>
513
- <td>
514
- <label><?php _e( 'Sandbox Mode', 'wpsc' ); ?></label>
515
- </td>
516
- <td>
517
- <label><input <?php checked( $this->setting->get( 'sandbox_mode' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'sandbox_mode' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
518
- <label><input <?php checked( (bool) $this->setting->get( 'sandbox_mode' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'sandbox_mode' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
519
- </td>
520
- </tr>
521
- <tr>
522
- <td>
523
- <label><?php _e( 'IPN', 'wpsc' ); ?></label>
524
- </td>
525
- <td>
526
- <label><input <?php checked( $this->setting->get( 'ipn' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'ipn' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
527
- <label><input <?php checked( (bool) $this->setting->get( 'ipn' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'ipn' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
528
- </td>
529
- </tr>
530
-
531
- <!-- Cart Customization -->
532
- <tr>
533
- <td colspan="2">
534
- <label><h4><?php _e( 'Cart Customization', 'wpsc'); ?></h4></label>
535
- </td>
536
- </tr>
537
- <tr>
538
- <td>
539
- <label for="wpsc-paypal-express-cart-logo"><?php _e( 'Merchant Logo', 'wpsc' ); ?></label>
540
- </td>
541
- <td>
542
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'cart_logo' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'cart_logo' ) ); ?>" id="wpsc-paypal-express-cart-logo" />
543
- </td>
544
- </tr>
545
- <tr>
546
- <td>
547
- <label for="wpsc-paypal-express-cart-border"><?php _e( 'Cart Border Color', 'wpsc' ); ?></label>
548
- </td>
549
- <td>
550
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'cart_border' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'cart_border' ) ); ?>" id="wpsc-paypal-express-cart-border" />
551
- </td>
552
- </tr>
553
-
554
- <!-- Currency Conversion -->
555
- <?php if ( ! $this->is_currency_supported() ) : ?>
556
- <tr>
557
- <td colspan="2">
558
- <h4><?php _e( 'Currency Conversion', 'wpsc' ); ?></h4>
559
- </td>
560
- </tr>
561
- <tr>
562
- <td colspan="2">
563
- <p><?php _e( 'Your base currency is currently not accepted by PayPal. As a result, before a payment request is sent to PayPal, WP eCommerce has to convert the amounts into one of PayPal supported currencies. Please select your preferred currency below.', 'wpsc' ); ?></p>
564
- </td>
565
- </tr>
566
- <tr>
567
- <td>
568
- <label for "wpsc-paypal-express-currency"><?php _e( 'PayPal Currency', 'wpsc' ); ?></label>
569
- </td>
570
- <td>
571
- <select name="<?php echo esc_attr( $this->setting->get_field_name( 'currency' ) ); ?>" id="wpsc-paypal-express-currency">
572
- <?php foreach ( $this->gateway->get_supported_currencies() as $currency ) : ?>
573
- <option <?php selected( $currency, $paypal_currency ); ?> value="<?php echo esc_attr( $currency ); ?>"><?php echo esc_html( $currency ); ?></option>
574
- <?php endforeach ?>
575
- </select>
576
- </td>
577
- </tr>
578
- <?php endif ?>
579
-
580
- <!-- Error Logging -->
581
- <tr>
582
- <td colspan="2">
583
- <h4><?php _e( 'Error Logging', 'wpsc' ); ?></h4>
584
- </td>
585
- </tr>
586
- <tr>
587
- <td>
588
- <label><?php _e( 'Enable Debugging', 'wpsc' ); ?></label>
589
- </td>
590
- <td>
591
- <label><input <?php checked( $this->setting->get( 'debugging' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
592
- <label><input <?php checked( (bool) $this->setting->get( 'debugging' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
593
- </td>
594
- </tr>
595
- <?php
596
- }
597
-
598
- /**
599
- * Check if the selected currency is supported by the gateway
600
- *
601
- * @return bool
602
- *
603
- * @since 3.9
604
- */
605
- protected function is_currency_supported() {
606
- return in_array( parent::get_currency_code(), $this->gateway->get_supported_currencies() );
607
- }
608
-
609
- /**
610
- * Return the Currency ISO code
611
- *
612
- * @return string
613
- *
614
- * @since 3.9
615
- */
616
- public function get_currency_code() {
617
- $code = parent::get_currency_code();
618
-
619
- if ( ! in_array( $code, $this->gateway->get_supported_currencies() ) ) {
620
- $code = $this->setting->get( 'currency', 'USD' );
621
- }
622
-
623
- return $code;
624
- }
625
-
626
- /**
627
- * Convert an amount (integer) to the supported currency
628
- * @param integer $amt
629
- *
630
- * @return integer
631
- *
632
- * @since 3.9
633
- */
634
- protected function convert( $amt ) {
635
- if ( $this->is_currency_supported() ) {
636
- return $amt;
637
- }
638
-
639
- return wpsc_convert_currency( $amt, parent::get_currency_code(), $this->get_currency_code() );
640
- }
641
-
642
- /**
643
- * Process the SetExpressCheckout API Call
644
- *
645
- * @return void
646
- *
647
- * @since 3.9
648
- */
649
- public function process() {
650
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
651
- $options = array(
652
- 'return_url' => $this->get_return_url(),
653
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
654
- 'invoice' => $this->purchase_log->get( 'id' ),
655
- 'address_override' => 1,
656
- );
657
-
658
- $options += $this->checkout_data->get_gateway_data();
659
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
660
-
661
- if ( $this->setting->get( 'ipn', false ) ) {
662
- $options['notify_url'] = $this->get_notify_url();
663
- }
664
-
665
- // SetExpressCheckout
666
- $response = $this->gateway->setup_purchase( $options );
667
-
668
- if ( $response->is_successful() ) {
669
- $params = $response->get_params();
670
- if ( $params['ACK'] == 'SuccessWithWarning' ) {
671
- $this->log_error( $response );
672
- }
673
- // Successful redirect
674
- $url = $this->get_redirect_url( array( 'token' => $response->get( 'token' ) ) );
675
- } else {
676
- // SetExpressCheckout Failure
677
- $this->log_error( $response );
678
- $url = add_query_arg( array(
679
- 'payment_gateway' => 'paypal-express-checkout',
680
- 'payment_gateway_callback' => 'display_paypal_error',
681
- ), $this->get_return_url() );
682
- }
683
-
684
- wp_redirect( $url );
685
- exit;
686
- }
687
-
688
- /**
689
- * Log an error message
690
- *
691
- * @param PHP_Merchant_Paypal_Express_Checkout_Response $response
692
- * @return void
693
- *
694
- * @since 3.9
695
- */
696
- public function log_error( $response ) {
697
- if ( $this->setting->get( 'debugging' ) ) {
698
- $log_data = array(
699
- 'post_title' => 'PayPal ExpressCheckout Operation Failure',
700
- 'post_content' => 'There was an error processing the payment. Find details in the log entry meta fields.',
701
- 'log_type' => 'error'
702
- );
703
-
704
- $log_meta = array(
705
- 'correlation_id' => $response->get( 'correlation_id' ),
706
- 'time' => $response->get( 'datetime' ),
707
- 'errors' => $response->get_errors(),
708
- );
709
-
710
- $log_entry = WPSC_Logging::insert_log( $log_data, $log_meta );
711
- }
712
- }
713
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/paypal-pro.php DELETED
@@ -1,633 +0,0 @@
1
- <?php
2
- /**
3
- * The PayPal Pro Gateway class
4
- *
5
- */
6
-
7
- class WPSC_Payment_Gateway_Paypal_Pro extends WPSC_Payment_Gateway {
8
- private $gateway;
9
-
10
- /**
11
- * Constructor of PayPal Pro Gateway
12
- *
13
- * @param array $options
14
- * @return void
15
- *
16
- * @since 3.9
17
- */
18
- public function __construct( $options ) {
19
- parent::__construct();
20
-
21
- $this->title = __( 'PayPal Pro Hosted', 'wpsc' );
22
-
23
- require_once( 'php-merchant/gateways/paypal-pro.php' );
24
-
25
- $this->gateway = new PHP_Merchant_Paypal_Pro( $options );
26
-
27
- $this->gateway->set_options( array(
28
- 'api_username' => $this->setting->get( 'api_username' ),
29
- 'api_password' => $this->setting->get( 'api_password' ),
30
- 'api_signature' => $this->setting->get( 'api_signature' ),
31
- 'cancel_url' => $this->get_shopping_cart_payment_url(),
32
- 'currency' => $this->get_currency_code(),
33
- 'test' => (bool) $this->setting->get( 'sandbox_mode' ),
34
- ) );
35
-
36
- // Load PayPal Pro JavaScript file
37
- add_action( 'wp_enqueue_scripts', array( $this, 'pro_script' ) );
38
-
39
- add_filter( 'wpsc_purchase_log_gateway_data', array( $this, 'filter_purchase_log_gateway_data' ), 10, 2 );
40
-
41
- // Unselect Default Payment Gateway
42
- add_filter(
43
- 'wpsc_payment_method_form_fields',
44
- array( $this, 'filter_unselect_default' ), 101 , 1
45
- );
46
- }
47
-
48
- /**
49
- * No payment gateway is selected by default
50
- *
51
- * @access public
52
- * @param array $fields
53
- * @return array
54
- *
55
- * @since 3.9
56
- */
57
- public function filter_unselect_default( $fields ) {
58
- foreach ( $fields as $i=>$field ) {
59
- $fields[ $i ][ 'checked' ] = false;
60
- }
61
-
62
- return $fields;
63
- }
64
-
65
- /**
66
- * Returns the HTML of the logo of the payment gateway.
67
- *
68
- * @access public
69
- * @return string
70
- *
71
- * @since 3.9
72
- */
73
- public function get_mark_html() {
74
- $html = '<img src="' . WPSC_URL . '/images/cc.gif" border="0" alt="' . esc_attr__( 'Credit Card Icons' ) .'" />';
75
-
76
- return apply_filters( 'wpsc_paypal-pro_mark_html', $html );
77
- }
78
-
79
- /**
80
- * WordPress Enqueue for the Pro Script and CSS file
81
- *
82
- * @return void
83
- *
84
- * @since 3.9
85
- */
86
- public function pro_script() {
87
- if ( wpsc_is_checkout() ) {
88
- wp_enqueue_script( 'pro-script-internal', WPSC_URL . '/wpsc-components/merchant-core-v3/gateways/pro.js', array( 'jquery' ) );
89
- wp_enqueue_style( 'pro-syle-internal', WPSC_URL . '/wpsc-components/merchant-core-v3/gateways/pro.css' );
90
- }
91
- }
92
-
93
- /**
94
- * Purchase Log Filter for Gateway Data
95
- *
96
- * @param array $gateway_data
97
- * @param array $data
98
- * @return array
99
- *
100
- * @since 3.9
101
- */
102
- public static function filter_purchase_log_gateway_data( $gateway_data, $data ) {
103
- // Because paypal express checkout API doesn't have full support for discount, we have to manually add an item here
104
- if ( isset( $gateway_data['discount'] ) && (float) $gateway_data['discount'] != 0 ) {
105
- $i =& $gateway_data['items'];
106
- $d =& $gateway_data['discount'];
107
- $s =& $gateway_data['subtotal'];
108
-
109
- // If discount amount is larger than or equal to the item total, we need to set item total to 0.01
110
- // because Paypal does not accept 0 item total.
111
- if ( $d >= $gateway_data['subtotal'] ) {
112
- $d = $s - 0.01;
113
-
114
- // if there's shipping, we'll take 0.01 from there
115
- if ( ! empty( $gateway_data['shipping'] ) ) {
116
- $gateway_data['shipping'] -= 0.01;
117
- } else {
118
- $gateway_data['amount'] = 0.01;
119
- }
120
- }
121
-
122
- $s -= $d;
123
-
124
- $i[] = array(
125
- 'name' => __( 'Discount', 'wpsc' ),
126
- 'amount' => - $d,
127
- 'quantity' => 1,
128
- );
129
- }
130
- return $gateway_data;
131
- }
132
-
133
- /**
134
- * Returns the URL of the Return Page after the PayPal Checkout
135
- *
136
- * @return string
137
- */
138
- protected function get_return_url() {
139
- $location = add_query_arg( array(
140
- 'sessionid' => $this->purchase_log->get( 'sessionid' ),
141
- 'payment_gateway' => 'paypal-pro',
142
- 'payment_gateway_callback' => 'confirm_transaction',
143
- ),
144
- get_option( 'transact_url' )
145
- );
146
- return apply_filters( 'wpsc_paypal_pro_return_url', $location, $this );
147
-
148
- }
149
-
150
- /**
151
- * Returns the URL of the IPN Page
152
- *
153
- * @return string
154
- */
155
- protected function get_notify_url() {
156
- $location = add_query_arg( array(
157
- 'payment_gateway' => 'paypal-pro',
158
- 'payment_gateway_callback' => 'ipn',
159
- ), home_url( 'index.php' ) );
160
-
161
- return apply_filters( 'wpsc_paypal_pro_notify_url', $location );
162
- }
163
-
164
- /**
165
- * Creates a new Purchase Log entry and set it to the current object
166
- * @param bool|int ID or session id
167
- *
168
- * @return null
169
- */
170
- protected function set_purchase_log_for_callbacks( $id = false, $sessionid = false ) {
171
- // Define the sessionid if it's not passed
172
- if ( $id === false ) {
173
- $id = $_REQUEST['sessionid'];
174
- }
175
-
176
- // Create a new Purchase Log entry
177
- if ( $sessionid === 'sessionid' ) {
178
- $purchase_log = new WPSC_Purchase_Log( $id, 'sessionid' );
179
- } else {
180
- $purchase_log = new WPSC_Purchase_Log( $id, 'id' );
181
- }
182
-
183
- if ( ! $purchase_log->exists() ) {
184
- return null;
185
- }
186
-
187
- // Set the Purchase Log for the gateway object
188
- $this->set_purchase_log( $purchase_log );
189
- }
190
-
191
- /**
192
- * IPN Callback function
193
- *
194
- * @return void
195
- */
196
- public function callback_ipn() {
197
- $ipn = new PHP_Merchant_Paypal_IPN( false, (bool) $this->setting->get( 'sandbox_mode', false ) );
198
-
199
- if ( $ipn->is_verified() ) {
200
- $sessionid = $ipn->get( 'invoice' );
201
- $this->set_purchase_log_for_callbacks( $sessionid );
202
-
203
- if ( $ipn->is_payment_denied() ) {
204
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::PAYMENT_DECLINED );
205
- } elseif ( $ipn->is_payment_refunded() ) {
206
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::REFUNDED );
207
- } elseif ( $ipn->is_payment_completed() ) {
208
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
209
- } elseif ( $ipn->is_payment_pending() ) {
210
- if ( $ipn->is_payment_refund_pending() ) {
211
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::REFUND_PENDING );
212
- } else {
213
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
214
- }
215
- }
216
-
217
- $this->purchase_log->save();
218
- transaction_results( $sessionid, false );
219
- }
220
-
221
- exit;
222
- }
223
-
224
- /**
225
- * Confirm Transaction Callback
226
- *
227
- * @return bool
228
- *
229
- * @since 3.9
230
- */
231
- public function callback_confirm_transaction() {
232
- if ( ! isset( $_REQUEST['sessionid'] ) || ! isset( $_REQUEST['tx'] ) ) {
233
- return false;
234
- }
235
-
236
- // Set the Purchase Log
237
- $this->set_purchase_log_for_callbacks();
238
-
239
- // Display the Confirmation Page
240
- $this->do_transaction();
241
- }
242
-
243
- /**
244
- * Process the transaction through the PayPal APIs
245
- *
246
- * @since 3.9
247
- */
248
- public function do_transaction() {
249
- $args = array_map( 'urldecode', $_GET );
250
- extract( $args, EXTR_SKIP );
251
-
252
- if ( ! isset( $sessionid ) || ! isset( $tx ) || ! isset( $CSCMATCH ) ) {
253
- return;
254
- }
255
-
256
- $this->set_purchase_log_for_callbacks( $sessionid, 'sessionid' );
257
-
258
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
259
-
260
- $options = array(
261
- 'tx' => $tx,
262
- 'CSCMATCH' => $CSCMATCH,
263
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
264
- 'invoice' => $this->purchase_log->get( 'id' ),
265
- );
266
-
267
- $options += $this->checkout_data->get_gateway_data();
268
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
269
-
270
- if ( $this->setting->get( 'ipn', false ) ) {
271
- $options['notify_url'] = $this->get_notify_url();
272
- }
273
-
274
- $response = $this->gateway->get_transaction_details( $tx );
275
-
276
- $this->log_payer_details( $response );
277
- $this->log_protection_status( $response );
278
- $location = remove_query_arg( 'payment_gateway_callback' );
279
-
280
- if ( $response->has_errors() ) {
281
- wpsc_update_customer_meta( 'paypal_pro_errors', $response->get_errors() );
282
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_paypal_error' ) );
283
- } elseif ( $response->is_payment_completed() || $response->is_payment_pending() ) {
284
- $location = remove_query_arg( 'payment_gateway' );
285
-
286
- if ( $response->is_payment_completed() ) {
287
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ACCEPTED_PAYMENT );
288
- } else {
289
- $this->purchase_log->set( 'processed', WPSC_Purchase_Log::ORDER_RECEIVED );
290
- }
291
-
292
- $this->purchase_log->set( 'transactid', $response->get( 'transaction_id' ) )
293
- ->set( 'date', time() )
294
- ->save();
295
- } else {
296
- $location = add_query_arg( array( 'payment_gateway_callback' => 'display_generic_error' ) );
297
- }
298
-
299
- wp_redirect( $location );
300
- exit;
301
- }
302
-
303
- public function callback_display_paypal_error() {
304
- add_filter( 'wpsc_get_transaction_html_output', array( $this, 'filter_paypal_error_page' ) );
305
- }
306
-
307
- public function callback_display_generic_error() {
308
- add_filter( 'wpsc_get_transaction_html_output', array( $this, 'filter_generic_error_page' ) );
309
- }
310
-
311
- /**
312
- * Records the Payer ID, Payer Status and Shipping Status to the Purchase
313
- * Log on GetExpressCheckout Call
314
- *
315
- * @return void
316
- */
317
- public function log_payer_details( $details ) {
318
- if ( isset( $details->get( 'payer' )->id ) && !empty( $details->get( 'payer' )->id ) ) {
319
- $payer_id = $details->get( 'payer' )->id;
320
- } else {
321
- $payer_id = 'not set';
322
- }
323
- if ( isset( $details->get( 'payer' )->status ) && !empty( $details->get( 'payer' )->status ) ) {
324
- $payer_status = $details->get( 'payer' )->status;
325
- } else {
326
- $payer_status = 'not set';
327
- }
328
- if ( isset( $details->get( 'payer' )->shipping_status ) && !empty( $details->get( 'payer' )->shipping_status ) ) {
329
- $payer_shipping_status = $details->get( 'payer' )->shipping_status;
330
- } else {
331
- $payer_shipping_status = 'not set';
332
- }
333
- $paypal_log = array(
334
- 'payer_id' => $payer_id,
335
- 'payer_status' => $payer_status,
336
- 'shipping_status' => $payer_shipping_status,
337
- 'protection' => null,
338
- );
339
-
340
- wpsc_update_purchase_meta( $this->purchase_log->get( 'id' ), 'paypal_pro_details' , $paypal_log );
341
- }
342
-
343
- /**
344
- * Records the Protection Eligibility status to the Purchase Log
345
- * after the purchase process
346
- *
347
- * @param PHP_Merchant_Paypal_Pro_Response $response
348
- * @return void
349
- */
350
- public function log_protection_status( $response ) {
351
- $params = $response->get_params();
352
-
353
- $elg = $params['PROTECTIONELIGIBILITY'];
354
- $paypal_log = wpsc_get_purchase_meta( $this->purchase_log->get( 'id' ), 'paypal_pro_details', true );
355
- $paypal_log['protection'] = $elg;
356
- wpsc_update_purchase_meta( $this->purchase_log->get( 'id' ), 'paypal_pro_details' , $paypal_log );
357
- }
358
-
359
- public function callback_process_confirmed_payment() {
360
-
361
- }
362
-
363
- /**
364
- * Error Page Template
365
- *
366
- * @since 3.9
367
- */
368
- public function filter_paypal_error_page() {
369
- $errors = wpsc_get_customer_meta( 'paypal_pro_errors' );
370
- ob_start();
371
- ?>
372
- <p>
373
- <?php _e( 'Sorry, your transaction could not be processed by PayPal. Please contact the site administrator. The following errors are returned:' , 'wpsc' ); ?>
374
- </p>
375
- <ul>
376
- <?php foreach ( $errors as $error ): ?>
377
- <li><?php echo esc_html( $error['details'] ) ?> (<?php echo esc_html( $error['code'] ); ?>)</li>
378
- <?php endforeach; ?>
379
- </ul>
380
- <p><a href="<?php echo esc_url( $this->get_shopping_cart_payment_url() ); ?>"><?php ( 'Click here to go back to the checkout page.') ?></a></p>
381
- <?php
382
- $output = apply_filters( 'wpsc_paypal_pro_gateway_error_message', ob_get_clean(), $errors );
383
- return $output;
384
- }
385
-
386
- /**
387
- * Generic Error Page Template
388
- *
389
- * @since 3.9
390
- */
391
- public function filter_generic_error_page() {
392
- ob_start();
393
- ?>
394
- <p><?php _e( 'Sorry, but your transaction could not be processed by PayPal for some reason. Please contact the site administrator.' , 'wpsc' ); ?></p>
395
- <p><a href="<?php echo esc_attr( $this->get_shopping_cart_payment_url() ); ?>"><?php _e( 'Click here to go back to the checkout page.', 'wpsc' ) ?></a></p>
396
- <?php
397
- $output = apply_filters( 'wpsc_paypal_pro_generic_error_message', ob_get_clean() );
398
- return $output;
399
- }
400
-
401
- /**
402
- * Settings Form Template
403
- *
404
- * @since 3.9
405
- */
406
- public function setup_form() {
407
- $paypal_currency = $this->get_currency_code();
408
- ?>
409
-
410
- <!-- Account Credentials -->
411
- <tr>
412
- <td colspan="2">
413
- <h4><?php _e( 'Account Credentials', 'wpsc' ); ?></h4>
414
- </td>
415
- </tr>
416
- <tr>
417
- <td>
418
- <label for="wpsc-paypal-pro-vendor-id"><?php _e( 'Vendor ID', 'wpsc' ); ?></label>
419
- </td>
420
- <td>
421
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'vendor_id' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'vendor_id' ) ); ?>" id="wpsc-paypal-pro-vendor-id" />
422
- </td>
423
- </tr>
424
- <tr>
425
- <td>
426
- <label for="wpsc-paypal-pro-api-username"><?php _e( 'API Username', 'wpsc' ); ?></label>
427
- </td>
428
- <td>
429
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_username' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_username' ) ); ?>" id="wpsc-paypal-pro-api-username" />
430
- </td>
431
- </tr>
432
- <tr>
433
- <td>
434
- <label for="wpsc-paypal-pro-api-password"><?php _e( 'API Password', 'wpsc' ); ?></label>
435
- </td>
436
- <td>
437
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_password' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_password' ) ); ?>" id="wpsc-paypal-pro-api-password" />
438
- </td>
439
- </tr>
440
- <tr>
441
- <td>
442
- <label for="wpsc-paypal-pro-api-signature"><?php _e( 'API Signature', 'wpsc' ); ?></label>
443
- </td>
444
- <td>
445
- <input type="text" name="<?php echo esc_attr( $this->setting->get_field_name( 'api_signature' ) ); ?>" value="<?php echo esc_attr( $this->setting->get( 'api_signature' ) ); ?>" id="wpsc-paypal-pro-api-signature" />
446
- </td>
447
- </tr>
448
- <tr>
449
- <td>
450
- <label><?php _e( 'Sandbox Mode', 'wpsc' ); ?></label>
451
- </td>
452
- <td>
453
- <label><input <?php checked( $this->setting->get( 'sandbox_mode' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'sandbox_mode' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
454
- <label><input <?php checked( (bool) $this->setting->get( 'sandbox_mode' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'sandbox_mode' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
455
- </td>
456
- </tr>
457
- <tr>
458
- <td>
459
- <label><?php _e( 'IPN', 'wpsc' ); ?></label>
460
- </td>
461
- <td>
462
- <label><input <?php checked( $this->setting->get( 'ipn' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'ipn' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
463
- <label><input <?php checked( (bool) $this->setting->get( 'ipn' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'ipn' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
464
- </td>
465
- </tr>
466
-
467
- <!-- Currency Conversion -->
468
- <?php if ( ! $this->is_currency_supported() ): ?>
469
- <tr>
470
- <td colspan="2">
471
- <h4><?php _e( 'Currency Conversion', 'wpsc' ); ?></h4>
472
- </td>
473
- </tr>
474
- <tr>
475
- <td colspan="2">
476
- <p><?php _e( 'Your base currency is currently not accepted by PayPal. As a result, before a payment request is sent to PayPal, WP eCommerce has to convert the amounts into one of PayPal supported currencies. Please select your preferred currency below.', 'wpsc' ); ?></p>
477
- </td>
478
- </tr>
479
- <tr>
480
- <td>
481
- <label for "wpsc-paypal-pro-currency"><?php _e( 'PayPal Currency', 'wpsc' ); ?></label>
482
- </td>
483
- <td>
484
- <select name="<?php echo esc_attr( $this->setting->get_field_name( 'currency' ) ); ?>" id="wpsc-paypal-pro-currency">
485
- <?php foreach ( $this->gateway->get_supported_currencies() as $currency ) : ?>
486
- <option <?php selected( $currency, $paypal_currency ); ?> value="<?php echo esc_attr( $currency ); ?>"><?php echo esc_html( $currency ); ?></option>
487
- <?php endforeach ?>
488
- </select>
489
- </td>
490
- </tr>
491
- <?php endif ?>
492
-
493
- <!-- Error Logging -->
494
- <tr>
495
- <td colspan="2">
496
- <h4><?php _e( 'Error Logging', 'wpsc' ); ?></h4>
497
- </td>
498
- </tr>
499
- <tr>
500
- <td>
501
- <label><?php _e( 'Enable Debugging', 'wpsc' ); ?></label>
502
- </td>
503
- <td>
504
- <label><input <?php checked( $this->setting->get( 'debugging' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>&nbsp;&nbsp;&nbsp;
505
- <label><input <?php checked( (bool) $this->setting->get( 'debugging' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'debugging' ) ); ?>" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label>
506
- </td>
507
- </tr>
508
- <?php
509
- }
510
-
511
- /**
512
- * Check if the selected currency is supported by the gateway
513
- *
514
- * @return bool
515
- *
516
- * @since 3.9
517
- */
518
- protected function is_currency_supported() {
519
- return in_array( parent::get_currency_code(), $this->gateway->get_supported_currencies() );
520
- }
521
-
522
- /**
523
- * Return the Currency ISO code
524
- *
525
- * @return string
526
- *
527
- * @since 3.9
528
- */
529
- public function get_currency_code() {
530
- $code = parent::get_currency_code();
531
-
532
- if ( ! in_array( $code, $this->gateway->get_supported_currencies() ) ) {
533
- $code = $this->setting->get( 'currency', 'USD' );
534
- }
535
-
536
- return $code;
537
- }
538
-
539
- /**
540
- * Convert an amount (integer) to the supported currency
541
- * @param integer $amt
542
- *
543
- * @return integer
544
- *
545
- * @since 3.9
546
- */
547
- protected function convert( $amt ) {
548
- if ( $this->is_currency_supported() ) {
549
- return $amt;
550
- }
551
-
552
- return wpsc_convert_currency( $amt, parent::get_currency_code(), $this->get_currency_code() );
553
- }
554
-
555
- /**
556
- * Call the CreateButton API
557
- *
558
- * @return void
559
- *
560
- * @since 3.9
561
- */
562
- public function process() {
563
- $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
564
- $options = array(
565
- 'return_url' => $this->get_return_url(),
566
- 'message_id' => $this->purchase_log->get( 'sessionid' ),
567
- 'invoice' => $this->purchase_log->get( 'id' ),
568
- 'address_override' => 1,
569
- 'paymentaction' => 'sale',
570
- 'template' => 'templateD',
571
- 'vendor' => $this->setting->get( 'vendor_id' ),
572
- );
573
-
574
- $options += $this->checkout_data->get_gateway_data();
575
- $options += $this->purchase_log->get_gateway_data( parent::get_currency_code(), $this->get_currency_code() );
576
-
577
- if ( $this->setting->get( 'ipn', false ) ) {
578
- $options['notify_url'] = $this->get_notify_url();
579
- }
580
-
581
- // BMCreateButton API call
582
- $response = $this->gateway->createButton( $options );
583
- $params = $response->get_params();
584
- $website_code = $params['WEBSITECODE'];
585
-
586
-
587
- if ( $response->is_successful() ) {
588
- $params = $response->get_params();
589
- // Log any warning
590
- if ( $params['ACK'] == 'SuccessWithWarning' ) {
591
- $this->log_error( $response );
592
- }
593
- } else {
594
- // Log errors and redirect user
595
- $this->log_error( $response );
596
- $url = add_query_arg( array(
597
- 'payment_gateway' => 'paypal-pro-checkout',
598
- 'payment_gateway_callback' => 'display_paypal_error',
599
- ), $this->get_return_url() );
600
- }
601
-
602
- // Write the Button code
603
- echo( $website_code );
604
-
605
- exit;
606
- }
607
-
608
- /**
609
- * Log an error message
610
- *
611
- * @param PHP_Merchant_Paypal_Pro_Response $response
612
- * @return void
613
- *
614
- * @since 3.9
615
- */
616
- public function log_error( $response ) {
617
- if ( $this->setting->get( 'debugging' ) ) {
618
- $log_data = array(
619
- 'post_title' => 'PayPal Pro Operation Failure',
620
- 'post_content' => 'There was an error processing the payment. Find details in the log entry meta fields.',
621
- 'log_type' => 'error'
622
- );
623
-
624
- $log_meta = array(
625
- 'correlation_id' => $response->get( 'correlation_id' ),
626
- 'time' => $response->get( 'datetime' ),
627
- 'errors' => $response->get_errors(),
628
- );
629
-
630
- $log_entry = WPSC_Logging::insert_log( $log_data, $log_meta );
631
- }
632
- }
633
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/common/exception.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- define( 'PHPME_FEATURE_NOT_SUPPORTED', 1 );
4
- define( 'PHPME_REQUIRED_OPTION_UNDEFINED', 2 );
5
- define( 'PHPME_HTTP_REQUEST_FAILED', 3 );
6
- define( 'PHPME_INVALID_RESPONSE', 4 );
7
-
8
- final class PHP_Merchant_Exception extends Exception {
9
- private static $messages = array(
10
- PHPME_FEATURE_NOT_SUPPORTED => 'This payment gateway does not support "%s" feature',
11
- PHPME_REQUIRED_OPTION_UNDEFINED => 'Missing required parameter: %s',
12
- PHPME_HTTP_REQUEST_FAILED => 'HTTP request failed: %s',
13
- PHPME_INVALID_RESPONSE => 'Invalid response from payment gateway',
14
- );
15
-
16
- public static function addCodes( $codes ) {
17
- if ( ! is_array( $codes ) )
18
- return;
19
-
20
- self::$message += $codes;
21
- }
22
-
23
- private $other_args;
24
-
25
- public function __construct( $code, $message_args = array(), $other_args = array() ) {
26
- $this->message_args = (array) $message_args;
27
- $this->message = vsprintf( self::$messages[$code], $this->message_args );
28
- $this->other_args = (array) $other_args;
29
- $this->code = $code;
30
-
31
- parent::__construct( $this->message, $code );
32
- }
33
-
34
- public function getArguments() {
35
- return $this->other_args;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/common/helpers.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- function phpme_map( $from_array, $map, $return_type = 'Array' ) {
3
- $return = array();
4
-
5
- foreach ( $map as $to_key => $from_key ) {
6
- if ( isset( $from_array[$from_key] ) )
7
- $return[$to_key] = $from_array[$from_key];
8
- }
9
-
10
- if ( $return_type == 'Object' )
11
- $return = (Object) $return;
12
-
13
- return $return;
14
- }
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/common/http-curl.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
-
3
- class PHP_Merchant_HTTP_CURL extends PHP_Merchant_HTTP
4
- {
5
- protected function request( $url, $fields = array(), $args = array() ) {
6
- $defaults = array(
7
- 'follow' => true,
8
- 'method' => 'GET',
9
- 'ssl_verify' => false,
10
- 'body' => '',
11
- );
12
-
13
- $args = array_merge( $defaults, $args );
14
- extract( $args, EXTR_SKIP );
15
-
16
- $body = http_build_query( $fields );
17
-
18
- $handle = curl_init();
19
- curl_setopt( $handle, CURLOPT_URL, $url );
20
- curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
21
- curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, $ssl_verify ? 2 : false );
22
- curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
23
- curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, $follow );
24
-
25
- switch ( $method ) {
26
- case 'POST':
27
- curl_setopt( $handle, CURLOPT_POST, true );
28
- curl_setopt( $handle, CURLOPT_POSTFIELDS, $body );
29
- break;
30
- }
31
-
32
- $response = curl_exec( $handle );
33
-
34
- if ( ! $response ) {
35
- throw new PHP_Merchant_Exception( PHPME_HTTP_REQUEST_FAILED, curl_error( $handle ) );
36
- }
37
-
38
- return $response;
39
- }
40
-
41
- public function post( $url, $fields = array(), $args = array() ) {
42
- $args['method'] = 'POST';
43
- return $this->request( $url, $fields, $args );
44
- }
45
-
46
- public function get( $url, $fields = array(), $args = array() ) {
47
- return $this->request( $url, $fields, $args );
48
- }
49
-
50
- /**
51
- * Generate URL-encoded query string
52
- *
53
- * @param array|object $args An Array or Object containaing properties
54
- * @return string|bool Returns a URL-encoded string.
55
- */
56
- protected function parse_args( $args ) {
57
- if ( is_object ( $args ) || is_array( $args ) ) {
58
- return http_build_query( $args );
59
- }
60
- return false;
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/common/http.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- abstract class PHP_Merchant_HTTP
4
- {
5
- public function __construct() {
6
-
7
- }
8
-
9
- abstract public function get( $url, $args = array() );
10
- abstract public function post( $url, $args = array() );
11
- }
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/common/php-merchant.php DELETED
@@ -1,157 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- *
6
- * @author Instinct Entertainment
7
- * @package PHP_Merchant
8
- **/
9
-
10
- require_once( 'exception.php' );
11
- require_once( 'http.php' );
12
- require_once( 'response.php' );
13
- require_once( 'helpers.php' );
14
-
15
- abstract class PHP_Merchant {
16
- /**
17
- * These currencies don't have decimal points. Eg: You never see JPY1000.5
18
- *
19
- * @var array
20
- * @access protected
21
- */
22
- protected $currencies_without_fractions = array( 'JPY', 'HUF' );
23
-
24
- /**
25
- * Options are passed into the object constructor or payment action methods (purchase,
26
- * authorize, capture void, credit, recurring). These options will eventually be used
27
- * to generate HTTP requests to payment gateways.
28
- *
29
- * @var array
30
- * @access protected
31
- */
32
- protected $options = array(
33
- 'currency' => 'USD',
34
- );
35
-
36
- /**
37
- * This is the object that handles sending HTTP requests. The default HTTP client is CURL,
38
- * but you can always set a custom HTTP client object that inherits from PHP_Merchant_HTTP.
39
- *
40
- * @var PHP_Merchant_HTTP
41
- * @access protected
42
- */
43
- protected $http;
44
-
45
- /**
46
- * Constructor of the payment gateway. Accepts an array of options.
47
- *
48
- * @param array $options
49
- */
50
- public function __construct( $options = array() ) {
51
- if ( ! array_key_exists( 'http_client', $options ) ) {
52
- require_once( 'http-curl.php' );
53
- $this->http = new PHP_Merchant_HTTP_CURL();
54
- } else {
55
- $this->http =& $options['http_client'];
56
- unset( $options['http_client'] );
57
- }
58
-
59
- $this->set_options( $options );
60
- }
61
-
62
- /**
63
- * Format the amount according to the currency being used.
64
- *
65
- * @param float $amt Amount
66
- * @param string $currency Defaults to the currency specified in defined $options
67
- * @return string
68
- */
69
- public function format( $amt, $currency = false ) {
70
- if ( ! $currency )
71
- $currency = $this->options['currency'];
72
-
73
- $dec = in_array( $currency, $this->currencies_without_fractions ) ? 0 : 2;
74
- return number_format( $amt, $dec );
75
- }
76
-
77
- public function purchase( $options = array() ) {
78
- $this->requires( 'amount' );
79
- }
80
-
81
- public function authorize() {
82
- throw new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'authorize' );
83
- }
84
-
85
- public function capture() {
86
- throw new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'capture' );
87
- }
88
-
89
- public function void() {
90
- throw new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'void' );
91
- }
92
-
93
- public function credit() {
94
- throw new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'credit' );
95
- }
96
-
97
- public function recurring() {
98
- throw new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'recurring' );
99
- }
100
-
101
- public function get_options() {
102
- return $this->options;
103
- }
104
-
105
- public function set_options( $options ) {
106
- $this->options = array_merge( $this->options, $options );
107
- return $this;
108
- }
109
-
110
- public function get_option( $key ) {
111
- return array_key_exists( $key, $this->options ) ? $this->options[ $key ] : null;
112
- }
113
-
114
- public function set_option( $key, $value ) {
115
- $this->options[ $key ] = $value;
116
- return $this;
117
- }
118
-
119
- /**
120
- * Specify fields that are required for the API operation, otherwise
121
- * throw a PHP_Merchant_Exception exception
122
- *
123
- * @param array $options Required fields
124
- * @return void
125
- * @since 3.9
126
- */
127
- protected function requires( $options ) {
128
- $missing = array();
129
- foreach ( (array) $options as $option ) {
130
- if ( ! isset( $this->options[ $option ] ) ) {
131
- $missing[] = $option;
132
- }
133
- }
134
-
135
- if ( ! empty( $missing ) ) {
136
- throw new PHP_Merchant_Exception( PHPME_REQUIRED_OPTION_UNDEFINED, implode( ', ', $missing ) );
137
- }
138
- }
139
-
140
- /**
141
- * Specify fields that are required for the API operation, otherwise
142
- * throw a PHP_Merchant_Exception exception
143
- *
144
- * @param array $options Required fields
145
- * @return boolean|void Returns True if a specified field is found
146
- * @since 3.9
147
- */
148
- protected function conditional_requires( $options ) {
149
- foreach ( (array) $options as $option ) {
150
- if ( isset( $this->options[ $option ] ) ) {
151
- return true;
152
- }
153
- }
154
-
155
- throw new PHP_Merchant_Exception( PHPME_REQUIRED_OPTION_UNDEFINED, implode( ', ', $options ) );
156
- }
157
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/common/response.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- abstract class PHP_Merchant_Response
4
- {
5
- protected $is_successful = false;
6
- protected $options = array();
7
- protected $errors = array();
8
- protected $response = '';
9
-
10
- public function __construct( $response_str ) {
11
- $this->response = $response_str;
12
- }
13
-
14
- public function is_successful() {
15
- return $this->is_successful;
16
- }
17
-
18
- public function get( $name ) {
19
- if ( ! isset( $this->options[$name] ) )
20
- return null;
21
- return $this->options[$name];
22
- }
23
-
24
- public function get_response_string() {
25
- return $this->response;
26
- }
27
-
28
- public function get_errors() {
29
- return $this->errors;
30
- }
31
-
32
- public function has_errors() {
33
- return ! empty( $this->errors );
34
- }
35
-
36
- public function get_error() {
37
- return empty( $this->errors ) ? false : $this->errors[0];
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-digital-goods.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
-
3
- require_once( 'paypal-express-checkout.php' );
4
- require_once( 'paypal-express-checkout-response.php' );
5
-
6
- class PHP_Merchant_Paypal_Digital_Goods extends PHP_Merchant_Paypal_Express_Checkout
7
- {
8
- public function __construct( $options = array() ) {
9
- parent::__construct( $options );
10
- }
11
-
12
- /**
13
- * Creates and returns the payment component of a PayPal Digital Goods NVP API request.
14
- *
15
- * PayPal requires the category component for all items in a digital goods purchase to be set as Digital.
16
- * This function specifies that all goods are digital, then calls @see parent::add_payment() to create
17
- * the rest of the API request (which is the same as a vanilla Express Checkout request).
18
- *
19
- * @uses parent::add_payment() to create non digital goods components of the request.
20
- * @return Array An array of name value pairs for each element representing a payment in a PayPal Digital Goods NVP API request.
21
- */
22
- protected function add_payment( $action ) {
23
- $request = parent::add_payment( $action );
24
-
25
- // Make sure PayPal knows all goods are digital
26
- for( $i = 0; $i < count( $this->options['items'] ); $i++ ) {
27
- $request += array( "L_PAYMENTREQUEST_0_ITEMCATEGORY{$i}" => 'Digital' );
28
- }
29
-
30
- return $request;
31
- }
32
-
33
- /**
34
- * For Digital Goods purchases, PayPal requires the PAYMENTREQUEST_n_ITEMAMT. This function sets the 'items' flag to required
35
- * then calls @see parent::setup_purchase() to initiate an Express Checkout payment.
36
- *
37
- * @uses self::requires() to flag 'items' as required
38
- * @uses parent::setup_purchase() to create and make the request.
39
- * @return PHP_Merchant_Paypal_Express_Checkout_Response An object containing the details of PayPal's response to the request.
40
- */
41
- public function setup_purchase( $options = array(), $action = 'Sale' ) {
42
- return parent::setup_purchase( $options, $action );
43
- }
44
-
45
- /**
46
- * For Digital Goods purchases, PayPal requires the PAYMENTREQUEST_n_ITEMAMT. This function sets the 'items' flag to required
47
- * then calls @see parent::setup_purchase() to complete the payment.
48
- *
49
- * @uses self::requires() to flag 'items' as required
50
- * @uses parent::setup_purchase() to create and make the request.
51
- * @return PHP_Merchant_Paypal_Express_Checkout_Response An object containing the details of PayPal's response to the request.
52
- */
53
- public function purchase( $options = array(), $action = 'Sale' ) {
54
- return parent::purchase( $options, $action );
55
- }
56
-
57
-
58
- /**
59
- * The Javascript to invoke the digital goods in context checkout process.
60
- *
61
- * No need to call this function manually, required scripts are automatically printed with @see print_buy_buttion().
62
- * If you do print this script manually, print it after the button in the DOM to ensure the
63
- * click event is properly hooked.
64
- */
65
- public function get_script( $args = array() ){
66
-
67
- if( empty( $args['element_id'] ) )
68
- $args['element_id'] = 'paypal-submit';
69
-
70
- $dg_script = '<script src ="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>'
71
- . '<script>'
72
- . 'var dg = new PAYPAL.apps.DGFlow({'
73
- . 'trigger: "' . $args['element_id'] . '"' // the ID of the HTML element which calls setExpressCheckout
74
- . '}); </script>';
75
-
76
- return $dg_script;
77
- }
78
-
79
-
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout-response.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
- class PHP_Merchant_Paypal_Express_Checkout_Response extends PHP_Merchant_Paypal_Response
3
- {
4
- public function __construct( $response_str ) {
5
- parent::__construct( $response_str );
6
- $p =& $this->params;
7
-
8
- // more readable checkout status
9
- if ( isset( $p['CHECKOUTSTATUS'] ) )
10
- switch ( $p['CHECKOUTSTATUS'] ) {
11
- case 'PaymentActionNotInitiated':
12
- $this->options['checkout_status'] = 'Not-Initiated';
13
- break;
14
-
15
- case 'PaymentActionFailed':
16
- $this->options['checkout_status'] = 'Failed';
17
- break;
18
-
19
- case 'PaymentActionInProgress':
20
- $this->options['checkout_status'] = 'In-Progress';
21
- break;
22
-
23
- case 'PaymentCompleted':
24
- $this->options['checkout_status'] = 'Completed';
25
- break;
26
-
27
- default:
28
- $this->options['checkout_status'] = $p['CHECKOUTSTATUS'];
29
- break;
30
- }
31
-
32
- if ( isset( $p['PAYMENTINFO_0_PAYMENTSTATUS'] ) )
33
- $this->options['payment_status'] = $p['PAYMENTINFO_0_PAYMENTSTATUS'];
34
-
35
- if ( isset( $p['PAYMENTINFO_0_TRANSACTIONID'] ) )
36
- $this->options['transaction_id'] = $p['PAYMENTINFO_0_TRANSACTIONID'];
37
-
38
- $this->options += phpme_map( $p, array(
39
- 'currency' => 'PAYMENTREQUEST_0_CURRENCYCODE',
40
- 'total' => 'PAYMENTREQUEST_0_AMT', // alias for "amount"
41
- 'amount' => 'PAYMENTREQUEST_0_AMT',
42
- 'subtotal' => 'PAYMENTREQUEST_0_ITEMAMT',
43
- 'shipping' => 'PAYMENTREQUEST_0_SHIPPINGAMT',
44
- 'handling' => 'PAYMENTREQUEST_0_HANDLINGAMT',
45
- 'tax' => 'PAYMENTREQUEST_0_TAXAMT',
46
- 'description' => 'PAYMENTREQUEST_0_DESC',
47
- 'invoice' => 'PAYMENTREQUEST_0_INVNUM',
48
- 'notify_url' => 'PAYMENTREQUEST_0_NOTIFYURL',
49
- 'shipping_discount' => 'PAYMENTREQUEST_0_SHIPDISCAMT',
50
- ) );
51
-
52
- $items = array();
53
- $i = 0;
54
- while ( isset( $p["L_PAYMENTREQUEST_0_NAME{$i}"] ) ) {
55
- $items[] = phpme_map( $p, array(
56
- 'name' => "L_PAYMENTREQUEST_0_NAME{$i}",
57
- 'description' => "L_PAYMENTREQUEST_0_DESC{$i}",
58
- 'amount' => "L_PAYMENTREQUEST_0_AMT{$i}",
59
- 'quantity' => "L_PAYMENTREQUEST_0_QTY{$i}",
60
- 'tax' => "L_PAYMENTREQUEST_0_TAXAMT{$i}",
61
- ), 'Object' );
62
-
63
- $i ++;
64
- }
65
-
66
- $this->options['items'] = $items;
67
-
68
- if ( isset( $p['PAYERID'] ) )
69
- $this->options['payer'] = phpme_map( $p, array(
70
- 'email' => 'EMAIL',
71
- 'id' => 'PAYERID',
72
- 'status' => 'PAYERSTATUS',
73
- 'shipping_status' => 'ADDRESSSTATUS',
74
- 'first_name' => 'FIRSTNAME',
75
- 'last_name' => 'LASTNAME',
76
- 'country' => 'COUNTRYCODE',
77
- ), 'Object' );
78
-
79
- if ( isset( $p['SHIPTONAME'] ) )
80
- $this->options['shipping_address'] = phpme_map( $p, array(
81
- 'name' => 'SHIPTONAME',
82
- 'street' => 'SHIPTOSTREET',
83
- 'street2' => 'SHIPTOSTREET2',
84
- 'city' => 'SHIPTOCITY',
85
- 'state' => 'SHIPTOSTATE',
86
- 'zip' => 'SHIPTOZIP',
87
- 'country_code' => 'SHIPTOCOUNTRYCODE',
88
- 'country' => 'SHIPTOCOUNTRYNAME',
89
- 'phone' => 'SHIPTOPHONENUM',
90
- ) );
91
- }
92
-
93
- public function is_checkout_not_initiated() {
94
- return $this->get( 'checkout_status' ) == 'Not-Initiated';
95
- }
96
-
97
- public function is_checkout_failed() {
98
- return $this->get( 'checkout_status' ) == 'Failed';
99
- }
100
-
101
- public function is_checkout_in_progress() {
102
- return $this->get( 'checkout_status' ) == 'In-Progress';
103
- }
104
-
105
- public function is_checkout_completed() {
106
- return $this->get( 'checkout_status' ) == 'Completed';
107
- }
108
-
109
- public function is_payment_completed() {
110
- return in_array( $this->get( 'payment_status' ), array( 'Completed', 'Processed' ) );
111
- }
112
-
113
- public function is_payment_pending() {
114
- return $this->get( 'payment_status' ) == 'Pending';
115
- }
116
-
117
- public function is_payment_refunded() {
118
- return $this->get( 'payment_status' ) == 'Refunded';
119
- }
120
-
121
- public function is_payment_denied() {
122
- return $this->get( 'payment_status' ) == 'Denied';
123
- }
124
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
- require_once( 'paypal.php' );
3
- require_once( 'paypal-express-checkout-response.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout extends PHP_Merchant_Paypal
6
- {
7
- public function __construct( $options = array() ) {
8
- parent::__construct( $options );
9
- }
10
-
11
- /**
12
- * Add the payment details to the PayPal request
13
- *
14
- * @param array $action
15
- * @return array
16
- * @since 3.9
17
- */
18
- protected function add_payment( $action ) {
19
-
20
- // Total Payment details
21
- $request = array(
22
- 'PAYMENTREQUEST_0_AMT' => $this->format( $this->options['amount'] ),
23
- 'PAYMENTREQUEST_0_CURRENCYCODE' => $this->options['currency'],
24
- 'PAYMENTREQUEST_0_PAYMENTACTION' => $action,
25
- );
26
-
27
- if ( $action === 'Sale' ) {
28
- $request['PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD'] = 'InstantPaymentOnly';
29
- }
30
-
31
- foreach ( array( 'subtotal', 'shipping', 'handling', 'tax' ) as $key ) {
32
- if ( isset( $this->options[$key] ) ) {
33
- $this->options[$key] = $this->format( $this->options[$key] );
34
- }
35
- }
36
-
37
- $request += phpme_map( $this->options, array(
38
- 'PAYMENTREQUEST_0_ITEMAMT' => 'subtotal',
39
- 'PAYMENTREQUEST_0_SHIPPINGAMT' => 'shipping',
40
- 'PAYMENTREQUEST_0_HANDLINGAMT' => 'handling',
41
- 'PAYMENTREQUEST_0_TAXAMT' => 'tax',
42
- 'PAYMENTREQUEST_0_DESC' => 'description',
43
- 'PAYMENTREQUEST_0_INVNUM' => 'invoice',
44
- 'PAYMENTREQUEST_0_NOTIFYURL' => 'notify_url',
45
- 'L_BILLINGTYPE0' => 'billing_type',
46
- 'L_BILLINGAGREEMENTDESCRIPTION0' => 'billing_description',
47
- ) );
48
-
49
- $subtotal = 0;
50
-
51
- // Shopping Cart details
52
- $i = 0;
53
- foreach ( $this->options['items'] as $item ) {
54
- // Options Fields
55
- $item_optionals = array(
56
- 'description' => "L_PAYMENTREQUEST_0_DESC{$i}",
57
- 'tax' => "L_PAYMENTREQUEST_0_TAXAMT{$i}",
58
- 'url' => "L_PAYMENTREQUEST_0_ITEMURL{$i}",
59
- 'number' => "L_PAYMENTREQUEST_0_NUMBER{$i}",
60
- );
61
-
62
- // Format Amount Field
63
- $item['amount'] = $this->format( $item['amount'] );
64
-
65
- // Required Fields
66
- $request += phpme_map( $item, array(
67
- "L_PAYMENTREQUEST_0_NAME{$i}" => 'name',
68
- "L_PAYMENTREQUEST_0_AMT{$i}" => 'amount',
69
- "L_PAYMENTREQUEST_0_QTY{$i}" => 'quantity',
70
- ) );
71
-
72
- // No Shipping Field
73
- if ( isset( $this->options['no_shipping'] ) ) {
74
- $request["L_PAYMENTREQUEST_0_ITEMCATEGORY{$i}"] = 'DIGITAL';
75
- }
76
-
77
- foreach ( $item_optionals as $key => $param ) {
78
- if ( ! empty( $this->options['items'][$i][$key] ) )
79
- if ( $key == 'tax' ) {
80
- $request[$param] = $this->format( $this->options['items'][$i][$key] );
81
- } else {
82
- $request[$param] = $this->options['items'][$i][$key];
83
- }
84
- }
85
-
86
- $i ++;
87
- }
88
-
89
- return $request;
90
- }
91
-
92
- /**
93
- * Add a shipping address to the PayPal request
94
- *
95
- * @return array
96
- * @since 3.9
97
- */
98
- protected function add_address() {
99
- $map = array(
100
- 'name' => 'PAYMENTREQUEST_0_SHIPTONAME',
101
- 'street' => 'PAYMENTREQUEST_0_SHIPTOSTREET',
102
- 'street2' => 'PAYMENTREQUEST_0_SHIPTOSTREET2',
103
- 'city' => 'PAYMENTREQUEST_0_SHIPTOCITY',
104
- 'state' => 'PAYMENTREQUEST_0_SHIPTOSTATE',
105
- 'zip' => 'PAYMENTREQUEST_0_SHIPTOZIP',
106
- 'country' => 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE',
107
- 'phone' => 'PAYMENTREQUEST_0_SHIPTOPHONENUM',
108
- );
109
-
110
- $request = array();
111
-
112
- foreach ( $map as $key => $param ) {
113
- if ( ! empty( $this->options['shipping_address'][$key] ) ) {
114
- $request[$param] = $this->options['shipping_address'][$key];
115
- }
116
- }
117
-
118
- return $request;
119
- }
120
-
121
- /**
122
- * Build the request array
123
- *
124
- * @param string $action
125
- * @param array $options
126
- * @return array
127
- * @since 3.9
128
- */
129
- protected function build_checkout_request( $action, $options = array() ) {
130
- $request = array();
131
-
132
- if ( isset( $this->options['return_url'] ) ) {
133
- $request['RETURNURL'] = $this->options['return_url'];
134
- }
135
-
136
- if ( isset( $this->options['cancel_url'] ) ) {
137
- $request['CANCELURL'] = $this->options['cancel_url'];
138
- }
139
-
140
- // Common Fields
141
- $request += phpme_map( $this->options, array(
142
- 'AMT' => 'amount',
143
- 'MAXAMT' => 'max_amount',
144
- 'SOLUTIONTYPE' => 'solution_type',
145
- 'ALLOWNOTE' => 'allow_note',
146
- 'ADDROVERRIDE' => 'address_override',
147
- 'TOKEN' => 'token',
148
- 'PAYERID' => 'payer_id',
149
- 'TRANSACTIONID'=> 'transaction_id',
150
- 'AUTHORIZATIONID'=> 'authorization_id',
151
- 'MSGSUBID' => 'message_id',
152
- 'INVOICEID' => 'invoice',
153
- ) );
154
-
155
- // Cart Customization Fields
156
- $request += phpme_map( $this->options, array(
157
- 'LOGOIMG' => 'cart_logo',
158
- 'CARTBORDERCOLOR' => 'cart_border',
159
- ) );
160
-
161
- // RefundTransaction Fields
162
- $request += phpme_map( $this->options, array(
163
- 'REFUNDTYPE' => 'refund_type',
164
- 'REFUNDSOURCE' => 'refund_source',
165
- 'REFUNDADVICE' => 'refund_advice',
166
- ) );
167
-
168
- // DoCapture Fields
169
- $request += phpme_map( $this->options, array(
170
- 'COMPLETETYPE' => 'complete_type',
171
- ) );
172
-
173
- if ( ! empty( $this->options['shipping_address'] ) ) {
174
- $request += $this->add_address();
175
- }
176
-
177
- if ( isset( $this->options['no_shipping'] ) ) {
178
- $request['NOSHIPPING'] = '1';
179
- }
180
-
181
- if ( $action != false ) {
182
- $request += $this->add_payment( $action );
183
- }
184
-
185
- // BN Code
186
- $request['BUTTONSOURCE'] = 'WPECOM_ECM';
187
-
188
- return $request;
189
- }
190
-
191
- /**
192
- * Gateway implementation for SetExpressCheckout
193
- *
194
- * @param array $options
195
- * @param string $action
196
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
197
- * @since 3.9
198
- */
199
- public function setup_purchase( $options = array(), $action = 'Sale' ) {
200
- $this->options = array_merge( $this->options, $options );
201
- $this->requires( array( 'amount', 'return_url', 'cancel_url' ) );
202
- $request = $this->build_checkout_request( $action, $options );
203
-
204
- $response_str = $this->commit( 'SetExpressCheckout', $request );
205
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
206
- }
207
-
208
- /**
209
- * Gateway impelementation for GetExpressCheckoutDetails
210
- *
211
- * @param string $token Authentication token returned by the SetExpressCheckout operation
212
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
213
- * @since 3.9
214
- */
215
- public function get_details_for( $token ) {
216
- $request = array( 'TOKEN' => $token );
217
- $response_str = $this->commit( 'GetExpressCheckoutDetails', $request );
218
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
219
- }
220
-
221
- /**
222
- * Gateway impelementation for GetTransactionDetails
223
- *
224
- * @param string $transaction_id Unique identifier of a transaction.
225
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
226
- * @since 3.9
227
- */
228
- public function get_transaction_details( $transaction_id ) {
229
- $request = array( 'TRANSACTIONID' => $transaction_id );
230
- $response_str = $this->commit( 'GetTransactionDetails', $request );
231
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
232
- }
233
-
234
- /**
235
- * Gateway implementation for DoExpressCheckout
236
- *
237
- * @param array $options
238
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
239
- * @since 3.9
240
- */
241
- public function purchase( $options = array(), $action = 'Sale' ) {
242
- $this->options = array_merge( $this->options, $options );
243
- $this->requires( array( 'amount', 'token', 'payer_id' ) );
244
- $request = $this->build_checkout_request( $action, $options );
245
-
246
- $response_str = $this->commit( 'DoExpressCheckoutPayment', $request );
247
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
248
- }
249
-
250
- /**
251
- * Gateway implementation for DoAuthorize
252
- *
253
- * @param array $options
254
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
255
- * @since 3.9
256
- */
257
- public function authorize( $options = array() ) {
258
- $this->options = array_merge( $this->options, $options );
259
- $this->requires( array( 'amount', 'token', 'transaction_id' ) );
260
- $request = $this->build_checkout_request( false, $options );
261
-
262
- $response_str = $this->commit( 'DoAuthorization', $request );
263
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
264
- }
265
-
266
- /**
267
- * Gateway implementation for DoCapture
268
- *
269
- * @param array $options
270
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
271
- * @since 3.9
272
- */
273
- public function capture( $options = array() ) {
274
- $this->options = array_merge( $this->options, $options );
275
- $this->requires( array( 'amount', 'complete_type', 'authorization_id' ) );
276
- $request = $this->build_checkout_request( false, $options );
277
-
278
- $response_str = $this->commit( 'DoCapture', $request );
279
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
280
- }
281
-
282
- /**
283
- * Gateway implementation for DoVoid
284
- *
285
- * @param array $options
286
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
287
- * @since 3.9
288
- */
289
- public function void( $options = array() ) {
290
- $this->options = array_merge( $this->options, $options );
291
- $this->requires( array( 'authorization_id' ) );
292
- $request = $this->build_checkout_request( false, $options );
293
-
294
- $response_str = $this->commit( 'DoVoid', $request );
295
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
296
- }
297
-
298
- /**
299
- * Gateway implementation for RefundTransaction
300
- *
301
- * @param array $options
302
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
303
- * @since 3.9
304
- */
305
- public function credit( $options = array() ) {
306
- $this->options = array_merge( $this->options, $options );
307
-
308
- // Required Fields
309
- $this->requires( array( 'message_id', 'invoice' ) );
310
-
311
- // Conditionally required fields (one field at least is set)
312
- $this->conditional_requires( array( 'payer_id', 'transaction_id' ) );
313
-
314
- // Amount is required if the refund is partial
315
- if ( strtolower( $this->options['refund_type'] ) === 'partial' ) {
316
- $this->requires( array( 'amount' ) );
317
- }
318
-
319
- $request = $this->build_checkout_request( false, $options );
320
-
321
- $response_str = $this->commit( 'RefundTransaction', $request );
322
- return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-ipn.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
-
3
- class PHP_Merchant_Paypal_IPN
4
- {
5
- const SANDBOX_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
6
- const LIVE_URL = 'https://www.paypal.com/cgi-bin/webscr';
7
-
8
- private $verified = null;
9
- private $params = array();
10
- private $data = array();
11
- private $url;
12
- protected $http = false;
13
-
14
- public function __construct( $data = false, $test = false, &$http = false ) {
15
- if ( $http ) {
16
- $this->http = $http;
17
- } else {
18
- require_once( dirname( __FILE__ ) . '/../common/http-curl.php' );
19
- $this->http = new PHP_Merchant_HTTP_CURL();
20
- }
21
-
22
- if ( $data === false ) {
23
- $data = $_POST;
24
- }
25
-
26
- $this->params = $data;
27
-
28
- $this->url = $test ? self::SANDBOX_URL : self::LIVE_URL;
29
- }
30
-
31
- public function is_verified() {
32
- if ( is_null( $this->verified ) ) {
33
- $verifying_data = array( 'cmd' => '_notify-validate' );
34
- $verifying_data += $this->params;
35
-
36
- $verifying_response = $this->http->post( $this->url, $verifying_data );
37
-
38
- if ( $verifying_response == 'VERIFIED' ) {
39
- $this->verified = true;
40
-
41
- /*
42
-
43
- There's some confusing stuff regarding payment information:
44
- mc_gross = total amount = total tax + item subtotal + total shipping
45
- mc_gross_$i = item amount * quantity + item shipping
46
-
47
- See: https://www.x.com/developers/paypal/forums/ipn/pdt/mcgross-does-not-include-tax-right
48
-
49
- IPN only returns the item gross amount, so the single item amount will need to be
50
- calculated so that the $this->data array is consistent with other Paypal Response classes.
51
-
52
- */
53
- $this->data = phpme_map( $this->params, array(
54
- 'transaction_id' => 'txn_id',
55
- 'transaction_type' => 'txn_type',
56
- 'handling' => 'mc_handling',
57
- 'shipping' => 'mc_shipping',
58
- 'exchange_rate' => 'exchange_rate',
59
- 'invoice' => 'invoice',
60
- 'currency' => 'mc_currency',
61
- 'fee' => 'mc_fee',
62
- 'total' => 'mc_gross',
63
- 'amount' => 'mc_gross',
64
- 'payment_status' => 'payment_status',
65
- 'tax' => 'tax',
66
- ) );
67
-
68
- // Strangely, Canceled_Reversal in IPN response is actually Canceled-Reversal in normal Paypal Express responses.
69
- // Need to change the underscore to hyphen to maintain consistency
70
- $this->data['payment_status'] = str_replace( '_', '-', $this->data['payment_status'] );
71
-
72
- $i = 1;
73
- $this->data['items'] = array();
74
- while ( isset( $this->params["item_name{$i}"] ) ) {
75
- $item = phpme_map( $this->params, array(
76
- 'name' => "item_name{$i}",
77
- 'quantity' => "quantity{$i}",
78
- ) );
79
-
80
- $item['shipping'] = $shipping = isset( $this->params["mc_shipping{$i}"] ) ? $this->params["mc_shipping{$i}"] : 0;
81
- $item['handling'] = $handling = isset( $this->params["mc_handling{$i}"] ) ? $this->params["mc_handling{$i}"] : 0;
82
- $item['amount'] = ( $this->params["mc_gross_{$i}"] - $shipping - $handling ) / $item['quantity'];
83
- $this->data['items'][] = $item;
84
- $i++;
85
- }
86
-
87
- $this->data['payer'] = phpme_map( $this->params, array(
88
- 'first_name' => 'first_name',
89
- 'last_name' => 'last_name',
90
- 'business_name' => 'payer_business_name',
91
- 'status' => 'payer_status',
92
- 'id' => 'payer_id',
93
- 'email' => 'payer_email',
94
- ) );
95
-
96
- $this->data['address'] = phpme_map( $this->params, array(
97
- 'street' => 'address_street',
98
- 'zip' => 'address_zip',
99
- 'city' => 'address_city',
100
- 'state' => 'address_state',
101
- 'country' => 'address_country',
102
- 'country_code' => 'address_country_code',
103
- 'name' => 'address_name',
104
- 'status' => 'address_status',
105
- 'phone' => 'contact_phone',
106
- ) );
107
- }
108
- }
109
-
110
- return $this->verified;
111
- }
112
-
113
- public function get( $item ) {
114
- return isset( $this->data[$item] ) ? $this->data[$item] : null;
115
- }
116
-
117
- public function get_data() {
118
- return $this->data;
119
- }
120
-
121
- public function is_payment_completed() {
122
- return in_array( $this->get( 'payment_status' ), array( 'Completed', 'Processed' ) );
123
- }
124
-
125
- public function is_payment_pending() {
126
- return $this->get( 'payment_status' ) == 'Pending';
127
- }
128
-
129
- public function is_payment_refunded() {
130
- return in_array( $this->get( 'payment_status' ), array( 'Refunded', 'Reversed' ) );
131
- }
132
-
133
- public function is_payment_refund_pending() {
134
- return $this->is_payment_pending() && isset( $this->params['reason_code'] ) && $this->params['reason_code'] == 'refund';
135
- }
136
-
137
- public function is_payment_denied() {
138
- return $this->get( 'payment_status' ) == 'Denied';
139
- }
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-pro-response.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
-
3
- class PHP_Merchant_Paypal_Pro_Response extends PHP_Merchant_Paypal_Response
4
- {
5
- public function __construct( $response_str ) {
6
- parent::__construct( $response_str );
7
- $p =& $this->params;
8
-
9
- if ( isset( $p['PAYMENTSTATUS'] ) )
10
- $this->options['payment_status'] = $p['PAYMENTSTATUS'];
11
-
12
- if ( isset( $p['TRANSACTIONID'] ) )
13
- $this->options['transaction_id'] = $p['TRANSACTIONID'];
14
-
15
- $this->options += phpme_map( $p, array(
16
- 'currency' => 'CURRENCYCODE',
17
- 'total' => 'AMT', // alias for "amount"
18
- 'amount' => 'AMT',
19
- 'subtotal' => 'ITEMAMT',
20
- 'shipping' => 'SHIPPINGAMT',
21
- 'handling' => 'HANDLINGAMT',
22
- 'tax' => 'TAXAMT',
23
- 'description' => 'DESC',
24
- 'invoice' => 'INVNUM',
25
- 'notify_url' => 'NOTIFYURL',
26
- 'shipping_discount' => 'SHIPDISCAMT',
27
- ) );
28
-
29
- if ( isset( $p['PAYERID'] ) )
30
- $this->options['payer'] = phpme_map( $p, array(
31
- 'email' => 'EMAIL',
32
- 'id' => 'PAYERID',
33
- 'status' => 'PAYERSTATUS',
34
- 'shipping_status' => 'ADDRESSSTATUS',
35
- 'first_name' => 'FIRSTNAME',
36
- 'last_name' => 'LASTNAME',
37
- 'country' => 'COUNTRYCODE',
38
- ), 'Object' );
39
-
40
- if ( isset( $p['SHIPTONAME'] ) )
41
- $this->options['shipping_address'] = phpme_map( $p, array(
42
- 'name' => 'SHIPTONAME',
43
- 'street' => 'SHIPTOSTREET',
44
- 'street2' => 'SHIPTOSTREET2',
45
- 'city' => 'SHIPTOCITY',
46
- 'state' => 'SHIPTOSTATE',
47
- 'zip' => 'SHIPTOZIP',
48
- 'country_code' => 'SHIPTOCOUNTRYCODE',
49
- 'country' => 'SHIPTOCOUNTRYNAME',
50
- 'phone' => 'SHIPTOPHONENUM',
51
- ) );
52
- }
53
-
54
- public function is_payment_completed() {
55
- return in_array( $this->get( 'payment_status' ), array( 'Completed', 'Processed' ) );
56
- }
57
-
58
- public function is_payment_pending() {
59
- return $this->get( 'payment_status' ) == 'Pending';
60
- }
61
-
62
- public function is_payment_refunded() {
63
- return $this->get( 'payment_status' ) == 'Refunded';
64
- }
65
-
66
- public function is_payment_denied() {
67
- return $this->get( 'payment_status' ) == 'Denied';
68
- }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-pro.php DELETED
@@ -1,358 +0,0 @@
1
- <?php
2
- require_once( 'paypal.php' );
3
- require_once( 'paypal-pro-response.php' );
4
-
5
- class PHP_Merchant_Paypal_Pro extends PHP_Merchant_Paypal
6
- {
7
- const API_VERSION = '117.0';
8
- const SANDBOX_URL = 'https://api-3t.sandbox.paypal.com/nvp';
9
- const LIVE_URL = 'https://api-3t.paypal.com/nvp';
10
-
11
- public function __construct( $options = array() ) {
12
- parent::__construct( $options );
13
- }
14
-
15
- /**
16
- * Add the payment details to the PayPal request
17
- *
18
- * @param array $action
19
- * @return array
20
- * @since 3.9
21
- */
22
- protected function add_payment( $action ) {
23
-
24
- // Total Payment details
25
- $request = array(
26
- 'amount' => $this->format( $this->options['amount'] ),
27
- 'currency_code' => $this->options['currency'],
28
- 'paymentaction' => $action,
29
- );
30
-
31
- foreach ( array( 'subtotal', 'shipping', 'handling', 'tax' ) as $key ) {
32
- if ( isset( $this->options[$key] ) ) {
33
- $this->options[$key] = $this->format( $this->options[$key] );
34
- }
35
- }
36
-
37
- $request += phpme_map( $this->options, array(
38
- 'subtotal' => 'subtotal',
39
- 'shipping' => 'shipping',
40
- 'handling' => 'handling',
41
- 'tax' => 'tax',
42
- 'item_name' => 'description',
43
- 'invoice' => 'invoice',
44
- 'notify_url' => 'notify_url',
45
- ) );
46
-
47
- $subtotal = 0;
48
-
49
- // Shopping Cart details
50
- $i = 0;
51
- foreach ( $this->options['items'] as $item ) {
52
- // Options Fields
53
- $item_optionals = array(
54
- 'tax' => "tax{$i}",
55
- );
56
-
57
- // Format Amount Field
58
- $item['amount'] = $this->format( $item['amount'] );
59
-
60
- // Required Fields
61
- $request += phpme_map( $item, array(
62
- "item_name{$i}" => 'name',
63
- "amount{$i}" => 'amount',
64
- "quantity{$i}" => 'quantity',
65
- ) );
66
-
67
- foreach ( $item_optionals as $key => $param ) {
68
- if ( ! empty( $this->options['items'][$i][$key] ) )
69
- if ( $key == 'tax' ) {
70
- $request[$param] = $this->format( $this->options['items'][$i][$key] );
71
- } else {
72
- $request[$param] = $this->options['items'][$i][$key];
73
- }
74
- }
75
-
76
- $i ++;
77
- }
78
-
79
- return $request;
80
- }
81
-
82
- /**
83
- * Add a shipping address to the PayPal request
84
- *
85
- * @return array
86
- * @since 3.9
87
- */
88
- protected function add_address() {
89
- $map = array(
90
- 'name' => 'first_name',
91
- 'street' => 'address1',
92
- 'street2' => 'address2',
93
- 'city' => 'city',
94
- 'state' => 'state',
95
- 'zip' => 'zip',
96
- 'country' => 'country',
97
- 'phone' => 'night_phone_1',
98
- );
99
-
100
- $request = array();
101
-
102
- foreach ( $map as $key => $param ) {
103
- if ( ! empty( $this->options['shipping_address'][$key] ) ) {
104
- $request[$param] = $this->options['shipping_address'][$key];
105
- }
106
- }
107
-
108
- return $request;
109
- }
110
-
111
- /**
112
- * Add a Billing address to the PayPal request
113
- *
114
- * @return array
115
- * @since 3.9
116
- */
117
- protected function add_billing_address() {
118
- $map = array(
119
- 'name' => 'billing_first_name',
120
- 'street' => 'billing_address1',
121
- 'street2' => 'billing_address2',
122
- 'city' => 'billing_city',
123
- 'state' => 'billing_state',
124
- 'zip' => 'billing_zip',
125
- 'country' => 'billing_country',
126
- 'phone' => 'billing_night_phone_1',
127
- );
128
-
129
- $request = array();
130
-
131
- foreach ( $map as $key => $param ) {
132
- if ( ! empty( $this->options['billing_address'][$key] ) ) {
133
- $request[$param] = $this->options['billing_address'][$key];
134
- }
135
- }
136
-
137
- return $request;
138
- }
139
- /**
140
- * Gateway implementation for BMCreateButton
141
- *
142
- * @param array $options
143
- * @return PHP_Merchant_Paypal_Pro_Response
144
- * @since 3.9
145
- */
146
- public function createButton( $options = array() ) {
147
- $this->options = array_merge( $this->options, $options );
148
- $this->requires( array( 'amount', 'vendor', 'paymentaction', 'template' ) );
149
-
150
- $request = $this->build_button_vars( $this->options );
151
- $request['BUTTONCODE'] = 'TOKEN';
152
- $request['BUTTONTYPE'] = 'PAYMENT';
153
- $request['cmd'] = '_cart';
154
-
155
- $response_str = $this->commit( 'BMCreateButton', $request );
156
- return new PHP_Merchant_Paypal_Pro_Response( $response_str );
157
- }
158
-
159
- /**
160
- * Build the request array
161
- *
162
- * @param array $options
163
- * @return array
164
- * @since 3.9
165
- */
166
- protected function build_button_vars( $options = array(), $action = 'sale' ) {
167
- $request = array();
168
-
169
- if ( isset( $this->options['return_url'] ) ) {
170
- $request['return'] = $this->options['return_url'];
171
- }
172
-
173
- if ( isset( $this->options['cancel_url'] ) ) {
174
- $request['cancel_return'] = $this->options['cancel_url'];
175
- }
176
-
177
- if ( isset( $this->options['notify_url'] ) ) {
178
- $request['notify_url'] = $this->options['notify_url'];
179
- }
180
-
181
- if ( $action != false ) {
182
- $request += $this->add_payment( $action );
183
- $request['display'] = '1';
184
- }
185
-
186
- if ( ! empty( $this->options['shipping_address'] ) ) {
187
- $request += $this->add_address();
188
- }
189
-
190
- if ( ! empty( $this->options['billing_address'] ) ) {
191
- $request += $this->add_billing_address();
192
- }
193
-
194
- if ( isset( $this->options['no_shipping'] ) ) {
195
- $request['no_shipping'] = '1';
196
- }
197
-
198
- // Common Fields
199
- $request += phpme_map( $this->options, array(
200
- 'amount' => 'amount',
201
- 'subtotal' => 'subtotal',
202
- 'tax' => 'tax',
203
- 'shipping' => 'shipping',
204
- 'paymentaction' => 'paymentaction',
205
- 'template' => 'template',
206
- 'address_override' => 'address_override',
207
- 'vendor' => 'merchant_email',
208
- 'invoice' => 'invoice',
209
- 'currency' => 'currency',
210
- ) );
211
-
212
- $request = $this->add_sub( 'L_BUTTONVAR', $request );
213
-
214
- return $request;
215
- }
216
-
217
- /**
218
- * Build the request array
219
- *
220
- * @param string $action
221
- * @param array $options
222
- * @return array
223
- * @since 3.9
224
- */
225
- function build_checkout_request( $action, $options = array() ) {
226
- $request = array();
227
-
228
- // Common Fields
229
- $request += phpme_map( $this->options, array(
230
- 'AMT' => 'amount',
231
- 'MAXAMT' => 'max_amount',
232
- 'SOLUTIONTYPE' => 'solution_type',
233
- 'ALLOWNOTE' => 'allow_note',
234
- 'ADDROVERRIDE' => 'address_override',
235
- 'TOKEN' => 'token',
236
- 'PAYERID' => 'payer_id',
237
- 'TRANSACTIONID'=> 'transaction_id',
238
- 'AUTHORIZATIONID'=> 'authorization_id',
239
- 'MSGSUBID' => 'message_id',
240
- 'INVOICEID' => 'invoice',
241
- ) );
242
-
243
- // RefundTransaction Fields
244
- $request += phpme_map( $this->options, array(
245
- 'REFUNDTYPE' => 'refund_type',
246
- 'REFUNDSOURCE' => 'refund_source',
247
- 'REFUNDADVICE' => 'refund_advice',
248
- ) );
249
- // BN Code
250
- $request['BUTTONSOURCE'] = 'WPECOM_ECM';
251
-
252
- return $request;
253
- }
254
-
255
- /**
256
- * Add a subline for the HTML variables array
257
- *
258
- * @param string $sub
259
- * @param array $array
260
- * @return array
261
- * @since 3.9
262
- */
263
- private function add_sub( $sub, $arr ) {
264
- $request = array();
265
-
266
- $i = 0;
267
- foreach( $arr as $key=>$value) {
268
- $request[$sub . $i] = $key . '=' . $value;
269
- $i++;
270
- }
271
-
272
- return $request;
273
- }
274
-
275
- /**
276
- * Gateway implementation for "purchase" operation
277
- *
278
- * @param array $options
279
- * @return PHP_Merchant_Paypal_Pro_Response
280
- * @since 3.9
281
- */
282
- public function purchase( $options = array(), $action = 'Sale' ) {
283
-
284
- }
285
-
286
- /**
287
- * Gateway implementation for "authorize" operation
288
- *
289
- * @param array $options
290
- * @return PHP_Merchant_Paypal_Pro_Response
291
- * @since 3.9
292
- */
293
- public function authorize( $options = array() ) {
294
-
295
- }
296
-
297
- /**
298
- * Gateway implementation for "capture" operation
299
- *
300
- * @param array $options
301
- * @return PHP_Merchant_Paypal_Pro_Response
302
- * @since 3.9
303
- */
304
- public function capture( $options = array() ) {
305
-
306
- }
307
-
308
- /**
309
- * Gateway implementation for "void" operation
310
- *
311
- * @param array $options
312
- * @return PHP_Merchant_Paypal_Pro_Response
313
- * @since 3.9
314
- */
315
- public function void( $options = array() ) {
316
-
317
- }
318
-
319
- /**
320
- * Gateway implementation for RefundTransaction
321
- *
322
- * @param array $options
323
- * @return PHP_Merchant_Paypal_Pro_Response
324
- * @since 3.9
325
- */
326
- public function credit( $options = array() ) {
327
- $this->options = array_merge( $this->options, $options );
328
-
329
- // Required Fields
330
- $this->requires( array( 'message_id', 'invoice' ) );
331
-
332
- // Conditionally required fields (one field at least is set)
333
- $this->conditional_requires( array( 'payer_id', 'transaction_id' ) );
334
-
335
- // Amount is required if the refund is partial
336
- if ( strtolower( $this->options['refund_type'] ) === 'partial' ) {
337
- $this->requires( array( 'amount' ) );
338
- }
339
-
340
- $request = $this->build_checkout_request( $options, false );
341
-
342
- $response_str = $this->commit( 'RefundTransaction', $request );
343
- return new PHP_Merchant_Paypal_Pro_Response( $response_str );
344
- }
345
-
346
- /**
347
- * Gateway impelementation for GetTransactionDetails
348
- *
349
- * @param string $transaction_id Unique identifier of a transaction.
350
- * @return PHP_Merchant_Paypal_Express_Checkout_Response
351
- * @since 3.9
352
- */
353
- public function get_transaction_details( $transaction_id ) {
354
- $request = array( 'TRANSACTIONID' => $transaction_id );
355
- $response_str = $this->commit( 'GetTransactionDetails', $request );
356
- return new PHP_Merchant_Paypal_Pro_Response( $response_str );
357
- }
358
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-response.php DELETED
@@ -1,104 +0,0 @@
1
- <?php
2
-
3
- class PHP_Merchant_Paypal_Response extends PHP_Merchant_Response {
4
- protected $params = array();
5
-
6
- public function __construct( $response_str ) {
7
- parent::__construct( $response_str );
8
-
9
- parse_str( $response_str, $params );
10
-
11
- $this->params = $params = array_map( 'urldecode', $params );
12
-
13
- if ( empty( $params ) || ! isset( $params['ACK'] ) ) {
14
- throw new PHP_Merchant_Exception( PHPME_INVALID_RESPONSE, array(), $response_str );
15
- }
16
-
17
- $this->options['datetime'] = $params['TIMESTAMP'];
18
-
19
- $time = rtrim( $params['TIMESTAMP'], 'Z' ) . '+0000';
20
-
21
- if ( function_exists( 'strptime' ) ) {
22
- if ( ! $time = strptime( $time, '%FT%T%z' ) ) {
23
- $time = strptime( $time, '%FT%T%Z' );
24
- }
25
- } else {
26
- if ( ! $time = self::strptime( $time, '%FT%T%z' ) ) {
27
- $time = self::strptime( $time, '%FT%T%Z' );
28
- }
29
- }
30
-
31
- switch ( $params['ACK'] ) {
32
- case 'Success':
33
- case 'SuccessWithWarning':
34
- $this->is_successful = true;
35
- break;
36
-
37
- case 'Failure':
38
- case 'FailureWithWarning':
39
- case 'Warning':
40
- $this->is_successful = false;
41
- break;
42
- }
43
-
44
- if ( isset( $params['TOKEN'] ) ) {
45
- $this->options['token'] = $params['TOKEN'];
46
- }
47
-
48
- $this->options['correlation_id'] = $params['CORRELATIONID'];
49
- $this->options['version'] = $params['VERSION'];
50
- $this->options['build'] = $params['BUILD'];
51
-
52
- $i = 0;
53
-
54
- while ( array_key_exists( "L_ERRORCODE{$i}", $params ) ) {
55
- $error = array(
56
- 'code' => $params["L_ERRORCODE{$i}"],
57
- 'message' => $params["L_SHORTMESSAGE{$i}"],
58
- 'details' => $params["L_LONGMESSAGE{$i}"],
59
- );
60
-
61
- $this->errors[] = $error;
62
- $i++;
63
- }
64
-
65
- if ( is_array( $time ) ) {
66
- extract( $time, EXTR_SKIP );
67
- $this->options['timestamp'] = mktime( $tm_hour, $tm_min, $tm_sec, 1 + $tm_mon, $tm_mday, 1900 + $tm_year );
68
- } else {
69
- $this->options['timestamp'] = time();
70
- }
71
- }
72
-
73
- public static function strptime( $date, $format ) {
74
- $masks = array(
75
- '%d' => '(?P<d>[0-9]{2})',
76
- '%m' => '(?P<m>[0-9]{2})',
77
- '%Y' => '(?P<Y>[0-9]{4})',
78
- '%H' => '(?P<H>[0-9]{2})',
79
- '%M' => '(?P<M>[0-9]{2})',
80
- '%S' => '(?P<S>[0-9]{2})',
81
- );
82
-
83
- $rexep = '#' . strtr( preg_quote( $format ), $masks ) . '#';
84
-
85
- if ( ! preg_match( $rexep, $date, $out ) ) {
86
- return false;
87
- }
88
-
89
- $ret = array(
90
- 'tm_sec' => (int) $out['S'],
91
- 'tm_min' => (int) $out['M'],
92
- 'tm_hour' => (int) $out['H'],
93
- 'tm_mday' => (int) $out['d'],
94
- 'tm_mon' => $out['m'] ? $out['m'] - 1 : 0,
95
- 'tm_year' => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
96
- );
97
-
98
- return $ret;
99
- }
100
-
101
- public function get_params() {
102
- return $this->params;
103
- }
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
- require_once( dirname( __FILE__ ) . '/../common/php-merchant.php' );
3
- require_once( 'paypal-response.php' );
4
- require_once( 'paypal-ipn.php' );
5
-
6
- abstract class PHP_Merchant_Paypal extends PHP_Merchant
7
- {
8
- private static $supported_currencies = array(
9
- 'AUD',
10
- 'BRL',
11
- 'CAD',
12
- 'CHF',
13
- 'CZK',
14
- 'DKK',
15
- 'EUR',
16
- 'GBP',
17
- 'HKD',
18
- 'HUF',
19
- 'ILS',
20
- 'JPY',
21
- 'MXN',
22
- 'MYR',
23
- 'NOK',
24
- 'NZD',
25
- 'PHP',
26
- 'PLN',
27
- 'SEK',
28
- 'SGD',
29
- 'THB',
30
- 'TWD',
31
- 'USD',
32
- );
33
-
34
- const API_VERSION = '114.0';
35
- const SANDBOX_URL = 'https://api-3t.sandbox.paypal.com/nvp';
36
- const LIVE_URL = 'https://api-3t.paypal.com/nvp';
37
-
38
- protected $request = array();
39
- protected $url;
40
-
41
- protected function add_credentials() {
42
- $this->requires( array( 'api_username', 'api_password', 'api_signature' ) );
43
- $credentials = array(
44
- 'USER' => $this->options['api_username'],
45
- 'PWD' => $this->options['api_password'],
46
- 'VERSION' => self::API_VERSION,
47
- 'SIGNATURE' => $this->options['api_signature'],
48
- );
49
-
50
- return $credentials;
51
- }
52
-
53
- protected function build_request( $action = '', $request = array() ) {
54
- $this->request += $this->add_credentials();
55
- if ( ! empty( $action ) )
56
- $this->request['METHOD'] = $action;
57
- $this->request = array_merge( $this->request, $request );
58
- foreach( $this->request as $key => $value ) {
59
- if ( is_bool( $value ) )
60
- $this->request[$key] = (int) $value;
61
- }
62
-
63
- return $this->request;
64
- }
65
-
66
- public static function get_supported_currencies() {
67
- return self::$supported_currencies;
68
- }
69
-
70
- public function __construct( $options = array() ) {
71
- parent::__construct( $options );
72
- }
73
-
74
- public function get_url() {
75
- return empty( $this->options['test'] ) ? self::LIVE_URL : self::SANDBOX_URL;
76
- }
77
-
78
- public static function is_currency_supported( $currency ) {
79
- return in_array( $currency, self::$supported_currencies );
80
- }
81
-
82
- protected function commit( $action, $request = array() ) {
83
- $this->build_request( $action, $request );
84
- return $this->http->post( $this->get_url(), $this->request );
85
- }
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/http-curl.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/common/http.php' );
4
- require_once( PHP_MERCHANT_PATH . '/common/http-curl.php' );
5
-
6
- class PHP_Merchant_HTTP_CURL_Test extends UnitTestCase
7
- {
8
- public function __construct() {
9
- parent::__construct( 'PHP_Merchant_HTTP_CURL unit tests' );
10
- }
11
-
12
- public function test_array_is_parsed_correctly_into_query_string() {
13
- $http = new PHP_Merchant_HTTP_CURL_Bogus();
14
-
15
- $args = array(
16
- 'key_1' => 'key 1 value',
17
- 'key_2' => 'key&2%value='
18
- );
19
-
20
- $query_string = 'key_1=key+1+value&key_2=key%262%25value%3D';
21
-
22
- $this->assertEqual( $http->parse_args( $args ), $query_string );
23
- }
24
- }
25
-
26
- class PHP_Merchant_HTTP_CURL_Bogus extends PHP_Merchant_HTTP_CURL
27
- {
28
- public function parse_args( $args ) {
29
- return parent::parse_args( $args );
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/php-merchant.php DELETED
@@ -1,180 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/common/php-merchant.php' );
4
-
5
- class PHP_Merchant_Test extends UnitTestCase
6
- {
7
- public function __construct() {
8
- parent::__construct( 'PHP_Merchant test cases' );
9
- }
10
-
11
- public function test_options_are_initialized_correctly() {
12
- $options = array(
13
- 'option_1' => 'option 1',
14
- 'option_2' => 'option 2',
15
- );
16
-
17
- $bogus = new PHP_Merchant_Bogus( $options );
18
- foreach ( $options as $key => $value ) {
19
- $this->assertEqual( $value, $bogus->get_option( $key ) );
20
- }
21
- }
22
-
23
- public function test_multiple_options_are_set_correctly() {
24
- $options = array(
25
- 'option_1' => 'option 1',
26
- 'option_2' => 'option 2',
27
- );
28
-
29
- $bogus = new PHP_Merchant_Bogus();
30
- $bogus->set_options( $options );
31
- foreach ( $options as $key => $value ) {
32
- $this->assertEqual( $value, $bogus->get_option( $key ) );
33
- }
34
- }
35
-
36
- public function test_option_is_set_correctly() {
37
- $bogus = new PHP_Merchant_Bogus();
38
- $bogus->set_option( 'test_option', 'test_value' );
39
- $this->assertEqual( 'test_value', $bogus->get_option( 'test_option' ) );
40
- }
41
-
42
- public function test_default_currency_option_is_usd() {
43
- $bogus = new PHP_Merchant_Bogus();
44
- $this->assertEqual( 'USD', $bogus->get_option( 'currency' ) );
45
- }
46
-
47
- public function test_option_is_overrided_correctly() {
48
- $bogus = new PHP_Merchant_Bogus();
49
- $bogus->set_option( 'currency', 'JPY' );
50
- $this->assertEqual( 'JPY', $bogus->get_option( 'currency' ) );
51
- }
52
-
53
- public function test_multiple_options_are_overrided_correctly() {
54
- $bogus = new PHP_Merchant_Bogus();
55
- $bogus->set_option( 'option_1', 'option 1' );
56
- $bogus->set_option( 'option_2', 'option 2' );
57
-
58
- $bogus->set_options( array(
59
- 'currency' => 'JPY',
60
- 'option_1' => 'updated value',
61
- ) );
62
-
63
- $this->assertEqual( 'JPY', $bogus->get_option( 'currency' ) );
64
- $this->assertEqual( 'updated value', $bogus->get_option( 'option_1' ) );
65
- $this->assertEqual( 'option 2', $bogus->get_option( 'option_2' ) );
66
- }
67
-
68
- public function test_price_is_formatted_correctly() {
69
- $bogus = new PHP_Merchant_Bogus();
70
- $this->assertEqual( $bogus->format( 22.59378 ), '22.59' );
71
- $this->assertEqual( $bogus->format( 22.495 ), '22.5' );
72
- }
73
-
74
- public function test_price_should_not_be_fractional_in_certain_currencies() {
75
- $bogus = new PHP_Merchant_Bogus();
76
- $bogus->set_option( 'currency', 'JPY' );
77
- $this->assertEqual( $bogus->format( 22.59378 ), '23' );
78
- $this->assertEqual( $bogus->format( 22.495 ), '22' );
79
- $this->assertEqual( $bogus->format( 22.333 ), '22' );
80
-
81
- $bogus->set_option( 'currency', 'HUF' );
82
- $this->assertEqual( $bogus->format( 22.59378 ), '23' );
83
- $this->assertEqual( $bogus->format( 22.495 ), '22' );
84
- $this->assertEqual( $bogus->format( 22.333 ), '22' );
85
- }
86
-
87
- public function test_no_exception_is_thrown_when_feature_is_supported() {
88
- $bogus = new PHP_Merchant_Bogus_Full_Features();
89
- $bogus->authorize();
90
- $bogus->capture();
91
- $bogus->void();
92
- $bogus->credit();
93
- $bogus->recurring();
94
- }
95
-
96
- public function test_exception_is_thrown_when_authorize_is_not_supported() {
97
- $bogus = new PHP_Merchant_Bogus();
98
-
99
- $this->expectException( new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'authorize' ) );
100
- $bogus->authorize();
101
- }
102
-
103
- public function test_exception_is_thrown_when_capture_is_not_supported() {
104
- $bogus = new PHP_Merchant_Bogus();
105
-
106
- $this->expectException( new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'capture' ) );
107
- $bogus->capture();
108
- }
109
-
110
- public function test_exception_is_thrown_when_void_is_not_supported() {
111
- $bogus = new PHP_Merchant_Bogus();
112
-
113
- $this->expectException( new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'void' ) );
114
- $bogus->void();
115
- }
116
-
117
- public function test_exception_is_thrown_when_credit_is_not_supported() {
118
- $bogus = new PHP_Merchant_Bogus();
119
-
120
- $this->expectException( new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'credit' ) );
121
- $bogus->credit();
122
- }
123
-
124
- public function test_exception_is_thrown_when_recurring_is_not_supported() {
125
- $bogus = new PHP_Merchant_Bogus();
126
-
127
- $this->expectException( new PHP_Merchant_Exception( PHPME_FEATURE_NOT_SUPPORTED, 'recurring' ) );
128
- $bogus->recurring();
129
- }
130
-
131
- public function test_exception_is_thrown_when_a_required_option_is_missing() {
132
- $bogus = new PHP_Merchant_Bogus();
133
-
134
- $this->expectException( new PHP_Merchant_Exception( PHPME_REQUIRED_OPTION_UNDEFINED, array( 'missing_option' ) ) );
135
- $bogus->requires( 'missing_option' );
136
- }
137
-
138
- public function test_exception_is_thrown_when_some_required_options_are_missing() {
139
- $bogus = new PHP_Merchant_Bogus();
140
-
141
- $bogus->set_option( 'option_1', 'option 1' );
142
- $bogus->set_option( 'option_2', 'option 2' );
143
-
144
- $this->expectException( new PHP_Merchant_Exception( PHPME_REQUIRED_OPTION_UNDEFINED, array( 'missing_option' ) ) );
145
- $bogus->requires( array( 'currency', 'option_1', 'option_2', 'missing_option' ) );
146
- }
147
-
148
- public function test_exception_is_thrown_when_some_cond_required_options_are_missing() {
149
- $bogus = new PHP_Merchant_Bogus();
150
-
151
- $this->expectException( new PHP_Merchant_Exception( PHPME_REQUIRED_OPTION_UNDEFINED, 'option_1, option_2, option_3' ) );
152
- $bogus->conditional_requires( array( 'option_1', 'option_2', 'option_3' ) );
153
- }
154
- }
155
-
156
- class PHP_Merchant_Bogus extends PHP_Merchant {
157
- public function requires( $options ) {
158
- parent::requires( $options );
159
- }
160
- public function conditional_requires( $options ) {
161
- parent::conditional_requires( $options );
162
- }
163
- }
164
-
165
- class PHP_Merchant_Bogus_Full_Features extends PHP_Merchant {
166
- public function authorize() {
167
- }
168
-
169
- public function capture() {
170
- }
171
-
172
- public function void() {
173
- }
174
-
175
- public function credit() {
176
- }
177
-
178
- public function recurring() {
179
- }
180
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/test-accounts.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- // @todo: Update to use canonical test accounts rather than those of individuals.
3
- $test_accounts = array(
4
- 'paypal-express-checkout' => array(
5
- 'api_username' => 'pro_1304085877_biz_api1.garyc40.com',
6
- 'api_password' => '1304085909',
7
- 'api_signature' => 'AvoRfECzHW0KLVBSrJC70dNDVgEQA2j69L5ydKo3JhQBCJCNrZTj2zS8',
8
- 'test' => true,
9
- ),
10
- 'paypal-ec-oa' => array(
11
- 'api_username' => 'paypal-facilitator_api1.omarabid.com',
12
- 'api_password' => '1404523024',
13
- 'api_signature' => 'An5ns1Kso7MWUdW4ErQKJJJ4qi4-AnIgHxdxM4-jkGKkkOhcO0fD-Av5',
14
- 'test' => true,
15
- ),
16
- 'paypal-pro-oa' => array(
17
- 'api_username' => 'wpp_api1.omarabid.com',
18
- 'api_password' => '4WQY6WGGAGS4JPEA',
19
- 'api_signature' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AboWy-uBCAMW9aDx8JwAq7ryYemY',
20
- 'test' => true,
21
- ),
22
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal-express-checkout.php DELETED
@@ -1,552 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Test extends UnitTestCase
6
- {
7
- private $bogus;
8
- private $options;
9
- private $amount;
10
- private $token;
11
- private $setup_purchase_options;
12
- private $purchase_options;
13
-
14
- public function __construct() {
15
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
16
- $this->token = 'EC-6L77249383950130E';
17
- // options to pass to the merchant class
18
- $this->setup_purchase_options = $this->purchase_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => true,
23
-
24
- // Shipping details
25
- 'shipping_address' => array(
26
- 'name' => 'Gary Cao',
27
- 'street' => '1 Infinite Loop',
28
- 'street2' => 'Apple Headquarter',
29
- 'city' => 'Cupertino',
30
- 'state' => 'CA',
31
- 'country' => 'USA',
32
- 'zip' => '95014',
33
- 'phone' => '(877) 412-7753',
34
- ),
35
-
36
- // Payment info
37
- 'currency' => 'JPY',
38
- 'amount' => 15337,
39
- 'subtotal' => 13700,
40
- 'shipping' => 1500,
41
- 'tax' => 137,
42
- 'description' => 'Order for example.com',
43
- 'invoice' => 'E84A90G94',
44
- 'notify_url' => 'http://example.com/ipn',
45
-
46
- // Items
47
- 'items' => array(
48
- array(
49
- 'name' => 'Gold Cart Plugin',
50
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality, including views, galleries, store search and payment gateways.',
51
- 'amount' => 4000,
52
- 'quantity' => 1,
53
- 'tax' => 40,
54
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
55
- ),
56
- array(
57
- 'name' => 'Member Access Plugin',
58
- 'description' => 'Create pay to view subscription sites',
59
- 'amount' => 5000,
60
- 'quantity' => 1,
61
- 'tax' => 50,
62
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
63
- ),
64
- array(
65
- 'name' => 'Amazon S3',
66
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
67
- 'amount' => 4700,
68
- 'quantity' => 1,
69
- 'tax' => 47,
70
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
71
- ),
72
- ),
73
- );
74
-
75
- $this->purchase_options += array(
76
- 'token' => 'EC-2JJ0893331633543K',
77
- 'payer_id' => 'BC798KQ2QU22W',
78
- );
79
- }
80
-
81
- public function setUp() {
82
- $this->bogus = new PHP_Merchant_Paypal_Express_Checkout_Bogus( array(
83
- 'api_username' => 'sdk-three_api1.sdk.com',
84
- 'api_password' => 'QFZCWN5HZM8VBG7Q',
85
- 'api_signature' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
86
- ) );
87
- }
88
-
89
- public function tearDown() {
90
-
91
- }
92
-
93
- public function test_correct_parameters_are_sent_to_paypal_when_set_express_checkout() {
94
- // set up expectations for mock objects
95
- $url = 'https://api-3t.paypal.com/nvp';
96
-
97
- // how the request parameters should look like
98
- $args = array(
99
- // API info
100
- 'USER' => 'sdk-three_api1.sdk.com',
101
- 'PWD' => 'QFZCWN5HZM8VBG7Q',
102
- 'VERSION' => '114.0',
103
- 'SIGNATURE' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
104
- 'METHOD' => 'SetExpressCheckout',
105
- 'RETURNURL' => 'http://example.com/return',
106
- 'CANCELURL' => 'http://example.com/cancel',
107
- 'AMT' => 15337,
108
- 'ADDROVERRIDE' => 1,
109
- 'INVOICEID' => 'E84A90G94',
110
-
111
-
112
- // Shipping details
113
- 'PAYMENTREQUEST_0_SHIPTONAME' => 'Gary Cao',
114
- 'PAYMENTREQUEST_0_SHIPTOSTREET' => '1 Infinite Loop',
115
- 'PAYMENTREQUEST_0_SHIPTOSTREET2' => 'Apple Headquarter',
116
- 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Cupertino',
117
- 'PAYMENTREQUEST_0_SHIPTOSTATE' => 'CA',
118
- 'PAYMENTREQUEST_0_SHIPTOZIP' => '95014',
119
- 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'USA',
120
- 'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '(877) 412-7753',
121
-
122
- // Payment info
123
- 'PAYMENTREQUEST_0_AMT' => '15,337',
124
- 'PAYMENTREQUEST_0_CURRENCYCODE' => 'JPY',
125
- 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
126
- 'PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD' => 'InstantPaymentOnly',
127
- 'PAYMENTREQUEST_0_ITEMAMT' => '13,700',
128
- 'PAYMENTREQUEST_0_SHIPPINGAMT' => '1,500',
129
- 'PAYMENTREQUEST_0_TAXAMT' => '137',
130
- 'PAYMENTREQUEST_0_DESC' => 'Order for example.com',
131
- 'PAYMENTREQUEST_0_INVNUM' => 'E84A90G94',
132
- 'PAYMENTREQUEST_0_NOTIFYURL' => 'http://example.com/ipn',
133
-
134
- // Items
135
- 'L_PAYMENTREQUEST_0_NAME0' => 'Gold Cart Plugin',
136
- 'L_PAYMENTREQUEST_0_AMT0' => '4,000',
137
- 'L_PAYMENTREQUEST_0_QTY0' => 1,
138
- 'L_PAYMENTREQUEST_0_DESC0' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality, including views, galleries, store search and payment gateways.',
139
- 'L_PAYMENTREQUEST_0_TAXAMT0' => '40',
140
- 'L_PAYMENTREQUEST_0_ITEMURL0' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
141
-
142
- 'L_PAYMENTREQUEST_0_NAME1' => 'Member Access Plugin',
143
- 'L_PAYMENTREQUEST_0_AMT1' => '5,000',
144
- 'L_PAYMENTREQUEST_0_QTY1' => 1,
145
- 'L_PAYMENTREQUEST_0_DESC1' => 'Create pay to view subscription sites',
146
- 'L_PAYMENTREQUEST_0_TAXAMT1' => '50',
147
- 'L_PAYMENTREQUEST_0_ITEMURL1' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
148
-
149
- 'L_PAYMENTREQUEST_0_NAME2' => 'Amazon S3',
150
- 'L_PAYMENTREQUEST_0_AMT2' => '4,700',
151
- 'L_PAYMENTREQUEST_0_QTY2' => 1,
152
- 'L_PAYMENTREQUEST_0_DESC2' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
153
- 'L_PAYMENTREQUEST_0_TAXAMT2' => '47',
154
- 'L_PAYMENTREQUEST_0_ITEMURL2' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
155
- );
156
-
157
- $this->bogus->http->expectOnce( 'post', array( $url, $args ) );
158
- try {
159
- $this->bogus->setup_purchase( $this->setup_purchase_options );
160
- } catch ( PHP_Merchant_Exception $e ) {
161
-
162
- }
163
- }
164
-
165
- public function test_correct_parameters_are_sent_when_do_express_checkout_payment() {
166
- // set up expectations for mock objects
167
- $url = 'https://api-3t.paypal.com/nvp';
168
-
169
- // how the request parameters should look like
170
- $args = array(
171
- // API info
172
- 'USER' => 'sdk-three_api1.sdk.com',
173
- 'PWD' => 'QFZCWN5HZM8VBG7Q',
174
- 'VERSION' => '114.0',
175
- 'SIGNATURE' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
176
- 'METHOD' => 'DoExpressCheckoutPayment',
177
- 'RETURNURL' => 'http://example.com/return',
178
- 'CANCELURL' => 'http://example.com/cancel',
179
- 'AMT' => 15337,
180
- 'ADDROVERRIDE' => 1,
181
-
182
- // Payer ID
183
- 'TOKEN' => 'EC-2JJ0893331633543K',
184
- 'PAYERID' => 'BC798KQ2QU22W',
185
-
186
- 'INVOICEID' => 'E84A90G94',
187
-
188
- // Shipping details
189
- 'PAYMENTREQUEST_0_SHIPTONAME' => 'Gary Cao',
190
- 'PAYMENTREQUEST_0_SHIPTOSTREET' => '1 Infinite Loop',
191
- 'PAYMENTREQUEST_0_SHIPTOSTREET2' => 'Apple Headquarter',
192
- 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Cupertino',
193
- 'PAYMENTREQUEST_0_SHIPTOSTATE' => 'CA',
194
- 'PAYMENTREQUEST_0_SHIPTOZIP' => '95014',
195
- 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'USA',
196
- 'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '(877) 412-7753',
197
-
198
- // Payment info
199
- 'PAYMENTREQUEST_0_AMT' => '15,337',
200
- 'PAYMENTREQUEST_0_CURRENCYCODE' => 'JPY',
201
- 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
202
- 'PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD' => 'InstantPaymentOnly',
203
- 'PAYMENTREQUEST_0_ITEMAMT' => '13,700',
204
- 'PAYMENTREQUEST_0_SHIPPINGAMT' => '1,500',
205
- 'PAYMENTREQUEST_0_TAXAMT' => '137',
206
- 'PAYMENTREQUEST_0_DESC' => 'Order for example.com',
207
- 'PAYMENTREQUEST_0_INVNUM' => 'E84A90G94',
208
- 'PAYMENTREQUEST_0_NOTIFYURL' => 'http://example.com/ipn',
209
-
210
- // Items
211
- 'L_PAYMENTREQUEST_0_NAME0' => 'Gold Cart Plugin',
212
- 'L_PAYMENTREQUEST_0_AMT0' => '4,000',
213
- 'L_PAYMENTREQUEST_0_QTY0' => 1,
214
- 'L_PAYMENTREQUEST_0_DESC0' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality, including views, galleries, store search and payment gateways.',
215
- 'L_PAYMENTREQUEST_0_TAXAMT0' => '40',
216
- 'L_PAYMENTREQUEST_0_ITEMURL0' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
217
-
218
- 'L_PAYMENTREQUEST_0_NAME1' => 'Member Access Plugin',
219
- 'L_PAYMENTREQUEST_0_AMT1' => '5,000',
220
- 'L_PAYMENTREQUEST_0_QTY1' => 1,
221
- 'L_PAYMENTREQUEST_0_DESC1' => 'Create pay to view subscription sites',
222
- 'L_PAYMENTREQUEST_0_TAXAMT1' => '50',
223
- 'L_PAYMENTREQUEST_0_ITEMURL1' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
224
-
225
- 'L_PAYMENTREQUEST_0_NAME2' => 'Amazon S3',
226
- 'L_PAYMENTREQUEST_0_AMT2' => '4,700',
227
- 'L_PAYMENTREQUEST_0_QTY2' => 1,
228
- 'L_PAYMENTREQUEST_0_DESC2' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
229
- 'L_PAYMENTREQUEST_0_TAXAMT2' => '47',
230
- 'L_PAYMENTREQUEST_0_ITEMURL2' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
231
- );
232
-
233
- $this->bogus->http->expectOnce( 'post', array( $url, $args ) );
234
- try {
235
- $this->bogus->purchase( $this->purchase_options );
236
- } catch ( PHP_Merchant_Exception $e ) {
237
-
238
- }
239
- }
240
-
241
- public function test_correct_parameters_are_sent_when_get_express_checkout_details() {
242
- $url = 'https://api-3t.paypal.com/nvp';
243
- $args = array(
244
- // API info
245
- 'USER' => 'sdk-three_api1.sdk.com',
246
- 'PWD' => 'QFZCWN5HZM8VBG7Q',
247
- 'VERSION' => '114.0',
248
- 'SIGNATURE' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
249
- 'METHOD' => 'GetExpressCheckoutDetails',
250
- 'TOKEN' => $this->token,
251
- );
252
-
253
- $this->bogus->http->expectOnce( 'post', array( $url, $args ) );
254
- try {
255
- $this->bogus->get_details_for( $this->token );
256
- } catch ( PHP_Merchant_Exception $e ) {
257
-
258
- }
259
- }
260
-
261
- public function test_correct_response_is_returned_when_set_express_checkout_is_successful() {
262
- $mock_response = 'ACK=Success&CORRELATIONID=224f0e4a32d14&TIMESTAMP=2011%2d07%2d05T13%253A23%253A52Z&VERSION=2%2e30000&BUILD=1%2e0006&TOKEN=EC%2d1OIN4UJGFOK54YFV';
263
- $this->bogus->http->returnsByValue( 'post', $mock_response );
264
- $response = $this->bogus->setup_purchase( $this->setup_purchase_options );
265
-
266
- $this->assertTrue( $response->is_successful() );
267
- $this->assertFalse( $response->has_errors() );
268
- $this->assertEqual( $response->get( 'token' ), 'EC-1OIN4UJGFOK54YFV' );
269
- $this->assertEqual( $response->get( 'timestamp' ), 1309872232 );
270
- $this->assertEqual( $response->get( 'datetime' ), '2011-07-05T13:23:52Z' );
271
- $this->assertEqual( $response->get( 'correlation_id' ), '224f0e4a32d14' );
272
- $this->assertEqual( $response->get( 'version' ), '2.30000' );
273
- $this->assertEqual( $response->get( 'build' ), '1.0006' );
274
- }
275
-
276
- public function test_correct_response_is_returned_when_get_express_checkout_details_is_successful() {
277
- $mock_response = 'TOKEN=EC%2d6EC97401PF4449255'.
278
-
279
- // API Info
280
- '&CHECKOUTSTATUS=PaymentActionNotInitiated'.
281
- '&TIMESTAMP=2011%2d08%2d25T08%3a04%3a26Z'.
282
- '&CORRELATIONID=b5ae9bd5c735f'.
283
- '&ACK=Success'.
284
- '&VERSION=114%2e0'.
285
- '&BUILD=2085867'.
286
-
287
- // Payer info
288
- '&EMAIL=visa_1304648966_per%40garyc40%2ecom'.
289
- '&PAYERID=BC798KQ2QU22W'.
290
- '&PAYERSTATUS=verified'.
291
- '&FIRSTNAME=Test'.
292
- '&LASTNAME=User'.
293
- '&COUNTRYCODE=US'.
294
- '&SHIPTONAME=Gary%20Cao'.
295
- '&SHIPTOSTREET=1%20Infinite%20Loop'.
296
- '&SHIPTOSTREET2=Apple%20Headquarter'.
297
- '&SHIPTOCITY=Cupertino'.
298
- '&SHIPTOSTATE=CA'.
299
- '&SHIPTOZIP=95014'.
300
- '&SHIPTOCOUNTRYCODE=US'.
301
- '&SHIPTOPHONENUM=%28877%29%20412%2d7753'.
302
- '&SHIPTOCOUNTRYNAME=United%20States'.
303
- '&ADDRESSSTATUS=Unconfirmed'.
304
-
305
- // Legacy parameters (old API)
306
- '&CURRENCYCODE=JPY'.
307
- '&AMT=15337'.
308
- '&ITEMAMT=13700'.
309
- '&SHIPPINGAMT=1500'.
310
- '&HANDLINGAMT=0'.
311
- '&TAXAMT=137'.
312
- '&DESC=Order%20for%20example%2ecom'.
313
- '&INVNUM=E84A90G94'.
314
- '&NOTIFYURL=http%3a%2f%2fexample%2ecom%2fipn'.
315
- '&INSURANCEAMT=0'.
316
- '&SHIPDISCAMT=0'.
317
-
318
- // Legacy parameters (old API)
319
- '&L_NAME0=Gold%20Cart%20Plugin'.
320
- '&L_NAME1=Member%20Access%20Plugin'.
321
- '&L_NAME2=Amazon%20S3'.
322
- '&L_QTY0=1'.
323
- '&L_QTY1=1'.
324
- '&L_QTY2=1'.
325
- '&L_TAXAMT0=40'.
326
- '&L_TAXAMT1=50'.
327
- '&L_TAXAMT2=47'.
328
- '&L_AMT0=4000'.
329
- '&L_AMT1=5000'.
330
- '&L_AMT2=4700'.
331
- '&L_DESC0=Gold%20Cart%20extends%20your%20WP%20e%2dCommerce%20store%20by%20enabling%20additional%20features%20and%20functionality%2e'.
332
- '&L_DESC1=Create%20pay%20to%20view%20subscription%20sites'.
333
- '&L_DESC2=This%20Plugin%20allows%20downloadable%20products%20on%20your%20WP%20e%2dCommerce%20site%20to%20be%20hosted%20on%20Amazon%20S3%2e'.
334
- '&L_ITEMWEIGHTVALUE0=%20%20%200%2e00000'.
335
- '&L_ITEMWEIGHTVALUE1=%20%20%200%2e00000'.
336
- '&L_ITEMWEIGHTVALUE2=%20%20%200%2e00000'.
337
- '&L_ITEMLENGTHVALUE0=%20%20%200%2e00000'.
338
- '&L_ITEMLENGTHVALUE1=%20%20%200%2e00000'.
339
- '&L_ITEMLENGTHVALUE2=%20%20%200%2e00000'.
340
- '&L_ITEMWIDTHVALUE0=%20%20%200%2e00000'.
341
- '&L_ITEMWIDTHVALUE1=%20%20%200%2e00000'.
342
- '&L_ITEMWIDTHVALUE2=%20%20%200%2e00000'.
343
- '&L_ITEMHEIGHTVALUE0=%20%20%200%2e00000'.
344
- '&L_ITEMHEIGHTVALUE1=%20%20%200%2e00000'.
345
- '&L_ITEMHEIGHTVALUE2=%20%20%200%2e00000'.
346
-
347
- // Payment Information
348
- '&PAYMENTREQUEST_0_CURRENCYCODE=JPY'.
349
- '&PAYMENTREQUEST_0_AMT=15337'.
350
- '&PAYMENTREQUEST_0_ITEMAMT=13700'.
351
- '&PAYMENTREQUEST_0_SHIPPINGAMT=1500'.
352
- '&PAYMENTREQUEST_0_HANDLINGAMT=0'.
353
- '&PAYMENTREQUEST_0_TAXAMT=137'.
354
- '&PAYMENTREQUEST_0_DESC=Order%20for%20example%2ecom'.
355
- '&PAYMENTREQUEST_0_INVNUM=E84A90G94'.
356
- '&PAYMENTREQUEST_0_NOTIFYURL=http%3a%2f%2fexample%2ecom%2fipn'.
357
- '&PAYMENTREQUEST_0_INSURANCEAMT=0'.
358
- '&PAYMENTREQUEST_0_SHIPDISCAMT=0'.
359
- '&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false'.
360
-
361
- // Item Information
362
- '&L_PAYMENTREQUEST_0_NAME0=Gold%20Cart%20Plugin'.
363
- '&L_PAYMENTREQUEST_0_NAME1=Member%20Access%20Plugin'.
364
- '&L_PAYMENTREQUEST_0_NAME2=Amazon%20S3'.
365
- '&L_PAYMENTREQUEST_0_QTY0=1'.
366
- '&L_PAYMENTREQUEST_0_QTY1=1'.
367
- '&L_PAYMENTREQUEST_0_QTY2=1'.
368
- '&L_PAYMENTREQUEST_0_TAXAMT0=40'.
369
- '&L_PAYMENTREQUEST_0_TAXAMT1=50'.
370
- '&L_PAYMENTREQUEST_0_TAXAMT2=47'.
371
- '&L_PAYMENTREQUEST_0_AMT0=4000'.
372
- '&L_PAYMENTREQUEST_0_AMT1=5000'.
373
- '&L_PAYMENTREQUEST_0_AMT2=4700'.
374
- '&L_PAYMENTREQUEST_0_DESC0=Gold%20Cart%20extends%20your%20WP%20e%2dCommerce%20store%20by%20enabling%20additional%20features%20and%20functionality%2e'.
375
- '&L_PAYMENTREQUEST_0_DESC1=Create%20pay%20to%20view%20subscription%20sites'.
376
- '&L_PAYMENTREQUEST_0_DESC2=This%20Plugin%20allows%20downloadable%20products%20on%20your%20WP%20e%2dCommerce%20site%20to%20be%20hosted%20on%20Amazon%20S3%2e'.
377
- '&L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0=%20%20%200%2e00000'.
378
- '&L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE1=%20%20%200%2e00000'.
379
- '&L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE2=%20%20%200%2e00000'.
380
- '&L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0=%20%20%200%2e00000'.
381
- '&L_PAYMENTREQUEST_0_ITEMLENGTHVALUE1=%20%20%200%2e00000'.
382
- '&L_PAYMENTREQUEST_0_ITEMLENGTHVALUE2=%20%20%200%2e00000'.
383
- '&L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0=%20%20%200%2e00000'.
384
- '&L_PAYMENTREQUEST_0_ITEMWIDTHVALUE1=%20%20%200%2e00000'.
385
- '&L_PAYMENTREQUEST_0_ITEMWIDTHVALUE2=%20%20%200%2e00000'.
386
- '&L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0=%20%20%200%2e00000'.
387
- '&L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE1=%20%20%200%2e00000'.
388
- '&L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE2=%20%20%200%2e00000'.
389
-
390
- // Errors
391
- '&PAYMENTREQUESTINFO_0_ERRORCODE=0';
392
-
393
- $this->bogus->http->returnsByValue( 'post', $mock_response );
394
- $response = $this->bogus->get_details_for( $this->token );
395
-
396
- $this->assertTrue( $response->is_successful() );
397
- $this->assertFalse( $response->has_errors() );
398
-
399
- // API Info
400
- $this->assertTrue( $response->is_checkout_not_initiated() );
401
- $this->assertFalse( $response->is_checkout_failed() );
402
- $this->assertFalse( $response->is_checkout_in_progress() );
403
- $this->assertFalse( $response->is_checkout_completed() );
404
- $this->assertEqual( $response->get( 'checkout_status' ), 'Not-Initiated' );
405
- $this->assertEqual( $response->get( 'token' ), 'EC-6EC97401PF4449255' );
406
- $this->assertEqual( $response->get( 'timestamp' ), 1314259466 );
407
- $this->assertEqual( $response->get( 'datetime' ), '2011-08-25T08:04:26Z' );
408
- $this->assertEqual( $response->get( 'correlation_id' ), 'b5ae9bd5c735f' );
409
- $this->assertEqual( $response->get( 'version' ), '114.0' );
410
- $this->assertEqual( $response->get( 'build' ), '2085867' );
411
-
412
- // Payer Information
413
- $mock_payer = (Object) array(
414
- 'email' => 'visa_1304648966_per@garyc40.com',
415
- 'id' => 'BC798KQ2QU22W',
416
- 'status' => 'verified',
417
- 'shipping_status' => 'Unconfirmed',
418
- 'first_name' => 'Test',
419
- 'last_name' => 'User',
420
- 'country' => 'US',
421
- );
422
- $this->assertEqual( $response->get( 'payer' ), $mock_payer );
423
-
424
- // Shipping Address
425
- $mock_shipping_address = array(
426
- 'name' => 'Gary Cao',
427
- 'street' => '1 Infinite Loop',
428
- 'street2' => 'Apple Headquarter',
429
- 'city' => 'Cupertino',
430
- 'state' => 'CA',
431
- 'zip' => '95014',
432
- 'country_code' => 'US',
433
- 'country' => 'United States',
434
- 'phone' => '(877) 412-7753',
435
- );
436
- $this->assertEqual( $response->get( 'shipping_address' ), $mock_shipping_address );
437
-
438
- // Payment Information
439
- $this->assertEqual( $response->get( 'currency' ), 'JPY' );
440
- $this->assertEqual( $response->get( 'amount' ), 15337 );
441
- $this->assertEqual( $response->get( 'subtotal' ), 13700 );
442
- $this->assertEqual( $response->get( 'shipping' ), 1500 );
443
- $this->assertEqual( $response->get( 'handling' ), 0 );
444
- $this->assertEqual( $response->get( 'tax' ), 137 );
445
- $this->assertEqual( $response->get( 'invoice' ), 'E84A90G94' );
446
- $this->assertEqual( $response->get( 'notify_url' ), 'http://example.com/ipn' );
447
- $this->assertEqual( $response->get( 'shipping_discount' ), 0 );
448
-
449
- // Item Information
450
- $items = $response->get( 'items' );
451
- $mock_items = array();
452
-
453
- $mock_items[0] = new stdClass();
454
- $mock_items[0]->name = 'Gold Cart Plugin';
455
- $mock_items[0]->description = 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.';
456
- $mock_items[0]->amount = 4000;
457
- $mock_items[0]->quantity = 1;
458
- $mock_items[0]->tax = 40;
459
-
460
- $mock_items[1] = new stdClass();
461
- $mock_items[1]->name = 'Member Access Plugin';
462
- $mock_items[1]->description = 'Create pay to view subscription sites';
463
- $mock_items[1]->amount = 5000;
464
- $mock_items[1]->quantity = 1;
465
- $mock_items[1]->tax = 50;
466
-
467
- $mock_items[2] = new stdClass();
468
- $mock_items[2]->name = 'Amazon S3';
469
- $mock_items[2]->description = 'This Plugin allows downloadable products on your WP eCommerce site to be hosted on Amazon S3.';
470
- $mock_items[2]->amount = 4700;
471
- $mock_items[2]->quantity = 1;
472
- $mock_items[2]->tax = 47;
473
-
474
- $this->assertEqual( $items, $mock_items );
475
- }
476
-
477
- public function test_correct_response_is_returned_when_set_express_checkout_fails() {
478
- $mock_response = 'ACK=Failure&CORRELATIONID=224f0e4a32d14&TIMESTAMP=2011%2d07%2d05T13%253A23%253A52Z&VERSION=2%2e30000&BUILD=1%2e0006&TOKEN=EC%2d1OIN4UJGFOK54YFV&L_ERRORCODE0=10412&L_SHORTMESSAGE0=Duplicate%20invoice&L_LONGMESSAGE0=Payment%20has%20already%20been%20made%20for%20this%20InvoiceID.&L_SEVERITYCODE0=3&L_ERRORCODE1=10010&L_SHORTMESSAGE1=Invalid%20Invoice&L_LONGMESSAGE1=Non-ASCII%20invoice%20id%20is%20not%20supported.&L_SEVERITYCODE1=3';
479
- $this->bogus->http->returnsByValue( 'post', $mock_response );
480
- $response = $this->bogus->setup_purchase( $this->setup_purchase_options );
481
-
482
- $this->assertFalse( $response->is_successful() );
483
- $this->assertTrue( $response->has_errors() );
484
- $this->assertEqual( $response->get( 'timestamp' ), 1309872232 );
485
- $this->assertEqual( $response->get( 'datetime' ), '2011-07-05T13:23:52Z' );
486
- $this->assertEqual( $response->get( 'correlation_id' ), '224f0e4a32d14' );
487
- $this->assertEqual( $response->get( 'version' ), '2.30000' );
488
- $this->assertEqual( $response->get( 'build' ), '1.0006' );
489
-
490
- $expected_errors = array(
491
- array(
492
- 'code' => 10412,
493
- 'message' => 'Duplicate invoice',
494
- 'details' => 'Payment has already been made for this InvoiceID.',
495
- ),
496
-
497
- array(
498
- 'code' => 10010,
499
- 'message' => 'Invalid Invoice',
500
- 'details' => 'Non-ASCII invoice id is not supported.',
501
- ),
502
- );
503
- $actual_errors = $response->get_errors();
504
- $this->assertEqual( $actual_errors, $expected_errors );
505
- }
506
-
507
- public function test_correct_response_is_returned_when_set_express_checkout_is_successful_with_warning() {
508
- $mock_response = 'ACK=SuccessWithWarning&CORRELATIONID=224f0e4a32d14&TIMESTAMP=2011%2d07%2d05T13%253A23%253A52Z&VERSION=2%2e30000&BUILD=1%2e0006&TOKEN=EC%2d1OIN4UJGFOK54YFV&L_ERRORCODE0=10412&L_SHORTMESSAGE0=Duplicate%20invoice&L_LONGMESSAGE0=Payment%20has%20already%20been%20made%20for%20this%20InvoiceID.&L_SEVERITYCODE0=3&L_ERRORCODE1=10010&L_SHORTMESSAGE1=Invalid%20Invoice&L_LONGMESSAGE1=Non-ASCII%20invoice%20id%20is%20not%20supported.&L_SEVERITYCODE1=3';
509
-
510
- $this->bogus->http->returnsByValue( 'post', $mock_response );
511
- $response = $this->bogus->setup_purchase( $this->setup_purchase_options );
512
-
513
- $this->assertTrue( $response->is_successful() );
514
- $this->assertTrue( $response->has_errors() );
515
- $this->assertEqual( $response->get( 'token' ), 'EC-1OIN4UJGFOK54YFV' );
516
- $this->assertEqual( $response->get( 'timestamp' ), 1309872232 );
517
- $this->assertEqual( $response->get( 'datetime' ), '2011-07-05T13:23:52Z' );
518
- $this->assertEqual( $response->get( 'correlation_id' ), '224f0e4a32d14' );
519
- $this->assertEqual( $response->get( 'version' ), '2.30000' );
520
- $this->assertEqual( $response->get( 'build' ), '1.0006' );
521
-
522
- $expected_errors = array(
523
- array(
524
- 'code' => 10412,
525
- 'message' => 'Duplicate invoice',
526
- 'details' => 'Payment has already been made for this InvoiceID.',
527
- ),
528
-
529
- array(
530
- 'code' => 10010,
531
- 'message' => 'Invalid Invoice',
532
- 'details' => 'Non-ASCII invoice id is not supported.',
533
- ),
534
- );
535
- $actual_errors = $response->get_errors();
536
- $this->assertEqual( $actual_errors, $expected_errors );
537
-
538
- }
539
- }
540
-
541
- require_once( PHP_MERCHANT_PATH . '/common/http-curl.php' );
542
- Mock::generate( 'PHP_Merchant_HTTP_CURL' );
543
-
544
- class PHP_Merchant_Paypal_Express_Checkout_Bogus extends PHP_Merchant_Paypal_Express_Checkout
545
- {
546
- public $http;
547
-
548
- public function __construct( $options = array() ) {
549
- $options['http_client'] = new MockPHP_Merchant_HTTP_CURL();
550
- parent::__construct( $options );
551
- }
552
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal-ipn.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-ipn.php' );
4
-
5
- class PHP_Merchant_Paypal_IPN_Test extends UnitTestCase
6
- {
7
- private $http;
8
-
9
- public $ipn_request = array(
10
- 'mc_gross' => '-27.50',
11
- 'invoice' => '1411316760920',
12
- 'settle_amount' => '19.02',
13
- 'protection_eligibility' => 'Eligible',
14
- 'item_number1' => '',
15
- 'payer_id' => 'BC798KQ2QU22W',
16
- 'address_street' => '1 Main St',
17
- 'payment_date' => '00:06:09 Sep 23, 2011 PDT',
18
- 'payment_status' => 'Pending',
19
- 'charset' => 'windows-1252',
20
- 'address_zip' => '95131',
21
- 'mc_shipping' => '0.00',
22
- 'mc_handling' => '0.00',
23
- 'first_name' => 'Test',
24
- 'mc_fee' => '-1.25',
25
- 'address_country_code' => 'US',
26
- 'exchange_rate' => '0.724571',
27
- 'address_name' => 'Test User',
28
- 'notify_version' => '3.4',
29
- 'reason_code' => 'refund',
30
- 'settle_currency' => 'USD',
31
- 'custom' => '',
32
- 'address_country' => 'United States',
33
- 'mc_handling1' => '0.00',
34
- 'address_city' => 'San Jose',
35
- 'verify_sign' => 'An5ns1Kso7MWUdW4ErQKJJJ4qi4-AVcXYpICHDtcWk34bsCJQf7rc93o',
36
- 'payer_email' => 'visa_1304648966_per@garyc40.com',
37
- 'mc_shipping1' => '0.00',
38
- 'parent_txn_id' => '3BC81385RB1253259',
39
- 'txn_id' => '64B91482UD035471X',
40
- 'payment_type' => 'echeck',
41
- 'last_name' => 'User',
42
- 'address_state' => 'CA',
43
- 'item_name1' => 'Test Product',
44
- 'receiver_email' => 'pro_1304085877_biz@garyc40.com',
45
- 'payment_fee' => '',
46
- 'quantity1' => '1',
47
- 'receiver_id' => 'S2FHLPD5HHGMJ',
48
- 'pending_reason' => 'echeck',
49
- 'mc_gross_1' => '25.00',
50
- 'mc_currency' => 'NZD',
51
- 'residence_country' => 'US',
52
- 'test_ipn' => '1',
53
- 'transaction_subject' => '',
54
- 'payment_gross' => '',
55
- 'ipn_track_id' => 'qXFPBOM1pjBuIydRsesfyQ',
56
- );
57
-
58
- public function __construct() {
59
- parent::__construct( 'PHP_Merchant_Paypal_IPN test cases' );
60
- require_once( PHP_MERCHANT_PATH . '/common/http-curl.php' );
61
- Mock::generate( 'PHP_Merchant_HTTP_CURL' );
62
- }
63
-
64
- public function test_correct_request_is_returned_to_IPN() {
65
- $live_url = 'https://www.paypal.com/cgi-bin/webscr';
66
- $sandbox_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
67
-
68
- $verify_request = array( 'cmd' => '_notify-validate' );
69
- $verify_request += $this->ipn_request;
70
-
71
- // expects to send to Live URL and receive "VERIFIED" message from Paypal
72
- $http = new MockPHP_Merchant_HTTP_CURL();
73
- $http->returns( 'post', 'VERIFIED' );
74
- $ipn = new PHP_Merchant_Paypal_IPN( $this->ipn_request, false, $http );
75
- $http->expectOnce( 'post', array( $live_url, $verify_request ) ); // make sure $verify_request is constructed correctly
76
- $this->assertTrue( $ipn->is_verified() );
77
-
78
- // expects to send to Sandbox URL and receive "INVALID" message from Paypal
79
- $http = new MockPHP_Merchant_HTTP_CURL();
80
- $http->returns( 'post', 'INVALID' );
81
- $ipn = new PHP_Merchant_Paypal_IPN( $this->ipn_request, true, $http );
82
- $http->expectOnce( 'post', array( $sandbox_url, $verify_request ) ); // make sure $verify_request is constructed correctly
83
- $this->assertFalse( $ipn->is_verified() );
84
- }
85
- }
86
-
87
- class PHP_Merchant_Paypal_IPN_Bogus extends PHP_Merchant_Paypal_IPN
88
- {
89
- public $http;
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal.php' );
4
-
5
- class PHP_Merchant_Paypal_Test extends UnitTestCase
6
- {
7
- private $bogus;
8
-
9
- public function __construct() {
10
- parent::__construct( 'PHP_Merchant_Paypal test cases' );
11
- }
12
-
13
- public function setUp() {
14
- $options = array(
15
- 'api_username' => 'sdk-three_api1.sdk.com',
16
- 'api_password' => 'QFZCWN5HZM8VBG7Q',
17
- 'api_signature' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
18
- );
19
- $this->bogus = new PHP_Merchant_Paypal_Bogus( $options );
20
- }
21
-
22
- public function test_api_credentials_are_properly_generated() {
23
- $params = array(
24
- 'USER' => 'sdk-three_api1.sdk.com',
25
- 'PWD' => 'QFZCWN5HZM8VBG7Q',
26
- 'VERSION' => '114.0',
27
- 'SIGNATURE' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
28
- );
29
- $this->assertEqual( $this->bogus->add_credentials(), $params );
30
- }
31
-
32
- public function test_check_whether_currency_is_supported_by_paypal() {
33
- $supported = array(
34
- 'AUD',
35
- 'BRL',
36
- 'CAD',
37
- 'CHF',
38
- 'CZK',
39
- 'DKK',
40
- 'EUR',
41
- 'GBP',
42
- 'HKD',
43
- 'HUF',
44
- 'ILS',
45
- 'JPY',
46
- 'MXN',
47
- 'MYR',
48
- 'NOK',
49
- 'NZD',
50
- 'PHP',
51
- 'PLN',
52
- 'SEK',
53
- 'SGD',
54
- 'THB',
55
- 'TWD',
56
- 'USD',
57
- );
58
-
59
- $this->assertEqual( $supported, PHP_Merchant_Paypal_Bogus::get_supported_currencies() );
60
-
61
- foreach ( $supported as $currency ) {
62
- $this->assertTrue( PHP_Merchant_Paypal_Bogus::is_currency_supported( $currency ) );
63
- }
64
-
65
- $this->assertFalse( PHP_Merchant_Paypal_Bogus::is_currency_supported( 'ZAR' ) );
66
- }
67
-
68
- public function test_build_request_function_correctly_handles_custom_request_array() {
69
- $additional_params = array(
70
- 'PAYMENTREQUEST_0_SHIPTONAME' => 'Gary Cao',
71
- 'PAYMENTREQUEST_0_SHIPTOSTREET' => '1 Infinite Loop',
72
- 'PAYMENTREQUEST_0_SHIPTOSTREET2' => 'Apple Headquarter',
73
- 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Cupertino',
74
- 'PAYMENTREQUEST_0_SHIPTOSTATE' => 'CA',
75
- 'PAYMENTREQUEST_0_SHIPTOZIP' => '95014',
76
- 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'USA',
77
- 'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '(877) 412-7753',
78
- );
79
-
80
- $full_param_list = array(
81
- 'USER' => 'sdk-three_api1.sdk.com',
82
- 'PWD' => 'QFZCWN5HZM8VBG7Q',
83
- 'VERSION' => '114.0',
84
- 'SIGNATURE' => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',
85
- 'METHOD' => 'SetExpressCheckout',
86
-
87
- 'PAYMENTREQUEST_0_SHIPTONAME' => 'Gary Cao',
88
- 'PAYMENTREQUEST_0_SHIPTOSTREET' => '1 Infinite Loop',
89
- 'PAYMENTREQUEST_0_SHIPTOSTREET2' => 'Apple Headquarter',
90
- 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Cupertino',
91
- 'PAYMENTREQUEST_0_SHIPTOSTATE' => 'CA',
92
- 'PAYMENTREQUEST_0_SHIPTOZIP' => '95014',
93
- 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'USA',
94
- 'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '(877) 412-7753',
95
- );
96
-
97
- $request = $this->bogus->build_request( 'SetExpressCheckout', $additional_params );
98
- $this->assertEqual( $request, $full_param_list );
99
- }
100
-
101
- public function test_get_url_returns_sandbox_url_when_in_test_mode() {
102
- $this->bogus->set_option( 'test', true );
103
- $this->assertEqual( $this->bogus->get_url(), 'https://api-3t.sandbox.paypal.com/nvp' );
104
- }
105
-
106
- public function test_get_url_returns_live_url_when_in_live_mode() {
107
- $this->assertEqual( $this->bogus->get_url(), 'https://api-3t.paypal.com/nvp' );
108
-
109
- $this->bogus->set_option( 'test', false );
110
- $this->assertEqual( $this->bogus->get_url(), 'https://api-3t.paypal.com/nvp' );
111
- }
112
- }
113
-
114
- class PHP_Merchant_Paypal_Bogus extends PHP_Merchant_Paypal
115
- {
116
- public $request = array();
117
-
118
- public function add_credentials() {
119
- return parent::add_credentials();
120
- }
121
-
122
- public function build_request( $action = '', $request = array() ) {
123
- return parent::build_request( $action, $request );
124
- }
125
-
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/index.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- // Check for Remote Tests
3
- global $remote;
4
- global $argv;
5
- $remote = false;
6
- if ( in_array( '--enable-remote', $argv ) || ! empty( $_GET['remote'] ) ) {
7
- $remote = true;
8
- }
9
- if ( $remote ) {
10
- require_once( 'simpletest/web_tester.php' );
11
- require_once( 'common/test-accounts.php' );
12
- }
13
-
14
- require_once( 'simpletest/varlog.php' );
15
- require_once( 'simpletest/autorun.php' );
16
-
17
- define( 'PHP_MERCHANT_PATH', realpath( '../' ) );
18
- define( 'PHP_MERCHANT_TEST_PATH', dirname( __FILE__ ) );
19
-
20
- class PHP_Merchant_Test_Suite extends TestSuite
21
- {
22
- function __construct() {
23
- global $remote;
24
- parent::__construct( 'PHP Merchant Test Suite' );
25
- $tests = array(
26
- 'common/php-merchant',
27
- 'common/http-curl',
28
- 'gateways/paypal',
29
- 'gateways/paypal-express-checkout',
30
- 'gateways/paypal-ipn',
31
- );
32
-
33
- // Since we are running the SimpleTest Tests from the command-line,
34
- // we are adding a command-line key for remote tests
35
- if ( $remote ) {
36
- $tests = array_merge( $tests, array(
37
- 'remote/http-curl',
38
- 'remote/paypal-express-checkout',
39
- 'remote/paypal-ec-cert-x1',
40
- 'remote/paypal-ec-cert-x2',
41
- 'remote/paypal-ec-cert-x3',
42
- 'remote/paypal-ec-cert-x4',
43
- 'remote/paypal-ec-cert-x5',
44
- 'remote/paypal-ec-cert-x6',
45
- 'remote/paypal-dg-cert-x1',
46
- 'remote/paypal-dg-cert-x2',
47
- 'remote/paypal-dg-cert-x3',
48
- 'remote/paypal-dg-cert-x4',
49
- 'remote/paypal-pro-cert-x1',
50
- 'remote/paypal-pro-cert-x2',
51
- ) );
52
- }
53
-
54
- $dir = dirname( __FILE__ );
55
-
56
- foreach ( $tests as $test ) {
57
- $this->addFile( $dir . '/' . $test . '.php' );
58
- }
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/http-curl.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/common/http-curl.php' );
4
-
5
- class PHP_Merchant_HTTP_CURL_Remote_Test extends WebTestCase
6
- {
7
- public function __construct() {
8
- parent::__construct( 'PHP_Merchant_HTTP_CURL Remote Unit Tests' );
9
- }
10
-
11
- public function test_http_curl_get_request_returns_correct_response() {
12
- $expected_content = "c7194f7e74fedaf84525235d3b37c203\n";
13
-
14
- $http = new PHP_Merchant_HTTP_CURL();
15
- $actual_content = $http->get( 'https://raw.githubusercontent.com/wp-e-commerce/Science-Repository/master/json' );
16
- $this->assertEqual( $expected_content, $actual_content );
17
- }
18
-
19
- public function test_http_curl_post_request_returns_correct_response() {
20
- $expected_content = "key_1 => value 1\ntest_another_key => value 2\n";
21
-
22
- $http = new PHP_Merchant_HTTP_CURL();
23
- $actual_content = $http->post( 'https://raw.githubusercontent.com/wp-e-commerce/Science-Repository/master/post', array(
24
- 'key 1' => 'value 1',
25
- 'test another key' => 'value 2',
26
- ) );
27
- $this->assertEqual( $expected_content, $actual_content );
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x1.php DELETED
@@ -1,317 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-digital-goods.php' );
4
-
5
- class PHP_Merchant_Paypal_Digital_Goods_Certification_Test_X1 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Digital_Goods test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Digital_Goods( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 1.01
80
- *
81
- * Standard Fields Test
82
- *
83
- * @return void
84
- * @since 3.9
85
- */
86
- public function test_setexpresscheckout_standard_ref101() {
87
- // Call SetExpressCheckout
88
- $options = is_array( $this->purchase_options ) ? $this->purchase_options : array();
89
- $response = $this->gateway->setup_purchase( $options, 'Sale' );
90
-
91
- $this->assertTrue( $response->is_successful() );
92
-
93
- // Display the transaction Id
94
- st_echo('Test Case 1.01: ' . $response->get( 'token' ) . "\n" );
95
- }
96
-
97
- /**
98
- * Test Case Reference 1.02
99
- *
100
- * No Shipping
101
- *
102
- * @return void
103
- * @since 3.9
104
- */
105
- public function test_setexpresscheckout_standard_ref102() {
106
- // Max Amount
107
- $this->purchase_options['no_shipping'] = true;
108
-
109
- // Call SetExpressCheckout
110
- $response = $this->gateway->setup_purchase( $this->purchase_options );
111
-
112
- $this->assertTrue( $response->is_successful() );
113
-
114
- // Display the transaction Id
115
- st_echo('Test Case 1.02: ' . $response->get( 'token' ) . "\n" );
116
- }
117
-
118
- /**
119
- * Test Case Reference 1.03
120
- *
121
- * @return void
122
- * @since 3.9
123
- */
124
- public function test_setexpresscheckout_standard_ref103() {
125
- // Shipping Details
126
- $this->purchase_options['shipping_address'] = array(
127
- 'name' => 'Abid Omar',
128
- 'street' => '',
129
- 'street2' => '',
130
- 'city' => 'Cupertino',
131
- 'state' => 'CA',
132
- 'country' => 'US',
133
- 'zip' => '95014',
134
- 'phone' => '(877) 412-7753',
135
- );
136
-
137
- // Call SetExpressCheckout
138
- $response = $this->gateway->setup_purchase( $this->purchase_options );
139
-
140
- $this->assertFalse( $response->is_successful() );
141
-
142
- // Display the transaction Id
143
- $error = $response->get_error();
144
- st_echo( 'Test Case 1.03: ' . $response->get( 'correlation_id' ) . ' - ' . $error['details'] . "\n" );
145
- }
146
-
147
- /**
148
- * Test Case Reference 1.04
149
- *
150
- * @return void
151
- * @since 3.9
152
- */
153
- public function test_setexpresscheckout_standard_ref104() {
154
- // Shipping Details
155
- $this->purchase_options['shipping_address'] = array(
156
- 'name' => 'Abid Omar',
157
- 'street' => '1 Infinite Loop',
158
- 'street2' => 'Apple Headquarter',
159
- 'city' => '',
160
- 'state' => 'CA',
161
- 'country' => 'US',
162
- 'zip' => '95014',
163
- 'phone' => '(877) 412-7753',
164
- );
165
-
166
- // Call SetExpressCheckout
167
- $response = $this->gateway->setup_purchase( $this->purchase_options );
168
-
169
- $this->assertFalse( $response->is_successful() );
170
-
171
- // Display the transaction Id
172
- $error = $response->get_error();
173
- st_echo( 'Test Case 1.04: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
174
- }
175
-
176
- /**
177
- * Test Case Reference 1.05
178
- *
179
- * @return void
180
- * @since 3.9
181
- */
182
- public function test_setexpresscheckout_standard_ref105() {
183
- // Shipping Details
184
- $this->purchase_options['shipping_address'] = array(
185
- 'name' => 'Abid Omar',
186
- 'street' => '1 Infinite Loop',
187
- 'street2' => 'Apple Headquarter',
188
- 'city' => 'Cupertino',
189
- 'state' => '',
190
- 'country' => 'US',
191
- 'zip' => '95014',
192
- 'phone' => '(877) 412-7753',
193
- );
194
-
195
- // Call SetExpressCheckout
196
- $response = $this->gateway->setup_purchase( $this->purchase_options );
197
-
198
- $this->assertFalse( $response->is_successful() );
199
-
200
- // Display the transaction Id
201
- $error = $response->get_error();
202
- st_echo( 'Test Case 1.05: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
203
- }
204
-
205
- /**
206
- * Test Case Reference 1.06
207
- *
208
- * @return void
209
- * @since 3.9
210
- */
211
- public function test_setexpresscheckout_standard_ref106() {
212
- // Shipping Details
213
- $this->purchase_options['shipping_address'] = array(
214
- 'name' => 'Abid Omar',
215
- 'street' => '1 Infinite Loop',
216
- 'street2' => 'Apple Headquarter',
217
- 'city' => 'Cupertino',
218
- 'state' => 'CA',
219
- 'country' => 'US',
220
- 'zip' => '',
221
- 'phone' => '(877) 412-7753',
222
- );
223
-
224
- // Call SetExpressCheckout
225
- $response = $this->gateway->setup_purchase( $this->purchase_options );
226
-
227
- $this->assertFalse( $response->is_successful() );
228
-
229
- // Display the transaction Id
230
- $error = $response->get_error();
231
- st_echo( 'Test Case 1.06: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
232
- }
233
-
234
- /**
235
- * Test Case Reference 1.07
236
- *
237
- * @return void
238
- * @since 3.9
239
- */
240
- public function test_setexpresscheckout_standard_ref107() {
241
- // Shipping Details
242
- $this->purchase_options['shipping_address'] = array(
243
- 'name' => 'Abid Omar',
244
- 'street' => '1 Infinite Loop',
245
- 'street2' => 'Apple Headquarter',
246
- 'city' => 'Cupertino',
247
- 'state' => 'CA',
248
- 'country' => '',
249
- 'zip' => '95014',
250
- 'phone' => '(877) 412-7753',
251
- );
252
-
253
- // Call SetExpressCheckout
254
- $response = $this->gateway->setup_purchase( $this->purchase_options );
255
-
256
- $this->assertFalse( $response->is_successful() );
257
-
258
- // Display the transaction Id
259
- $error = $response->get_error();
260
- st_echo( 'Test Case 1.07: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
261
- }
262
-
263
- /**
264
- * Test Case Reference 1.08
265
- *
266
- * @return void
267
- * @since 3.9
268
- */
269
- public function test_setexpresscheckout_standard_ref108() {
270
- // Shipping Details
271
- $this->purchase_options['shipping_address'] = array(
272
- 'name' => 'Abid Omar',
273
- 'street' => '123 Any Street',
274
- 'street2' => '',
275
- 'city' => 'New York',
276
- 'state' => 'NY',
277
- 'country' => 'US',
278
- 'zip' => '90210',
279
- 'phone' => '(877) 412-7753',
280
- );
281
-
282
- // Call SetExpressCheckout
283
- $response = $this->gateway->setup_purchase( $this->purchase_options );
284
-
285
- $this->assertFalse( $response->is_successful() );
286
-
287
- // Display the transaction Id
288
- $error = $response->get_error();
289
- st_echo( 'Test Case 1.08: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
290
- }
291
-
292
- /**
293
- * Test Case Reference 1.09
294
- *
295
- * @return void
296
- * @since 3.9
297
- */
298
- public function test_setexpresscheckout_standard_ref109() {
299
- // Negative Testing
300
- $this->purchase_options['subtotal'] = 100.01;
301
- $this->purchase_options['shipping'] = 0;
302
- $this->purchase_options['tax'] = 0;
303
- $this->purchase_options['amount'] = 100.01;
304
- $this->purchase_options['max_amount'] = 100.01;
305
- $this->purchase_options['items'] = array();
306
-
307
- // Call SetExpressCheckout
308
- $response = $this->gateway->setup_purchase( $this->purchase_options );
309
-
310
- $this->assertFalse( $response->is_successful() );
311
-
312
- // Display the transaction Id
313
- $error = $response->get_error();
314
- st_echo( 'Test Case 1.09: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
315
- }
316
-
317
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x2.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-digital-goods.php' );
4
-
5
- class PHP_Merchant_Paypal_Digital_Goods_Certification_Test_X2 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Digital_Goods test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Digital_Goods( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 2.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref21() {
85
- // Using the Token and Payer Id for another transaction
86
- $token = 'EC-9HN89702CD731133X';
87
-
88
- // Call DoExpressCheckout
89
- $response = $this->gateway->get_details_for( $token );
90
-
91
- $this->assertTrue( $response->is_successful() );
92
-
93
- // Display the Transaction Id
94
- st_echo( 'Test Case 2.1: ' . $response->get( 'correlation_id' ) . "\n" );
95
- }
96
-
97
- /**
98
- * Test Case Reference 2.2
99
- *
100
- * @return void
101
- * @since 3.9
102
- */
103
- public function test_doexpresscheckout_ref22() {
104
- // Using the Token and Payer Id for another transaction
105
- $transaction_id = '10001';
106
-
107
- // Call DoExpressCheckout
108
- $response = $this->gateway->get_transaction_details( $transaction_id );
109
-
110
- $this->assertFalse( $response->is_successful() );
111
-
112
- // Display the Transaction Id
113
- st_echo( 'Test Case 2.2: ' . $response->get( 'correlation_id' ) . "\n" );
114
- }
115
-
116
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x3.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-digital-goods.php' );
4
-
5
- class PHP_Merchant_Paypal_Digital_Goods_Certification_Test_X3 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Digital_Goods( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 3.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref31() {
85
- // Using the Token and Payer Id for another transaction
86
- $this->purchase_options['token'] = 'EC-3W674134AM197213K';
87
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
88
-
89
- // Call DoExpressCheckout
90
- $response = $this->gateway->purchase( $this->purchase_options );
91
-
92
- $this->assertTrue( $response->is_successful() );
93
-
94
- // Display the Transaction Id
95
- st_echo( 'Test Case 3.1: ' . $response->get( 'transaction_id' ) . "\n" );
96
- st_echo( 'Test Case 3.2: ' . $response->get( 'transaction_id' ) . "\n" );
97
-
98
- }
99
-
100
- /**
101
- * Test Case Reference 3.3
102
- *
103
- * @return void
104
- * @since 3.9
105
- */
106
- public function test_doexpresscheckout_ref33() {
107
- // Negative Testing
108
- $this->purchase_options['subtotal'] = 100.01;
109
- $this->purchase_options['shipping'] = 0;
110
- $this->purchase_options['tax'] = 0;
111
- $this->purchase_options['amount'] = 100.01;
112
- $this->purchase_options['max_amount'] = 100.01;
113
- $this->purchase_options['items'] = array();
114
-
115
- // Using the Token and Payer Id for another transaction
116
- $this->purchase_options['token'] = 'EC-3W674134AM197213K';
117
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
118
-
119
- // Call DoExpressCheckout
120
- $response = $this->gateway->purchase( $this->purchase_options );
121
-
122
- $this->assertFalse( $response->is_successful() );
123
-
124
- // Display the Transaction Id
125
- st_echo( 'Test Case 3.3: ' . $response->get( 'correlation_id' ) . "\n" );
126
- }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x4.php DELETED
@@ -1,163 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-digital-goods.php' );
4
-
5
- class PHP_Merchant_Paypal_Digital_Goods_Certification_Test_X4 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Digital_Goods test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- /*
27
- 'amount' => 15.337,
28
- 'subtotal' => 13.700,
29
- 'shipping' => 1.500,
30
- 'tax' => 0.137,
31
- */
32
- 'description' => 'A sample order',
33
- 'invoice' => $inv,
34
- 'notify_url' => 'http://example.com/ipn',
35
-
36
- // Items
37
- 'items' => array(
38
- array(
39
- 'name' => 'Gold Cart Plugin',
40
- 'description' => 'Gold Cart extends your WP e-Commerce store by enabling additional features and functionality.',
41
- 'amount' => 4,
42
- 'quantity' => 1,
43
- 'tax' => 0.040,
44
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
45
- 'number' => '7A12343-WHT-XL',
46
- ),
47
- array(
48
- 'name' => 'Member Access Plugin',
49
- 'description' => 'Create pay to view subscription sites',
50
- 'amount' => 5,
51
- 'quantity' => 1,
52
- 'tax' => 0.05,
53
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
54
- 'number' => '7A12344-WHT-XL',
55
- ),
56
- array(
57
- 'name' => 'Amazon S3',
58
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP e-Commerce site to be hosted within Amazon S3.',
59
- 'amount' => 4.7,
60
- 'quantity' => 1,
61
- 'tax' => 0.047,
62
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
63
- 'number' => '7A12345-WHT-XL',
64
- ),
65
- ),
66
- );
67
- }
68
-
69
- public function setUp() {
70
- global $test_accounts;
71
- $this->gateway = new PHP_Merchant_Paypal_Digital_Goods( $test_accounts['paypal-ec-oa'] );
72
- $this->purchase_options = $this->default_options;
73
- }
74
-
75
-
76
- public function tearDown() {
77
- $this->purchase_options = null;
78
- }
79
-
80
- /**
81
- * Test Case Reference 4.1
82
- *
83
- * @return void
84
- * @since 3.9
85
- */
86
- public function test_doexpresscheckout_ref41() {
87
- /*
88
- $this->purchase_options['token'] = 'EC-6YT23592N88199745';
89
- $this->purchase_options['message_id'] = 'abcedfght';
90
- $this->purchase_options['invoice'] = 'E84A90G811';
91
- $this->purchase_options['transaction_id'] = '91E227400G099735F';
92
-
93
- $response = $this->gateway->credit( $this->purchase_options );
94
- $this->assertTrue( $response->is_successful() );
95
- st_log( $response );
96
- */
97
-
98
- // Fully Refunded Transaction
99
- $response = $this->gateway->get_transaction_details( '91E227400G099735F' );
100
-
101
- $this->assertTrue( $response->is_successful() );
102
- st_echo( 'Test Case 4.1:' . "\n" );
103
- st_echo( 'Transaction ID: 91E227400G099735F' . "\n" );
104
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
105
- }
106
-
107
- /**
108
- * Test Case Reference 4.2
109
- *
110
- * @return void
111
- * @since 3.9
112
- */
113
- public function test_doexpresscheckout_ref42() {
114
- /*
115
- $this->purchase_options['token'] = 'EC-8AU95879WD9646218';
116
- $this->purchase_options['message_id'] = 'abcedfghkk';
117
- $this->purchase_options['invoice'] = 'E84A90G555';
118
- $this->purchase_options['transaction_id'] = '2WH811268W276704P';
119
- $this->purchase_options['refund_type'] = 'partial';
120
- $this->purchase_options['amount'] = 6.5;
121
-
122
- // Call DoExpressCheckout 8P404440G06461422
123
- $response = $this->gateway->credit( $this->purchase_options );
124
-
125
-
126
- $this->assertTrue( $response->is_successful() );
127
- st_log( $response );
128
- */
129
-
130
- // Fully Refunded Transaction
131
- $response = $this->gateway->get_transaction_details( '2WH811268W276704P' );
132
-
133
- $this->assertTrue( $response->is_successful() );
134
- st_echo( 'Test Case 4.2:' . "\n" );
135
- st_echo( 'Transaction ID: 2WH811268W276704P' . "\n" );
136
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
137
- }
138
-
139
- /**
140
- * Test Case Reference 4.3
141
- *
142
- * @return void
143
- * @since 3.9
144
- */
145
- public function test_doexpresscheckout_ref43() {
146
- $this->purchase_options['token'] = 'EC-8AU95879WD9646218';
147
- $this->purchase_options['message_id'] = 'abcedfghkk';
148
- $this->purchase_options['invoice'] = 'E84A90G555';
149
- $this->purchase_options['transaction_id'] = '2WH811268W276704P';
150
- $this->purchase_options['amount'] = 100.01;
151
-
152
- // Call DoRefund
153
- $response = $this->gateway->credit( $this->purchase_options );
154
-
155
- $this->assertFalse( $response->is_successful() );
156
-
157
- // Display the Transaction Id
158
- st_echo( 'Test Case 4.3: ' . $response->get( 'correlation_id' ) . "\n" );
159
-
160
-
161
- }
162
-
163
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x1.php DELETED
@@ -1,403 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Certification_Test_X1 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 1.01
80
- *
81
- * Standard Fields Test
82
- *
83
- * @return void
84
- * @since 3.9
85
- */
86
- public function test_setexpresscheckout_standard_ref101() {
87
- // Call SetExpressCheckout
88
- $options = is_array( $this->purchase_options ) ? $this->purchase_options : array();
89
- $response = $this->gateway->setup_purchase( $options );
90
-
91
- $this->assertTrue( $response->is_successful() );
92
-
93
- // Display the transaction Id
94
- st_echo('Test Case 1.01: ' . $response->get( 'token' ) . "\n" );
95
- }
96
-
97
- /**
98
- * Test Case Reference 1.02
99
- *
100
- * @return void
101
- * @since 3.9
102
- */
103
- public function test_setexpresscheckout_standard_ref102() {
104
- // Shipping Details
105
- $this->purchase_options['shipping_address'] = array(
106
- 'name' => 'Abid Omar',
107
- 'street' => '1 Infinite Loop',
108
- 'street2' => 'Apple Headquarter ext',
109
- 'city' => 'Cupertino',
110
- 'state' => 'CA',
111
- 'country' => 'US',
112
- 'zip' => '95014',
113
- 'phone' => '(877) 412-7753',
114
- );
115
-
116
- // Call SetExpressCheckout
117
- $response = $this->gateway->setup_purchase( $this->purchase_options );
118
-
119
- $this->assertTrue( $response->is_successful() );
120
-
121
- // Display the transaction Id
122
- st_echo('Test Case 1.02: ' . $response->get( 'token' ) . "\n" );
123
- }
124
-
125
- /**
126
- * Test Case Reference 1.03
127
- *
128
- * @return void
129
- * @since 3.9
130
- */
131
- public function test_setexpresscheckout_standard_ref103() {
132
- // Max Amount
133
- $this->purchase_options['max_amount'] = 15.9;
134
- $this->purchase_options['solution_type'] = 'Mark';
135
-
136
- // Call SetExpressCheckout
137
- $response = $this->gateway->setup_purchase( $this->purchase_options );
138
-
139
- $this->assertTrue( $response->is_successful() );
140
-
141
- // Display the transaction Id
142
- st_echo('Test Case 1.03: ' . $response->get( 'token' ) . "\n" );
143
-
144
- }
145
-
146
- /**
147
- * Test Case Reference 1.04
148
- *
149
- * @return void
150
- * @since 3.9
151
- */
152
- public function test_setexpresscheckout_standard_ref104() {
153
- // Max Amount
154
- $this->purchase_options['max_amount'] = 15.9;
155
- $this->purchase_options['solution_type'] = 'Sole';
156
-
157
- // Call SetExpressCheckout
158
- $response = $this->gateway->setup_purchase( $this->purchase_options );
159
-
160
- $this->assertTrue( $response->is_successful() );
161
-
162
- // Display the transaction Id
163
- st_echo('Test Case 1.04: ' . $response->get( 'token' ) . "\n" );
164
- }
165
-
166
- /**
167
- * Test Case Reference 1.05
168
- *
169
- * @return void
170
- * @since 3.9
171
- */
172
- public function test_setexpresscheckout_standard_ref105() {
173
- // Max Amount
174
- $this->purchase_options['no_shipping'] = true;
175
-
176
- // Call SetExpressCheckout
177
- $response = $this->gateway->setup_purchase( $this->purchase_options );
178
-
179
- $this->assertTrue( $response->is_successful() );
180
-
181
- // Display the transaction Id
182
- st_echo('Test Case 1.05: ' . $response->get( 'token' ) . "\n" );
183
- }
184
-
185
- /**
186
- * Test Case Reference 1.06
187
- *
188
- * @return void
189
- * @since 3.9
190
- */
191
- public function test_setexpresscheckout_standard_ref106() {
192
- // Billing Agreement description
193
- $this->purchase_options['billing_type'] = 'MerchantInitiatedBillingSingleAgreement';
194
- $this->purchase_options['billing_description'] = 'One Time Payment';
195
-
196
- // Call SetExpressCheckout
197
- $response = $this->gateway->setup_purchase( $this->purchase_options );
198
-
199
- $this->assertTrue( $response->is_successful() );
200
-
201
- // Display the transaction Id
202
- st_echo('Test Case 1.06: ' . $response->get( 'token' ) . "\n" );
203
- }
204
-
205
- /**
206
- * Test Case Reference 1.08
207
- *
208
- * @return void
209
- * @since 3.9
210
- */
211
- public function test_setexpresscheckout_standard_ref108() {
212
- // Shipping Details
213
- $this->purchase_options['shipping_address'] = array(
214
- 'name' => 'Abid Omar',
215
- 'street' => '',
216
- 'street2' => '',
217
- 'city' => 'Cupertino',
218
- 'state' => 'CA',
219
- 'country' => 'US',
220
- 'zip' => '95014',
221
- 'phone' => '(877) 412-7753',
222
- );
223
-
224
- // Call SetExpressCheckout
225
- $response = $this->gateway->setup_purchase( $this->purchase_options );
226
-
227
- $this->assertFalse( $response->is_successful() );
228
-
229
- // Display the transaction Id
230
- $error = $response->get_error();
231
- st_echo( 'Test Case 1.08: ' . $response->get( 'correlation_id' ) . ' - ' . $error['details'] . "\n" );
232
- }
233
-
234
- /**
235
- * Test Case Reference 1.09
236
- *
237
- * @return void
238
- * @since 3.9
239
- */
240
- public function test_setexpresscheckout_standard_ref109() {
241
- // Shipping Details
242
- $this->purchase_options['shipping_address'] = array(
243
- 'name' => 'Abid Omar',
244
- 'street' => '1 Infinite Loop',
245
- 'street2' => 'Apple Headquarter',
246
- 'city' => '',
247
- 'state' => 'CA',
248
- 'country' => 'US',
249
- 'zip' => '95014',
250
- 'phone' => '(877) 412-7753',
251
- );
252
-
253
- // Call SetExpressCheckout
254
- $response = $this->gateway->setup_purchase( $this->purchase_options );
255
-
256
- $this->assertFalse( $response->is_successful() );
257
-
258
- // Display the transaction Id
259
- $error = $response->get_error();
260
- st_echo( 'Test Case 1.09: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
261
- }
262
-
263
- /**
264
- * Test Case Reference 1.10
265
- *
266
- * @return void
267
- * @since 3.9
268
- */
269
- public function test_setexpresscheckout_standard_ref110() {
270
- // Shipping Details
271
- $this->purchase_options['shipping_address'] = array(
272
- 'name' => 'Abid Omar',
273
- 'street' => '1 Infinite Loop',
274
- 'street2' => 'Apple Headquarter',
275
- 'city' => 'Cupertino',
276
- 'state' => '',
277
- 'country' => 'US',
278
- 'zip' => '95014',
279
- 'phone' => '(877) 412-7753',
280
- );
281
-
282
- // Call SetExpressCheckout
283
- $response = $this->gateway->setup_purchase( $this->purchase_options );
284
-
285
- $this->assertFalse( $response->is_successful() );
286
-
287
- // Display the transaction Id
288
- $error = $response->get_error();
289
- st_echo( 'Test Case 1.10: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
290
- }
291
-
292
- /**
293
- * Test Case Reference 1.11
294
- *
295
- * @return void
296
- * @since 3.9
297
- */
298
- public function test_setexpresscheckout_standard_ref111() {
299
- // Shipping Details
300
- $this->purchase_options['shipping_address'] = array(
301
- 'name' => 'Abid Omar',
302
- 'street' => '1 Infinite Loop',
303
- 'street2' => 'Apple Headquarter',
304
- 'city' => 'Cupertino',
305
- 'state' => 'CA',
306
- 'country' => 'US',
307
- 'zip' => '',
308
- 'phone' => '(877) 412-7753',
309
- );
310
-
311
- // Call SetExpressCheckout
312
- $response = $this->gateway->setup_purchase( $this->purchase_options );
313
-
314
- $this->assertFalse( $response->is_successful() );
315
-
316
- // Display the transaction Id
317
- $error = $response->get_error();
318
- st_echo( 'Test Case 1.11: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
319
- }
320
-
321
- /**
322
- * Test Case Reference 1.12
323
- *
324
- * @return void
325
- * @since 3.9
326
- */
327
- public function test_setexpresscheckout_standard_ref112() {
328
- // Shipping Details
329
- $this->purchase_options['shipping_address'] = array(
330
- 'name' => 'Abid Omar',
331
- 'street' => '1 Infinite Loop',
332
- 'street2' => 'Apple Headquarter',
333
- 'city' => 'Cupertino',
334
- 'state' => 'CA',
335
- 'country' => '',
336
- 'zip' => '95014',
337
- 'phone' => '(877) 412-7753',
338
- );
339
-
340
- // Call SetExpressCheckout
341
- $response = $this->gateway->setup_purchase( $this->purchase_options );
342
-
343
- $this->assertFalse( $response->is_successful() );
344
-
345
- // Display the transaction Id
346
- $error = $response->get_error();
347
- st_echo( 'Test Case 1.12: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
348
- }
349
-
350
- /**
351
- * Test Case Reference 1.13
352
- *
353
- * @return void
354
- * @since 3.9
355
- */
356
- public function test_setexpresscheckout_standard_ref113() {
357
- // Shipping Details
358
- $this->purchase_options['shipping_address'] = array(
359
- 'name' => 'Abid Omar',
360
- 'street' => '123 Any Street',
361
- 'street2' => '',
362
- 'city' => 'New York',
363
- 'state' => 'NY',
364
- 'country' => 'US',
365
- 'zip' => '90210',
366
- 'phone' => '(877) 412-7753',
367
- );
368
-
369
- // Call SetExpressCheckout
370
- $response = $this->gateway->setup_purchase( $this->purchase_options );
371
-
372
- $this->assertFalse( $response->is_successful() );
373
-
374
- // Display the transaction Id
375
- $error = $response->get_error();
376
- st_echo( 'Test Case 1.13: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
377
- }
378
-
379
- /**
380
- * Test Case Reference 1.14
381
- *
382
- * @return void
383
- * @since 3.9
384
- */
385
- public function test_setexpresscheckout_standard_ref114() {
386
- // Negative Testing
387
- $this->purchase_options['subtotal'] = 100.01;
388
- $this->purchase_options['shipping'] = 0;
389
- $this->purchase_options['tax'] = 0;
390
- $this->purchase_options['amount'] = 100.01;
391
- $this->purchase_options['max_amount'] = 100.01;
392
- $this->purchase_options['items'] = array();
393
-
394
- // Call SetExpressCheckout
395
- $response = $this->gateway->setup_purchase( $this->purchase_options );
396
-
397
- $this->assertFalse( $response->is_successful() );
398
-
399
- // Display the transaction Id
400
- $error = $response->get_error();
401
- st_echo( 'Test Case 1.14: ' . $response->get( 'correlation_id' ) . ' - '. $error['details'] . "\n" );
402
- }
403
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x2.php DELETED
@@ -1,186 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Certification_Test_X2 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 2.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref21() {
85
- // Using the Token and Payer Id for another transaction
86
- $this->purchase_options['token'] = 'EC-2LX41209SH738634B';
87
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
88
-
89
- // Call DoExpressCheckout
90
- $response = $this->gateway->purchase( $this->purchase_options );
91
-
92
- $this->assertTrue( $response->is_successful() );
93
-
94
- // Display the Transaction Id
95
- st_echo( 'Test Case 2.1: ' . $response->get( 'transaction_id' ) . "\n" );
96
- }
97
-
98
- /**
99
- * Test Case Reference 2.2
100
- *
101
- * @return void
102
- * @since 3.9
103
- */
104
- public function test_doexpresscheckout_ref22() {
105
- // Using the Token and Payer Id for another transaction
106
- $this->purchase_options['token'] = 'EC-5T412084S27270248';
107
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
108
-
109
- // Call DoExpressCheckout
110
- $response = $this->gateway->purchase( $this->purchase_options, 'Authorization' );
111
-
112
- $this->assertTrue( $response->is_successful() );
113
-
114
- // Display the Transaction Id
115
- st_echo( 'Test Case 2.2: ' . $response->get( 'transaction_id' ) . "\n" );
116
- }
117
-
118
- /**
119
- * Test Case Reference 2.3
120
- *
121
- * @return void
122
- * @since 3.9
123
- */
124
- public function test_doexpresscheckout_ref23() {
125
- // Using the Token and Payer Id for another transaction
126
- $this->purchase_options['token'] = 'EC-94S08582T02646945';
127
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
128
-
129
- // Call DoExpressCheckout
130
- $response = $this->gateway->purchase( $this->purchase_options, 'Order' );
131
-
132
- $this->assertTrue( $response->is_successful() );
133
-
134
- // Display the Transaction Id
135
- st_echo( 'Test Case 2.3: ' . $response->get( 'transaction_id' ) . "\n" );
136
- }
137
-
138
- /**
139
- * Test Case Reference 2.4
140
- *
141
- * @return void
142
- * @since 3.9
143
- */
144
- public function test_doexpresscheckout_ref24() {
145
- // Using the Token and Payer Id for another transaction
146
- $this->purchase_options['token'] = 'EC-2A077123HD2136914';
147
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
148
-
149
- // Call DoExpressCheckout
150
- $this->purchase_options['no_shipping'] = 1;
151
- $response = $this->gateway->purchase( $this->purchase_options );
152
-
153
- $this->assertTrue( $response->is_successful() );
154
-
155
- // Display the Transaction Id
156
- st_echo( 'Test Case 2.4: ' . $response->get( 'transaction_id' ) . "\n" );
157
- }
158
-
159
- /**
160
- * Test Case Reference 2.5
161
- *
162
- * @return void
163
- * @since 3.9
164
- */
165
- public function test_doexpresscheckout_ref25() {
166
- // Negative Testing
167
- $this->purchase_options['subtotal'] = 100.01;
168
- $this->purchase_options['shipping'] = 0;
169
- $this->purchase_options['tax'] = 0;
170
- $this->purchase_options['amount'] = 100.01;
171
- $this->purchase_options['max_amount'] = 100.01;
172
- $this->purchase_options['items'] = array();
173
-
174
- // Using the Token and Payer Id for another transaction
175
- $this->purchase_options['token'] = 'EC-04C181866P316870M';
176
- $this->purchase_options['payer_id'] = 'FQQ7Q9EVPAB86';
177
-
178
- // Call DoExpressCheckout
179
- $response = $this->gateway->purchase( $this->purchase_options );
180
-
181
- $this->assertFalse( $response->is_successful() );
182
-
183
- // Display the Transaction Id
184
- st_echo( 'Test Case 2.5: ' . $response->get( 'correlation_id' ) . "\n" );
185
- }
186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x3.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Certification_Test_X3 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 3.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref31() {
85
-
86
- }
87
-
88
- /**
89
- * Test Case Reference 3.2
90
- *
91
- * @return void
92
- * @since 3.9
93
- */
94
- public function test_doexpresscheckout_ref32() {
95
-
96
- }
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x4.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Certification_Test_X4 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 4.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref41() {
85
- $this->purchase_options['complete_type'] = 'NotComplete';
86
- $this->purchase_options['amount'] = 10;
87
- $this->purchase_options['authorization_id'] = '3AU5391768007820J';
88
-
89
- $response = $this->gateway->capture( $this->purchase_options );
90
-
91
- $this->assertTrue( $response->is_successful() );
92
-
93
- // Display the Transaction Id
94
- st_echo('Test Case 4.1: ' . $response->get( 'transaction_id' ) . "\n" );
95
- }
96
-
97
- /**
98
- * Test Case Reference 4.2
99
- *
100
- * @return void
101
- * @since 3.9
102
- */
103
- public function test_doexpresscheckout_ref42() {
104
- $this->purchase_options['complete_type'] = 'Complete';
105
- $this->purchase_options['amount'] = 15.34;
106
- $this->purchase_options['authorization_id'] = 'O-79124340AV3470941';
107
-
108
- $response = $this->gateway->capture( $this->purchase_options );
109
-
110
- $this->assertTrue( $response->is_successful() );
111
-
112
- // Display the Transaction Id
113
- st_echo('Test Case 4.2: ' . $response->get( 'transaction_id' ) . "\n" );
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x5.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Certification_Test_X5 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP e-Commerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP e-Commerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 5.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref51() {
85
- // Fully Refunded Transaction
86
- $response = $this->gateway->get_transaction_details( '0SH96542L88249424' );
87
-
88
- $this->assertTrue( $response->is_successful() );
89
- st_echo( 'Test Case 5.1:' . "\n" );
90
- st_echo( 'Transaction ID: 0SH96542L88249424' . "\n" );
91
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
92
- }
93
-
94
- /**
95
- * Test Case Reference 5.2
96
- *
97
- * @return void
98
- * @since 3.9
99
- */
100
- public function test_doexpresscheckout_ref52() {
101
- // Fully Refunded Transaction
102
- $response = $this->gateway->get_transaction_details( '29585298U7589982T' );
103
-
104
- $this->assertTrue( $response->is_successful() );
105
- st_echo( 'Test Case 5.2:' . "\n" );
106
- st_echo( 'Transaction ID: 29585298U7589982T' . "\n" );
107
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
108
- }
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x6.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Certification_Test_X6 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout test cases' );
14
- // Generate an invoice number
15
- $inv = 'E84A90G' . mt_rand( 100, 999);
16
-
17
- // Common Options
18
- $this->default_options = array(
19
- // API info
20
- 'return_url' => 'http://example.com/return',
21
- 'cancel_url' => 'http://example.com/cancel',
22
- 'address_override' => 1,
23
-
24
- // Payment info
25
- 'currency' => 'USD',
26
- 'amount' => 15.337,
27
- 'subtotal' => 13.700,
28
- 'shipping' => 1.500,
29
- 'tax' => 0.137,
30
- 'description' => 'A sample order',
31
- 'invoice' => $inv,
32
- 'notify_url' => 'http://example.com/ipn',
33
-
34
- // Items
35
- 'items' => array(
36
- array(
37
- 'name' => 'Gold Cart Plugin',
38
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
39
- 'amount' => 4,
40
- 'quantity' => 1,
41
- 'tax' => 0.040,
42
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
43
- 'number' => '7A12343-WHT-XL',
44
- ),
45
- array(
46
- 'name' => 'Member Access Plugin',
47
- 'description' => 'Create pay to view subscription sites',
48
- 'amount' => 5,
49
- 'quantity' => 1,
50
- 'tax' => 0.05,
51
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
52
- 'number' => '7A12344-WHT-XL',
53
- ),
54
- array(
55
- 'name' => 'Amazon S3',
56
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
57
- 'amount' => 4.7,
58
- 'quantity' => 1,
59
- 'tax' => 0.047,
60
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
61
- 'number' => '7A12345-WHT-XL',
62
- ),
63
- ),
64
- );
65
- }
66
-
67
- public function setUp() {
68
- global $test_accounts;
69
- $this->gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-ec-oa'] );
70
- $this->purchase_options = $this->default_options;
71
- }
72
-
73
-
74
- public function tearDown() {
75
- $this->purchase_options = null;
76
- }
77
-
78
- /**
79
- * Test Case Reference 6.1
80
- *
81
- * @return void
82
- * @since 3.9
83
- */
84
- public function test_doexpresscheckout_ref61() {
85
- // Cancelled Transaction
86
- $response = $this->gateway->get_transaction_details( 'O-0CJ689879E5247331' );
87
-
88
- $this->assertTrue( $response->is_successful() );
89
- st_echo( 'Test Case 6.1:' . "\n" );
90
- st_echo( 'Transaction ID: O-0CJ689879E5247331' . "\n" );
91
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-express-checkout.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-express-checkout.php' );
4
-
5
- class PHP_Merchant_Paypal_Express_Checkout_Remote_Test extends WebTestCase
6
- {
7
- private $response;
8
-
9
- public function __construct() {
10
- parent::__construct( 'PHP_Merchant_Paypal_Express_Checkout Remote Unit Tests' );
11
- }
12
-
13
- public function test_successful_set_express_checkout_request() {
14
- global $test_accounts;
15
- $gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-express-checkout'] );
16
-
17
- $purchase_options = array(
18
- // API info
19
- 'return_url' => 'http://example.com/return',
20
- 'cancel_url' => 'http://example.com/cancel',
21
- 'address_override' => true,
22
-
23
- // Shipping details
24
- 'shipping_address' => array(
25
- 'name' => 'Gary Cao',
26
- 'street' => '1 Infinite Loop',
27
- 'street2' => 'Apple Headquarter',
28
- 'city' => 'Cupertino',
29
- 'state' => 'CA',
30
- 'country' => 'US',
31
- 'zip' => '95014',
32
- 'phone' => '(877) 412-7753',
33
- ),
34
-
35
- // Payment info
36
- 'currency' => 'JPY',
37
- 'subtotal' => 13700,
38
- 'shipping' => 1500,
39
- 'tax' => 137,
40
- 'amount' => 15337,
41
- 'description' => 'Order for example.com',
42
- 'invoice' => 'E84A90G94',
43
- 'notify_url' => 'http://example.com/ipn',
44
-
45
- // Items
46
- 'items' => array(
47
- array(
48
- 'name' => 'Gold Cart Plugin',
49
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
50
- 'amount' => 4000,
51
- 'quantity' => 1,
52
- 'tax' => 40,
53
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
54
- ),
55
- array(
56
- 'name' => 'Member Access Plugin',
57
- 'description' => 'Create pay to view subscription sites',
58
- 'amount' => 5000,
59
- 'quantity' => 1,
60
- 'tax' => 50,
61
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
62
- ),
63
- array(
64
- 'name' => 'Amazon S3',
65
- 'description' => 'This Plugin allows downloadable products on your WP eCommerce site to be hosted on Amazon S3.',
66
- 'amount' => 4700,
67
- 'quantity' => 1,
68
- 'tax' => 47,
69
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
70
- ),
71
- ),
72
- );
73
-
74
- $this->response = $response = $gateway->setup_purchase( $purchase_options );
75
- $this->token = $response->get( 'token' );
76
- $this->timestamp = $response->get( 'timestamp' );
77
- $this->datetime = $response->get( 'datetime' );
78
- $this->correlation_id = $response->get( 'correlation_id' );
79
- $this->version = $response->get( 'version' );
80
- $this->build = $response->get( 'build' );
81
- $this->assertTrue( $response->is_successful() );
82
- $this->assertFalse( $response->has_errors() );
83
- }
84
-
85
- public function test_successful_get_express_checkout_request() {
86
- global $test_accounts;
87
-
88
- // This is required to fill the response property
89
- $this->test_successful_set_express_checkout_request();
90
-
91
- $gateway = new PHP_Merchant_Paypal_Express_Checkout( $test_accounts['paypal-express-checkout'] );
92
-
93
- $response = $gateway->get_details_for( $this->response->get( 'token' ) );
94
-
95
- $this->assertTrue( $response->is_successful() );
96
- $this->assertFalse( $response->has_errors() );
97
-
98
- // API Info
99
- $this->assertTrue( $response->is_checkout_not_initiated() );
100
- $this->assertFalse( $response->is_checkout_failed() );
101
- $this->assertFalse( $response->is_checkout_in_progress() );
102
- $this->assertFalse( $response->is_checkout_completed() );
103
- $this->assertEqual( $response->get( 'checkout_status' ), 'Not-Initiated' );
104
- $this->assertEqual( $response->get( 'token' ), $this->response->get( 'token' ) );
105
- $this->assertEqual( $response->get( 'version' ), $this->response->get( 'version' ) );
106
- $this->assertEqual( $response->get( 'build' ), $this->response->get( 'build' ) );
107
-
108
- // Payment Information
109
- $this->assertEqual( $response->get( 'currency' ), 'JPY' );
110
- $this->assertEqual( $response->get( 'amount' ), 15337 );
111
- $this->assertEqual( $response->get( 'subtotal' ), 13700 );
112
- $this->assertEqual( $response->get( 'shipping' ), 1500 );
113
- $this->assertEqual( $response->get( 'handling' ), 0 );
114
- $this->assertEqual( $response->get( 'tax' ), 137 );
115
- $this->assertEqual( $response->get( 'invoice' ), 'E84A90G94' );
116
- $this->assertEqual( $response->get( 'notify_url' ), 'http://example.com/ipn' );
117
- $this->assertEqual( $response->get( 'shipping_discount' ), 0 );
118
-
119
- // Item Information
120
- $items = $response->get( 'items' );
121
- $mock_items = array();
122
-
123
- $mock_items[0] = new stdClass();
124
- $mock_items[0]->name = 'Gold Cart Plugin';
125
- $mock_items[0]->description = 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.';
126
- $mock_items[0]->amount = 4000;
127
- $mock_items[0]->quantity = 1;
128
- $mock_items[0]->tax = 40;
129
-
130
- $mock_items[1] = new stdClass();
131
- $mock_items[1]->name = 'Member Access Plugin';
132
- $mock_items[1]->description = 'Create pay to view subscription sites';
133
- $mock_items[1]->amount = 5000;
134
- $mock_items[1]->quantity = 1;
135
- $mock_items[1]->tax = 50;
136
-
137
- $mock_items[2] = new stdClass();
138
- $mock_items[2]->name = 'Amazon S3';
139
- $mock_items[2]->description = 'This Plugin allows downloadable products on your WP eCommerce site to be hosted on Amazon S3.';
140
- $mock_items[2]->amount = 4700;
141
- $mock_items[2]->quantity = 1;
142
- $mock_items[2]->tax = 47;
143
-
144
- $this->assertEqual( $items, $mock_items );
145
- }
146
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-pro-cert-x1.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-pro.php' );
3
-
4
- class PHP_Merchant_Paypal_Pro_Certification_Test_X1 extends UnitTestCase
5
- {
6
- private $gateway;
7
- private $token;
8
- private $default_options;
9
- private $purchase_options;
10
-
11
- public function __construct() {
12
- parent::__construct( 'PHP_Merchant_Paypal_Pro test cases' );
13
- // Generate an invoice number
14
- $inv = 'E84A90G' . mt_rand( 100, 999);
15
-
16
- // Common Options
17
- $this->default_options = array(
18
- 'paymentaction' => 'sale',
19
- 'template' => 'templateD',
20
- 'vendor' => 'wpp@omarabid.com',
21
-
22
- // API info
23
- 'return_url' => 'http://example.com/return',
24
- 'cancel_url' => 'http://example.com/cancel',
25
- 'address_override' => 1,
26
-
27
- // Payment info
28
- 'currency' => 'USD',
29
- 'amount' => 15.337,
30
- 'subtotal' => 13.700,
31
- 'shipping' => 1.500,
32
- 'tax' => 0.137,
33
- 'description' => 'A sample order',
34
- 'invoice' => $inv,
35
- 'notify_url' => 'http://example.com/ipn',
36
- 'shipping_address' => array(
37
- 'name' => 'Abid Omar',
38
- 'street' => '1 Infinite Loop',
39
- 'street2' => 'Apple Headquarter ext',
40
- 'city' => 'Cupertino',
41
- 'state' => 'CA',
42
- 'country' => 'US',
43
- 'zip' => '95014',
44
- 'phone' => '(877) 412-7753',
45
- ),
46
- // Items
47
- 'items' => array(
48
- array(
49
- 'name' => 'Gold Cart Plugin',
50
- 'description' => 'Gold Cart extends your WP eCommerce store by enabling additional features and functionality.',
51
- 'amount' => 4,
52
- 'quantity' => 1,
53
- 'tax' => 0.040,
54
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/',
55
- 'number' => '7A12343-WHT-XL',
56
- ),
57
- array(
58
- 'name' => 'Member Access Plugin',
59
- 'description' => 'Create pay to view subscription sites',
60
- 'amount' => 5,
61
- 'quantity' => 1,
62
- 'tax' => 0.05,
63
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/member-access-plugin/',
64
- 'number' => '7A12344-WHT-XL',
65
- ),
66
- array(
67
- 'name' => 'Amazon S3',
68
- 'description' => 'This Plugin allows downloadable products that you have for sale on your WP eCommerce site to be hosted within Amazon S3.',
69
- 'amount' => 4.7,
70
- 'quantity' => 1,
71
- 'tax' => 0.047,
72
- 'url' => 'http://getshopped.org/extend/premium-upgrades/premium-upgrades/amazon-s3-plugin/',
73
- 'number' => '7A12345-WHT-XL',
74
- ),
75
- ),
76
- );
77
- }
78
-
79
- public function setUp() {
80
- global $test_accounts;
81
- $this->gateway = new PHP_Merchant_Paypal_Pro( $test_accounts['paypal-pro-oa'] );
82
- $this->purchase_options = $this->default_options;
83
- }
84
-
85
-
86
- public function tearDown() {
87
- $this->purchase_options = null;
88
- }
89
-
90
- /**
91
- * Test Case Reference A.6.1
92
- *
93
- * Standard Fields Test
94
- *
95
- * @return void
96
- * @since 3.9
97
- */
98
- public function test_setexpresscheckout_standard_refA61() {
99
- // Call CreateButtom
100
- $options = is_array( $this->purchase_options ) ? $this->purchase_options : array();
101
- $response = $this->gateway->createButton( $options );
102
-
103
- $this->assertTrue( $response->is_successful() );
104
-
105
- // Display the correlation Id
106
- st_echo('Test Case A.6.1: ' . $response->get( 'correlation_id' ) . "\n" );
107
- }
108
-
109
- /**
110
- * Test Case Reference A.6.2
111
- *
112
- * Standard Fields Test
113
- *
114
- * @return void
115
- * @since 3.9
116
- */
117
- public function test_setexpresscheckout_standard_refA62() {
118
- // Call CreateButtom
119
- $options = is_array( $this->purchase_options ) ? $this->purchase_options : array();
120
-
121
- // Set Billing information
122
- $options['billing_address'] = array(
123
- 'name' => 'Abid Omar',
124
- 'street' => '1 Infinite Loop',
125
- 'street2' => 'Apple Headquarter ext',
126
- 'city' => 'Cupertino',
127
- 'state' => 'CA',
128
- 'country' => 'US',
129
- 'zip' => '95014',
130
- 'phone' => '(877) 412-7753',
131
- );
132
-
133
- $response = $this->gateway->createButton( $options );
134
-
135
- $this->assertTrue( $response->is_successful() );
136
-
137
- // Display the correlation Id
138
- st_echo('Test Case A.6.2: ' . $response->get( 'correlation_id' ) . "\n" );
139
- }
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-pro-cert-x2.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
-
3
- require_once( PHP_MERCHANT_PATH . '/gateways/paypal-pro.php' );
4
-
5
- class PHP_Merchant_Paypal_Pro_Certification_Test_X2 extends UnitTestCase
6
- {
7
- private $gateway;
8
- private $token;
9
- private $default_options;
10
- private $purchase_options;
11
-
12
- public function __construct() {
13
- parent::__construct( 'PHP_Merchant_Paypal_Pro test cases' );
14
- $this->default_options = array();
15
- }
16
-
17
- public function setUp() {
18
- global $test_accounts;
19
- $this->gateway = new PHP_Merchant_Paypal_Pro( $test_accounts['paypal-pro-oa'] );
20
- $this->purchase_options = $this->default_options;
21
- }
22
-
23
-
24
- public function tearDown() {
25
- $this->purchase_options = null;
26
- }
27
-
28
- /**
29
- * Test Case Reference A.1.1
30
- *
31
- * @return void
32
- * @since 3.9
33
- */
34
- public function test_paypalpro_refA11() {
35
- // Fully Refunded Transaction
36
- $response = $this->gateway->get_transaction_details( '57T574999A4979400' );
37
-
38
- $this->assertTrue( $response->is_successful() );
39
- st_echo( 'Test Case A1.1:' . "\n" );
40
- st_echo( 'Transaction ID: 57T574999A4979400' . "\n" );
41
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
42
- }
43
-
44
- /**
45
- * Test Case Reference A.1.2
46
- *
47
- * @return void
48
- * @since 3.9
49
- */
50
- public function test_paypalpro_refA12() {
51
- // Partially Refunded Transaction
52
- $response = $this->gateway->get_transaction_details( '6XD74563HX9353102' );
53
-
54
- $this->assertTrue( $response->is_successful() );
55
- st_echo( 'Test Case A1.2:' . "\n" );
56
- st_echo( 'Transaction ID: 6XD74563HX9353102' . "\n" );
57
- st_echo( 'Payment Status: ' . $response->get_params()['PAYMENTSTATUS'] . "\n" );
58
- }
59
-
60
- /**
61
- * Test Case Reference A.1.3
62
- *
63
- * @return void
64
- * @since 3.9
65
- */
66
- public function test_paypalpro_refA13() {
67
- // Negative Test
68
- $this->purchase_options['message_id'] = '';
69
- $this->purchase_options['transaction_id'] = '1MC14541JJ0533214';
70
- $this->purchase_options['invoice'] = '2';
71
- $this->purchase_options['refund_type'] = 'partial';
72
- $this->purchase_options['amount'] = '100.01';
73
-
74
- $response = $this->gateway->credit( $this->purchase_options );
75
-
76
- $this->assertFalse( $response->is_successful() );
77
-
78
- st_echo( 'Test Case A1.3:' . "\n" );
79
- st_echo( 'Correlation ID: ' . $response->get_params()['CORRELATIONID'] . "\n" );
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE DELETED
@@ -1,399 +0,0 @@
1
- Simple Test interface changes
2
- =============================
3
- Because the SimpleTest tool set is still evolving it is likely that tests
4
- written with earlier versions will fail with the newest ones. The most
5
- dramatic changes are in the alpha releases. Here is a list of possible
6
- problems and their fixes...
7
-
8
- assertText() no longer finds a string inside a <script> tag
9
- -----------------------------------------------------------
10
- The assertText() method is intended to match only visible,
11
- human-readable text on the web page. Therefore, the contents of script
12
- tags should not be matched by this assertion. However there was a bug
13
- in the text normalisation code of simpletest which meant that <script>
14
- tags spanning multiple lines would not have their content stripped
15
- out. If you want to check the content of a <script> tag, use
16
- assertPattern(), or write a custom expectation.
17
-
18
- Overloaded method not working
19
- -----------------------------
20
- All protected and private methods had underscores
21
- removed. This means that any private/protected methods that
22
- you overloaded with those names need to be updated.
23
-
24
- Fatal error: Call to undefined method Classname::classname()
25
- ------------------------------------------------------------
26
- SimpleTest renamed all of its constructors from
27
- Classname to __construct; derived classes invoking
28
- their parent constructors should replace parent::Classname()
29
- with parent::__construct().
30
-
31
- Custom CSS in HtmlReporter not being applied
32
- --------------------------------------------
33
- Batch rename of protected and private methods
34
- means that _getCss() was renamed to getCss().
35
- Please rename your method and it should work again.
36
-
37
- setReturnReference() throws errors in E_STRICT
38
- ----------------------------------------------
39
- Happens when an object is passed by reference.
40
- This also happens with setReturnReferenceAt().
41
- If you want to return objects then replace these
42
- with calls to returns() and returnsAt() with the
43
- same arguments. This change was forced in the 1.1
44
- version for E_STRICT compatibility.
45
-
46
- assertReference() throws errors in E_STRICT
47
- -------------------------------------------
48
- Due to language restrictions you cannot compare
49
- both variables and objects in E_STRICT mode. Use
50
- assertSame() in this mode with objects. This change
51
- was forced the 1.1 version.
52
-
53
- Cannot create GroupTest
54
- -----------------------
55
- The GroupTest has been renamed TestSuite (see below).
56
- It was removed completely in 1.1 in favour of this
57
- name.
58
-
59
- No method getRelativeUrls() or getAbsoluteUrls()
60
- ------------------------------------------------
61
- These methods were always a bit weird anyway, and
62
- the new parsing of the base tag makes them more so.
63
- They have been replaced with getUrls() instead. If
64
- you want the old functionality then simply chop
65
- off the current domain from getUrls().
66
-
67
- Method setWildcard() removed in mocks
68
- -------------------------------------
69
- Even setWildcard() has been removed in 1.0.1beta now.
70
- If you want to test explicitely for a '*' string, then
71
- simply pass in new IdenticalExpectation('*') instead.
72
-
73
- No method _getTest() on mocks
74
- -----------------------------
75
- This has finally been removed. It was a pretty esoteric
76
- flex point anyway. It was there to allow the mocks to
77
- work with other test tools, but no one does this.
78
-
79
- No method assertError(), assertNoErrors(), swallowErrors()
80
- ----------------------------------------------------------
81
- These have been deprecated in 1.0.1beta in favour of
82
- expectError() and expectException(). assertNoErrors() is
83
- redundant if you use expectError() as failures are now reported
84
- immediately.
85
-
86
- No method TestCase::signal()
87
- ----------------------------
88
- This has been deprecated in favour of triggering an error or
89
- throwing an exception. Deprecated as of 1.0.1beta.
90
-
91
- No method TestCase::sendMessage()
92
- ---------------------------------
93
- This has been deprecated as of 1.0.1beta.
94
-
95
- Failure to connect now emits failures
96
- -------------------------------------
97
- It used to be that you would have to use the
98
- getTransferError() call on the web tester to see if
99
- there was a socket level error in a fetch. This check
100
- is now always carried out by the WebTestCase unless
101
- the fetch is prefaced with WebTestCase::ignoreErrors().
102
- The ignore directive only lasts for the next fetching
103
- action such as get() and click().
104
-
105
- No method SimpleTestOptions::ignore()
106
- -------------------------------------
107
- This is deprecated in version 1.0.1beta and has been moved
108
- to SimpleTest::ignore() as that is more readable. In
109
- addition, parent classes are also ignored automatically.
110
- If you are using PHP5 you can skip this directive simply
111
- by marking your test case as abstract.
112
-
113
- No method assertCopy()
114
- ----------------------
115
- This is deprecated in 1.0.1 in favour of assertClone().
116
- The assertClone() method is slightly different in that
117
- the objects must be identical, but without being a
118
- reference. It is thus not a strict inversion of
119
- assertReference().
120
-
121
- Constructor wildcard override has no effect in mocks
122
- ----------------------------------------------------
123
- As of 1.0.1beta this is now set with setWildcard() instead
124
- of in the constructor.
125
-
126
- No methods setStubBaseClass()/getStubBaseClass()
127
- ------------------------------------------------
128
- As mocks are now used instead of stubs, these methods
129
- stopped working and are now removed as of the 1.0.1beta
130
- release. The mock objects may be freely used instead.
131
-
132
- No method addPartialMockCode()
133
- ------------------------------
134
- The ability to insert arbitrary partial mock code
135
- has been removed. This was a low value feature
136
- causing needless complications. It was removed
137
- in the 1.0.1beta release.
138
-
139
- No method setMockBaseClass()
140
- ----------------------------
141
- The ability to change the mock base class has been
142
- scheduled for removal and is deprecated since the
143
- 1.0.1beta version. This was a rarely used feature
144
- except as a workaround for PHP5 limitations. As
145
- these limitations are being resolved it's hoped
146
- that the bundled mocks can be used directly.
147
-
148
- No class Stub
149
- -------------
150
- Server stubs are deprecated from 1.0.1 as the mocks now
151
- have exactly the same interface. Just use mock objects
152
- instead.
153
-
154
- No class SimpleTestOptions
155
- --------------------------
156
- This was replced by the shorter SimpleTest in 1.0.1beta1
157
- and is since deprecated.
158
-
159
- No file simple_test.php
160
- -----------------------
161
- This was renamed test_case.php in 1.0.1beta to more accurately
162
- reflect it's purpose. This file should never be directly
163
- included in test suites though, as it's part of the
164
- underlying mechanics and has a tendency to be refactored.
165
-
166
- No class WantedPatternExpectation
167
- ---------------------------------
168
- This was deprecated in 1.0.1alpha in favour of the simpler
169
- name PatternExpectation.
170
-
171
- No class NoUnwantedPatternExpectation
172
- -------------------------------------
173
- This was deprecated in 1.0.1alpha in favour of the simpler
174
- name NoPatternExpectation.
175
-
176
- No method assertNoUnwantedPattern()
177
- -----------------------------------
178
- This has been renamed to assertNoPattern() in 1.0.1alpha and
179
- the old form is deprecated.
180
-
181
- No method assertWantedPattern()
182
- -------------------------------
183
- This has been renamed to assertPattern() in 1.0.1alpha and
184
- the old form is deprecated.
185
-
186
- No method assertExpectation()
187
- -----------------------------
188
- This was renamed as assert() in 1.0.1alpha and the old form
189
- has been deprecated.
190
-
191
- No class WildcardExpectation
192
- ----------------------------
193
- This was a mostly internal class for the mock objects. It was
194
- renamed AnythingExpectation to bring it closer to JMock and
195
- NMock in version 1.0.1alpha.
196
-
197
- Missing UnitTestCase::assertErrorPattern()
198
- ------------------------------------------
199
- This method is deprecated for version 1.0.1 onwards.
200
- This method has been subsumed by assertError() that can now
201
- take an expectation. Simply pass a PatternExpectation
202
- into assertError() to simulate the old behaviour.
203
-
204
- No HTML when matching page elements
205
- -----------------------------------
206
- This behaviour has been switched to using plain text as if it
207
- were seen by the user of the browser. This means that HTML tags
208
- are suppressed, entities are converted and whitespace is
209
- normalised. This should make it easier to match items in forms.
210
- Also images are replaced with their "alt" text so that they
211
- can be matched as well.
212
-
213
- No method SimpleRunner::_getTestCase()
214
- --------------------------------------
215
- This was made public as getTestCase() in 1.0RC2.
216
-
217
- No method restartSession()
218
- --------------------------
219
- This was renamed to restart() in the WebTestCase, SimpleBrowser
220
- and the underlying SimpleUserAgent in 1.0RC2. Because it was
221
- undocumented anyway, no attempt was made at backward
222
- compatibility.
223
-
224
- My custom test case ignored by tally()
225
- --------------------------------------
226
- The _assertTrue method has had it's signature changed due to a bug
227
- in the PHP 5.0.1 release. You must now use getTest() from within
228
- that method to get the test case. Mock compatibility with other
229
- unit testers is now deprecated as of 1.0.1alpha as PEAR::PHPUnit2
230
- should soon have mock support of it's own.
231
-
232
- Broken code extending SimpleRunner
233
- ----------------------------------
234
- This was replaced with SimpleScorer so that I could use the runner
235
- name in another class. This happened in RC1 development and there
236
- is no easy backward compatibility fix. The solution is simply to
237
- extend SimpleScorer instead.
238
-
239
- Missing method getBaseCookieValue()
240
- -----------------------------------
241
- This was renamed getCurrentCookieValue() in RC1.
242
-
243
- Missing files from the SimpleTest suite
244
- ---------------------------------------
245
- Versions of SimpleTest prior to Beta6 required a SIMPLE_TEST constant
246
- to point at the SimpleTest folder location before any of the toolset
247
- was loaded. This is no longer documented as it is now unnecessary
248
- for later versions. If you are using an earlier version you may
249
- need this constant. Consult the documentation that was bundled with
250
- the release that you are using or upgrade to Beta6 or later.
251
-
252
- No method SimpleBrowser::getCurrentUrl()
253
- --------------------------------------
254
- This is replaced with the more versatile showRequest() for
255
- debugging. It only existed in this context for version Beta5.
256
- Later versions will have SimpleBrowser::getHistory() for tracking
257
- paths through pages. It is renamed as getUrl() since 1.0RC1.
258
-
259
- No method Stub::setStubBaseClass()
260
- ----------------------------------
261
- This method has finally been removed in 1.0RC1. Use
262
- SimpleTestOptions::setStubBaseClass() instead.
263
-
264
- No class CommandLineReporter
265
- ----------------------------
266
- This was renamed to TextReporter in Beta3 and the deprecated version
267
- was removed in 1.0RC1.
268
-
269
- No method requireReturn()
270
- -------------------------
271
- This was deprecated in Beta3 and is now removed.
272
-
273
- No method expectCookie()
274
- ------------------------
275
- This method was abruptly removed in Beta4 so as to simplify the internals
276
- until another mechanism can replace it. As a workaround it is necessary
277
- to assert that the cookie has changed by setting it before the page
278
- fetch and then assert the desired value.
279
-
280
- No method clickSubmitByFormId()
281
- -------------------------------
282
- This method had an incorrect name as no button was involved. It was
283
- renamed to submitByFormId() in Beta4 and the old version deprecated.
284
- Now removed.
285
-
286
- No method paintStart() or paintEnd()
287
- ------------------------------------
288
- You should only get this error if you have subclassed the lower level
289
- reporting and test runner machinery. These methods have been broken
290
- down into events for test methods, events for test cases and events
291
- for group tests. The new methods are...
292
-
293
- paintStart() --> paintMethodStart(), paintCaseStart(), paintGroupStart()
294
- paintEnd() --> paintMethodEnd(), paintCaseEnd(), paintGroupEnd()
295
-
296
- This change was made in Beta3, ironically to make it easier to subclass
297
- the inner machinery. Simply duplicating the code you had in the previous
298
- methods should provide a temporary fix.
299
-
300
- No class TestDisplay
301
- --------------------
302
- This has been folded into SimpleReporter in Beta3 and is now deprecated.
303
- It was removed in RC1.
304
-
305
- No method WebTestCase::fetch()
306
- ------------------------------
307
- This was renamed get() in Alpha8. It is removed in Beta3.
308
-
309
- No method submit()
310
- ------------------
311
- This has been renamed clickSubmit() in Beta1. The old method was
312
- removed in Beta2.
313
-
314
- No method clearHistory()
315
- ------------------------
316
- This method is deprecated in Beta2 and removed in RC1.
317
-
318
- No method getCallCount()
319
- ------------------------
320
- This method has been deprecated since Beta1 and has now been
321
- removed. There are now more ways to set expectations on counts
322
- and so this method should be unecessery. Removed in RC1.
323
-
324
- Cannot find file *
325
- ------------------
326
- The following public name changes have occoured...
327
-
328
- simple_html_test.php --> reporter.php
329
- simple_mock.php --> mock_objects.php
330
- simple_unit.php --> unit_tester.php
331
- simple_web.php --> web_tester.php
332
-
333
- The old names were deprecated in Alpha8 and removed in Beta1.
334
-
335
- No method attachObserver()
336
- --------------------------
337
- Prior to the Alpha8 release the old internal observer pattern was
338
- gutted and replaced with a visitor. This is to trade flexibility of
339
- test case expansion against the ease of writing user interfaces.
340
-
341
- Code such as...
342
-
343
- $test = &new MyTestCase();
344
- $test->attachObserver(new TestHtmlDisplay());
345
- $test->run();
346
-
347
- ...should be rewritten as...
348
-
349
- $test = &new MyTestCase();
350
- $test->run(new HtmlReporter());
351
-
352
- If you previously attached multiple observers then the workaround
353
- is to run the tests twice, once with each, until they can be combined.
354
- For one observer the old method is simulated in Alpha 8, but is
355
- removed in Beta1.
356
-
357
- No class TestHtmlDisplay
358
- ------------------------
359
- This class has been renamed to HtmlReporter in Alpha8. It is supported,
360
- but deprecated in Beta1 and removed in Beta2. If you have subclassed
361
- the display for your own design, then you will have to extend this
362
- class (HtmlReporter) instead.
363
-
364
- If you have accessed the event queue by overriding the notify() method
365
- then I am afraid you are in big trouble :(. The reporter is now
366
- carried around the test suite by the runner classes and the methods
367
- called directly. In the unlikely event that this is a problem and
368
- you don't want to upgrade the test tool then simplest is to write your
369
- own runner class and invoke the tests with...
370
-
371
- $test->accept(new MyRunner(new MyReporter()));
372
-
373
- ...rather than the run method. This should be easier to extend
374
- anyway and gives much more control. Even this method is overhauled
375
- in Beta3 where the runner class can be set within the test case. Really
376
- the best thing to do is to upgrade to this version as whatever you were
377
- trying to achieve before should now be very much easier.
378
-
379
- Missing set options method
380
- --------------------------
381
- All test suite options are now in one class called SimpleTestOptions.
382
- This means that options are set differently...
383
-
384
- GroupTest::ignore() --> SimpleTestOptions::ignore()
385
- Mock::setMockBaseClass() --> SimpleTestOptions::setMockBaseClass()
386
-
387
- These changed in Alpha8 and the old versions are now removed in RC1.
388
-
389
- No method setExpected*()
390
- ------------------------
391
- The mock expectations changed their names in Alpha4 and the old names
392
- ceased to be supported in Alpha8. The changes are...
393
-
394
- setExpectedArguments() --> expectArguments()
395
- setExpectedArgumentsSequence() --> expectArgumentsAt()
396
- setExpectedCallCount() --> expectCallCount()
397
- setMaximumCallCount() --> expectMaximumCallCount()
398
-
399
- The parameters remained the same.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/LICENSE DELETED
@@ -1,502 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 2.1, February 1999
3
-
4
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
- Everyone is permitted to copy and distribute verbatim copies
7
- of this license document, but changing it is not allowed.
8
-
9
- [This is the first released version of the Lesser GPL. It also counts
10
- as the successor of the GNU Library Public License, version 2, hence
11
- the version number 2.1.]
12
-
13
- Preamble
14
-
15
- The licenses for most software are designed to take away your
16
- freedom to share and change it. By contrast, the GNU General Public
17
- Licenses are intended to guarantee your freedom to share and change
18
- free software--to make sure the software is free for all its users.
19
-
20
- This license, the Lesser General Public License, applies to some
21
- specially designated software packages--typically libraries--of the
22
- Free Software Foundation and other authors who decide to use it. You
23
- can use it too, but we suggest you first think carefully about whether
24
- this license or the ordinary General Public License is the better
25
- strategy to use in any particular case, based on the explanations below.
26
-
27
- When we speak of free software, we are referring to freedom of use,
28
- not price. Our General Public Licenses are designed to make sure that
29
- you have the freedom to distribute copies of free software (and charge
30
- for this service if you wish); that you receive source code or can get
31
- it if you want it; that you can change the software and use pieces of
32
- it in new free programs; and that you are informed that you can do
33
- these things.
34
-
35
- To protect your rights, we need to make restrictions that forbid
36
- distributors to deny you these rights or to ask you to surrender these
37
- rights. These restrictions translate to certain responsibilities for
38
- you if you distribute copies of the library or if you modify it.
39
-
40
- For example, if you distribute copies of the library, whether gratis
41
- or for a fee, you must give the recipients all the rights that we gave
42
- you. You must make sure that they, too, receive or can get the source
43
- code. If you link other code with the library, you must provide
44
- complete object files to the recipients, so that they can relink them
45
- with the library after making changes to the library and recompiling
46
- it. And you must show them these terms so they know their rights.
47
-
48
- We protect your rights with a two-step method: (1) we copyright the
49
- library, and (2) we offer you this license, which gives you legal
50
- permission to copy, distribute and/or modify the library.
51
-
52
- To protect each distributor, we want to make it very clear that
53
- there is no warranty for the free library. Also, if the library is
54
- modified by someone else and passed on, the recipients should know
55
- that what they have is not the original version, so that the original
56
- author's reputation will not be affected by problems that might be
57
- introduced by others.
58
-
59
- Finally, software patents pose a constant threat to the existence of
60
- any free program. We wish to make sure that a company cannot
61
- effectively restrict the users of a free program by obtaining a
62
- restrictive license from a patent holder. Therefore, we insist that
63
- any patent license obtained for a version of the library must be
64
- consistent with the full freedom of use specified in this license.
65
-
66
- Most GNU software, including some libraries, is covered by the
67
- ordinary GNU General Public License. This license, the GNU Lesser
68
- General Public License, applies to certain designated libraries, and
69
- is quite different from the ordinary General Public License. We use
70
- this license for certain libraries in order to permit linking those
71
- libraries into non-free programs.
72
-
73
- When a program is linked with a library, whether statically or using
74
- a shared library, the combination of the two is legally speaking a
75
- combined work, a derivative of the original library. The ordinary
76
- General Public License therefore permits such linking only if the
77
- entire combination fits its criteria of freedom. The Lesser General
78
- Public License permits more lax criteria for linking other code with
79
- the library.
80
-
81
- We call this license the "Lesser" General Public License because it
82
- does Less to protect the user's freedom than the ordinary General
83
- Public License. It also provides other free software developers Less
84
- of an advantage over competing non-free programs. These disadvantages
85
- are the reason we use the ordinary General Public License for many
86
- libraries. However, the Lesser license provides advantages in certain
87
- special circumstances.
88
-
89
- For example, on rare occasions, there may be a special need to
90
- encourage the widest possible use of a certain library, so that it becomes
91
- a de-facto standard. To achieve this, non-free programs must be
92
- allowed to use the library. A more frequent case is that a free
93
- library does the same job as widely used non-free libraries. In this
94
- case, there is little to gain by limiting the free library to free
95
- software only, so we use the Lesser General Public License.
96
-
97
- In other cases, permission to use a particular library in non-free
98
- programs enables a greater number of people to use a large body of
99
- free software. For example, permission to use the GNU C Library in
100
- non-free programs enables many more people to use the whole GNU
101
- operating system, as well as its variant, the GNU/Linux operating
102
- system.
103
-
104
- Although the Lesser General Public License is Less protective of the
105
- users' freedom, it does ensure that the user of a program that is
106
- linked with the Library has the freedom and the wherewithal to run
107
- that program using a modified version of the Library.
108
-
109
- The precise terms and conditions for copying, distribution and
110
- modification follow. Pay close attention to the difference between a
111
- "work based on the library" and a "work that uses the library". The
112
- former contains code derived from the library, whereas the latter must
113
- be combined with the library in order to run.
114
-
115
- GNU LESSER GENERAL PUBLIC LICENSE
116
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
-
118
- 0. This License Agreement applies to any software library or other
119
- program which contains a notice placed by the copyright holder or
120
- other authorized party saying it may be distributed under the terms of
121
- this Lesser General Public License (also called "this License").
122
- Each licensee is addressed as "you".
123
-
124
- A "library" means a collection of software functions and/or data
125
- prepared so as to be conveniently linked with application programs
126
- (which use some of those functions and data) to form executables.
127
-
128
- The "Library", below, refers to any such software library or work
129
- which has been distributed under these terms. A "work based on the
130
- Library" means either the Library or any derivative work under
131
- copyright law: that is to say, a work containing the Library or a
132
- portion of it, either verbatim or with modifications and/or translated
133
- straightforwardly into another language. (Hereinafter, translation is
134
- included without limitation in the term "modification".)
135
-
136
- "Source code" for a work means the preferred form of the work for
137
- making modifications to it. For a library, complete source code means
138
- all the source code for all modules it contains, plus any associated
139
- interface definition files, plus the scripts used to control compilation
140
- and installation of the library.
141
-
142
- Activities other than copying, distribution and modification are not
143
- covered by this License; they are outside its scope. The act of
144
- running a program using the Library is not restricted, and output from
145
- such a program is covered only if its contents constitute a work based
146
- on the Library (independent of the use of the Library in a tool for
147
- writing it). Whether that is true depends on what the Library does
148
- and what the program that uses the Library does.
149
-
150
- 1. You may copy and distribute verbatim copies of the Library's
151
- complete source code as you receive it, in any medium, provided that
152
- you conspicuously and appropriately publish on each copy an
153
- appropriate copyright notice and disclaimer of warranty; keep intact
154
- all the notices that refer to this License and to the absence of any
155
- warranty; and distribute a copy of this License along with the
156
- Library.
157
-
158
- You may charge a fee for the physical act of transferring a copy,
159
- and you may at your option offer warranty protection in exchange for a
160
- fee.
161
-
162
- 2. You may modify your copy or copies of the Library or any portion
163
- of it, thus forming a work based on the Library, and copy and
164
- distribute such modifications or work under the terms of Section 1
165
- above, provided that you also meet all of these conditions:
166
-
167
- a) The modified work must itself be a software library.
168
-
169
- b) You must cause the files modified to carry prominent notices
170
- stating that you changed the files and the date of any change.
171
-
172
- c) You must cause the whole of the work to be licensed at no
173
- charge to all third parties under the terms of this License.
174
-
175
- d) If a facility in the modified Library refers to a function or a
176
- table of data to be supplied by an application program that uses
177
- the facility, other than as an argument passed when the facility
178
- is invoked, then you must make a good faith effort to ensure that,
179
- in the event an application does not supply such function or
180
- table, the facility still operates, and performs whatever part of
181
- its purpose remains meaningful.
182
-
183
- (For example, a function in a library to compute square roots has
184
- a purpose that is entirely well-defined independent of the
185
- application. Therefore, Subsection 2d requires that any
186
- application-supplied function or table used by this function must
187
- be optional: if the application does not supply it, the square
188
- root function must still compute square roots.)
189
-
190
- These requirements apply to the modified work as a whole. If
191
- identifiable sections of that work are not derived from the Library,
192
- and can be reasonably considered independent and separate works in
193
- themselves, then this License, and its terms, do not apply to those
194
- sections when you distribute them as separate works. But when you
195
- distribute the same sections as part of a whole which is a work based
196
- on the Library, the distribution of the whole must be on the terms of
197
- this License, whose permissions for other licensees extend to the
198
- entire whole, and thus to each and every part regardless of who wrote
199
- it.
200
-
201
- Thus, it is not the intent of this section to claim rights or contest
202
- your rights to work written entirely by you; rather, the intent is to
203
- exercise the right to control the distribution of derivative or
204
- collective works based on the Library.
205
-
206
- In addition, mere aggregation of another work not based on the Library
207
- with the Library (or with a work based on the Library) on a volume of
208
- a storage or distribution medium does not bring the other work under
209
- the scope of this License.
210
-
211
- 3. You may opt to apply the terms of the ordinary GNU General Public
212
- License instead of this License to a given copy of the Library. To do
213
- this, you must alter all the notices that refer to this License, so
214
- that they refer to the ordinary GNU General Public License, version 2,
215
- instead of to this License. (If a newer version than version 2 of the
216
- ordinary GNU General Public License has appeared, then you can specify
217
- that version instead if you wish.) Do not make any other change in
218
- these notices.
219
-
220
- Once this change is made in a given copy, it is irreversible for
221
- that copy, so the ordinary GNU General Public License applies to all
222
- subsequent copies and derivative works made from that copy.
223
-
224
- This option is useful when you wish to copy part of the code of
225
- the Library into a program that is not a library.
226
-
227
- 4. You may copy and distribute the Library (or a portion or
228
- derivative of it, under Section 2) in object code or executable form
229
- under the terms of Sections 1 and 2 above provided that you accompany
230
- it with the complete corresponding machine-readable source code, which
231
- must be distributed under the terms of Sections 1 and 2 above on a
232
- medium customarily used for software interchange.
233
-
234
- If distribution of object code is made by offering access to copy
235
- from a designated place, then offering equivalent access to copy the
236
- source code from the same place satisfies the requirement to
237
- distribute the source code, even though third parties are not
238
- compelled to copy the source along with the object code.
239
-
240
- 5. A program that contains no derivative of any portion of the
241
- Library, but is designed to work with the Library by being compiled or
242
- linked with it, is called a "work that uses the Library". Such a
243
- work, in isolation, is not a derivative work of the Library, and
244
- therefore falls outside the scope of this License.
245
-
246
- However, linking a "work that uses the Library" with the Library
247
- creates an executable that is a derivative of the Library (because it
248
- contains portions of the Library), rather than a "work that uses the
249
- library". The executable is therefore covered by this License.
250
- Section 6 states terms for distribution of such executables.
251
-
252
- When a "work that uses the Library" uses material from a header file
253
- that is part of the Library, the object code for the work may be a
254
- derivative work of the Library even though the source code is not.
255
- Whether this is true is especially significant if the work can be
256
- linked without the Library, or if the work is itself a library. The
257
- threshold for this to be true is not precisely defined by law.
258
-
259
- If such an object file uses only numerical parameters, data
260
- structure layouts and accessors, and small macros and small inline
261
- functions (ten lines or less in length), then the use of the object
262
- file is unrestricted, regardless of whether it is legally a derivative
263
- work. (Executables containing this object code plus portions of the
264
- Library will still fall under Section 6.)
265
-
266
- Otherwise, if the work is a derivative of the Library, you may
267
- distribute the object code for the work under the terms of Section 6.
268
- Any executables containing that work also fall under Section 6,
269
- whether or not they are linked directly with the Library itself.
270
-
271
- 6. As an exception to the Sections above, you may also combine or
272
- link a "work that uses the Library" with the Library to produce a
273
- work containing portions of the Library, and distribute that work
274
- under terms of your choice, provided that the terms permit
275
- modification of the work for the customer's own use and reverse
276
- engineering for debugging such modifications.
277
-
278
- You must give prominent notice with each copy of the work that the
279
- Library is used in it and that the Library and its use are covered by
280
- this License. You must supply a copy of this License. If the work
281
- during execution displays copyright notices, you must include the
282
- copyright notice for the Library among them, as well as a reference
283
- directing the user to the copy of this License. Also, you must do one
284
- of these things:
285
-
286
- a) Accompany the work with the complete corresponding
287
- machine-readable source code for the Library including whatever
288
- changes were used in the work (which must be distributed under
289
- Sections 1 and 2 above); and, if the work is an executable linked
290
- with the Library, with the complete machine-readable "work that
291
- uses the Library", as object code and/or source code, so that the
292
- user can modify the Library and then relink to produce a modified
293
- executable containing the modified Library. (It is understood
294
- that the user who changes the contents of definitions files in the
295
- Library will not necessarily be able to recompile the application
296
- to use the modified definitions.)
297
-
298
- b) Use a suitable shared library mechanism for linking with the
299
- Library. A suitable mechanism is one that (1) uses at run time a
300
- copy of the library already present on the user's computer system,
301
- rather than copying library functions into the executable, and (2)
302
- will operate properly with a modified version of the library, if
303
- the user installs one, as long as the modified version is
304
- interface-compatible with the version that the work was made with.
305
-
306
- c) Accompany the work with a written offer, valid for at
307
- least three years, to give the same user the materials
308
- specified in Subsection 6a, above, for a charge no more
309
- than the cost of performing this distribution.
310
-
311
- d) If distribution of the work is made by offering access to copy
312
- from a designated place, offer equivalent access to copy the above
313
- specified materials from the same place.
314
-
315
- e) Verify that the user has already received a copy of these
316
- materials or that you have already sent this user a copy.
317
-
318
- For an executable, the required form of the "work that uses the
319
- Library" must include any data and utility programs needed for
320
- reproducing the executable from it. However, as a special exception,
321
- the materials to be distributed need not include anything that is
322
- normally distributed (in either source or binary form) with the major
323
- components (compiler, kernel, and so on) of the operating system on
324
- which the executable runs, unless that component itself accompanies
325
- the executable.
326
-
327
- It may happen that this requirement contradicts the license
328
- restrictions of other proprietary libraries that do not normally
329
- accompany the operating system. Such a contradiction means you cannot
330
- use both them and the Library together in an executable that you
331
- distribute.
332
-
333
- 7. You may place library facilities that are a work based on the
334
- Library side-by-side in a single library together with other library
335
- facilities not covered by this License, and distribute such a combined
336
- library, provided that the separate distribution of the work based on
337
- the Library and of the other library facilities is otherwise
338
- permitted, and provided that you do these two things:
339
-
340
- a) Accompany the combined library with a copy of the same work
341
- based on the Library, uncombined with any other library
342
- facilities. This must be distributed under the terms of the
343
- Sections above.
344
-
345
- b) Give prominent notice with the combined library of the fact
346
- that part of it is a work based on the Library, and explaining
347
- where to find the accompanying uncombined form of the same work.
348
-
349
- 8. You may not copy, modify, sublicense, link with, or distribute
350
- the Library except as expressly provided under this License. Any
351
- attempt otherwise to copy, modify, sublicense, link with, or
352
- distribute the Library is void, and will automatically terminate your
353
- rights under this License. However, parties who have received copies,
354
- or rights, from you under this License will not have their licenses
355
- terminated so long as such parties remain in full compliance.
356
-
357
- 9. You are not required to accept this License, since you have not
358
- signed it. However, nothing else grants you permission to modify or
359
- distribute the Library or its derivative works. These actions are
360
- prohibited by law if you do not accept this License. Therefore, by
361
- modifying or distributing the Library (or any work based on the
362
- Library), you indicate your acceptance of this License to do so, and
363
- all its terms and conditions for copying, distributing or modifying
364
- the Library or works based on it.
365
-
366
- 10. Each time you redistribute the Library (or any work based on the
367
- Library), the recipient automatically receives a license from the
368
- original licensor to copy, distribute, link with or modify the Library
369
- subject to these terms and conditions. You may not impose any further
370
- restrictions on the recipients' exercise of the rights granted herein.
371
- You are not responsible for enforcing compliance by third parties with
372
- this License.
373
-
374
- 11. If, as a consequence of a court judgment or allegation of patent
375
- infringement or for any other reason (not limited to patent issues),
376
- conditions are imposed on you (whether by court order, agreement or
377
- otherwise) that contradict the conditions of this License, they do not
378
- excuse you from the conditions of this License. If you cannot
379
- distribute so as to satisfy simultaneously your obligations under this
380
- License and any other pertinent obligations, then as a consequence you
381
- may not distribute the Library at all. For example, if a patent
382
- license would not permit royalty-free redistribution of the Library by
383
- all those who receive copies directly or indirectly through you, then
384
- the only way you could satisfy both it and this License would be to
385
- refrain entirely from distribution of the Library.
386
-
387
- If any portion of this section is held invalid or unenforceable under any
388
- particular circumstance, the balance of the section is intended to apply,
389
- and the section as a whole is intended to apply in other circumstances.
390
-
391
- It is not the purpose of this section to induce you to infringe any
392
- patents or other property right claims or to contest validity of any
393
- such claims; this section has the sole purpose of protecting the
394
- integrity of the free software distribution system which is
395
- implemented by public license practices. Many people have made
396
- generous contributions to the wide range of software distributed
397
- through that system in reliance on consistent application of that
398
- system; it is up to the author/donor to decide if he or she is willing
399
- to distribute software through any other system and a licensee cannot
400
- impose that choice.
401
-
402
- This section is intended to make thoroughly clear what is believed to
403
- be a consequence of the rest of this License.
404
-
405
- 12. If the distribution and/or use of the Library is restricted in
406
- certain countries either by patents or by copyrighted interfaces, the
407
- original copyright holder who places the Library under this License may add
408
- an explicit geographical distribution limitation excluding those countries,
409
- so that distribution is permitted only in or among countries not thus
410
- excluded. In such case, this License incorporates the limitation as if
411
- written in the body of this License.
412
-
413
- 13. The Free Software Foundation may publish revised and/or new
414
- versions of the Lesser General Public License from time to time.
415
- Such new versions will be similar in spirit to the present version,
416
- but may differ in detail to address new problems or concerns.
417
-
418
- Each version is given a distinguishing version number. If the Library
419
- specifies a version number of this License which applies to it and
420
- "any later version", you have the option of following the terms and
421
- conditions either of that version or of any later version published by
422
- the Free Software Foundation. If the Library does not specify a
423
- license version number, you may choose any version ever published by
424
- the Free Software Foundation.
425
-
426
- 14. If you wish to incorporate parts of the Library into other free
427
- programs whose distribution conditions are incompatible with these,
428
- write to the author to ask for permission. For software which is
429
- copyrighted by the Free Software Foundation, write to the Free
430
- Software Foundation; we sometimes make exceptions for this. Our
431
- decision will be guided by the two goals of preserving the free status
432
- of all derivatives of our free software and of promoting the sharing
433
- and reuse of software generally.
434
-
435
- NO WARRANTY
436
-
437
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438
- WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439
- EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440
- OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441
- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444
- LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445
- THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
-
447
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448
- WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449
- AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450
- FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451
- CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452
- LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453
- RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454
- FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455
- SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456
- DAMAGES.
457
-
458
- END OF TERMS AND CONDITIONS
459
-
460
- How to Apply These Terms to Your New Libraries
461
-
462
- If you develop a new library, and you want it to be of the greatest
463
- possible use to the public, we recommend making it free software that
464
- everyone can redistribute and change. You can do so by permitting
465
- redistribution under these terms (or, alternatively, under the terms of the
466
- ordinary General Public License).
467
-
468
- To apply these terms, attach the following notices to the library. It is
469
- safest to attach them to the start of each source file to most effectively
470
- convey the exclusion of warranty; and each file should have at least the
471
- "copyright" line and a pointer to where the full notice is found.
472
-
473
- <one line to give the library's name and a brief idea of what it does.>
474
- Copyright (C) <year> <name of author>
475
-
476
- This library is free software; you can redistribute it and/or
477
- modify it under the terms of the GNU Lesser General Public
478
- License as published by the Free Software Foundation; either
479
- version 2.1 of the License, or (at your option) any later version.
480
-
481
- This library is distributed in the hope that it will be useful,
482
- but WITHOUT ANY WARRANTY; without even the implied warranty of
483
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484
- Lesser General Public License for more details.
485
-
486
- You should have received a copy of the GNU Lesser General Public
487
- License along with this library; if not, write to the Free Software
488
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489
-
490
- Also add information on how to contact you by electronic and paper mail.
491
-
492
- You should also get your employer (if you work as a programmer) or your
493
- school, if any, to sign a "copyright disclaimer" for the library, if
494
- necessary. Here is a sample; alter the names:
495
-
496
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
497
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
-
499
- <signature of Ty Coon>, 1 April 1990
500
- Ty Coon, President of Vice
501
-
502
- That's all there is to it!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/README DELETED
@@ -1,102 +0,0 @@
1
- SimpleTest
2
- ==========
3
-
4
- You probably got this package from:
5
-
6
- http://simpletest.org/en/download.html
7
-
8
- If there is no licence agreement with this package please download
9
- a version from the location above. You must read and accept that
10
- licence to use this software. The file is titled simply LICENSE.
11
-
12
- What is it? It's a framework for unit testing, web site testing and
13
- mock objects for PHP 5.0.5+.
14
-
15
- If you have used JUnit, you will find this PHP unit testing version very
16
- similar. Also included is a mock objects and server stubs generator.
17
- The stubs can have return values set for different arguments, can have
18
- sequences set also by arguments and can return items by reference.
19
- The mocks inherit all of this functionality and can also have
20
- expectations set, again in sequences and for different arguments.
21
-
22
- A web tester similar in concept to JWebUnit is also included. There is no
23
- JavaScript or tables support, but forms, authentication, cookies and
24
- frames are handled.
25
-
26
- You can see a release schedule at http://simpletest.org/en/overview.html
27
- which is also copied to the documentation folder with this release.
28
- A full PHPDocumenter API documentation exists at
29
- http://simpletest.org/api/.
30
-
31
- The user interface is minimal in the extreme, but a lot of information
32
- flows from the test suite. After version 1.0 we will release a better
33
- web UI, but we are leaving XUL and GTK versions to volunteers as
34
- everybody has their own opinion on a good GUI, and we don't want to
35
- discourage development by shipping one with the toolkit. You can
36
- download an Eclipse plug-in separately.
37
-
38
- The unit tests for SimpleTest itself can be run here:
39
-
40
- test/unit_tests.php
41
-
42
- And tests involving live network connections as well are here:
43
-
44
- test/all_tests.php
45
-
46
- The full tests will typically overrun the 8Mb limit often allowed
47
- to a PHP process. A workaround is to run the tests on the command
48
- with a custom php.ini file or with the switch -dmemory_limit=-1
49
- if you do not have access to your server version.
50
-
51
- The full tests read some test data from simpletest.org. If the site
52
- is down or has been modified for a later version then you will get
53
- spurious errors. A unit_tests.php failure on the other hand would be
54
- very serious. Please notify us if you find one.
55
-
56
- Even if all of the tests run please verify that your existing test suites
57
- also function as expected. The file:
58
-
59
- HELP_MY_TESTS_DONT_WORK_ANYMORE
60
-
61
- ...contains information on interface changes. It also points out
62
- deprecated interfaces, so you should read this even if all of
63
- your current tests appear to run.
64
-
65
- There is a documentation folder which contains the core reference information
66
- in English and French, although this information is fairly basic.
67
- You can find a tutorial on...
68
-
69
- http://simpletest.org/en/first_test_tutorial.html
70
-
71
- ...to get you started and this material will eventually become included
72
- with the project documentation. A French translation exists at:
73
-
74
- http://simpletest.org/fr/first_test_tutorial.html
75
-
76
- If you download and use, and possibly even extend this tool, please let us
77
- know. Any feedback, even bad, is always welcome and we will work to get
78
- your suggestions into the next release. Ideally please send your
79
- comments to:
80
-
81
- simpletest-support@lists.sourceforge.net
82
-
83
- ...so that others can read them too. We usually try to respond within 48
84
- hours.
85
-
86
- There is no change log except at Sourceforge. You can visit the
87
- release notes to see the completed TODO list after each cycle and also the
88
- status of any bugs, but if the bug is recent then it will be fixed in SVN only.
89
- The SVN check-ins always have all the tests passing and so SVN snapshots should
90
- be pretty usable, although the code may not look so good internally.
91
-
92
- Oh, and one last thing: SimpleTest is called "Simple" because it should
93
- be simple to use. We intend to add a complete set of tools for a test
94
- first and "test as you code" type of development. "Simple" does not mean
95
- "Lite" in this context.
96
-
97
- Thanks to everyone who has sent comments and offered suggestions. They
98
- really are invaluable, but sadly you are too many to mention in full.
99
- Thanks to all on the advanced PHP forum on SitePoint, especially Harry
100
- Fuecks. Early adopters are always an inspiration.
101
-
102
- -- Marcus Baker, Jason Sweat, Travis Swicegood, Perrick Penet and Edward Z. Yang.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1alpha3
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/authentication.php DELETED
@@ -1,237 +0,0 @@
1
- <?php
2
- /**
3
- * Base include file for SimpleTest
4
- * @package SimpleTest
5
- * @subpackage WebTester
6
- * @version $Id: authentication.php 2011 2011-04-29 08:22:48Z pp11 $
7
- */
8
- /**
9
- * include http class
10
- */
11
- require_once(dirname(__FILE__) . '/http.php');
12
-
13
- /**
14
- * Represents a single security realm's identity.
15
- * @package SimpleTest
16
- * @subpackage WebTester
17
- */
18
- class SimpleRealm {
19
- private $type;
20
- private $root;
21
- private $username;
22
- private $password;
23
-
24
- /**
25
- * Starts with the initial entry directory.
26
- * @param string $type Authentication type for this
27
- * realm. Only Basic authentication
28
- * is currently supported.
29
- * @param SimpleUrl $url Somewhere in realm.
30
- * @access public
31
- */
32
- function SimpleRealm($type, $url) {
33
- $this->type = $type;
34
- $this->root = $url->getBasePath();
35
- $this->username = false;
36
- $this->password = false;
37
- }
38
-
39
- /**
40
- * Adds another location to the realm.
41
- * @param SimpleUrl $url Somewhere in realm.
42
- * @access public
43
- */
44
- function stretch($url) {
45
- $this->root = $this->getCommonPath($this->root, $url->getPath());
46
- }
47
-
48
- /**
49
- * Finds the common starting path.
50
- * @param string $first Path to compare.
51
- * @param string $second Path to compare.
52
- * @return string Common directories.
53
- * @access private
54
- */
55
- protected function getCommonPath($first, $second) {
56
- $first = explode('/', $first);
57
- $second = explode('/', $second);
58
- for ($i = 0; $i < min(count($first), count($second)); $i++) {
59
- if ($first[$i] != $second[$i]) {
60
- return implode('/', array_slice($first, 0, $i)) . '/';
61
- }
62
- }
63
- return implode('/', $first) . '/';
64
- }
65
-
66
- /**
67
- * Sets the identity to try within this realm.
68
- * @param string $username Username in authentication dialog.
69
- * @param string $username Password in authentication dialog.
70
- * @access public
71
- */
72
- function setIdentity($username, $password) {
73
- $this->username = $username;
74
- $this->password = $password;
75
- }
76
-
77
- /**
78
- * Accessor for current identity.
79
- * @return string Last succesful username.
80
- * @access public
81
- */
82
- function getUsername() {
83
- return $this->username;
84
- }
85
-
86
- /**
87
- * Accessor for current identity.
88
- * @return string Last succesful password.
89
- * @access public
90
- */
91
- function getPassword() {
92
- return $this->password;
93
- }
94
-
95
- /**
96
- * Test to see if the URL is within the directory
97
- * tree of the realm.
98
- * @param SimpleUrl $url URL to test.
99
- * @return boolean True if subpath.
100
- * @access public
101
- */
102
- function isWithin($url) {
103
- if ($this->isIn($this->root, $url->getBasePath())) {
104
- return true;
105
- }
106
- if ($this->isIn($this->root, $url->getBasePath() . $url->getPage() . '/')) {
107
- return true;
108
- }
109
- return false;
110
- }
111
-
112
- /**
113
- * Tests to see if one string is a substring of
114
- * another.
115
- * @param string $part Small bit.
116
- * @param string $whole Big bit.
117
- * @return boolean True if the small bit is
118
- * in the big bit.
119
- * @access private
120
- */
121
- protected function isIn($part, $whole) {
122
- return strpos($whole, $part) === 0;
123
- }
124
- }
125
-
126
- /**
127
- * Manages security realms.
128
- * @package SimpleTest
129
- * @subpackage WebTester
130
- */
131
- class SimpleAuthenticator {
132
- private $realms;
133
-
134
- /**
135
- * Clears the realms.
136
- * @access public
137
- */
138
- function SimpleAuthenticator() {
139
- $this->restartSession();
140
- }
141
-
142
- /**
143
- * Starts with no realms set up.
144
- * @access public
145
- */
146
- function restartSession() {
147
- $this->realms = array();
148
- }
149
-
150
- /**
151
- * Adds a new realm centered the current URL.
152
- * Browsers privatey wildly on their behaviour in this
153
- * regard. Mozilla ignores the realm and presents
154
- * only when challenged, wasting bandwidth. IE
155
- * just carries on presenting until a new challenge
156
- * occours. SimpleTest tries to follow the spirit of
157
- * the original standards committee and treats the
158
- * base URL as the root of a file tree shaped realm.
159
- * @param SimpleUrl $url Base of realm.
160
- * @param string $type Authentication type for this
161
- * realm. Only Basic authentication
162
- * is currently supported.
163
- * @param string $realm Name of realm.
164
- * @access public
165
- */
166
- function addRealm($url, $type, $realm) {
167
- $this->realms[$url->getHost()][$realm] = new SimpleRealm($type, $url);
168
- }
169
-
170
- /**
171
- * Sets the current identity to be presented
172
- * against that realm.
173
- * @param string $host Server hosting realm.
174
- * @param string $realm Name of realm.
175
- * @param string $username Username for realm.
176
- * @param string $password Password for realm.
177
- * @access public
178
- */
179
- function setIdentityForRealm($host, $realm, $username, $password) {
180
- if (isset($this->realms[$host][$realm])) {
181
- $this->realms[$host][$realm]->setIdentity($username, $password);
182
- }
183
- }
184
-
185
- /**
186
- * Finds the name of the realm by comparing URLs.
187
- * @param SimpleUrl $url URL to test.
188
- * @return SimpleRealm Name of realm.
189
- * @access private
190
- */
191
- protected function findRealmFromUrl($url) {
192
- if (! isset($this->realms[$url->getHost()])) {
193
- return false;
194
- }
195
- foreach ($this->realms[$url->getHost()] as $name => $realm) {
196
- if ($realm->isWithin($url)) {
197
- return $realm;
198
- }
199
- }
200
- return false;
201
- }
202
-
203
- /**
204
- * Presents the appropriate headers for this location.
205
- * @param SimpleHttpRequest $request Request to modify.
206
- * @param SimpleUrl $url Base of realm.
207
- * @access public
208
- */
209
- function addHeaders(&$request, $url) {
210
- if ($url->getUsername() && $url->getPassword()) {
211
- $username = $url->getUsername();
212
- $password = $url->getPassword();
213
- } elseif ($realm = $this->findRealmFromUrl($url)) {
214
- $username = $realm->getUsername();
215
- $password = $realm->getPassword();
216
- } else {
217
- return;
218
- }
219
- $this->addBasicHeaders($request, $username, $password);
220
- }
221
-
222
- /**
223
- * Presents the appropriate headers for this
224
- * location for basic authentication.
225
- * @param SimpleHttpRequest $request Request to modify.
226
- * @param string $username Username for realm.
227
- * @param string $password Password for realm.
228
- * @access public
229
- */
230
- static function addBasicHeaders(&$request, $username, $password) {
231
- if ($username && $password) {
232
- $request->addHeaderLine(
233
- 'Authorization: Basic ' . base64_encode("$username:$password"));
234
- }
235
- }
236
- }
237
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/autorun.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- /**
3
- * Autorunner which runs all tests cases found in a file
4
- * that includes this module.
5
- * @package SimpleTest
6
- * @version $Id: autorun.php 2011 2011-04-29 08:22:48Z pp11 $
7
- */
8
-
9
- /**#@+
10
- * include simpletest files
11
- */
12
- require_once dirname(__FILE__) . '/unit_tester.php';
13
- require_once dirname(__FILE__) . '/mock_objects.php';
14
- require_once dirname(__FILE__) . '/collector.php';
15
- require_once dirname(__FILE__) . '/default_reporter.php';
16
- /**#@-*/
17
-
18
- $GLOBALS['SIMPLETEST_AUTORUNNER_INITIAL_CLASSES'] = get_declared_classes();
19
- register_shutdown_function('simpletest_autorun');
20
-
21
- /**
22
- * Exit handler to run all recent test cases and exit system if in CLI
23
- */
24
- function simpletest_autorun() {
25
- if (tests_have_run()) {
26
- return;
27
- }
28
- $result = run_local_tests();
29
- if (SimpleReporter::inCli()) {
30
- exit($result ? 0 : 1);
31
- }
32
- }
33
-
34
- /**
35
- * run all recent test cases if no test has
36
- * so far been run. Uses the DefaultReporter which can have
37
- * it's output controlled with SimpleTest::prefer().
38
- * @return boolean/null false if there were test failures, true if
39
- * there were no failures, null if tests are
40
- * already running
41
- */
42
- function run_local_tests() {
43
- try {
44
- if (tests_have_run()) {
45
- return;
46
- }
47
- $candidates = capture_new_classes();
48
- $loader = new SimpleFileLoader();
49
- $suite = $loader->createSuiteFromClasses(
50
- basename(initial_file()),
51
- $loader->selectRunnableTests($candidates));
52
- return $suite->run(new DefaultReporter());
53
- } catch (Exception $stack_frame_fix) {
54
- print $stack_frame_fix->getMessage();
55
- return false;
56
- }
57
- }
58
-
59
- /**
60
- * Checks the current test context to see if a test has
61
- * ever been run.
62
- * @return boolean True if tests have run.
63
- */
64
- function tests_have_run() {
65
- if ($context = SimpleTest::getContext()) {
66
- return (boolean)$context->getTest();
67
- }
68
- return false;
69
- }
70
-
71
- /**
72
- * The first autorun file.
73
- * @return string Filename of first autorun script.
74
- */
75
- function initial_file() {
76
- static $file = false;
77
- if (! $file) {
78
- if (isset($_SERVER, $_SERVER['SCRIPT_FILENAME'])) {
79
- $file = $_SERVER['SCRIPT_FILENAME'];
80
- } else {
81
- $included_files = get_included_files();
82
- $file = reset($included_files);
83
- }
84
- }
85
- return $file;
86
- }
87
-
88
- /**
89
- * Every class since the first autorun include. This
90
- * is safe enough if require_once() is always used.
91
- * @return array Class names.
92
- */
93
- function capture_new_classes() {
94
- global $SIMPLETEST_AUTORUNNER_INITIAL_CLASSES;
95
- return array_map('strtolower', array_diff(get_declared_classes(),
96
- $SIMPLETEST_AUTORUNNER_INITIAL_CLASSES ?
97
- $SIMPLETEST_AUTORUNNER_INITIAL_CLASSES : array()));
98
- }
99
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/browser.php DELETED
@@ -1,1144 +0,0 @@
1
- <?php
2
- /**
3
- * Base include file for SimpleTest
4
- * @package SimpleTest
5
- * @subpackage WebTester
6
- * @version $Id: browser.php 2013 2011-04-29 09:29:45Z pp11 $
7
- */
8
-
9
- /**#@+
10
- * include other SimpleTest class files
11
- */
12
- require_once(dirname(__FILE__) . '/simpletest.php');
13
- require_once(dirname(__FILE__) . '/http.php');
14
- require_once(dirname(__FILE__) . '/encoding.php');
15
- require_once(dirname(__FILE__) . '/page.php');
16
- require_once(dirname(__FILE__) . '/php_parser.php');
17
- require_once(dirname(__FILE__) . '/tidy_parser.php');
18
- require_once(dirname(__FILE__) . '/selector.php');
19
- require_once(dirname(__FILE__) . '/frames.php');
20
- require_once(dirname(__FILE__) . '/user_agent.php');
21
- if (! SimpleTest::getParsers()) {
22
- SimpleTest::setParsers(array(new SimpleTidyPageBuilder(), new SimplePHPPageBuilder()));
23
- //SimpleTest::setParsers(array(new SimplePHPPageBuilder()));
24
- }
25
- /**#@-*/
26
-
27
- if (! defined('DEFAULT_MAX_NESTED_FRAMES')) {
28
- define('DEFAULT_MAX_NESTED_FRAMES', 3);
29
- }
30
-
31
- /**
32
- * Browser history list.
33
- * @package SimpleTest
34
- * @subpackage WebTester
35
- */
36
- class SimpleBrowserHistory {
37
- private $sequence = array();
38
- private $position = -1;
39
-
40
- /**
41
- * Test for no entries yet.
42
- * @return boolean True if empty.
43
- * @access private
44
- */
45
- protected function isEmpty() {
46
- return ($this->position == -1);
47
- }
48
-
49
- /**
50
- * Test for being at the beginning.
51
- * @return boolean True if first.
52
- * @access private
53
- */
54
- protected function atBeginning() {
55
- return ($this->position == 0) && ! $this->isEmpty();
56
- }
57
-
58
- /**
59
- * Test for being at the last entry.
60
- * @return boolean True if last.
61
- * @access private
62
- */
63
- protected function atEnd() {
64
- return ($this->position + 1 >= count($this->sequence)) && ! $this->isEmpty();
65
- }
66
-
67
- /**
68
- * Adds a successfully fetched page to the history.
69
- * @param SimpleUrl $url URL of fetch.
70
- * @param SimpleEncoding $parameters Any post data with the fetch.
71
- * @access public
72
- */
73
- function recordEntry($url, $parameters) {
74
- $this->dropFuture();
75
- array_push(
76
- $this->sequence,
77
- array('url' => $url, 'parameters' => $parameters));
78
- $this->position++;
79
- }
80
-
81
- /**
82
- * Last fully qualified URL for current history
83
- * position.
84
- * @return SimpleUrl URL for this position.
85
- * @access public
86
- */
87
- function getUrl() {
88
- if ($this->isEmpty()) {
89
- return false;
90
- }
91
- return $this->sequence[$this->position]['url'];
92
- }
93
-
94
- /**
95
- * Parameters of last fetch from current history
96
- * position.
97
- * @return SimpleFormEncoding Post parameters.
98
- * @access public
99
- */
100
- function getParameters() {
101
- if ($this->isEmpty()) {
102
- return false;
103
- }
104
- return $this->sequence[$this->position]['parameters'];
105
- }
106
-
107
- /**
108
- * Step back one place in the history. Stops at
109
- * the first page.
110
- * @return boolean True if any previous entries.
111
- * @access public
112
- */
113
- function back() {
114
- if ($this->isEmpty() || $this->atBeginning()) {
115
- return false;
116
- }
117
- $this->position--;
118
- return true;
119
- }
120
-
121
- /**
122
- * Step forward one place. If already at the
123
- * latest entry then nothing will happen.
124
- * @return boolean True if any future entries.
125
- * @access public
126
- */
127
- function forward() {
128
- if ($this->isEmpty() || $this->atEnd()) {
129
- return false;
130
- }
131
- $this->position++;
132
- return true;
133
- }
134
-
135
- /**
136
- * Ditches all future entries beyond the current
137
- * point.
138
- * @access private
139
- */
140
- protected function dropFuture() {
141
- if ($this->isEmpty()) {
142
- return;
143
- }
144
- while (! $this->atEnd()) {
145
- array_pop($this->sequence);
146
- }
147
- }
148
- }
149
-
150
- /**
151
- * Simulated web browser. This is an aggregate of
152
- * the user agent, the HTML parsing, request history
153
- * and the last header set.
154
- * @package SimpleTest
155
- * @subpackage WebTester
156
- */
157
- class SimpleBrowser {
158
- private $user_agent;
159
- private $page;
160
- private $history;
161
- private $ignore_frames;
162
- private $maximum_nested_frames;
163
- private $parser;
164
-
165
- /**
166
- * Starts with a fresh browser with no
167
- * cookie or any other state information. The
168
- * exception is that a default proxy will be
169
- * set up if specified in the options.
170
- * @access public
171
- */
172
- function __construct() {
173
- $this->user_agent = $this->createUserAgent();
174
- $this->user_agent->useProxy(
175
- SimpleTest::getDefaultProxy(),
176
- SimpleTest::getDefaultProxyUsername(),
177
- SimpleTest::getDefaultProxyPassword());
178
- $this->page = new SimplePage();
179
- $this->history = $this->createHistory();
180
- $this->ignore_frames = false;
181
- $this->maximum_nested_frames = DEFAULT_MAX_NESTED_FRAMES;
182
- }
183
-
184
- /**
185
- * Creates the underlying user agent.
186
- * @return SimpleFetcher Content fetcher.
187
- * @access protected
188
- */
189
- protected function createUserAgent() {
190
- return new SimpleUserAgent();
191
- }
192
-
193
- /**
194
- * Creates a new empty history list.
195
- * @return SimpleBrowserHistory New list.
196
- * @access protected
197
- */
198
- protected function createHistory() {
199
- return new SimpleBrowserHistory();
200
- }
201
-
202
- /**
203
- * Get the HTML parser to use. Can be overridden by
204
- * setParser. Otherwise scans through the available parsers and
205
- * uses the first one which is available.
206
- * @return object SimplePHPPageBuilder or SimpleTidyPageBuilder
207
- */
208
- protected function getParser() {
209
- if ($this->parser) {
210
- return $this->parser;
211
- }
212
- foreach (SimpleTest::getParsers() as $parser) {
213
- if ($parser->can()) {
214
- return $parser;
215
- }
216
- }
217
- }
218
-
219
- /**
220
- * Override the default HTML parser, allowing parsers to be plugged in.
221
- * @param object A parser object instance.
222
- */
223
- public function setParser($parser) {
224
- $this->parser = $parser;
225
- }
226
-
227
- /**
228
- * Disables frames support. Frames will not be fetched
229
- * and the frameset page will be used instead.
230
- * @access public
231
- */
232
- function ignoreFrames() {
233
- $this->ignore_frames = true;
234
- }
235
-
236
- /**
237
- * Enables frames support. Frames will be fetched from
238
- * now on.
239
- * @access public
240
- */
241
- function useFrames() {
242
- $this->ignore_frames = false;
243
- }
244
-
245
- /**
246
- * Switches off cookie sending and recieving.
247
- * @access public
248
- */
249
- function ignoreCookies() {
250
- $this->user_agent->ignoreCookies();
251
- }
252
-
253
- /**
254
- * Switches back on the cookie sending and recieving.
255
- * @access public
256
- */
257
- function useCookies() {
258
- $this->user_agent->useCookies();
259
- }
260
-
261
- /**
262
- * Parses the raw content into a page. Will load further
263
- * frame pages unless frames are disabled.
264
- * @param SimpleHttpResponse $response Response from fetch.
265
- * @param integer $depth Nested frameset depth.
266
- * @return SimplePage Parsed HTML.
267
- * @access private
268
- */
269
- protected function parse($response, $depth = 0) {
270
- $page = $this->buildPage($response);
271
- if ($this->ignore_frames || ! $page->hasFrames() || ($depth > $this->maximum_nested_frames)) {
272
- return $page;
273
- }
274
- $frameset = new SimpleFrameset($page);
275
- foreach ($page->getFrameset() as $key => $url) {
276
- $frame = $this->fetch($url, new SimpleGetEncoding(), $depth + 1);
277
- $frameset->addFrame($frame, $key);
278
- }
279
- return $frameset;
280
- }
281
-
282
- /**
283
- * Assembles the parsing machinery and actually parses
284
- * a single page. Frees all of the builder memory and so
285
- * unjams the PHP memory management.
286
- * @param SimpleHttpResponse $response Response from fetch.
287
- * @return SimplePage Parsed top level page.
288
- */
289
- protected function buildPage($response) {
290
- return $this->getParser()->parse($response);
291
- }
292
-
293
- /**
294
- * Fetches a page. Jointly recursive with the parse()
295
- * method as it descends a frameset.
296
- * @param string/SimpleUrl $url Target to fetch.
297
- * @param SimpleEncoding $encoding GET/POST parameters.
298
- * @param integer $depth Nested frameset depth protection.
299
- * @return SimplePage Parsed page.
300
- * @access private
301
- */
302
- protected function fetch($url, $encoding, $depth = 0) {
303
- $response = $this->user_agent->fetchResponse($url, $encoding);
304
- if ($response->isError()) {
305
- return new SimplePage($response);
306
- }
307
- return $this->parse($response, $depth);
308
- }
309
-
310
- /**
311
- * Fetches a page or a single frame if that is the current
312
- * focus.
313
- * @param SimpleUrl $url Target to fetch.
314
- * @param SimpleEncoding $parameters GET/POST parameters.
315
- * @return string Raw content of page.
316
- * @access private
317
- */
318
- protected function load($url, $parameters) {
319
- $frame = $url->getTarget();
320
- if (! $frame || ! $this->page->hasFrames() || (strtolower($frame) == '_top')) {
321
- return $this->loadPage($url, $parameters);
322
- }
323
- return $this->loadFrame(array($frame), $url, $parameters);
324
- }
325
-
326
- /**
327
- * Fetches a page and makes it the current page/frame.
328
- * @param string/SimpleUrl $url Target to fetch as string.
329
- * @param SimplePostEncoding $parameters POST parameters.
330
- * @return string Raw content of page.
331
- * @access private
332
- */
333
- protected function loadPage($url, $parameters) {
334
- $this->page = $this->fetch($url, $parameters);
335
- $this->history->recordEntry(
336
- $this->page->getUrl(),
337
- $this->page->getRequestData());
338
- return $this->page->getRaw();
339
- }
340
-
341
- /**
342
- * Fetches a frame into the existing frameset replacing the
343
- * original.
344
- * @param array $frames List of names to drill down.
345
- * @param string/SimpleUrl $url Target to fetch as string.
346
- * @param SimpleFormEncoding $parameters POST parameters.
347
- * @return string Raw content of page.
348
- * @access private
349
- */
350
- protected function loadFrame($frames, $url, $parameters) {
351
- $page = $this->fetch($url, $parameters);
352
- $this->page->setFrame($frames, $page);
353
- return $page->getRaw();
354
- }
355
-
356
- /**
357
- * Removes expired and temporary cookies as if
358
- * the browser was closed and re-opened.
359
- * @param string/integer $date Time when session restarted.
360
- * If omitted then all persistent
361
- * cookies are kept.
362
- * @access public
363
- */
364
- function restart($date = false) {
365
- $this->user_agent->restart($date);
366
- }
367
-
368
- /**
369
- * Adds a header to every fetch.
370
- * @param string $header Header line to add to every
371
- * request until cleared.
372
- * @access public
373
- */
374
- function addHeader($header) {
375
- $this->user_agent->addHeader($header);
376
- }
377
-
378
- /**
379
- * Ages the cookies by the specified time.
380
- * @param integer $interval Amount in seconds.
381
- * @access public
382
- */
383
- function ageCookies($interval) {
384
- $this->user_agent->ageCookies($interval);
385
- }
386
-
387
- /**
388
- * Sets an additional cookie. If a cookie has
389
- * the same name and path it is replaced.
390
- * @param string $name Cookie key.
391
- * @param string $value Value of cookie.
392
- * @param string $host Host upon which the cookie is valid.
393
- * @param string $path Cookie path if not host wide.
394
- * @param string $expiry Expiry date.
395
- * @access public
396
- */
397
- function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
398
- $this->user_agent->setCookie($name, $value, $host, $path, $expiry);
399
- }
400
-
401
- /**
402
- * Reads the most specific cookie value from the
403
- * browser cookies.
404
- * @param string $host Host to search.
405
- * @param string $path Applicable path.
406
- * @param string $name Name of cookie to read.
407
- * @return string False if not present, else the
408
- * value as a string.
409
- * @access public
410
- */
411
- function getCookieValue($host, $path, $name) {
412
- return $this->user_agent->getCookieValue($host, $path, $name);
413
- }
414
-
415
- /**
416
- * Reads the current cookies for the current URL.
417
- * @param string $name Key of cookie to find.
418
- * @return string Null if there is no current URL, false
419
- * if the cookie is not set.
420
- * @access public
421
- */
422
- function getCurrentCookieValue($name) {
423
- return $this->user_agent->getBaseCookieValue($name, $this->page->getUrl());
424
- }
425
-
426
- /**
427
- * Sets the maximum number of redirects before
428
- * a page will be loaded anyway.
429
- * @param integer $max Most hops allowed.
430
- * @access public
431
- */
432
- function setMaximumRedirects($max) {
433
- $this->user_agent->setMaximumRedirects($max);
434
- }
435
-
436
- /**
437
- * Sets the maximum number of nesting of framed pages
438
- * within a framed page to prevent loops.
439
- * @param integer $max Highest depth allowed.
440
- * @access public
441
- */
442
- function setMaximumNestedFrames($max) {
443
- $this->maximum_nested_frames = $max;
444
- }
445
-
446
- /**
447
- * Sets the socket timeout for opening a connection.
448
- * @param integer $timeout Maximum time in seconds.
449
- * @access public
450
- */
451
- function setConnectionTimeout($timeout) {
452
- $this->user_agent->setConnectionTimeout($timeout);
453
- }
454
-
455
- /**
456
- * Sets proxy to use on all requests for when
457
- * testing from behind a firewall. Set URL
458
- * to false to disable.
459
- * @param string $proxy Proxy URL.
460
- * @param string $username Proxy username for authentication.
461
- * @param string $password Proxy password for authentication.
462
- * @access public
463
- */
464
- function useProxy($proxy, $username = false, $password = false) {
465
- $this->user_agent->useProxy($proxy, $username, $password);
466
- }
467
-
468
- /**
469
- * Fetches the page content with a HEAD request.
470
- * Will affect cookies, but will not change the base URL.
471
- * @param string/SimpleUrl $url Target to fetch as string.
472
- * @param hash/SimpleHeadEncoding $parameters Additional parameters for
473
- * HEAD request.
474
- * @return boolean True if successful.
475
- * @access public
476
- */
477
- function head($url, $parameters = false) {
478
- if (! is_object($url)) {
479
- $url = new SimpleUrl($url);
480
- }
481
- if ($this->getUrl()) {
482
- $url = $url->makeAbsolute($this->getUrl());
483
- }
484
- $response = $this->user_agent->fetchResponse($url, new SimpleHeadEncoding($parameters));
485
- $this->page = new SimplePage($response);
486
- return ! $response->isError();
487
- }
488
-
489
- /**
490
- * Fetches the page content with a simple GET request.
491
- * @param string/SimpleUrl $url Target to fetch.
492
- * @param hash/SimpleFormEncoding $parameters Additional parameters for
493
- * GET request.
494
- * @return string Content of page or false.
495
- * @access public
496
- */
497
- function get($url, $parameters = false) {
498
- if (! is_object($url)) {
499
- $url = new SimpleUrl($url);
500
- }
501
- if ($this->getUrl()) {
502
- $url = $url->makeAbsolute($this->getUrl());
503
- }
504
- return $this->load($url, new SimpleGetEncoding($parameters));
505
- }
506
-
507
- /**
508
- * Fetches the page content with a POST request.
509
- * @param string/SimpleUrl $url Target to fetch as string.
510
- * @param hash/SimpleFormEncoding $parameters POST parameters or request body.
511
- * @param string $content_type MIME Content-Type of the request body
512
- * @return string Content of page.
513
- * @access public
514
- */
515
- function post($url, $parameters = false, $content_type = false) {
516
- if (! is_object($url)) {
517
- $url = new SimpleUrl($url);
518
- }
519
- if ($this->getUrl()) {
520
- $url = $url->makeAbsolute($this->getUrl());
521
- }
522
- return $this->load($url, new SimplePostEncoding($parameters, $content_type));
523
- }
524
-
525
- /**
526
- * Fetches the page content with a PUT request.
527
- * @param string/SimpleUrl $url Target to fetch as string.
528
- * @param hash/SimpleFormEncoding $parameters PUT request body.
529
- * @param string $content_type MIME Content-Type of the request body
530
- * @return string Content of page.
531
- * @access public
532
- */
533
- function put($url, $parameters = false, $content_type = false) {
534
- if (! is_object($url)) {
535
- $url = new SimpleUrl($url);
536
- }
537
- return $this->load($url, new SimplePutEncoding($parameters, $content_type));
538
- }
539
-
540
- /**
541
- * Sends a DELETE request and fetches the response.
542
- * @param string/SimpleUrl $url Target to fetch.
543
- * @param hash/SimpleFormEncoding $parameters Additional parameters for
544
- * DELETE request.
545
- * @return string Content of page or false.
546
- * @access public
547
- */
548
- function delete($url, $parameters = false) {
549
- if (! is_object($url)) {
550
- $url = new SimpleUrl($url);
551
- }
552
- return $this->load($url, new SimpleDeleteEncoding($parameters));
553
- }
554
-
555
- /**
556
- * Equivalent to hitting the retry button on the
557
- * browser. Will attempt to repeat the page fetch. If
558
- * there is no history to repeat it will give false.
559
- * @return string/boolean Content if fetch succeeded
560
- * else false.
561
- * @access public
562
- */
563
- function retry() {
564
- $frames = $this->page->getFrameFocus();
565
- if (count($frames) > 0) {
566
- $this->loadFrame(
567
- $frames,
568
- $this->page->getUrl(),
569
- $this->page->getRequestData());
570
- return $this->page->getRaw();
571
- }
572
- if ($url = $this->history->getUrl()) {
573
- $this->page = $this->fetch($url, $this->history->getParameters());
574
- return $this->page->getRaw();
575
- }
576
- return false;
577
- }
578
-
579
- /**
580
- * Equivalent to hitting the back button on the
581
- * browser. The browser history is unchanged on
582
- * failure. The page content is refetched as there
583
- * is no concept of content caching in SimpleTest.
584
- * @return boolean True if history entry and
585
- * fetch succeeded
586
- * @access public
587
- */
588
- function back() {
589
- if (! $this->history->back()) {
590
- return false;
591
- }
592
- $content = $this->retry();
593
- if (! $content) {
594
- $this->history->forward();
595
- }
596
- return $content;
597
- }
598
-
599
- /**
600
- * Equivalent to hitting the forward button on the
601
- * browser. The browser history is unchanged on
602
- * failure. The page content is refetched as there
603
- * is no concept of content caching in SimpleTest.
604
- * @return boolean True if history entry and
605
- * fetch succeeded
606
- * @access public
607
- */
608
- function forward() {
609
- if (! $this->history->forward()) {
610
- return false;
611
- }
612
- $content = $this->retry();
613
- if (! $content) {
614
- $this->history->back();
615
- }
616
- return $content;
617
- }
618
-
619
- /**
620
- * Retries a request after setting the authentication
621
- * for the current realm.
622
- * @param string $username Username for realm.
623
- * @param string $password Password for realm.
624
- * @return boolean True if successful fetch. Note
625
- * that authentication may still have
626
- * failed.
627
- * @access public
628
- */
629
- function authenticate($username, $password) {
630
- if (! $this->page->getRealm()) {
631
- return false;
632
- }
633
- $url = $this->page->getUrl();
634
- if (! $url) {
635
- return false;
636
- }
637
- $this->user_agent->setIdentity(
638
- $url->getHost(),
639
- $this->page->getRealm(),
640
- $username,
641
- $password);
642
- return $this->retry();
643
- }
644
-
645
- /**
646
- * Accessor for a breakdown of the frameset.
647
- * @return array Hash tree of frames by name
648
- * or index if no name.
649
- * @access public
650
- */
651
- function getFrames() {
652
- return $this->page->getFrames();
653
- }
654
-
655
- /**
656
- * Accessor for current frame focus. Will be
657
- * false if no frame has focus.
658
- * @return integer/string/boolean Label if any, otherwise
659
- * the position in the frameset
660
- * or false if none.
661
- * @access public
662
- */
663
- function getFrameFocus() {
664
- return $this->page->getFrameFocus();
665
- }
666
-
667
- /**
668
- * Sets the focus by index. The integer index starts from 1.
669
- * @param integer $choice Chosen frame.
670
- * @return boolean True if frame exists.
671
- * @access public
672
- */
673
- function setFrameFocusByIndex($choice) {
674
- return $this->page->setFrameFocusByIndex($choice);
675
- }
676
-
677
- /**
678
- * Sets the focus by name.
679
- * @param string $name Chosen frame.
680
- * @return boolean True if frame exists.
681
- * @access public
682
- */
683
- function setFrameFocus($name) {
684
- return $this->page->setFrameFocus($name);
685
- }
686
-
687
- /**
688
- * Clears the frame focus. All frames will be searched
689
- * for content.
690
- * @access public
691
- */
692
- function clearFrameFocus() {
693
- return $this->page->clearFrameFocus();
694
- }
695
-
696
- /**
697
- * Accessor for last error.
698
- * @return string Error from last response.
699
- * @access public
700
- */
701
- function getTransportError() {
702
- return $this->page->getTransportError();
703
- }
704
-
705
- /**
706
- * Accessor for current MIME type.
707
- * @return string MIME type as string; e.g. 'text/html'
708
- * @access public
709
- */
710
- function getMimeType() {
711
- return $this->page->getMimeType();
712
- }
713
-
714
- /**
715
- * Accessor for last response code.
716
- * @return integer Last HTTP response code received.
717
- * @access public
718
- */
719
- function getResponseCode() {
720
- return $this->page->getResponseCode();
721
- }
722
-
723
- /**
724
- * Accessor for last Authentication type. Only valid
725
- * straight after a challenge (401).
726
- * @return string Description of challenge type.
727
- * @access public
728
- */
729
- function getAuthentication() {
730
- return $this->page->getAuthentication();
731
- }
732
-
733
- /**
734
- * Accessor for last Authentication realm. Only valid
735
- * straight after a challenge (401).
736
- * @return string Name of security realm.
737
- * @access public
738
- */
739
- function getRealm() {
740
- return $this->page->getRealm();
741
- }
742
-
743
- /**
744
- * Accessor for current URL of page or frame if
745
- * focused.
746
- * @return string Location of current page or frame as
747
- * a string.
748
- */
749
- function getUrl() {
750
- $url = $this->page->getUrl();
751
- return $url ? $url->asString() : false;
752
- }
753
-
754
- /**
755
- * Accessor for base URL of page if set via BASE tag
756
- * @return string base URL
757
- */
758
- function getBaseUrl() {
759
- $url = $this->page->getBaseUrl();
760
- return $url ? $url->asString() : false;
761
- }
762
-
763
- /**
764
- * Accessor for raw bytes sent down the wire.
765
- * @return string Original text sent.
766
- * @access public
767
- */
768
- function getRequest() {
769
- return $this->page->getRequest();
770
- }
771
-
772
- /**
773
- * Accessor for raw header information.
774
- * @return string Header block.
775
- * @access public
776
- */
777
- function getHeaders() {
778
- return $this->page->getHeaders();
779
- }
780
-
781
- /**
782
- * Accessor for raw page information.
783
- * @return string Original text content of web page.
784
- * @access public
785
- */
786
- function getContent() {
787
- return $this->page->getRaw();
788
- }
789
-
790
- /**
791
- * Accessor for plain text version of the page.
792
- * @return string Normalised text representation.
793
- * @access public
794
- */
795
- function getContentAsText() {
796
- return $this->page->getText();
797
- }
798
-
799
- /**
800
- * Accessor for parsed title.
801
- * @return string Title or false if no title is present.
802
- * @access public
803
- */
804
- function getTitle() {
805
- return $this->page->getTitle();
806
- }
807
-
808
- /**
809
- * Accessor for a list of all links in current page.
810
- * @return array List of urls with scheme of
811
- * http or https and hostname.
812
- * @access public
813
- */
814
- function getUrls() {
815
- return $this->page->getUrls();
816
- }
817
-
818
- /**
819
- * Sets all form fields with that name.
820
- * @param string $label Name or label of field in forms.
821
- * @param string $value New value of field.
822
- * @return boolean True if field exists, otherwise false.
823
- * @access public
824
- */
825
- function setField($label, $value, $position=false) {
826
- return $this->page->setField(new SimpleByLabelOrName($label), $value, $position);
827
- }
828
-
829
- /**
830
- * Sets all form fields with that name. Will use label if
831
- * one is available (not yet implemented).
832
- * @param string $name Name of field in forms.
833
- * @param string $value New value of field.
834
- * @return boolean True if field exists, otherwise false.
835
- * @access public
836
- */
837
- function setFieldByName($name, $value, $position=false) {
838
- return $this->page->setField(new SimpleByName($name), $value, $position);
839
- }
840
-
841
- /**
842
- * Sets all form fields with that id attribute.
843
- * @param string/integer $id Id of field in forms.
844
- * @param string $value New value of field.
845
- * @return boolean True if field exists, otherwise false.
846
- * @access public
847
- */
848
- function setFieldById($id, $value) {
849
- return $this->page->setField(new SimpleById($id), $value);
850
- }
851
-
852
- /**
853
- * Accessor for a form element value within the page.
854
- * Finds the first match.
855
- * @param string $label Field label.
856
- * @return string/boolean A value if the field is
857
- * present, false if unchecked
858
- * and null if missing.
859
- * @access public
860
- */
861
- function getField($label) {
862
- return $this->page->getField(new SimpleByLabelOrName($label));
863
- }
864
-
865
- /**
866
- * Accessor for a form element value within the page.
867
- * Finds the first match.
868
- * @param string $name Field name.
869
- * @return string/boolean A string if the field is
870
- * present, false if unchecked
871
- * and null if missing.
872
- * @access public
873
- */
874
- function getFieldByName($name) {
875
- return $this->page->getField(new SimpleByName($name));
876
- }
877
-
878
- /**
879
- * Accessor for a form element value within the page.
880
- * @param string/integer $id Id of field in forms.
881
- * @return string/boolean A string if the field is
882
- * present, false if unchecked
883
- * and null if missing.
884
- * @access public
885
- */
886
- function getFieldById($id) {
887
- return $this->page->getField(new SimpleById($id));
888
- }
889
-
890
- /**
891
- * Clicks the submit button by label. The owning
892
- * form will be submitted by this.
893
- * @param string $label Button label. An unlabeled
894
- * button can be triggered by 'Submit'.
895
- * @param hash $additional Additional form data.
896
- * @return string/boolean Page on success.
897
- * @access public
898
- */
899
- function clickSubmit($label = 'Submit', $additional = false) {
900
- if (! ($form = $this->page->getFormBySubmit(new SimpleByLabel($label)))) {
901
- return false;
902
- }
903
- $success = $this->load(
904
- $form->getAction(),
905
- $form->submitButton(new SimpleByLabel($label), $additional));
906
- return ($success ? $this->getContent() : $success);
907
- }
908
-
909
- /**
910
- * Clicks the submit button by name attribute. The owning
911
- * form will be submitted by this.
912
- * @param string $name Button name.
913
- * @param hash $additional Additional form data.
914
- * @return string/boolean Page on success.
915
- * @access public
916
- */
917
- function clickSubmitByName($name, $additional = false) {
918
- if (! ($form = $this->page->getFormBySubmit(new SimpleByName($name)))) {
919
- return false;
920
- }
921
- $success = $this->load(
922
- $form->getAction(),
923
- $form->submitButton(new SimpleByName($name), $additional));
924
- return ($success ? $this->getContent() : $success);
925
- }
926
-
927
- /**
928
- * Clicks the submit button by ID attribute of the button
929
- * itself. The owning form will be submitted by this.
930
- * @param string $id Button ID.
931
- * @param hash $additional Additional form data.
932
- * @return string/boolean Page on success.
933
- * @access public
934
- */
935
- function clickSubmitById($id, $additional = false) {
936
- if (! ($form = $this->page->getFormBySubmit(new SimpleById($id)))) {
937
- return false;
938
- }
939
- $success = $this->load(
940
- $form->getAction(),
941
- $form->submitButton(new SimpleById($id), $additional));
942
- return ($success ? $this->getContent() : $success);
943
- }
944
-
945
- /**
946
- * Tests to see if a submit button exists with this
947
- * label.
948
- * @param string $label Button label.
949
- * @return boolean True if present.
950
- * @access public
951
- */
952
- function isSubmit($label) {
953
- return (boolean)$this->page->getFormBySubmit(new SimpleByLabel($label));
954
- }
955
-
956
- /**
957
- * Clicks the submit image by some kind of label. Usually
958
- * the alt tag or the nearest equivalent. The owning
959
- * form will be submitted by this. Clicking outside of
960
- * the boundary of the coordinates will result in
961
- * a failure.
962
- * @param string $label ID attribute of button.
963
- * @param integer $x X-coordinate of imaginary click.
964
- * @param integer $y Y-coordinate of imaginary click.
965
- * @param hash $additional Additional form data.
966
- * @return string/boolean Page on success.
967
- * @access public
968
- */
969
- function clickImage($label, $x = 1, $y = 1, $additional = false) {
970
- if (! ($form = $this->page->getFormByImage(new SimpleByLabel($label)))) {
971
- return false;
972
- }
973
- $success = $this->load(
974
- $form->getAction(),
975
- $form->submitImage(new SimpleByLabel($label), $x, $y, $additional));
976
- return ($success ? $this->getContent() : $success);
977
- }
978
-
979
- /**
980
- * Clicks the submit image by the name. Usually
981
- * the alt tag or the nearest equivalent. The owning
982
- * form will be submitted by this. Clicking outside of
983
- * the boundary of the coordinates will result in
984
- * a failure.
985
- * @param string $name Name attribute of button.
986
- * @param integer $x X-coordinate of imaginary click.
987
- * @param integer $y Y-coordinate of imaginary click.
988
- * @param hash $additional Additional form data.
989
- * @return string/boolean Page on success.
990
- * @access public
991
- */
992
- function clickImageByName($name, $x = 1, $y = 1, $additional = false) {
993
- if (! ($form = $this->page->getFormByImage(new SimpleByName($name)))) {
994
- return false;
995
- }
996
- $success = $this->load(
997
- $form->getAction(),
998
- $form->submitImage(new SimpleByName($name), $x, $y, $additional));
999
- return ($success ? $this->getContent() : $success);
1000
- }
1001
-
1002
- /**
1003
- * Clicks the submit image by ID attribute. The owning
1004
- * form will be submitted by this. Clicking outside of
1005
- * the boundary of the coordinates will result in
1006
- * a failure.
1007
- * @param integer/string $id ID attribute of button.
1008
- * @param integer $x X-coordinate of imaginary click.
1009
- * @param integer $y Y-coordinate of imaginary click.
1010
- * @param hash $additional Additional form data.
1011
- * @return string/boolean Page on success.
1012
- * @access public
1013
- */
1014
- function clickImageById($id, $x = 1, $y = 1, $additional = false) {
1015
- if (! ($form = $this->page->getFormByImage(new SimpleById($id)))) {
1016
- return false;
1017
- }
1018
- $success = $this->load(
1019
- $form->getAction(),
1020
- $form->submitImage(new SimpleById($id), $x, $y, $additional));
1021
- return ($success ? $this->getContent() : $success);
1022
- }
1023
-
1024
- /**
1025
- * Tests to see if an image exists with this
1026
- * title or alt text.
1027
- * @param string $label Image text.
1028
- * @return boolean True if present.
1029
- * @access public
1030
- */
1031
- function isImage($label) {
1032
- return (boolean)$this->page->getFormByImage(new SimpleByLabel($label));
1033
- }
1034
-
1035
- /**
1036
- * Submits a form by the ID.
1037
- * @param string $id The form ID. No submit button value
1038
- * will be sent.
1039
- * @return string/boolean Page on success.
1040
- * @access public
1041
- */
1042
- function submitFormById($id, $additional = false) {
1043
- if (! ($form = $this->page->getFormById($id))) {
1044
- return false;
1045
- }
1046
- $success = $this->load(
1047
- $form->getAction(),
1048
- $form->submit($additional));
1049
- return ($success ? $this->getContent() : $success);
1050
- }
1051
-
1052
- /**
1053
- * Finds a URL by label. Will find the first link
1054
- * found with this link text by default, or a later
1055
- * one if an index is given. The match ignores case and
1056
- * white space issues.
1057
- * @param string $label Text between the anchor tags.
1058
- * @param integer $index Link position counting from zero.
1059
- * @return string/boolean URL on success.
1060
- * @access public
1061
- */
1062
- function getLink($label, $index = 0) {
1063
- $urls = $this->page->getUrlsByLabel($label);
1064
- if (count($urls) == 0) {
1065
- return false;
1066
- }
1067
- if (count($urls) < $index + 1) {
1068
- return false;
1069
- }
1070
- return $urls[$index];
1071
- }
1072
-
1073
- /**
1074
- * Follows a link by label. Will click the first link
1075
- * found with this link text by default, or a later
1076
- * one if an index is given. The match ignores case and
1077
- * white space issues.
1078
- * @param string $label Text between the anchor tags.
1079
- * @param integer $index Link position counting from zero.
1080
- * @return string/boolean Page on success.
1081
- * @access public
1082
- */
1083
- function clickLink($label, $index = 0) {
1084
- $url = $this->getLink($label, $index);
1085
- if ($url === false) {
1086
- return false;
1087
- }
1088
- $this->load($url, new SimpleGetEncoding());
1089
- return $this->getContent();
1090
- }
1091
-
1092
- /**
1093
- * Finds a link by id attribute.
1094
- * @param string $id ID attribute value.
1095
- * @return string/boolean URL on success.
1096
- * @access public
1097
- */
1098
- function getLinkById($id) {
1099
- return $this->page->getUrlById($id);
1100
- }
1101
-
1102
- /**
1103
- * Follows a link by id attribute.
1104
- * @param string $id ID attribute value.
1105
- * @return string/boolean Page on success.
1106
- * @access public
1107
- */
1108
- function clickLinkById($id) {
1109
- if (! ($url = $this->getLinkById($id))) {
1110
- return false;
1111
- }
1112
- $this->load($url, new SimpleGetEncoding());
1113
- return $this->getContent();
1114
- }
1115
-
1116
- /**
1117
- * Clicks a visible text item. Will first try buttons,
1118
- * then links and then images.
1119
- * @param string $label Visible text or alt text.
1120
- * @return string/boolean Raw page or false.
1121
- * @access public
1122
- */
1123
- function click($label) {
1124
- $raw = $this->clickSubmit($label);
1125
- if (! $raw) {
1126
- $raw = $this->clickLink($label);
1127
- }
1128
- if (! $raw) {
1129
- $raw = $this->clickImage($label);
1130
- }
1131
- return $raw;
1132
- }
1133
-
1134
- /**
1135
- * Tests to see if a click target exists.
1136
- * @param string $label Visible text or alt text.
1137
- * @return boolean True if target present.
1138
- * @access public
1139
- */
1140
- function isClickable($label) {
1141
- return $this->isSubmit($label) || ($this->getLink($label) !== false) || $this->isImage($label);
1142
- }
1143
- }
1144
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/collector.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
- /**
3
- * This file contains the following classes: {@link SimpleCollector},
4
- * {@link SimplePatternCollector}.
5
- *
6
- * @author Travis Swicegood <development@domain51.com>
7
- * @package SimpleTest
8
- * @subpackage UnitTester
9
- * @version $Id: collector.php 2011 2011-04-29 08:22:48Z pp11 $
10
- */
11
-
12
- /**
13
- * The basic collector for {@link GroupTest}
14
- *
15
- * @see collect(), GroupTest::collect()
16
- * @package SimpleTest
17
- * @subpackage UnitTester
18
- */
19
- class SimpleCollector {
20
-
21
- /**
22
- * Strips off any kind of slash at the end so as to normalise the path.
23
- * @param string $path Path to normalise.
24
- * @return string Path without trailing slash.
25
- */
26
- protected function removeTrailingSlash($path) {
27
- if (substr($path, -1) == DIRECTORY_SEPARATOR) {
28
- return substr($path, 0, -1);
29
- } elseif (substr($path, -1) == '/') {
30
- return substr($path, 0, -1);
31
- } else {
32
- return $path;
33
- }
34
- }
35
-
36
- /**
37
- * Scans the directory and adds what it can.
38
- * @param object $test Group test with {@link GroupTest::addTestFile()} method.
39
- * @param string $path Directory to scan.
40
- * @see _attemptToAdd()
41
- */
42
- function collect(&$test, $path) {
43
- $path = $this->removeTrailingSlash($path);
44
- if ($handle = opendir($path)) {
45
- while (($entry = readdir($handle)) !== false) {
46
- if ($this->isHidden($entry)) {
47
- continue;
48
- }
49
- $this->handle($test, $path . DIRECTORY_SEPARATOR . $entry);
50
- }
51
- closedir($handle);
52
- }
53
- }
54
-
55
- /**
56
- * This method determines what should be done with a given file and adds
57
- * it via {@link GroupTest::addTestFile()} if necessary.
58
- *
59
- * This method should be overriden to provide custom matching criteria,
60
- * such as pattern matching, recursive matching, etc. For an example, see
61
- * {@link SimplePatternCollector::_handle()}.
62
- *
63
- * @param object $test Group test with {@link GroupTest::addTestFile()} method.
64
- * @param string $filename A filename as generated by {@link collect()}
65
- * @see collect()
66
- * @access protected
67
- */
68
- protected function handle(&$test, $file) {
69
- if (is_dir($file)) {
70
- return;
71
- }
72
- $test->addFile($file);
73
- }
74
-
75
- /**
76
- * Tests for hidden files so as to skip them. Currently
77
- * only tests for Unix hidden files.
78
- * @param string $filename Plain filename.
79
- * @return boolean True if hidden file.
80
- * @access private
81
- */
82
- protected function isHidden($filename) {
83
- return strncmp($filename, '.', 1) == 0;
84
- }
85
- }
86
-
87
- /**
88
- * An extension to {@link SimpleCollector} that only adds files matching a
89
- * given pattern.
90
- *
91
- * @package SimpleTest
92
- * @subpackage UnitTester
93
- * @see SimpleCollector
94
- */
95
- class SimplePatternCollector extends SimpleCollector {
96
- private $pattern;
97
-
98
- /**
99
- *
100
- * @param string $pattern Perl compatible regex to test name against
101
- * See {@link http://us4.php.net/manual/en/reference.pcre.pattern.syntax.php PHP's PCRE}
102
- * for full documentation of valid pattern.s
103
- */
104
- function __construct($pattern = '/php$/i') {
105
- $this->pattern = $pattern;
106
- }
107
-
108
- /**
109
- * Attempts to add files that match a given pattern.
110
- *
111
- * @see SimpleCollector::_handle()
112
- * @param object $test Group test with {@link GroupTest::addTestFile()} method.
113
- * @param string $path Directory to scan.
114
- * @access protected
115
- */
116
- protected function handle(&$test, $filename) {
117
- if (preg_match($this->pattern, $filename)) {
118
- parent::handle($test, $filename);
119
- }
120
- }
121
- }
122
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/compatibility.php DELETED
@@ -1,166 +0,0 @@
1
- <?php
2
- /**
3
- * base include file for SimpleTest
4
- * @package SimpleTest
5
- * @version $Id: compatibility.php 1900 2009-07-29 11:44:37Z lastcraft $
6
- */
7
-
8
- /**
9
- * Static methods for compatibility between different
10
- * PHP versions.
11
- * @package SimpleTest
12
- */
13
- class SimpleTestCompatibility {
14
-
15
- /**
16
- * Creates a copy whether in PHP5 or PHP4.
17
- * @param object $object Thing to copy.
18
- * @return object A copy.
19
- * @access public
20
- */
21
- static function copy($object) {
22
- if (version_compare(phpversion(), '5') >= 0) {
23
- eval('$copy = clone $object;');
24
- return $copy;
25
- }
26
- return $object;
27
- }
28
-
29
- /**
30
- * Identity test. Drops back to equality + types for PHP5
31
- * objects as the === operator counts as the
32
- * stronger reference constraint.
33
- * @param mixed $first Test subject.
34
- * @param mixed $second Comparison object.
35
- * @return boolean True if identical.
36
- * @access public
37
- */
38
- static function isIdentical($first, $second) {
39
- if (version_compare(phpversion(), '5') >= 0) {
40
- return SimpleTestCompatibility::isIdenticalType($first, $second);
41
- }
42
- if ($first != $second) {
43
- return false;
44
- }
45
- return ($first === $second);
46
- }
47
-
48
- /**
49
- * Recursive type test.
50
- * @param mixed $first Test subject.
51
- * @param mixed $second Comparison object.
52
- * @return boolean True if same type.
53
- * @access private
54
- */
55
- protected static function isIdenticalType($first, $second) {
56
- if (gettype($first) != gettype($second)) {
57
- return false;
58
- }
59
- if (is_object($first) && is_object($second)) {
60
- if (get_class($first) != get_class($second)) {
61
- return false;
62
- }
63
- return SimpleTestCompatibility::isArrayOfIdenticalTypes(
64
- (array) $first,
65
- (array) $second);
66
- }
67
- if (is_array($first) && is_array($second)) {
68
- return SimpleTestCompatibility::isArrayOfIdenticalTypes($first, $second);
69
- }
70
- if ($first !== $second) {
71
- return false;
72
- }
73
- return true;
74
- }
75
-
76
- /**
77
- * Recursive type test for each element of an array.
78
- * @param mixed $first Test subject.
79
- * @param mixed $second Comparison object.
80
- * @return boolean True if identical.
81
- * @access private
82
- */
83
- protected static function isArrayOfIdenticalTypes($first, $second) {
84
- if (array_keys($first) != array_keys($second)) {
85
- return false;
86
- }
87
- foreach (array_keys($first) as $key) {
88
- $is_identical = SimpleTestCompatibility::isIdenticalType(
89
- $first[$key],
90
- $second[$key]);
91
- if (! $is_identical) {
92
- return false;
93
- }
94
- }
95
- return true;
96
- }
97
-
98
- /**
99
- * Test for two variables being aliases.
100
- * @param mixed $first Test subject.
101
- * @param mixed $second Comparison object.
102
- * @return boolean True if same.
103
- * @access public
104
- */
105
- static function isReference(&$first, &$second) {
106
- if (version_compare(phpversion(), '5', '>=') && is_object($first)) {
107
- return ($first === $second);
108
- }
109
- if (is_object($first) && is_object($second)) {
110
- $id = uniqid("test");
111
- $first->$id = true;
112
- $is_ref = isset($second->$id);
113
- unset($first->$id);
114
- return $is_ref;
115
- }
116
- $temp = $first;
117
- $first = uniqid("test");
118
- $is_ref = ($first === $second);
119
- $first = $temp;
120
- return $is_ref;
121
- }
122
-
123
- /**
124
- * Test to see if an object is a member of a
125
- * class hiearchy.
126
- * @param object $object Object to test.
127
- * @param string $class Root name of hiearchy.
128
- * @return boolean True if class in hiearchy.
129
- * @access public
130
- */
131
- static function isA($object, $class) {
132
- if (version_compare(phpversion(), '5') >= 0) {
133
- if (! class_exists($class, false)) {
134
- if (function_exists('interface_exists')) {
135
- if (! interface_exists($class, false)) {
136
- return false;
137
- }
138
- }
139
- }
140
- eval("\$is_a = \$object instanceof $class;");
141
- return $is_a;
142
- }
143
- if (function_exists('is_a')) {
144
- return is_a($object, $class);
145
- }
146
- return ((strtolower($class) == get_class($object))
147
- or (is_subclass_of($object, $class)));
148
- }
149
-
150
- /**
151
- * Sets a socket timeout for each chunk.
152
- * @param resource $handle Socket handle.
153
- * @param integer $timeout Limit in seconds.
154
- * @access public
155
- */
156
- static function setTimeout($handle, $timeout) {
157
- if (function_exists('stream_set_timeout')) {
158
- stream_set_timeout($handle, $timeout, 0);
159
- } elseif (function_exists('socket_set_timeout')) {
160
- socket_set_timeout($handle, $timeout, 0);
161
- } elseif (function_exists('set_socket_timeout')) {
162
- set_socket_timeout($handle, $timeout, 0);
163
- }
164
- }
165
- }
166
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/cookies.php DELETED
@@ -1,380 +0,0 @@
1
- <?php
2
- /**
3
- * Base include file for SimpleTest
4
- * @package SimpleTest
5
- * @subpackage WebTester
6
- * @version $Id: cookies.php 2011 2011-04-29 08:22:48Z pp11 $
7
- */
8
-
9
- /**#@+
10
- * include other SimpleTest class files
11
- */
12
- require_once(dirname(__FILE__) . '/url.php');
13
- /**#@-*/
14
-
15
- /**
16
- * Cookie data holder. Cookie rules are full of pretty
17
- * arbitary stuff. I have used...
18
- * http://wp.netscape.com/newsref/std/cookie_spec.html
19
- * http://www.cookiecentral.com/faq/
20
- * @package SimpleTest
21
- * @subpackage WebTester
22
- */
23
- class SimpleCookie {
24
- private $host;
25
- private $name;
26
- private $value;
27
- private $path;
28
- private $expiry;
29
- private $is_secure;
30
-
31
- /**
32
- * Constructor. Sets the stored values.
33
- * @param string $name Cookie key.
34
- * @param string $value Value of cookie.
35
- * @param string $path Cookie path if not host wide.
36
- * @param string $expiry Expiry date as string.
37
- * @param boolean $is_secure Currently ignored.
38
- */
39
- function __construct($name, $value = false, $path = false, $expiry = false, $is_secure = false) {
40
- $this->host = false;
41
- $this->name = $name;
42
- $this->value = $value;
43
- $this->path = ($path ? $this->fixPath($path) : "/");
44
- $this->expiry = false;
45
- if (is_string($expiry)) {
46
- $this->expiry = strtotime($expiry);
47
- } elseif (is_integer($expiry)) {
48
- $this->expiry = $expiry;
49
- }
50
- $this->is_secure = $is_secure;
51
- }
52
-
53
- /**
54
- * Sets the host. The cookie rules determine
55
- * that the first two parts are taken for
56
- * certain TLDs and three for others. If the
57
- * new host does not match these rules then the
58
- * call will fail.
59
- * @param string $host New hostname.
60
- * @return boolean True if hostname is valid.
61
- * @access public
62
- */
63
- function setHost($host) {
64
- if ($host = $this->truncateHost($host)) {
65
- $this->host = $host;
66
- return true;
67
- }
68
- return false;
69
- }
70
-
71
- /**
72
- * Accessor for the truncated host to which this
73
- * cookie applies.
74
- * @return string Truncated hostname.
75
- * @access public
76
- */
77
- function getHost() {
78
- return $this->host;
79
- }
80
-
81
- /**
82
- * Test for a cookie being valid for a host name.
83
- * @param string $host Host to test against.
84
- * @return boolean True if the cookie would be valid
85
- * here.
86
- */
87
- function isValidHost($host) {
88
- return ($this->truncateHost($host) === $this->getHost());
89
- }
90
-
91
- /**
92
- * Extracts just the domain part that determines a
93
- * cookie's host validity.
94
- * @param string $host Host name to truncate.
95
- * @return string Domain or false on a bad host.
96
- * @access private
97
- */
98
- protected function truncateHost($host) {
99
- $tlds = SimpleUrl::getAllTopLevelDomains();
100
- if (preg_match('/[a-z\-]+\.(' . $tlds . ')$/i', $host, $matches)) {
101
- return $matches[0];
102
- } elseif (preg_match('/[a-z\-]+\.[a-z\-]+\.[a-z\-]+$/i', $host, $matches)) {
103
- return $matches[0];
104
- }
105
- return false;
106
- }
107
-
108
- /**
109
- * Accessor for name.
110
- * @return string Cookie key.
111
- * @access public
112
- */
113
- function getName() {
114
- return $this->name;
115
- }
116
-
117
- /**
118
- * Accessor for value. A deleted cookie will
119
- * have an empty string for this.
120
- * @return string Cookie value.
121
- * @access public
122
- */
123
- function getValue() {
124
- return $this->value;
125
- }
126
-
127
- /**
128
- * Accessor for path.
129
- * @return string Valid cookie path.
130
- * @access public
131
- */
132
- function getPath() {
133
- return $this->path;
134
- }
135
-
136
- /**
137
- * Tests a path to see if the cookie applies
138
- * there. The test path must be longer or
139
- * equal to the cookie path.
140
- * @param string $path Path to test against.
141
- * @return boolean True if cookie valid here.
142
- * @access public
143
- */
144
- function isValidPath($path) {
145
- return (strncmp(
146
- $this->fixPath($path),
147
- $this->getPath(),
148
- strlen($this->getPath())) == 0);
149
- }
150
-
151
- /**
152
- * Accessor for expiry.
153
- * @return string Expiry string.
154
- * @access public
155
- */
156
- function getExpiry() {
157
- if (! $this->expiry) {
158
- return false;
159
- }
160
- return gmdate("D, d M Y H:i:s", $this->expiry) . " GMT";
161
- }
162
-
163
- /**
164
- * Test to see if cookie is expired against
165
- * the cookie format time or timestamp.
166
- * Will give true for a session cookie.
167
- * @param integer/string $now Time to test against. Result
168
- * will be false if this time
169
- * is later than the cookie expiry.
170
- * Can be either a timestamp integer
171
- * or a cookie format date.
172
- * @access public
173
- */
174
- function isExpired($now) {
175
- if (! $this->expiry) {
176
- return true;
177
- }
178
- if (is_string($now)) {
179
- $now = strtotime($now);
180
- }
181
- return ($this->expiry < $now);
182
- }
183
-
184
- /**
185
- * Ages the cookie by the specified number of
186
- * seconds.
187
- * @param integer $interval In seconds.
188
- * @public
189
- */
190
- function agePrematurely($interval) {
191
- if ($this->expiry) {
192
- $this->expiry -= $interval;
193
- }
194
- }
195
-
196
- /**
197
- * Accessor for the secure flag.
198
- * @return boolean True if cookie needs SSL.
199
- * @access public
200
- */
201
- function isSecure() {
202
- return $this->is_secure;
203
- }
204
-
205
- /**
206
- * Adds a trailing and leading slash to the path
207
- * if missing.
208
- * @param string $path Path to fix.
209
- * @access private
210
- */
211
- protected function fixPath($path) {
212
- if (substr($path, 0, 1) != '/') {
213
- $path = '/' . $path;
214
- }
215
- if (substr($path, -1, 1) != '/') {
216
- $path .= '/';
217
- }
218
- return $path;
219
- }
220
- }
221
-
222
- /**
223
- * Repository for cookies. This stuff is a
224
- * tiny bit browser dependent.
225
- * @package SimpleTest
226
- * @subpackage WebTester
227
- */
228
- class SimpleCookieJar {
229
- private $cookies;
230
-
231
- /**
232
- * Constructor. Jar starts empty.
233
- * @access public
234
- */
235
- function __construct() {
236
- $this->cookies = array();
237
- }
238
-
239
- /**
240
- * Removes expired and temporary cookies as if
241
- * the browser was closed and re-opened.
242
- * @param string/integer $now Time to test expiry against.
243
- * @access public
244
- */
245
- function restartSession($date = false) {
246
- $surviving_cookies = array();
247
- for ($i = 0; $i < count($this->cookies); $i++) {
248
- if (! $this->cookies[$i]->getValue()) {
249
- continue;
250
- }
251
- if (! $this->cookies[$i]->getExpiry()) {
252
- continue;
253
- }
254
- if ($date && $this->cookies[$i]->isExpired($date)) {
255
- continue;
256
- }
257
- $surviving_cookies[] = $this->cookies[$i];
258
- }
259
- $this->cookies = $surviving_cookies;
260
- }
261
-
262
- /**
263
- * Ages all cookies in the cookie jar.
264
- * @param integer $interval The old session is moved
265
- * into the past by this number
266
- * of seconds. Cookies now over
267
- * age will be removed.
268
- * @access public
269
- */
270
- function agePrematurely($interval) {
271
- for ($i = 0; $i < count($this->cookies); $i++) {
272
- $this->cookies[$i]->agePrematurely($interval);
273
- }
274
- }
275
-
276
- /**
277
- * Sets an additional cookie. If a cookie has
278
- * the same name and path it is replaced.
279
- * @param string $name Cookie key.
280
- * @param string $value Value of cookie.
281
- * @param string $host Host upon which the cookie is valid.
282
- * @param string $path Cookie path if not host wide.
283
- * @param string $expiry Expiry date.
284
- * @access public
285
- */
286
- function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
287
- $cookie = new SimpleCookie($name, $value, $path, $expiry);
288
- if ($host) {
289
- $cookie->setHost($host);
290
- }
291
- $this->cookies[$this->findFirstMatch($cookie)] = $cookie;
292
- }
293
-
294
- /**
295
- * Finds a matching cookie to write over or the
296
- * first empty slot if none.
297
- * @param SimpleCookie $cookie Cookie to write into jar.
298
- * @return integer Available slot.
299
- * @access private
300
- */
301
- protected function findFirstMatch($cookie) {
302
- for ($i = 0; $i < count($this->cookies); $i++) {
303
- $is_match = $this->isMatch(
304
- $cookie,
305
- $this->cookies[$i]->getHost(),
306
- $this->cookies[$i]->getPath(),
307
- $this->cookies[$i]->getName());
308
- if ($is_match) {
309
- return $i;
310
- }
311
- }
312
- return count($this->cookies);
313
- }
314
-
315
- /**
316
- * Reads the most specific cookie value from the
317
- * browser cookies. Looks for the longest path that
318
- * matches.
319
- * @param string $host Host to search.
320
- * @param string $path Applicable path.
321
- * @param string $name Name of cookie to read.
322
- * @return string False if not present, else the
323
- * value as a string.
324
- * @access public
325
- */
326
- function getCookieValue($host, $path, $name) {
327
- $longest_path = '';
328
- foreach ($this->cookies as $cookie) {
329
- if ($this->isMatch($cookie, $host, $path, $name)) {
330
- if (strlen($cookie->getPath()) > strlen($longest_path)) {
331
- $value = $cookie->getValue();
332
- $longest_path = $cookie->getPath();
333
- }
334
- }
335
- }
336
- return (isset($value) ? $value : false);
337
- }
338
-
339
- /**
340
- * Tests cookie for matching against search
341
- * criteria.
342
- * @param SimpleTest $cookie Cookie to test.
343
- * @param string $host Host must match.
344
- * @param string $path Cookie path must be shorter than
345
- * this path.
346
- * @param string $name Name must match.
347
- * @return boolean True if matched.
348
- * @access private
349
- */
350
- protected function isMatch($cookie, $host, $path, $name) {
351
- if ($cookie->getName() != $name) {
352
- return false;
353
- }
354
- if ($host && $cookie->getHost() && ! $cookie->isValidHost($host)) {
355
- return false;
356
- }
357
- if (! $cookie->isValidPath($path)) {
358
- return false;
359
- }
360
- return true;
361
- }
362
-
363
- /**
364
- * Uses a URL to sift relevant cookies by host and
365
- * path. Results are list of strings of form "name=value".
366
- * @param SimpleUrl $url Url to select by.
367
- * @return array Valid name and value pairs.
368
- * @access public
369
- */
370
- function selectAsPairs($url) {
371
- $pairs = array();
372
- foreach ($this->cookies as $cookie) {
373
- if ($this->isMatch($cookie, $url->getHost(), $url->getPath(), $cookie->getName())) {
374
- $pairs[] = $cookie->getName() . '=' . $cookie->getValue();
375
- }
376
- }
377
- return $pairs;
378
- }
379
- }
380
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/default_reporter.php DELETED
@@ -1,163 +0,0 @@
1
- <?php
2
- /**
3
- * Optional include file for SimpleTest
4
- * @package SimpleTest
5
- * @subpackage UnitTester
6
- * @version $Id: default_reporter.php 2011 2011-04-29 08:22:48Z pp11 $
7
- */
8
-
9
- /**#@+
10
- * include other SimpleTest class files
11
- */
12
- require_once(dirname(__FILE__) . '/simpletest.php');
13
- require_once(dirname(__FILE__) . '/scorer.php');
14
- require_once(dirname(__FILE__) . '/reporter.php');
15
- require_once(dirname(__FILE__) . '/xml.php');
16
- /**#@-*/
17
-
18
- /**
19
- * Parser for command line arguments. Extracts
20
- * the a specific test to run and engages XML
21
- * reporting when necessary.
22
- * @package SimpleTest
23
- * @subpackage UnitTester
24
- */
25
- class SimpleCommandLineParser {
26
- private $to_property = array(
27
- 'case' => 'case', 'c' => 'case',
28
- 'test' => 'test', 't' => 'test',
29
- );
30
- private $case = '';
31
- private $test = '';
32
- private $xml = false;
33
- private $help = false;
34
- private $no_skips = false;
35
-
36
- /**
37
- * Parses raw command line arguments into object properties.
38
- * @param string $arguments Raw commend line arguments.
39
- */
40
- function __construct($arguments) {
41
- if (! is_array($arguments)) {
42
- return;
43
- }
44
- foreach ($arguments as $i => $argument) {
45
- if (preg_match('/^--?(test|case|t|c)=(.+)$/', $argument, $matches)) {
46
- $property = $this->to_property[$matches[1]];
47
- $this->$property = $matches[2];
48
- } elseif (preg_match('/^--?(test|case|t|c)$/', $argument, $matches)) {
49
- $property = $this->to_property[$matches[1]];
50
- if (isset($arguments[$i + 1])) {
51
- $this->$property = $arguments[$i + 1];
52
- }
53
- } elseif (preg_match('/^--?(xml|x)$/', $argument)) {
54
- $this->xml = true;
55
- } elseif (preg_match('/^--?(no-skip|no-skips|s)$/', $argument)) {
56
- $this->no_skips = true;
57
- } elseif (preg_match('/^--?(help|h)$/', $argument)) {
58
- $this->help = true;
59
- }
60
- }
61
- }
62
-
63
- /**
64
- * Run only this test.
65
- * @return string Test name to run.
66
- */
67
- function getTest() {
68
- return $this->test;
69
- }
70
-
71
- /**
72
- * Run only this test suite.
73
- * @return string Test class name to run.
74
- */
75
- function getTestCase() {
76
- return $this->case;
77
- }
78
-
79
- /**
80
- * Output should be XML or not.
81
- * @return boolean True if XML desired.
82
- */
83
- function isXml() {
84
- return $this->xml;
85
- }
86
-
87
- /**
88
- * Output should suppress skip messages.
89
- * @return boolean True for no skips.
90
- */
91
- function noSkips() {
92
- return $this->no_skips;
93
- }
94
-
95
- /**
96
- * Output should be a help message. Disabled during XML mode.
97
- * @return boolean True if help message desired.
98
- */
99
- function help() {
100
- return $this->help && ! $this->xml;
101
- }
102
-
103
- /**
104
- * Returns plain-text help message for command line runner.
105
- * @return string String help message
106
- */
107
- function getHelpText() {
108
- return <<<HELP
109
- SimpleTest command line default reporter (autorun)
110
- Usage: php <test_file> [args...]
111
-
112
- -c <class> Run only the test-case <class>
113
- -t <method> Run only the test method <method>
114
- -s Suppress skip messages
115
- -x Return test results in XML
116
- -h Display this help message
117
-
118
- HELP;
119
- }
120
-
121
- }
122
-
123
- /**
124
- * The default reporter used by SimpleTest's autorun
125
- * feature. The actual reporters used are dependency
126
- * injected and can be overridden.
127
- * @package SimpleTest
128
- * @subpackage UnitTester
129
- */
130
- class DefaultReporter extends SimpleReporterDecorator {
131
-
132
- /**
133
- * Assembles the appropriate reporter for the environment.
134
- */
135
- function __construct() {
136
- if (SimpleReporter::inCli()) {
137
- $parser = new SimpleCommandLineParser($_SERVER['argv']);
138
- $interfaces = $parser->isXml() ? array('XmlReporter') : array('TextReporter');
139
- if ($parser->help()) {
140
- // I'm not sure if we should do the echo'ing here -- ezyang
141
- echo $parser->getHelpText();
142
- exit(1);
143
- }
144
- $reporter = new SelectiveReporter(
145
- SimpleTest::preferred($interfaces),
146
- $parser->getTestCase(),
147
- $parser->getTest());
148
- if ($parser->noSkips()) {
149
- $reporter = new NoSkipsReporter($reporter);
150
- }
151
- } else {
152
- $reporter = new SelectiveReporter(
153
- SimpleTest::preferred('HtmlReporter'),
154
- @$_GET['c'],
155
- @$_GET['t']);
156
- if (@$_GET['skips'] == 'no' || @$_GET['show-skips'] == 'no') {
157
- $reporter = new NoSkipsReporter($reporter);
158
- }
159
- }
160
- parent::__construct($reporter);
161
- }
162
- }
163
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/detached.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- /**
3
- * base include file for SimpleTest
4
- * @package SimpleTest
5
- * @subpackage UnitTester
6
- * @version $Id: detached.php 1784 2008-04-26 13:07:14Z pp11 $
7
- */
8
-
9
- /**#@+
10
- * include other SimpleTest class files
11
- */
12
- require_once(dirname(__FILE__) . '/xml.php');
13
- require_once(dirname(__FILE__) . '/shell_tester.php');
14
- /**#@-*/
15
-
16
- /**
17
- * Runs an XML formated test in a separate process.
18
- * @package SimpleTest
19
- * @subpackage UnitTester
20
- */
21
- class DetachedTestCase {
22
- private $command;
23
- private $dry_command;
24
- private $size;
25
-
26
- /**
27
- * Sets the location of the remote test.
28
- * @param string $command Test script.
29
- * @param string $dry_command Script for dry run.
30
- * @access public
31
- */
32
- function __construct($command, $dry_command = false) {
33
- $this->command = $command;
34
- $this->dry_command = $dry_command ? $dry_command : $command;
35
- $this->size = false;
36
- }
37
-
38
- /**
39
- * Accessor for the test name for subclasses.
40
- * @return string Name of the test.
41
- * @access public
42
- */
43
- function getLabel() {
44
- return $this->command;
45
- }
46
-
47
- /**
48
- * Runs the top level test for this class. Currently
49
- * reads the data as a single chunk. I'll fix this
50
- * once I have added iteration to the browser.
51
- * @param SimpleReporter $reporter Target of test results.
52
- * @returns boolean True if no failures.
53
- * @access public
54
- */
55
- function run(&$reporter) {
56
- $shell = &new SimpleShell();
57
- $shell->execute($this->command);
58
- $parser = &$this->createParser($reporter);
59
- if (! $parser->parse($shell->getOutput())) {
60
- trigger_error('Cannot parse incoming XML from [' . $this->command . ']');
61
- return false;
62
- }
63
- return true;
64
- }
65
-
66
- /**
67
- * Accessor for the number of subtests.
68
- * @return integer Number of test cases.
69
- * @access public
70
- */
71
- function getSize() {
72
- if ($this->size === false) {
73
- $shell = &new SimpleShell();
74
- $shell->execute($this->dry_command);
75
- $reporter = &new SimpleReporter();
76
- $parser = &$this->createParser($reporter);
77
- if (! $parser->parse($shell->getOutput())) {
78
- trigger_error('Cannot parse incoming XML from [' . $this->dry_command . ']');
79
- return false;
80
- }
81
- $this->size = $reporter->getTestCaseCount();
82
- }
83
- return $this->size;
84
- }
85
-
86
- /**
87
- * Creates the XML parser.
88
- * @param SimpleReporter $reporter Target of test results.
89
- * @return SimpleTestXmlListener XML reader.
90
- * @access protected
91
- */
92
- protected function &createParser(&$reporter) {
93
- return new SimpleTestXmlParser($reporter);
94
- }
95
- }
96
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/authentication_documentation.html DELETED
@@ -1,378 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
- <title>SimpleTest documentation for testing log-in and authentication</title>
5
- <link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
6
- </head>
7
- <body>
8
- <div class="menu_back"><div class="menu">
9
- <a href="index.html">SimpleTest</a>
10
- |
11
- <a href="overview.html">Overview</a>
12
- |
13
- <a href="unit_test_documentation.html">Unit tester</a>
14
- |
15
- <a href="group_test_documentation.html">Group tests</a>
16
- |
17
- <a href="mock_objects_documentation.html">Mock objects</a>
18
- |
19
- <a href="partial_mocks_documentation.html">Partial mocks</a>
20
- |
21
- <a href="reporter_documentation.html">Reporting</a>
22
- |
23
- <a href="expectation_documentation.html">Expectations</a>
24
- |
25
- <a href="web_tester_documentation.html">Web tester</a>
26
- |
27
- <a href="form_testing_documentation.html">Testing forms</a>
28
- |
29
- <span class="chosen">Authentication</span>
30
- |
31
- <a href="browser_documentation.html">Scriptable browser</a>
32
- </div></div>
33
- <h1>Authentication documentation</h1>
34
- This page...
35
- <ul>
36
- <li>
37
- Getting through <a href="#basic">Basic HTTP authentication</a>
38
- </li>
39
- <li>
40
- Testing <a href="#cookies">cookie based authentication</a>
41
- </li>
42
- <li>
43
- Managing <a href="#session">browser sessions</a> and timeouts
44
- </li>
45
- </ul>
46
- <div class="content">
47
-
48
- <p>
49
- One of the trickiest, and yet most important, areas
50
- of testing web sites is the security.
51
- Testing these schemes is one of the core goals of
52
- the SimpleTest web tester.
53
- </p>
54
-
55
- <h2>
56
- <a class="target" name="basic"></a>Basic HTTP authentication</h2>
57
- <p>
58
- If you fetch a page protected by basic authentication then
59
- rather than receiving content, you will instead get a 401
60
- header.
61
- We can illustrate this with this test...
62
- <pre>
63
- class AuthenticationTest extends WebTestCase {<strong>
64
- function test401Header() {
65
- $this-&gt;get('http://www.lastcraft.com/protected/');
66
- $this-&gt;showHeaders();
67
- }</strong>
68
- }
69
- </pre>
70
- This allows us to see the challenge header...
71
- <div class="demo">
72
- <h1>File test</h1>
73
- <pre>
74
- HTTP/1.1 401 Authorization Required
75
- Date: Sat, 18 Sep 2004 19:25:18 GMT
76
- Server: Apache/1.3.29 (Unix) PHP/4.3.4
77
- WWW-Authenticate: Basic realm="SimpleTest basic authentication"
78
- Connection: close
79
- Content-Type: text/html; charset=iso-8859-1
80
- </pre>
81
- <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
82
- <strong>0</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
83
- </div>
84
- We are trying to get away from visual inspection though, and so SimpleTest
85
- allows to make automated assertions against the challenge.
86
- Here is a thorough test of our header...
87
- <pre>
88
- class AuthenticationTest extends WebTestCase {
89
- function test401Header() {
90
- $this-&gt;get('http://www.lastcraft.com/protected/');<strong>
91
- $this-&gt;assertAuthentication('Basic');
92
- $this-&gt;assertResponse(401);
93
- $this-&gt;assertRealm('SimpleTest basic authentication');</strong>
94
- }
95
- }
96
- </pre>
97
- Any one of these tests would normally do on it's own depending
98
- on the amount of detail you want to see.
99
- </p>
100
- <p>
101
- One theme that runs through SimpleTest is the ability to use
102
- <span class="new_code">SimpleExpectation</span> objects wherever a simple
103
- match is not enough.
104
- If you want only an approximate match to the realm for
105
- example, you can do this...
106
- <pre>
107
- class AuthenticationTest extends WebTestCase {
108
- function test401Header() {
109
- $this-&gt;get('http://www.lastcraft.com/protected/');
110
- $this-&gt;assertRealm(<strong>new PatternExpectation('/simpletest/i')</strong>);
111
- }
112
- }
113
- </pre>
114
- This type of test, testing HTTP responses, is not typical.
115
- </p>
116
- <p>
117
- Most of the time we are not interested in testing the
118
- authentication itself, but want to get past it to test
119
- the pages underneath.
120
- As soon as the challenge has been issued we can reply with
121
- an authentication response...
122
- <pre>
123
- class AuthenticationTest extends WebTestCase {
124
- function testCanAuthenticate() {
125
- $this-&gt;get('http://www.lastcraft.com/protected/');<strong>
126
- $this-&gt;authenticate('Me', 'Secret');</strong>
127
- $this-&gt;assertTitle(...);
128
- }
129
- }
130
- </pre>
131
- The username and password will now be sent with every
132
- subsequent request to that directory and subdirectories.
133
- You will have to authenticate again if you step outside
134
- the authenticated directory, but SimpleTest is smart enough
135
- to merge subdirectories into a common realm.
136
- </p>
137
- <p>
138
- If you want, you can shortcut this step further by encoding
139
- the log in details straight into the URL...
140
- <pre>
141
- class AuthenticationTest extends WebTestCase {
142
- function testCanReadAuthenticatedPages() {
143
- $this-&gt;get('http://<strong>Me:Secret@</strong>www.lastcraft.com/protected/');
144
- $this-&gt;assertTitle(...);
145
- }
146
- }
147
- </pre>
148
- If your username or password has special characters, then you
149
- will have to URL encode them or the request will not be parsed
150
- correctly.
151
- I'm afraid we leave this up to you.
152
- </p>
153
- <p>
154
- A problem with encoding the login details directly in the URL is
155
- the authentication header will not be sent on subsequent requests.
156
- If you navigate with relative URLs though, the authentication
157
- information will be preserved along with the domain name.
158
- </p>
159
- <p>
160
- Normally though, you use the <span class="new_code">authenticate()</span> call.
161
- SimpleTest will then remember your login information on each request.
162
- </p>
163
- <p>
164
- Only testing with basic authentication is currently supported, and
165
- this is only really secure in tandem with HTTPS connections.
166
- This is usually good enough to protect test server from prying eyes,
167
- however.
168
- Digest authentication and NTLM authentication may be added
169
- in the future if enough people request this feature.
170
- </p>
171
-
172
- <h2>
173
- <a class="target" name="cookies"></a>Cookies</h2>
174
- <p>
175
- Basic authentication doesn't give enough control over the
176
- user interface for web developers.
177
- More likely this functionality will be coded directly into
178
- the web architecture using cookies with complicated timeouts.
179
- We need to be able to test this too.
180
- </p>
181
- <p>
182
- Starting with a simple log-in form...
183
- <pre>
184
- &lt;form&gt;
185
- Username:
186
- &lt;input type="text" name="u" value="" /&gt;&lt;br /&gt;
187
- Password:
188
- &lt;input type="password" name="p" value="" /&gt;&lt;br /&gt;
189
- &lt;input type="submit" value="Log in" /&gt;
190
- &lt;/form&gt;
191
- </pre>
192
- Which looks like...
193
- </p>
194
- <p>
195
- <form class="demo">
196
- Username:
197
- <input type="text" name="u" value=""><br>
198
- Password:
199
- <input type="password" name="p" value=""><br>
200
- <input type="submit" value="Log in">
201
- </form>
202
- </p>
203
- <p>
204
- Let's suppose that in fetching this page a cookie has been
205
- set with a session ID.
206
- We are not going to fill the form in yet, just test that
207
- we are tracking the user.
208
- Here is the test...
209
- <pre>
210
- class LogInTest extends WebTestCase {
211
- function testSessionCookieSetBeforeForm() {
212
- $this-&gt;get('http://www.my-site.com/login.php');<strong>
213
- $this-&gt;assertCookie('SID');</strong>
214
- }
215
- }
216
- </pre>
217
- All we are doing is confirming that the cookie is set.
218
- As the value is likely to be rather cryptic it's not
219
- really worth testing this with...
220
- <pre>
221
- class LogInTest extends WebTestCase {
222
- function testSessionCookieIsCorrectPattern() {
223
- $this-&gt;get('http://www.my-site.com/login.php');
224
- $this-&gt;assertCookie('SID', <strong>new PatternExpectation('/[a-f0-9]{32}/i')</strong>);
225
- }
226
- }
227
- </pre>
228
- If you are using PHP to handle sessions for you then
229
- this test is even more useless, as we are just testing PHP itself.
230
- </p>
231
- <p>
232
- The simplest test of logging in is to visually inspect the
233
- next page to see if you are really logged in.
234
- Just test the next page with <span class="new_code">WebTestCase::assertText()</span>.
235
- </p>
236
- <p>
237
- The test is similar to any other form test,
238
- but we might want to confirm that we still have the same
239
- cookie after log-in as before we entered.
240
- We wouldn't want to lose track of this after all.
241
- Here is a possible test for this...
242
- <pre>
243
- class LogInTest extends WebTestCase {
244
- ...
245
- function testSessionCookieSameAfterLogIn() {
246
- $this-&gt;get('http://www.my-site.com/login.php');<strong>
247
- $session = $this-&gt;getCookie('SID');
248
- $this-&gt;setField('u', 'Me');
249
- $this-&gt;setField('p', 'Secret');
250
- $this-&gt;click('Log in');
251
- $this-&gt;assertText('Welcome Me');
252
- $this-&gt;assertCookie('SID', $session);</strong>
253
- }
254
- }
255
- </pre>
256
- This confirms that the session identifier is maintained
257
- afer log-in and we haven't accidently reset it.
258
- </p>
259
- <p>
260
- We could even attempt to hack our own system by setting
261
- arbitrary cookies to gain access...
262
- <pre>
263
- class LogInTest extends WebTestCase {
264
- ...
265
- function testSessionCookieSameAfterLogIn() {
266
- $this-&gt;get('http://www.my-site.com/login.php');<strong>
267
- $this-&gt;setCookie('SID', 'Some other session');
268
- $this-&gt;get('http://www.my-site.com/restricted.php');</strong>
269
- $this-&gt;assertText('Access denied');
270
- }
271
- }
272
- </pre>
273
- Is your site protected from this attack?
274
- </p>
275
-
276
- <h2>
277
- <a class="target" name="session"></a>Browser sessions</h2>
278
- <p>
279
- If you are testing an authentication system a critical piece
280
- of behaviour is what happens when a user logs back in.
281
- We would like to simulate closing and reopening a browser...
282
- <pre>
283
- class LogInTest extends WebTestCase {
284
- ...
285
- function testLoseAuthenticationAfterBrowserClose() {
286
- $this-&gt;get('http://www.my-site.com/login.php');
287
- $this-&gt;setField('u', 'Me');
288
- $this-&gt;setField('p', 'Secret');
289
- $this-&gt;click('Log in');
290
- $this-&gt;assertText('Welcome Me');<strong>
291
-
292
- $this-&gt;restart();
293
- $this-&gt;get('http://www.my-site.com/restricted.php');
294
- $this-&gt;assertText('Access denied');</strong>
295
- }
296
- }
297
- </pre>
298
- The <span class="new_code">WebTestCase::restart()</span> method will
299
- preserve cookies that have unexpired timeouts, but throw away
300
- those that are temporary or expired.
301
- You can optionally specify the time and date that the restart
302
- happened.
303
- </p>
304
- <p>
305
- Expiring cookies can be a problem.
306
- After all, if you have a cookie that expires after an hour,
307
- you don't want to stall the test for an hour while waiting
308
- for the cookie to pass it's timeout.
309
- </p>
310
- <p>
311
- To push the cookies over the hour limit you can age them
312
- before you restart the session...
313
- <pre>
314
- class LogInTest extends WebTestCase {
315
- ...
316
- function testLoseAuthenticationAfterOneHour() {
317
- $this-&gt;get('http://www.my-site.com/login.php');
318
- $this-&gt;setField('u', 'Me');
319
- $this-&gt;setField('p', 'Secret');
320
- $this-&gt;click('Log in');
321
- $this-&gt;assertText('Welcome Me');
322
- <strong>
323
- $this-&gt;ageCookies(3600);</strong>
324
- $this-&gt;restart();
325
- $this-&gt;get('http://www.my-site.com/restricted.php');
326
- $this-&gt;assertText('Access denied');
327
- }
328
- }
329
- </pre>
330
- After the restart it will appear that cookies are an
331
- hour older, and any that pass their expiry will have
332
- disappeared.
333
- </p>
334
-
335
- </div>
336
- References and related information...
337
- <ul>
338
- <li>
339
- SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
340
- </li>
341
- <li>
342
- SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
343
- </li>
344
- <li>
345
- The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
346
- gives full detail on the classes and assertions available.
347
- </li>
348
- </ul>
349
- <div class="menu_back"><div class="menu">
350
- <a href="index.html">SimpleTest</a>
351
- |
352
- <a href="overview.html">Overview</a>
353
- |
354
- <a href="unit_test_documentation.html">Unit tester</a>
355
- |
356
- <a href="group_test_documentation.html">Group tests</a>
357
- |
358
- <a href="mock_objects_documentation.html">Mock objects</a>
359
- |
360
- <a href="partial_mocks_documentation.html">Partial mocks</a>
361
- |
362
- <a href="reporter_documentation.html">Reporting</a>
363
- |
364
- <a href="expectation_documentation.html">Expectations</a>
365
- |
366
- <a href="web_tester_documentation.html">Web tester</a>
367
- |
368
- <a href="form_testing_documentation.html">Testing forms</a>
369
- |
370
- <span class="chosen">Authentication</span>
371
- |
372
- <a href="browser_documentation.html">Scriptable browser</a>
373
- </div></div>
374
- <div class="copyright">
375
- Copyright<br>Marcus Baker 2006
376
- </div>
377
- </body>
378
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/browser_documentation.html DELETED
@@ -1,501 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
- <title>SimpleTest documentation for the scriptable web browser component</title>
5
- <link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
6
- </head>
7
- <body>
8
- <div class="menu_back"><div class="menu">
9
- <a href="index.html">SimpleTest</a>
10
- |
11
- <a href="overview.html">Overview</a>
12
- |
13
- <a href="unit_test_documentation.html">Unit tester</a>
14
- |
15
- <a href="group_test_documentation.html">Group tests</a>
16
- |
17
- <a href="mock_objects_documentation.html">Mock objects</a>
18
- |
19
- <a href="partial_mocks_documentation.html">Partial mocks</a>
20
- |
21
- <a href="reporter_documentation.html">Reporting</a>
22
- |
23
- <a href="expectation_documentation.html">Expectations</a>
24
- |
25
- <a href="web_tester_documentation.html">Web tester</a>
26
- |
27
- <a href="form_testing_documentation.html">Testing forms</a>
28
- |
29
- <a href="authentication_documentation.html">Authentication</a>
30
- |
31
- <span class="chosen">Scriptable browser</span>
32
- </div></div>
33
- <h1>PHP Scriptable Web Browser</h1>
34
- This page...
35
- <ul>
36
- <li>
37
- Using the bundled <a href="#scripting">web browser in scripts</a>
38
- </li>
39
- <li>
40
- <a href="#debug">Debugging</a> failed pages
41
- </li>
42
- <li>
43
- Complex <a href="#unit">tests with multiple web browsers</a>
44
- </li>
45
- </ul>
46
- <div class="content">
47
-
48
- <p>
49
- SimpleTest's web browser component can be used not just
50
- outside of the <span class="new_code">WebTestCase</span> class, but also
51
- independently of the SimpleTest framework itself.
52
- </p>
53
-
54
- <h2>
55
- <a class="target" name="scripting"></a>The Scriptable Browser</h2>
56
- <p>
57
- You can use the web browser in PHP scripts to confirm
58
- services are up and running, or to extract information
59
- from them at a regular basis.
60
- For example, here is a small script to extract the current number of
61
- open PHP 5 bugs from the <a href="http://www.php.net/">PHP web site</a>...
62
- <pre>
63
- <strong>&lt;?php
64
- require_once('simpletest/browser.php');
65
-
66
- $browser = &amp;new SimpleBrowser();
67
- $browser-&gt;get('http://php.net/');
68
- $browser-&gt;click('reporting bugs');
69
- $browser-&gt;click('statistics');
70
- $page = $browser-&gt;click('PHP 5 bugs only');
71
- preg_match('/status=Open.*?by=Any.*?(\d+)&lt;\/a&gt;/', $page, $matches);
72
- print $matches[1];
73
- ?&gt;</strong>
74
- </pre>
75
- There are simpler methods to do this particular example in PHP
76
- of course.
77
- For example you can just use the PHP <span class="new_code">file()</span>
78
- command against what here is a pretty fixed page.
79
- However, using the web browser for scripts allows authentication,
80
- correct handling of cookies, automatic loading of frames, redirects,
81
- form submission and the ability to examine the page headers.
82
- <p>
83
- </p>
84
- Methods such as periodic scraping are fragile against a site that is constantly
85
- evolving and you would want a more direct way of accessing
86
- data in a permanent set up, but for simple tasks this can provide
87
- a very rapid solution.
88
- </p>
89
- <p>
90
- All of the navigation methods used in the
91
- <a href="web_tester_documentation.html">WebTestCase</a>
92
- are present in the <span class="new_code">SimpleBrowser</span> class, but
93
- the assertions are replaced with simpler accessors.
94
- Here is a full list of the page navigation methods...
95
- <table><tbody>
96
- <tr>
97
- <td><span class="new_code">addHeader($header)</span></td>
98
- <td>Adds a header to every fetch</td>
99
- </tr>
100
- <tr>
101
- <td><span class="new_code">useProxy($proxy, $username, $password)</span></td>
102
- <td>Use this proxy from now on</td>
103
- </tr>
104
- <tr>
105
- <td><span class="new_code">head($url, $parameters)</span></td>
106
- <td>Perform a HEAD request</td>
107
- </tr>
108
- <tr>
109
- <td><span class="new_code">get($url, $parameters)</span></td>
110
- <td>Fetch a page with GET</td>
111
- </tr>
112
- <tr>
113
- <td><span class="new_code">post($url, $parameters)</span></td>
114
- <td>Fetch a page with POST</td>
115
- </tr>
116
- <tr>
117
- <td><span class="new_code">click($label)</span></td>
118
- <td>Clicks visible link or button text</td>
119
- </tr>
120
- <tr>
121
- <td><span class="new_code">clickLink($label)</span></td>
122
- <td>Follows a link by label</td>
123
- </tr>
124
- <tr>
125
- <td><span class="new_code">clickLinkById($id)</span></td>
126
- <td>Follows a link by attribute</td>
127
- </tr>
128
- <tr>
129
- <td><span class="new_code">getUrl()</span></td>
130
- <td>Current URL of page or frame</td>
131
- </tr>
132
- <tr>
133
- <td><span class="new_code">getTitle()</span></td>
134
- <td>Page title</td>
135
- </tr>
136
- <tr>
137
- <td><span class="new_code">getContent()</span></td>
138
- <td>Raw page or frame</td>
139
- </tr>
140
- <tr>
141
- <td><span class="new_code">getContentAsText()</span></td>
142
- <td>HTML removed except for alt text</td>
143
- </tr>
144
- <tr>
145
- <td><span class="new_code">retry()</span></td>
146
- <td>Repeat the last request</td>
147
- </tr>
148
- <tr>
149
- <td><span class="new_code">back()</span></td>
150
- <td>Use the browser back button</td>
151
- </tr>
152
- <tr>
153
- <td><span class="new_code">forward()</span></td>
154
- <td>Use the browser forward button</td>
155
- </tr>
156
- <tr>
157
- <td><span class="new_code">authenticate($username, $password)</span></td>
158
- <td>Retry page or frame after a 401 response</td>
159
- </tr>
160
- <tr>
161
- <td><span class="new_code">restart($date)</span></td>
162
- <td>Restarts the browser for a new session</td>
163
- </tr>
164
- <tr>
165
- <td><span class="new_code">ageCookies($interval)</span></td>
166
- <td>Ages the cookies by the specified time</td>
167
- </tr>
168
- <tr>
169
- <td><span class="new_code">setCookie($name, $value)</span></td>
170
- <td>Sets an additional cookie</td>
171
- </tr>
172
- <tr>
173
- <td><span class="new_code">getCookieValue($host, $path, $name)</span></td>
174
- <td>Reads the most specific cookie</td>
175
- </tr>
176
- <tr>
177
- <td><span class="new_code">getCurrentCookieValue($name)</span></td>
178
- <td>Reads cookie for the current context</td>
179
- </tr>
180
- </tbody></table>
181
- The methods <span class="new_code">SimpleBrowser::useProxy()</span> and
182
- <span class="new_code">SimpleBrowser::addHeader()</span> are special.
183
- Once called they continue to apply to all subsequent fetches.
184
- </p>
185
- <p>
186
- Navigating forms is similar to the
187
- <a href="form_testing_documentation.html">WebTestCase form navigation</a>...
188
- <table><tbody>
189
- <tr>
190
- <td><span class="new_code">setField($label, $value)</span></td>
191
- <td>Sets all form fields with that label or name</td>
192
- </tr>
193
- <tr>
194
- <td><span class="new_code">setFieldByName($name, $value)</span></td>
195
- <td>Sets all form fields with that name</td>
196
- </tr>
197
- <tr>
198
- <td><span class="new_code">setFieldById($id, $value)</span></td>
199
- <td>Sets all form fields with that id</td>
200
- </tr>
201
- <tr>
202
- <td><span class="new_code">getField($label)</span></td>
203
- <td>Accessor for a form element value by label tag and then name</td>
204
- </tr>
205
- <tr>
206
- <td><span class="new_code">getFieldByName($name)</span></td>
207
- <td>Accessor for a form element value using name attribute</td>
208
- </tr>
209
- <tr>
210
- <td><span class="new_code">getFieldById($id)</span></td>
211
- <td>Accessor for a form element value</td>
212
- </tr>
213
- <tr>
214
- <td><span class="new_code">clickSubmit($label)</span></td>
215
- <td>Submits form by button label</td>
216
- </tr>
217
- <tr>
218
- <td><span class="new_code">clickSubmitByName($name)</span></td>
219
- <td>Submits form by button attribute</td>
220
- </tr>
221
- <tr>
222
- <td><span class="new_code">clickSubmitById($id)</span></td>
223
- <td>Submits form by button attribute</td>
224
- </tr>
225
- <tr>
226
- <td><span class="new_code">clickImage($label, $x, $y)</span></td>
227
- <td>Clicks an input tag of type image by title or alt text</td>
228
- </tr>
229
- <tr>
230
- <td><span class="new_code">clickImageByName($name, $x, $y)</span></td>
231
- <td>Clicks an input tag of type image by name</td>
232
- </tr>
233
- <tr>
234
- <td><span class="new_code">clickImageById($id, $x, $y)</span></td>
235
- <td>Clicks an input tag of type image by ID attribute</td>
236
- </tr>
237
- <tr>
238
- <td><span class="new_code">submitFormById($id)</span></td>
239
- <td>Submits by the form tag attribute</td>
240
- </tr>
241
- </tbody></table>
242
- At the moment there aren't many methods to list available links and fields.
243
- <table><tbody>
244
- <tr>
245
- <td><span class="new_code">isClickable($label)</span></td>
246
- <td>Test to see if a click target exists by label or name</td>
247
- </tr>
248
- <tr>
249
- <td><span class="new_code">isSubmit($label)</span></td>
250
- <td>Test for the existence of a button with that label or name</td>
251
- </tr>
252
- <tr>
253
- <td><span class="new_code">isImage($label)</span></td>
254
- <td>Test for the existence of an image button with that label or name</td>
255
- </tr>
256
- <tr>
257
- <td><span class="new_code">getLink($label)</span></td>
258
- <td>Finds a URL from its label</td>
259
- </tr>
260
- <tr>
261
- <td><span class="new_code">getLinkById($label)</span></td>
262
- <td>Finds a URL from its ID attribute</td>
263
- </tr>
264
- <tr>
265
- <td><span class="new_code">getUrls()</span></td>
266
- <td>Lists available links in the current page</td>
267
- </tr>
268
- </tbody></table>
269
- This will be expanded in later versions of SimpleTest.
270
- </p>
271
- <p>
272
- Frames are a rather esoteric feature these days, but SimpleTest has
273
- retained support for them.
274
- </p>
275
- <p>
276
- Within a page, individual frames can be selected.
277
- If no selection is made then all the frames are merged together
278
- in one large conceptual page.
279
- The content of the current page will be a concatenation of all of the
280
- frames in the order that they were specified in the "frameset"
281
- tags.
282
- <table><tbody>
283
- <tr>
284
- <td><span class="new_code">getFrames()</span></td>
285
- <td>A dump of the current frame structure</td>
286
- </tr>
287
- <tr>
288
- <td><span class="new_code">getFrameFocus()</span></td>
289
- <td>Current frame label or index</td>
290
- </tr>
291
- <tr>
292
- <td><span class="new_code">setFrameFocusByIndex($choice)</span></td>
293
- <td>Select a frame numbered from 1</td>
294
- </tr>
295
- <tr>
296
- <td><span class="new_code">setFrameFocus($name)</span></td>
297
- <td>Select frame by label</td>
298
- </tr>
299
- <tr>
300
- <td><span class="new_code">clearFrameFocus()</span></td>
301
- <td>Treat all the frames as a single page</td>
302
- </tr>
303
- </tbody></table>
304
- When focused on a single frame, the content will come from
305
- that frame only.
306
- This includes links to click and forms to submit.
307
- </p>
308
-
309
- <h2>
310
- <a class="target" name="debug"></a>What went wrong?</h2>
311
- <p>
312
- All of this functionality is great when we actually manage to fetch pages,
313
- but that doesn't always happen.
314
- To help figure out what went wrong, the browser has some methods to
315
- aid in debugging...
316
- <table><tbody>
317
- <tr>
318
- <td><span class="new_code">setConnectionTimeout($timeout)</span></td>
319
- <td>Close the socket on overrun</td>
320
- </tr>
321
- <tr>
322
- <td><span class="new_code">getUrl()</span></td>
323
- <td>Url of most recent page fetched</td>
324
- </tr>
325
- <tr>
326
- <td><span class="new_code">getRequest()</span></td>
327
- <td>Raw request header of page or frame</td>
328
- </tr>
329
- <tr>
330
- <td><span class="new_code">getHeaders()</span></td>
331
- <td>Raw response header of page or frame</td>
332
- </tr>
333
- <tr>
334
- <td><span class="new_code">getTransportError()</span></td>
335
- <td>Any socket level errors in the last fetch</td>
336
- </tr>
337
- <tr>
338
- <td><span class="new_code">getResponseCode()</span></td>
339
- <td>HTTP response of page or frame</td>
340
- </tr>
341
- <tr>
342
- <td><span class="new_code">getMimeType()</span></td>
343
- <td>Mime type of page or frame</td>
344
- </tr>
345
- <tr>
346
- <td><span class="new_code">getAuthentication()</span></td>
347
- <td>Authentication type in 401 challenge header</td>
348
- </tr>
349
- <tr>
350
- <td><span class="new_code">getRealm()</span></td>
351
- <td>Authentication realm in 401 challenge header</td>
352
- </tr>
353
- <tr>
354
- <td><span class="new_code">getBaseUrl()</span></td>
355
- <td>Base url only of most recent page fetched</td>
356
- </tr>
357
- <tr>
358
- <td><span class="new_code">setMaximumRedirects($max)</span></td>
359
- <td>Number of redirects before page is loaded anyway</td>
360
- </tr>
361
- <tr>
362
- <td><span class="new_code">setMaximumNestedFrames($max)</span></td>
363
- <td>Protection against recursive framesets</td>
364
- </tr>
365
- <tr>
366
- <td><span class="new_code">ignoreFrames()</span></td>
367
- <td>Disables frames support</td>
368
- </tr>
369
- <tr>
370
- <td><span class="new_code">useFrames()</span></td>
371
- <td>Enables frames support</td>
372
- </tr>
373
- <tr>
374
- <td><span class="new_code">ignoreCookies()</span></td>
375
- <td>Disables sending and receiving of cookies</td>
376
- </tr>
377
- <tr>
378
- <td><span class="new_code">useCookies()</span></td>
379
- <td>Enables cookie support</td>
380
- </tr>
381
- </tbody></table>
382
- The methods <span class="new_code">SimpleBrowser::setConnectionTimeout()</span>
383
- <span class="new_code">SimpleBrowser::setMaximumRedirects()</span>,
384
- <span class="new_code">SimpleBrowser::setMaximumNestedFrames()</span>,
385
- <span class="new_code">SimpleBrowser::ignoreFrames()</span>,
386
- <span class="new_code">SimpleBrowser::useFrames()</span>,
387
- <span class="new_code">SimpleBrowser::ignoreCookies()</span> and
388
- <span class="new_code">SimpleBrowser::useCokies()</span> continue to apply
389
- to every subsequent request.
390
- The other methods are frames aware.
391
- This means that if you have an individual frame that is not
392
- loading, navigate to it using <span class="new_code">SimpleBrowser::setFrameFocus()</span>
393
- and you can then use <span class="new_code">SimpleBrowser::getRequest()</span>, etc to
394
- see what happened.
395
- </p>
396
-
397
- <h2>
398
- <a class="target" name="unit"></a>Complex unit tests with multiple browsers</h2>
399
- <p>
400
- Anything that could be done in a
401
- <a href="web_tester_documentation.html">WebTestCase</a> can
402
- now be done in a <a href="unit_tester_documentation.html">UnitTestCase</a>.
403
- This means that we could freely mix domain object testing with the
404
- web interface...
405
- <pre>
406
- <strong>class TestOfRegistration extends UnitTestCase {
407
- function testNewUserAddedToAuthenticator() {</strong>
408
- $browser = new SimpleBrowser();
409
- $browser-&gt;get('http://my-site.com/register.php');
410
- $browser-&gt;setField('email', 'me@here');
411
- $browser-&gt;setField('password', 'Secret');
412
- $browser-&gt;click('Register');
413
- <strong>
414
- $authenticator = new Authenticator();
415
- $member = $authenticator-&gt;findByEmail('me@here');
416
- $this-&gt;assertEqual($member-&gt;getPassword(), 'Secret');
417
- }
418
- }</strong>
419
- </pre>
420
- While this may be a useful temporary expediency, I am not a fan
421
- of this type of testing.
422
- The testing has cut across application layers, make it twice as
423
- likely it will need refactoring when the code changes.
424
- </p>
425
- <p>
426
- A more useful case of where using the browser directly can be helpful
427
- is where the <span class="new_code">WebTestCase</span> cannot cope.
428
- An example is where two browsers are needed at the same time.
429
- </p>
430
- <p>
431
- For example, say we want to disallow multiple simultaneous
432
- usage of a site with the same username.
433
- This test case will do the job...
434
- <pre>
435
- class TestOfSecurity extends UnitTestCase {
436
- function testNoMultipleLoginsFromSameUser() {<strong>
437
- $first_attempt = new SimpleBrowser();
438
- $first_attempt-&gt;get('http://my-site.com/login.php');
439
- $first_attempt-&gt;setField('name', 'Me');
440
- $first_attempt-&gt;setField('password', 'Secret');
441
- $first_attempt-&gt;click('Enter');
442
- $this-&gt;assertEqual($first_attempt-&gt;getTitle(), 'Welcome');
443
-
444
- $second_attempt = new SimpleBrowser();
445
- $second_attempt-&gt;get('http://my-site.com/login.php');
446
- $second_attempt-&gt;setField('name', 'Me');
447
- $second_attempt-&gt;setField('password', 'Secret');
448
- $second_attempt-&gt;click('Enter');
449
- $this-&gt;assertEqual($second_attempt-&gt;getTitle(), 'Access Denied');</strong>
450
- }
451
- }
452
- </pre>
453
- You can also use the <span class="new_code">SimpleBrowser</span> class
454
- directly when you want to write test cases using a different
455
- test tool than SimpleTest, such as PHPUnit.
456
- </p>
457
-
458
- </div>
459
- References and related information...
460
- <ul>
461
- <li>
462
- SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
463
- </li>
464
- <li>
465
- SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
466
- </li>
467
- <li>
468
- The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
469
- gives full detail on the classes and assertions available.
470
- </li>
471
- </ul>
472
- <div class="menu_back"><div class="menu">
473
- <a href="index.html">SimpleTest</a>
474
- |
475
- <a href="overview.html">Overview</a>
476
- |
477
- <a href="unit_test_documentation.html">Unit tester</a>
478
- |
479
- <a href="group_test_documentation.html">Group tests</a>
480
- |
481
- <a href="mock_objects_documentation.html">Mock objects</a>
482
- |
483
- <a href="partial_mocks_documentation.html">Partial mocks</a>
484
- |
485
- <a href="reporter_documentation.html">Reporting</a>
486
- |
487
- <a href="expectation_documentation.html">Expectations</a>
488
- |
489
- <a href="web_tester_documentation.html">Web tester</a>
490
- |
491
- <a href="form_testing_documentation.html">Testing forms</a>
492
- |
493
- <a href="authentication_documentation.html">Authentication</a>
494
- |
495
- <span class="chosen">Scriptable browser</span>
496
- </div></div>
497
- <div class="copyright">
498
- Copyright<br>Marcus Baker 2006
499
- </div>
500
- </body>
501
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/docs.css DELETED
@@ -1,121 +0,0 @@
1
- body {
2
- padding-left: 3%;
3
- padding-right: 3%;
4
- }
5
- h1, h2, h3 {
6
- font-family: sans-serif;
7
- }
8
- h1 {
9
- text-align: center;
10
- }
11
- pre {
12
- font-family: "courier new", courier, typewriter, monospace;
13
- font-size: 90%;
14
- border: 1px solid;
15
- border-color: #999966;
16
- background-color: #ffffcc;
17
- padding: 5px;
18
- margin-left: 20px;
19
- margin-right: 40px;
20
- }
21
- .code, .new_code, pre.new_code {
22
- font-family: "courier new", courier, typewriter, monospace;
23
- font-weight: bold;
24
- }
25
- div.copyright {
26
- font-size: 80%;
27
- color: gray;
28
- }
29
- div.copyright a {
30
- margin-top: 1em;
31
- color: gray;
32
- }
33
- ul.api {
34
- border: 2px outset;
35
- border-color: gray;
36
- background-color: white;
37
- margin: 5px;
38
- margin-left: 5%;
39
- margin-right: 5%;
40
- }
41
- ul.api li {
42
- margin-top: 0.2em;
43
- margin-bottom: 0.2em;
44
- list-style: none;
45
- text-indent: -3em;
46
- padding-left: 1em;
47
- }
48
- div.demo {
49
- border: 4px ridge;
50
- border-color: gray;
51
- padding: 10px;
52
- margin: 5px;
53
- margin-left: 20px;
54
- margin-right: 40px;
55
- background-color: white;
56
- }
57
- div.demo span.fail {
58
- color: red;
59
- }
60
- div.demo span.pass {
61
- color: green;
62
- }
63
- div.demo h1 {
64
- font-size: 12pt;
65
- text-align: left;
66
- font-weight: bold;
67
- }
68
- div.menu {
69
- text-align: center;
70
- }
71
- table {
72
- border: 2px outset;
73
- border-color: gray;
74
- background-color: white;
75
- margin: 5px;
76
- margin-left: 5%;
77
- margin-right: 5%;
78
- }
79
- td {
80
- font-size: 90%;
81
- }
82
- .shell {
83
- color: white;
84
- }
85
- pre.shell {
86
- border: 4px ridge;
87
- border-color: gray;
88
- padding: 10px;
89
- margin: 5px;
90
- margin-left: 20px;
91
- margin-right: 40px;
92
- background-color: #000100;
93
- color: #99ff99;
94
- font-size: 90%;
95
- }
96
- pre.file {
97
- color: black;
98
- border: 1px solid;
99
- border-color: black;
100
- padding: 10px;
101
- margin: 5px;
102
- margin-left: 20px;
103
- margin-right: 40px;
104
- background-color: white;
105
- font-size: 90%;
106
- }
107
- form.demo {
108
- background-color: lightgray;
109
- border: 4px outset;
110
- border-color: lightgray;
111
- padding: 10px;
112
- margin-right: 40%;
113
- }
114
- dl, dd {
115
- margin: 10px;
116
- margin-left: 30px;
117
- }
118
- em {
119
- font-weight: bold;
120
- font-family: "courier new", courier, typewriter, monospace;
121
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/expectation_documentation.html DELETED
@@ -1,476 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
- <title>
5
- Extending the SimpleTest unit tester with additional expectation classes
6
- </title>
7
- <link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
8
- </head>
9
- <body>
10
- <div class="menu_back"><div class="menu">
11
- <a href="index.html">SimpleTest</a>
12
- |
13
- <a href="overview.html">Overview</a>
14
- |
15
- <a href="unit_test_documentation.html">Unit tester</a>
16
- |
17
- <a href="group_test_documentation.html">Group tests</a>
18
- |
19
- <a href="mock_objects_documentation.html">Mock objects</a>
20
- |
21
- <a href="partial_mocks_documentation.html">Partial mocks</a>
22
- |
23
- <a href="reporter_documentation.html">Reporting</a>
24
- |
25
- <span class="chosen">Expectations</span>
26
- |
27
- <a href="web_tester_documentation.html">Web tester</a>
28
- |
29
- <a href="form_testing_documentation.html">Testing forms</a>
30
- |
31
- <a href="authentication_documentation.html">Authentication</a>
32
- |
33
- <a href="browser_documentation.html">Scriptable browser</a>
34
- </div></div>
35
- <h1>Expectation documentation</h1>
36
- This page...
37
- <ul>
38
- <li>
39
- Using expectations for
40
- <a href="#mock">more precise testing with mock objects</a>
41
- </li>
42
- <li>
43
- <a href="#behaviour">Changing mock object behaviour</a> with expectations
44
- </li>
45
- <li>
46
- <a href="#extending">Extending the expectations</a>
47
- </li>
48
- <li>
49
- Underneath SimpleTest <a href="#unit">uses expectation classes</a>
50
- </li>
51
- </ul>
52
- <div class="content">
53
- <h2>
54
- <a class="target" name="mock"></a>More control over mock objects</h2>
55
- <p>
56
- The default behaviour of the
57
- <a href="mock_objects_documentation.html">mock objects</a>
58
- in
59
- <a href="http://sourceforge.net/projects/simpletest/">SimpleTest</a>
60
- is either an identical match on the argument or to allow any argument at all.
61
- For almost all tests this is sufficient.
62
- Sometimes, though, you want to weaken a test case.
63
- </p>
64
- <p>
65
- One place where a test can be too tightly coupled is with
66
- text matching.
67
- Suppose we have a component that outputs a helpful error
68
- message when something goes wrong.
69
- You want to test that the correct error was sent, but the actual
70
- text may be rather long.
71
- If you test for the text exactly, then every time the exact wording
72
- of the message changes, you will have to go back and edit the test suite.
73
- </p>
74
- <p>
75
- For example, suppose we have a news service that has failed
76
- to connect to its remote source.
77
- <pre>
78
- <strong>class NewsService {
79
- ...
80
- function publish($writer) {
81
- if (! $this-&gt;isConnected()) {
82
- $writer-&gt;write('Cannot connect to news service "' .
83
- $this-&gt;_name . '" at this time. ' .
84
- 'Please try again later.');
85
- }
86
- ...
87
- }
88
- }</strong>
89
- </pre>
90
- Here it is sending its content to a
91
- <span class="new_code">Writer</span> class.
92
- We could test this behaviour with a
93
- <span class="new_code">MockWriter</span> like so...
94
- <pre>
95
- class TestOfNewsService extends UnitTestCase {
96
- ...
97
- function testConnectionFailure() {<strong>
98
- $writer = new MockWriter();
99
- $writer-&gt;expectOnce('write', array(
100
- 'Cannot connect to news service ' .
101
- '"BBC News" at this time. ' .
102
- 'Please try again later.'));
103
-
104
- $service = new NewsService('BBC News');
105
- $service-&gt;publish($writer);</strong>
106
- }
107
- }
108
- </pre>
109
- This is a good example of a brittle test.
110
- If we decide to add additional instructions, such as
111
- suggesting an alternative news source, we will break
112
- our tests even though no underlying functionality
113
- has been altered.
114
- </p>
115
- <p>
116
- To get around this, we would like to do a regular expression
117
- test rather than an exact match.
118
- We can actually do this with...
119
- <pre>
120
- class TestOfNewsService extends UnitTestCase {
121
- ...
122
- function testConnectionFailure() {
123
- $writer = new MockWriter();<strong>
124
- $writer-&gt;expectOnce(
125
- 'write',
126
- array(new PatternExpectation('/cannot connect/i')));</strong>
127
-
128
- $service = new NewsService('BBC News');
129
- $service-&gt;publish($writer);
130
- }
131
- }
132
- </pre>
133
- Instead of passing in the expected parameter to the
134
- <span class="new_code">MockWriter</span> we pass an
135
- expectation class called
136
- <span class="new_code">PatternExpectation</span>.
137
- The mock object is smart enough to recognise this as special
138
- and to treat it differently.
139
- Rather than simply comparing the incoming argument to this
140
- object, it uses the expectation object itself to
141
- perform the test.
142
- </p>
143
- <p>
144
- The <span class="new_code">PatternExpectation</span> takes
145
- the regular expression to match in its constructor.
146
- Whenever a comparison is made by the <span class="new_code">MockWriter</span>
147
- against this expectation class, it will do a
148
- <span class="new_code">preg_match()</span> with this pattern.
149
- With our test case above, as long as "cannot connect"
150
- appears in the text of the string, the mock will issue a pass
151
- to the unit tester.
152
- The rest of the text does not matter.
153
- </p>
154
- <p>
155
- The possible expectation classes are...
156
- <table><tbody>
157
- <tr>
158
- <td><span class="new_code">AnythingExpectation</span></td>
159
- <td>Will always match</td>
160
- </tr>
161
- <tr>
162
- <td><span class="new_code">EqualExpectation</span></td>
163
- <td>An equality, rather than the stronger identity comparison</td>
164
- </tr>
165
- <tr>
166
- <td><span class="new_code">NotEqualExpectation</span></td>
167
- <td>An inequality comparison</td>
168
- </tr>
169
- <tr>
170
- <td><span class="new_code">IndenticalExpectation</span></td>
171
- <td>The default mock object check which must match exactly</td>
172
- </tr>
173
- <tr>
174
- <td><span class="new_code">NotIndenticalExpectation</span></td>
175
- <td>Inverts the mock object logic</td>
176
- </tr>
177
- <tr>
178
- <td><span class="new_code">WithinMarginExpectation</span></td>
179
- <td>Compares a value to within a margin</td>
180
- </tr>
181
- <tr>
182
- <td><span class="new_code">OutsideMarginExpectation</span></td>
183
- <td>Checks that a value is out side the margin</td>
184
- </tr>
185
- <tr>
186
- <td><span class="new_code">PatternExpectation</span></td>
187
- <td>Uses a Perl Regex to match a string</td>
188
- </tr>
189
- <tr>
190
- <td><span class="new_code">NoPatternExpectation</span></td>
191
- <td>Passes only if failing a Perl Regex</td>
192
- </tr>
193
- <tr>
194
- <td><span class="new_code">IsAExpectation</span></td>
195
- <td>Checks the type or class name only</td>
196
- </tr>
197
- <tr>
198
- <td><span class="new_code">NotAExpectation</span></td>
199
- <td>Opposite of the <span class="new_code">IsAExpectation</span>
200
- </td>
201
- </tr>
202
- <tr>
203
- <td><span class="new_code">MethodExistsExpectation</span></td>
204
- <td>Checks a method is available on an object</td>
205
- </tr>
206
- <tr>
207
- <td><span class="new_code">TrueExpectation</span></td>
208
- <td>Accepts any PHP variable that evaluates to true</td>
209
- </tr>
210
- <tr>
211
- <td><span class="new_code">FalseExpectation</span></td>
212
- <td>Accepts any PHP variable that evaluates to false</td>
213
- </tr>
214
- </tbody></table>
215
- Most take the expected value in the constructor.
216
- The exceptions are the pattern matchers, which take a regular expression,
217
- and the <span class="new_code">IsAExpectation</span> and <span class="new_code">NotAExpectation</span> which takes a type
218
- or class name as a string.
219
- </p>
220
- <p>
221
- Some examples...
222
- </p>
223
- <p>
224
- <pre>
225
- $mock-&gt;expectOnce('method', array(new IdenticalExpectation(14)));
226
- </pre>
227
- This is the same as <span class="new_code">$mock-&gt;expectOnce('method', array(14))</span>.
228
- <pre>
229
- $mock-&gt;expectOnce('method', array(new EqualExpectation(14)));
230
- </pre>
231
- This is different from the previous version in that the string
232
- <span class="new_code">"14"</span> as a parameter will also pass.
233
- Sometimes the additional type checks of SimpleTest are too restrictive.
234
- <pre>
235
- $mock-&gt;expectOnce('method', array(new AnythingExpectation(14)));
236
- </pre>
237
- This is the same as <span class="new_code">$mock-&gt;expectOnce('method', array('*'))</span>.
238
- <pre>
239
- $mock-&gt;expectOnce('method', array(new IdenticalExpectation('*')));
240
- </pre>
241
- This is handy if you want to assert a literal <span class="new_code">"*"</span>.
242
- <pre>
243
- new NotIdenticalExpectation(14)
244
- </pre>
245
- This matches on anything other than integer 14.
246
- Even the string <span class="new_code">"14"</span> would pass.
247
- <pre>
248
- new WithinMarginExpectation(14.0, 0.001)
249
- </pre>
250
- This will accept any value from 13.999 to 14.001 inclusive.
251
- </p>
252
-
253
- <h2>
254
- <a class="target" name="behaviour"></a>Using expectations to control stubs</h2>
255
- <p>
256
- The expectation classes can be used not just for sending assertions
257
- from mock objects, but also for selecting behaviour for the
258
- <a href="mock_objects_documentation.html">mock objects</a>.
259
- Anywhere a list of arguments is given, a list of expectation objects
260
- can be inserted instead.
261
- </p>
262
- <p>
263
- Suppose we want a mock authorisation server to simulate a successful login,
264
- but only if it receives a valid session object.
265
- We can do this as follows...
266
- <pre>
267
- Mock::generate('Authorisation');
268
- <strong>
269
- $authorisation = new MockAuthorisation();
270
- $authorisation-&gt;returns(
271
- 'isAllowed',
272
- true,
273
- array(new IsAExpectation('Session', 'Must be a session')));
274
- $authorisation-&gt;returns('isAllowed', false);</strong>
275
- </pre>
276
- We have set the default mock behaviour to return false when
277
- <span class="new_code">isAllowed</span> is called.
278
- When we call the method with a single parameter that
279
- is a <span class="new_code">Session</span> object, it will return true.
280
- We have also added a second parameter as a message.
281
- This will be displayed as part of the mock object
282
- failure message if this expectation is the cause of
283
- a failure.
284
- </p>
285
- <p>
286
- This kind of sophistication is rarely useful, but is included for
287
- completeness.
288
- </p>
289
-
290
- <h2>
291
- <a class="target" name="extending"></a>Creating your own expectations</h2>
292
- <p>
293
- The expectation classes have a very simple structure.
294
- So simple that it is easy to create your own versions for
295
- commonly used test logic.
296
- </p>
297
- <p>
298
- As an example here is the creation of a class to test for
299
- valid IP addresses.
300
- In order to work correctly with the stubs and mocks the new
301
- expectation class should extend
302
- <span class="new_code">SimpleExpectation</span> or further extend a subclass...
303
- <pre>
304
- <strong>class ValidIp extends SimpleExpectation {
305
-
306
- function test($ip) {
307
- return (ip2long($ip) != -1);
308
- }
309
-
310
- function testMessage($ip) {
311
- return "Address [$ip] should be a valid IP address";
312
- }
313
- }</strong>
314
- </pre>
315
- There are only two methods to implement.
316
- The <span class="new_code">test()</span> method should
317
- evaluate to true if the expectation is to pass, and
318
- false otherwise.
319
- The <span class="new_code">testMessage()</span> method
320
- should simply return some helpful text explaining the test
321
- that was carried out.
322
- </p>
323
- <p>
324
- This class can now be used in place of the earlier expectation
325
- classes.
326
- </p>
327
- <p>
328
- Here is a more typical example, matching part of a hash...
329
- <pre>
330
- <strong>class JustField extends EqualExpectation {
331
- private $key;
332
-
333
- function __construct($key, $expected) {
334
- parent::__construct($expected);
335
- $this-&gt;key = $key;
336
- }
337
-
338
- function test($compare) {
339
- if (! isset($compare[$this-&gt;key])) {
340
- return false;
341
- }
342
- return parent::test($compare[$this-&gt;key]);
343
- }
344
-
345
- function testMessage($compare) {
346
- if (! isset($compare[$this-&gt;key])) {
347
- return 'Key [' . $this-&gt;key . '] does not exist';
348
- }
349
- return 'Key [' . $this-&gt;key . '] -&gt; ' .
350
- parent::testMessage($compare[$this-&gt;key]);
351
- }
352
- }</strong>
353
- </pre>
354
- We tend to seperate message clauses with
355
- "&amp;nbsp;-&gt;&amp;nbsp;".
356
- This allows derivative tools to reformat the output.
357
- </p>
358
- <p>
359
- Suppose some authenticator is expecting to be given
360
- a database row corresponding to the user, and we
361
- only need to confirm the username is correct.
362
- We can assert just their username with...
363
- <pre>
364
- $mock-&gt;expectOnce('authenticate',
365
- array(new JustKey('username', 'marcus')));
366
- </pre>
367
- </p>
368
-
369
- <h2>
370
- <a class="target" name="unit"></a>Under the bonnet of the unit tester</h2>
371
- <p>
372
- The <a href="http://sourceforge.net/projects/simpletest/">SimpleTest unit testing framework</a>
373
- also uses the expectation classes internally for the
374
- <a href="unit_test_documentation.html">UnitTestCase class</a>.
375
- We can also take advantage of these mechanisms to reuse our
376
- homebrew expectation classes within the test suites directly.
377
- </p>
378
- <p>
379
- The most crude way of doing this is to use the generic
380
- <span class="new_code">SimpleTest::assert()</span> method to
381
- test against it directly...
382
- <pre>
383
- <strong>class TestOfNetworking extends UnitTestCase {
384
- ...
385
- function testGetValidIp() {
386
- $server = &amp;new Server();
387
- $this-&gt;assert(
388
- new ValidIp(),
389
- $server-&gt;getIp(),
390
- 'Server IP address-&gt;%s');
391
- }
392
- }</strong>
393
- </pre>
394
- <span class="new_code">assert()</span> will test any expectation class directly.
395
- </p>
396
- <p>
397
- This is a little untidy compared with our usual
398
- <span class="new_code">assert...()</span> syntax.
399
- </p>
400
- <p>
401
- For such a simple case we would normally create a
402
- separate assertion method on our test case rather
403
- than bother using the expectation class.
404
- If we pretend that our expectation is a little more
405
- complicated for a moment, so that we want to reuse it,
406
- we get...
407
- <pre>
408
- class TestOfNetworking extends UnitTestCase {
409
- ...<strong>
410
- function assertValidIp($ip, $message = '%s') {
411
- $this-&gt;assert(new ValidIp(), $ip, $message);
412
- }</strong>
413
-
414
- function testGetValidIp() {
415
- $server = &amp;new Server();<strong>
416
- $this-&gt;assertValidIp(
417
- $server-&gt;getIp(),
418
- 'Server IP address-&gt;%s');</strong>
419
- }
420
- }
421
- </pre>
422
- It is rare to need the expectations for more than pattern
423
- matching, but these facilities do allow testers to build
424
- some sort of domain language for testing their application.
425
- Also, complex expectation classes could make the tests
426
- harder to read and debug.
427
- In effect extending the test framework to create their own tool set.
428
- </p>
429
-
430
- </div>
431
- References and related information...
432
- <ul>
433
- <li>
434
- SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
435
- </li>
436
- <li>
437
- SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
438
- </li>
439
- <li>
440
- The expectations mimic the constraints in <a href="http://www.jmock.org/">JMock</a>.
441
- </li>
442
- <li>
443
- <a href="http://simpletest.org/api/">Full API for SimpleTest</a>
444
- from the PHPDoc.
445
- </li>
446
- </ul>
447
- <div class="menu_back"><div class="menu">
448
- <a href="index.html">SimpleTest</a>
449
- |
450
- <a href="overview.html">Overview</a>
451
- |
452
- <a href="unit_test_documentation.html">Unit tester</a>
453
- |
454
- <a href="group_test_documentation.html">Group tests</a>
455
- |
456
- <a href="mock_objects_documentation.html">Mock objects</a>
457
- |
458
- <a href="partial_mocks_documentation.html">Partial mocks</a>
459
- |
460
- <a href="reporter_documentation.html">Reporting</a>
461
- |
462
- <span class="chosen">Expectations</span>
463
- |
464
- <a href="web_tester_documentation.html">Web tester</a>
465
- |
466
- <a href="form_testing_documentation.html">Testing forms</a>
467
- |
468
- <a href="authentication_documentation.html">Authentication</a>
469
- |
470
- <a href="browser_documentation.html">Scriptable browser</a>
471
- </div></div>
472
- <div class="copyright">
473
- Copyright<br>Marcus Baker 2006
474
- </div>
475
- </body>
476
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/merchant-core-v3/gateways/php-merchant/tests/simpletest/docs/en/form_testing_documentation.html DELETED
@@ -1,351 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
- <title>SimpleTest documentation for testing HTML forms</title>
5
- <link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
6
- </head>
7
- <body>
8
- <div class="menu_back"><div class="menu">
9
- <a href="index.html">SimpleTest</a>
10
- |
11
- <a href="overview.html">Overview</a>
12
- |
13
- <a href="unit_test_documentation.html">Unit tester</a>
14
- |
15
- <a href="group_test_documentation.html">Group tests</a>
16
- |
17
- <a href="mock_objects_documentation.html">Mock objects</a>
18
- |
19
- <a href="partial_mocks_documentation.ht