WP eCommerce - Version 3.8.12.2

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.12.2
Comparing to
See all releases

Code changes from version 3.9.2 to 3.8.12.2

Files changed (172) hide show
  1. .gitignore +2 -0
  2. images/google_checkout.gif +0 -0
  3. readme.md +39 -0
  4. readme.txt +169 -270
  5. screenshot-1.png +0 -0
  6. screenshot-2.png +0 -0
  7. screenshot-3.png +0 -0
  8. screenshot-4.png +0 -0
  9. wp-shopping-cart.php +47 -92
  10. wpsc-admin/admin-form-functions.php +198 -9
  11. wpsc-admin/admin.php +209 -388
  12. wpsc-admin/ajax-and-init.php +4 -21
  13. wpsc-admin/ajax.php +23 -152
  14. wpsc-admin/css/admin.css +782 -1287
  15. wpsc-admin/css/media.css +0 -26
  16. wpsc-admin/css/settingspage.css +0 -3
  17. wpsc-admin/css/xit.gif +0 -0
  18. wpsc-admin/db-upgrades/routines/1.php +25 -20
  19. wpsc-admin/db-upgrades/routines/10.php +0 -134
  20. wpsc-admin/db-upgrades/routines/11.php +0 -83
  21. wpsc-admin/db-upgrades/routines/12.php +0 -55
  22. wpsc-admin/db-upgrades/routines/13.php +0 -54
  23. wpsc-admin/db-upgrades/routines/14.php +0 -28
  24. wpsc-admin/db-upgrades/routines/2.php +98 -79
  25. wpsc-admin/db-upgrades/routines/3.php +14 -10
  26. wpsc-admin/db-upgrades/routines/4.php +1 -2
  27. wpsc-admin/db-upgrades/routines/5.php +0 -49
  28. wpsc-admin/db-upgrades/routines/6.php +0 -12
  29. wpsc-admin/db-upgrades/routines/7.php +0 -36
  30. wpsc-admin/db-upgrades/routines/8.php +0 -12
  31. wpsc-admin/db-upgrades/routines/9.php +0 -13
  32. wpsc-admin/db-upgrades/upgrade.php +12 -19
  33. wpsc-admin/db-upgrades/views/main.php +1 -1
  34. wpsc-admin/display-coupon-add.php +5 -11
  35. wpsc-admin/display-coupon-edit.php +7 -14
  36. wpsc-admin/display-coupons.php +4 -9
  37. wpsc-admin/display-debug.page.php +2 -2
  38. wpsc-admin/display-items.page.php +25 -12
  39. wpsc-admin/display-options-settings.page.php +1 -1
  40. wpsc-admin/display-sales-logs.php +22 -39
  41. wpsc-admin/display-update.page.php +10 -6
  42. wpsc-admin/display-upgrades.page.php +127 -40
  43. wpsc-admin/includes/coupon-list-table-class.php +8 -8
  44. wpsc-admin/includes/display-items-functions.php +645 -908
  45. wpsc-admin/includes/product-functions.php +109 -190
  46. wpsc-admin/includes/product-variation-list-table.class.php +11 -30
  47. wpsc-admin/includes/product-variations-page.class.php +26 -70
  48. wpsc-admin/includes/product-variations-setup.page.php +1 -1
  49. wpsc-admin/includes/product-variations.page.php +5 -15
  50. wpsc-admin/includes/purchase-log-action-links.php +0 -482
  51. wpsc-admin/includes/purchase-log-list-table-class.php +18 -61
  52. wpsc-admin/includes/purchase-logs-page/item-details.php +51 -48
  53. wpsc-admin/includes/purchase-logs-page/list-table.php +2 -2
  54. wpsc-admin/includes/purchase-logs-page/packing-slip.php +0 -2
  55. wpsc-admin/includes/purchase-logs-page/upgrade.php +2 -2
  56. wpsc-admin/includes/save-data.functions.php +50 -62
  57. wpsc-admin/includes/settings-tabs/admin.php +3 -9
  58. wpsc-admin/includes/settings-tabs/checkout.php +5 -8
  59. wpsc-admin/includes/settings-tabs/gateway.php +9 -24
  60. wpsc-admin/includes/settings-tabs/general.php +4 -4
  61. wpsc-admin/includes/settings-tabs/import.php +42 -86
  62. wpsc-admin/includes/settings-tabs/marketing.php +0 -11
  63. wpsc-components/theme-engine-v1/classes/settings-tab-presentation.php → wpsc-admin/includes/settings-tabs/presentation.php +3 -3
  64. wpsc-admin/includes/settings-tabs/shipping.php +9 -13
  65. wpsc-admin/includes/settings-tabs/taxes.php +5 -9
  66. wpsc-admin/includes/tax_and_shipping.php +1 -7
  67. wpsc-admin/includes/updating-functions.php +11 -15
  68. wpsc-admin/includes/walker-variation-checklist.php +5 -13
  69. wpsc-admin/init.php +171 -301
  70. wpsc-admin/js/admin.js +71 -245
  71. wpsc-admin/js/media.js +0 -401
  72. wpsc-admin/js/product-variations.js +3 -28
  73. wpsc-admin/js/purchase-log-action-links.js +0 -124
  74. wpsc-admin/js/settings-page.js +10 -21
  75. wpsc-admin/js/variations.js +3 -15
  76. wpsc-admin/js/wp-e-commerce-admin.js +0 -169
  77. wpsc-admin/media.php +0 -95
  78. wpsc-admin/settings-page.php +9 -30
  79. wpsc-admin/users.php +0 -7
  80. wpsc-components/marketplace-core-v1/library/Sputnik.php +0 -596
  81. wpsc-components/marketplace-core-v1/library/Sputnik/API.php +0 -246
  82. wpsc-components/marketplace-core-v1/library/Sputnik/API/Auth.php +0 -137
  83. wpsc-components/marketplace-core-v1/library/Sputnik/Admin.php +0 -994
  84. wpsc-components/marketplace-core-v1/library/Sputnik/Library/Plugin.php +0 -128
  85. wpsc-components/marketplace-core-v1/library/Sputnik/Library/Plugin/Base.php +0 -109
  86. wpsc-components/marketplace-core-v1/library/Sputnik/Library/Plugin/Dynamic.php +0 -85
  87. wpsc-components/marketplace-core-v1/library/Sputnik/Library/TwitterOAuth.php +0 -147
  88. wpsc-components/marketplace-core-v1/library/Sputnik/Library/TwitterOAuth/Internal.php +0 -242
  89. wpsc-components/marketplace-core-v1/library/Sputnik/Library/TwitterOAuth/LICENSE +0 -22
  90. wpsc-components/marketplace-core-v1/library/Sputnik/List/Account.php +0 -162
  91. wpsc-components/marketplace-core-v1/library/Sputnik/List/Install.php +0 -470
  92. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Consumer.php +0 -16
  93. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/DataStore.php +0 -27
  94. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Exception.php +0 -7
  95. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Request.php +0 -261
  96. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Server.php +0 -225
  97. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod.php +0 -54
  98. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod/HMAC/SHA1.php +0 -29
  99. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod/PLAINTEXT.php +0 -34
  100. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod/RSA/SHA1.php +0 -68
  101. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Token.php +0 -31
  102. wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Util.php +0 -152
  103. wpsc-components/marketplace-core-v1/library/Sputnik/Pointers.php +0 -57
  104. wpsc-components/marketplace-core-v1/library/Sputnik/ThemeUpgrader.php +0 -56
  105. wpsc-components/marketplace-core-v1/library/Sputnik/Theme_Upgrader.php +0 -56
  106. wpsc-components/marketplace-core-v1/library/Sputnik/Updater.php +0 -200
  107. wpsc-components/marketplace-core-v1/library/Sputnik/Upgrader.php +0 -56
  108. wpsc-components/marketplace-core-v1/library/Sputnik/Upgrader/Skin.php +0 -65
  109. wpsc-components/marketplace-core-v1/library/Sputnik/View.php +0 -80
  110. wpsc-components/marketplace-core-v1/library/Sputnik/View/Account.php +0 -140
  111. wpsc-components/marketplace-core-v1/library/Sputnik/View/Auth.php +0 -34
  112. wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser.php +0 -120
  113. wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/Grid.php +0 -327
  114. wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/List.php +0 -82
  115. wpsc-components/marketplace-core-v1/library/Sputnik/View/Info.php +0 -202
  116. wpsc-components/marketplace-core-v1/library/Sputnik/View/Install.php +0 -80
  117. wpsc-components/marketplace-core-v1/library/Sputnik/View/Install/Skin.php +0 -64
  118. wpsc-components/marketplace-core-v1/library/Sputnik/View/Mini.php +0 -32
  119. wpsc-components/marketplace-core-v1/library/Sputnik/View/Upgrade.php +0 -53
  120. wpsc-components/marketplace-core-v1/library/Sputnik/index.php +0 -2
  121. wpsc-components/marketplace-core-v1/marketplace-core-v1.php +0 -11
  122. wpsc-components/marketplace-core-v1/static/admin.css +0 -480
  123. wpsc-components/marketplace-core-v1/static/admin.js +0 -111
  124. wpsc-components/marketplace-core-v1/static/gray-star.png +0 -0
  125. wpsc-components/marketplace-core-v1/static/grid.png +0 -0
  126. wpsc-components/marketplace-core-v1/static/icon16.png +0 -0
  127. wpsc-components/marketplace-core-v1/static/icon32.png +0 -0
  128. wpsc-components/marketplace-core-v1/static/icons.png +0 -0
  129. wpsc-components/marketplace-core-v1/static/logo.png +0 -0
  130. wpsc-components/marketplace-core-v1/static/modal.css +0 -1628
  131. wpsc-components/marketplace-core-v1/static/modal.js +0 -313
  132. wpsc-components/marketplace-core-v1/static/sputnik.css +0 -61
  133. wpsc-components/marketplace-core-v1/static/sputnik.js +0 -4
  134. wpsc-components/marketplace-core-v1/static/star.png +0 -0
  135. wpsc-components/merchant-core-v2/helpers/admin.php +1 -32
  136. wpsc-components/merchant-core-v2/helpers/checkout.php +11 -204
  137. wpsc-components/merchant-core-v2/helpers/gateways.php +17 -137
  138. wpsc-components/merchant-core-v3/classes/http.php +0 -35
  139. wpsc-components/merchant-core-v3/classes/payment-gateway.php +0 -639
  140. wpsc-components/merchant-core-v3/gateways/dg.css +0 -72
  141. wpsc-components/merchant-core-v3/gateways/dg.js +0 -28
  142. wpsc-components/merchant-core-v3/gateways/manual.php +0 -46
  143. wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php +0 -638
  144. wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php +0 -713
  145. wpsc-components/merchant-core-v3/gateways/paypal-pro.php +0 -633
  146. wpsc-components/merchant-core-v3/gateways/php-merchant/common/exception.php +0 -37
  147. wpsc-components/merchant-core-v3/gateways/php-merchant/common/helpers.php +0 -15
  148. wpsc-components/merchant-core-v3/gateways/php-merchant/common/http-curl.php +0 -62
  149. wpsc-components/merchant-core-v3/gateways/php-merchant/common/http.php +0 -11
  150. wpsc-components/merchant-core-v3/gateways/php-merchant/common/php-merchant.php +0 -157
  151. wpsc-components/merchant-core-v3/gateways/php-merchant/common/response.php +0 -39
  152. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-digital-goods.php +0 -80
  153. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout-response.php +0 -124
  154. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout.php +0 -324
  155. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-ipn.php +0 -140
  156. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-pro-response.php +0 -68
  157. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-pro.php +0 -358
  158. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-response.php +0 -104
  159. wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal.php +0 -86
  160. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/http-curl.php +0 -31
  161. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/php-merchant.php +0 -180
  162. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/common/test-accounts.php +0 -22
  163. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal-express-checkout.php +0 -552
  164. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal-ipn.php +0 -90
  165. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/gateways/paypal.php +0 -126
  166. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/index.php +0 -60
  167. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/http-curl.php +0 -29
  168. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x1.php +0 -317
  169. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x2.php +0 -116
  170. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x3.php +0 -127
  171. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-dg-cert-x4.php +0 -163
  172. wpsc-components/merchant-core-v3/gateways/php-merchant/tests/remote/paypal-ec-cert-x1.php +0 -356
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
1
+ cookbooks
2
+ tmp
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.12.1](http://wordpress.org/extend/plugins/wp-e-commerce).
19
+ * Active development version: 3.8.13-dev (branch [master](https://github.com/wp-e-commerce/WP-e-Commerce))
20
+ * [Roadmap for 3.8.13](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Roadmap)
21
+ * [3.8.13 tickets](https://github.com/wp-e-commerce/wp-e-commerce/issues?milestone=11&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,220 +146,9 @@ 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.
210
- * Fix: Anonymous cart items will be lost after signing in.
211
-
212
- = 3.8.13.1 =
213
- * Security and maintenance release
214
-
215
- = 3.8.13 =
216
-
217
- * New: Product Media UI.
218
- * New: Cart Item Meta API
219
- * New: 'wpsc_after_checkout_cart_rows' action.
220
- * New: Add 'wpsc_default_dimension_unit' and 'wpsc_default_weight_unit' filters.
221
- * New: Add 'wpsc_save_product_order' action and use it to save category product order in the term_relationships table.
222
- * New: Add logic filter for coupons. We currently have one for properties, this should sufficiently round out the extensibility for the UI.
223
- * New: Allow gateway images to be filtered.
224
- * New: Allow multiple comma-separated categories in coupon conditions.
225
- * New: Product Gallery metabox.
226
- * Change: Better Customer API.
227
- * Change: Prepend (WPEC) to widget names in wp-admin
228
- * Change: Replace default noimage.png with a better image.
229
- * Change: Updated NL language
230
- * Change: Updated german language strings
231
- * Change: Use new spinner image in WordPress 3.8
232
- * Fix: Add preg_quote() to coupon regexes that intend to parse strings. Fixes issue where unexpected results occur when strings contain slashes, or really, any regex-oriented characters.
233
- * Fix: Change wpsc_get_remaining_quantity() to call the method dynamically, rather than statically. The previous behaviour caused a strict standards warning.
234
- * Fix: Database Upgrade Routine to rename old _wpsc_* product metadata array keys so they no longer include the '_wpsc_' prefix
235
- * Fix: In Purchase log admin screen, item count is sum of quantity field rather than count of rows
236
- * Fix: Invert logic on shipping ZIP code check in core theme files.
237
- * Fix: Modify behavior in Download CSV functionality to properly convert region IDs to regions.
238
- * Fix: Modify wpsc_update_item_quantity() to listen for wpsc_quantity_update, reverting to $_POST['quantity'] only if it exists.
239
- * Fix: PHP strict warnings.
240
- * Fix: Properly quote SKUs in CSV file.
241
- * Fix: Rename generically named function.
242
- * Fix: Stock and sale price empty values should be preserved.
243
- * Fix: Variation thumbnail size in admin screen.
244
- * Fix: cart is not initialized when some shipping modules are triggered
245
- * Fix: redundant product thumbnail is displayed on category / single product list.
246
- * Fix: variation checkbox column width in WP 3.7.
247
- * Fix: Out of stock message for variations now correctly shows variation of product for the title, rather than main product.
248
- * Fix: Use proper link in checkout for variation products.
249
- * Fix: Return tax information in switchmethod() JS function.
250
- * Fix: Resolve conflict with Advanced Custom Fields on save_post hook for products.
251
- * Fix: Update Bulgarian Currency symbol.
252
- * Fix: Resolve issue where updating pages causes rewrite rule conflicts when pretty permalinks are enabled.
253
 
254
  = 3.8.12.1 =
255
  * Fix: Fatal error in wpsc_product_list_exclude_child_categories() due to other themes
@@ -262,7 +161,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 +332,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 +529,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.
@@ -774,44 +673,44 @@ After upgrading from earlier versions look for link "Update Store". This will up
774
  * Fix: Checking (or unchecking) Stock checkbox when editing product causes variation table columns to break.
775
  * Fix: jQuery 1.6 incompatibility with attr( 'className' ).
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.4
6
+ Tested up to: 3.6
7
+ Stable tag: 3.8.12.2
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.4 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.12.2 =
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.12.1 =
154
  * Fix: Fatal error in wpsc_product_list_exclude_child_categories() due to other themes
161
  * Change: Remove nusoap
162
  * Change: Improvements to Marketing admin panel
163
  * Change: Improvements to Products List Admin Page
164
+ * Fix: WP e-Commerce pagination breaks WordPress pagination
165
  * Fix: Wrong thumbnail size in Product Specials widget
166
  * Fix: Filtering by a category also shows all products in subcategories
167
  * Fix: admin.js throwing a Parse Error in Safari
332
  * Change: Default checkout shipping option to lowest shipping cost of all choices.
333
  * Fix: "Variation Controls" anchor in metabox leads nowhere.
334
  * Fix: AJAX code audit (security)
335
+ * Fix: Activating WP e-Commerce on a vanilla WordPress installation with pretty permalinks enabled messes up the rewrite rules.
336
  * Fix: Add a space after tilde character to avoid confusion in admin product list.
337
  * Fix: Add new variation sets and terms from Edit Product page doesn't work properly.
338
  * Fix: Additional description is double escaped in product edit page.
529
  * Fix: Fatal error when trying to include a non-existent admin file.
530
  * Fix: Hide Google Feed information from display
531
  * Fix: Incompatibility with Genesis framework in Product Edit page.
532
+ * Fix: Make the WP e-Commerce 3.8.x activation/installation routine much more efficient.
533
  * Fix: Mandatory fields in user_log_functions.php are not properly validated.
534
  * Fix: Memory improvement for productfeed.
535
  * Fix: Purchase logs have incorrect time if a timezone is specified in Settings->General.
673
  * Fix: Checking (or unchecking) Stock checkbox when editing product causes variation table columns to break.
674
  * Fix: jQuery 1.6 incompatibility with attr( 'className' ).
675
 
 
 
 
 
 
 
 
 
 
 
 
676
 
677
+ = 3.8.5 =
678
+ * New: Added hooks to support WPML.
679
+ * New: Links to WP e-Commerce documentation for individual payment gateways.
680
+ * Change: User can specify 0 in thumbnail width or height to make it scale proportional.
681
+ * Change: Show display name, not internal name for shipping method on purchase log view.
682
+ * Change: Presentation settings page is restored to WPEC Settings page when WooTheme is activated.
683
+ * Fix: Add to cart using Donation widget causes the page to reload and the item is added twice.
684
+ * Fix: Free-shipping discount causes tax to be calculated incorrectly.
685
+ * Fix: Paypal Buy Now button passes the wrong price to Paypal if product is on sale.
686
+ * Fix: Thumbnail sizes are not generated correctly.
687
+ * Fix: Broken output buffering rendering wpsc_add_advanced_options hook useless.
688
+ * Fix: Paypal Pro doesn't properly account for discount and coupon.
689
+ * Fix: IPN doesn't work on Paypal Standard.
690
+ * Fix: IPN doesn't work on Paypal Pro gateway.
691
+ * Fix: Paypal Express doesn't handle discounts.
692
+ * Fix: Paypal Express doesn't handle IPN.
693
+ * Fix: Paypal Express doesn't send purchase receipt after a payment is accepted on Paypal.
694
+ * Fix: Paypal Express doesn't include item description, quantity, tax etc. in email receipts.
695
+ * Fix: Invalid country code in Paypal Pro and Express, should be GB instead of UK
696
+ * Fix: Take Discount into account when DoExpressCheckout in Paypal Express gateway.
697
+ * Fix: Category checkout form sets don't work.
698
+ * Fix: Incorrect Product display mode selected when ['view_type'] is set and 'show_advanced_search' is disabled.
699
+ * Fix: PHP notice in wpsc-transaction_results_functions.php.
700
+ * Fix: attr('checked') == true always evaluates to false. Use is(':checked') instead.
701
+ * Fix: jQuery 1.6 select by attribute incompatibility.
702
+ * Fix: Price tag is added to RSS even when there is no price.
703
+ * Fix: Span tag is not closed in issue 598.
704
+ * Fix: Faulty php tag in template (issue 589).
705
+ * Fix: PHP Notices when checking out with shipping disabled.
706
 
707
+ == Frequently Asked Questions ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708
 
709
+ = How do I customize WP e-Commerce =
710
 
711
+ First of all you should check out the Presentation settings which are in the Settings->Store page.
712
 
713
+ 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/").
714
 
715
  == Screenshots ==
716
 
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
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,7 @@
17
  */
18
  class WP_eCommerce {
19
  private $components = array(
20
- 'merchant' => array(),
21
- 'marketplace' => array(),
22
- 'theme-engine' => array(),
23
  );
24
 
25
  /**
@@ -28,9 +26,9 @@ 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
  }
35
 
36
  /**
@@ -43,7 +41,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
 
@@ -58,87 +56,49 @@ class WP_eCommerce {
58
  }
59
 
60
  /**
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
- );
89
-
90
  return $components;
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;
126
- $wpdb->wpsc_region_tax = WPSC_TABLE_REGION_TAX;
127
- $wpdb->wpsc_coupon_codes = WPSC_TABLE_COUPON_CODES;
128
- $wpdb->wpsc_cart_contents = WPSC_TABLE_CART_CONTENTS;
129
- $wpdb->wpsc_claimed_stock = WPSC_TABLE_CLAIMED_STOCK;
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
  /**
143
  * Setup the WPEC core constants
144
  *
@@ -150,7 +110,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
 
@@ -169,9 +129,6 @@ class WP_eCommerce {
169
  // WPEC Table names and related constants
170
  wpsc_core_constants_table_names();
171
 
172
- // setup wpdb table name attributes
173
- $this->setup_table_names();
174
-
175
  // Uploads directory info
176
  wpsc_core_constants_uploads();
177
 
@@ -185,25 +142,17 @@ 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,20 +179,24 @@ 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
 
237
  // Legacy action
238
  do_action( 'wpsc_before_init' );
239
 
 
 
 
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();
@@ -257,15 +210,13 @@ class WP_eCommerce {
257
  // Load the shipping modules
258
  wpsc_core_load_shipping_modules();
259
 
 
 
 
260
  // WPEC is fully loaded
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 +224,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 ) {
@@ -301,5 +256,5 @@ class WP_eCommerce {
301
  $wpec = new WP_eCommerce();
302
 
303
  // Activation
304
- register_activation_hook( __FILE__ , array( $wpec, 'install' ) );
305
  register_deactivation_hook( __FILE__, array( $wpec, 'deactivate' ) );
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.12.2
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
  );
22
 
23
  /**
26
  * @uses add_action() Attaches to 'plugins_loaded' hook
27
  * @uses add_action() Attaches to 'wpsc_components' hook
28
  */
29
+ function WP_eCommerce() {
30
  add_action( 'plugins_loaded' , array( $this, 'init' ), 8 );
31
+ add_action( 'wpsc_components', array( $this, '_register_core_components' ) );
32
  }
33
 
34
  /**
41
  * @uses do_action() Calls 'wpsc_pre_init' which runs before WPEC initializes
42
  * @uses do_action() Calls 'wpsc_init' runs just after WPEC initializes
43
  */
44
+ function init() {
45
  // Previous to initializing
46
  do_action( 'wpsc_pre_init' );
47
 
56
  }
57
 
58
  /**
59
+ * @todo we need documentation finished here
60
  *
61
+ * @param array $components
 
62
  *
63
+ * @return array
 
 
 
64
  */
65
  public function _register_core_components( $components ) {
66
  $components['merchant']['core-v2'] = array(
67
+ 'title' => __( 'WP e-Commerce Merchant API v2', 'wpsc' ),
68
  'includes' =>
69
  WPSC_FILE_PATH . '/wpsc-components/merchant-core-v2/merchant-core-v2.php'
70
  );
71
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  return $components;
73
  }
74
 
75
  /**
76
+ * Initialize the basic WPEC constants
77
  *
78
  * @uses plugins_url() Retrieves url to plugins directory
79
  * @uses load_plugin_textdomain() Loads plugin transations strings
80
  * @uses plugin_basename() Gets the basename of a plugin (extracts the name of a plugin from its filename)
81
  * @uses do_action() Calls 'wpsc_started' which runs after WPEC has started
82
  */
83
+ function start() {
84
  // Set the core file path
85
  define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
86
 
87
  // Define the path to the plugin folder
88
  define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
 
89
 
90
  // Define the URL to the plugin folder
91
+ define( 'WPSC_FOLDER', dirname( plugin_basename( __FILE__ ) ) );
92
  define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
93
 
94
  //load text domain
95
+ if( !load_plugin_textdomain( 'wpsc', false, '../languages/' ) )
96
+ load_plugin_textdomain( 'wpsc', false, dirname( plugin_basename( __FILE__ ) ) . '/wpsc-languages/' );
 
97
 
98
  // Finished starting
99
  do_action( 'wpsc_started' );
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  /**
103
  * Setup the WPEC core constants
104
  *
110
  * @uses wpsc_core_constants_uploads() Set the upload related constants
111
  * @uses do_action() Calls 'wpsc_constants' which runs after the WPEC constants are defined
112
  */
113
+ function constants() {
114
  // Define globals and constants used by wp-e-commerce
115
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
116
 
129
  // WPEC Table names and related constants
130
  wpsc_core_constants_table_names();
131
 
 
 
 
132
  // Uploads directory info
133
  wpsc_core_constants_uploads();
134
 
142
  * @uses apply_filters() Calls 'wpsc_components' private merchant components
143
  * @uses do_action() Calls 'wpsc_includes' which runs after WPEC files have been included
144
  */
145
+ function includes() {
 
 
 
 
 
146
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
147
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
148
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
149
 
150
  $this->components = apply_filters( 'wpsc_components', $this->components );
151
 
152
  foreach ( $this->components as $type => $registered ) {
153
  foreach ( $registered as $component ) {
154
+ if ( ! is_array( $component['includes'] ) )
 
155
  $component['includes'] = array( $component['includes' ] );
 
 
156
  foreach ( $component['includes'] as $include ) {
157
  require_once( $include );
158
  }
179
  * @uses wpsc_core_load_page_titles() Loads the core WPEC pagetitles
180
  * @uses do_action() Calls 'wpsc_loaded' which runs after WPEC is fully loaded
181
  */
182
+ function load() {
183
  // Before setup
184
  do_action( 'wpsc_pre_load' );
185
 
186
  // Legacy action
187
  do_action( 'wpsc_before_init' );
188
 
189
+ // Setup the customer ID just in case to make sure it's set up correctly
190
+ _wpsc_action_create_customer_id( 'create' );
191
+
192
  // Setup the core WPEC globals
193
  wpsc_core_setup_globals();
194
 
195
+ // Setup the core WPEC cart
196
+ wpsc_core_setup_cart();
197
 
198
+ // Load the thumbnail sizes
199
+ wpsc_core_load_thumbnail_sizes();
200
 
201
  // Load the purchase log statuses
202
  wpsc_core_load_purchase_log_statuses();
210
  // Load the shipping modules
211
  wpsc_core_load_shipping_modules();
212
 
213
+ // Set page title array for important WPSC pages
214
+ wpsc_core_load_page_titles();
215
+
216
  // WPEC is fully loaded
217
  do_action( 'wpsc_loaded' );
218
  }
219
 
 
 
 
 
 
220
  /**
221
  * WPEC Activation Hook
222
  *
224
  * @uses wp_die() Kills loading and returns the HTML
225
  * @uses wpsc_install() Performs checks to see if this is a clean install or not
226
  */
227
+ function install() {
228
+ global $wp_version;
229
+ if((float)$wp_version < 3.0){
230
+ deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourselves
231
+ 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));
232
+ return;
233
  }
234
+ define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
235
  require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
236
  $this->constants();
237
  wpsc_install();
238
+
239
  }
240
 
241
  /**
242
+ * Runs the WPEC deactivation routines which basically just removes the cron
243
+ * jobs that WPEC has set.
244
  *
245
+ * @uses wp_get_schedules() Retrieves all filtered Cron recurrences
246
+ * @uses wp_clear_scheduled_hook() Removes any hooks on cron
247
  */
248
  public function deactivate() {
249
  foreach ( wp_get_schedules() as $cron => $schedule ) {
256
  $wpec = new WP_eCommerce();
257
 
258
  // Activation
259
+ register_activation_hook( __FILE__, array( $wpec, 'install' ) );
260
  register_deactivation_hook( __FILE__, array( $wpec, 'deactivate' ) );
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']);
@@ -155,14 +148,14 @@ $output ='
155
  <input type="submit" value="'.esc_attr__("Update Coupon", "wpsc").'" class="button-primary" name="edit_coupon['.$id.'][submit_coupon]" />';
156
 
157
  $nonced_url = admin_url( 'admin.php' );
158
- $nonced_url = add_query_arg(
159
  array(
160
  'wpsc_admin_action' => 'wpsc-delete-coupon',
161
  'delete_id' => $id,
162
  '_wp_http_referer' => urlencode( admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ) ),
163
  ),
164
  $nonced_url
165
- );
166
  $nonced_url = wp_nonce_url( $nonced_url, 'delete-coupon' );
167
 
168
  $output.= "<a class='delete_button' style='text-decoration:none;' href=" .$nonced_url.">" . esc_html__( 'Delete', 'wpsc' ) . "</a>";
@@ -261,5 +254,201 @@ function wpsc_right_now() {
261
  <?php
262
  }
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  function wpsc_product_item_row() {
265
  }
1
  <?php
 
 
 
 
 
 
 
2
  function coupon_edit_form($coupon) {
3
 
4
  $conditions = maybe_unserialize($coupon['condition']);
148
  <input type="submit" value="'.esc_attr__("Update Coupon", "wpsc").'" class="button-primary" name="edit_coupon['.$id.'][submit_coupon]" />';
149
 
150
  $nonced_url = admin_url( 'admin.php' );
151
+ $nonced_url = esc_url( add_query_arg(
152
  array(
153
  'wpsc_admin_action' => 'wpsc-delete-coupon',
154
  'delete_id' => $id,
155
  '_wp_http_referer' => urlencode( admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ) ),
156
  ),
157
  $nonced_url
158
+ ) );
159
  $nonced_url = wp_nonce_url( $nonced_url, 'delete-coupon' );
160
 
161
  $output.= "<a class='delete_button' style='text-decoration:none;' href=" .$nonced_url.">" . esc_html__( 'Delete', 'wpsc' ) . "</a>";
254
  <?php
255
  }
256
 
257
+
258
+ function wpsc_packing_slip( $purchase_id ) {
259
+ echo "<!DOCTYPE html><html><meta http-equiv=\"content-type\" content=\"text-html; charset=utf-8\"><head><title>" . __( 'Packing Slip', 'wpsc' ) . "</title></head><body id='wpsc-packing-slip'>";
260
+ global $wpdb;
261
+ $purch_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=%d", $purchase_id );
262
+ $purch_data = $wpdb->get_row( $purch_sql, ARRAY_A ) ;
263
+
264
+ $cartsql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=%d", $purchase_id );
265
+ $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ;
266
+ $j = 0;
267
+
268
+ if($cart_log != null) {
269
+ echo "<div class='packing_slip'>\n\r";
270
+ echo apply_filters( 'wpsc_packing_slip_header', '<h2>' . esc_html__( 'Packing Slip', 'wpsc' ) . "</h2>\n\r" );
271
+ echo "<strong>". esc_html__( 'Order', 'wpsc' )." #</strong> ".$purchase_id."<br /><br />\n\r";
272
+
273
+ echo "<table>\n\r";
274
+
275
+ $form_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_SUBMITTED_FORM_DATA."` WHERE `log_id` = %d", $purchase_id );
276
+ $input_data = $wpdb->get_results($form_sql,ARRAY_A);
277
+
278
+ foreach($input_data as $input_row) {
279
+ $rekeyed_input[$input_row['form_id']] = $input_row;
280
+ }
281
+
282
+
283
+ if($input_data != null) {
284
+ $form_data = $wpdb->get_results( "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' ORDER BY `checkout_order`" , ARRAY_A );
285
+
286
+ foreach($form_data as $form_field) {
287
+
288
+ switch($form_field['type']) {
289
+ case 'country':
290
+ $region_count_sql = $wpdb->prepare( "SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('%s')", $purch_data['billing_country'] );
291
+ $delivery_region_count = $wpdb->get_var( $region_count_sql );
292
+
293
+ if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0))
294
+ echo " <tr><td>".esc_html__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
295
+
296
+ echo " <tr><td>" . esc_html( $form_field['name'] ) . ":</td><td>" . esc_html( $rekeyed_input[$form_field['id']]['value'] ) . "</td></tr>\n\r";
297
+ break;
298
+
299
+ case 'delivery_country':
300
+
301
+ if(is_numeric($purch_data['shipping_region']) && ($delivery_region_count > 0))
302
+ echo " <tr><td>".esc_html__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['shipping_region'])."</td></tr>\n\r";
303
+
304
+ echo " <tr><td>" . esc_html( $form_field['name'] ) . ":</td><td>" . esc_html( $rekeyed_input[ $form_field['id']]['value'] ) . "</td></tr>\n\r";
305
+ break;
306
+
307
+ case 'heading':
308
+
309
+ if($form_field['name'] == "Hidden Fields")
310
+ continue;
311
+ else
312
+ echo " <tr class='heading'><td colspan='2'><strong>" . esc_html( $form_field['name'] ) . ":</strong></td></tr>\n\r";
313
+ break;
314
+
315
+ default:
316
+ if ($form_field['name']=="State" && !empty($purch_data['billing_region']) || $form_field['name']=="State" && !empty($purch_data['billing_region']))
317
+ echo "";
318
+ else
319
+ echo " <tr><td>" . esc_html( $form_field['name'] ) . ":</td><td>".
320
+ ( isset( $rekeyed_input[$form_field['id']] ) ? esc_html( $rekeyed_input[$form_field['id']]['value'] ) : '' ) .
321
+ "</td></tr>\n\r";
322
+ break;
323
+ }
324
+
325
+ }
326
+ } else {
327
+ echo " <tr><td>".esc_html__('Name', 'wpsc').":</td><td>".$purch_data['firstname']." ".$purch_data['lastname']."</td></tr>\n\r";
328
+ echo " <tr><td>".esc_html__('Address', 'wpsc').":</td><td>".$purch_data['address']."</td></tr>\n\r";
329
+ echo " <tr><td>".esc_html__('Phone', 'wpsc').":</td><td>".$purch_data['phone']."</td></tr>\n\r";
330
+ echo " <tr><td>".esc_html__('Email', 'wpsc').":</td><td>".$purch_data['email']."</td></tr>\n\r";
331
+ }
332
+
333
+ if ( 2 == get_option( 'payment_method' ) ) {
334
+ $gateway_name = '';
335
+ global $nzshpcrt_gateways;
336
+
337
+ foreach( $nzshpcrt_gateways as $gateway ) {
338
+ if ( $purch_data['gateway'] != 'testmode' ) {
339
+ if ( $gateway['internalname'] == $purch_data['gateway'] ) {
340
+ $gateway_name = $gateway['name'];
341
+ }
342
+ } else {
343
+ $gateway_name = esc_html__('Manual Payment', 'wpsc');
344
+ }
345
+ }
346
+ }
347
+
348
+ echo "</table>\n\r";
349
+
350
+
351
+ do_action ('wpsc_packing_slip_extra_info',$purchase_id);
352
+
353
+
354
+ echo "<table class='packing_slip'>";
355
+
356
+ echo "<tr>";
357
+ echo " <th>".esc_html__('Quantity', 'wpsc')." </th>";
358
+
359
+ echo " <th>".esc_html__('Name', 'wpsc')."</th>";
360
+
361
+
362
+ echo " <th>".esc_html__('Price', 'wpsc')." </th>";
363
+
364
+ echo " <th>".esc_html__('Shipping', 'wpsc')." </th>";
365
+ echo '<th>' . esc_html__('Tax', 'wpsc') . '</th>';
366
+ echo '</tr>';
367
+ $endtotal = 0;
368
+ $all_donations = true;
369
+ $all_no_shipping = true;
370
+ $file_link_list = array();
371
+ $total_shipping = 0;
372
+ foreach($cart_log as $cart_row) {
373
+ $alternate = "";
374
+ $j++;
375
+ if(($j % 2) != 0) {
376
+ $alternate = "class='alt'";
377
+ }
378
+ // product ID will be $cart_row['prodid']. need to fetch name and stuff
379
+
380
+ $variation_list = '';
381
+
382
+ if($cart_row['donation'] != 1) {
383
+ $all_donations = false;
384
+ }
385
+
386
+ if($cart_row['no_shipping'] != 1) {
387
+ $shipping = $cart_row['pnp'];
388
+ $total_shipping += $shipping;
389
+ $all_no_shipping = false;
390
+ } else {
391
+ $shipping = 0;
392
+ }
393
+
394
+ $price = $cart_row['price'] * $cart_row['quantity'];
395
+ $gst = $price - ($price / (1+($cart_row['gst'] / 100)));
396
+
397
+ if($gst > 0) {
398
+ $tax_per_item = $gst / $cart_row['quantity'];
399
+ }
400
+
401
+
402
+ echo "<tr $alternate>";
403
+
404
+
405
+ echo " <td>";
406
+ echo $cart_row['quantity'];
407
+ echo " </td>";
408
+
409
+ echo " <td>";
410
+ echo apply_filters( 'the_title', $cart_row['name'] );
411
+ echo $variation_list;
412
+ echo " </td>";
413
+
414
+
415
+ echo " <td>";
416
+ echo wpsc_currency_display( $price );
417
+ echo " </td>";
418
+
419
+ echo " <td>";
420
+ echo wpsc_currency_display($shipping );
421
+ echo " </td>";
422
+
423
+
424
+
425
+ echo '<td>';
426
+ echo wpsc_currency_display( $cart_row['tax_charged'] );
427
+ echo '</td>';
428
+ echo '</tr>';
429
+ }
430
+
431
+ echo "</table>";
432
+ echo '<table class="packing-slip-totals">';
433
+ if ( floatval( $purch_data['discount_value'] ) )
434
+ echo '<tr><th>'.esc_html__('Discount', 'wpsc').'</th><td>(' . wpsc_currency_display( $purch_data['discount_value'] ) . ')</td></tr>';
435
+
436
+ echo '<tr><th>'.esc_html__('Base Shipping','wpsc').'</th><td>' . wpsc_currency_display( $purch_data['base_shipping'] ) . '</td></tr>';
437
+ echo '<tr><th>'.esc_html__('Total Shipping','wpsc').'</th><td>' . wpsc_currency_display( $purch_data['base_shipping'] + $total_shipping ) . '</td></tr>';
438
+ //wpec_taxes
439
+ if($purch_data['wpec_taxes_total'] != 0.00)
440
+ {
441
+ echo '<tr><th>'.esc_html__('Taxes','wpsc').'</th><td>' . wpsc_currency_display( $purch_data['wpec_taxes_total'] ) . '</td></tr>';
442
+ }
443
+ echo '<tr><th>'.esc_html__('Total Price','wpsc').'</th><td>' . wpsc_currency_display( $purch_data['totalprice'] ) . '</td></tr>';
444
+ echo '</table>';
445
+
446
+ echo "</div>\n\r";
447
+ } else {
448
+ echo "<br />".esc_html__('This users cart was empty', 'wpsc');
449
+ }
450
+
451
+ }
452
+
453
  function wpsc_product_item_row() {
454
  }
wpsc-admin/admin.php CHANGED
@@ -24,7 +24,6 @@ require_once( WPSC_FILE_PATH . '/wpsc-admin/init.php' );
24
  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 +32,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
  *
@@ -65,30 +60,7 @@ function wpsc_query_vars_product_list( $vars ){
65
  }
66
 
67
  /**
68
- * Admin Edit Posts Order
69
- *
70
- * @since 3.8.12
71
- * @access public
72
- *
73
- * @param string $orderby_sql Order by SQL.
74
- * @return string Filtered order by SQL.
75
- */
76
- function wpsc_admin_edit_posts_orderby( $orderby_sql ) {
77
- global $wp_query, $wpdb;
78
- if ( 'dragndrop' == get_option( 'wpsc_sort_by' ) ) {
79
- if ( function_exists( 'is_main_query' ) && is_main_query() && 'wpsc-product' == get_query_var( 'post_type' ) && is_tax( 'wpsc_product_category' ) ) {
80
- if ( ! empty( $orderby_sql ) )
81
- $orderby_sql = ', ' . $orderby_sql;
82
- $orderby_sql = " {$wpdb->term_relationships}.term_order ASC" . $orderby_sql;
83
- remove_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );
84
- }
85
- }
86
- return $orderby_sql;
87
- }
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 +73,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 +103,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 +234,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 +323,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 +337,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 +346,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 +356,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 +399,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 +411,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 +436,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 +472,23 @@ 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 +509,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 +529,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 +545,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 +572,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 +590,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 +813,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 +868,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 +883,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 +1040,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 +1120,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 +1280,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 +1298,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 +1384,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 +1443,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 +1457,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 +1466,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 +1480,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 +1497,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 +1506,13 @@ 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 +1523,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' );
24
  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
 
28
  if ( ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( $_SESSION['wpsc_activate_debug_page'] == true ) ) || ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( constant( 'WPSC_ADD_DEBUG_PAGE' ) == true ) ) )
29
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
32
  $form_sets = array( __( 'Default Checkout Forms', 'wpsc' ) );
33
  update_option( 'wpsc_checkout_form_sets', $form_sets );
34
  }
 
 
 
 
35
  /**
36
  * wpsc_query_vars_product_list sets the ordering for the edit-products page list
37
  *
60
  }
61
 
62
  /**
63
+ * setting the screen option to between 1 and 999
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  *
65
  * @since 3.8
66
  * @access public
73
  * @return $value after changes...
74
  */
75
  function wpsc_set_screen_option($status, $option, $value){
76
+ if( in_array($option, array ("edit_wpsc_variation_per_page","edit_wpsc_product_per_page" )) ){
77
  if ( "edit_wpsc_variation_per_page" == $option ){
78
  global $user_ID;
79
  update_user_option($user_ID,'edit_wpsc-variation_per_page',$value);
103
  return $per_page;
104
  }
105
  add_filter( 'request', 'wpsc_query_vars_product_list' );
106
+ add_filter('edit_posts_per_page' , 'wpsc_drag_and_drop_ordering', 10, 2 );
107
 
108
  /**
109
  * Checks whether to display or hide the update wp-e-commerce link
234
  add_action( 'load-post.php' , 'wpsc_add_help_tabs' );
235
  add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
236
  add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );
 
 
 
237
  }
238
 
239
  /**
323
  $content = '<p><strong>' . __( 'For More Information', 'wpsc' ) . '</strong></p>';
324
  $links = array();
325
  foreach( $tab['links'] as $link => $link_title ) {
326
+ $link = 'http://docs.getshopped.org/' . $link;
327
  $links[] = '<a target="_blank" href="' . esc_url( $link ) . '">' . esc_html( $link_title ) . '</a>';
328
  }
329
  $content .= '<p>' . implode( '<br />', $links ) . '</p>';
337
  }
338
  }
339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  /**
341
  * Includes purchase logs CSS and JS
342
  *
346
  * @uses wp_localize_script() Adds noncing and other data to the logs script
347
  */
348
  function wpsc_admin_include_purchase_logs_css_and_js() {
 
 
 
349
  wp_enqueue_script( 'wp-e-commerce-purchase-logs', WPSC_URL . '/wpsc-admin/js/purchase-logs.js', array( 'jquery' ), WPSC_VERSION . '.' . WPSC_MINOR_VERSION );
350
  wp_localize_script( 'wp-e-commerce-purchase-logs', 'WPSC_Purchase_Logs_Admin', array(
351
  'nonce' => wp_create_nonce( 'wpsc_purchase_logs' ),
356
  'sent_message' => _x( 'Email Sent!', 'sending tracking email for purchase log', 'wpsc' ),
357
  'current_view' => empty( $_REQUEST['status'] ) ? 'all' : $_REQUEST['status'],
358
  'current_filter' => empty( $_REQUEST['m'] ) ? '' : $_REQUEST['m'],
359
+ 'current_page' => empty( $_REQUEST['paged']) ? '' : $_REQUEST['paged'],
 
 
 
 
 
 
 
360
  ) );
 
361
  }
362
 
363
  /**
399
  * @uses admin_url() Retrieves URL to the WordPress admin
400
  */
401
  function wpsc_product_log_rss_feed() {
402
+ echo "<link type='application/rss+xml' href='" . esc_url( 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' />";
403
  }
404
 
405
  /**
411
  function wpsc_admin_include_coupon_js() {
412
 
413
  // Variables
414
+ $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
 
 
 
415
 
416
  // Coupon CSS
417
  wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
418
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
419
 
420
  // Coupon JS
421
+ wp_enqueue_script( 'wp-e-commerce-admin-parameters', admin_url( '/wp-admin/admin.php?wpsc_admin_dynamic_js=true' ), false, $version_identifier );
422
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
423
  wp_enqueue_script( 'jquery-ui-datepicker' );
 
 
424
  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 );
425
 
426
+ wp_enqueue_style ( 'wpsc-jquery-ui-datepicker', WPSC_URL . '/wpsc-admin/css/jquery.ui.datepicker-' . get_user_option( 'admin_color' ) . '.css', false, $version_identifier );
 
 
 
427
  }
428
 
429
  /**
436
  * @uses wp_enqueue_style() Includes and prints out the CSS for the WPEC options page
437
  */
438
  function wpsc_admin_include_optionspage_css_and_js() {
 
 
 
439
  $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
440
  wp_enqueue_script( 'wp-e-commerce-admin-settings-page', WPSC_URL . '/wpsc-admin/js/settings-page.js', array( 'jquery-query' ), $version_identifier );
441
 
472
  //if a variation page do not show these metaboxes
473
  if ( is_object( $post ) && $post->post_parent == 0 ) {
474
  add_meta_box( 'wpsc_product_variation_forms' , __( 'Variations', 'wpsc' ) , 'wpsc_product_variation_forms' , $pagename, 'normal', 'high' );
475
+ add_meta_box( 'wpsc_product_external_link_forms', __( 'Off Site Product link', 'wpsc' ), 'wpsc_product_external_link_forms', $pagename, 'normal', 'high' );
476
  } else if( is_object( $post ) && $post->post_status == "inherit" ) {
477
  remove_meta_box( 'tagsdiv-product_tag' , 'wpsc-product', 'core' );
478
+ remove_meta_box( 'wpsc_product_external_link_forms', 'wpsc-product', 'core' );
479
  remove_meta_box( 'wpsc_product_categorydiv' , 'wpsc-product', 'core' );
480
  }
481
 
482
+ add_meta_box( 'wpsc_price_control_forms', __('Price Control', 'wpsc'), 'wpsc_price_control_forms', $pagename, 'side', 'low' );
483
+ add_meta_box( 'wpsc_stock_control_forms', __('Stock Control', 'wpsc'), 'wpsc_stock_control_forms', $pagename, 'side', 'low' );
484
  add_meta_box( 'wpsc_product_taxes_forms', __('Taxes', 'wpsc'), 'wpsc_product_taxes_forms', $pagename, 'side', 'low' );
485
+ add_meta_box( 'wpsc_additional_desc', __('Additional Description', 'wpsc'), 'wpsc_additional_desc', $pagename, 'normal', 'high' );
486
+ add_meta_box( 'wpsc_product_download_forms', __('Product Download', 'wpsc'), 'wpsc_product_download_forms', $pagename, 'normal', 'high' );
487
+ add_meta_box( 'wpsc_product_image_forms', __('Product Images', 'wpsc'), 'wpsc_product_image_forms', $pagename, 'normal', 'high' );
488
+ if ( ! empty( $post->ID ) && ! wpsc_product_has_variations( $post->ID ) )
489
+ add_meta_box( 'wpsc_product_shipping_forms', __('Shipping', 'wpsc'), 'wpsc_product_shipping_forms_metabox', $pagename, 'normal', 'high' );
490
+ add_meta_box( 'wpsc_product_advanced_forms', __('Advanced Settings', 'wpsc'), 'wpsc_product_advanced_forms', $pagename, 'normal', 'high' );
491
  }
 
492
  add_action( 'admin_footer', 'wpsc_meta_boxes' );
493
  add_action( 'admin_enqueue_scripts', 'wpsc_admin_include_css_and_js_refac' );
494
 
509
 
510
  $current_screen = get_current_screen();
511
 
512
+ if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) )
513
+ wp_admin_css( 'dashboard' );
514
+
515
  if ( 'dashboard_page_wpsc-sales-logs' == $current_screen->id ) {
516
  // jQuery
517
  wp_enqueue_script( 'jquery' );
529
  $pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
530
 
531
  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' ) ) {
 
 
 
532
  wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
533
+ wp_enqueue_script( 'wp-e-commerce-admin-parameters', admin_url( 'admin.php?wpsc_admin_dynamic_js=true' ), false, $version_identifier );
534
  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 );
535
  wp_enqueue_script( 'wpsc-sortable-table', WPSC_URL . '/wpsc-admin/js/sortable-table.js', array( 'jquery' ) );
536
 
545
  );
546
  }
547
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
548
+ wp_enqueue_style( 'wp-e-commerce-admin-dynamic', admin_url( "admin.php?wpsc_admin_dynamic_css=true" ), false, $version_identifier, 'all' );
549
+ // Localize scripts
550
+ wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
551
+ 'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
552
+ 'save_product_order_nonce' => _wpsc_create_ajax_nonce( 'save_product_order' ),
553
+ 'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};',
554
+ 'empty_coupon' => esc_html__( 'Please enter a coupon code.', 'wpsc' ),
555
+ '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' ),
556
+ 'wpsc_core_images_url' => WPSC_CORE_IMAGES_URL,
557
+ 'variation_parent_swap' => esc_html_x( 'New Variation Set', 'Variation taxonomy parent', 'wpsc' ),
558
+ /* translators : This string is prepended to the 'New Variation Set' string */
559
+ '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' ),
560
+ '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' ),
561
+ /* translators : These strings are dynamically inserted as a drop-down for the Coupon comparison conditions */
562
+ 'coupons_compare_or' => esc_html_x( 'OR' , 'Coupon comparison logic', 'wpsc' ),
563
+ 'coupons_compare_and' => esc_html_x( 'AND' , 'Coupon comparison logic', 'wpsc' ),
564
+ ) );
 
 
 
 
 
 
 
 
 
 
565
  }
566
  if ( $pagehook == 'wpsc-product-variations-iframe' ) {
 
 
567
  wp_enqueue_script( 'wp-e-commerce-product-variations', WPSC_URL . '/wpsc-admin/js/product-variations.js', array( 'jquery' ), $version_identifier );
568
  wp_localize_script( 'wp-e-commerce-product-variations', 'WPSC_Product_Variations', array(
569
  'product_id' => $_REQUEST['product_id'],
572
  }
573
 
574
  if ( $pagehook == 'media-upload-popup' ) {
 
575
  $post = get_post( $_REQUEST['post_id'] );
576
  if ( $post->post_type == 'wpsc-product' && $post->post_parent ) {
 
 
577
  wp_dequeue_script( 'set-post-thumbnail' );
578
  wp_enqueue_script( 'wpsc-set-post-thumbnail', WPSC_URL . '/wpsc-admin/js/set-post-thumbnail.js', array( 'jquery', 'wp-e-commerce-admin' ), $version_identifier );
579
  wp_localize_script( 'wpsc-set-post-thumbnail', 'WPSC_Set_Post_Thumbnail', array(
590
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
591
  }
592
 
 
593
  /**
594
+ * @todo docs
 
 
 
 
595
  *
596
+ * @uses get_option() Gets an option by name from the WordPress database
597
  */
598
+ function wpsc_admin_dynamic_js() {
599
+ header( 'Content-Type: text/javascript' );
600
+ header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
601
+ header( 'Cache-Control: public, must-revalidate, max-age=86400' );
602
+ header( 'Pragma: public' );
603
 
604
+ $hidden_boxes = get_option( 'wpsc_hidden_box' );
 
605
 
606
+ $form_types1 = get_option( 'wpsc_checkout_form_fields' );
607
+ $unique_names1 = get_option( 'wpsc_checkout_unique_names' );
 
 
 
 
 
 
 
608
 
609
  $form_types = '';
610
+ foreach ( (array)$form_types1 as $form_type ) {
611
+ $form_types .= "<option value='" . $form_type . "'>" . $form_type . "</option>";
612
  }
613
 
614
+ $unique_names = "<option value='-1'>" . __('Select a Unique Name', 'wpsc') . "</option>";
615
+ foreach ( (array)$unique_names1 as $unique_name ) {
616
+ $unique_names.= "<option value='" . $unique_name . "'>" . $unique_name . "</option>";
617
  }
618
 
619
+ $hidden_boxes = implode( ',', (array)$hidden_boxes );
620
+ echo "var base_url = '" . esc_js( site_url() ) . "';\n\r";
621
+ echo "var WPSC_URL = '" . esc_js( WPSC_URL ) . "';\n\r";
622
+ echo "var WPSC_IMAGE_URL = '" . esc_js( WPSC_IMAGE_URL ) . "';\n\r";
623
+ echo "var WPSC_DIR_NAME = '" . esc_js( WPSC_DIR_NAME ) . "';\n\r";
624
+ echo "var WPSC_IMAGE_URL = '" . esc_js( WPSC_IMAGE_URL ) . "';\n\r";
625
+
626
+ // LightBox Configuration start
627
+ echo "var fileLoadingImage = '" . esc_js( WPSC_CORE_IMAGES_URL ) . "/loading.gif';\n\r";
628
+ echo "var fileBottomNavCloseImage = '" . esc_js( WPSC_CORE_IMAGES_URL ) . "/closelabel.gif';\n\r";
629
+ echo "var fileThickboxLoadingImage = '" . esc_js( WPSC_CORE_IMAGES_URL ) . "/loadingAnimation.gif';\n\r";
630
+
631
+ echo "var resizeSpeed = 9;\n\r";
632
+
633
+ echo "var borderSize = 10;\n\r";
634
+
635
+ echo "var hidden_boxes = '" . esc_js( $hidden_boxes ) . "';\n\r";
636
+ echo "var IS_WP27 = '" . esc_js( IS_WP27 ) . "';\n\r";
637
+ echo "var TXT_WPSC_DELETE = '" . esc_js( __( 'Delete', 'wpsc' ) ) . "';\n\r";
638
+ echo "var TXT_WPSC_TEXT = '" . esc_js( __( 'Text', 'wpsc' ) ) . "';\n\r";
639
+ echo "var TXT_WPSC_EMAIL = '" . esc_js( __( 'Email', 'wpsc' ) ) . "';\n\r";
640
+ echo "var TXT_WPSC_COUNTRY = '" . esc_js( __( 'Country', 'wpsc' ) ) . "';\n\r";
641
+ echo "var TXT_WPSC_TEXTAREA = '" . esc_js( __( 'Textarea', 'wpsc' ) ) . "';\n\r";
642
+ echo "var TXT_WPSC_HEADING = '" . esc_js( __( 'Heading', 'wpsc' ) ) . "';\n\r";
643
+ echo "var TXT_WPSC_COUPON = '" . esc_js( __( 'Coupon', 'wpsc' ) ) . "';\n\r";
644
+
645
+ echo "var HTML_FORM_FIELD_TYPES =\" " . esc_js( $form_types ) . "; \" \n\r";
646
+ echo "var HTML_FORM_FIELD_UNIQUE_NAMES = \" " . esc_js( $unique_names ) . "; \" \n\r";
647
+
648
+ echo "var TXT_WPSC_LABEL = '" . esc_js( __( 'Label', 'wpsc' ) ) . "';\n\r";
649
+ echo "var TXT_WPSC_LABEL_DESC = '" . esc_js( __( 'Label Description', 'wpsc' ) ) . "';\n\r";
650
+ echo "var TXT_WPSC_ITEM_NUMBER = '" . esc_js( __( 'Item Number', 'wpsc' ) ) . "';\n\r";
651
+ echo "var TXT_WPSC_LIFE_NUMBER = '" . esc_js( __( 'Life Number', 'wpsc' ) ) . "';\n\r";
652
+ echo "var TXT_WPSC_PRODUCT_CODE = '" . esc_js( __( 'Product Code', 'wpsc' ) ) . "';\n\r";
653
+ echo "var TXT_WPSC_PDF = '" . esc_js( __( 'PDF', 'wpsc' ) ) . "';\n\r";
654
+
655
+ echo "var TXT_WPSC_AND_ABOVE = '" . esc_js( __( ' and above', 'wpsc' ) ) . "';\n\r";
656
+ echo "var TXT_WPSC_IF_PRICE_IS = '" . esc_js( __( 'If price is ', 'wpsc' ) ) . "';\n\r";
657
+ echo "var TXT_WPSC_IF_WEIGHT_IS = '" . esc_js( __( 'If weight is ', 'wpsc' ) ) . "';\n\r";
658
+
659
+ exit();
660
  }
661
 
662
+ if ( isset( $_GET['wpsc_admin_dynamic_js'] ) && ( $_GET['wpsc_admin_dynamic_js'] == 'true' ) ) {
663
+ add_action( "admin_init", 'wpsc_admin_dynamic_js' );
664
+ }
665
+
666
+ /**
667
+ * @todo finish docs
668
+ *
669
+ * @uses apply_filters() Allows manipulation of the flash upload params.
670
  */
671
+ function wpsc_admin_dynamic_css() {
672
+ header( 'Content-Type: text/css' );
673
+ header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
674
+ header( 'Cache-Control: public, must-revalidate, max-age=86400' );
675
+ header( 'Pragma: public' );
676
+ $flash = 0;
677
+ $flash = apply_filters( 'flash_uploader', $flash );
678
+
679
+ if ( $flash = 1 ) {
680
+ ?>
681
+ div.flash-image-uploader {
682
+ display: block;
683
+ }
684
+
685
+ div.browser-image-uploader {
686
+ display: none;
687
+ }
688
+ <?php
689
+ } else {
690
+ ?>
691
+ div.flash-image-uploader {
692
+ display: none;
693
+ }
694
+
695
+ div.browser-image-uploader {
696
+ display: block;
697
+ }
698
+ <?php
699
  }
700
+ exit();
701
+ }
702
+
703
+ if ( isset( $_GET['wpsc_admin_dynamic_css'] ) && ( $_GET['wpsc_admin_dynamic_css'] == 'true' ) ) {
704
+ add_action( "admin_init", 'wpsc_admin_dynamic_css' );
705
  }
706
 
707
  add_action( 'admin_menu', 'wpsc_admin_pages' );
813
 
814
  // Add the dashboard widgets
815
  if ( current_user_can( $news_cap ) )
816
+ wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'WP e-Commerce News' , 'wpsc' ), 'wpsc_dashboard_news' );
817
  if ( current_user_can( $sales_cap ) )
818
  wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary', 'wpsc' ), 'wpsc_dashboard_widget' );
819
  if ( current_user_can( $quarterly_sales_cap ) )
868
  * @uses wp_widget_rss_output() Display the RSS entries in a list
869
  */
870
  function wpsc_dashboard_news() {
871
+ $rss = fetch_feed( 'http://getshopped.org/feed/?category_name=wp-e-commerce-plugin' );
872
  $args = array( 'show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items' => 3 );
873
  wp_widget_rss_output( $rss, $args );
874
 
883
  * @return array The array of prices
884
  */
885
  function wpsc_get_quarterly_summary() {
886
+ (int)$firstquarter = get_option( 'wpsc_first_quart' );
887
+ (int)$secondquarter = get_option( 'wpsc_second_quart' );
888
+ (int)$thirdquarter = get_option( 'wpsc_third_quart' );
889
+ (int)$fourthquarter = get_option( 'wpsc_fourth_quart' );
890
+ (int)$finalquarter = get_option( 'wpsc_final_quart' );
891
 
892
  $results[] = admin_display_total_price( $thirdquarter + 1, $fourthquarter );
893
  $results[] = admin_display_total_price( $secondquarter + 1, $thirdquarter );
1040
  $timeranges[2]["start"] = mktime( 0, 0, 0, $this_month - 1, 1, $this_year );
1041
  $timeranges[2]["end"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
1042
  $timeranges[3]["start"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
1043
+ $timeranges[3]["end"] = mktime();
1044
 
1045
  $prod_data = array( );
1046
  foreach ( (array)$products as $product ) { //run through products and get each product income amounts and name
1120
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
1121
 
1122
  /**
1123
+ * Prits out the admin scripts
1124
  *
1125
+ * @uses is_ssl() Defines if SSL is true
1126
  * @uses wp_enqueue_script() Enqueues scripts
1127
  * @uses home_url() Returns the base url for the site
1128
  */
1129
  function wpsc_print_admin_scripts() {
1130
+ $scheme = is_ssl() ? 'https' : 'http';
1131
+ wp_enqueue_script( 'wp-e-commerce-dynamic', home_url( "/index.php?wpsc_user_dynamic_js=true", $scheme ) );
1132
+ }
1133
+
1134
+ /**
1135
+ * Update products page URL options when permalink scheme changes.
1136
+ *
1137
+ * @since 3.8.9
1138
+ * @access private
1139
+ *
1140
+ * @uses get_bloginfo() Returns information about your site to be used elsewhere
1141
+ * @uses version_compare() Compares two "PHP-standardized" version number strings
1142
+ * @uses _wpsc_display_permalink_refresh_notice() Display warning on older WordPress versions
1143
+ * @uses wpsc_update_page_urls() Gets the premalinks for product pages and stores for quick reference
1144
+ */
1145
+ function _wpsc_action_permalink_structure_changed() {
1146
+ $wp_version = get_bloginfo( 'version' );
1147
+
1148
+ // see WordPress core trac ticket:
1149
+ // http://core.trac.wordpress.org/ticket/16736
1150
+ // this has been fixed in WordPress 3.3
1151
+ if ( version_compare( $wp_version, '3.3', '<' ) )
1152
+ _wpsc_display_permalink_refresh_notice();
1153
+ add_action( 'admin_notices', 'wpsc_check_permalink_notice' );
1154
+
1155
+ wpsc_update_page_urls( true );
1156
+ }
1157
+
1158
+ /**
1159
+ * Display warning if the user is using WordPress prior to 3.3 because there is a bug with custom
1160
+ * post type and taxonomy permalink generation.
1161
+ *
1162
+ * @since 3.8.9
1163
+ * @access private
1164
+ */
1165
+ function _wpsc_display_permalink_refresh_notice(){
1166
+ ?>
1167
+ <div id="notice" class="error fade">
1168
+ <p>
1169
+ <?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' ); ?>
1170
+ </p>
1171
+ </div>
1172
+ <?php
1173
  }
1174
 
1175
+
1176
  /**
1177
  * wpsc_ajax_ie_save save changes made using inline edit
1178
  *
1280
  $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' );
1281
  break;
1282
  case 'UK':
1283
+ $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' );
1284
  break;
1285
  case 'AN':
1286
  $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' );
1287
  case 'TP':
1288
+ $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' );
1289
  break;
1290
  }
1291
 
1298
  echo '<div id="wpsc-warning" class="error"><p>' . $message . '</p></div>';
1299
  }
1300
 
1301
+ add_action( 'admin_notices', '_wpsc_action_admin_notices_deprecated_countries_notice' );
1302
+ add_action( 'permalink_structure_changed' , '_wpsc_action_permalink_structure_changed' );
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
  // Copy the meta information
1385
  wpsc_duplicate_product_meta( $post->ID, $new_post_id );
1386
 
 
 
1387
  // Finds children (Which includes product files AND product images), their meta values, and duplicates them.
1388
  wpsc_duplicate_children( $post->ID, $new_post_id );
1389
 
1443
  $sql_query.= implode( ",", $sql_query_sel );
1444
  $sql_query = $wpdb->prepare( $sql_query, $values );
1445
  $wpdb->query( $sql_query );
 
1446
  }
 
1447
  }
1448
 
1449
  /**
1457
  */
1458
  function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
1459
 
1460
+ //Get children products and duplicate them
1461
  $child_posts = get_posts( array(
1462
  'post_parent' => $old_parent_id,
1463
  'post_type' => 'any',
1466
  'order' => 'ASC',
1467
  ) );
1468
 
1469
+ foreach ( $child_posts as $child_post )
1470
+ wpsc_duplicate_product_process( $child_post, $new_parent_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1471
 
1472
  }
1473
 
1480
  * @uses get_option() Gets option from the database given string
1481
  */
1482
  function _wpsc_admin_notices_3dot8dot9() {
1483
+ $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>';
1484
  $message .= "\n<p>" . __( '<a href="%2$s">Hide this warning</a>', 'wpsc' ) . '</p>';
1485
  $message = sprintf(
1486
  $message,
1487
+ 'http://getshopped.org/wp-e-commerce-3-8-9-compatibility-issues/',
1488
+ esc_url( add_query_arg( 'dismiss_389_upgrade_notice', 1 ) )
1489
  );
1490
 
1491
  echo '<div id="wpsc-3.8.9-notice" class="error">' . $message . '</div>';
1497
  if ( ! get_option( 'wpsc_hide_3.8.9_notices' ) )
1498
  add_action( 'admin_notices', '_wpsc_admin_notices_3dot8dot9' );
1499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1500
  /**
1501
  * @todo docs
1502
  * @access private
1506
  * @uses get_option() Gets option from the database given string
1507
  */
1508
  function _wpsc_admin_notices_3dot8dot11() {
1509
+ $message = '<p>' . __( 'You are currently using WPeC 3.8.11. We have included a fix for a <a href="%1$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="%2$s">simple instructions for you to follow</a> to resolve the issue. We are sorry for the inconvenience.' , 'wpsc' ) . '</p>';
1510
+ $message .= "\n<p>" . __( '<a href="%3$s">Hide this warning</a>', 'wpsc' ) . '</p>';
1511
+ $message = sprintf(
1512
  $message,
 
1513
  'https://github.com/wp-e-commerce/WP-e-Commerce/issues/359',
1514
+ 'http://docs.getshopped.org/documentation/3-8-11-user-logs',
1515
+ esc_url( add_query_arg( 'dismiss_3811_upgrade_notice', 1 ) )
1516
  );
1517
 
1518
  echo '<div id="wpsc-3.8.11-notice" class="error">' . $message . '</div>';
1523
 
1524
  if ( get_option( '_wpsc_3811_user_log_notice' ) )
1525
  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,25 +15,20 @@
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'] ) )
22
  $nonce = $_REQUEST['_wpnonce'];
23
  else
24
- return _wpsc_error_invalid_nonce();
25
 
26
  // validate nonce
27
  if ( ! wp_verify_nonce( $nonce, 'wpsc_ajax_' . $ajax_action ) )
28
- return _wpsc_error_invalid_nonce();
29
 
30
  return true;
31
  }
32
 
33
- function _wpsc_error_invalid_nonce() {
34
- return new WP_Error( 'wpsc_ajax_invalid_nonce', __( 'Your session has expired. Please refresh the page and try again.', 'wpsc' ) );
35
- }
36
-
37
  /**
38
  * Verify AJAX callback and call it if it exists.
39
  *
@@ -73,11 +68,7 @@ function _wpsc_ajax_fire_callback( $ajax_action ) {
73
  */
74
  function _wpsc_ajax_handler() {
75
  $ajax_action = str_replace( '-', '_', $_REQUEST['wpsc_action'] );
76
-
77
- if ( is_callable( '_wpsc_ajax_verify_' . $ajax_action ) )
78
- $result = call_user_func( '_wpsc_ajax_verify_' . $ajax_action );
79
- else
80
- $result = _wpsc_ajax_verify_nonce( $ajax_action );
81
 
82
  if ( ! is_wp_error( $result ) )
83
  $result = _wpsc_ajax_fire_callback( $ajax_action );
@@ -192,32 +183,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 +372,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 +397,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 +452,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 +468,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 );
@@ -621,10 +530,6 @@ function _wpsc_ajax_save_product_order() {
621
  $failed[] = $product_id;
622
  }
623
 
624
- // Validate data before exposing to action
625
- $category = isset( $_POST['category_id'] ) ? get_term_by( 'slug', $_POST['category_id'], 'wpsc_product_category' ) : false;
626
- do_action( 'wpsc_save_product_order', $products, $category );
627
-
628
  if ( ! empty( $failed ) ) {
629
  $error_data = array(
630
  'failed_ids' => $failed,
@@ -638,39 +543,6 @@ function _wpsc_ajax_save_product_order() {
638
  );
639
  }
640
 
641
- /**
642
- * Save Category Product Order
643
- *
644
- * Note that this uses the 'term_order' field in the 'term_relationships' table to store
645
- * the order. Although this column presently seems to be unused by WordPress, the intention
646
- * is it should be used to store the order of terms associates to a post, not the order
647
- * of posts as we are doing. This shouldn't be an issue for WPEC unless WordPress adds a UI
648
- * for this. More info at http://core.trac.wordpress.org/ticket/9547
649
- *
650
- * @since 3.9
651
- * @access private
652
- *
653
- * @uses $wpdb WordPress database object used for queries
654
- */
655
- function _wpsc_save_category_product_order( $products, $category ) {
656
- global $wpdb;
657
-
658
- // Only save category product order if in category
659
- if ( ! $category )
660
- return;
661
-
662
- // Save product order in term_relationships table
663
- foreach ( $products as $order => $product_id ) {
664
- $wpdb->update( $wpdb->term_relationships,
665
- array( 'term_order' => $order ),
666
- array( 'object_id' => $product_id, 'term_taxonomy_id' => $category->term_taxonomy_id ),
667
- array( '%d' ),
668
- array( '%d', '%d' )
669
- );
670
- }
671
- }
672
- add_action( 'wpsc_save_product_order', '_wpsc_save_category_product_order', 10, 2 );
673
-
674
  /**
675
  * Update Checkout fields order
676
  *
@@ -880,7 +752,6 @@ function _wpsc_ajax_add_tax_rate() {
880
  */
881
  function wpsc_product_variations_table() {
882
  check_admin_referer( 'wpsc_product_variations_table' );
883
- set_current_screen( 'wpsc-product' );
884
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-variations-page.class.php' );
885
  $page = new WPSC_Product_Variations_Page();
886
  $page->display();
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'] ) )
21
  $nonce = $_REQUEST['_wpnonce'];
22
  else
23
+ return new WP_Error( 'wpsc_ajax_invalid_nonce', __( 'Your session has expired. Please refresh the page and try again.', 'wpsc' ) );
24
 
25
  // validate nonce
26
  if ( ! wp_verify_nonce( $nonce, 'wpsc_ajax_' . $ajax_action ) )
27
+ return new WP_Error( 'wpsc_ajax_invalid_nonce', __( 'Your session has expired. Please refresh the page and try again.', 'wpsc' ) );
28
 
29
  return true;
30
  }
31
 
 
 
 
 
32
  /**
33
  * Verify AJAX callback and call it if it exists.
34
  *
68
  */
69
  function _wpsc_ajax_handler() {
70
  $ajax_action = str_replace( '-', '_', $_REQUEST['wpsc_action'] );
71
+ $result = _wpsc_ajax_verify_nonce( $ajax_action );
 
 
 
 
72
 
73
  if ( ! is_wp_error( $result ) )
74
  $result = _wpsc_ajax_fire_callback( $ajax_action );
183
 
184
  require_once( 'includes/walker-variation-checklist.php' );
185
 
186
+ /* --- DIRTY HACK START --- */
187
+ /*
188
+ There's a bug with term cache in WordPress core. See http://core.trac.wordpress.org/ticket/14485.
189
+ The next 3 lines will delete children term cache for wpsc-variation.
190
+ Without this hack, the new child variations won't be displayed on "Variations" page and
191
+ also won't be displayed in wp_terms_checklist() call below.
192
+ */
193
+ clean_term_cache( $variation_set_id, 'wpsc-variation' );
194
+ delete_option('wpsc-variation_children');
195
+ wp_cache_set( 'last_changed', 1, 'terms' );
196
+ _get_term_hierarchy('wpsc-variation');
197
+ /* --- DIRTY HACK END --- */
 
 
 
 
198
 
199
  ob_start();
 
200
  wp_terms_checklist( (int) $_POST['post_id'], array(
201
  'taxonomy' => 'wpsc-variation',
202
  'descendants_and_self' => $variation_set_id,
203
  'walker' => new WPSC_Walker_Variation_Checklist( $inserted_variants ),
204
  'checked_ontop' => false,
205
  ) );
 
206
  $content = ob_get_clean();
207
 
208
  $return = array(
372
  $message = str_replace( '%trackid%', $trackingid, $message );
373
  $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
374
 
375
+ $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" );
376
+ $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 ) );
377
 
378
  $subject = get_option( 'wpsc_trackingid_subject' );
379
  $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
397
  return $return;
398
  }
399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  /**
401
  * Delete an attached downloadable file via AJAX.
402
  *
452
  *
453
  * @uses wpsc_purchlog_edit_status() Edits purchase log status
454
  * @uses WP_Error WordPress Error class
455
+ * @uses get_bloginfo() Gets information about your WordPress site
456
+ * @uses set_current_screen() Sets current screen object
457
  * @uses WPSC_Purchase_Log_List_Table
458
  * @uses WPSC_Purchase_Log_List_Table::prepare_items()
459
  * @uses WPSC_Purchase_Log_List_Table::views()
468
 
469
  $args = array();
470
 
471
+ if ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) )
472
+ set_current_screen( 'dashboard_page_wpsc-sales-logs' );
473
+ else
474
+ $args['screen'] = 'dashboard_page_wpsc-sales-logs';
475
 
476
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-list-table-class.php' );
477
  $purchaselog_table = new WPSC_Purchase_Log_List_Table( $args );
530
  $failed[] = $product_id;
531
  }
532
 
 
 
 
 
533
  if ( ! empty( $failed ) ) {
534
  $error_data = array(
535
  'failed_ids' => $failed,
543
  );
544
  }
545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  /**
547
  * Update Checkout fields order
548
  *
752
  */
753
  function wpsc_product_variations_table() {
754
  check_admin_referer( 'wpsc_product_variations_table' );
 
755
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-variations-page.class.php' );
756
  $page = new WPSC_Product_Variations_Page();
757
  $page->display();
wpsc-admin/css/admin.css CHANGED
@@ -1,311 +1,240 @@
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 +242,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 +339,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 +354,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 +368,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 +386,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 +403,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 +485,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 +598,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 +630,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 +654,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 +672,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 +690,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 +712,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 +751,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,90 +775,86 @@ 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;
985
- margin-top: 3px;
986
- overflow-x: hidden;
987
- overflow-y: auto;
988
- position: relative;
989
- width: 100%;
990
- }
991
 
992
  span.select_product_note {
993
  margin: 0 0 5px;
@@ -999,58 +866,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 +937,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 +1033,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 +1060,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 +1104,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 +1114,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 +1132,7 @@ a.edit_categorisation_group,
1269
 
1270
  label.select_categorisation_group {
1271
  padding-top: 4px;
 
1272
  font-size: 11px;
1273
  }
1274
 
@@ -1280,38 +1144,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 +1185,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 +1202,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 +1219,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 +1286,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 +1314,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 +1331,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 +1395,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 +1411,7 @@ div.wpsc_clear {
1610
  position: relative;
1611
  }
1612
 
 
1613
  .wpsc_featured .item_text {
1614
  float: left;
1615
  height: 240px;
@@ -1628,12 +1430,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 +1447,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 +1620,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 +1794,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 +1815,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 +1824,15 @@ 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 +1841,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,90 +1853,84 @@ 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
 
2108
- .wpsc-product-variations-tabs:before,
2109
- .wpsc-product-variations-tabs:after {
2110
- display: table;
2111
- content: "";
2112
  }
2113
 
2114
- .wpsc-product-variations-tabs:after {
2115
- clear: both;
 
 
 
2116
  }
2117
 
2118
  .wpsc-product-variations-tabs li {
2119
- float: left;
2120
- margin: 5px 4px 0 0px;
2121
  }
2122
 
2123
  .wpsc-product-variations-tabs a {
2124
- display: block;
2125
- background-color: #f1f1f1;
2126
- border-color: #dfdfdf #dfdfdf #fff;
2127
  border-style: solid;
2128
  border-width: 1px 1px 0;
2129
- line-height: 1em;
2130
  color: #aaa;
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 {
@@ -2144,14 +1938,12 @@ table.purchase-logs tr:hover .column-id .delete {
2144
  }
2145
 
2146
  .wpsc-product-variations-tabs .active a {
2147
- background: #fff;
2148
  border-bottom-width: 1px;
2149
  color: #333;
2150
- margin-bottom: -1px;
2151
  }
2152
 
2153
  .wpsc-product-variations-tab-content {
2154
- clear: both;
2155
  padding: 0 10px;
2156
  }
2157
 
@@ -2160,13 +1952,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 +1961,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 +1972,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 +2004,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-title {
6
+ width: 26%;
7
+ }
8
  table.wp-list-table .column-featured {
9
  width: 30px;
10
  }
 
11
  table.wp-list-table .column-price,
12
  table.wp-list-table .column-sale_price {
13
  width: 8%;
14
  }
 
15
  table.wp-list-table .column-SKU {
16
  width: 11%;
17
  }
 
18
  table.wp-list-table .column-stock {
19
  width: 8%;
20
  }
 
21
  table.wp-list-table .column-weight {
22
  width: 7%;
23
  }
 
24
  table.wp-list-table .column-cats {
25
  width: 15%;
26
  }
27
 
28
  ul.variation_checkboxes li {
29
+ margin: 1px 0 3px;
30
  }
 
31
  /* This is the variation meta box stuff need to put it in the correct place - mychelle */
32
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td span{
33
+ display:none;
 
34
  }
35
 
36
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.weight{
37
  width: 81px;
38
  }
39
 
40
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.stock{
41
  width: 110px;
42
  }
43
 
44
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.price{
45
  width: 125px;
46
  }
47
 
48
+ div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.post-title{
49
  width: 115px;
50
  }
51
 
52
  .wpsc_ie_stock[disabled] {
53
+ background-color:#f6f6f6;
54
  }
55
 
56
  div#wpsc_add_variant_desc,
57
+ div#wpsc_add_variation_desc{
58
  float: left;
59
+ margin:33px 0px 30px 20px;
60
  }
61
 
62
+ div#wpsc_add_variation_desc{
63
+ width:300px;
64
  }
65
 
66
+ div#wpsc_add_variant_desc{
67
+ width:200px;
68
  }
69
 
70
+ div#wpsc_add_variant{
71
  float: left;
72
  max-width: 245px;
73
  }
74
 
75
+ div #add_new_variation{
76
+ float:left;
77
+ width:215px;
78
  }
79
 
80
  input.wpsc_ie_field {
81
  margin-bottom:10px;
82
  }
83
 
84
+ .wpsc_ie_save{
85
+ margin-bottom:5px;
86
  }
87
 
88
+ .wpsc_trackingid_row{
89
+ margin-left:20px;
90
  }
91
 
92
+ ul.children{
93
+ padding-left:5px;
94
  }
95
+ .category_indenter{
96
+ float:left;
97
+ width:auto;
 
98
  }
99
 
 
100
  /**
101
+ *Dashboard Widget CSS
102
+ *
103
+ */
104
+ #leftDashboard{
105
+ width:45%;
106
+ float:left;
107
+ text-align:right;
108
+ border-right:1px #999999 solid;
109
+
110
+ }
111
+ #leftDashboard strong{
112
+ float:left;
 
113
  padding-left: 40px;
114
  }
115
+ #rightDashboard strong{
116
+ float:left;
 
117
  padding-left: 40px;
118
  }
119
+ #rightDashboard{
120
+ width:45%;
121
+ float:right;
122
+ text-align:right;
123
 
 
 
 
 
124
  }
125
+ .pricedisplay, .salespricedisplay{
126
+ /* width:40%; */
127
+ /*float:left;*/
128
+ }
129
+ .dashboardWidgetSpecial{
130
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
131
+ color:#21759B;
132
+ font-size:15px!important;
133
  margin: 5px 0 5px 0;
134
  }
135
+ .dashboardWidget{
136
+ color:#777777;
137
+ padding-left:10px;
 
138
  padding-right: 30px;
 
139
 
 
 
 
140
  }
141
+ span.wpsc_quart_left{
142
+ width:40%;
143
+ float:left;
 
 
 
144
  }
145
+ p.atglance{
146
+ color:#777777;
147
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
148
+ font-size:13px;
149
+ font-style:italic;
150
+ }
151
+ span.wpsc_quart_right{
152
+ width:60%;
153
+ float:right;
154
  text-align: right;
155
  }
156
+ #box span{
 
157
  border-bottom: 1px solid #999999;
158
  }
159
+ p.quarterly{
160
+ color:#21759B;
161
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
162
+ font-size:12px;
 
163
  line-height: 140%;
164
+ margin:5px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
+ /* end of dashboard widget css */
167
+ /*
168
+ *Display Purchase log Details CSS is HERE
169
+ */
170
+ #purchlogs_customfields{
171
+ clear:both;
172
  }
173
+ th#date{
174
+ width:120px;
 
175
  }
176
+ th#purchid{
177
+ width:60px;
 
 
178
  }
179
+ th#details{
180
+ width:100px;
 
181
  }
182
+ th#name{
183
+ /* width:220px; */
 
 
 
 
184
  }
185
+ th#track{
186
+ width:75px;
 
 
187
  }
188
+ th#delete{
189
+ width:60px;
 
190
  }
191
+ th#status{
192
+ width:200px;
 
193
  }
194
+ .google_checkout_logo{
195
+ padding-right:10px;
 
 
 
 
 
 
196
  }
197
+ #wpsc_items_ordered{
198
+ clear:both;
 
199
  }
200
+ #wpsc_items_ordered h3{
201
+ margin-bottom:0em;
 
202
  }
203
+ .wpsc_pushdown_img {
204
+ float:left;
 
 
205
  }
206
+ #wpsc_purchlogitems_links{
207
+ clear:both;
208
 
 
 
 
209
  }
210
+ #wpsc_purchlog_order_status{
211
+ float:right;
212
+ width:250px;
213
  }
214
+ #wpsc_purchlog_order_status .selector{
215
+ margin-top:-.2em;
 
216
  }
217
 
218
+ #wpsc_purchlogitems_links a{
219
+ text-decoration:none;
220
+ line-height:14pt;
221
  }
222
+ #wpsc_purchlogitems_links img{
223
+ padding-top:2px;
224
+ float:left;
225
  }
226
+ #wpsc_shipping_details_box{
227
+ width:45%;
228
+ float:left;
229
+ margin:.4em;
230
+ padding:.6em;
231
+ margin-right:5em;
 
232
  }
233
+ #wpsc_billing_details_box{
234
+ width:35%;
235
+ float:left;
236
+ margin:.4em;
237
+ padding:.6em;
 
238
  }
239
 
240
  #wpsc_shipping_details_box em.field-blank,
242
  color: #999;
243
  }
244
 
245
+ #wpsc_purchlog_searchbox{
246
+ width:100%;
247
+ text-align:right;
 
248
 
249
 
250
+ }
251
+ /*
252
+ * Display Purchase log Details CSS ends HERE
253
  * Display Products CSS starts here
254
+ */
 
255
  .tablenav select[name="bulkAction"] {
256
+ width:100px;
257
  }
258
+ textarea#additional_description{
 
259
  border: 1px solid #dfdfdf;
260
+ /* width:465px !important; */
261
  }
262
 
263
  #poststuff h3.form_heading {
264
+ font-size:1.1em;
265
  margin: 40px 0px 10px 0px;
266
  padding-left: 0px;
267
  }
268
 
269
  #poststuff h3.form_heading span {
270
+ font-size:0.8em;
271
  }
272
 
273
  div.search-box input#page-search-input {
274
  width: 129px;
275
+
276
  }
277
 
278
+
279
  #wpsc_product_list,
280
  table.widefat {
281
+ width:100%;
282
  }
283
 
284
  table.widefat .column-hidden_alerts {
285
+ display:none;
286
  }
287
 
288
  #wpsc_product_list .column-cb,
289
  table.widefat .column-cb {
290
+ /* width:24px; */
291
  vertical-align: middle;
292
  }
293
+ #wpsc_product_list .column-image, #wpsc_product_list .product-image,
294
+ table.widefat .column-image, table.widefat .product-image {
 
 
 
295
  padding-right: 0px;
296
  width: 42px;
297
  }
298
 
 
 
 
 
 
 
 
299
  #wpsc_product_list .column-categories,
300
+ table.widefat .column-categories{
301
+ /* width: 70px; */
302
  padding-right:18px;
303
  }
304
 
305
  #wpsc_product_list tbody tr td.column-title,
306
  table.widefat tbody tr td.column-title {
307
+ border-right:none;
308
  }
309
 
310
  #wpsc_product_list tbody tr td.product-image img,
311
  table.widefat tbody tr td.product-image img {
312
  margin-top: 4px;
313
+ cursor:move;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }
315
 
316
+ .newCurrency{
317
+ width:150px;
 
318
  }
319
+ div.wpsc_floatleft{
320
+ width:161px;
321
+ float:left;
 
322
  }
 
323
  div.wpsc_floatleft label {
324
+ line-height: 18px;
325
+ white-space: nowrap;
 
326
  }
327
 
328
+ /* Sortable product styling*/
 
 
 
329
 
330
  table.product_editform {
331
+ width:100%;
332
  }
333
 
334
+
335
  #wpsc_product_list .ui-sortable-helper,
336
  table.widefat .ui-sortable-helper {
337
  width: 410px;
339
  background-color: #FEFEFE;
340
  }
341
 
342
+ #wpsc_product_list .ui-sortable-helper td, #wpsc_product_list .ui-sortable-helper th,
343
+ table.widefat .ui-sortable-helper td, table.widefat .ui-sortable-helper th{
 
 
344
  border-top: 1px solid #DFDFDF;
345
  opacity: .4;
346
  }
347
+ .wpsc-sortable-table-placeholder td, .product-placeholder {
 
 
348
  border-width: 1px;
349
  border-style: dashed;
350
  z-index: 900;
354
  }
355
 
356
  div#poststuff table tr td {
357
+ vertical-align:top;
358
  }
359
 
360
  div#poststuff textarea {
368
 
369
  div.admin_product_name {
370
  position: relative;
371
+
372
+ height: 30px;
373
  background: #ffffff;
374
+
375
  border: 1px solid #dfdfdf;
376
+ -moz-border-radius: 6px;
377
+ -khtml-border-radius: 6px;
378
  -webkit-border-radius: 6px;
379
+ border-radius: 6px;
 
 
380
  }
 
381
  div.admin_product_name input.wpsc_product_name {
382
  border: none;
383
  }
386
  position: absolute;
387
  top: 0px;
388
  right: 0px;
389
+ background:url(../../wpsc-core/images/info_icon.jpg) no-repeat scroll 5px 8px;
390
+ border-left:1px solid #DFDFDF;
391
+ display:block;
392
+ height:100%;
393
+ padding:0px 3px 0px 3px;
394
+ width:18px;
395
  }
396
 
397
+ div#icon_card
398
+ {
399
  float: left;
400
  height: 36px;
401
  margin: 7px 8px 0 0;
403
  background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
404
  }
405
 
 
 
406
  div.admin_product_shorttags {
407
+ width:93%;
408
+ min-width:396px;
409
+ max-width:558px;
410
+
411
  clear: both;
412
  padding: 6px;
413
  font-size: 8pt;
414
+ margin:0 0 0 6px !important;
415
+ border-left:1px solid #DFDFDF;
416
+ border-right:1px solid #DFDFDF;
417
+ border-bottom:1px solid #DFDFDF;
418
+ /* height: 28px; */
419
  display: none;
420
+ _width:396px;
421
  background-color: #ffffff;
422
  }
423
 
424
  #description {
425
+ margin:0;
426
+ /* width:100%; */
427
  }
428
 
429
  h4.product_action_link {
430
+ margin:4px 0px 0px 0px;
431
+ display:block;
432
+ font-weight:bold;
433
+ }
434
+
435
+
436
+
437
+ /* custom meta styling */
438
+ div.product_custom_meta {
439
  display: block;
440
+ width: 100%;
441
+ vertical-align: top;
442
+ }
443
+ div#poststuff div.product_custom_meta input, div#poststuff div.product_custom_meta textarea {
444
+ width: 100%;
445
  }
446
 
447
 
448
+ div.product_custom_meta a.add_more_meta {
449
+ display: block;
450
+ float: left;
451
+ margin-top: 18px;
452
+ margin-left: 4px;
453
+ }
454
+
455
+ div.product_custom_meta a.remove_meta {
456
+ display: block;
457
+ margin-left: 4px;
458
+ }
459
+
460
 
461
+ div.product_custom_meta label {
462
+ display: block;
463
+ width: 170px;
464
+ float: left;
465
+ }
466
+
467
+ div.product_custom_meta label input {
468
+ font-size:13px;
469
+ width: 160px !important;
470
+ margin:1px !important;
471
+ padding:3px !important;
472
+ display: block;
473
+ }
474
+
475
+ div.product_custom_meta br {
476
+ clear: both;
477
+ }
478
+
479
+ /* image form styling */
480
  div.flash-image-uploader {
481
  display: none;
482
  }
485
  position: relative;
486
  border: none;
487
  }
488
+ #wpbody-content div.flash-image-uploader #media-items .progress{
 
489
  position: static;
490
+ margin:0 0 6px;
491
  height: 16px;
492
  }
493
 
494
  .ui-selected {
495
+ border:2px dashed #969696;
496
  }
497
 
498
  img.deleteButton {
499
+ display:none;
500
+ position:absolute;
501
+ top:-5px;
502
  right: -1px;
503
+ width:16px;
504
+ height:16px;
505
+ cursor:pointer;
506
  }
 
507
  a.editButton {
508
+ background:#FFFFFF none repeat scroll 0%;
509
+ height:20px;
510
+ display:none;
511
+ position:absolute;
512
+ right:0px;
513
+ top:0px;
514
+ padding-bottom:3px;
515
+ padding-left:3px;
516
+ cursor:pointer;
517
  }
518
 
519
  div.image_settings_box {
520
+ position:absolute;
521
+ width:150px;
522
+ display:none;
523
  margin: -66px 0px 0px 36px;
524
+ _margin: 0px 0px 0px -30px;
525
+ padding-top:2px;
526
+ width:252px;
527
+ z-index:69;
528
+ _z-index:80;
529
  }
530
 
531
  a.thickbox img {
532
+ border:medium none;
533
  }
534
 
535
  img.previewimage {
536
+ cursor:move;
537
+ height:60px;
538
+ margin-right:4px;
539
+ width:60px;
540
  }
541
 
542
  div.lower_settings_box {
543
+ width:234px;
544
+ background-color:white;
545
+ border:1px solid black;
546
+ border-top:1px solid #CCCCCC;
547
+ float:right;
548
  margin: -1px -6px 0px 0px;
549
  padding: 2px 0 0 4px;
550
+ background-color:#EAF3FA;
551
  }
552
 
553
  div.upper_settings_box {
554
+ width:250px;
555
+ background-color:white;
556
+ border:1px solid black;
557
+ padding:3px 1px 2px 5px;
558
  }
559
 
560
  div.upper_image {
561
+ float:left;
562
+ /* border-bottom:1px solid black; */
563
+ padding-left:5px;
564
+ margin-left:-5px;
565
+ _margin-left:-3px;
566
+ margin-right:-7px;
567
+ padding-bottom:4px;
568
+ _padding-bottom:6px;
569
+ _margin-bottom:-2px;
570
  }
571
 
572
+ div.upper_txt{
573
+ padding-left:22px;
574
+ color:#666666;
575
  }
576
 
577
  div.previewimage {
578
+ position:relative;
579
+ }
580
+
581
+ tr.edit_product_image *{
582
+ z-index:80;
583
  }
584
 
585
+ div.browser-image-uploader {
586
+
587
  }
588
 
589
+ div.browser-image-uploader h4{
590
  margin-bottom: 8px;
591
  }
592
 
598
  width: 100%;
599
  }
600
 
601
+ #wpsc_product_category_and_tag_forms table td.itemfirstcol{
602
+ padding-left:3pt;
603
  width: 50%;
604
  }
605
 
606
+ /* variations CSS starts */
607
 
608
+ table.product_variation_listing{
 
 
 
 
609
  margin-bottom: 12px;
610
  }
611
 
612
+ table.product_variation_listing th.variation_name{
613
  color: #71A4C8;
614
  font-style: italic;
615
  text-align: left;
616
  padding-bottom: 1px;
617
  }
618
 
619
+ table.product_variation_grid{
620
  margin-top: 12px;
621
  }
622
 
623
+ table.product_variation_grid th.variation_name{
624
  color: #71A4C8;
625
  font-style: italic;
626
  text-align: left;
630
  div#edit_variations_container {
631
  margin-top: 12px;
632
  }
 
633
  table.product_variation_grid {
634
  border-collapse: collapse;
635
  margin-top: 0px;
636
  }
637
 
638
+ table.product_variation_grid tr td, table.product_variation_grid tr th {
 
639
  border: 1px solid #cccccc;
640
  border-collapse: collapse;
641
  text-align: left;
654
  width: 78px;
655
  }
656
 
657
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
 
658
  padding: 4px 0px 4px 10px;
659
  }
660
 
661
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
 
662
  width: 300px;
663
  }
664
 
665
+
666
+ table.product_variation_grid tr td input{
667
  padding: 0px 3px 0px 3px;
668
  }
669
 
672
  }
673
 
674
  a.about_this_page_sub {
675
+ text-decoration:underline;
676
  }
677
 
678
+ table.product_variation_grid tr td, table.product_variation_grid tr th {
 
679
  border: 1px solid #cccccc;
680
  border-collapse: collapse;
681
  text-align: left;
690
  padding: 0px !important;
691
  }
692
 
693
+
694
  table.product_variation_grid tr.settings_row td div.variation_settings {
695
  display: none;
696
  border-top: 1px dotted #cccccc;
697
  width: 100%;
698
  min-height: 30px;
699
  padding: 4px 10px;
 
700
 
701
+ }
702
  table.product_variation_grid tr th {
703
  border-bottom: 1px solid #969696;
704
  }
712
  width: 78px;
713
  }
714
 
715
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
 
716
  padding: 4px 0px 4px 10px;
717
  }
718
 
719
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
 
720
  width: 300px;
721
  }
722
 
723
+
724
+ table.product_variation_grid tr td input{
725
  padding: 0px 3px 0px 3px;
726
  }
727
 
728
+ table.product_variation_grid tr td input.checkbox{
729
  display: block;
730
+ margin:6px auto;
731
  }
732
 
733
  table.product_variation_grid tr.group_boundary td {
751
  height: 16px;
752
  width: 16px;
753
  margin: 4px auto 0px auto;
754
+
755
  }
756
 
757
+ div.variation_settings div.variation_settings_contents{
758
  padding-left: 10px;
759
  }
760
 
761
  div.select_variation_file {
762
  padding-left: 6px;
763
  }
 
764
  div.select_variation_file p {
765
+ margin:0 0 3px;
766
  }
767
 
768
  div.select_variation_file p {
769
+ margin:0 0 3px;
770
  }
771
 
772
  div.select_variation_file p input {
775
  }
776
 
777
  .variation_checkboxes li {
778
+ margin:0;
779
  }
780
 
781
  .variation_checkboxes ul {
782
+ margin-left:30px;
783
  }
784
 
785
  .js .variation_checkboxes .children {
786
+ display:none;
787
  }
788
 
789
  .js .variation_checkboxes .expanded .children {
790
+ display:block;
791
  }
792
 
793
  .variation_checkboxes a.expand {
794
+ background:url(arrows.png) no-repeat left -108px;
795
+ display:inline-block;
796
+ height:15px;
797
+ width:15px;
798
+ text-indent:-999em;
799
+ vertical-align:middle;
800
  }
801
 
802
  .variation_checkboxes .expanded a.expand {
803
+ background-position:left top;
804
  }
805
 
806
  #add-new-variation-set {
807
+ margin-bottom:20px;
808
+ display:none;
809
  }
810
 
811
  #add-new-variation-set p {
812
+ position:relative;
813
  }
814
 
815
  #add-new-variation-set p.howto {
816
+ margin-bottom:16px;
817
  }
818
 
819
  #add-new-variation-set p label.focus {
820
+ color:#666;
821
  }
822
 
823
  #add-new-variation-set p.error label {
824
+ color:red;
825
  }
826
 
827
  #add-new-variation-set p label {
828
+ color:#000;
829
+ cursor:text;
830
+ left:6px;
831
+ position:absolute;
832
+ top:4px;
833
  }
834
 
835
  #add-new-variation-set .text-field {
836
+ width:195px;
837
  }
838
 
839
  .variation-set-prototype {
840
+ display:none;
841
  }
842
+ /* variations CSS ends */
 
843
 
844
  div#side-sortables input[type="file"] {
845
+ width:250px;
846
  }
 
847
  .wpsc_product_downloads_header {
848
  margin: 0 0 5px;
849
  }
 
850
  .select_product_file,
851
  .edit_select_product_file {
852
+ margin-bottom:0;
853
+ margin-top:3px;
854
+ overflow-x:hidden;
855
+ overflow-y:auto;
856
+ position:relative;
857
+ }
 
858
 
859
  span.select_product_note {
860
  margin: 0 0 5px;
866
  top: 2px;
867
  }
868
 
869
+ div#poststuff table tr.wpsc_product_download_row td {
870
+ padding: 6px 7px;
871
+ vertical-align: middle;
872
+ line-height: 16px;
 
 
 
 
 
 
 
 
 
 
873
  }
874
 
875
+ a.file_delete_button {
876
+ cursor:pointer;
877
+ color:red;
878
+ display: block;
879
  }
880
 
881
+ a.delete_button {
882
+ border-color:-moz-use-text-color -moz-use-text-color #FF0000;
883
+ border-style:none none solid;
884
+ border-width:medium medium 1px;
885
+ color:#FF0000;
886
+ font-size:11px;
887
+ padding:1px 2px;
888
+ text-decoration:none;
889
+ }
890
+ .greytext{
891
+ color:#666666;
892
+ }
893
+ span.small_italic{
894
  font-style: italic;
895
  }
896
+ /* Product details form styling ends */
897
+ /*
898
+ * Display Products CSS ends here
899
+ */
900
 
901
+ /*
902
+ * Product Groups styles start here
903
+ */
904
+ td.firstcol div.postbox div.inside{
 
 
 
 
 
 
905
  margin: 0px;
906
  padding: 0px;
907
  }
908
 
909
+ table#productpage{
910
  width: 100%;
911
  clear: both;
912
  border-collapse: collapse;
913
  }
914
 
915
+ table#productpage tr td{
916
  vertical-align: top;
917
+ /* padding: 0px 0px 0px 6px; */
918
  }
919
 
920
+ table#productpage tr td.secondcol{
921
+ /* width: 60%; */
922
+ /* margin-left: 20px; */
923
  padding: 0px 2px 0px 16px;
924
+
925
  }
926
 
927
+
928
  table.category-edit {
929
  border-collapse: collapse;
930
  width: 100%;
937
  width: 450px;
938
  }
939
 
940
+
941
  div.category-image-container {
942
  width: 55px;
943
  height: 30px;
944
+
945
  }
946
 
947
  div.category-image-container img {
948
  float: left;
949
  }
 
950
  div.category-image-container img.category_indenter {
951
  margin-right: 3px;
952
+ width:auto;
953
+ float:left;
954
  }
955
 
 
 
 
 
956
 
 
 
 
 
957
 
 
 
 
958
 
 
 
 
959
 
960
+ div#productform{ display: none; width: 99.5%; }
961
+
962
+ div#edititem27{ display: none; width: 586px; }
963
+
964
+ div#productform table tr td{ height: 11px !important; }
965
+
966
+
967
+
968
+
969
+ div#blank_item{ display: block;}
970
+
971
+ #poststuff div#blank_item h3{
972
  margin-top: 0px;
 
973
 
 
 
974
  }
975
 
976
+ div#additem{ display: none;}
 
 
 
977
 
978
+ div#productform td.itemfirstcol{ padding-left:4px; vertical-align: top; }
979
+
980
+
981
+
982
+
983
+ div#productform input.text, div#additem input.text{
984
+ width:386px;
985
+ border:1px solid #bbb;
986
  }
987
 
988
+
989
  table.category_forms {
990
  width: 100%;
991
  }
 
992
  table.category_forms tr td {
993
  padding: 0px;
994
  padding-right: 8px;
995
  }
996
+ table.category_forms tr td textarea {
 
997
  width: 386px;
998
  }
999
 
1000
+ div#edit_variation_values input.text{width:286px !important;border:1px solid #bbb;}
 
 
 
1001
 
1002
+ input.image_resize{ position: relative; top: 4px; }
 
 
 
1003
 
1004
+ div#additem table.additem input.wpsc_tag{
1005
+ width:180px;
1006
  }
1007
+ div#additem label{
 
1008
  font-style: normal;
1009
  font-size: 0.95em;
1010
  }
1011
 
1012
+
1013
+
1014
+
1015
+
1016
+ .groupItem{
1017
+ border-top:1px solid #bbb;
1018
+ width:385px;
1019
+ height:35px;
1020
  clear: both;
1021
+ /* margin-left:-6px; */
1022
  padding: 0px 0px 4px 0px;
1023
  }
1024
 
1025
+ .groupItem .itemHeader{
1026
+ width:65px;
1027
  line-height: 15px;
1028
  color: #000;
1029
  padding: 4px;
1033
  clear: both;
1034
  }
1035
 
1036
+ .groupItem .itemHeader a{
1037
  margin: 4px 0px 4px 0px;
1038
  font-weight: normal;
1039
  font-size: 11px;
1040
  text-decoration: none;
1041
  }
1042
+ .sortHelper{
 
1043
  border: 3px dashed #666;
1044
  width: auto;
1045
  }
1046
+ .groupWrapper p{
 
1047
  height: 1px;
1048
  overflow: hidden;
1049
  margin: 0;
1050
  padding: 0;
1051
  }
1052
 
1053
+
1054
  table#productpage tr td.secondcol.product_groups_page {
1055
  padding-left: 16px;
1056
  }
1060
  margin-top: 20px;
1061
  }
1062
 
1063
+ td.product_groups_page #additem .inside, td.product_groups_page #productform .inside {
 
1064
  margin: 0px 0px 15px 0px;
1065
  }
1066
 
1067
  div.editing_this_group {
1068
  margin-top: 8px;
1069
  margin-bottom: 8px;
1070
+ /* border-bottom:1px dotted black; */
1071
+ width:100%;
1072
  }
1073
 
1074
  td.product_groups_page h4 {
1075
  margin-bottom: 1ex;
1076
  }
1077
+ #editorcontainer{
1078
+ clear:both;
 
1079
  }
 
1080
  td.product_groups_page td.category_presentation_settings {
1081
  padding-bottom: 1ex;
1082
  }
1083
 
1084
  div.editing_this_group {
1085
+ font-size:8pt;
1086
  }
1087
 
1088
  div.editing_this_group p {
1089
+ padding:4px 4px 4px 8px;
1090
  }
1091
 
1092
  div.editing_this_group dl {
1093
+ padding:4px 4px 4px 8px;
1094
  }
1095
 
1096
+
1097
+ #blank_item a.add_category_link{
1098
  display: block;
1099
  margin: 8px 8px 8px 0px;
1100
  text-decoration: underline;
1104
  margin: 12px 0px 10px 0px;
1105
  }
1106
 
1107
+
1108
  table#wpsc_category_list td div.subcategory img.category_indenter {
1109
  float: left;
1110
  margin: 8px 0px 0px 0px;
1114
  float: left;
1115
  }
1116
 
1117
+
1118
+ label.select_categorisation_group, select#select_categorisation_group, a.add_categorisation_group, a.edit_categorisation_group, #submit_categorisation_form span {
 
 
 
1119
  display: block;
1120
  float: left;
1121
  }
1132
 
1133
  label.select_categorisation_group {
1134
  padding-top: 4px;
1135
+ /* color: #336699; */
1136
  font-size: 11px;
1137
  }
1138
 
1144
  margin-left: 30px;
1145
  }
1146
 
1147
+
1148
+
1149
+ div#add_categorisation, div#edit_categorisation{
1150
  display: none;
1151
  border: 1px solid #BBBBBB;
1152
  padding: 4px;
1153
  margin-top: 6px;
1154
  }
1155
 
1156
+ div#add_categorisation br, div#edit_categorisation br{
 
1157
  clear: both;
1158
  }
1159
 
1160
+
1161
+ div#add_categorisation fieldset, div#edit_categorisation fieldset{
1162
  width: 230px;
1163
  float: left;
1164
  border: none;
1165
  }
1166
 
1167
+ div#add_categorisation fieldset label, div#edit_categorisation fieldset label{
 
1168
  display: block;
1169
  }
1170
 
1171
+ ul.categorisation_links{
1172
  list-style-type: none;
1173
  clear: both;
1174
  padding: 0px;
1175
  }
1176
+ .wpsc_add_new_currency{
1177
+ text-decoration: none;
1178
+ }
1179
+ ul.categorisation_links li{
1180
  display: block;
1181
  float: left;
1182
  list-style-type: none;
1185
  padding: 4px;
1186
  }
1187
 
1188
+ ul.categorisation_links li.selected a{
1189
  color: #D54E21;
1190
  }
 
1191
  .multiple-select-container {
1192
  margin-left: 0.5em;
1193
  }
1202
  padding: 0 0 0 5px;
1203
  position: relative;
1204
  }
 
1205
  .multiple-select input {
1206
  width: inherit;
1207
  }
 
1208
  .multiple-select label {
1209
  display: inherit;
1210
  }
1211
 
1212
+ table.category_forms a.delete_button {
1213
  display: block;
1214
  margin: 3px 0px 0px 8px;
1215
  float: left;
1219
  padding: 16px 0px 0px 0px;
1220
  }
1221
 
1222
+ .wpsc_gold_float{
1223
+ min-width:45%;
1224
+ float:left;
1225
+ max-width:450px;
1226
+ _width:450px;
1227
  }
1228
+ .wpsc_gold_side{
1229
+ margin-top:90px;
1230
+ float:right;
1231
+ width:35%;
1232
+ }
1233
+ .wpsc_gold_text{
1234
+ width:70%;
1235
+ float:left;
1236
+ clear:both;
1237
  }
1238
 
1239
+ .wpsc_gold_info{
1240
+ width:30%;
1241
+ float:right;
1242
  text-align: center;
1243
+ font-size:20px;
1244
  }
1245
+ .wpsc_gold_module{
1246
+ width:100%;
1247
+ float:left;
1248
 
 
 
 
1249
  border-bottom: 1px solid #DFDFDF;
1250
  }
1251
+ .wpsc_gold_module strong{
1252
+ width:auto;
1253
+ float:left;
 
1254
  }
1255
+ #visitInstinct{
1256
+ float:right;
1257
+ margin:5px 20px 0 0;
 
1258
  }
1259
 
 
 
 
1260
 
1261
+ #gold_cart_form .postbox p img{
1262
+ padding-bottom:10px;
1263
  }
1264
+ #wpsc_gold_options_outside{
1265
+ width:400px;
1266
+ }
1267
+ #gold_cart_form .postbox p{
1268
  padding-left: 4px;
1269
  }
1270
+ #gold_cart_form .postbox{
1271
+ width:100%;
1272
+ max-width:500px;
 
1273
  }
1274
+ #gold_cart_form .postbox p{
1275
+ padding-left:10px;
 
1276
  }
1277
+ #gold_cart_form .postbox p label{
1278
+ width:80px;
1279
+ float:left;
 
1280
  }
1281
 
1282
  a.admin_download {
1286
  text-decoration: none;
1287
  }
1288
 
1289
+ a.admin_download img{
1290
  margin-right: 3px;
1291
  }
1292
 
1293
+ a.admin_download span{
1294
  text-decoration: underline;
1295
  }
1296
 
1297
+ /*
1298
+ * Product Groups styles end here
1299
+ */
1300
+ .wpsc_td_note{
1301
+ padding-bottom:0 !important;
 
 
1302
  }
1303
 
1304
  .wpsc_purchaselogs_options {
1305
  margin: 0px 0px 8px 0px;
1306
+
1307
  }
1308
 
1309
+
1310
  p.add_new_form_set_forms {
1311
  display: none;
1312
  }
1314
  td.product-image a img.attachment-thumbnail {
1315
  height: 38px;
1316
  width: 38px;
1317
+
1318
  }
1319
 
1320
  #wpsc_product_category_and_tag_forms .tagchecklist {
1321
+ font-size:11px;
1322
  }
1323
 
1324
+ #categorydiv div{
1325
  margin-top: 4px;
1326
  }
1327
 
1331
  font-size: 15px;
1332
  }
1333
 
1334
+ .toplevel_page_wpsc-edit-products .wrap h2
1335
+ {
1336
+ padding-bottom:0px;
1337
+ border-bottom:1px solid #CCC;
1338
  }
1339
+ #post-body #advanced-sortables
1340
+ {
1341
+ margin-right:300px
1342
  }
 
1343
  #media-buttons #add_audio,
1344
  #media-buttons #add_video,
1345
  #media-buttons #add_media {
1346
+ display:none;
1347
  }
 
1348
  .meta-box-sortables-wpec .postbox:hover .handlediv {
1349
  background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
1350
  }
1351
 
1352
+ /* marketing / coupon page styling */
1353
 
1354
+ div.modify_coupon{ border: 1px solid #eeeeee; display: none; width: 100%; }
1355
+ table.coupon_data{
 
 
 
 
 
 
 
 
 
 
 
 
 
1356
  width: 100%;
1357
  }
1358
+ table.add-coupon{width:100%;}
1359
+ table.add-coupon tr th{ text-align: left; padding: 2px 5px 0px 5px; border: none;}
1360
+ table.add-coupon tr td{ text-align: left; padding: 2px 5px 2px 5px; border: none;}
1361
+ table.add-coupon tr td p{padding:0;margin:5px;}
1362
+ #table_header{
1363
+ font-size:16px;
1364
+ margin-top:20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
1365
  font-weight: bold;
1366
  }
1367
+ table.coupon-list{ width: 100%; }
1368
+ table.coupon-list th{ text-align:left;}
1369
+ table.coupon-list tr.toprow td{ text-align: left; font-weight:bold; }
1370
 
1371
+ table.coupon-list tr td{ padding: 5px 5px 10px 10px; vertical-align: middle;}
 
 
 
 
 
 
1372
 
1373
+ table.coupon-list tr.alt{ background-color: #eeeeee; }
 
 
 
 
 
 
 
 
1374
 
1375
+ table.coupon-list tr.alt td{ background-color: #eeeeee; }
1376
+ table.coupon-list tr.coupon_edit td{ padding:0; }
1377
+ td#order_summary_container{ width: 80px; }
1378
+ table.category_forms a.delete_button, span.delete_button {
1379
+ color:#FF0000;
1380
+ display:block;
1381
+ float:left;
1382
+ font-size:11px;
1383
+ margin:3px 0 0 8px;
1384
+ text-decoration:underline;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1385
  }
1386
+ p span.input_label{
1387
+ font-size:1.2em;
1388
+ width:180px;
1389
+ float:left;
 
1390
  }
 
1391
  a.wpsc_featured_product_toggle {
1392
  display: block;
1393
  height: 18px;
1395
  margin: 4px 0px 0px 0px;
1396
  }
1397
 
1398
+ .column-featured a { background:url( '../../wpsc-core/images/core-sprite.png') no-repeat 0 -32px transparent; }
1399
+ .column-featured a.gold-star { background-position:0 -16px; }
 
 
 
 
 
 
1400
  .column-featured a:active,
1401
+ .column-featured a.gold-star:active { background-position:0 0; }
 
 
1402
 
1403
  div.wpsc_clear {
1404
  clear: both;
1411
  position: relative;
1412
  }
1413
 
1414
+
1415
  .wpsc_featured .item_text {
1416
  float: left;
1417
  height: 240px;
1430
  height: 240px;
1431
  width: 340px;
1432
  border: 1px solid #FEFAF1;
1433
+ border-radius: 18px;
1434
+ -moz-border-radius: 18px;
1435
  -webkit-border-radius: 18px;
 
 
1436
  background-repeat: no-repeat;
1437
  }
1438
 
1439
+
1440
  .wpsc_featured .item_text h3 {
1441
  font-size: 1.4em;
1442
  margin: 0px 0px 8px 0px;
1447
  line-height: normal;
1448
  display: block;
1449
  margin: 0px 0px 4px 0px;
1450
+
1451
  }
1452
 
1453
  .wpsc_featured .item_text .wpsc_description {
1454
  font-size: 1em;
1455
+ line-height:24px;
1456
+ display:block;
1457
+ float:left;
1458
  width: auto;
1459
  color: #9B9A96;
1460
+ font-family: Georgia,"Bitstream Charter",serif;
1461
  }
1462
 
1463
  .wpsc_featured .item_text .wpsc_description p {
1464
  margin-bottom: 0px;
1465
  }
1466
 
1467
+
1468
  .wpsc_featured .item_text .wpsc_description a {
1469
+ color:#9B9A96;
1470
  }
1471
 
1472
  ul.wpsc_categories {
1473
  clear: both;
1474
  }
1475
 
1476
+ a.update_variations_action
1477
+ {
1478
+ vertical-align:middle;
1479
  }
 
1480
  #poststuff .inside p.update-variations {
1481
+ display:none;
1482
+ margin-top:1em;
1483
  }
1484
+ #search-products{
1485
+ width:auto;
1486
+ float:right;
 
1487
  }
1488
+ .productnav{
1489
+ height: 30px;
1490
+ margin: 6px 0px 4px;
1491
+ vertical-align: middle;
 
1492
  }
1493
 
1494
  #wpsc_stock_control_forms .edit_stock {
1495
+ margin-top:0.5em;
1496
+ line-height:16px;
1497
  }
 
1498
  #wpsc_stock_control_forms .unpublish_when_none_left,
1499
  #wpsc_stock_control_forms .notify_when_none_left {
1500
+ margin:0.5em 0;
1501
  }
 
1502
  #media-upload form p.help {
1503
+ text-align:left;
1504
+ clear:both;
1505
+ }
1506
+ ul#category_list_li, ul.poll-options {
1507
  }
1508
+ ul#category_list_li li div,
1509
+ ul#category_list_li li div ul li div {
1510
+ }
1511
+ ul#category_list_li li div div,
1512
+ ul#category_list_li li div ul li div div {
1513
 
1514
+ }
1515
+ ul#category_list_li li div:hover div{
1516
  }
1517
 
1518
+ ul#category_list_li li div ul li div:hover div {
1519
+ }
1520
+ ul#category_list_li li {
1521
+ }
1522
+ ul#category_list_li li:hover span.handle {
1523
+ cursor: move;
1524
+ }
1525
+ .edit{
1526
+ }
1527
  ul#category_list_li li span.handle {
1528
+ float:left;
1529
+
1530
  padding: 5px;
1531
+
1532
  }
1533
 
1534
+ .category_admin_list_img a.row-title{
1535
  text-decoration: none;
1536
  }
1537
 
1538
+
1539
  .category_admin_list_img:hover div.row-actions {
1540
+ visibility:visible;
1541
  }
1542
 
1543
  ul#category_list_li ul {
1544
+ margin-left:15px;
1545
  }
1546
 
1547
  .row-title img {
1548
+ width:30px;
1549
+ float:left;
1550
+ padding-right:10px;
1551
  }
 
1552
  .row-title {
1553
+ margin-right:5px;
1554
  }
 
1555
  body.edit-php form#posts-filter {
1556
+ min-width:830px;
1557
  }
 
1558
  input.wpsc_cat_image_size {
1559
+ width:40px
1560
  }
 
1561
  input.wpsc_cat_box {
1562
+ width:auto;
1563
+ margin:6px;
1564
+ vertical-align:middle;
1565
  }
1566
 
1567
+ .wpsc_ie_field{
1568
+ width:100%;
1569
  }
 
1570
  .wpsc_inline_actions .loading_indicator {
1571
+ position:relative;
1572
+ top:3px;
1573
+ left:2px;
1574
  visibility: hidden;
1575
  }
 
1576
  table.tags th#image {
1577
+ width:60px;
1578
  }
1579
+ /* quick and bulk edit product */
 
 
 
 
 
1580
  #wpbody-content .bulk-edit-row-post fieldset.wpsc-cols {
1581
+ width:49%;
1582
+ margin-top:0;
1583
  }
1584
 
1585
  #wpbody-content .quick-edit-row-post .inline-edit-col-left {
1586
+ width:35%;
1587
  }
1588
 
1589
  .bulk-edit-row-post fieldset.inline-edit-col-right label span.title {
1590
+ padding-right:0.5em;
1591
+ width:auto;
1592
  }
1593
 
1594
  .wpsc-quick-edit {
1595
+ width: 30%;
1596
+ float:left;
1597
  }
1598
 
1599
  textarea.tax_input_product_tag {
1600
+ width:50% !important;
1601
+ height: 95px !important;
1602
  }
1603
 
1604
  ul.wpsc_product_category-checklist {
1605
+ height: 280px;
1606
  }
1607
 
1608
+ span.wpsc-quick-edit{
1609
+ width:77px;
1610
+ display: block;
1611
+ float: left;
1612
  }
1613
+ .wpsc_var_description{
1614
+ margin:20px 0 0 20px !important;
1615
+ color:red;
 
1616
  }
1617
 
1618
  .ajax-loading {
1620
  }
1621
 
1622
  #cart_options .delete {
1623
+ color:#c00;
1624
+ float:right;
1625
  }
 
1626
  #cart_options .delete:hover {
1627
+ color:#D54E21;
1628
  }
1629
 
1630
  .dashboard_page_wpsc-update .wpsc-progress-bar {
1631
+ position:relative;
1632
+ height:20px;
1633
+ width:300px;
1634
+ border:1px solid #3a58cf;
1635
+ margin:-0.75em 0 27px;
1636
  }
1637
 
1638
  .dashboard_page_wpsc-update .wpsc-progress-bar * {
1639
+ position:absolute;
1640
+ left:0;
1641
+ top:0;
1642
+ background:#f9f9f9;
1643
+ font-size:12px;
1644
  }
1645
 
1646
  .dashboard_page_wpsc-update .wpsc-progress-bar .block {
1647
+ background-color:#527dff;
1648
+ z-index:-1;
1649
+ height:20px;
1650
  }
1651
 
1652
  .dashboard_page_wpsc-update .wpsc-progress-bar span {
1653
+ display:block;
1654
+ left:310px;
1655
+ line-height:20px;
1656
+ width:200px;
1657
  }
1658
 
1659
  .dashboard_page_wpsc-update .wpsc-progress-bar .eta {
1660
+ top:22px;
1661
+ line-height:15px;
1662
+ width:100%;
1663
  }
1664
 
1665
+ .downloadables_float{
1666
  float: right;
1667
+ width:80px;
1668
  vertical-align: middle;
1669
+
1670
  }
1671
 
1672
+ .downloadables_headding1{
1673
  display: inline;
1674
+ float:left;
1675
  text-align: left;
1676
  vertical-align: middle;
1677
  width: auto;
1678
  }
1679
 
1680
  img.ajax-feedback-active {
1681
+ vertical-align:middle;
1682
+ visibility:visible;
1683
  }
1684
 
1685
  .dashboard_page_wpsc-purchase-logs .column-id {
1686
+ width:75px;
1687
  }
1688
 
1689
  .dashboard_page_wpsc-purchase-logs .column-amount {
1690
+ width:100px;
1691
  }
1692
 
1693
+ .js table.purchase-logs td.column-status span, table.purchase-logs .column-status select {
1694
+ display:none;
 
1695
  }
1696
 
1697
  .js table.purchase-logs .column-status select {
1698
+ display:inline-block;
1699
+ margin-right:5px;
1700
  }
1701
 
1702
  table.purchase-logs .column-tracking .empty {
1703
+ position:relative;
1704
  }
1705
 
1706
  table.purchase-logs .column-tracking .empty .send-email {
1707
+ display:none;
1708
  }
1709
 
1710
  table.purchase-logs .column-tracking .add {
1711
+ position:absolute;
1712
+ left:6px;
1713
+ top:4px;
1714
  }
1715
 
1716
  table.purchase-logs .column-tracking {
1717
+ width:200px;
1718
  }
1719
 
1720
  table.purchase-logs .column-tracking input[type="text"] {
1721
+ width:180px;
1722
  }
1723
 
1724
  table.purchase-logs .column-tracking a.save {
1725
+ display:none;
1726
+ float:right;
1727
  }
1728
 
1729
  table.purchase-logs .column-tracking a.add {
1730
+ display:none;
1731
+ color:#ccc;
1732
+ cursor:text;
1733
  }
1734
 
1735
  table.purchase-logs .column-tracking .empty a.add {
1736
+ display:inline;
1737
  }
1738
 
1739
  table.purchase-logs .column-tracking .ajax-feedback {
1740
+ display:none;
1741
+ float:right;
1742
+ margin-top:5px;
1743
  }
1744
 
1745
  table.purchase-logs .column-tracking .ajax-feedback-active {
1746
+ display:inline-block;
1747
  }
1748
 
1749
  table.purchase-logs .column-tracking em.sent {
1750
+ color:green;
1751
  }
1752
 
1753
  table.purchase-logs .column-id .delete {
1754
+ color:red;
1755
+ visibility:hidden;
1756
  }
1757
 
1758
  table.purchase-logs tr:hover .column-id .delete {
1759
+ visibility:visible;
1760
  }
1761
 
1762
+ /* Product Variations */
 
 
 
 
1763
  .no-js #wpsc_product_variation_forms iframe {
1764
+ height:300px;
1765
  }
1766
 
1767
  .js #wpsc_product_variation_forms iframe {
1768
+ border:0;
1769
+ margin:0;
1770
+ overflow:hidden;
1771
+ padding:0;
 
 
 
 
 
1772
  }
1773
 
1774
  #wpsc_product_variation_forms iframe {
1775
+ background:transparent;
1776
+ width:100%;
1777
  }
1778
 
1779
  .wpsc-product-variation-iframe {
1780
  min-width: 400px;
 
 
1781
  }
1782
 
1783
  #wpsc-product-variations-wrapper .tablenav.top {
1784
+ margin-top:0;
1785
  }
1786
 
1787
  .wpsc-save-variations-top {
1788
+ float:right;
1789
+ margin:8px 0 5px;
1790
  }
1791
 
1792
  #wpsc-product-variations-wrapper .column-stock input[type="text"],
1794
  #wpsc-product-variations-wrapper .column-price input[type="text"],
1795
  #wpsc-product-variations-wrapper .column-sale_price input[type="text"],
1796
  #wpsc-product-variations-wrapper .column-sku input[type="text"] {
1797
+ width:100%;
1798
+
1799
+ box-sizing:border-box;
1800
+ -o-box-sizing:border-box;
1801
+ -moz-box-sizing:border-box;
1802
+ -webkit-box-sizing:border-box;
1803
  }
1804
 
1805
  #wpsc-product-variations-wrapper .inline-edit-row.column-stock input[type="text"],
1815
  #wpsc-product-variations-wrapper .column-price,
1816
  #wpsc-product-variations-wrapper .column-sale_price,
1817
  #wpsc-product-variations-wrapper .column-sku {
1818
+ text-align:center;
1819
+ width:11%;
1820
  }
1821
 
1822
  #wpsc-product-variations-wrapper .column-stock input,
1824
  #wpsc-product-variations-wrapper .column-price input,
1825
  #wpsc-product-variations-wrapper .column-sale_price input,
1826
  #wpsc-product-variations-wrapper .column-sku input {
1827
+ text-align:right;
1828
+ }
1829
+
1830
+ .js #wpsc-product-variations-wrapper tbody .active td, .js #wpsc-product-variations-wrapper tbody .active th {
1831
+ border-bottom-style:dashed;
1832
  }
1833
 
1834
+ .js #wpsc-product-variations-wrapper tbody td, .js #wpsc-product-variations-wrapper tbody th {
1835
+ border-bottom-style:solid;
 
1836
  }
1837
 
1838
  #wpsc-product-variations-wrapper div.updated,
1841
  }
1842
 
1843
  .js #wpsc-product-variations-wrapper .wpsc-stock-editor-row {
1844
+ display:none;
1845
  }
1846
 
1847
  #wpsc-product-variations-wrapper .wpsc-stock-editor-row td {
1848
+ border-bottom-style:solid;
1849
  }
1850
 
1851
  #wpsc-product-variations-wrapper {
1853
  }
1854
 
1855
  #wpsc-product-variations-wrapper .submit {
1856
+ margin:0;
1857
+ padding:0;
1858
  }
1859
 
1860
  .wpsc-stock-editor .inside {
1861
+ overflow:hidden;
1862
  }
1863
 
1864
  .wpsc-stock-editor .wpsc-product-shipping-section {
1865
+ display:inline-block;
1866
  vertical-align: top;
1867
+ width:49%;
1868
  }
1869
 
1870
  .wpsc-stock-editor .wpsc-form-field {
1871
+ clear:both;
 
 
 
 
 
 
 
 
1872
  }
1873
 
1874
  .wpsc-stock-editor .wpsc-product-shipping-section input[type="text"] {
1875
+ text-align:right;
1876
+ width:50px;
1877
  }
1878
 
1879
  .wpsc-product-shipping-weight-dimensions label {
1880
+ display:inline-block;
1881
+ min-width:60px;
1882
  }
1883
 
1884
  .wpsc-product-shipping-flat-rate label {
1885
+ display:inline-block;
1886
+ min-width:160px;
1887
  }
1888
 
1889
  .wpsc-stock-editor {
1890
+ overflow:hidden;
1891
  }
1892
 
1893
  .wpsc-stock-editor select {
1894
+ min-width:100px;
1895
  }
1896
 
1897
+ #wpsc_product_variation_forms .inside {
1898
+ background: #fff;
1899
+ padding: 0;
1900
+ margin: 0;
1901
  }
1902
 
1903
+ #wpsc_product_variation_forms {
1904
+ overflow: auto !important;
 
 
1905
  }
1906
 
1907
+ .wpsc-product-variations-tabs {
1908
+ background: #F1F1F1;
1909
+ border-bottom: 1px solid #ccc;
1910
+ padding: 10px 10px 0;
1911
+ margin: 0;
1912
  }
1913
 
1914
  .wpsc-product-variations-tabs li {
1915
+ display: inline-block;
1916
+ margin: 0 4px 2px 0;
1917
  }
1918
 
1919
  .wpsc-product-variations-tabs a {
1920
+ background-color: #fff;
1921
+ border-color: #ccc #ccc #fff;
 
1922
  border-style: solid;
1923
  border-width: 1px 1px 0;
 
1924
  color: #aaa;
1925
  padding: 5px 7px 3px;
1926
  text-decoration: none;
1927
+
1928
+ border-top-left-radius: 3px;
1929
+ border-top-right-radius: 3px;
 
1930
  -webkit-border-top-left-radius: 3px;
1931
+ -webkit-border-top-right-radius: 3px;
1932
+ -moz-border-top-left-radius: 3px;
1933
+ -moz-border-top-right-radius: 3px;
1934
  }
1935
 
1936
  .wpsc-product-variations-tabs a:hover {
1938
  }
1939
 
1940
  .wpsc-product-variations-tabs .active a {
 
1941
  border-bottom-width: 1px;
1942
  color: #333;
1943
+ margin-bottom: 2px;
1944
  }
1945
 
1946
  .wpsc-product-variations-tab-content {
 
1947
  padding: 0 10px;
1948
  }
1949
 
1952
  }
1953
 
1954
  .wpsc-save-product-variations.bottom {
 
 
1955
  padding-bottom: 5px;
1956
  }
 
 
 
1957
 
1958
  .wpsc-product-variation-thumbnail {
1959
  float: left;
1961
  width: 50px;
1962
  }
1963
 
 
 
 
 
 
1964
  .wpsc-product-variation-title {
1965
  margin-left: 60px;
1966
  }
1972
 
1973
  .wpsc-button-round {
1974
  padding: 0 0 1px !important;
1975
+ height: 24px !important;
1976
  text-align: center;
1977
+ width: 24px !important;
1978
+ -webkit-border-radius: 12px !important;
1979
+ border-radius: 12px !important;
1980
  outline: 0 !important;
1981
  }
1982
 
1983
+ /* make the minus sign look balanced with the plus sign */
 
1984
  .wpsc-button-minus {
1985
  font-weight: bold;
1986
  font-size: 10px !important;
2004
  padding: 0;
2005
  }
2006
 
2007
+ div.new_layer,
2008
+ div#table_rate {
2009
+ display:none;
 
 
 
 
 
 
 
 
 
 
2010
  }
2011
 
2012
  body.edit-tags-php img.wpsc_category_image {
2013
+ max-width:256px;
2014
+ max-height:256px;
2015
+ min-width:128px;
2016
  }
2017
 
2018
  .wpsc-width-height-fields label {
2019
  display: inline;
2020
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/css/media.css DELETED
@@ -1,26 +0,0 @@
1
- .wpsc-featured-label {
2
- position: absolute;
3
- bottom: 0;
4
- left: 0;
5
- right: 0;
6
- background: #f1f1f1;
7
- background-image: -webkit-gradient(linear, left top, left bottom, from(#f1f1f1), to(#e1e1e1));
8
- background-image: -webkit-linear-gradient(top, #f1f1f1, #e1e1e1);
9
- background-image: -moz-linear-gradient(top, #f1f1f1, #e1e1e1);
10
- background-image: -o-linear-gradient(top, #f1f1f1, #e1e1e1);
11
- background-image: linear-gradient(to bottom, #f1f1f1, #e1e1e1);
12
- box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.15 );
13
- font-weight: bold;
14
- text-align: center;
15
- color: rgb(70, 70, 70);
16
- max-height: 100%;
17
- padding: 5px 10px;
18
- outline: 0 none;
19
- opacity: 0.95;
20
- line-height: 1em;
21
- }
22
-
23
- .selection-view .wpsc-featured-label {
24
- font-size:7px;
25
- padding: 2px 0;
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/4.php CHANGED
@@ -19,8 +19,7 @@ function _wpsc_maybe_update_user_log_file() {
19
  '3.8.10' => '09e2cb9c753587c9228a4e9e8008a82f',
20
  );
21
 
22
- if ( function_exists( 'wpsc_flush_theme_transients' ) )
23
- wpsc_flush_theme_transients( true );
24
 
25
  //Make sure the theme has actually been moved.
26
  $file = wpsc_get_template_file_path( 'wpsc-user-log.php' );
19
  '3.8.10' => '09e2cb9c753587c9228a4e9e8008a82f',
20
  );
21
 
22
+ wpsc_flush_theme_transients( true );
 
23
 
24
  //Make sure the theme has actually been moved.
25
  $file = wpsc_get_template_file_path( 'wpsc-user-log.php' );
wpsc-admin/db-upgrades/routines/5.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- function _wpsc_db_upgrade_5() {
4
- _wpsc_maybe_update_product_meta_array_keys();
5
- }
6
-
7
- /**
8
- * Rename old _wpsc_* product metadata array keys so they no longer include the '_wpsc_' prefix
9
- * See https://github.com/wp-e-commerce/WP-e-Commerce/issues/492 for details
10
- */
11
- function _wpsc_maybe_update_product_meta_array_keys() {
12
- global $wpdb;
13
-
14
- $product_ids = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_wpsc_product_metadata' AND meta_value LIKE '%_wpsc_%'" );
15
-
16
- foreach ( $product_ids as $product_id ) {
17
- $metadata_needs_saving = false;
18
- $product_metadata = get_post_meta( $product_id, '_wpsc_product_metadata', true );
19
- if ( is_array( $product_metadata ) ) {
20
- foreach ( $product_metadata as $meta_key => $meta_value ) {
21
- if ( '_wpsc_' === substr( $meta_key, 0, 6 ) ) {
22
- /*
23
- Typical meta keys that need renaming are:
24
- wpsc_url_name
25
- _wpsc_sku
26
- _wpsc_dimensions
27
- _wpsc_engraved
28
- _wpsc_can_have_uploaded_image
29
- _wpsc_unpublish_oos
30
- */
31
- $new_meta_key = substr( $meta_key, 6 );
32
-
33
- // remove the old (_wpsc_ prefixed) metadata from the array
34
- unset ( $product_metadata[ $meta_key ] );
35
- $metadata_needs_saving = true;
36
-
37
- // If metadata doesn't already exist with the new non-prefixed key, add it to the array
38
- // This check ensures that we don't overwrite newer product metadata
39
- if ( ! isset( $product_metadata[ $new_meta_key ] ) ) {
40
- $product_metadata[ $new_meta_key ] = $meta_value;
41
- }
42
- }
43
- }
44
- }
45
- if ( $metadata_needs_saving ) {
46
- update_post_meta( $product_id, '_wpsc_product_metadata', $product_metadata );
47
- }
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/6.php DELETED
@@ -1,12 +0,0 @@
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();
6
- }
7
-
8
- function _wpsc_maybe_create_meta_tables() {
9
-
10
- _wpsc_create_cart_item_meta_table();
11
- _wpsc_meta_migrate_wpsc_cart_item();
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/7.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- function _wpsc_db_upgrade_7() {
4
- _wpsc_migrate_user_meta();
5
- }
6
-
7
- function _wpsc_migrate_user_meta() {
8
- global $wpdb;
9
-
10
- $sql = "
11
- SELECT *
12
- FROM {$wpdb->usermeta}
13
- WHERE
14
- meta_key LIKE '_wpsc_%customer_profile';
15
- ";
16
-
17
- $results = $wpdb->get_results( $sql );
18
-
19
- foreach ( $results as $row ) {
20
- preg_match( '/_wpsc_(.*)customer_profile/', $row->meta_key, $matches );
21
- $blog_prefix = $matches[1];
22
-
23
- $profile = maybe_unserialize( $row->meta_value );
24
-
25
- foreach ( $profile as $key => $value ) {
26
- $internal_key = "{$blog_prefix}_wpsc_{$key}";
27
- $current_value = get_user_meta( $row->user_id, $internal_key, true );
28
-
29
- if ( $current_value === '' && $value ) {
30
- update_user_meta( $row->user_id, $internal_key, $value );
31
- }
32
- }
33
-
34
- delete_user_meta( $row->user_id, $row->meta_key );
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/db-upgrades/routines/8.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- function _wpsc_db_upgrade_8() {
4
- _wpsc_fix_bulgaria_currency();
5
- }
6
-
7
- function _wpsc_fix_bulgaria_currency() {
8
- $country = new WPSC_Country( array(
9
- 'isocode' => 'BG',
10
- 'code' => __( 'BGN', 'wpsc' ),
11
- ) );
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -14,12 +14,12 @@
14
  * @since 3.8.9
15
  */
16
  function _wpsc_maybe_upgrade() {
17
- $current_db_ver = (int) get_option( 'wpsc_db_version', 0 );
18
 
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
 
@@ -145,11 +138,11 @@ function _wpsc_action_load_db_upgrade() {
145
 
146
  _wpsc_maybe_upgrade();
147
 
148
- wp_redirect( add_query_arg( 'wpsc_db_upgrade_successful', 1, admin_url() ) );
149
  exit;
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
- }
14
  * @since 3.8.9
15
  */
16
  function _wpsc_maybe_upgrade() {
17
+ $current_db_ver = get_option( 'wpsc_db_version', 0 );
18
 
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
 
138
 
139
  _wpsc_maybe_upgrade();
140
 
141
+ wp_redirect( esc_url( add_query_arg( 'wpsc_db_upgrade_successful', 1, admin_url() ) ) );
142
  exit;
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
 
@@ -93,7 +90,7 @@
93
  </th>
94
  <td>
95
  <input type="hidden" name="rules[operator][]" value="" />
96
- <div class='coupon-condition'>
97
  <select class="ruleprops" name="rules[property][]">
98
  <option value="item_name" rel="order"><?php _e( 'Item name', 'wpsc' ); ?></option>
99
  <option value="item_quantity" rel="order"><?php _e( 'Item quantity', 'wpsc' ); ?></option>
@@ -111,7 +108,6 @@
111
  <option value="begins"><?php _e( 'Begins with', 'wpsc' ); ?></option>
112
  <option value="ends"><?php _e( 'Ends with', 'wpsc' ); ?></option>
113
  <option value="category"><?php _e( 'In Category', 'wpsc' ); ?></option>
114
- <?php echo apply_filters( 'wpsc_coupon_rule_logic_options', '' ); ?>
115
  </select>
116
 
117
  <input type="text" name="rules[value][]" style="width: 150px;"/>
@@ -121,11 +117,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"/>
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
 
90
  </th>
91
  <td>
92
  <input type="hidden" name="rules[operator][]" value="" />
93
+ <div class='coupon-condition' >
94
  <select class="ruleprops" name="rules[property][]">
95
  <option value="item_name" rel="order"><?php _e( 'Item name', 'wpsc' ); ?></option>
96
  <option value="item_quantity" rel="order"><?php _e( 'Item quantity', 'wpsc' ); ?></option>
108
  <option value="begins"><?php _e( 'Begins with', 'wpsc' ); ?></option>
109
  <option value="ends"><?php _e( 'Ends with', 'wpsc' ); ?></option>
110
  <option value="category"><?php _e( 'In Category', 'wpsc' ); ?></option>
 
111
  </select>
112
 
113
  <input type="text" name="rules[value][]" style="width: 150px;"/>
117
  </td>
118
  </tr>
119
 
 
 
120
  </tbody>
121
  </table>
122
+
123
  <?php submit_button( __( 'Add Coupon', 'wpsc' ), 'primary', 'add_coupon' ); ?>
124
 
125
  </form>
wpsc-admin/display-coupon-edit.php CHANGED
@@ -7,7 +7,7 @@ if( !defined( 'ABSPATH' ) )
7
  $coupon_id = absint( $_GET['coupon'] );
8
  $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` = %d", $coupon_id ), ARRAY_A );
9
  ?>
10
- <div class="wrap" id="coupon_data">
11
  <div id="edit_coupon_box">
12
  <h2><?php _e( 'Edit Coupon', 'wpsc' ); ?></h2>
13
 
@@ -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>
7
  $coupon_id = absint( $_GET['coupon'] );
8
  $coupon = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` = %d", $coupon_id ), ARRAY_A );
9
  ?>
10
+ <div class="wrap" id+"coupon_data">
11
  <div id="edit_coupon_box">
12
  <h2><?php _e( 'Edit Coupon', 'wpsc' ); ?></h2>
13
 
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"/>
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,7 +135,7 @@ 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
 
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 admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
141
 
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
  *
@@ -84,12 +85,11 @@ add_action( 'wpsc_manage_products_column_image', '_wpsc_manage_products_column_i
84
  * @param int $post_id Post ID
85
  * @param boolean $has_variations Whether the product has variations
86
  *
87
- * @uses esc_html_e() Safe HTML with translation
88
- * @uses get_post_meta() Gets post meta given key and post_id
89
- * @uses maybe_unserialize() Unserialize value only if it was serialized.
90
- * @uses wpsc_convert_weight() Does weight conversions
91
- * @uses esc_html() Makes sure things are safe
92
- * @uses wpsc_weight_unit_display() Gets weight unit for display
93
  */
94
  function _wpsc_manage_products_column_weight( $post, $post_id, $has_variations ) {
95
  if( $has_variations ) {
@@ -117,7 +117,22 @@ function _wpsc_manage_products_column_weight( $post, $post_id, $has_variations )
117
 
118
  $unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
119
 
120
- echo $weight . wpsc_weight_unit_display( $unit );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  echo '<div id="inline_' . $post->ID . '_weight" class="hidden">' . esc_html( $weight ) . '</div>';
122
  }
123
  add_action( 'wpsc_manage_products_column_weight', '_wpsc_manage_products_column_weight', 10, 3 );
@@ -539,9 +554,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(
@@ -559,7 +572,7 @@ function wpsc_update_featured_products() {
559
  exit;
560
  }
561
 
562
- add_filter( 'page_row_actions','wpsc_action_row', 10, 2 );
563
 
564
  /**
565
  * @param $actions
@@ -571,7 +584,7 @@ add_filter( 'page_row_actions','wpsc_action_row', 10, 2 );
571
  * @uses esc_url() Makes sure the URL is safe, we like safe
572
  * @uses esc_html_x() Displays translated string with gettext context
573
  */
574
- function wpsc_action_row( $actions, $post ) {
575
 
576
  if ( $post->post_type != "wpsc-product" )
577
  return $actions;
11
 
12
  require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
13
 
14
+
15
  /**
16
  * wpsc_additional_column_names function.
17
  *
85
  * @param int $post_id Post ID
86
  * @param boolean $has_variations Whether the product has variations
87
  *
88
+ * @uses esc_html_e() Safe HTML with translation
89
+ * @uses get_post_meta() Gets post meta given key and post_id
90
+ * @uses maybe_unserialize() Unserialize value only if it was serialized.
91
+ * @uses wpsc_convert_weight() Does weight conversions
92
+ * @uses esc_html() Makes sure things are safe
 
93
  */
94
  function _wpsc_manage_products_column_weight( $post, $post_id, $has_variations ) {
95
  if( $has_variations ) {
117
 
118
  $unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
119
 
120
+ switch( $unit ) {
121
+ case "pound":
122
+ $unit = __(" lbs.", "wpsc");
123
+ break;
124
+ case "ounce":
125
+ $unit = __(" oz.", "wpsc");
126
+ break;
127
+ case "gram":
128
+ $unit = __(" g", "wpsc");
129
+ break;
130
+ case "kilograms":
131
+ case "kilogram":
132
+ $unit = __(" kgs.", "wpsc");
133
+ break;
134
+ }
135
+ echo $weight.$unit;
136
  echo '<div id="inline_' . $post->ID . '_weight" class="hidden">' . esc_html( $weight ) . '</div>';
137
  }
138
  add_action( 'wpsc_manage_products_column_weight', '_wpsc_manage_products_column_weight', 10, 3 );
554
  $status = array_values( $status );
555
  }
556
 
557
+ update_option( 'sticky_products', $status );
 
 
558
 
559
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
560
  $json_response = array(
572
  exit;
573
  }
574
 
575
+ add_filter( 'page_row_actions','my_action_row', 10, 2 );
576
 
577
  /**
578
  * @param $actions
584
  * @uses esc_url() Makes sure the URL is safe, we like safe
585
  * @uses esc_html_x() Displays translated string with gettext context
586
  */
587
+ function my_action_row( $actions, $post ) {
588
 
589
  if ( $post->post_type != "wpsc-product" )
590
  return $actions;
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,8 @@ 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
+
428
+ return esc_url( $location );
429
  }
430
 
431
  }
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
 
@@ -495,118 +416,6 @@ function wpsc_product_shipping_forms_metabox() {
495
  wpsc_product_shipping_forms();
496
  }
497
 
498
- /**
499
- * Dimension Units
500
- *
501
- * @since 3.8.13
502
- *
503
- * @return array List of valid dimension units.
504
- */
505
- function wpsc_dimension_units() {
506
- return array(
507
- 'in' => __( 'inches', 'wpsc' ),
508
- 'cm' => __( 'cm', 'wpsc' ),
509
- 'meter' => __( 'meters', 'wpsc' )
510
- );
511
- }
512
-
513
- /**
514
- * Weight Units
515
- *
516
- * @since 3.8.13
517
- *
518
- * @return array List of valid weight units.
519
- */
520
- function wpsc_weight_units() {
521
- return array(
522
- 'pound' => __( 'pounds', 'wpsc' ),
523
- 'ounce' => __( 'ounces', 'wpsc' ),
524
- 'gram' => __( 'grams', 'wpsc' ),
525
- 'kilogram' => __( 'kilograms', 'wpsc' )
526
- );
527
- }
528
-
529
- /**
530
- * Weight Unit Display
531
- *
532
- * Returns a weight unit abbreviation for display.
533
- *
534
- * @since 3.8.13
535
- *
536
- * @param string $unit Weight unit.
537
- * @return string Weight unit string.
538
- */
539
- function wpsc_weight_unit_display( $unit ) {
540
- switch ( $unit ) {
541
- case 'pound' :
542
- return __( ' lbs.', 'wpsc' );
543
- case 'ounce' :
544
- return __( ' oz.', 'wpsc' );
545
- case 'gram' :
546
- return __( ' g', 'wpsc' );
547
- case 'kilograms' :
548
- case 'kilogram' :
549
- return __( ' kgs.', 'wpsc' );
550
- }
551
- return '';
552
- }
553
-
554
- /**
555
- * Validate Dimension Unit
556
- *
557
- * Returns a valid dimensions unit.
558
- * If the unit is not set or invalid it will be filtered using 'wpsc_default_dimension_unit'
559
- * so that an alternative default unit can be set.
560
- *
561
- * @since 3.8.13
562
- *
563
- * @param string $unit Dimension unit.
564
- * @return string Dimension unit string.
565
- *
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
-
579
- /**
580
- * Validate Weight Unit
581
- *
582
- * Returns a valid weight unit.
583
- * If the unit is not set or invalid it will be filtered using 'wpsc_default_weight_unit'
584
- * so that an alternative default unit can be set.
585
- *
586
- * @since 3.8.13
587
- *
588
- * @param string $unit Weight unit.
589
- * @return string Weight unit string.
590
- *
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
-
604
- /**
605
- * Product Shipping Forms
606
- *
607
- * @uses wpsc_validate_weight_unit()
608
- * @uses wpsc_validate_dimension_unit()
609
- */
610
  function wpsc_product_shipping_forms( $product = false, $field_name_prefix = 'meta[_wpsc_product_metadata]', $bulk = false ) {
611
  if ( ! $product )
612
  $product_id = get_the_ID();
@@ -618,21 +427,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 +454,89 @@ 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 +544,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 +580,187 @@ 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,134 +768,59 @@ 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
  */
1097
 
 
 
 
 
 
 
1098
  add_filter( 'attachment_fields_to_edit', 'wpsc_attachment_fields', 11, 2 );
1099
  add_filter( 'attachment_fields_to_save', 'wpsc_save_attachment_fields', 9, 2 );
1100
  add_filter( 'gettext_with_context', 'wpsc_filter_gettex_with_context', 12, 4);
@@ -1111,7 +837,7 @@ add_filter( 'gettext_with_context', 'wpsc_filter_gettex_with_context', 12, 4);
1111
  function wpsc_filter_gettex_with_context( $translation, $text, $context, $domain ) {
1112
 
1113
  if ( 'Taxonomy Parent' == $context && 'Parent' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ) {
1114
- $translations = get_translations_for_domain( $domain );
1115
  return $translations->translate( 'Variation Set', 'wpsc' );
1116
  //this will never happen, this is here only for gettext to pick up the translation
1117
  return __( 'Variation Set', 'wpsc' );
@@ -1119,6 +845,29 @@ function wpsc_filter_gettex_with_context( $translation, $text, $context, $domain
1119
  return $translation;
1120
  }
1121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1122
  function wpsc_attachment_fields( $form_fields, $post ) {
1123
  $out = '';
1124
 
@@ -1221,118 +970,184 @@ 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 +1155,6 @@ function wpsc_save_quickedit_box( $post_id ) {
1340
  }
1341
 
1342
  return $post_id;
1343
-
1344
  }
1345
 
1346
  /**
@@ -1360,60 +1174,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 +1281,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 +1349,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 +1368,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 +1439,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
 
416
  wpsc_product_shipping_forms();
417
  }
418
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  function wpsc_product_shipping_forms( $product = false, $field_name_prefix = 'meta[_wpsc_product_metadata]', $bulk = false ) {
420
  if ( ! $product )
421
  $product_id = get_the_ID();
427
  $meta = array();
428
 
429
  $defaults = array(
430
+ 'weight' => '',
431
+ 'weight_unit' => '',
432
+ 'dimensions' => array(),
433
+ 'shipping' => array(),
434
+ 'no_shipping' => '',
 
435
  'display_weight_as' => '',
436
  );
437
  $dimensions_defaults = array(
438
+ 'height_unit' => '',
439
+ 'width_unit' => '',
440
+ 'length_unit' => '',
441
  'height' => 0,
442
+ 'width' => 0,
443
  'length' => 0,
444
  );
445
  $shipping_defaults = array(
446
+ 'local' => '',
447
  'international' => '',
448
  );
449
  $meta = array_merge( $defaults, $meta );
454
 
455
  foreach ( $shipping as $key => &$val ) {
456
  $val = wpsc_format_number( $val );
457
+ }
458
 
459
  $weight = wpsc_convert_weight( $weight, 'pound', $weight_unit );
460
 
461
+ $dimension_units = array(
462
+ 'in' => __( 'inches', 'wpsc' ),
463
+ 'cm' => __( 'cm', 'wpsc' ),
464
+ 'meter' => __( 'meters', 'wpsc' )
465
+ );
466
+
467
+ $weight_units = array(
468
+ 'pound' => __( 'pounds', 'wpsc' ),
469
+ 'ounce' => __( 'ounces', 'wpsc' ),
470
+ 'gram' => __( 'grams', 'wpsc' ),
471
+ 'kilogram' => __( 'kilograms', 'wpsc' )
472
+ );
473
 
 
474
  $measurements = $dimensions;
475
  $measurements['weight'] = $weight;
476
  $measurements['weight_unit'] = $weight_unit;
 
477
 
478
+ $measurement_fields = array(
479
+ array(
480
+ 'name' => 'weight',
481
+ 'prefix' => '',
482
+ 'label' => __( 'Weight', 'wpsc' ),
483
+ 'value' => $weight,
484
+ 'units' => $weight_units,
485
+ ),
486
+ array(
487
+ 'name' => 'height',
488
+ 'prefix' => '[dimensions]',
489
+ 'label' => __( 'Height', 'wpsc' ),
490
+ 'value' => $dimensions['height'],
491
+ 'units' => $dimension_units,
492
+ ),
493
+ array(
494
+ 'name' => 'width',
495
+ 'prefix' => '[dimensions]',
496
+ 'label' => __( 'Width', 'wpsc' ),
497
+ 'value' => $dimensions['width'],
498
+ 'units' => $dimension_units,
499
+ ),
500
+ array(
501
+ 'name' => 'length',
502
+ 'prefix' => '[dimensions]',
503
+ 'label' => __( 'Length', 'wpsc' ),
504
+ 'value' => $dimensions['length'],
505
+ 'units' => $dimension_units,
506
+ ),
507
+ );
508
  ?>
509
  <div class="wpsc-stock-editor<?php if ( $bulk ) echo ' wpsc-bulk-edit' ?>">
510
  <p class="wpsc-form-field">
511
+ <label><?php esc_html_e( 'Disregard Shipping for this Product', 'wpsc' ); ?></label>&nbsp;&nbsp;
512
+ <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;
513
+ <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;
514
  </p>
515
 
516
  <div class="wpsc-product-shipping-section wpsc-product-shipping-weight-dimensions">
517
+ <p><strong><?php esc_html_e( 'Weight and Dimensions', 'wpsc' ); ?></strong></p>
518
+ <?php
519
+ foreach ( $measurement_fields as $field ):
520
+ ?>
521
+ <p class="wpsc-form-field">
522
+ <?php if ( $bulk ): ?>
523
+ <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][<?php echo $field['name'] ?>]" value="1" />
524
+ <?php endif ?>
525
+ <label for="wpsc-product-shipping-<?php echo $field['name']; ?>"><?php echo esc_html( $field['label'] ); ?></label>
526
+ <span class="wpsc-product-shipping-input">
527
+ <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'] ) ); ?>" />
528
+ <select name="<?php echo $field_name_prefix . $field['prefix'] . '[' . $field['name'] . '_unit]'; ?>">
529
+ <?php foreach ( $field['units'] as $unit => $unit_label ): ?>
530
+ <option value="<?php echo $unit; ?>" <?php if ( ! $bulk ) selected( $unit, $measurements[$field['name'] . '_unit'] ); ?>><?php echo esc_html( $unit_label ); ?></option>
531
  <?php endforeach; ?>
532
  </select>
533
+ </span>
534
+ </p>
535
+ <?php
536
+ endforeach;
537
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
538
  </div>
539
 
 
 
 
 
 
 
 
540
  <div class="wpsc-product-shipping-section wpsc-product-shipping-flat-rate">
541
  <p><strong><?php esc_html_e( 'Flat Rate Settings', 'wpsc' ); ?></strong></p>
542
  <p class="wpsc-form-field">
544
  <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][local]" value="1" />
545
  <?php endif; ?>
546
  <label for="wpsc-product-shipping-flatrate-local"><?php esc_html_e( 'Local Shipping Fee', 'wpsc' ); ?></label>
547
+ <input type="text" id="wpsc-product-shipping-flatrate-local" name="<?php echo $field_name_prefix; ?>[shipping][local]" value="<?php if ( ! $bulk ) echo $shipping['local']; ?>" />
 
 
 
548
  </p>
549
  <p class="wpsc-form-field">
550
  <?php if ( $bulk ): ?>
551
  <input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][international]" value="1" />
552
  <?php endif; ?>
553
  <label for="wpsc-product-shipping-flatrate-international"><?php esc_html_e( 'International Shipping Fee', 'wpsc' ); ?></label>
554
+ <input type="text" id="wpsc-product-shipping-flatrate-international" name="<?php echo $field_name_prefix; ?>[shipping][international]" value="<?php if ( ! $bulk ) echo $shipping['international']; ?>" />
 
 
 
555
  </p>
556
  </div>
557
  </div>
558
+ <?php
 
 
 
559
  }
560
 
 
 
 
 
 
 
561
  function wpsc_product_advanced_forms() {
562
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
563
+ $product_data = get_post_custom( $post->ID );
564
 
565
+ $product_data['meta'] = $product_meta = array();
566
+ if ( !empty( $product_data['_wpsc_product_metadata'] ) )
567
+ $product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
568
 
569
  $delete_nonce = _wpsc_create_ajax_nonce( 'remove_product_meta' );
570
 
580
  ORDER BY
581
  LOWER(meta_key)", ARRAY_A
582
  );
583
+ if( !isset( $product_meta['engraved'] ) )
584
+ $product_meta['engraved'] = '';
585
 
586
+ if( !isset( $product_meta['can_have_uploaded_image'] ) )
587
+ $product_meta['can_have_uploaded_image'] = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
588
 
589
+ ?>
 
 
 
 
 
590
 
591
+ <table>
592
+ <tr>
593
+ <td colspan='2' class='itemfirstcol'>
594
+ <strong><?php esc_html_e( 'Custom Meta', 'wpsc' ); ?>:</strong><br />
595
+ <a href='#' class='add_more_meta' onclick="return add_more_meta(this)"><?php esc_html_e( '+ Add Custom Meta', 'wpsc' );?> </a><br /><br />
596
 
597
+ <?php
598
+ foreach ( (array)$custom_fields as $custom_field ) {
599
+ $i = $custom_field['meta_id'];
600
 
601
+ ?>
602
+ <div class='product_custom_meta' id='custom_meta_<?php echo $i; ?>'>
603
+ <?php esc_html_e( 'Name', 'wpsc' ); ?>
604
+ <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; ?>'>
605
+ <?php esc_html_e( 'Value', 'wpsc' ); ?>
606
+ <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>
607
+ <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>
608
+ <br />
609
+ </div>
610
+ <?php
611
+ }
612
+ ?>
613
+ <div class='product_custom_meta'>
614
+ <?php esc_html_e( 'Name', 'wpsc' ); ?>: <br />
615
+ <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
616
+ <?php esc_html_e( 'Description', 'wpsc' ); ?>: <br />
617
+ <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
618
+ <br />
619
+ </div>
620
+ </td>
621
+ </tr>
622
+ <tr>
623
+ <td class='itemfirstcol' colspan='2'><br /> <strong><?php esc_html_e( 'Merchant Notes:', 'wpsc' ); ?></strong><br />
624
+
625
+ <textarea cols='40' rows='3' name='meta[_wpsc_product_metadata][merchant_notes]' id='merchant_notes'><?php
626
+ if ( isset( $product_meta['merchant_notes'] ) )
627
+ echo esc_textarea( trim( $product_meta['merchant_notes'] ) );
628
+ ?></textarea>
629
+ <small><?php esc_html_e( 'These notes are only available here.', 'wpsc' ); ?></small>
630
+ </td>
631
+ </tr>
632
+ <tr>
633
+ <td class='itemfirstcol' colspan='2'><br />
634
+ <strong><?php esc_html_e( 'Personalisation Options', 'wpsc' ); ?>:</strong><br />
635
+ <input type='hidden' name='meta[_wpsc_product_metadata][engraved]' value='0' />
636
+ <input type='checkbox' name='meta[_wpsc_product_metadata][engraved]' <?php echo ( ( $product_meta['engraved'] == true ) ? 'checked="checked"' : '' ); ?> id='add_engrave_text' />
637
+ <label for='add_engrave_text'><?php esc_html_e( 'Users can personalize this Product by leaving a message on single product page', 'wpsc' ); ?></label>
638
+ <br />
639
+ </td>
640
+ </tr>
641
+ <tr>
642
+ <td class='itemfirstcol' colspan='2'>
643
+ <input type='hidden' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' value='0' />
644
+ <input type='checkbox' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' <?php echo ( $product_meta['can_have_uploaded_image'] == true ) ? 'checked="checked"' : ''; ?> id='can_have_uploaded_image' />
645
+ <label for='can_have_uploaded_image'> <?php esc_html_e( 'Users can upload images on single product page to purchase logs.', 'wpsc' ); ?> </label>
646
+ <br />
647
+ </td>
648
+ </tr>
649
+ <?php
650
+ if ( get_option( 'payment_gateway' ) == 'google' ) {
651
+ ?>
652
+ <tr>
653
+ <td class='itemfirstcol' colspan='2'>
654
 
655
+ <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'>
656
+ <?php esc_html_e( 'Prohibited <a href="http://checkout.google.com/support/sell/bin/answer.py?answer=75724">by Google?</a>', 'wpsc' ); ?>
657
+ </label><br />
658
+ </td>
659
+ </tr>
660
+ <?php
661
+ }
662
+ do_action( 'wpsc_add_advanced_options', $post->ID );
663
+ ?>
664
+ <tr>
665
+ <td class='itemfirstcol' colspan='2'><br />
666
+ <strong><?php esc_html_e( 'Enable Comments', 'wpsc' ); ?>:</strong><br />
667
+ <select name='meta[_wpsc_product_metadata][enable_comments]'>
668
+ <option value='' <?php echo ( ( isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '' ) ? 'selected' : '' ); ?> ><?php esc_html_e( 'Use Default', 'wpsc' ); ?></option>
669
+ <option value='1' <?php echo ( ( isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '1' ) ? 'selected' : '' ); ?> ><?php esc_html_e( 'Yes', 'wpsc' ); ?></option>
670
+ <option value='0' <?php echo ( ( isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '0' ) ? 'selected' : '' ); ?> ><?php esc_html_e( 'No', 'wpsc' ); ?></option>
671
+ </select>
672
+ <br/><?php esc_html_e( 'Allow users to comment on this Product.', 'wpsc' ); ?>
673
+ </td>
674
+ </tr>
675
+ </table>
676
+ <?php
677
  }
 
 
 
 
 
 
678
  function wpsc_product_external_link_forms() {
679
 
680
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
681
+ $product_data = get_post_custom( $post->ID );
682
+
683
+ $product_data['meta'] = $product_meta = array();
684
+ if ( !empty( $product_data['_wpsc_product_metadata'] ) )
685
+ $product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
686
 
687
  // Get External Link Values
688
+ $external_link_value = isset( $product_meta['external_link'] ) ? $product_meta['external_link'] : '';
689
+ $external_link_text_value = isset( $product_meta['external_link_text'] ) ? $product_meta['external_link_text'] : '';
690
+ $external_link_target_value = isset( $product_meta['external_link_target'] ) ? $product_meta['external_link_target'] : '';
691
+ $external_link_target_value_selected[$external_link_target_value] = ' selected="selected"';
692
+ if ( !isset( $external_link_target_value_selected['_self'] ) ) $external_link_target_value_selected['_self'] = '';
693
+ if ( !isset( $external_link_target_value_selected['_blank'] ) ) $external_link_target_value_selected['_blank'] = '';
694
 
695
+ ?>
696
+ <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' ); ?>
697
+ <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
698
+ <tbody>
699
+ <tr class="form-field">
700
+ <th valign="top" scope="row"><label for="external_link"><?php esc_html_e( 'External Link', 'wpsc' ); ?></label></th>
701
+ <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>
702
+ </tr>
703
+ <tr class="form-field">
704
+ <th valign="top" scope="row"><label for="external_link_text"><?php esc_html_e( 'External Link Text', 'wpsc' ); ?></label></th>
705
+ <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>
706
+ </tr>
707
+ <tr class="form-field">
708
+ <th valign="top" scope="row"><label for="external_link_target"><?php esc_html_e( 'External Link Target', 'wpsc' ); ?></label></th>
709
+ <td>
710
+ <select id="external_link_target" name="meta[_wpsc_product_metadata][external_link_target]">
711
+ <option value=""><?php _ex( 'Default (set by theme)', 'External product link target', 'wpsc' ); ?></option>
712
+ <option value="_self" <?php echo $external_link_target_value_selected['_self'] ; ?>><?php esc_html_e( 'Open link in the same window', 'wpsc' ); ?></option>
713
+ <option value="_blank" <?php echo $external_link_target_value_selected['_blank'] ; ?>><?php esc_html_e( 'Open link in a new window', 'wpsc' ); ?></option>
714
+ </select>
715
+ </td>
716
+ </tr>
717
+ </tbody>
718
+ </table>
719
+ <?php
720
+ }
721
+ function wpsc_product_image_forms() {
 
 
 
 
 
 
 
 
 
722
 
723
+ global $post;
724
 
725
+ edit_multiple_image_gallery( $post );
726
 
 
727
  ?>
 
 
 
728
 
729
+ <p><strong <?php if ( isset( $display ) ) echo $display; ?>><a href="media-upload.php?parent_page=wpsc-edit-products&amp;post_id=<?php echo $post->ID; ?>&amp;type=image&amp;tab=gallery&amp;TB_iframe=1&amp;width=640&amp;height=566" class="thickbox" title="<?php esc_attr_e( 'Manage Product Images', 'wpsc' ); ?>"><?php esc_html_e( 'Manage Product Images', 'wpsc' ); ?></a></strong></p>
730
+ <?php
731
  }
732
+ function wpsc_additional_desc() {
733
+ ?>
734
+ <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo esc_textarea( get_post_field( 'post_excerpt', get_the_ID() ) ); ?></textarea>
735
+ <?php
736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
  }
 
 
738
  function wpsc_product_download_forms() {
739
  global $post, $wpdb, $wpsc_product_defaults;
740
  $product_data = get_post_custom( $post->ID );
741
  $output = '';
742
+ $product_data['meta'] = $product_meta = array();
 
743
  if ( !empty( $product_data['_wpsc_product_metadata'] ) )
744
+ $product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
745
 
746
  $upload_max = wpsc_get_max_upload_size();
747
  ?>
748
  <?php echo wpsc_select_product_file( $post->ID ); ?>
749
+ <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>
750
+ <a name="wpsc_downloads"></a>
751
+ <h4><?php esc_html_e( 'Upload New File', 'wpsc' ); ?>:</h4>
752
+ <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 />
 
 
 
 
753
 
754
  <?php
755
  if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
756
  ?>
757
+ <br />
758
+ <h4><?php esc_html_e( 'Select an MP3 file to upload as a preview', 'wpsc' ) ?></h4>
759
+ <input type='file' name='preview_file' value='' /><br />
760
 
761
+ <h4><?php esc_html_e( 'Your preview for this product', 'wpsc' ) ?>:</h4>
762
 
763
+ <?php
764
  $args = array(
765
  'post_type' => 'wpsc-preview-file',
766
  'post_parent' => $post->ID,
768
  'post_status' => 'all'
769
  );
770
 
771
+ $preview_files = (array)get_posts( $args );
772
 
773
+ foreach ($preview_files as $preview)
774
  echo $preview->post_title . '<br />';
 
 
775
  ?>
776
+ <br />
777
+ <?php
778
  }
 
779
  $output = apply_filters( 'wpsc_downloads_metabox', $output );
780
  }
781
 
782
  /**
783
+ * Adding function to change text for media buttons
 
 
784
  */
785
+ function change_context( $context ) {
786
+ $current_screen = get_current_screen();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
787
 
788
+ if ( $current_screen->id != 'wpsc-product' )
789
+ return $context;
790
+ return __( 'Upload Image%s', 'wpsc' );
791
  }
792
+ function change_link( $link ) {
793
+ global $post_ID;
794
+ $current_screen = get_current_screen();
795
+ if ( $current_screen && $current_screen->id != 'wpsc-product' )
796
+ return $link;
797
 
798
+ $uploading_iframe_ID = $post_ID;
799
+ $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
800
 
801
+ return $media_upload_iframe_src . "&amp;type=image&parent_page=wpsc-edit-products";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
802
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
803
  function wpsc_form_multipart_encoding() {
804
  echo ' enctype="multipart/form-data"';
805
  }
806
 
807
  add_action( 'post_edit_form_tag', 'wpsc_form_multipart_encoding' );
808
 
809
+ if ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) ) {
810
+ add_filter( 'media_buttons_context', 'change_context' );
811
+ add_filter( 'image_upload_iframe_src', "change_link" );
812
+ }
813
+
814
  /*
815
  * Modifications to Media Gallery
816
  */
817
 
818
+ if ( ( isset( $_REQUEST['parent_page'] ) && ( $_REQUEST['parent_page'] == 'wpsc-edit-products' ) ) ) {
819
+ add_filter( 'media_upload_tabs', 'wpsc_media_upload_tab_gallery', 12 );
820
+ add_filter( 'media_upload_form_url', 'wpsc_media_upload_url', 9, 1 );
821
+ add_action( 'admin_head', 'wpsc_gallery_css_mods' );
822
+ }
823
+ add_filter( 'gettext', 'wpsc_filter_delete_text', 12 , 3 );
824
  add_filter( 'attachment_fields_to_edit', 'wpsc_attachment_fields', 11, 2 );
825
  add_filter( 'attachment_fields_to_save', 'wpsc_save_attachment_fields', 9, 2 );
826
  add_filter( 'gettext_with_context', 'wpsc_filter_gettex_with_context', 12, 4);
837
  function wpsc_filter_gettex_with_context( $translation, $text, $context, $domain ) {
838
 
839
  if ( 'Taxonomy Parent' == $context && 'Parent' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ) {
840
+ $translations = &get_translations_for_domain( $domain );
841
  return $translations->translate( 'Variation Set', 'wpsc' );
842
  //this will never happen, this is here only for gettext to pick up the translation
843
  return __( 'Variation Set', 'wpsc' );
845
  return $translation;
846
  }
847
 
848
+ /*
849
+ * This filter translates string before it is displayed
850
+ * specifically for the words 'Use as featured image' with 'Use as Product Thumbnail' when the user is selecting a Product Thumbnail
851
+ * using media gallery.
852
+ *
853
+ * @todo As this feature is entirely cosmetic and breaks with WP_DEBUG on in WP 3.5+, we've removed the filter for it. Will revisit the functionality in 3.9 when we look at new media workflows.
854
+ * @param $translation The current translation
855
+ * @param $text The text being translated
856
+ * @param $domain The domain for the translation
857
+ * @return string The translated / filtered text.
858
+ */
859
+ function wpsc_filter_feature_image_text( $translation, $text, $domain ) {
860
+ if ( 'Use as featured image' == $text && isset( $_REQUEST['post_id'] ) ) {
861
+ $post = get_post( $_REQUEST['post_id'] );
862
+ if ( $post->post_type != 'wpsc-product' ) return $translation;
863
+ $translations = &get_translations_for_domain( $domain );
864
+ return $translations->translate( 'Use as Product Thumbnail', 'wpsc' );
865
+ //this will never happen, this is here only for gettexr to pick up the translation
866
+ return __( 'Use as Product Thumbnail', 'wpsc' );
867
+ }
868
+
869
+ return $translation;
870
+ }
871
  function wpsc_attachment_fields( $form_fields, $post ) {
872
  $out = '';
873
 
970
 
971
  }
972
  function wpsc_save_attachment_fields( $post, $attachment ) {
973
+ if ( isset ( $attachment['wpsc_custom_thumb_w'] ) )
 
974
  update_post_meta( $post['ID'], '_wpsc_custom_thumb_w', $attachment['wpsc_custom_thumb_w'] );
 
975
 
976
+ if ( isset ( $attachment['wpsc_custom_thumb_h'] ) )
977
  update_post_meta( $post['ID'], '_wpsc_custom_thumb_h', $attachment['wpsc_custom_thumb_h'] );
 
978
 
979
+ if ( isset ( $attachment['wpsc_image_size'] ) )
980
  update_post_meta( $post['ID'], '_wpsc_selected_image_size', $attachment['wpsc_image_size'] );
 
981
 
982
  return $post;
983
  }
984
+ function wpsc_media_upload_url( $form_action_url ) {
985
+
986
+ $form_action_url = esc_url( add_query_arg( array( 'parent_page'=>'wpsc-edit-products' ) ) );
987
+
988
+ return $form_action_url;
989
+
990
+ }
991
+ function wpsc_gallery_css_mods() {
992
+
993
+ print '<style type="text/css">
994
+ #gallery-settings *{
995
+ display:none;
996
+ }
997
+ a.wp-post-thumbnail {
998
+ color:green;
999
+ }
1000
+ #media-upload a.del-link {
1001
+ color:red;
1002
+ }
1003
+ #media-upload a.wp-post-thumbnail {
1004
+ margin-left:0px;
1005
+ }
1006
+ td.savesend input.button {
1007
+ display:none;
1008
+ }
1009
+ </style>';
1010
+ print '
1011
+ <script type="text/javascript">
1012
+ jQuery(function(){
1013
+ jQuery("td.A1B1").each(function(){
1014
+
1015
+ var target = jQuery(this).next();
1016
+ jQuery("p > input.button", this).appendTo(target);
1017
+
1018
+ });
1019
+
1020
+ jQuery("a.wp-post-thumbnail").each(function(){
1021
+ var product_image = jQuery(this).text();
1022
+ if (product_image == "' . __( 'Use as featured image' ) . '") {
1023
+ jQuery(this).text("' . __( 'Use as Product Thumbnail', 'wpsc' ) . '");
1024
+ }
1025
+ });
1026
+ });
1027
+
1028
+ </script>';
1029
+ }
1030
+ function wpsc_media_upload_tab_gallery( $tabs ) {
1031
+
1032
+ unset( $tabs['gallery'] );
1033
+ $tabs['gallery'] = __( 'Product Image Gallery', 'wpsc' );
1034
+
1035
+ return $tabs;
1036
+ }
1037
+ function wpsc_filter_delete_text( $translation, $text, $domain ) {
1038
+
1039
+ if ( 'Delete' == $text && isset( $_REQUEST['post_id'] ) && isset( $_REQUEST['parent_page'] ) ) {
1040
+ $translations = &get_translations_for_domain( $domain );
1041
+ return $translations->translate( 'Trash' ) ;
1042
+ }
1043
+ return $translation;
1044
+ }
1045
+ function edit_multiple_image_gallery( $post ) {
1046
+ global $wpdb;
1047
+
1048
+ // Make sure thumbnail isn't duplicated
1049
+ if ( $post->ID > 0 ) {
1050
+ if ( has_post_thumbnail( $post->ID ) )
1051
+ echo get_the_post_thumbnail( $post->ID, 'admin-product-thumbnails' );
1052
+
1053
+ $args = array(
1054
+ 'post_type' => 'attachment',
1055
+ 'numberposts' => -1,
1056
+ 'post_status' => null,
1057
+ 'post_parent' => $post->ID,
1058
+ 'orderby' => 'menu_order',
1059
+ 'order' => 'ASC'
1060
+ );
1061
+
1062
+ $attached_images = (array)get_posts( $args );
1063
+
1064
+ if ( count( $attached_images ) > 0 ) {
1065
+ foreach ( $attached_images as $images ) {
1066
+ $attached_image = wp_get_attachment_image( $images->ID, 'admin-product-thumbnails' );
1067
+ echo $attached_image. '&nbsp;';
1068
+ }
1069
+ }
1070
+
1071
+ }
1072
+ }
1073
 
1074
  /**
1075
+ * wpsc_save_quickedit_box function
1076
+ * Saves input for the various meta in the quick edit boxes
1077
  *
1078
+ * @todo UI
1079
+ * @todo Data validation / sanitization / security
1080
+ * @todo AJAX should probably return weight unit
1081
+ * @return $post_id (int) Post ID
 
 
 
1082
  */
 
1083
 
1084
+ function wpsc_save_quickedit_box( $post_id ) {
1085
  global $doaction;
1086
 
1087
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || get_post_type( $post_id ) != 'wpsc-product' )
 
1088
  return;
 
1089
 
1090
+ $bulk = isset( $doaction ) && $doaction =='edit';
1091
 
 
1092
  $custom_fields = array(
1093
+ 'weight' => 'product_metadata',
1094
+ 'stock' => 'stock',
1095
+ 'price' => 'price',
1096
  'sale_price' => 'special_price',
1097
+ 'sku' => 'sku',
1098
  );
1099
 
1100
+ $args = array(
1101
+ 'post_parent' => $post_id,
1102
+ 'post_type' => 'wpsc-product',
1103
+ 'post_status' => 'inherit'
1104
+ );
1105
+ $children = get_children($args);
1106
+ $is_parent = (bool)$children;
 
1107
  foreach ( $custom_fields as $post_key => $meta_key ) {
1108
+ $overideVariant = isset($_REQUEST[$post_key.'_variant']) && $_REQUEST[$post_key.'_variant'] == 'on';
1109
+ // 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)
1110
+ if ( ! isset( $_REQUEST[$post_key] ) || ( $bulk && empty( $_REQUEST[$post_key] ) ) ||
1111
+ ( $is_parent && in_array( $post_key, array( 'weight', 'stock', 'price', 'special_price' )) && !$overideVariant ) ){
1112
  continue;
1113
  }
1114
 
1115
+ if($is_parent && count($children) >0){
1116
+ $products = $children;
1117
+ }else{
1118
+ $products = array($post_id);
 
 
 
 
 
 
 
1119
  }
1120
 
1121
+ foreach($products as $product){
1122
+ $value = $_REQUEST[$post_key];
1123
+ if($is_parent) $post_id = $product->ID;
1124
+ else $post_id = $product;
1125
  switch ( $post_key ) {
 
1126
  case 'weight':
1127
  $product_meta = get_post_meta( $post_id, '_wpsc_product_metadata', true );
1128
+ if ( ! is_array( $product_meta ) )
1129
  $product_meta = array();
1130
+ // draft products don't have product metadata set yet
1131
+ $weight_unit = isset( $product_meta["weight_unit"] ) ? $product_meta["weight_unit"] : 'pound';
1132
+ $weight = wpsc_convert_weight( $value, $weight_unit, "pound", true );
 
 
1133
 
1134
+ if ( isset( $product_meta["weight"] ) )
1135
+ unset( $product_meta["weight"] );
 
1136
 
1137
+ $product_meta["weight"] = $weight;
1138
 
1139
  $value = $product_meta;
1140
  break;
1141
 
1142
  case 'stock':
1143
+ if ( ! is_numeric( $value ) )
1144
  $value = '';
 
1145
  break;
1146
 
1147
  case 'sku':
1148
+ if ( $value == __( 'N/A', 'wpsc' ) )
1149
  $value = '';
 
1150
  break;
 
1151
  }
1152
 
1153
  update_post_meta( $post_id, "_wpsc_{$meta_key}", $value );
1155
  }
1156
 
1157
  return $post_id;
 
1158
  }
1159
 
1160
  /**
1174
  ?>
1175
 
1176
  <fieldset class="inline-edit-col-left wpsc-cols">
1177
+ <div class="inline-edit-col">
1178
+ <div class="inline-edit-group">
1179
  <?php
1180
  switch ( $col_name ) :
1181
  case 'SKU' :
1182
  ?>
1183
+ <label style="max-width: 85%" class="alignleft">
1184
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'SKU:', 'wpsc' ); ?> </span>
1185
+ <input type="text" name="sku" class="wpsc_ie_sku" />
1186
  <input type="checkbox" name="sku_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1187
 
1188
+ </label>
1189
+ <?php
1190
  break;
1191
  case 'weight' :
1192
  ?>
1193
+ <label style="max-width: 85%" class="alignleft">
1194
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Weight:', 'wpsc' ); ?> </span>
1195
+ <input type="text" name="weight" class="wpsc_ie_weight" />
1196
  <input type="checkbox" name="weight_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1197
+ </label>
1198
+ <?php
1199
  break;
1200
  case 'stock' :
1201
  ?>
1202
+ <label style="max-width: 85%" class="alignleft">
1203
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Stock:', 'wpsc' ); ?> </span>
1204
+ <input type="text" name="stock" class="wpsc_ie_stock" />
1205
  <input type="checkbox" name="stock_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1206
+ </label>
1207
+ <?php
1208
  break;
1209
  case 'price' :
1210
  ?>
1211
+ <label style="max-width: 85%" class="alignleft">
1212
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Price:', 'wpsc' ); ?> </span>
1213
+ <input type="text" name="price" class="wpsc_ie_price" />
1214
  <input type="checkbox" name="price_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1215
+ </label>
1216
+ <?php
1217
  break;
1218
  case 'sale_price' :
1219
  ?>
1220
+ <label style="max-width: 85%" class="alignleft">
1221
+ <span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Sale Price:', 'wpsc' ); ?> </span>
1222
+ <input type="text" name="sale_price" class="wpsc_ie_sale_price" />
1223
  <input type="checkbox" name="sale_price_variant"> <span><?php esc_html_e( 'Update Variants', 'wpsc');?></span>
1224
+ </label>
1225
+ <?php
1226
  break;
1227
  endswitch;
1228
  ?>
1229
+ </div>
1230
+ </div>
1231
  </fieldset>
1232
  <?php
1233
  }
1281
  } else{
1282
  ?>
1283
  <tr class="form-field">
1284
+ <th scope="row" valign="top">
1285
  <label for="variation_price"><?php esc_html_e( 'Variation Price', 'wpsc' ); ?></label>
1286
+ </th>
1287
+ <td>
1288
  <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
1289
  <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>
1290
+ </td>
1291
  </tr>
1292
  <?php
1293
  }
1349
 
1350
  /**
1351
  * @todo - Should probably refactor this at some point - very procedural,
1352
+ * WAY too many foreach loops for my liking :) But it does the trick
1353
  *
1354
  * @param <type> $term_id
1355
  */
1368
  // 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
1369
  if ( isset( $_POST["apply_to_current"] ) ) {
1370
 
1371
+ //Check for flat, percentile or differential
1372
+ $var_price_type = '';
1373
+
1374
+ if ( flat_price( $_POST["variation_price"] ) )
1375
+ $var_price_type = 'flat';
1376
+ elseif ( differential_price( $_POST["variation_price"] ) )
1377
+ $var_price_type = 'differential';
1378
+ elseif ( percentile_price( $_POST["variation_price"] ) )
1379
+ $var_price_type = 'percentile';
1380
+
1381
  //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)
1382
  $products_to_mod = get_objects_in_term( $term_id, "wpsc-variation" );
1383
  $product_parents = array( );
1439
  }
1440
  }
1441
  add_action( 'before_delete_post', 'wpsc_delete_variations' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/includes/product-functions.php CHANGED
@@ -18,37 +18,28 @@ 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 );
28
  $product_id = $post_ID;
29
-
30
- $post_data['additional_description'] = isset( $post_data['additional_description'] ) ? $post_data['additional_description'] : '';
31
-
32
- if ( ! isset( $post_data['meta'] ) && isset( $_POST['meta'] ) ) {
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
-
40
  if ( isset( $post_data['meta']['_wpsc_special_price'] ) )
41
  $post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
42
-
43
- if ( isset( $post_data['meta']['_wpsc_sku'] ) && $post_data['meta']['_wpsc_sku'] == __('N/A', 'wpsc') ) {
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;
54
  } else {
@@ -56,33 +47,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 +79,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,67 +102,19 @@ 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
 
@@ -227,17 +145,22 @@ 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.
239
- if ( isset( $post_data['tax_input']['wpsc_product_category'] ) && count( $post_data['tax_input']['wpsc_product_category'] ) == 1 && $post_data['tax_input']['wpsc_product_category'][0] == 0){
240
  $post_data['tax_input']['wpsc_product_category'][1] = wpsc_add_product_category_default($product_id);
 
241
  }
242
 
243
  // and the meta
@@ -246,21 +169,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 +206,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 != '' ) )
@@ -303,7 +218,7 @@ function wpsc_pre_update( $data , $postarr ) {
303
  return $data;
304
  }
305
  add_filter( 'wp_insert_post_data','wpsc_pre_update', 99, 2 );
306
- add_action( 'save_post', 'wpsc_admin_submit_product', 5, 2 );
307
  add_action( 'admin_notices', 'wpsc_admin_submit_notices' );
308
 
309
  /**
@@ -370,6 +285,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 +357,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 +391,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 +439,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 +531,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 +549,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 +643,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 +651,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 +692,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 +746,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 +772,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 +851,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
+ global $wpdb;
22
 
23
+ $current_screen = get_current_screen();
24
+
25
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || empty( $current_screen ) || $current_screen->id != 'wpsc-product' || $post->post_type != 'wpsc-product' || empty( $_POST['meta'] ) )
26
+ return $post_ID;
27
 
28
  //Type-casting ( not so much sanitization, which would be good to do )
29
+ $post_data = stripslashes_deep( $_POST );
30
  $product_id = $post_ID;
31
+ $post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
32
+ $post_meta['meta'] = (array)$_POST['meta'];
 
 
 
 
 
 
33
  if ( isset( $post_data['meta']['_wpsc_price'] ) )
34
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
 
35
  if ( isset( $post_data['meta']['_wpsc_special_price'] ) )
36
  $post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
37
+ if($post_data['meta']['_wpsc_sku'] == __('N/A', 'wpsc'))
 
38
  $post_data['meta']['_wpsc_sku'] = '';
39
+ if( isset( $post_data['meta']['_wpsc_is_donation'] ) )
40
+ $post_data['meta']['_wpsc_is_donation'] = 1;
41
+ else
42
+ $post_data['meta']['_wpsc_is_donation'] = 0;
 
 
 
43
  if ( ! isset( $post_data['meta']['_wpsc_limited_stock'] ) ){
44
  $post_data['meta']['_wpsc_stock'] = false;
45
  } else {
47
  }
48
 
49
  unset($post_data['meta']['_wpsc_limited_stock']);
50
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'] = 0;
51
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
52
+ if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
53
  if(!isset($post_data['special'])) $post_data['special'] = '';
54
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
55
 
56
+ $post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'];
57
+ $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
58
  $post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
59
  $post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
60
+ $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  // Product Weight
63
  if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
79
  }
80
  }
81
 
82
+ // table rate price
83
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
 
84
 
85
+ // if table_rate_price is unticked, wipe the table rate prices
86
+ if ( empty( $post_data['table_rate_price']['state'] ) ) {
87
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
88
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
89
+ }
90
 
91
+ if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
92
+ foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ){
93
+ if(empty($value)){
94
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
95
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
 
 
 
 
 
 
 
 
96
  }
97
  }
98
  }
102
  $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] );
103
  }
104
 
105
+ if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] ) )
106
+ $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] = wpsc_string_to_float(
107
+ $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount']
108
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  // Advanced Options
111
+ $post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
112
+ $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
113
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
 
 
 
 
 
 
 
 
 
 
 
114
  $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
115
 
116
+ $post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
117
+ $post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  $post_data['files'] = $_FILES;
120
 
145
  'thumbnail_state' => null
146
  );
147
 
148
+ foreach($product_columns as $column => $default)
149
+ {
150
+ if (!isset($post_data[$column])) $post_data[$column] = '';
151
+
152
+ if($post_data[$column] !== null) {
153
+ $update_values[$column] = $post_data[$column];
154
+ } else if(($update != true) && ($default !== null)) {
155
+ $update_values[$column] = ($default);
156
  }
157
  }
 
158
  // if we succeed, we can do further editing (todo - if_wp_error)
159
 
160
  // if we have no categories selected, assign one.
161
+ if( isset( $post_data['tax_input']['wpsc_product_category'] ) && count( $post_data['tax_input']['wpsc_product_category'] ) == 1 && $post_data['tax_input']['wpsc_product_category'][0] == 0){
162
  $post_data['tax_input']['wpsc_product_category'][1] = wpsc_add_product_category_default($product_id);
163
+
164
  }
165
 
166
  // and the meta
169
  // and the custom meta
170
  wpsc_update_custom_meta($product_id, $post_data);
171
 
172
+ //and the alt currency
173
+ if ( ! empty( $post_data['newCurrency'] ) ) {
174
+ foreach( (array) $post_data['newCurrency'] as $key =>$value ){
175
+ wpsc_update_alt_product_currency( $product_id, $value, $post_data['newCurrPrice'][$key] );
 
 
 
 
 
 
 
176
  }
177
  }
178
 
179
+ if($post_data['files']['file']['tmp_name'] != '') {
180
  wpsc_item_process_file($product_id, $post_data['files']['file']);
181
  } else {
182
  if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
206
  $data['post_status'] = 'inherit';
207
  }
208
 
209
+ if ( !empty( $postarr['meta'] ) && ( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] == 0 || empty( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) ) )
210
+ $data["comment_status"] = "closed";
211
+ else
212
+ $data["comment_status"] = "open";
 
213
 
214
  //Can anyone explain to me why this is here?
215
  if ( isset( $sku ) && ( $sku != '' ) )
218
  return $data;
219
  }
220
  add_filter( 'wp_insert_post_data','wpsc_pre_update', 99, 2 );
221
+ add_action( 'save_post', 'wpsc_admin_submit_product', 10, 2 );
222
  add_action( 'admin_notices', 'wpsc_admin_submit_notices' );
223
 
224
  /**
285
 
286
  $post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
287
  $post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
288
+ $post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
289
  if (!isset($post_data['meta']['_wpsc_is_donation'])) $post_data['meta']['_wpsc_is_donation'] = '';
290
  $post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
291
  $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
357
  );
358
 
359
 
360
+ foreach($product_columns as $column => $default)
361
+ {
362
+ if (!isset($post_data[$column])) $post_data[$column] = '';
363
+
364
+ if($post_data[$column] !== null) {
365
+ $update_values[$column] = $post_data[$column];
366
+ } else if(($update != true) && ($default !== null)) {
367
+ $update_values[$column] = $default;
368
  }
369
  }
370
 
391
  }else {
392
  unstick_post($product_id);
393
  }
394
+ if ($product_id == 0 ) {
395
+ if ( $wp_error ) {
396
+ return new WP_Error('db_insert_error', __( 'Could not insert product into the database', 'wpsc' ), $wpdb->last_error);
397
+ } else {
398
+ return 0;
399
+ }
400
+ }
401
  $adding = true;
402
 
403
  // if we succeed, we can do further editing
439
  }
440
 
441
  if (strchr($price, '-') ) {
442
+ $negative = true;
443
  } else {
444
  $positive = true;
445
  }
531
  if (!isset($post_data['edit_var_val']))
532
  $post_data['edit_var_val'] = '';
533
 
534
+ $variations = (array)$post_data['edit_var_val'];
535
 
536
  // Generate the arrays for variation sets, values and combinations
537
  $wpsc_combinator = new wpsc_variation_combinator($variations);
549
 
550
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
551
  $variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
 
552
  wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
553
 
554
  $parent_id = $_REQUEST['product_id'];
643
  $currently_associated_vars[] = $current->term_id;
644
  }
645
 
 
 
646
  foreach ($posted_term as $term=>$val) {
647
  $posted_terms[] = $term;
648
  if(is_array($val)) {
651
  }
652
  }
653
  }
 
654
  if(!empty($currently_associated_vars)){
655
  $term_ids_to_delete = array();
656
  $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
657
  }
658
+ if(isset($_REQUEST["post_ID"]))
 
659
  $post_id = $_REQUEST["post_ID"];
660
+ elseif(isset($_REQUEST["product_id"]))
661
  $post_id = $_REQUEST["product_id"];
 
 
 
 
662
  if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
663
  $post_ids_to_delete = array();
664
 
692
  }
693
  }
694
  }
 
 
695
  }
696
 
697
  function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
746
 
747
  function wpsc_update_custom_meta($product_id, $post_data) {
748
 
749
+ if($post_data['new_custom_meta'] != null) {
750
  foreach((array)$post_data['new_custom_meta']['name'] as $key => $name) {
751
  $value = $post_data['new_custom_meta']['value'][(int)$key];
752
  if(($name != '') && ($value != '')) {
753
  add_post_meta($product_id, $name, $value);
754
  }
755
  }
756
+ }
757
 
758
  if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
759
  if($post_data['custom_meta'] != null) {
772
  * @param array the file array from $_FILES
773
  * @param array the preview file array from $_FILES
774
  */
775
+ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = null) {
776
+ global $wpdb;
777
+ add_filter('upload_dir', 'wpsc_modify_upload_directory');
778
+ $overrides = array('test_form'=>false);
 
779
 
780
+ $time = current_time('mysql');
781
+ if ( $post = get_post($product_id) ) {
782
  if ( substr( $post->post_date, 0, 4 ) > 0 )
783
  $time = $post->post_date;
784
  }
785
 
786
+ $file = wp_handle_upload($submitted_file, $overrides, $time);
787
+ if ( isset($file['error']) )
 
788
  return new WP_Error( 'upload_error', $file['error'] );
 
789
 
790
+ $name_parts = pathinfo($file['file']);
791
+ $name = $name_parts['basename'];
792
+
793
+ $url = $file['url'];
794
+ $type = $file['type'];
795
+ $file = $file['file'];
796
+ $title = $name;
797
+ $content = '';
798
 
799
  // Construct the attachment array
800
  $attachment = array(
801
+ 'post_mime_type' => $type,
802
+ 'guid' => $url,
803
+ 'post_parent' => $product_id,
804
+ 'post_title' => $title,
805
+ 'post_content' => $content,
806
+ 'post_type' => "wpsc-product-file",
807
+ 'post_status' => 'inherit'
808
  );
809
 
810
  // Save the data
811
+ $id = wp_insert_post($attachment, $file, $product_id);
812
+ remove_filter('upload_dir', 'wpsc_modify_upload_directory');
 
813
  }
814
 
815
  function wpsc_modify_upload_directory($input) {
851
  'post_status' => 'any'
852
  );
853
 
854
+ $attached_files = (array)get_posts($args);
 
855
 
856
  foreach($attached_files as $key => $attached_file) {
857
  $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;
@@ -211,28 +206,14 @@ class WPSC_Product_Variation_List_Table extends WP_List_Table {
211
 
212
  public function column_title( $item ) {
213
  $title = implode( ', ', $this->object_terms_cache[$item->ID] );
214
- $thumbnail = wpsc_the_product_thumbnail( false, false, $item->ID, 'manage-products' );
215
  $show_edit_link = apply_filters( 'wpsc_show_product_variations_edit_action', true, $item );
216
 
217
- $nonce = wp_create_nonce( "wpsc_ajax_get_variation_gallery_{$item->ID}" );
218
- $save_gallery_nonce = wp_create_nonce( "wpsc_ajax_update_gallery_{$item->ID}" );
219
- $get_gallery_nonce = wp_create_nonce( "wpsc_ajax_get_gallery_{$item->ID}" );
220
-
221
  if ( ! $thumbnail )
222
  $thumbnail = WPSC_CORE_IMAGES_URL . '/no-image-uploaded.gif';
223
  ?>
224
  <div class="wpsc-product-variation-thumbnail">
225
- <a
226
- target="_blank"
227
- data-featured-nonce="<?php echo esc_attr( wp_create_nonce( "update-post_{$item->ID}" ) ); ?>"
228
- data-nonce="<?php echo esc_attr( $nonce ); ?>"
229
- data-save-gallery-nonce="<?php echo esc_attr( $save_gallery_nonce ); ?>"
230
- data-get-gallery-nonce="<?php echo esc_attr( $get_gallery_nonce ); ?>"
231
- data-image-id="<?php echo get_post_thumbnail_id( $item->ID ); ?>"
232
- data-id="<?php echo $item->ID; ?>"
233
- data-title="<?php echo esc_attr( $title ); ?>"
234
- href="<?php echo esc_url( admin_url( 'media-upload.php?post_id=' . $item->ID . '&width=640&height=566&product_variation=1' ) ) ?>"
235
- >
236
  <img id="wpsc-variation-thumbnail-<?php echo $item->ID; ?>" src="<?php echo esc_url( $thumbnail ); ?>" alt="" />
237
  </a>
238
  </div>
@@ -418,7 +399,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 +424,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 +488,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;
206
 
207
  public function column_title( $item ) {
208
  $title = implode( ', ', $this->object_terms_cache[$item->ID] );
209
+ $thumbnail = wpsc_the_product_thumbnail( 50, 50, $item->ID, '' );
210
  $show_edit_link = apply_filters( 'wpsc_show_product_variations_edit_action', true, $item );
211
 
 
 
 
 
212
  if ( ! $thumbnail )
213
  $thumbnail = WPSC_CORE_IMAGES_URL . '/no-image-uploaded.gif';
214
  ?>
215
  <div class="wpsc-product-variation-thumbnail">
216
+ <a data-title="<?php echo esc_attr( $title ); ?>" href="<?php echo esc_url( admin_url( 'media-upload.php?post_id=' . $item->ID . '&TB_iframe=1&width=640&height=566&product_variation=1' ) ) ?>">
 
 
 
 
 
 
 
 
 
 
217
  <img id="wpsc-variation-thumbnail-<?php echo $item->ID; ?>" src="<?php echo esc_url( $thumbnail ); ?>" alt="" />
218
  </a>
219
  </div>
399
  <div id="message" class="updated"><p>
400
  <?php
401
  echo join( ' ', $messages ); unset( $messages );
402
+ $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ) );
403
  echo '</p></div>';
404
  }
405
 
424
  return $actions;
425
  }
426
 
427
+ public function bulk_actions() {
428
  $screen = get_current_screen();
429
 
430
  if ( is_null( $this->_actions ) ) {
488
  $avail_post_stati = get_available_post_statuses( 'wpsc-product' );
489
  $post_type_object = get_post_type_object( 'wpsc-product' );
490
  $post_type = $post_type_object->name;
491
+ $url_base = esc_url( add_query_arg( array(
492
  'action' => 'wpsc_product_variations_table',
493
  'product_id' => $_REQUEST['product_id'],
494
  '_wpnonce' => wp_create_nonce( 'wpsc_product_variations_table' ),
495
+ ), admin_url( 'admin-ajax.php' ) ) );
496
 
497
  if ( !empty($locked_post_status) )
498
  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
  }
@@ -134,8 +99,6 @@ class WPSC_Product_Variations_Page {
134
  wp_enqueue_script( 'jquery-color' );
135
  wp_enqueue_script( 'utils' );
136
  wp_enqueue_script( 'jquery-query' );
137
- wp_enqueue_media( array( 'post' => absint( $_REQUEST['product_id'] ) ) );
138
-
139
 
140
  $callback = "callback_tab_{$this->current_tab}";
141
  if ( ! is_callable( array( $this, "callback_tab_{$this->current_tab}" ) ) )
@@ -152,12 +115,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 +151,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 +179,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 +194,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 +215,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 +227,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 +239,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 +275,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'] );
@@ -345,7 +301,7 @@ class WPSC_Product_Variations_Page {
345
  'last_paged'
346
  ), $sendback );
347
  $sendback = add_query_arg( 'updated', count( $ids ), $sendback );
348
- wp_redirect( $sendback );
349
  exit;
350
  }
351
 
@@ -389,7 +345,7 @@ class WPSC_Product_Variations_Page {
389
  _wpsc_refresh_parent_product_terms( $this->parent_id );
390
  _wpsc_add_refresh_variation_parent_term_hooks();
391
  if ( $current_action != 'edit' ) {
392
- wp_redirect( $sendback );
393
  exit;
394
  }
395
  }
@@ -420,4 +376,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
  }
99
  wp_enqueue_script( 'jquery-color' );
100
  wp_enqueue_script( 'utils' );
101
  wp_enqueue_script( 'jquery-query' );
 
 
102
 
103
  $callback = "callback_tab_{$this->current_tab}";
104
  if ( ! is_callable( array( $this, "callback_tab_{$this->current_tab}" ) ) )
115
  'manage' => _x( 'Manage', 'manage product variations', 'wpsc' ),
116
  'setup' => __( 'Setup', 'wpsc' ),
117
  );
118
+ echo '<ul class="wpsc-product-variations-tabs">';
 
119
  foreach ( $tabs as $tab => $title ) {
120
+ $class = ( $tab == $this->current_tab ) ? ' class="active"' : '';
121
  $item = '<li' . $class . '>';
122
+ $item .= '<a href="' . esc_url( add_query_arg( 'tab', $tab ) ) . '">' . esc_html( $title ) . '</a></li>';
123
  echo $item;
124
  }
125
  echo '</ul>';
151
  '_wp_http_referer',
152
  'updated',
153
  ) );
154
+ wp_redirect( esc_url( add_query_arg( 'tab', 'manage', $sendback ) ) );
155
  exit;
156
  }
157
 
179
 
180
  $trashed++;
181
  }
182
+ return esc_url( add_query_arg( array( 'trashed' => $trashed, 'ids' => join( ',', $post_ids ) ) ) );
183
  }
184
 
185
  public function process_bulk_action_untrash( $post_ids ) {
194
 
195
  $untrashed++;
196
  }
197
+ return esc_url( add_query_arg( 'untrashed', $untrashed ) );
198
  }
199
 
200
  public function process_bulk_action_delete( $post_ids ) {
215
  }
216
  $deleted++;
217
  }
218
+ return esc_url( add_query_arg( 'deleted', $deleted ) );
219
  }
220
 
221
  public function process_bulk_action_hide( $post_ids ) {
227
  ) );
228
  $updated ++;
229
  }
230
+ return esc_url( add_query_arg( 'updated', $updated ) );
231
  }
232
 
233
  public function process_bulk_action_show( $post_ids ) {
239
  ) );
240
  $updated ++;
241
  }
242
+ return esc_url( add_query_arg( 'updated', $updated ) );
243
  }
244
 
245
  private function save_bulk_edited_items() {
275
  unset( $data['product_metadata']['weight_unit'] );
276
  }
277
 
278
+ foreach ( array( 'height', 'width', 'length' ) as $field ) {
279
+ if ( empty( $fields['measurements'][$field] ) ) {
280
  unset( $data['product_metadata']['dimensions'][$field] );
281
  unset( $data['product_metadata']['dimensions'][$field . '_unit'] );
 
 
 
 
282
  }
283
  }
 
 
284
  }
285
 
286
  unset( $data['post'] );
301
  'last_paged'
302
  ), $sendback );
303
  $sendback = add_query_arg( 'updated', count( $ids ), $sendback );
304
+ wp_redirect( esc_url( $sendback ) );
305
  exit;
306
  }
307
 
345
  _wpsc_refresh_parent_product_terms( $this->parent_id );
346
  _wpsc_add_refresh_variation_parent_term_hooks();
347
  if ( $current_action != 'edit' ) {
348
+ wp_redirect( esc_url( $sendback ) );
349
  exit;
350
  }
351
  }
376
  <head>
377
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
378
  <?php
379
+ }
wpsc-admin/includes/product-variations-setup.page.php CHANGED
@@ -14,7 +14,7 @@
14
  <p class="howto"><?php esc_html_e( "Example: Red, Green, Blue. Separate variants with commas.", 'wpsc' ); ?></p>
15
  <p>
16
  <a class="button" href="#"><?php esc_html_e( 'Add New Variants', 'wpsc' ); ?></a>
17
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
18
  </p>
19
  </div>
20
 
14
  <p class="howto"><?php esc_html_e( "Example: Red, Green, Blue. Separate variants with commas.", 'wpsc' ); ?></p>
15
  <p>
16
  <a class="button" href="#"><?php esc_html_e( 'Add New Variants', 'wpsc' ); ?></a>
17
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
18
  </p>
19
  </div>
20
 
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
  }
@@ -84,33 +73,25 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
84
  $selects = array( 'p.id', 'p.totalprice AS amount', 'p.processed AS status', 'p.track_id', 'p.date' );
85
  $selects[] = '
86
  (
87
- SELECT SUM(quantity) FROM ' . WPSC_TABLE_CART_CONTENTS . ' AS c
88
  WHERE c.purchaseid = p.id
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
  ";
@@ -349,7 +327,7 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
349
  return $views;
350
  }
351
 
352
- public function months_dropdown( $post_type = '' ) {
353
  global $wp_locale;
354
 
355
  $m = isset( $_REQUEST['m'] ) ? $_REQUEST['m'] : 0;
@@ -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
 
@@ -502,7 +459,7 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
502
  }
503
 
504
  public function column_amount( $item ) {
505
- echo '<a href="' . esc_attr( $this->item_url( $item ) ) . '" title="' . esc_attr__( 'View order details', 'wpsc' ) . '">';
506
  echo wpsc_currency_display( $item->amount ) . "<br />";
507
  echo '<small>' . sprintf( _n( '1 item', '%s items', $item->item_count, 'wpsc' ), number_format_i18n( $item->item_count ) ) . '</small>';
508
  echo '</a>';
@@ -531,7 +488,7 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
531
  echo '<select class="wpsc-purchase-log-status" data-log-id="' . $item->id . '">';
532
  echo $dropdown_options;
533
  echo '</select>';
534
- echo '<img src="' . esc_url( wpsc_get_ajax_spinner() ) . '" class="ajax-feedback" title="" alt="" />';
535
  }
536
 
537
  public function column_tracking( $item ) {
@@ -542,7 +499,7 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {
542
  <a class="add" href="#"><?php echo esc_html_x( 'Add Tracking ID', 'add purchase log tracking id', 'wpsc' ); ?></a>
543
  <input type="text" class="wpsc-purchase-log-tracking-id" value="<?php echo esc_attr( $item->track_id ); ?>" />
544
  <a class="button save" href="#"><?php echo esc_html_x( 'Save', 'save sales log tracking id', 'wpsc' ); ?></a>
545
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
546
  <small class="send-email"><a href="#"><?php echo esc_html_x( 'Send Email', 'sales log', 'wpsc' ); ?></a></small>
547
  </div>
548
  <?php
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
  }
73
  $selects = array( 'p.id', 'p.totalprice AS amount', 'p.processed AS status', 'p.track_id', 'p.date' );
74
  $selects[] = '
75
  (
76
+ SELECT COUNT(*) FROM ' . WPSC_TABLE_CART_CONTENTS . ' AS c
77
  WHERE c.purchaseid = p.id
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
  ";
327
  return $views;
328
  }
329
 
330
+ public function months_dropdown() {
331
  global $wp_locale;
332
 
333
  $m = isset( $_REQUEST['m'] ) ? $_REQUEST['m'] : 0;
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
 
459
  }
460
 
461
  public function column_amount( $item ) {
462
+ echo '<a href="' . esc_url( $this->item_url( $item ) ) . '" title="' . esc_attr__( 'View order details', 'wpsc' ) . '">';
463
  echo wpsc_currency_display( $item->amount ) . "<br />";
464
  echo '<small>' . sprintf( _n( '1 item', '%s items', $item->item_count, 'wpsc' ), number_format_i18n( $item->item_count ) ) . '</small>';
465
  echo '</a>';
488
  echo '<select class="wpsc-purchase-log-status" data-log-id="' . $item->id . '">';
489
  echo $dropdown_options;
490
  echo '</select>';
491
+ echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="ajax-feedback" title="" alt="" />';
492
  }
493
 
494
  public function column_tracking( $item ) {
499
  <a class="add" href="#"><?php echo esc_html_x( 'Add Tracking ID', 'add purchase log tracking id', 'wpsc' ); ?></a>
500
  <input type="text" class="wpsc-purchase-log-tracking-id" value="<?php echo esc_attr( $item->track_id ); ?>" />
501
  <a class="button save" href="#"><?php echo esc_html_x( 'Save', 'save sales log tracking id', 'wpsc' ); ?></a>
502
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
503
  <small class="send-email"><a href="#"><?php echo esc_html_x( 'Send Email', 'sales log', 'wpsc' ); ?></a></small>
504
  </div>
505
  <?php
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' ), 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, 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/packing-slip.php CHANGED
@@ -104,7 +104,6 @@
104
  <th><?php echo esc_html_x( 'Order ID', 'packing slip', 'wpsc' ); ?></th>
105
  <th><?php echo esc_html_x( 'Shipping Method', 'packing slip', 'wpsc' ); ?></th>
106
  <th><?php echo esc_html_x( 'Payment Method', 'packing slip', 'wpsc' ); ?></th>
107
- <?php wpsc_purchaselog_order_summary_headers(); ?>
108
  </tr>
109
  </thead>
110
  <tbody>
@@ -113,7 +112,6 @@
113
  <td><?php echo wpsc_purchaselog_details_purchnumber(); ?></td>
114
  <td><?php echo wpsc_display_purchlog_shipping_method(); ?></td>
115
  <td><?php echo wpsc_display_purchlog_paymentmethod(); ?></td>
116
- <?php wpsc_purchaselog_order_summary(); ?>
117
  </tr>
118
  </tbody>
119
  </table>
104
  <th><?php echo esc_html_x( 'Order ID', 'packing slip', 'wpsc' ); ?></th>
105
  <th><?php echo esc_html_x( 'Shipping Method', 'packing slip', 'wpsc' ); ?></th>
106
  <th><?php echo esc_html_x( 'Payment Method', 'packing slip', 'wpsc' ); ?></th>
 
107
  </tr>
108
  </thead>
109
  <tbody>
112
  <td><?php echo wpsc_purchaselog_details_purchnumber(); ?></td>
113
  <td><?php echo wpsc_display_purchlog_shipping_method(); ?></td>
114
  <td><?php echo wpsc_display_purchlog_paymentmethod(); ?></td>
 
115
  </tr>
116
  </tbody>
117
  </table>
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,29 +169,26 @@ 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>
198
  <div class='form-field'>
199
- <?php if ( wpsc_is_suhosin_enabled() ) : ?>
200
- <em><?php esc_html_e( "The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.", 'wpsc' ); ?></em>
201
  <?php else: ?>
202
  <div class='multiple-select-container'>
203
  <span><?php esc_html_e( 'Select', 'wpsc' ); ?> <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wpsc' ); ?></a>&nbsp; <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wpsc' ); ?></a></span><br />
@@ -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>
189
  <div class='form-field'>
190
+ <?php if( @extension_loaded( 'suhosin' ) ) : ?>
191
+ <em><?php esc_html__( "The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.", 'wpsc' ); ?></em>
192
  <?php else: ?>
193
  <div class='multiple-select-container'>
194
  <span><?php esc_html_e( 'Select', 'wpsc' ); ?> <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wpsc' ); ?></a>&nbsp; <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wpsc' ); ?></a></span><br />
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
@@ -67,7 +61,7 @@ class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab {
67
  <input type='radio' value='1' name='wpsc_options[wpsc_check_mime_types]' id='wpsc_check_mime_types1' <?php echo $wpsc_check_mime_types2; ?> /> <label for='wpsc_check_mime_types1'><?php _e('No', 'wpsc');?></label><br />
68
 
69
  <span class="wpscsmall description">
70
- <?php esc_html_e( 'Warning: Disabling this exposes your site to greater possibility of malicious files being uploaded, we recommend installing the Fileinfo extension for PHP rather than disabling this.', 'wpsc' ); ?>
71
  </span>
72
  </td>
73
  </tr>
@@ -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
61
  <input type='radio' value='1' name='wpsc_options[wpsc_check_mime_types]' id='wpsc_check_mime_types1' <?php echo $wpsc_check_mime_types2; ?> /> <label for='wpsc_check_mime_types1'><?php _e('No', 'wpsc');?></label><br />
62
 
63
  <span class="wpscsmall description">
64
+ <?php esc_html_e( 'Warning: Disabling this exposes your site to greater possibility of malicious files being uploaded, we recommend installing the Fileinfo extention for PHP rather than disabling this.', 'wpsc' ); ?>
65
  </span>
66
  </td>
67
  </tr>
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] ) ) {
@@ -269,7 +266,7 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
269
  <a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wpsc' ); ?>">
270
  <img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
271
  </a>
272
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
273
  </div>
274
  </td>
275
  <td class="namecol">
@@ -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
 
@@ -443,7 +440,7 @@ class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab {
443
  <a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wpsc' ); ?>">
444
  <img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
445
  </a>
446
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
447
  </div>
448
  </td>
449
  <td class="namecol">
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] ) ) {
266
  <a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wpsc' ); ?>">
267
  <img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
268
  </a>
269
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
270
  </div>
271
  </td>
272
  <td class="namecol">
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
 
440
  <a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wpsc' ); ?>">
441
  <img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
442
  </a>
443
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
444
  </div>
445
  </td>
446
  <td class="namecol">
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 ) {
@@ -74,14 +74,14 @@ class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
74
  <table id='wpsc-payment-gateway-settings' class='wpsc-edit-module-options wp-list-table widefat plugins'>
75
  <thead>
76
  <tr>
77
- <th scope="col" id="wpsc-gateway-active" class="manage-column"></th>
78
  <th scope="col" id="wpsc-gateway-name" class="manage-column column-name"><?php _e( 'Payment Gateway', 'wpsc' ); ?></th>
79
  <th scope="col" id="wpsc-gateway-display-name" class="manage-column column-description"><?php _e( 'Display Name', 'wpsc' ); ?></th>
80
  </tr>
81
  </thead>
82
  <tfoot>
83
  <tr>
84
- <th scope="col" id="wpsc-gateway-active" class="manage-column"></th>
85
  <th scope="col" id="wpsc-gateway-name" class="manage-column column-name"><?php _e( 'Payment Gateway', 'wpsc' ); ?></th>
86
  <th scope="col" id="wpsc-gateway-display-name" class="manage-column column-description"><?php _e( 'Display Name', 'wpsc' ); ?></th>
87
  </tr>
@@ -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
 
@@ -118,7 +120,7 @@ class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
118
  <div class="row-actions-visible">
119
  <span class="edit">
120
  <a class='edit-payment-module' title="<?php esc_attr_e( "Edit this Payment Gateway's Settings", 'wpsc' ) ?>" href='<?php echo esc_url( $this->get_gateway_settings_url( $gateway['id'] ) ); ?>'><?php esc_html_e( 'Settings', 'wpsc' ); ?></a>
121
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
122
  </span>
123
  </div>
124
  </td>
@@ -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 ) {
74
  <table id='wpsc-payment-gateway-settings' class='wpsc-edit-module-options wp-list-table widefat plugins'>
75
  <thead>
76
  <tr>
77
+ <th scope="col" id="wpsc-gateway-active" class="manage-column"><?php _e( 'Active', 'wpsc' ); ?></th>
78
  <th scope="col" id="wpsc-gateway-name" class="manage-column column-name"><?php _e( 'Payment Gateway', 'wpsc' ); ?></th>
79
  <th scope="col" id="wpsc-gateway-display-name" class="manage-column column-description"><?php _e( 'Display Name', 'wpsc' ); ?></th>
80
  </tr>
81
  </thead>
82
  <tfoot>
83
  <tr>
84
+ <th scope="col" id="wpsc-gateway-active" class="manage-column"><?php _e( 'Active', 'wpsc' ); ?></th>
85
  <th scope="col" id="wpsc-gateway-name" class="manage-column column-name"><?php _e( 'Payment Gateway', 'wpsc' ); ?></th>
86
  <th scope="col" id="wpsc-gateway-display-name" class="manage-column column-description"><?php _e( 'Display Name', 'wpsc' ); ?></th>
87
  </tr>
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
 
120
  <div class="row-actions-visible">
121
  <span class="edit">
122
  <a class='edit-payment-module' title="<?php esc_attr_e( "Edit this Payment Gateway's Settings", 'wpsc' ) ?>" href='<?php echo esc_url( $this->get_gateway_settings_url( $gateway['id'] ) ); ?>'><?php esc_html_e( 'Settings', 'wpsc' ); ?></a>
123
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
124
  </span>
125
  </div>
126
  </td>
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
@@ -53,7 +53,7 @@ class WPSC_Settings_Tab_General extends WPSC_Settings_Tab {
53
  ?>
54
  <span id='wpsc-base-region-drop-down'>
55
  <?php $this->display_region_drop_down(); ?>
56
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
57
  </span>
58
  <p class='description'><?php esc_html_e( 'Select your primary business location.', 'wpsc' ); ?></p>
59
  </td>
@@ -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">
@@ -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">
53
  ?>
54
  <span id='wpsc-base-region-drop-down'>
55
  <?php $this->display_region_drop_down(); ?>
56
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
57
  </span>
58
  <p class='description'><?php esc_html_e( 'Select your primary business location.', 'wpsc' ); ?></p>
59
  </td>
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">
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-components/theme-engine-v1/classes/settings-tab-presentation.php → wpsc-admin/includes/settings-tabs/presentation.php RENAMED
@@ -129,7 +129,7 @@ class WPSC_Settings_Tab_Presentation extends WPSC_Settings_Tab {
129
 
130
  </p>
131
  <p>
132
- <?php _e( 'WP eCommerce provides you the ability to move your theme files to a safe place for theming control.
133
 
134
  If you want to change the look of your site, select the files you want to edit from the list and click the move button. This will copy the template files to your active WordPress theme. ','wpsc' ); ?>
135
  </p>
@@ -460,7 +460,7 @@ class WPSC_Settings_Tab_Presentation extends WPSC_Settings_Tab {
460
  <?php
461
  if ( ! function_exists( 'product_display_grid' ) ) {
462
  ?>
463
- <a href='http://wpecommerce.org/store/premium-plugins/'><?php esc_html_e( 'Purchase unavailable options', 'wpsc' ); ?></a>
464
  <?php
465
  }
466
  ?>
@@ -470,7 +470,7 @@ class WPSC_Settings_Tab_Presentation extends WPSC_Settings_Tab {
470
  <tr id="wpsc-grid-settings">
471
  <th scope="row"><?php esc_html_e( 'Grid view settings:', 'wpsc' ) ?></th>
472
  <td>
473
- <input type='number' min="0" name='wpsc_options[grid_number_per_row]' id='grid_number_per_row' size='2' value='<?php esc_attr_e( get_option( 'grid_number_per_row' ) ); ?>' class='small-text' />
474
  <label for='grid_number_per_row'><?php esc_html_e( 'Products Per Row', 'wpsc' ); ?></label><br />
475
 
476
  <input type='hidden' value='0' name='wpsc_options[show_images_only]' />
129
 
130
  </p>
131
  <p>
132
+ <?php _e( 'WP e-Commerce provides you the ability to move your theme files to a safe place for theming control.
133
 
134
  If you want to change the look of your site, select the files you want to edit from the list and click the move button. This will copy the template files to your active WordPress theme. ','wpsc' ); ?>
135
  </p>
460
  <?php
461
  if ( ! function_exists( 'product_display_grid' ) ) {
462
  ?>
463
+ <a href='http://getshopped.org/extend/premium-upgrades'><?php esc_html_e( 'Purchase unavailable options', 'wpsc' ); ?></a>
464
  <?php
465
  }
466
  ?>
470
  <tr id="wpsc-grid-settings">
471
  <th scope="row"><?php esc_html_e( 'Grid view settings:', 'wpsc' ) ?></th>
472
  <td>
473
+ <input type='number' name='wpsc_options[grid_number_per_row]' id='grid_number_per_row' size='2' value='<?php esc_attr_e( get_option( 'grid_number_per_row' ) ); ?>' />
474
  <label for='grid_number_per_row'><?php esc_html_e( 'Products Per Row', 'wpsc' ); ?></label><br />
475
 
476
  <input type='hidden' value='0' name='wpsc_options[show_images_only]' />
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
@@ -203,14 +199,14 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
203
  <th><?php esc_html_e( 'Force Sync with Shipwire', 'wpsc' ); ?></th>
204
  <td>
205
  <a class="shipwire_sync button"><?php esc_html_e( 'Update Tracking and Inventory', 'wpsc' ); ?></a>
206
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
207
  </td>
208
  </tr>
209
  </table>
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/' ); ?>
@@ -331,7 +327,7 @@ class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
331
  <div class="row-actions-visible">
332
  <span class="edit">
333
  <a class='edit-shipping-module' data-module-id="<?php echo $shipping->getInternalName(); ?>" title="<?php esc_attr_e( 'Edit this Shipping Module', 'wpsc' ); ?>" href='<?php echo esc_url( $this->get_shipping_module_url( $shipping ) ); ?>'><?php _ex( 'Settings', 'Shipping modules link to individual settings', 'wpsc' ); ?>
334
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
335
  </span>
336
  </div>
337
  </td>
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
199
  <th><?php esc_html_e( 'Force Sync with Shipwire', 'wpsc' ); ?></th>
200
  <td>
201
  <a class="shipwire_sync button"><?php esc_html_e( 'Update Tracking and Inventory', 'wpsc' ); ?></a>
202
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
203
  </td>
204
  </tr>
205
  </table>
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/' ); ?>
327
  <div class="row-actions-visible">
328
  <span class="edit">
329
  <a class='edit-shipping-module' data-module-id="<?php echo $shipping->getInternalName(); ?>" title="<?php esc_attr_e( 'Edit this Shipping Module', 'wpsc' ); ?>" href='<?php echo esc_url( $this->get_shipping_module_url( $shipping ) ); ?>'><?php _ex( 'Settings', 'Shipping modules link to individual settings', 'wpsc' ); ?>
330
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
331
  </span>
332
  </div>
333
  </td>
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,11 +1,7 @@
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] ) )
11
  $date[0] = 0;
@@ -33,7 +29,7 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
33
 
34
  function wpsc_delete_file() {
35
  $product_id = absint( $_REQUEST['product_id'] );
36
- $file_name = basename( $_REQUEST['file_name'] );
37
  check_admin_referer( 'delete_file_' . $file_name );
38
 
39
  _wpsc_delete_file( $product_id, $file_name );
@@ -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,9 +76,9 @@ 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();
91
  } else {
92
  wp_die( __( 'Sorry, for some reason, we couldn\'t duplicate this product because it could not be found in the database, check there for this ID: ', 'wpsc' ) . $id );
@@ -97,19 +89,13 @@ 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'];
113
  $start_end_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '%d' AND '%d' ORDER BY `date` DESC";
114
  $start_end_sql = apply_filters( 'wpsc_purchase_log_start_end_csv', $start_end_sql );
115
  $data = $wpdb->get_results( $wpdb->prepare( $start_end_sql, $start_timestamp, $end_timestamp ), ARRAY_A );
@@ -138,42 +124,39 @@ function wpsc_purchase_log_csv() {
138
 
139
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `type` != 'heading' ORDER BY `checkout_order` DESC;";
140
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
 
141
 
142
  $headers_array = array(
143
- _x( 'Purchase ID' , 'purchase log csv headers', 'wpsc' ),
144
  _x( 'Purchase Total', 'purchase log csv headers', 'wpsc' ),
145
  );
146
  $headers2_array = array(
147
  _x( 'Payment Gateway', 'purchase log csv headers', 'wpsc' ),
148
- _x( 'Payment Status' , 'purchase log csv headers', 'wpsc' ),
149
- _x( 'Purchase Date' , 'purchase log csv headers', 'wpsc' ),
150
  );
151
  $form_headers_array = array();
 
152
 
153
  $output = '';
154
 
155
- foreach ( (array) $form_data as $form_field ) {
156
  if ( empty ( $form_field['unique_name'] ) ) {
157
  $form_headers_array[] = $form_field['name'];
158
  } else {
159
- $prefix = false === strstr( $form_field['unique_name'], 'billing' ) ? _x( 'Shipping ', 'purchase log csv header field prefix', 'wpsc' ) : _x( 'Billing ', 'purchase log csv header field prefix', 'wpsc' );
160
- $form_headers_array[] = $prefix . $form_field['name'];
161
  }
162
  }
163
 
164
- foreach ( (array) $data as $purchase ) {
165
  $form_headers = '';
166
  $output .= "\"" . $purchase['id'] . "\","; //Purchase ID
167
  $output .= "\"" . $purchase['totalprice'] . "\","; //Purchase Total
168
- foreach ( (array) $form_data as $form_field ) {
169
  $collected_data_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
170
  $collected_data = $wpdb->get_results( $collected_data_sql, ARRAY_A );
171
  $collected_data = $collected_data[0];
172
-
173
- if ( ( 'billingstate' == $form_field['unique_name'] || 'shippingstate' == $form_field['unique_name'] ) && is_numeric( $collected_data['value'] ) )
174
- $output .= "\"" . wpsc_get_state_by_id( $collected_data['value'], 'code' ) . "\","; // get form fields
175
- else
176
- $output .= "\"" . str_replace( array( "\r", "\r\n", "\n" ), ' ', $collected_data['value'] ) . "\","; // get form fields
177
  }
178
 
179
  if ( isset( $wpsc_gateways[$purchase['gateway']] ) && isset( $wpsc_gateways[$purchase['gateway']]['display_name'] ) )
@@ -190,30 +173,17 @@ function wpsc_purchase_log_csv() {
190
  $cartsql = "SELECT `prodid`, `quantity`, `name` FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
191
  $cart = $wpdb->get_results( $cartsql, ARRAY_A );
192
 
193
- if ( $count < count( $cart ) )
194
  $count = count( $cart );
195
-
196
- $items = count( $cart );
197
- $i = 1;
198
-
199
  // Go through all products in cart and display quantity and sku
200
- foreach ( (array) $cart as $item ) {
201
  $skuvalue = get_product_meta( $item['prodid'], 'sku', true );
202
  if( empty( $skuvalue ) )
203
  $skuvalue = __( 'N/A', 'wpsc' );
204
  $output .= "\"" . $item['quantity'] . "\",";
205
- $output .= "\"" . str_replace( '"', '\"', $item['name'] ) . "\",";
206
-
207
- if ( $items <= 1 )
208
- $output .= "\"" . $skuvalue . "\"" ;
209
- elseif ( $items > 1 && $i != $items )
210
- $output .= "\"" . $skuvalue . "\"," ;
211
- else
212
- $output .= "\"" . $skuvalue . "\"" ;
213
-
214
- $i++;
215
  }
216
-
217
  $output .= "\n"; // terminates the row/line in the CSV file
218
  }
219
  // Get the most number of products and create a header for them
@@ -230,10 +200,8 @@ function wpsc_purchase_log_csv() {
230
  $headers3 = '"' . implode( '","', $headers3 ) . '"';
231
 
232
  $headers = apply_filters( 'wpsc_purchase_log_csv_headers', $headers . $form_headers . $headers2 . $headers3, $data, $form_data );
233
- $output = apply_filters( 'wpsc_purchase_log_csv_output' , $output, $data, $form_data );
234
-
235
  do_action( 'wpsc_purchase_log_csv' );
236
-
237
  header( 'Content-Type: text/csv' );
238
  header( 'Content-Disposition: inline; filename="' . $csv_name . '"' );
239
  echo $headers . "\n". $output;
@@ -249,11 +217,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 +227,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 +251,89 @@ 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 +343,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 +361,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 +369,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 +462,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,16 +496,13 @@ 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();
657
  wpsc_register_post_types();
658
 
659
- if ( ! $auto ) {
660
  $sendback = wp_get_referer();
661
  if ( isset( $updated ) )
662
  $sendback = add_query_arg( 'updated', $updated, $sendback );
@@ -664,7 +510,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 +519,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 +550,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 +567,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 +598,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 +630,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,19 +673,27 @@ function wpsc_delete_variation_set() {
811
  'variation_id'
812
  ), $sendback );
813
 
814
- wp_redirect( $sendback );
815
  exit();
816
  }
817
 
818
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-variation-set' == $_REQUEST['wpsc_admin_action'] ) )
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 +721,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 = $_POST['add_start'];
5
  $date = preg_split( '/-/', $lastdate );
6
  if ( !isset( $date[0] ) )
7
  $date[0] = 0;
29
 
30
  function wpsc_delete_file() {
31
  $product_id = absint( $_REQUEST['product_id'] );
32
+ $file_name = basename( $_REQUEST['file_name'] );
33
  check_admin_referer( 'delete_file_' . $file_name );
34
 
35
  _wpsc_delete_file( $product_id, $file_name );
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 = add_query_arg( 'duplicated', (int)$duplicated, $sendback );
80
 
81
+ wp_redirect( esc_url( $sendback ) );
82
  exit();
83
  } else {
84
  wp_die( __( 'Sorry, for some reason, we couldn\'t duplicate this product because it could not be found in the database, check there for this ID: ', 'wpsc' ) . $id );
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'];
99
  $start_end_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '%d' AND '%d' ORDER BY `date` DESC";
100
  $start_end_sql = apply_filters( 'wpsc_purchase_log_start_end_csv', $start_end_sql );
101
  $data = $wpdb->get_results( $wpdb->prepare( $start_end_sql, $start_timestamp, $end_timestamp ), ARRAY_A );
124
 
125
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `type` != 'heading' ORDER BY `checkout_order` DESC;";
126
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
127
+ $csv = 'Purchase ID, Price, Firstname, Lastname, Email, Order Status, Data, ';
128
 
129
  $headers_array = array(
130
+ _x( 'Purchase ID', 'purchase log csv headers', 'wpsc' ),
131
  _x( 'Purchase Total', 'purchase log csv headers', 'wpsc' ),
132
  );
133
  $headers2_array = array(
134
  _x( 'Payment Gateway', 'purchase log csv headers', 'wpsc' ),
135
+ _x( 'Payment Status', 'purchase log csv headers', 'wpsc' ),
136
+ _x( 'Purchase Date', 'purchase log csv headers', 'wpsc' ),
137
  );
138
  $form_headers_array = array();
139
+ $headers3_array = array();
140
 
141
  $output = '';
142
 
143
+ foreach ( (array)$form_data as $form_field ) {
144
  if ( empty ( $form_field['unique_name'] ) ) {
145
  $form_headers_array[] = $form_field['name'];
146
  } else {
147
+ $form_headers_array[] = $form_field['unique_name'];
 
148
  }
149
  }
150
 
151
+ foreach ( (array)$data as $purchase ) {
152
  $form_headers = '';
153
  $output .= "\"" . $purchase['id'] . "\","; //Purchase ID
154
  $output .= "\"" . $purchase['totalprice'] . "\","; //Purchase Total
155
+ foreach ( (array)$form_data as $form_field ) {
156
  $collected_data_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
157
  $collected_data = $wpdb->get_results( $collected_data_sql, ARRAY_A );
158
  $collected_data = $collected_data[0];
159
+ $output .= "\"" . $collected_data['value'] . "\","; // get form fields
 
 
 
 
160
  }
161
 
162
  if ( isset( $wpsc_gateways[$purchase['gateway']] ) && isset( $wpsc_gateways[$purchase['gateway']]['display_name'] ) )
173
  $cartsql = "SELECT `prodid`, `quantity`, `name` FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
174
  $cart = $wpdb->get_results( $cartsql, ARRAY_A );
175
 
176
+ if( $count < count( $cart ) )
177
  $count = count( $cart );
 
 
 
 
178
  // Go through all products in cart and display quantity and sku
179
+ foreach ( (array)$cart as $item ) {
180
  $skuvalue = get_product_meta( $item['prodid'], 'sku', true );
181
  if( empty( $skuvalue ) )
182
  $skuvalue = __( 'N/A', 'wpsc' );
183
  $output .= "\"" . $item['quantity'] . "\",";
184
+ $output .= "\"" . str_replace( '"', '\"', $item['name'] ) . "\"";
185
+ $output .= "," . $skuvalue."," ;
 
 
 
 
 
 
 
 
186
  }
 
187
  $output .= "\n"; // terminates the row/line in the CSV file
188
  }
189
  // Get the most number of products and create a header for them
200
  $headers3 = '"' . implode( '","', $headers3 ) . '"';
201
 
202
  $headers = apply_filters( 'wpsc_purchase_log_csv_headers', $headers . $form_headers . $headers2 . $headers3, $data, $form_data );
203
+ $output = apply_filters( 'wpsc_purchase_log_csv_output', $output, $data, $form_data );
 
204
  do_action( 'wpsc_purchase_log_csv' );
 
205
  header( 'Content-Type: text/csv' );
206
  header( 'Content-Disposition: inline; filename="' . $csv_name . '"' );
207
  echo $headers . "\n". $output;
217
  add_action( 'admin_init', 'wpsc_purchase_log_csv' );
218
 
219
  function wpsc_admin_sale_rss() {
 
 
 
 
 
220
  global $wpdb;
221
  if ( ($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log") ) {
222
  $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!='' ORDER BY `date` DESC";
227
  $output .= "<?xml version='1.0'?>\n\r";
228
  $output .= "<rss version='2.0'>\n\r";
229
  $output .= " <channel>\n\r";
230
+ $output .= " <title>" . _x( 'WP e-Commerce Product Log', 'admin rss product feed', 'wpsc' ) . "</title>\n\r";
231
  $output .= " <link>" . admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "</link>\n\r";
232
+ $output .= " <description>" . _x( 'This is the WP e-Commerce Product Log RSS feed', 'admin rss product feed', 'wpsc' ) . "</description>\n\r";
233
+ $output .= " <generator>" . _x( 'WP e-Commerce Plugin', 'admin rss product feed', 'wpsc' ) . "</generator>\n\r";
234
 
235
  foreach ( (array)$purchase_log as $purchase ) {
236
  $purchase_link = admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "&amp;purchaseid=" . $purchase['id'];
251
  }
252
  }
253
 
254
+ if ( isset( $_GET['action'] ) && ( 'purchase_log' == $_GET['action'] ) )
255
  add_action( 'admin_init', 'wpsc_admin_sale_rss' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
 
257
+ function wpsc_display_invoice() {
258
+ $purchase_id = (int)$_REQUEST['purchaselog_id'];
259
+ add_action('wpsc_packing_slip', 'wpsc_packing_slip');
260
+ do_action('wpsc_before_packing_slip', $purchase_id);
261
+ do_action('wpsc_packing_slip', $purchase_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  exit();
 
263
  }
264
+ //other actions are here
265
+ if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) )
266
+ add_action( 'admin_init', 'wpsc_display_invoice', 0 );
267
 
268
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) )
269
+ add_action( 'admin_init', 'wpsc_display_invoice' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
  /**
272
+ * Purchase log ajax code starts here
 
 
 
273
  */
274
+ function wpsc_purchlog_resend_email() {
 
 
 
 
 
275
  global $wpdb;
276
+ $log_id = $_REQUEST['email_buyer_id'];
277
+ $wpec_taxes_controller = new wpec_taxes_controller();
278
+ if ( is_numeric( $log_id ) ) {
279
+ $purchase_log = new WPSC_Purchase_Log( $log_id );
280
+ $sent = wpsc_send_customer_email( $purchase_log );
 
 
 
 
 
281
  }
282
 
283
+ $sendback = wp_get_referer();
 
 
 
 
 
 
 
 
 
 
 
284
 
285
+ if ( isset( $sent ) )
286
+ $sendback = add_query_arg( 'sent', $sent, $sendback );
287
 
288
+ wp_redirect( esc_url( $sendback ) );
289
+ exit();
290
  }
291
 
 
292
  if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_id'] ) ) {
293
+ add_action( 'admin_init', 'wpsc_purchlog_resend_email' );
294
  }
295
 
296
+ function wpsc_purchlog_clear_download_items() {
 
 
 
 
 
 
 
 
 
 
 
297
  global $wpdb;
298
+ if ( is_numeric( $_GET['purchaselog_id'] ) ) {
299
+ $purchase_id = (int)$_GET['purchaselog_id'];
300
+ $downloadable_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` IN ('$purchase_id')", ARRAY_A );
301
 
302
+ $clear_locks_sql = "UPDATE`" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `ip_number` = '' WHERE `purchid` IN ('$purchase_id')";
303
+ $wpdb->query( $clear_locks_sql );
304
+ $cleared = true;
 
 
 
 
 
 
 
 
 
 
305
 
306
  $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" );
307
+ $email_address = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id`='{$purchase_id}' AND `form_id` = '{$email_form_field}' LIMIT 1" );
308
+
309
+ foreach ( (array)$downloadable_items as $downloadable_item ) {
310
+ $download_links .= esc_url( add_query_arg(
311
+ 'downloadid',
312
+ $downloadable_item['uniqueid'],
313
+ home_url()
314
+ ) ) . "\n";
315
  }
316
 
 
317
 
318
+ 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' ) . "" );
319
 
 
320
 
321
+ $sendback = wp_get_referer();
322
 
323
+ if ( isset( $cleared ) ) {
324
+ $sendback = add_query_arg( 'cleared', $cleared, $sendback );
325
+ }
326
+ wp_redirect( esc_url( $sendback ) );
327
+ exit();
328
+ }
329
  }
330
 
 
331
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks') ) {
332
+ add_action( 'admin_init', 'wpsc_purchlog_clear_download_items' );
333
  }
334
 
335
  //bulk actions for purchase log
336
  function wpsc_purchlog_bulk_modify() {
 
 
 
 
 
337
  if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
338
  if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
339
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
343
  } elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) {
344
  foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
345
 
346
+ wpsc_delete_purchlog( $purchlogid );
347
+ $deleted++;
 
 
 
 
348
  }
349
  }
350
  }
361
  if ( isset( $_POST['view_purchlogs_by_status'] ) ) {
362
  $sendback = add_query_arg( 'view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback );
363
  }
364
+ wp_redirect( esc_url( $sendback ) );
365
  exit();
366
  }
367
 
369
  add_action( 'admin_init', 'wpsc_purchlog_bulk_modify' );
370
  }
371
 
372
+ /* Start Order Notes (by Ben) */
373
+ function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' ) {
374
+ global $wpdb;
375
+ if ( wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
376
+ if ( ($purchlog_id == '') && ($purchlog_notes == '') ) {
 
 
 
 
377
  $purchlog_id = absint( $_POST['purchlog_id'] );
378
  $purchlog_notes = stripslashes( $_POST['purchlog_notes'] );
379
  }
380
+ $wpdb->update(
381
+ WPSC_TABLE_PURCHASE_LOGS,
382
+ array(
383
+ 'notes' => $purchlog_notes
384
+ ),
385
+ array(
386
+ 'id' => $purchlog_id
387
+ ),
388
+ array(
389
+ '%s'
390
+ ),
391
+ array(
392
+ '%d'
393
+ )
394
+ );
395
+ }
396
+ }
397
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) )
398
  add_action( 'admin_init', 'wpsc_purchlogs_update_notes' );
 
399
 
400
+ /* End Order Notes (by Ben) */
 
 
 
 
 
 
 
 
401
 
402
+ //delete a purchase log
403
+ function wpsc_delete_purchlog( $purchlog_id='' ) {
404
  global $wpdb;
405
+ $deleted = 0;
406
 
 
407
  if ( $purchlog_id == '' ) {
408
+ $purchlog_id = absint( $_GET['purchlog_id'] );
409
+ check_admin_referer( 'delete_purchlog_' . $purchlog_id );
410
+ }
411
+
412
+ $purchlog_status = $wpdb->get_var( $wpdb->prepare( "SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= %d", $purchlog_id ) );
413
+ if ( $purchlog_status == 5 || $purchlog_status == 1 ) {
414
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = %d AND `cart_submitted` = '1'", $purchlog_id ) );
415
  }
416
 
417
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchlog_id ) );
418
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` IN (%d)", $purchlog_id ) );
419
+ $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = %d LIMIT 1", $purchlog_id ) );
420
 
421
+ $deleted = 1;
422
 
423
+ if ( is_numeric( $_GET['purchlog_id'] ) ) {
424
+ $sendback = wp_get_referer();
425
+ $sendback = remove_query_arg( array( 'c', 'id' ), $sendback );
426
+ if ( isset( $deleted ) ) {
427
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
428
+ }
429
+ wp_redirect( esc_url( $sendback ) );
430
+ exit();
431
+ }
432
  }
433
 
434
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) {
435
+ add_action( 'admin_init', 'wpsc_delete_purchlog' );
 
436
  }
437
 
438
  function wpsc_update_option_product_category_hierarchical_url() {
462
  function _wpsc_action_update_option_require_register( $old_value, $new_value ) {
463
  if ( $new_value == 1 && ! get_option( 'users_can_register' ) ) {
464
  update_option( 'users_can_register', 1 );
465
+ $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' );
466
  $message = sprintf( $message, admin_url( 'options-general.php' ) );
467
  add_settings_error( 'require_register', 'users_can_register_turned_on', $message, 'updated' );
468
  }
496
  * @return nothing
497
  */
498
  function wpsc_update_page_urls( $auto = false ) {
499
+ global $wpdb;
 
 
 
500
 
501
  wpsc_update_permalink_slugs();
502
  wpsc_core_load_page_titles();
503
  wpsc_register_post_types();
504
 
505
+ if( ! $auto ){
506
  $sendback = wp_get_referer();
507
  if ( isset( $updated ) )
508
  $sendback = add_query_arg( 'updated', $updated, $sendback );
510
  if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
511
  $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
512
 
513
+ wp_redirect( esc_url( $sendback ) );
514
  exit();
515
  }
516
  }
519
 
520
  //change the regions tax settings
521
  function wpsc_change_region_tax() {
 
 
 
 
 
522
  global $wpdb;
523
  if ( is_array( $_POST['region_tax'] ) ) {
524
  foreach ( $_POST['region_tax'] as $region_id => $tax ) {
550
  function wpsc_product_files_existing() {
551
  //List all product_files, with checkboxes
552
 
 
 
 
 
553
  $product_id = absint( $_GET["product_id"] );
554
  $file_list = wpsc_uploaded_files();
555
 
567
 
568
  $output = "<span class='admin_product_notes select_product_note '>" . esc_html__( 'Choose a downloadable file for this product:', 'wpsc' ) . "</span><br>";
569
  $output .= "<form method='post' class='product_upload'>";
570
+ $output .= "<div class='ui-widget-content multiple-select select_product_file'>";
571
  $num = 0;
572
  foreach ( (array)$file_list as $file ) {
573
  $num++;
598
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing') )
599
  add_action( 'admin_init', 'wpsc_product_files_existing' );
600
 
601
+ function wpsc_google_shipping_settings() {
602
+ if ( isset( $_POST['submit'] ) ) {
603
+ foreach ( (array)$_POST['google_shipping'] as $key => $country ) {
604
+ if ( $country == 'on' ) {
605
+ $google_shipping_country[] = $key;
606
+ $updated++;
607
+ }
608
+ }
609
+ update_option( 'google_shipping_country', $google_shipping_country );
610
+ $sendback = wp_get_referer();
611
+ $sendback = remove_query_arg( 'googlecheckoutshipping', $sendback );
612
+
613
+ if ( isset( $updated ) ) {
614
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
615
+ }
616
+
617
+ wp_redirect( esc_url( $sendback ) );
618
+ exit();
619
+ }
620
+ }
621
+
622
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) {
623
+ add_action( 'admin_init', 'wpsc_google_shipping_settings' );
624
+ }
625
+
626
  function wpsc_update_variations() {
627
  $product_id = absint( $_POST["product_id"] );
628
  $product_type_object = get_post_type_object('wpsc-product');
630
  return;
631
 
632
  //Setup postdata
633
+ $post_data = array( );
634
  $post_data['edit_var_val'] = isset( $_POST['edit_var_val'] ) ? $_POST["edit_var_val"] : '';
635
 
636
  //Add or delete variations
673
  'variation_id'
674
  ), $sendback );
675
 
676
+ wp_redirect( esc_url( $sendback ) );
677
  exit();
678
  }
679
 
680
  if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-variation-set' == $_REQUEST['wpsc_admin_action'] ) )
681
  add_action( 'admin_init', 'wpsc_delete_variation_set' );
682
 
683
+ function wpsc_force_flush_theme_transients() {
684
+ // Flush transients
685
+ wpsc_flush_theme_transients( true );
686
 
687
+ // Bounce back
688
+ $sendback = wp_get_referer();
689
+ wp_redirect( $sendback );
690
 
691
+ exit();
692
+ }
693
+ if ( isset( $_REQUEST['wpsc_flush_theme_transients'] ) && ( $_REQUEST['wpsc_flush_theme_transients'] == 'true' ) )
694
+ add_action( 'admin_init', 'wpsc_force_flush_theme_transients' );
695
+
696
+ function wpsc_backup_theme() {
697
  $wp_theme_path = get_stylesheet_directory();
698
  wpsc_recursive_copy( $wp_theme_path, WPSC_THEME_BACKUP_DIR );
699
  $_SESSION['wpsc_themes_backup'] = true;
721
  $sendback = add_query_arg( 'deleted', $deleted, $sendback );
722
 
723
  $sendback = remove_query_arg( array( 'deleteid', 'wpsc_admin_action' ), $sendback );
724
+ wp_redirect( esc_url( $sendback ) );
725
  exit();
726
  }
727
 
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),
@@ -157,28 +155,14 @@
157
  return false;
158
  });
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-', '' ),
@@ -387,6 +346,7 @@ jQuery(document).ready(function($){
387
  prototype.prepend(operator_box);
388
  }
389
 
 
390
  prototype.find('select').val('');
391
  prototype.find('input').val('');
392
  prototype.css( { 'opacity' : '0' } );
@@ -394,7 +354,6 @@ jQuery(document).ready(function($){
394
 
395
  margin = jQuery( 'select.ruleprops', prototype ).offset().left - prototype.offset().left;
396
  margin = parseInt( margin, 10 ) - 1;
397
- prototype.find('input').focus();
398
 
399
  prototype.animate( { opacity: 1, 'margin-left': '-' + margin + 'px', height: 'show' }, 150 );
400
 
@@ -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
+ $.post(ajaxurl, data, handler, 'json');
14
  };
15
 
16
  /**
24
  data['wpsc_action'] = data['action'];
25
  data['action'] = 'wpsc_ajax';
26
 
27
+ $.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),
155
  return false;
156
  });
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-', '' ),
346
  prototype.prepend(operator_box);
347
  }
348
 
349
+
350
  prototype.find('select').val('');
351
  prototype.find('input').val('');
352
  prototype.css( { 'opacity' : '0' } );
354
 
355
  margin = jQuery( 'select.ruleprops', prototype ).offset().left - prototype.offset().left;
356
  margin = parseInt( margin, 10 ) - 1;
 
357
 
358
  prototype.animate( { opacity: 1, 'margin-left': '-' + margin + 'px', height: 'show' }, 150 );
359
 
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 DELETED
@@ -1,401 +0,0 @@
1
- /*global _, WPSC_Media, Backbone, alert, WPSC, wp, wpsc_refresh_variation_iframe, wpsc_set_variation_product_thumbnail, jQuery, WPRemoveThumbnail */
2
- (function($) {
3
- "use strict";
4
- window.WPSC = window.WPSC || {};
5
-
6
- /**
7
- * Inspired by Cocktail (https://github.com/onsi/cocktail/) but with some
8
- * important modifications.
9
- *
10
- * Mixing an object into a class' prototype will make sure that object is
11
- * extended from previous Mixins / oroginal prototype.
12
- *
13
- * Primitive values can also be mixed in.
14
- *
15
- * @param {Object} object The original object
16
- * @param {...Object} mixins Mixins
17
- */
18
- window.WPSC.mixin = function( clss ) {
19
- var modules = _.rest( arguments );
20
- var chain = {};
21
-
22
- _.each( modules, function( module ) {
23
- var override = module._mixin_override || [];
24
- module = _.omit( module, [ '_mixin_override'] );
25
-
26
- _.each( module, function( value, key ) {
27
- if ( _.contains( override, key ) ) {
28
- chain[key] = [value];
29
- return;
30
- }
31
-
32
- if ( _.isFunction( value ) ) {
33
- if ( clss.prototype[key] )
34
- chain[key] = [clss.prototype[key]];
35
-
36
- chain[key].push( value );
37
- } else if ( _.isObject( value ) ) {
38
- chain[key] = chain[key] || [{}];
39
- if ( clss.prototype[key] )
40
- chain[key] = [clss.prototype[key]];
41
-
42
- chain[key].push( _.extend( {}, chain[key][0], value ) );
43
- } else {
44
- chain[key] = chain[key] || [];
45
- chain[key].push( value );
46
- }
47
- } );
48
- } );
49
-
50
- _.each( chain, function( values, key ) {
51
- var last = _.last( values );
52
-
53
- if ( ! _.isFunction( last ) ) {
54
- clss.prototype[key] = last;
55
- return;
56
- }
57
-
58
- clss.prototype[key] = function() {
59
- var ret, args = arguments, that = this;
60
- _.each( values, function( fn ) {
61
- var fnRet = fn.apply( that, args );
62
- ret =
63
- _.isUndefined( fnRet ) ?
64
- ret :
65
- fnRet;
66
- });
67
-
68
- return ret;
69
- };
70
- } );
71
- };
72
-
73
- var media = window.wp.media;
74
-
75
- var backup = _.clone( media.view.settings.post );
76
-
77
- media.controller.wpsc = {
78
- ProductGallery: media.controller.Library.extend({
79
- defaults: _.defaults({
80
- id : 'wpsc-product-gallery',
81
- filterable : 'uploaded',
82
- multiple : 'add',
83
- toolbar : 'wpsc-save-gallery',
84
- title : WPSC_Media.l10n.productMediaTitle,
85
- priority : 50,
86
- library : media.query( { type: 'image' } ),
87
- syncSelection: false
88
- }, media.controller.Library.prototype.defaults ),
89
-
90
- initialize: function( options ) {
91
- options = options || {};
92
- var selection = new media.model.wpsc.ProductGallerySelection(
93
- [],
94
- {
95
- postId: media.model.settings.post.id,
96
- multiple: this.get( 'multiple' ),
97
- updateNonce: options.updateNonce || WPSC_Media.updateGalleryNonce,
98
- getNonce: options.getNonce || WPSC_Media.getGalleryNonce
99
- }
100
- );
101
- this.set(
102
- 'selection',
103
- selection
104
- );
105
-
106
- var models = options.models || WPSC_Media.gallery;
107
-
108
- // work around for backbone.js 0.9.2
109
- if ( _.isUndefined( Backbone.Collection.prototype.set ) ) {
110
- // force parse the response
111
- models = selection.parse( models );
112
- selection.reset( models );
113
- } else {
114
- selection.set( models, { parse: true } );
115
- }
116
-
117
- media.controller.Library.prototype.initialize.apply( this, arguments );
118
-
119
- this.on( 'select', function() {
120
- selection.save_gallery();
121
- } );
122
-
123
- this.on( 'reset', function() {
124
- selection.get_gallery();
125
- }) ;
126
-
127
- this.get( 'library' ).observe( selection );
128
- }
129
- })
130
- };
131
-
132
- media.model.wpsc = {
133
- ProductGallerySelection: media.model.Selection.extend( {
134
- initialize: function( models, options ) {
135
- media.model.Selection.prototype.initialize.apply( this, [models, options] );
136
- this.postId = options && options.postId;
137
- this.updateNonce = options.updateNonce || WPSC_Media.updateGalleryNonce;
138
- this.getNonce = options.getNonce || WPSC_Media.getGalleryNonce;
139
- },
140
-
141
- save_gallery: function( options ) {
142
- options = _.extend( options || {}, {
143
- data: {
144
- items: this.pluck( 'id' )
145
- },
146
- success: function( resp, status, xhr ) {
147
- // in case of backbone 0.9.2
148
- if ( _.isUndefined( this.set ) ) {
149
- // force parse the response
150
- resp.obj = this.parse( resp.obj, xhr );
151
- this.reset( resp.obj );
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" ) );
160
- }
161
- } );
162
- this.sync( 'update', this, options );
163
- },
164
-
165
- get_gallery: function( options ) {
166
- options = _.extend( options || {}, {
167
- success: function( resp, status, xhr ) {
168
- // in case of backbone 0.9.2
169
- if ( _.isUndefined( this.set ) ) {
170
- // force parse the response
171
- resp.obj = this.parse( resp.obj, xhr );
172
- this.reset( resp.obj );
173
- } else {
174
- this.set( resp.obj, { parse: true } );
175
- }
176
- wpsc_refresh_variation_iframe();
177
- },
178
- error: function( resp ) {
179
- alert( resp.error.messages.join( "\n" ) );
180
- }
181
- } );
182
- this.sync( 'read', this, options );
183
- },
184
-
185
- sync: function( method, collection, options ) {
186
-
187
- var data;
188
- options = options ? _.clone( options ) : {};
189
-
190
- options.success = _.bind( options.success, this );
191
- options.error = _.bind( options.error, this );
192
-
193
- switch (method) {
194
- case 'read':
195
- options.data = options.data || {};
196
- data = _.defaults( {
197
- action: 'get_product_gallery',
198
- nonce : this.getNonce,
199
- postId: this.postId
200
- }, options.data );
201
- break;
202
-
203
- case 'update':
204
- options.data = options.data || {};
205
- data = _.defaults( {
206
- action: 'save_product_gallery',
207
- nonce : this.updateNonce,
208
- items : this.pluck( 'id' ),
209
- postId: this.postId
210
- }, options.data );
211
-
212
- break;
213
-
214
- case 'create':
215
- case 'delete':
216
- // do nothing for now
217
- break;
218
- }
219
-
220
- $.wpsc_post( data ).done( function( resp, status, xhr ) {
221
- if ( resp.is_successful ) {
222
- options.success( resp, status, xhr );
223
- } else {
224
- options.error( resp, status, xhr );
225
- }
226
- } );
227
- }
228
- } )
229
- };
230
-
231
- media.view.wpsc = {
232
- };
233
-
234
- /**
235
- * Extend the MediaFrame.Post class so that we can inject a custom tab
236
- * dynamically using JavaScript.
237
- */
238
- WPSC.mixin(
239
- media.view.MediaFrame.Post,
240
- {
241
- wpsc: {
242
- saveGalleryStatusBar: function( view ) {
243
- this.selectionStatusToolbar(view);
244
- },
245
- saveGalleryToolbar: function( toolbar ) {
246
- this.createSelectToolbar( toolbar, {
247
- text : WPSC_Media.l10n.saveGallery,
248
- state: this.options.state,
249
- reset: false
250
- } );
251
- },
252
- createStates: function() {
253
- this.states.add( new media.controller.wpsc.ProductGallery( { models: this.options.models, updateNonce: this.options.updateNonce, getNonce: this.options.getNonce } ) );
254
- },
255
- bindHandlers: function() {
256
- this.on( 'toolbar:create:wpsc-save-gallery', this.wpsc.saveGalleryToolbar, this );
257
- this.on( 'toolbar:render:wpsc-save-gallery', this.wpsc.saveGalleryStatusBar, this );
258
- }
259
- },
260
-
261
- initialize: function() {
262
- if ( ! this.options.models )
263
- this.options.models = WPSC_Media.gallery;
264
-
265
- if ( ! this.options.updateNonce )
266
- this.options.updateNonce = WPSC_Media.updateGalleryNonce;
267
-
268
- if ( ! this.options.getNonce )
269
- this.options.getNonce = WPSC_Media.getGalleryNonce;
270
-
271
- this.wpsc.createStates.apply( this );
272
- this.wpsc.bindHandlers.apply( this );
273
- }
274
- }
275
- );
276
-
277
- /**
278
- * Extend media.view.Attachment
279
- */
280
- WPSC.mixin(
281
- media.view.Attachment,
282
- {
283
- render: function() {
284
- if ( this.controller.state().id != 'wpsc-product-gallery' )
285
- return;
286
-
287
- if ( this.model.id != media.view.settings.post.featuredImageId )
288
- return;
289
-
290
- this.$el.find( '.thumbnail' ).append('<span class="wpsc-featured-label">featured</span>');
291
- }
292
- }
293
- );
294
-
295
- WPSC_Media.open = function( options ) {
296
- var workflow;
297
-
298
- media.view.settings.post.id = options.id;
299
- media.view.settings.post.featuredImageId = options.featuredId;
300
- media.view.settings.post.nonce = options.featuredNonce;
301
- media.model.settings.post = media.view.settings.post;
302
- media.editor.remove( 'wpsc-variation-media' );
303
- media.editor.add( 'wpsc-variation-media', {
304
- models: options.models,
305
- updateNonce: options.galleryUpdateNonce,
306
- getNonce: options.galleryGetNonce
307
- });
308
- workflow = media.editor.open( 'wpsc-variation-media' );
309
- };
310
-
311
- var oldEditorOpen = media.editor.open;
312
- media.editor.open = function( id ) {
313
- if ( id == 'content' ) {
314
- if ( media.view.settings.post.id == backup.id ) {
315
- // always make sure the backup copy is up to date
316
- backup = _.clone( media.view.settings.post );
317
- } else {
318
- // if the frame was opened for a variation previously, this time
319
- // restore the globals from the backup
320
- media.view.settings.post = _.clone( backup );
321
- media.model.settings.post = media.view.settings.post;
322
- }
323
- }
324
- return oldEditorOpen.apply( this, arguments );
325
- };
326
-
327
- // hack the set featured image function
328
- wp.media.featuredImage.set = function( id ) {
329
- var settings = wp.media.view.settings;
330
- var currentId = settings.post.id;
331
-
332
- settings.post.featuredImageId = id;
333
-
334
- wp.media.post( 'set-post-thumbnail', {
335
- json: true,
336
- post_id: settings.post.id,
337
- thumbnail_id: settings.post.featuredImageId,
338
- _wpnonce: settings.post.nonce
339
- }).done( function( html ) {
340
- if ( currentId == backup.id ) {
341
- wpsc_refresh_variation_iframe();
342
- $( '.inside', '#postimagediv' ).html( html );
343
- } else {
344
- wpsc_set_variation_product_thumbnail( currentId, $( html ).find( 'img' ).attr( 'src' ), id );
345
- }
346
- });
347
- };
348
-
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' ) {
356
- alert( setPostThumbnailL10n.error );
357
- } else {
358
- WPSetThumbnailHTML(str);
359
- wpsc_refresh_variation_iframe();
360
- }
361
- }
362
- );
363
- };
364
-
365
-
366
- $(function() {
367
- $('#wpsc-manage-product-gallery').on('click', function( e ) {
368
- var frame;
369
-
370
- e.preventDefault();
371
- e.stopPropagation();
372
-
373
- frame = wp.media({
374
- state: 'wpsc-product-gallery',
375
- states: [ new wp.media.controller.wpsc.ProductGallery() ]
376
- });
377
-
378
- frame.on( 'toolbar:create:wpsc-save-gallery', function(toolbar) {
379
- this.createSelectToolbar( toolbar, {
380
- text : WPSC_Media.l10n.saveGallery,
381
- state: this.options.state
382
- } );
383
- }, frame );
384
- frame.on( 'toolbar:render:wpsc-save-gallery', function( view ) {
385
- view.set( 'selection', new media.view.Selection({
386
- controller: this,
387
- collection: this.state().get( 'selection' ),
388
- priority: -40,
389
- editable: this.state().get('editable')
390
- }).render());
391
- }, frame );
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));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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();
@@ -55,31 +53,8 @@
55
  };
56
 
57
  var event_variation_thumbnail_click = function() {
58
- var t = $( this ), postId = t.data( 'id' ), nonce = t.data( 'nonce' );
59
-
60
- $.wpsc_post(
61
- {
62
- action: 'get_variation_gallery',
63
- nonce: nonce,
64
- id: postId
65
- },
66
- function( response ) {
67
- if ( ! response.is_successful ) {
68
- alert( response.error.messages.join( "\n" ) );
69
- return;
70
- }
71
-
72
- window.parent.WPSC_Media.open({
73
- id: postId,
74
- featuredId: response.obj.featuredId,
75
- models: response.obj.models,
76
- galleryUpdateNonce: t.data( 'save-gallery-nonce' ),
77
- galleryGetNonce: t.data( 'get-gallery-nonce' ),
78
- featuredNonce: t.data( 'featured-nonce' )
79
- });
80
- }
81
- );
82
-
83
  return false;
84
  };
85
 
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();
53
  };
54
 
55
  var event_variation_thumbnail_click = function() {
56
+ var t = $(this);
57
+ window.parent.wpsc_display_thickbox(t.data('title'), t.attr('href'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  return false;
59
  };
60
 
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
@@ -46,25 +46,13 @@ var wpsc_display_thickbox = function(title, url) {
46
  tb_show(WPSC_Variations.thickbox_title.replace('%s', title), url);
47
  };
48
 
49
- var wpsc_set_variation_product_thumbnail = function(id, src, thumbId) {
50
  var iframe = jQuery('#wpsc_product_variation_forms iframe');
51
- var el = iframe.contents().find('#wpsc-variation-thumbnail-' + id);
52
- el.attr('src', src);
53
- el.parent().data( 'image-id', thumbId );
54
- };
55
-
56
- var wpsc_refresh_variation_iframe = function() {
57
- jQuery('#wpsc_product_variation_forms iframe')[0].contentWindow.location.reload();
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 +81,6 @@ var wpsc_refresh_variation_iframe = function() {
93
  sort_order: order,
94
  parent_id: 0
95
  };
96
- jQuery.post( ajaxurl, data );
97
  };
98
  })(jQuery);
46
  tb_show(WPSC_Variations.thickbox_title.replace('%s', title), url);
47
  };
48
 
49
+ var wpsc_set_variation_product_thumbnail = function(id, src) {
50
  var iframe = jQuery('#wpsc_product_variation_forms iframe');
51
+ iframe.contents().find('#wpsc-variation-thumbnail-' + id).attr('src', src);
 
 
 
 
 
 
52
  };
53
 
54
  (function($) {
 
55
  $(function(){
 
 
 
 
 
56
  var table = $('body.edit-tags-php .wp-list-table');
57
  table.find('tbody tr').each(function(){
58
  var t = $(this);
81
  sort_order: order,
82
  parent_id: 0
83
  };
84
+ jQuery.post(ajaxurl, data);
85
  };
86
  })(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 DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
-
3
- add_action( 'admin_enqueue_scripts', '_wpsc_action_enqueue_media_scripts' );
4
- add_action( 'admin_enqueue_scripts', '_wpsc_action_enqueue_media_styles' );
5
- add_action( 'admin_footer', '_wpsc_action_print_media_templates' );
6
-
7
- function _wpsc_action_enqueue_media_scripts() {
8
- $current_screen = get_current_screen();
9
-
10
- if ( in_array( $current_screen->id, array( 'wpsc-product-variations-iframe', 'wpsc-product' ) ) ) {
11
- $post = get_post();
12
- if ( ! $post )
13
- $id = absint( $_REQUEST['product_id'] );
14
- else
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' ),
22
- 'saveGallery' => __( 'Set Product Images', 'wpsc' ),
23
- ),
24
- 'gallery' => $gallery,
25
- 'updateGalleryNonce' => wp_create_nonce( 'wpsc_ajax_update_gallery_' . $id ),
26
- 'getGalleryNonce' => wp_create_nonce( 'wpsc_ajax_get_gallery_' . $id )
27
- ) );
28
- }
29
- }
30
-
31
- function _wpsc_action_enqueue_media_styles() {
32
- $current_screen = get_current_screen();
33
-
34
- if ( 'wpsc-product' == $current_screen->id )
35
- wp_enqueue_style( 'wpsc-media', WPSC_URL . '/wpsc-admin/css/media.css', array( 'media-views' ), WPSC_VERSION );
36
- }
37
-
38
- function _wpsc_action_print_media_templates() {
39
- ?>
40
- <script type="text/html" id="tmpl-wpsc-featured-image">
41
- <div class="wpsc-media-featured-image">
42
- <span class="title"><?php _e( 'Featured image', 'wpsc' ); ?></span>
43
- <a class="edit-selection" href="#"><?php _ex( 'Edit', 'edit featured image', 'wpsc' ); ?></a>
44
- </div>
45
- <div class="wpsc-selection-view"></div>
46
- </script>
47
- <?php
48
- }
49
-
50
- function _wpsc_ajax_verify_get_variation_gallery() {
51
- return _wpsc_ajax_verify_nonce( 'get_variation_gallery_' . absint( $_REQUEST['id'] ) );
52
- }
53
-
54
- function _wpsc_ajax_get_variation_gallery() {
55
- $id = absint( $_REQUEST['id'] );
56
-
57
- $gallery = _wpsc_get_product_gallery_json( $id );
58
-
59
- return array(
60
- 'models' => $gallery,
61
- 'featuredId' => wpsc_the_product_thumbnail_id( $id )
62
- );
63
- }
64
-
65
- function _wpsc_ajax_verify_save_product_gallery() {
66
- return _wpsc_ajax_verify_nonce( 'update_gallery_' . absint( $_REQUEST['postId'] ) );
67
- }
68
-
69
- function _wpsc_ajax_verify_get_product_gallery() {
70
- return _wpsc_ajax_verify_nonce( 'get_gallery_' . absint( $_REQUEST['postId'] ) );
71
- }
72
-
73
- function _wpsc_ajax_save_product_gallery() {
74
- $id = absint( $_REQUEST['postId'] );
75
- $items = array_map( 'absint', $_REQUEST['items'] );
76
- $thumb = get_post_thumbnail_id( $id );
77
-
78
- // always make sure the thumbnail is included
79
- if ( $thumb && ! in_array( $thumb, $items ) )
80
- $items[] = $thumb;
81
-
82
- $result = wpsc_set_product_gallery( $id, $items );
83
-
84
- return _wpsc_get_product_gallery_json( $id );
85
- }
86
-
87
- function _wpsc_ajax_get_product_gallery() {
88
- $id = absint( $_REQUEST['postId'] );
89
- return _wpsc_get_product_gallery_json( $id );
90
- }
91
-
92
- function _wpsc_get_product_gallery_json( $id ) {
93
- $attachments = wpsc_get_product_gallery( $id );
94
- return array_map( 'wp_prepare_attachment_for_js', $attachments );
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  *
@@ -203,6 +203,7 @@ final class WPSC_Settings_Page {
203
  public static function init() {
204
  self::$default_tabs = array(
205
  'general' => _x( 'General' , 'General settings tab in Settings->Store page' , 'wpsc' ),
 
206
  'admin' => _x( 'Admin' , 'Admin settings tab in Settings->Store page' , 'wpsc' ),
207
  'taxes' => _x( 'Taxes' , 'Taxes settings tab in Settings->Store page' , 'wpsc' ),
208
  'shipping' => _x( 'Shipping' , 'Shipping settings tab in Settings->Store page' , 'wpsc' ),
@@ -365,13 +366,10 @@ final class WPSC_Settings_Page {
365
  */
366
  public function set_current_tab( $tab_id = null ) {
367
  if ( ! $tab_id ) {
368
- $tabs = array_keys( $this->tabs );
369
-
370
  if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) )
371
  $this->current_tab_id = $_GET['tab'];
372
  else
373
- $this->current_tab_id = array_shift( $tabs );
374
-
375
  } else {
376
  $this->current_tab_id = $tab_id;
377
  }
@@ -396,7 +394,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
  }
@@ -447,8 +445,7 @@ final class WPSC_Settings_Page {
447
  */
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
  /**
@@ -479,14 +476,14 @@ final class WPSC_Settings_Page {
479
  <div id="options_<?php echo esc_attr( $this->current_tab_id ); ?>" class="tab-content">
480
  <?php
481
  if ( is_callable( array( $this->current_tab, 'display' ) ) ) {
482
- do_action( 'wpsc_before_settings_tab', $this, $this->current_tab );
483
  $this->current_tab->display();
484
- do_action( 'wpsc_after_settings_tab', $this, $this->current_tab );
485
  }
486
  ?>
487
 
488
  <?php do_action( 'wpsc_' . $this->current_tab_id . '_settings_page' ); ?>
489
  <div class="submit">
 
 
490
  <?php if ( $this->current_tab->is_submit_button_displayed() ): ?>
491
  <?php submit_button( __( 'Save Changes' ) ); ?>
492
  <?php endif ?>
@@ -511,7 +508,7 @@ final class WPSC_Settings_Page {
511
  <div id="icon_card" class="icon32"></div>
512
  <h2 id="wpsc-settings-page-title">
513
  <?php esc_html_e( 'Store Settings', 'wpsc' ); ?>
514
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
515
  </h2>
516
  <?php $this->output_tabs(); ?>
517
  <div id='wpsc_options_page'>
@@ -579,12 +576,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 +632,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
 
@@ -652,7 +640,7 @@ final class WPSC_Settings_Page {
652
  $_POST['wpsc_options'] = stripslashes_deep( $_POST['wpsc_options'] );
653
  // make sure stock keeping time is a number
654
  if ( isset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] ) ) {
655
- $skt = $_POST['wpsc_options']['wpsc_stock_keeping_time']; // I hate repeating myself
656
  $skt = (float) $skt;
657
  if ( $skt <= 0 || ( $skt < 1 && $_POST['wpsc_options']['wpsc_stock_keeping_interval'] == 'hour' ) ) {
658
  unset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] );
@@ -718,12 +706,3 @@ final class WPSC_Settings_Page {
718
  }
719
 
720
  WPSC_Settings_Page::init();
721
-
722
- add_action( 'wpsc_after_settings_tab', '_wpsc_action_after_settings_tab' );
723
-
724
- function _wpsc_action_after_settings_tab() {
725
- ?>
726
- <input type='hidden' name='wpsc_admin_action' value='submit_options' />
727
- <?php
728
- wp_nonce_field( 'update-options', 'wpsc-update-options' );
729
- }
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
  *
203
  public static function init() {
204
  self::$default_tabs = array(
205
  'general' => _x( 'General' , 'General settings tab in Settings->Store page' , 'wpsc' ),
206
+ 'presentation' => _x( 'Presentation', 'Presentation settings tab in Settings->Store page', 'wpsc' ),
207
  'admin' => _x( 'Admin' , 'Admin settings tab in Settings->Store page' , 'wpsc' ),
208
  'taxes' => _x( 'Taxes' , 'Taxes settings tab in Settings->Store page' , 'wpsc' ),
209
  'shipping' => _x( 'Shipping' , 'Shipping settings tab in Settings->Store page' , 'wpsc' ),
366
  */
367
  public function set_current_tab( $tab_id = null ) {
368
  if ( ! $tab_id ) {
 
 
369
  if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) )
370
  $this->current_tab_id = $_GET['tab'];
371
  else
372
+ $this->current_tab_id = array_shift( array_keys( $this->tabs ) );
 
373
  } else {
374
  $this->current_tab_id = $tab_id;
375
  }
394
  set_transient( 'settings_errors', get_settings_errors(), 30 );
395
  $query_args['settings-updated'] = true;
396
  }
397
+ wp_redirect( esc_url( add_query_arg( $query_args ) ) );
398
  exit;
399
  }
400
  }
445
  */
446
  private function submit_url() {
447
  $location = add_query_arg( 'tab', $this->current_tab_id );
448
+ return esc_url( $location );
 
449
  }
450
 
451
  /**
476
  <div id="options_<?php echo esc_attr( $this->current_tab_id ); ?>" class="tab-content">
477
  <?php
478
  if ( is_callable( array( $this->current_tab, 'display' ) ) ) {
 
479
  $this->current_tab->display();
 
480
  }
481
  ?>
482
 
483
  <?php do_action( 'wpsc_' . $this->current_tab_id . '_settings_page' ); ?>
484
  <div class="submit">
485
+ <input type='hidden' name='wpsc_admin_action' value='submit_options' />
486
+ <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
487
  <?php if ( $this->current_tab->is_submit_button_displayed() ): ?>
488
  <?php submit_button( __( 'Save Changes' ) ); ?>
489
  <?php endif ?>
508
  <div id="icon_card" class="icon32"></div>
509
  <h2 id="wpsc-settings-page-title">
510
  <?php esc_html_e( 'Store Settings', 'wpsc' ); ?>
511
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
512
  </h2>
513
  <?php $this->output_tabs(); ?>
514
  <div id='wpsc_options_page'>
576
  else
577
  update_option( 'wpsc_ga_tracking_id', '' );
578
 
 
 
 
 
 
 
579
  }
580
 
581
  if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
632
  );
633
  }
634
  }
 
 
 
635
  }
636
  $previous_currency = get_option( 'currency_type' );
637
 
640
  $_POST['wpsc_options'] = stripslashes_deep( $_POST['wpsc_options'] );
641
  // make sure stock keeping time is a number
642
  if ( isset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] ) ) {
643
+ $skt =& $_POST['wpsc_options']['wpsc_stock_keeping_time']; // I hate repeating myself
644
  $skt = (float) $skt;
645
  if ( $skt <= 0 || ( $skt < 1 && $_POST['wpsc_options']['wpsc_stock_keeping_interval'] == 'hour' ) ) {
646
  unset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] );
706
  }
707
 
708
  WPSC_Settings_Page::init();
 
 
 
 
 
 
 
 
 
wpsc-admin/users.php DELETED
@@ -1,7 +0,0 @@
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
- );
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik.php DELETED
@@ -1,596 +0,0 @@
1
- <?php
2
- /**
3
- * Main class
4
- *
5
- * @package Sputnik
6
- * @subpackage Public API
7
- */
8
-
9
- /**
10
- * Main class
11
- *
12
- * @package Sputnik
13
- * @subpackage Public API
14
- */
15
- 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
45
- * @var string
46
- */
47
- public static $path = '';
48
-
49
- /**
50
- * Cache of purchased plugins API data
51
- */
52
- protected static $purchased = false;
53
-
54
- /**
55
- * Installed plugin IDs
56
- */
57
- protected static $installed = array();
58
-
59
- /**
60
- * Enabled plugins which haven't been purchased
61
- */
62
- protected static $invalid = array();
63
-
64
- /**
65
- * Plugins which have been suspended remotely
66
- */
67
- protected static $suspended = array();
68
-
69
- protected static $account = null;
70
-
71
- /**
72
- * Register everything we need
73
- */
74
- public static function bootstrap() {
75
-
76
- spl_autoload_register(array(get_class(), 'autoload'));
77
-
78
- self::$installed = get_option('sputnik_installed', array());
79
- self::$suspended = get_option('sputnik_suspended', array());
80
-
81
- //add_action('activated_plugin', array(get_class(), 'clear_installed'));
82
- //add_action('deactivated_plugin', array(get_class(), 'clear_installed'));
83
-
84
- // 'deactivated_plugin' runs before saving, so we have to do this instead:
85
- add_action('update_option_active_plugins', array(get_class(), 'clear_installed'));
86
-
87
- add_action( 'plugins_loaded', array(get_class(), 'loaded'));
88
- add_action( 'init', array(get_class(), 'init'));
89
- add_action( 'init', array( get_class(), 'check_for_saas_push' ) );
90
- add_action( 'init', array( get_class(), 'thumbnails' ) );
91
- add_action( 'init', array( get_class(), 'credentials' ) );
92
- add_action( 'wp', array( get_class(), 'show_login_form' ) );
93
- add_filter( 'extra_plugin_headers', array(get_class(), 'extra_headers'));
94
- add_filter( 'extra_theme_headers', array(get_class(), 'extra_headers'));
95
-
96
- add_action( 'wpsc_update_purchase_log_status', array( get_class(), 'push_sales_data' ), 10, 4 );
97
- add_action( 'init', array( get_class(), 'sales_data_postback' ) );
98
-
99
- add_filter( 'wpsc_purchase_log_customer_notification_raw_message', array( get_class(), 'add_download_link' ), 10, 2 );
100
- add_action( 'wpsc_transaction_results_shutdown' , array( get_class(), 'add_download_link_page' ), 10, 3 );
101
-
102
- Sputnik_Admin::bootstrap();
103
- Sputnik_Updater::bootstrap();
104
- Sputnik_Pointers::bootstrap();
105
- }
106
-
107
- public static function add_download_link( $message, $notification ) {
108
- $cart_contents = $notification->get_purchase_log()->get_cart_contents();
109
-
110
- $products = '';
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;
121
- }
122
-
123
- public static function show_login_form() {
124
- if ( ! isset( $_GET['marketplace'] ) )
125
- return;
126
-
127
- $url = 'http://www.wpeconomy.org/products-page/add/?framed=true&marketplace=' . urlencode( esc_url_raw( Sputnik_API::domain() ) );
128
-
129
- $auth = Sputnik_API::auth_request( $url, false );
130
- ?>
131
- <html>
132
- <head>
133
- <script type="text/javascript" src="<?php echo home_url( $GLOBALS['wp_scripts']->registered['jquery']->src ); ?>"></script>
134
- <script type="text/javascript">
135
- jQuery(window).load(function() {
136
- jQuery( '#add_form' ).load( '<?php echo esc_url( $auth ); ?>' );
137
- });
138
- </script>
139
- </head>
140
- <body>
141
- <div id="add_form"></div>
142
- </body>
143
- </html>
144
- <?php
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
-
152
- $cart_contents = $purchase_log_object->get_cart_contents();
153
-
154
- $products = '';
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;
165
- }
166
-
167
- /**
168
- * Callback for 'plugins_loaded' action
169
- */
170
- public static function loaded() {
171
- do_action('sputnik_loaded');
172
- }
173
-
174
- /**
175
- * Callback for 'init' action
176
- */
177
- public static function init() {
178
- do_action('sputnik_init');
179
- }
180
-
181
- public static function thumbnails() {
182
- if ( ! isset( $_REQUEST['thumbnails'] ) || ( isset( $_REQUEST['thumbnails'] ) && 'true' !== $_REQUEST['thumbnails'] ) )
183
- return;
184
-
185
- $thumbs = array( 'width' => get_option( 'product_image_width' ), 'height' => get_option( 'product_image_height' ) );
186
-
187
- echo json_encode( $thumbs );
188
- die;
189
- }
190
-
191
- public static function check_for_saas_push() {
192
-
193
- if ( ! isset( $_REQUEST['json_product_push'] ) || ( isset( $_REQUEST['json_product_push'] ) && 'true' !== $_REQUEST['json_product_push'] ) )
194
- return;
195
-
196
- error_reporting( E_ERROR );
197
-
198
- if ( ! empty( $_POST['product'] ) ) {
199
- $product = stripslashes( $_POST['product'] );
200
- $product = json_decode( $product );
201
-
202
- $download_url = Sputnik::API_BASE . '/download/' . $product->post_name . '.zip';
203
- $thumb_url = $product->thumbnail_url;
204
-
205
- //Check if local product exists - if so, update it, if not, don't.
206
- $local = get_posts( array(
207
- 'pagename' => $product->post_name,
208
- 'post_type' => 'wpsc-product',
209
- 'post_status' => 'publish',
210
- 'numberposts' => 1 )
211
- );
212
-
213
- $user_check = get_user_by( 'email', $product->author_email );
214
-
215
- if ( $user_check ) {
216
- $product->post_author = $user_check->ID;
217
-
218
- if ( ! in_array( 'vendor-administrator', $user_check->roles ) )
219
- $user_check->add_role( 'vendor-administrator' );
220
- }
221
- else {
222
- $product->post_author = wp_insert_user( array( 'role' => 'vendor-administrator', 'user_email' => $product->author_email, 'user_pass' => wp_generate_password(), 'user_login' => $product->author_email ) );
223
- }
224
-
225
- $product = (array) $product;
226
- unset( $product['guid'] );
227
- unset( $product['post_date_gmt'] );
228
- unset( $product['post_date'] );
229
-
230
- require_once(ABSPATH . 'wp-admin/includes/media.php');
231
- require_once(ABSPATH . 'wp-admin/includes/file.php');
232
- require_once(ABSPATH . 'wp-admin/includes/image.php');
233
-
234
- if ( ! empty( $local ) ) {
235
- $product['ID'] = $local[0]->ID;
236
- $new_id = wp_update_post( $product );
237
- } else {
238
- unset( $product['ID'] );
239
- // Doesn't exist, create it. Then, after created, add download URL and thumbnail.
240
- $new_id = wp_insert_post( $product );
241
- }
242
-
243
- update_post_meta( $new_id, '_download_url', $download_url );
244
-
245
- foreach ( $product['meta'] as $key => $val ) {
246
- if ( '_wpsc_product_metadata' == $key )
247
- continue;
248
-
249
- if ( '_wpsc_currency' == $key )
250
- continue;
251
-
252
- update_post_meta( $new_id, $key, $val[0] );
253
- }
254
-
255
-
256
-
257
- $thumb = media_sideload_image( $thumb_url, $new_id, 'Product Thumbnail' );
258
-
259
- if ( ! is_wp_error( $thumb ) ) {
260
- $thumbnail_id = get_posts( array( 'post_type' => 'attachment', 'post_parent' => $new_id ) );
261
-
262
- if ( ! empty( $thumbnail_id ) ) {
263
-
264
- $thumbnail = set_post_thumbnail( $new_id, $thumbnail_id[0]->ID );
265
- echo json_encode( array( 'set_thumbnail' => $thumbnail, 'post_id' => $new_id ) );
266
- die;
267
- }
268
- die;
269
- }
270
- die;
271
- }
272
-
273
- exit;
274
- }
275
-
276
- public static function credentials() {
277
-
278
- if ( ! isset( $_REQUEST['credential_request'] ) || ( isset( $_REQUEST['credential_request'] ) && 'true' !== $_REQUEST['credential_request'] ) )
279
- return;
280
-
281
- if ( ! isset( $_SERVER['HTTP_X_CREDENTIALS_REQUEST'] ) )
282
- return;
283
-
284
- die( json_encode( get_option( 'wpsc_payment_gateway_paypal_digital_goods' ) ) );
285
-
286
- }
287
-
288
- /**
289
- * Pushes sales data back to Baikonur
290
- *
291
- * Only pushes once. Accounts for annoying potential edge case of status-switching admins
292
- *
293
- * @param WPSC_Purchase_Log object $purchase_log Purchase Log object
294
- * @return void
295
- */
296
- public static function push_sales_data( $purchase_log_id, $current_status, $old_status, $purchase_log ) {
297
-
298
- $purchase_log = new WPSC_Purchase_Log( $purchase_log_id );
299
-
300
- $id = absint( $purchase_log->get( 'id' ) );
301
-
302
- //Also checking is_order_received, as that's what Manual Payments do.
303
- if ( $purchase_log->is_transaction_completed() || $purchase_log->is_order_received() ) {
304
-
305
- $pushed_to_sass = wpsc_get_meta( $id, '_pushed_to_wpeconomy', 'purchase_log' );
306
-
307
- if ( empty( $pushed_to_saas ) ) {
308
-
309
- $data = $purchase_log->get_data();
310
- $cart_contents = $purchase_log->get_cart_contents();
311
-
312
- //We want to push sales data - but naturally, IDs will differ, even names could potentially.
313
- //So we add the slug to the object we POST
314
- foreach ( $cart_contents as $key => $cart_item ) {
315
- $slug = get_post_field( 'post_name', $cart_item->prodid );
316
- $cart_contents[ $key ]->slug = $slug;
317
- }
318
-
319
- $args = array(
320
- 'body' => array( 'data' => json_encode( $data ), 'cart_contents' => json_encode( $cart_contents ) )
321
- );
322
-
323
- $request = wp_remote_post( 'http://www.wpeconomy.org/?sales_data=true', $args );
324
- $response = wp_remote_retrieve_response_code( $request );
325
-
326
- //For some reason, if the site is down, we want the ability to ensure we can grab the sale later.
327
- $success = ( 200 === $response );
328
-
329
- wpsc_update_meta( $id, '_pushed_to_wpeconomy', $success, 'purchase_log' );
330
- }
331
- }
332
- }
333
-
334
- public static function sales_data_postback() {
335
- if ( ! isset( $_REQUEST['sales_data'] ) )
336
- return;
337
-
338
- $data = json_decode( stripslashes( $_POST['data'] ) );
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
-
346
- $purchase_log = new WPSC_Purchase_Log( $data );
347
- $purchase_log->save();
348
- $purchase_log_id = $purchase_log->get( 'id' );
349
-
350
- global $wpdb;
351
-
352
- //We need to update the proper product ID, name and purchase ID
353
- foreach ( $cart_contents as $cart_item ) {
354
-
355
- $product = new WP_Query( array( 'post_type' => 'wpsc-product', 'pagename' => $cart_item->slug ) );
356
- $product = $product->get_posts();
357
- $product = $product[0];
358
-
359
- $cart_item = ( array ) $cart_item;
360
-
361
- unset( $cart_item['id'] );
362
- unset( $cart_item['slug'] );
363
-
364
- $cart_item['prodid'] = $product->ID;
365
- $cart_item['name'] = $product->post_title;
366
- $cart_item['purchaseid'] = $purchase_log_id;
367
-
368
- $wpdb->insert( WPSC_TABLE_CART_CONTENTS, $cart_item );
369
- }
370
-
371
- die;
372
- }
373
-
374
-
375
- /**
376
- * Register our extra plugin metadata headers
377
- */
378
- public static function extra_headers($headers) {
379
- $headers[] = 'Sputnik ID';
380
- $headers[] = 'Requires WPEC Version';
381
- $headers[] = 'Compatible to WPEC Version';
382
- return $headers;
383
- }
384
-
385
- /**
386
- * Autoload a Sputnik class
387
- *
388
- * @param string $class
389
- */
390
- public static function autoload($class) {
391
- if (strpos($class, 'Sputnik') !== 0) {
392
- return;
393
- }
394
-
395
- $file = str_replace('_', '/', $class);
396
- if (file_exists(self::$path . '/library/' . $file . '.php')) {
397
- require_once(self::$path . '/library/' . $file . '.php');
398
- }
399
- }
400
-
401
- /**
402
- * Get available modules
403
- *
404
- * @return array Available plugins (array of meta objects)
405
- */
406
- public static function get_available() {
407
- $plugins = Sputnik_API::get_all();
408
- return $plugins['body'];
409
- }
410
-
411
- /**
412
- * Get popular tags
413
- *
414
- * @return array
415
- */
416
- public static function get_tags() {
417
- $tags = Sputnik_API::get_tags();
418
- return $tags['body'];
419
- }
420
-
421
- /**
422
- * Return whether an account is linked to Sputnik
423
- *
424
- * @return bool
425
- */
426
- public static function account_is_linked() {
427
- $token = get_option('sputnik_oauth_access', false);
428
- return (is_array($token) && !empty($token['oauth_token']));
429
- }
430
-
431
- /**
432
- * Get account information
433
- *
434
- * @return stdObject
435
- */
436
- public static function get_account() {
437
- if ( is_null( self::$account ) ) {
438
- $account = Sputnik_API::get_account();
439
- self::$account = $account['body'];
440
- }
441
-
442
- return self::$account;
443
- }
444
-
445
- /**
446
- * Forces an update to the account information from the server
447
- *
448
- * @return stdObject
449
- */
450
- public static function update_account() {
451
- self::$account = null;
452
- return self::get_account();
453
- }
454
-
455
- /**
456
- * Get purchased plugins
457
- *
458
- * @return array Plugin slugs
459
- */
460
- public static function get_purchased() {
461
- // This should be cached in a transient
462
- if (self::$purchased === false) {
463
- $purchased = Sputnik_API::get_purchased();
464
- self::$purchased = $purchased['body'];
465
- }
466
- return self::$purchased;
467
- }
468
-
469
- /**
470
- * Check if a plugin has been purchased
471
- *
472
- * @param string $plugin Plugin slug
473
- * @return boolean
474
- */
475
- public static function is_purchased($plugin) {
476
- if (is_object($plugin)) {
477
- $plugin = $plugin->slug;
478
- }
479
-
480
- try {
481
- $account = self::get_account();
482
- return in_array($plugin, (array) $account->purchased);
483
- }
484
- catch (Exception $e) {
485
- return false;
486
- }
487
- }
488
-
489
- /**
490
- * Check if a plugin has been suspended
491
- *
492
- * @param string $plugin Plugin slug
493
- * @return boolean
494
- */
495
- public static function is_suspended($plugin) {
496
- if (is_object($plugin)) {
497
- $plugin = $plugin->slug;
498
- }
499
-
500
- return array_key_exists($plugin, self::$suspended);
501
- }
502
-
503
- /**
504
- * Suspend a plugin
505
- *
506
- * For internal use by {@see Sputnik_Updater} only
507
- * @param string $plugin Plugin slug
508
- */
509
- public static function suspend_plugin($plugin, $file, $data) {
510
- // Check that the updater was the one that issued the command
511
- if (!Sputnik_Updater::confirm_suspend($plugin, $data)) {
512
- return false;
513
- }
514
-
515
- self::$suspended[$plugin] = $data;
516
- deactivate_plugins(array($file), true);
517
- update_option('sputnik_suspended', self::$suspended);
518
- return true;
519
- }
520
-
521
- /**
522
- * Get a single module
523
- *
524
- * @param string $id
525
- * @return stdObject
526
- */
527
- public static function get_plugin($id, $user = 0) {
528
- $plugin = Sputnik_API::get_single($id, $user);
529
- return $plugin['body'];
530
- }
531
-
532
- public static function get_from_file($file) {
533
- if (empty(self::$installed)) {
534
- self::$installed = self::load_installed();
535
- }
536
-
537
- if (!empty(self::$installed[$file])) {
538
- return self::$installed[$file];
539
- }
540
-
541
- return null;
542
- }
543
-
544
- public static function check($file, $callback = null) {
545
- $file = plugin_basename($file);
546
-
547
- $plugin = self::get_from_file($file);
548
-
549
- if (!self::is_purchased($plugin['Sputnik ID'])) {
550
- $plugin['sputnik_error'] = 'not_purchased';
551
- self::$invalid[] = $plugin;
552
- return false;
553
- }
554
-
555
- if ($callback !== null) {
556
- call_user_func($callback);
557
- }
558
- return true;
559
- }
560
-
561
- public static function get_installed($force = false) {
562
- if (empty(self::$installed) || $force === true) {
563
- self::$installed = self::load_installed();
564
- }
565
-
566
- return self::$installed;
567
- }
568
-
569
- protected static function load_installed() {
570
- if (!function_exists('get_plugins')) {
571
- require_once(ABSPATH . 'wp-admin/includes/plugin.php');
572
- }
573
-
574
- $all = get_plugins();
575
- $plugins = array();
576
- foreach ($all as $file => $plugin) {
577
- if (empty($plugin['Sputnik ID'])) {
578
- continue;
579
- }
580
- $plugins[$file] = $plugin;
581
- }
582
-
583
- update_option('sputnik_installed', $plugins);
584
-
585
- return $plugins;
586
- }
587
-
588
- public static function clear_installed() {
589
- delete_option('sputnik_installed');
590
- self::$installed = self::load_installed();
591
- }
592
-
593
- public static function get_invalid() {
594
- return self::$invalid;
595
- }
596
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/API.php DELETED
@@ -1,246 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_API {
4
- /**
5
- * @var Sputnik_API_Auth
6
- */
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 = '/';
18
- if ($page !== 1) {
19
- $url = sprintf('/page/%d', $page);
20
- }
21
-
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(
44
- 'name' => $name
45
- );
46
- if ($user !== 0) {
47
- $params['user'] = $user;
48
- }
49
-
50
- $uri = "/info/{$name}/";
51
-
52
- return self::request( $uri );
53
- }
54
-
55
- public static function rate_product($name, $rating) {
56
- self::authenticate();
57
-
58
- $url = sprintf('/info/%s/rate', $name);
59
- $parameters = array('rating' => (int) $rating);
60
- $auth_header = self::$auth->get_auth_header($url, 'POST', $parameters);
61
- $options = array(
62
- 'method' => 'POST',
63
- 'headers' => array(
64
- 'Authorization' => $auth_header
65
- )
66
- );
67
- return self::request($url, $parameters, $options);
68
- }
69
-
70
- public static function get_tags() {
71
- return self::request('/tags');
72
- }
73
-
74
- protected static function authenticate() {
75
- $token = get_option('sputnik_oauth_access', false);
76
-
77
- if ($token == false) {
78
- throw new Exception('Need to authenticate first', 1);
79
- }
80
- self::$auth = new Sputnik_API_Auth(Sputnik::OAUTH_KEY, Sputnik::OAUTH_SECRET, $token['oauth_token'], $token['oauth_token_secret']);
81
- }
82
-
83
- public static function auth_request( $callback = '', $redirect = true ) {
84
- self::$auth = new Sputnik_API_Auth( Sputnik::OAUTH_KEY, Sputnik::OAUTH_SECRET);
85
- $callback_url = empty( $callback ) ? Sputnik_Admin::build_url( array( 'oauth' => 'callback' ) ) : $callback;
86
- $token = self::$auth->get_request_token( $callback_url );
87
-
88
- update_option( 'sputnik_oauth_request', $token );
89
-
90
- $auth_url = self::$auth->get_authorize_url( $token );
91
-
92
- //Modifying to add marketplace and user email to query string.
93
- if ( $redirect ) {
94
- wp_redirect( add_query_arg( array( 'domain' => self::domain(), 'user' => rawurlencode( wp_get_current_user()->user_email ) ), $auth_url ) );
95
- exit;
96
- } else {
97
- return $auth_url;
98
- }
99
- }
100
-
101
- public static function auth_access() {
102
-
103
- if( isset( $_REQUEST['denied'] ) ) {
104
-
105
- $return_url = Sputnik_Admin::build_url( array( 'auth' => 'denied' ) );
106
-
107
- } else {
108
- $request = get_option('sputnik_oauth_request', false);
109
-
110
- self::$auth = new Sputnik_API_Auth(Sputnik::OAUTH_KEY, Sputnik::OAUTH_SECRET, $request['oauth_token'], $request['oauth_token_secret']);
111
- $access = self::$auth->get_access_token($_REQUEST['oauth_verifier']);
112
-
113
- update_option('sputnik_oauth_access', $access);
114
-
115
- $args = array();
116
- if ( ! empty( $_REQUEST['oauth_buy'] ) )
117
- $args['oauth_buy'] = $_REQUEST['oauth_buy'];
118
- $return_url = Sputnik_Admin::build_url( $args );
119
- }
120
-
121
- // Close the authentication popup ?>
122
- <!DOCTYPE html><html>
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>
130
- <body>&nbsp;</body>
131
- </html><?php
132
- die();
133
- }
134
-
135
- public static function get_account() {
136
- self::authenticate();
137
-
138
- $url = '/account';
139
- $request = self::$auth->sign($url);
140
- return self::request($request->to_url());
141
- }
142
-
143
- public static function get_purchased() {
144
- self::authenticate();
145
-
146
- $url = '/account/purchased';
147
- $request = self::$auth->sign($url);
148
- return self::request($request->to_url());
149
- }
150
-
151
- public static function get_own() {
152
- self::authenticate();
153
-
154
- $url = '/account/myplugins';
155
- $request = self::$auth->sign($url);
156
- return self::request($request->to_url());
157
- }
158
-
159
- public static function sign_download(&$url, &$args) {
160
- self::authenticate();
161
-
162
- if (!isset($args['headers'])) {
163
- $args['headers'] = array();
164
- }
165
-
166
- $oauth = self::$auth->sign($url);
167
-
168
- $url = $oauth->to_url();
169
- }
170
-
171
- public static function get_auth_for_download($url) {
172
- self::authenticate();
173
-
174
- return self::$auth->get_auth_header($url);
175
- }
176
-
177
- /* Purchase Methods */
178
-
179
- public static function get_checkout_token( $product ) {
180
- self::authenticate();
181
-
182
- $url = '/purchase/get_checkout_token/' . $product->client_product_id;
183
-
184
- $request = self::$auth->sign( $url, 'GET', array(
185
- 'redirect_uri' => Sputnik_Admin::build_url( array( '_wpnonce' => wp_create_nonce( 'sputnik_install-plugin_' . $product->slug ) ) )
186
- )
187
- );
188
-
189
- $response = self::request( $request->to_url(), array(), array( 'timeout' => 25 ) );
190
-
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
-
235
- public static function domain() {
236
- $wp_install = home_url( '/' );
237
-
238
- if ( is_multisite() )
239
- $wp_install = network_site_url( '/' );
240
-
241
- if ( ! empty( self::$domain_override ) )
242
- $wp_install = self::$domain_override;
243
-
244
- return $wp_install;
245
- }
246
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/API/Auth.php DELETED
@@ -1,137 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Sputnik OAuth class
5
- */
6
- class Sputnik_API_Auth {
7
- public function __construct($key, $secret, $token = null, $token_secret = null) {
8
- $this->sha1_method = new Sputnik_OAuth_SignatureMethod_HMAC_SHA1();
9
- $this->consumer = new Sputnik_OAuth_Consumer($key, $secret);
10
- if (!empty($token) && !empty($token_secret)) {
11
- $this->token = new Sputnik_OAuth_Consumer($token, $token_secret);
12
- } else {
13
- $this->token = NULL;
14
- }
15
- }
16
-
17
- /**
18
- * Get a request_token from Twitter
19
- *
20
- * @return array A key/value array containing oauth_token and oauth_token_secret
21
- */
22
- public function get_request_token($callback = null) {
23
- $parameters = array();
24
- if (!empty($callback)) {
25
- $parameters['oauth_callback'] = $callback;
26
- }
27
- $request = $this->request('/auth/request_token', 'GET', $parameters);
28
-
29
- $token = Sputnik_OAuth_Util::parse_parameters($request);
30
- $this->token = new Sputnik_OAuth_Consumer($token['oauth_token'], $token['oauth_token_secret']);
31
- return $token;
32
- }
33
-
34
- /**
35
- * Get the authorize URL
36
- *
37
- * @return string
38
- */
39
- public function get_authorize_url($token) {
40
- if (is_array($token)) {
41
- $token = $token['oauth_token'];
42
- }
43
- return Sputnik::SITE_BASE . "/oauth/authorize?oauth_token={$token}";
44
- }
45
-
46
- /**
47
- * Exchange request token and secret for an access token and
48
- * secret, to sign API calls.
49
- *
50
- * @return array("oauth_token" => "the-access-token",
51
- * "oauth_token_secret" => "the-access-secret",
52
- * "user_id" => "9436992",
53
- * "screen_name" => "abraham")
54
- */
55
- public function get_access_token($verifier = false) {
56
- $parameters = array();
57
- if (!empty($verifier)) {
58
- $parameters['oauth_verifier'] = $verifier;
59
- }
60
-
61
- $request = $this->request('/auth/access_token', 'GET', $parameters);
62
-
63
- $token = Sputnik_OAuth_Util::parse_parameters($request);
64
- $this->token = new Sputnik_OAuth_Consumer($token['oauth_token'], $token['oauth_token_secret']);
65
- return $token;
66
- }
67
-
68
- /**
69
- * Format and sign an OAuth / API request
70
- */
71
- public function sign($url, $method = 'GET', $parameters = array()) {
72
- if (strpos($url, 'http') !== 0) {
73
- $url = Sputnik::API_BASE . $url;
74
- }
75
-
76
- $request = Sputnik_OAuth_Request::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
77
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
78
- return $request;
79
- }
80
-
81
- /**
82
- * Format and sign an OAuth / API request
83
- */
84
- public function get_auth_header($url, $method = 'GET', $parameters = array()) {
85
- if (strpos($url, 'http') !== 0) {
86
- $url = Sputnik::API_BASE . $url;
87
- }
88
- $request = Sputnik_OAuth_Request::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
89
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
90
- $header = $request->to_header($this->sha1_method, $this->consumer, $this->token);
91
-
92
- // We want to remove the 'Authorization' bit from the start
93
- return substr($header, 15);
94
- }
95
-
96
- /**
97
- * Format and sign an OAuth / API request, and execute it
98
- */
99
- public function request($url, $method, $parameters) {
100
- $request = $this->sign($url, $method, $parameters);
101
-
102
- switch ($method) {
103
- case 'GET':
104
- return $this->http($request->to_url(), 'GET');
105
- default:
106
- return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
107
- }
108
- }
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) {
117
- case 'POST':
118
- if (!empty($postfields)) {
119
- $args['body'] = $postfields;
120
- }
121
- break;
122
- }
123
-
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());
130
- }
131
-
132
- if ($response['response']['code'] != 200) {
133
- throw new Exception($response['body']);
134
- }
135
- return $response['body'];
136
- }
137
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Admin.php DELETED
@@ -1,994 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_Admin {
4
- protected static $page_is_current = false;
5
- protected static $list_table;
6
-
7
- protected static $page = 'dash';
8
-
9
- public static function bootstrap() {
10
- add_action( 'admin_init', array(__CLASS__, 'init'), 0);
11
- add_action( 'all_admin_notices', array(__CLASS__, 'report_errors'));
12
-
13
- add_action( 'admin_menu', array(__CLASS__, 'menu'));
14
-
15
- add_action( 'admin_head-wpsc-product_page_sputnik', array(__CLASS__, 'admin_head_page'));
16
- add_action( 'admin_head-wpsc-product_page_sputnik-account', array(__CLASS__, 'admin_head_page'));
17
- add_action( 'install_plugins_pre_plugin-information', array(__CLASS__, 'maybe_info'), 0);
18
- add_action( 'load-update.php', array(__CLASS__, 'maybe_redirect_update'));
19
- add_filter( 'plugin_row_meta', array(__CLASS__, 'add_row_note'), 10, 3);
20
- add_action( 'wp_ajax_sputnik_rate', array(__CLASS__, 'set_rating'));
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
-
32
- global $plugin_page;
33
-
34
- if ( $plugin_page !== 'sputnik' && $plugin_page !== 'sputnik-account' )
35
- return;
36
-
37
- // Run most OAuth stuff now, before output
38
- if (!empty($_GET['oauth'])) {
39
- if ($_GET['oauth'] == 'request') {
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
- }
47
- if ($_GET['oauth'] == 'callback') {
48
- Sputnik_API::auth_access();
49
- }
50
- if ($_GET['oauth'] == 'reset') {
51
- delete_option('sputnik_oauth_request');
52
- delete_option('sputnik_oauth_access');
53
-
54
- wp_redirect(self::build_url());
55
- }
56
- }
57
-
58
- switch (true) {
59
- case isset($_GET['info']):
60
- self::$page = 'info';
61
- break;
62
- case isset($_GET['buy']):
63
- self::$page = 'buy';
64
- break;
65
- case isset($_GET['paid']):
66
- self::$page = 'paid';
67
- break;
68
- case isset($_GET['install']):
69
- self::$page = 'install';
70
- break;
71
- case isset($_GET['upgrade']):
72
- self::$page = 'upgrade';
73
- break;
74
- case isset($_GET['cancel_payment']):
75
- self::$page = 'cancel_payment';
76
- break;
77
- case $plugin_page === 'wpsc-product_page_sputnik-account':
78
- self::$page = 'account';
79
- $GLOBALS['tab'] = 'account';
80
- break;
81
- default:
82
- self::$page = 'dash';
83
- break;
84
- }
85
-
86
- // Avoid having to specify this for every page
87
- if (self::$page !== 'dash' && self::$page !== 'account') {
88
- $_GET['noheader'] = true;
89
- }
90
- }
91
-
92
- public static function report_errors() {
93
- $invalid = Sputnik::get_invalid();
94
- if (empty($invalid)) {
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) {
102
- if (empty($plugin['sputnik_error'])) {
103
- $plugin['sputnik_error'] = 'unknown';
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
- ?>
114
- <li><?php echo esc_html($plugin['Name']) ?> &mdash; <?php echo $error ?></li>
115
- <?php
116
- }
117
- ?>
118
- </ul>
119
- </div>
120
- <?php
121
- }
122
-
123
- /**
124
- * Adds a note to all plugins handled by us on the plugin screen
125
- */
126
- public static function add_row_note($meta, $file, $data) {
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();
145
- self::$list_table->prepare_items();
146
- }
147
- elseif (self::$page === 'account') {
148
- self::$list_table = new Sputnik_List_Account();
149
- $pagenum = self::$list_table->get_pagenum();
150
- self::$list_table->prepare_items();
151
- }
152
-
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() {
181
- if ( self::$page_is_current != true )
182
- return;
183
-
184
- if ( ! current_user_can( 'install_plugins' ) )
185
- return;
186
-
187
- $oauth_url = self::build_url(array('oauth' => 'request', 'TB_iframe' => true));
188
-
189
-
190
- ?>
191
- <div class="sputnik-message updated">
192
- <p>
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
-
207
- protected static function print_message($message = '') {
208
- ?>
209
- <div id="message" class="updated below-h2">
210
- <p><?php echo $message; ?></p>
211
- </div>
212
- <?php
213
- }
214
-
215
- public static function menu_order($menu_order) {
216
- $real = array();
217
-
218
- foreach ( $menu_order as $index => $item ) {
219
- if ( $item != 'sputnik' )
220
- $real[] = $item;
221
-
222
- if ( $index == 0 )
223
- $real[] = 'sputnik';
224
- }
225
-
226
- return $real;
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
-
239
- public static function build_url($args = array()) {
240
- $url = add_query_arg( array( 'post_type' => 'wpsc-product', 'page' => 'sputnik' ), admin_url( 'edit.php' ) );
241
-
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()) {
249
- $url = add_query_arg( array( 'post_type' => 'wpsc-product', 'page' => 'sputnik-account' ), admin_url( 'edit.php' ) );
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() {
300
- global $current_user;
301
-
302
- switch (self::$page) {
303
- case 'info':
304
- return self::info($_GET['info']);
305
- case 'buy':
306
- return self::purchase($_GET['buy']);
307
- case 'paid':
308
- return self::paid($_GET['paid']);
309
- case 'cancel_payment':
310
- return self::cancel_payment($_GET['cancel_payment']);
311
- case 'install':
312
- return self::install($_GET['install']);
313
- case 'upgrade':
314
- return self::upgrade($_GET['upgrade']);
315
- default:
316
- return self::other_pages();
317
- }
318
- }
319
-
320
- public static function maybe_info() {
321
- $plugin = $_REQUEST['plugin'];
322
- if (strpos($plugin, 'sputnik-') !== 0) {
323
- return;
324
- }
325
-
326
- $plugin = substr($plugin, 8);
327
- self::info($plugin);
328
-
329
- die();
330
- }
331
-
332
- protected static function info($plugin) {
333
- global $tab;
334
- require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
335
-
336
- define( 'IFRAME_REQUEST', true );
337
-
338
- try {
339
- if ( Sputnik::account_is_linked() ) {
340
- $account = Sputnik::get_account();
341
- $api = Sputnik::get_plugin( $plugin, $account->ID );
342
- } else {
343
- $api = Sputnik::get_plugin( $plugin );
344
- }
345
- } catch (Exception $e) {
346
- status_header(500);
347
- iframe_header( __('Plugin Install', 'wpsc') );
348
- echo $e->getMessage();
349
- iframe_footer();
350
- die();
351
- }
352
-
353
- $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
354
- 'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
355
- 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
356
- 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
357
- 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
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
370
- $api->sections = isset( $api->sections ) ? (array) $api->sections : array();
371
- $api->author = links_add_target($api->author, '_blank');
372
- foreach ( $api->sections as $section_name => $content )
373
- $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
374
-
375
- $api->screenshots = (array) $api->screenshots;
376
- foreach ( $api->screenshots as &$data ) {
377
- if (!isset($data->caption) || !isset($data->location)) {
378
- continue;
379
- }
380
-
381
- $data->caption = wp_kses($data->caption, $plugins_allowedtags);
382
- $data->location = esc_url($data->location, array('http', 'https'));
383
- }
384
- unset($data);
385
-
386
- foreach ( array( 'version', 'requires', 'tested', 'homepage', 'downloaded', 'slug', 'requires_wpec', 'tested_wpec' ) as $key ) {
387
- if ( isset( $api->$key ) )
388
- $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
389
- }
390
-
391
- $section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
392
- if ( empty($section) || (!isset($api->sections[ $section ]) && ($section !== 'screenshots' || empty($api->screenshots))) )
393
- $section = array_shift( $section_titles = array_keys((array)$api->sections) );
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>
401
- <?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>
402
- <p class="action-button">
403
- <?php
404
- $status = self::install_status($api);
405
- switch ( $status['status'] ) {
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
- ?>
427
- </p>
428
- <?php endif; ?>
429
- <?php
430
- echo "<div id='plugin-information-header'>\n";
431
- echo "<ul id='sidemenu'>\n";
432
- foreach ( (array)$api->sections as $section_name => $content ) {
433
- if ( isset( $plugins_section_titles[ $section_name ] ) )
434
- $title = $plugins_section_titles[ $section_name ];
435
- else
436
- $title = ucwords( str_replace( '_', ' ', $section_name ) );
437
-
438
- $class = ( $section_name == $section ) ? ' class="current"' : '';
439
- $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
440
- $href = esc_url($href);
441
- $san_section = esc_attr($section_name);
442
- echo "\t<li><a name='$san_section' href='$href'$class>$title</a></li>\n";
443
- }
444
-
445
- if (!empty($api->screenshots)) {
446
- $title = $plugins_section_titles['screenshots'];
447
- $class = ( 'screenshots' == $section ) ? ' class="current"' : '';
448
- $href = add_query_arg( array('tab' => $tab, 'section' => 'screenshots') );
449
- $href = esc_url($href);
450
- echo "\t<li><a name='screenshots' href='$href'$class>$title</a></li>\n";
451
- }
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 ] ) )
495
- $title = $plugins_section_titles[ $section_name ];
496
- else
497
- $title = ucwords( str_replace( '_', ' ', $section_name ) );
498
-
499
- $content = links_add_base_url($content, $api->permalink);
500
- $content = links_add_target($content, '_blank');
501
-
502
- $san_section = esc_attr($title);
503
-
504
- $display = ( $section_name == $section ) ? 'block' : 'none';
505
-
506
- echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
507
- echo "\t\t<h2 class='long-header'>$title</h2>";
508
- echo $content;
509
- echo "\t</div>\n";
510
- }
511
-
512
- if (!empty($api->screenshots)) {
513
- $display = ( 'screenshots' == $section ) ? 'block' : 'none';
514
- echo "\t<div id='section-screenshots' class='section' style='display: {$display};'>\n";
515
- echo "\t\t<h2 class='long-header'>Screenshots</h2>\n";
516
- echo "\t\t<ol>\n";
517
- foreach ($api->screenshots as $data) {
518
- echo "\t\t\t<li><img src='{$data->location}' class='screenshot' /><p>{$data->caption}</p></li>\n";
519
- }
520
- echo "\t\t</ol>\n";
521
- echo "\t</div>\n";
522
- }
523
-
524
- echo "</div>\n";
525
-
526
- iframe_footer();
527
- die();
528
- }
529
-
530
- /**
531
- * Set the rating for a given plugin
532
- */
533
- public static function set_rating() {
534
- header('Content-Type: application/json; charset=utf-8');
535
- try {
536
- $rating = absint($_POST['rating']);
537
- Sputnik_API::rate_product($_POST['product'], $rating);
538
- echo json_encode(array('success' => true, 'rating' => $rating));
539
- }
540
- catch (Exception $e) {
541
- status_header(500);
542
- echo json_encode(array('success' => false, 'error' => $e->getMessage()));
543
- }
544
- die();
545
- }
546
-
547
- /**
548
- * Determine the action we can perform on a plugin
549
- *
550
- * @param stdClass $api API data
551
- * @param boolean $loop Prevents further loops when called recursively
552
- * @return array Keys 'status', 'url', 'version'
553
- */
554
- public static function install_status($api, $loop = false) {
555
- // Default to a "new" plugin
556
- $status = 'install';
557
- $url = false;
558
-
559
- // Check to see if this plugin is known to be installed, and has an update awaiting it.
560
- $update_plugins = get_site_transient('update_plugins');
561
- if (is_object($update_plugins) && isset($update_plugins->response)) {
562
- foreach ((array) $update_plugins->response as $file => $plugin) {
563
- if (!empty($plugin->sputnik_id) && $plugin->sputnik_id === $api->slug) {
564
- $status = 'update_available';
565
- $version = $plugin->new_version;
566
- if ( current_user_can('update_plugins') )
567
- $url = wp_nonce_url(self::build_url(array('upgrade' => $file)), 'sputnik_upgrade-plugin_' . $file);
568
- break;
569
- }
570
- }
571
- }
572
-
573
- if ('install' == $status) {
574
- $installed = get_plugins();
575
- $real = false;
576
- foreach ($installed as $plugin) {
577
- if (!empty($plugin['Sputnik ID']) && $plugin['Sputnik ID'] === $api->slug) {
578
- $real = $plugin;
579
- break;
580
- }
581
- }
582
-
583
- if ($real === false) {
584
- if (current_user_can('install_plugins')) {
585
- $url = wp_nonce_url(self::build_url(array('install' => $api->slug)), 'sputnik_install-plugin_' . $api->slug);
586
- }
587
- } else {
588
- if (version_compare($api->version, $plugin['Version'], '=')){
589
- $status = 'latest_installed';
590
- } elseif (version_compare($api->version, $plugin['Version'], '<')) {
591
- $status = 'newer_installed';
592
- $version = $plugin['Version'];
593
- } else {
594
- // If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
595
- if (!$loop) {
596
- delete_site_transient('update_plugins');
597
- wp_update_plugins();
598
- return self::install_status($api, true);
599
- }
600
-
601
- // Otherwise, we'll need to tell the user there's an update, though we have no idea how they can get it
602
- $status = 'update_available';
603
- }
604
- }
605
- }
606
-
607
- if (!Sputnik::is_purchased($api)) {
608
- $status = 'purchase';
609
- $url = wp_nonce_url(self::build_url(array('buy' => $api->slug)), 'sputnik_install-plugin_' . $api->slug);
610
- }
611
-
612
- if ( ! Sputnik::account_is_linked() )
613
- $url = self::build_url( array(
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');
622
- }
623
-
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(),
632
- 'account' => menu_page_url( 'sputnik-account', false ),
633
- );
634
-
635
- $current = self::$page;
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
-
647
- $account = false;
648
- try {
649
- $account = Sputnik::get_account();
650
- }
651
- catch (Exception $e) {
652
- if ($e->getCode() === 401) {
653
- delete_option('sputnik_oauth_access');
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
-
661
- self::header( $account );
662
-
663
- if ( Sputnik::account_is_linked() ) {
664
- self::auth();
665
- ?>
666
- <div class="account-card">
667
- <div class="block">
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
-
702
- try {
703
- $api_tags = Sputnik::get_tags();
704
-
705
- //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud()
706
- $tags = array();
707
- foreach ($api_tags as $tag) {
708
- $tags[ $tag->name ] = (object) array(
709
- 'link' => esc_url( self::build_url(array('tab' => 'search', 's' => urlencode($tag->name))) ),
710
- 'name' => $tag->name,
711
- 'id' => sanitize_title_with_dashes($tag->name),
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();
719
- }
720
- echo '</p><br class="clear" />';
721
- }
722
-
723
- public static function account() {
724
- self::$page = 'account';
725
- $account = false;
726
-
727
- try {
728
- $account = Sputnik::get_account();
729
- }
730
- catch (Exception $e) {
731
- if ($e->getCode() === 1) {
732
- $GLOBALS['tab'] = 'auth';
733
- return self::other_pages();
734
- }
735
- elseif ($e->getCode() === 401) {
736
- delete_option('sputnik_oauth_access');
737
- delete_option('sputnik_oauth_request');
738
- $GLOBALS['tab'] = 'auth';
739
- return self::other_pages();
740
- }
741
- else {
742
- self::header('Account', $account);
743
- echo '<p>' . sprintf(__('Problem: %s', 'wpsc'), $e->getMessage()) . '</p>';
744
-
745
- return;
746
- }
747
- }
748
-
749
- self::header('Account', $account);
750
- ?>
751
- <div class="account-card">
752
- <div class="block">
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
-
778
- /**
779
- * When a user clicks a plugin's "Buy Now" button, setup a payment flow.
780
- *
781
- * @param string $plugin_id
782
- */
783
- protected static function purchase( $plugin_id ) {
784
-
785
- $plugin = Sputnik::get_plugin( $plugin_id );
786
-
787
- if( Sputnik::is_purchased( $plugin->slug ) ) {
788
- wp_redirect( self::build_url( array( 'install' => $plugin_id ) ) );
789
- die();
790
- }
791
-
792
- // Request a checkout token from the Baikonur REST API for this product (associate user ID in custom field?)
793
- $response = Sputnik_API::get_checkout_token( $plugin );
794
-
795
- // Redirect to PayPal with token in checkout URL
796
- wp_redirect( $response['body']->checkout_uri );
797
- exit;
798
- }
799
-
800
- /**
801
- * When a user returns from the server after making a payment, update their account,
802
- * close the PayPal iframe & redirect to the installation page for the plugin they
803
- * just purchased.
804
- *
805
- * @param string $product_slug the slug of the product just purchased
806
- */
807
- protected static function paid( $product_slug ) {
808
-
809
- check_admin_referer( 'sputnik_install-plugin_' . $product_slug );
810
-
811
- // Update Sputnik account to include newly purchased plugin
812
- Sputnik::update_account();
813
-
814
- $install_url = self::build_url(array('install' => $product_slug));
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
- /**
822
- * When a user cancels a payment, we need to close the PayPal iframe & redirect
823
- * back to Sputnik with a notice.
824
- *
825
- * @param string $plugin_id the slug of the plugin just purchased
826
- */
827
- protected static function cancel_payment() {
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();
847
- }
848
-
849
- if (!Sputnik::is_purchased($api->slug)) {
850
- wp_redirect(self::build_url(array('buy' => $id)));
851
- die();
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
-
859
- check_admin_referer('sputnik_install-plugin_' . $api->slug);
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();
902
- }
903
-
904
- if (!Sputnik::is_purchased($id)) {
905
- wp_redirect(self::build_url(array('buy' => $id)));
906
- die();
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
-
914
- check_admin_referer('sputnik_upgrade-plugin_' . $file);
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']) )
924
- $url .= '&from=' . urlencode(stripslashes($_GET['from']));
925
-
926
- $type = 'web'; //Install plugin type, From Web or an Upload.
927
- $plugin = $id;
928
-
929
- if ( $api->is_theme )
930
- $upgrader = new Sputnik_ThemeUpgrader( new Sputnik_Upgrader_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
931
- else
932
- $upgrader = new Sputnik_Upgrader( new Sputnik_Upgrader_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
933
-
934
- $upgrader->upgrade($file);
935
-
936
- iframe_footer();
937
- die();
938
- }
939
-
940
- public static function search_form(){
941
- $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
942
- $term = isset($_REQUEST['s']) ? esc_attr($_REQUEST['s']) : '';
943
-
944
- ?><form id="search-plugins" method="get" action="">
945
- <input type="hidden" name="page" value="sputnik" />
946
- <input type="hidden" name="post_type" value="wpsc-product" />
947
- <input type="hidden" name="tab" value="search" />
948
- <input type="text" name="s" value="<?php echo esc_attr($term) ?>" />
949
- <?php submit_button( __( 'Search Plugins' ), 'button', '', false ); ?>
950
- </form><?php
951
- }
952
-
953
- /**
954
- * When a user cancels a payment or returns after making a payment, we need to
955
- * close the PayPal iframe.
956
- *
957
- * @param string $redirect_url The URL to load in the parent window.
958
- * @param string $title optional The title attribute for the page.
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>
966
- <head>
967
- <title><?php echo $title; ?></title>
968
- <script type="text/javascript">if (window!=top) {top.location.replace("<?php echo $redirect_url; ?>");}</script>
969
- </head>
970
- <body>&nbsp;</body>
971
- </html>
972
- <?php
973
- die();
974
- }
975
-
976
- public static function maybe_redirect_update() {
977
- if (empty($_GET['action']) || $_GET['action'] !== 'upgrade-plugin' || empty($_REQUEST['plugin'])) {
978
- return;
979
- }
980
- $file = trim($_REQUEST['plugin']);
981
-
982
- $data = Sputnik::get_from_file($file);
983
- if ($data === null || empty($data['Sputnik ID'])) {
984
- return;
985
- }
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();
993
- }
994
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Library/Plugin.php DELETED
@@ -1,128 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * A new way of using the WordPress API
5
- *
6
- * @package Sputnik
7
- * @subpackage Public Utilities
8
- */
9
- class Sputnik_Library_Plugin extends Sputnik_Library_Plugin_Base {
10
- /**
11
- * Register hooks automatically
12
- *
13
- * Ensure you call this from your child class
14
- *
15
- * @param boolean $enable_prefixes Whether to enable prefixed methods (i.e. `action_init` or `filter_the_title`)
16
- */
17
- protected static function register_hooks($enable_prefixes = false) {
18
- if (function_exists('get_called_class') && false) {
19
- $class = get_called_class();
20
- }
21
- else {
22
- $trace = debug_backtrace();
23
- $class = $trace[1]['class'];
24
- }
25
- self::_register_hooks($enable_prefixes, $class);
26
- }
27
-
28
- /**
29
- * Add a method as a filter
30
- *
31
- * This is exactly the same as {@see add_filter()} but instead of passing
32
- * a full callback, only the method needs to be passed in.
33
- *
34
- * @param string $hook Filter name
35
- * @param string $method Method name on current class, or priority (as an int)
36
- * @param int $priority Specify the order in which the functions associated with a particular action are executed (default: 10)
37
- * @param int $accepted_args Number of parameters which callback accepts (default: corresponds to method prototype)
38
- * @param string $class Internal use only
39
- */
40
- protected static function add_filter($hook, $method = null, $priority = 10, $params = null, $class = null) {
41
- if ($method === null) {
42
- $method = $hook;
43
- }
44
- elseif (is_int($method)) {
45
- $priority = $method;
46
- $method = $hook;
47
- }
48
-
49
- if ($class === null) {
50
- if (function_exists('get_called_class') && false) {
51
- $class = get_called_class();
52
- }
53
- else {
54
- $trace = debug_backtrace();
55
- do {
56
- array_shift($trace);
57
- }
58
- while (empty($trace[0]['class']) && !empty($trace));
59
- if (empty($trace)) {
60
- throw new BadMethodCallException('Must be called from a class');
61
- }
62
- $class = $trace[0]['class'];
63
- }
64
- }
65
-
66
- if (!method_exists($class, $method)) {
67
- throw new InvalidArgumentException('Method does not exist');
68
- }
69
-
70
- if ($params === null) {
71
- $ref = new ReflectionMethod($class, $method);
72
- $params = $ref->getNumberOfParameters();
73
- }
74
-
75
- return add_filter($hook, array($class, $method), $priority, $params);
76
- }
77
-
78
- /**
79
- * Add a method as a action
80
- *
81
- * This is exactly the same as {@see add_action()} but instead of passing
82
- * a full callback, only the method needs to be passed in.
83
- *
84
- * @internal This is duplication, but ensures consistency with WordPress API
85
- * @param string $hook Action name
86
- * @param string $method Method name on current class, or priority (as an int)
87
- * @param int $priority Specify the order in which the functions associated with a particular action are executed (default: 10)
88
- * @param int $accepted_args Number of parameters which callback accepts (default: corresponds to method prototype)
89
- * @param string $class Internal use only
90
- */
91
- protected static function add_action($hook, $method = null, $priority = 10, $params = null, $class = null) {
92
- if ($method === null) {
93
- $method = $hook;
94
- }
95
- elseif (is_int($method)) {
96
- $priority = $method;
97
- $method = $hook;
98
- }
99
-
100
- if ($class === null) {
101
- if (function_exists('get_called_class') && false) {
102
- $class = get_called_class();
103
- }
104
- else {
105
- $trace = debug_backtrace();
106
- do {
107
- array_shift($trace);
108
- }
109
- while (empty($trace[0]['class']) && !empty($trace));
110
- if (empty($trace)) {
111
- throw new BadMethodCallException('Must be called from a class');
112
- }
113
- $class = $trace[0]['class'];
114
- }
115
- }
116
-
117
- if (!method_exists($class, $method)) {
118
- throw new InvalidArgumentException('Method does not exist');
119
- }
120
-
121
- if ($params === null) {
122
- $ref = new ReflectionMethod($class, $method);
123
- $params = $ref->getNumberOfParameters();
124
- }
125
-
126
- return add_action($hook, array($class, $method), $priority, $params);
127
- }
128
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Library/Plugin/Base.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * A new way of using the WordPress API
5
- *
6
- * @package Sputnik
7
- * @subpackage Public Utilities
8
- */
9
- class Sputnik_Library_Plugin_Base {
10
- /**
11
- * Register hooks
12
- *
13
- * @see Sputnik_Library_Plugin::register_hooks
14
- * @see Sputnik_Library_Plugin_Dynamic::register_hooks
15
- * @param boolean|array $prefixes True for default (`action_`/`filter_`), array with keys "action" & "filter" or false
16
- * @param string|object $parent Object to register from
17
- */
18
- public static function _register_hooks($prefixes, $parent) {
19
- $is_sane = self::check_eaccelerator_saneness();
20
- if (!$is_sane) {
21
- // This will be replaced with something better soon
22
- throw new Exception('eAccelerator is configured to strip doc comments, cannot continue');
23
- }
24
-
25
- $enable_prefixes = true;
26
- if ($prefixes === false) {
27
- $enable_prefixes = false;
28
- }
29
- elseif ($prefixes === true) {
30
- $prefixes = array('filter' => 'filter_', 'action' => 'action_');
31
- }
32
-
33
- $self = new ReflectionClass($parent);
34
- foreach ($self->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
35
- $params = $method->getNumberOfParameters();
36
- $doc = $method->getDocComment();
37
- if (!empty($doc) && preg_match('#^\s+\*\s*@wp-nohook#im', $doc) !== 0) {
38
- continue;
39
- }
40
-
41
- $hooks = array('filter' => array(), 'action' => array());
42
-
43
- if ($enable_prefixes === true) {
44
- // If either prefix is blank, always hook
45
- if ($prefixes['filter'] === '' || $prefixes['action'] === '') {
46
- $hooks['filter'][$method->name] = 10;
47
- }
48
-
49
- // Method starts with filter prefix
50
- elseif ($enable_prefixes === true && strpos($method->name, $prefixes['filter']) === 0) {
51
- $hook = substr($method->name, strlen($prefixes['filter']));
52
- $hooks['action'][$hook] = 10;
53
- }
54
-
55
- // Method starts with action prefix
56
- elseif ($enable_prefixes === true && strpos($method->name, $prefixes['action']) === 0) {
57
- $hook = substr($method->name, strlen($prefixes['action']));
58
- $hooks['action'][$hook] = 10;
59
- }
60
- }
61
-
62
- // If we haven't hooked anything yet, check phpdoc
63
- if (empty($hooks['filter']) && empty($hooks['action'])) {
64
- if (empty($doc) || (strpos($doc, '@wp-filter') === false && strpos($doc, '@wp-action') === false)) {
65
- continue;
66
- }
67
-
68
- preg_match_all('#^\s+\*\s*@wp-(action|filter)\s+([\w-]+)(\s*\d+)?#im', $doc, $matches, PREG_SET_ORDER);
69
- if (empty($matches)) {
70
- continue;
71
- }
72
- foreach ($matches as $match) {
73
- $type = $match[1];
74
- $hook = $match[2];
75
- $priority = 10;
76
- if (!empty($match[3])) {
77
- $priority = (int) $match[3];
78
- }
79
-
80
- $hooks[$type][$hook] = $priority;
81
- }
82
- }
83
-
84
- foreach ($hooks['filter'] as $hook => $priority) {
85
- call_user_func(array($parent, 'add_filter'), $hook, $method->name, $priority, $params, $parent);
86
- }
87
- foreach ($hooks['action'] as $hook => $priority) {
88
- call_user_func(array($parent, 'add_action'), $hook, $method->name, $priority, $params, $parent);
89
- }
90
- }
91
- }
92
-
93
- /**
94
- * Check if eAccelerator is loaded, and if so, is sane
95
- *
96
- * @internal If you can find me, it's sane.
97
- * @return boolean True if doc comments are fine, false otherwise
98
- */
99
- private static function check_eaccelerator_saneness() {
100
- if (!extension_loaded('eaccelerator') && !extension_loaded('eAccelerator')) {
101
- return true;
102
- }
103
-
104
- $method = new ReflectionMethod('Sputnik_Library_Plugin_Base', 'check_eaccelerator_saneness');
105
- $comment = $method->getDocComment();
106
-
107
- return (strpos($comment, "If you can find me, it's sane.") !== false);
108
- }
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Library/Plugin/Dynamic.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * A new way of using the WordPress API
5
- *
6
- * @package Sputnik
7
- * @subpackage Public Utilities
8
- */
9
- class Sputnik_Library_Plugin extends Sputnik_Library_Plugin_Base {
10
- /**
11
- * Register hooks
12
- *
13
- * Ensure you call this from your child class
14
- *
15
- * @param boolean $enable_prefixes Whether to enable prefixed methods (i.e. `action_init` or `filter_the_title`)
16
- */
17
- protected function register_hooks($enable_prefixes = false) {
18
- $this->_register_hooks($enable_prefixes, $this);
19
- }
20
-
21
- /**
22
- * Add a method as a filter
23
- *
24
- * This is exactly the same as {@see add_filter()} but instead of passing
25
- * a full callback, only the method needs to be passed in.
26
- *
27
- * @param string $hook Filter name
28
- * @param string $method Method name on current class, or priority (as an int)
29
- * @param int $priority Specify the order in which the functions associated with a particular action are executed (default: 10)
30
- * @param int $accepted_args Number of parameters which callback accepts (default: corresponds to method prototype)
31
- */
32
- protected function add_filter($hook, $method = null, $priority = 10, $params = null) {
33
- if ($method === null) {
34
- $method = $hook;
35
- }
36
- elseif (is_int($method)) {
37
- $priority = $method;
38
- $method = $hook;
39
- }
40
-
41
- if (!method_exists($this, $method)) {
42
- throw new InvalidArgumentException('Method does not exist');
43
- }
44
-
45
- if ($params === null) {
46
- $ref = new ReflectionMethod($this, $method);
47
- $params = $ref->getNumberOfParameters();
48
- }
49
-
50
- return add_filter($hook, array($this, $method), $priority, $params);
51
- }
52
-
53
- /**
54
- * Add a method as a action
55
- *
56
- * This is exactly the same as {@see add_action()} but instead of passing
57
- * a full callback, only the method needs to be passed in.
58
- *
59
- * @internal This is duplication, but ensures consistency with WordPress API
60
- * @param string $hook Action name
61
- * @param string|int $method Method name on current class, or priority (as an int)
62
- * @param int $priority Specify the order in which the functions associated with a particular action are executed (default: 10)
63
- * @param int $accepted_args Number of parameters which callback accepts (default: corresponds to method prototype)
64
- */
65
- protected function add_action($hook, $method = null, $priority = 10, $params = null) {
66
- if ($method === null) {
67
- $method = $hook;
68
- }
69
- elseif (is_int($method)) {
70
- $priority = $method;
71
- $method = $hook;
72
- }
73
-
74
- if (!method_exists($this, $method)) {
75
- throw new InvalidArgumentException('Method does not exist');
76
- }
77
-
78
- if ($params === null) {
79
- $ref = new ReflectionMethod($this, $method);
80
- $params = $ref->getNumberOfParameters();
81
- }
82
-
83
- return add_action($hook, array($this, $method), $priority, $params);
84
- }
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Library/TwitterOAuth.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Twitter OAuth library, based on Abraham Williams'
5
- *
6
- * This class extends the original and replaces OAuth* classes with
7
- * Sputnik_OAuth_* classes, in addition to adapting it for WP_Http
8
- *
9
- * @package Sputnik
10
- * @subpackage Public Utilities
11
- */
12
- class Sputnik_Library_TwitterOAuth extends Sputnik_Library_TwitterOAuth_Internal {
13
-
14
- /**
15
- * construct TwitterOAuth object
16
- * @internal Converted OAuth* to Sputnik_OAuth_*
17
- */
18
- function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
19
- $this->sha1_method = new Sputnik_OAuth_SignatureMethod_HMAC_SHA1();
20
- $this->consumer = new Sputnik_OAuth_Consumer($consumer_key, $consumer_secret);
21
- if (!empty($oauth_token) && !empty($oauth_token_secret)) {
22
- $this->token = new Sputnik_OAuth_Consumer($oauth_token, $oauth_token_secret);
23
- } else {
24
- $this->token = NULL;
25
- }
26
- }
27
-
28
-
29
- /**
30
- * Get a request_token from Twitter
31
- *
32
- * @internal Converted OAuth* to Sputnik_OAuth_*
33
- * @returns a key/value array containing oauth_token and oauth_token_secret
34
- */
35
- function getRequestToken($oauth_callback = NULL) {
36
- $parameters = array();
37
- if (!empty($oauth_callback)) {
38
- $parameters['oauth_callback'] = $oauth_callback;
39
- }
40
- $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
41
- $token = Sputnik_OAuth_Util::parse_parameters($request);
42
- $this->token = new Sputnik_OAuth_Consumer($token['oauth_token'], $token['oauth_token_secret']);
43
- return $token;
44
- }
45
-
46
- /**
47
- * Exchange request token and secret for an access token and
48
- * secret, to sign API calls.
49
- *
50
- * @internal Converted OAuth* to Sputnik_OAuth_*
51
- * @returns array("oauth_token" => "the-access-token",
52
- * "oauth_token_secret" => "the-access-secret",
53
- * "user_id" => "9436992",
54
- * "screen_name" => "abraham")
55
- */
56
- function getAccessToken($oauth_verifier = FALSE) {
57
- $parameters = array();
58
- if (!empty($oauth_verifier)) {
59
- $parameters['oauth_verifier'] = $oauth_verifier;
60
- }
61
- $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
62
- $token = Sputnik_OAuth_Util::parse_parameters($request);
63
- $this->token = new Sputnik_OAuth_Consumer($token['oauth_token'], $token['oauth_token_secret']);
64
- return $token;
65
- }
66
-
67
- /**
68
- * One time exchange of username and password for access token and secret.
69
- *
70
- * @internal Converted OAuth* to Sputnik_OAuth_*
71
- * @returns array("oauth_token" => "the-access-token",
72
- * "oauth_token_secret" => "the-access-secret",
73
- * "user_id" => "9436992",
74
- * "screen_name" => "abraham",
75
- * "x_auth_expires" => "0")
76
- */
77
- function getXAuthToken($username, $password) {
78
- $parameters = array();
79
- $parameters['x_auth_username'] = $username;
80
- $parameters['x_auth_password'] = $password;
81
- $parameters['x_auth_mode'] = 'client_auth';
82
- $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
83
- $token = Sputnik_OAuth_Util::parse_parameters($request);
84
- $this->token = new Sputnik_OAuth_Consumer($token['oauth_token'], $token['oauth_token_secret']);
85
- return $token;
86
- }
87
-
88
- /**
89
- * Format and sign an OAuth / API request
90
- *
91
- * @internal Converted OAuth* to Sputnik_OAuth_*
92
- */
93
- function oAuthRequest($url, $method, $parameters) {
94
- if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
95
- $url = "{$this->host}{$url}.{$this->format}";
96
- }
97
- $request = Sputnik_OAuth_Request::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
98
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
99
- switch ($method) {
100
- case 'GET':
101
- return $this->http($request->to_url(), 'GET');
102
- default:
103
- return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
104
- }
105
- }
106
-
107
- /**
108
- * Make an HTTP request
109
- *
110
- * @internal Adapted for WP_Http
111
- * @return API results
112
- */
113
- function http($url, $method, $postfields = NULL) {
114
- $this->http_info = null; // this is never used
115
- $options = array(
116
- 'method' => $method,
117
- 'timeout' => $this->timeout,
118
- 'user-agent' => $this->useragent,
119
- 'sslverify' => $this->ssl_verifypeer
120
- );
121
-
122
- switch ($method) {
123
- case 'POST':
124
- if (!empty($postfields)) {
125
- $options['body'] = $postfields;
126
- }
127
- break;
128
- case 'DELETE':
129
- if (!empty($postfields)) {
130
- $url = "{$url}?{$postfields}";
131
- }
132
- }
133
-
134
- $response = wp_remote_request($url, $options);
135
-
136
- if (is_wp_error($response)) {
137
- $this->http_code = null;
138
- $this->http_header = array();
139
- return false;
140
- }
141
-
142
- $this->http_code = $response['response']['code'];
143
- $this->http_header = $response['headers'];
144
-
145
- return $response['body'];
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Library/TwitterOAuth/Internal.php DELETED
@@ -1,242 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Abraham Williams (abraham@abrah.am) http://abrah.am
5
- *
6
- * The first PHP Library to support OAuth for Twitter's REST API.
7
- */
8
-
9
- /**
10
- * Twitter OAuth class
11
- */
12
- class Sputnik_Library_TwitterOAuth_Internal {
13
- /* Contains the last HTTP status code returned. */
14
- public $http_code;
15
- /* Contains the last API call. */
16
- public $url;
17
- /* Set up the API root URL. */
18
- public $host = "https://api.twitter.com/1/";
19
- /* Set timeout default. */
20
- public $timeout = 30;
21
- /* Set connect timeout. */
22
- public $connecttimeout = 30;
23
- /* Verify SSL Cert. */
24
- public $ssl_verifypeer = FALSE;
25
- /* Respons format. */
26
- public $format = 'json';
27
- /* Decode returned json data. */
28
- public $decode_json = TRUE;
29
- /* Contains the last HTTP headers returned. */
30
- public $http_info;
31
- /* Set the useragnet. */
32
- public $useragent = 'TwitterOAuth v0.2.0-beta2';
33
- /* Immediately retry the API call if the response was not successful. */
34
- //public $retry = TRUE;
35
-
36
-
37
-
38
-
39
- /**
40
- * Set API URLS
41
- */
42
- function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
43
- function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
44
- function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
45
- function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
46
-
47
- /**
48
- * Debug helpers
49
- */
50
- function lastStatusCode() { return $this->http_status; }
51
- function lastAPICall() { return $this->last_api_call; }
52
-
53
- /**
54
- * construct TwitterOAuth object
55
- */
56
- function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
57
- $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
58
- $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
59
- if (!empty($oauth_token) && !empty($oauth_token_secret)) {
60
- $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
61
- } else {
62
- $this->token = NULL;
63
- }
64
- }
65
-
66
-
67
- /**
68
- * Get a request_token from Twitter
69
- *
70
- * @returns a key/value array containing oauth_token and oauth_token_secret
71
- */
72
- function getRequestToken($oauth_callback = NULL) {
73
- $parameters = array();
74
- if (!empty($oauth_callback)) {
75
- $parameters['oauth_callback'] = $oauth_callback;
76
- }
77
- $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
78
- $token = OAuthUtil::parse_parameters($request);
79
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
80
- return $token;
81
- }
82
-
83
- /**
84
- * Get the authorize URL
85
- *
86
- * @returns a string
87
- */
88
- function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
89
- if (is_array($token)) {
90
- $token = $token['oauth_token'];
91
- }
92
- if (empty($sign_in_with_twitter)) {
93
- return $this->authorizeURL() . "?oauth_token={$token}";
94
- } else {
95
- return $this->authenticateURL() . "?oauth_token={$token}";
96
- }
97
- }
98
-
99
- /**
100
- * Exchange request token and secret for an access token and
101
- * secret, to sign API calls.
102
- *
103
- * @returns array("oauth_token" => "the-access-token",
104
- * "oauth_token_secret" => "the-access-secret",
105
- * "user_id" => "9436992",
106
- * "screen_name" => "abraham")
107
- */
108
- function getAccessToken($oauth_verifier = FALSE) {
109
- $parameters = array();
110
- if (!empty($oauth_verifier)) {
111
- $parameters['oauth_verifier'] = $oauth_verifier;
112
- }
113
- $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
114
- $token = OAuthUtil::parse_parameters($request);
115
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
116
- return $token;
117
- }
118
-
119
- /**
120
- * One time exchange of username and password for access token and secret.
121
- *
122
- * @returns array("oauth_token" => "the-access-token",
123
- * "oauth_token_secret" => "the-access-secret",
124
- * "user_id" => "9436992",
125
- * "screen_name" => "abraham",
126
- * "x_auth_expires" => "0")
127
- */
128
- function getXAuthToken($username, $password) {
129
- $parameters = array();
130
- $parameters['x_auth_username'] = $username;
131
- $parameters['x_auth_password'] = $password;
132
- $parameters['x_auth_mode'] = 'client_auth';
133
- $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
134
- $token = OAuthUtil::parse_parameters($request);
135
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
136
- return $token;
137
- }
138
-
139
- /**
140
- * GET wrapper for oAuthRequest.
141
- */
142
- function get($url, $parameters = array()) {
143
- $response = $this->oAuthRequest($url, 'GET', $parameters);
144
- if ($this->format === 'json' && $this->decode_json) {
145
- return json_decode($response);
146
- }
147
- return $response;
148
- }
149
-
150
- /**
151
- * POST wrapper for oAuthRequest.
152
- */
153
- function post($url, $parameters = array()) {
154
- $response = $this->oAuthRequest($url, 'POST', $parameters);
155
- if ($this->format === 'json' && $this->decode_json) {
156
- return json_decode($response);
157
- }
158
- return $response;
159
- }
160
-
161
- /**
162
- * DELETE wrapper for oAuthReqeust.
163
- */
164
- function delete($url, $parameters = array()) {
165
- $response = $this->oAuthRequest($url, 'DELETE', $parameters);
166
- if ($this->format === 'json' && $this->decode_json) {
167
- return json_decode($response);
168
- }
169
- return $response;
170
- }
171
-
172
- /**
173
- * Format and sign an OAuth / API request
174
- */
175
- function oAuthRequest($url, $method, $parameters) {
176
- if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
177
- $url = "{$this->host}{$url}.{$this->format}";
178
- }
179
- $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
180
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
181
- switch ($method) {
182
- case 'GET':
183
- return $this->http($request->to_url(), 'GET');
184
- default:
185
- return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
186
- }
187
- }
188
-
189
- /**
190
- * Make an HTTP request
191
- *
192
- * @return API results
193
- */
194
- function http($url, $method, $postfields = NULL) {
195
- $this->http_info = array();
196
- $ci = curl_init();
197
- /* Curl settings */
198
- curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
199
- curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
200
- curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
201
- curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
202
- curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
203
- curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
204
- curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
205
- curl_setopt($ci, CURLOPT_HEADER, FALSE);
206
-
207
- switch ($method) {
208
- case 'POST':
209
- curl_setopt($ci, CURLOPT_POST, TRUE);
210
- if (!empty($postfields)) {
211
- curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
212
- }
213
- break;
214
- case 'DELETE':
215
- curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
216
- if (!empty($postfields)) {
217
- $url = "{$url}?{$postfields}";
218
- }
219
- }
220
-
221
- curl_setopt($ci, CURLOPT_URL, $url);
222
- $response = curl_exec($ci);
223
- $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
224
- $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
225
- $this->url = $url;
226
- curl_close ($ci);
227
- return $response;
228
- }
229
-
230
- /**
231
- * Get the header info to store.
232
- */
233
- function getHeader($ch, $header) {
234
- $i = strpos($header, ':');
235
- if (!empty($i)) {
236
- $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
237
- $value = trim(substr($header, $i + 2));
238
- $this->http_header[$key] = $value;
239
- }
240
- return strlen($header);
241
- }
242
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Library/TwitterOAuth/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2009 Abraham Williams - http://abrah.am - abraham@poseurte.ch
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/List/Account.php DELETED
@@ -1,162 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_List_Account extends Sputnik_List_Install {
4
- protected $view = 'grid';
5
- protected $connect_error = false;
6
-
7
- public function prepare_items() {
8
- require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
9
-
10
- global $tabs, $tab, $paged, $type, $term;
11
-
12
- wp_reset_vars( array( 'tab' ) );
13
-
14
- $paged = $this->get_pagenum();
15
-
16
- // These are the tabs which are shown on the page
17
- $tabs = array();
18
- $tabs['purchased'] = __( 'Purchased Plugins', 'wpsc' );
19
- $tabs['yours'] = __( 'Your Plugins', 'wpsc' );
20
-
21
- $nonmenu_tabs = array( ); //Valid actions to perform which do not have a Menu item.
22
-
23
- $tabs = apply_filters( 'install_plugins_tabs', $tabs );
24
- $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
25
-
26
- // If a non-valid menu tab has been selected, and its not a non-menu action.
27
- if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
28
- $tab = key( $tabs );
29
-
30
- $args = array();
31
-
32
- try {
33
- switch ( $tab ) {
34
- case 'yours':
35
- add_filter('sputnik_install_row_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
36
- add_filter('sputnik_install_grid_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
37
- $api = Sputnik_API::get_own();
38
- break;
39
-
40
- default:
41
- case 'purchased':
42
- $api = Sputnik_API::get_purchased();
43
- break;
44
- }
45
- }
46
- catch (Exception $e) {
47
- $this->connect_error = true;
48
- return false;
49
- }
50
-
51
- if (!empty($_REQUEST['view'])) {
52
- switch ($_REQUEST['view']) {
53
- case 'grid':
54
- case 'list':
55
- $this->view = $_REQUEST['view'];
56
- break;
57
- default:
58
- $this->view = 'grid';
59
- break;
60
- }
61
- } else {
62
- $this->view = 'grid';
63
- }
64
-
65
- $this->items = $api['body'];
66
-
67
- if (isset($api['headers']['x-pagecount'])) {
68
- $this->set_pagination_args( array(
69
- 'total_items' => $api['headers']['x-pagecount'],
70
- 'per_page' => 30,
71
- ) );
72
- }
73
- }
74
-
75
- public function no_items() {
76
- global $tab;
77
- echo '<p>';
78
- if ($tab === 'yours') {
79
- _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' );
80
- }
81
- else {
82
- printf(__( "You haven't purchased any plugins yet. Why not <a href='%s'>buy some</a>?", 'wpsc' ), Sputnik_Admin::build_url());
83
- }
84
- echo '</p>';
85
- }
86
-
87
- public function get_views() {
88
- global $tabs, $tab;
89
-
90
- $display_tabs = array();
91
- foreach ( (array) $tabs as $action => $text ) {
92
- $class = ( $action == $tab ) ? ' class="current"' : '';
93
- $bits = array('tab' => $action);
94
- if ($this->view !== 'grid') {
95
- $bits['view'] = $this->view;
96
- }
97
- $href = Sputnik_Admin::build_account_url($bits);
98
- $display_tabs['plugin-install-'.$action] = "<a href='$href'$class>$text</a>";
99
- }
100
-
101
- return $display_tabs;
102
- }
103
-
104
- public function display_grid() {
105
- extract( $this->_args );
106
-
107
- $this->display_tablenav( 'top' );
108
- ?>
109
- <div class="grid-view">
110
- <?php
111
- $this->display_rows_or_placeholder();
112
- ?>
113
- </div>
114
- <?php
115
- $this->display_tablenav( 'bottom' );
116
- }
117
-
118
- public function display_tablenav( $which ) {
119
- global $tab;
120
-
121
- if ($tab === 'account')
122
- return;
123
-
124
- $account = Sputnik::get_account();
125
- if ( 'top' == $which ) { ?>
126
- <div class="tablenav top">
127
- <div class="alignright actions">
128
- <?php
129
- switch ($this->view) {
130
- case 'list':
131
- $view = 'grid';
132
- $name = __('Grid', 'wpsc' );
133
- break;
134
- case 'grid':
135
- $view = 'list';
136
- $name = __('List', 'wpsc' );
137
- break;
138
- }
139
- ?>
140
- <!-- <a href="<?php echo add_query_arg('view', $view) ?>" class="view-as-<?php echo $view; ?> button"><?php echo $name ?></a> -->
141
- </div>
142
- <?php
143
- $this->pagination($which);
144
- ?>
145
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-loading list-ajax-loading" alt="" />
146
- <br class="clear" />
147
- </div>
148
- <?php } else { ?>
149
- <div class="tablenav bottom">
150
- <?php $this->pagination($which); ?>
151
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-loading list-ajax-loading" alt="" />
152
- <br class="clear" />
153
- </div>
154
- <?php
155
- }
156
- }
157
-
158
- public static function mangle_action_for_own($actions, $plugin) {
159
- $actions[] = sprintf('<a href="%s" class="button edit">%s</a>', sprintf(Sputnik::SITE_BASE . '/your-products/edit/%d', $plugin->product_id), _x('Edit', 'edit own product', 'wpsc' ));
160
- return $actions;
161
- }
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/List/Install.php DELETED
@@ -1,470 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_List_Install extends WP_List_Table {
4
- protected $view = 'grid';
5
- protected $connect_error = false;
6
-
7
- public function ajax_user_can() {
8
- return current_user_can('install_plugins');
9
- }
10
-
11
- public function prepare_items() {
12
- require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
13
-
14
- global $tabs, $tab, $paged, $type, $term;
15
-
16
- wp_reset_vars( array( 'tab' ) );
17
-
18
- $paged = $this->get_pagenum();
19
-
20
- // These are the tabs which are shown on the page
21
- $tabs = array();
22
- $tabs['dashboard'] = __( 'Search', 'wpsc' );
23
-
24
- if ( Sputnik::account_is_linked() ) {
25
- $tabs['purchased'] = __( 'Purchased Plugins', 'wpsc' );
26
- } elseif ( $tab == 'purchased' ) {
27
- wp_redirect( Sputnik_Admin::build_url() );
28
- exit;
29
- }
30
-
31
- if ( 'search' == $tab )
32
- $tabs['search'] = __( 'Search Results', 'wpsc' );
33
- $tabs['featured'] = _x( 'Featured', 'Plugin Installer', 'wpsc' );
34
- $tabs['popular'] = _x( 'Popular', 'Plugin Installer', 'wpsc' );
35
- $tabs['new'] = _x( 'Newest', 'Plugin Installer', 'wpsc' );
36
- $tabs['updated'] = _x( 'Recently Updated', 'Plugin Installer', 'wpsc' );
37
- $tabs['price'] = _x( 'Lowest Priced', 'Plugin Installer', 'wpsc' );
38
-
39
- $nonmenu_tabs = array( 'account' ); //Valid actions to perform which do not have a Menu item.
40
-
41
- $tabs = apply_filters( 'install_plugins_tabs', $tabs );
42
- $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
43
-
44
- // If a non-valid menu tab has been selected, and its not a non-menu action.
45
- if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
46
- $tab = key( $tabs );
47
-
48
- $args = array();
49
-
50
- try {
51
- switch ( $tab ) {
52
- case 'purchased':
53
- $api = Sputnik_API::get_purchased();
54
- break;
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':
62
- $api = Sputnik_API::get_purchased();
63
- break;
64
-
65
- case 'featured':
66
- case 'popular':
67
- case 'new':
68
- case 'updated':
69
- case 'price':
70
- default:
71
- $api = Sputnik_API::get_all($paged, array('browse' => $tab));
72
- break;
73
- }
74
- }
75
- catch (Exception $e) {
76
- $this->connect_error = true;
77
- return false;
78
- }
79
-
80
- if (!empty($_REQUEST['view'])) {
81
- switch ($_REQUEST['view']) {
82
- case 'grid':
83
- case 'list':
84
- $this->view = $_REQUEST['view'];
85
- break;
86
- default:
87
- $this->view = 'grid';
88
- break;
89
- }
90
- } else {
91
- $this->view = 'grid';
92
- }
93
-
94
- $this->items = $api['body'];
95
-
96
- $total_items = isset( $api['headers']['x-pagecount'] ) ? $api['headers']['x-pagecount'] : -1;
97
-
98
- $this->set_pagination_args( array(
99
- 'total_items' => $total_items,
100
- 'per_page' => 30,
101
- ) );
102
- }
103
-
104
- public function no_items() {
105
- global $tab;
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>';
113
- }
114
-
115
- public function get_views() {
116
- global $tabs, $tab;
117
-
118
- $display_tabs = array();
119
- foreach ( (array) $tabs as $action => $text ) {
120
- $class = ( $action == $tab ) ? ' class="current"' : '';
121
- $bits = array('tab' => $action);
122
- if ($this->view !== 'grid') {
123
- $bits['view'] = $this->view;
124
- }
125
- $href = Sputnik_Admin::build_url($bits);
126
- $display_tabs['plugin-install-'.$action] = "<a href='$href'$class>$text</a>";
127
- }
128
-
129
- return $display_tabs;
130
- }
131
-
132
- public function display() {
133
- if ($this->connect_error) {
134
- ?>
135
- <div class="connect-error">
136
- <h2>Whoops!</h2>
137
- <p>We don't appear to be able to connect to the WPEConomy server right now.
138
- Try again later!</p>
139
- </div>
140
- <?php
141
- return;
142
- }
143
- switch ($this->view) {
144
- case 'list':
145
- parent::display();
146
- break;
147
- default:
148
- $this->display_grid();
149
- break;
150
- }
151
- }
152
-
153
- public function display_grid() {
154
-
155
- $this->display_tablenav( 'top' );
156
- ?>
157
- <div class="grid-view">
158
- <?php
159
- $this->display_rows_or_placeholder();
160
- ?>
161
- </div>
162
- <?php
163
- $this->display_tablenav( 'bottom' );
164
- }
165
-
166
- public function display_tablenav( $which ) {
167
- global $tab;
168
-
169
- if ($tab === 'account')
170
- return;
171
-
172
- if ( ! Sputnik::account_is_linked() )
173
- return;
174
-
175
- $account = Sputnik::get_account();
176
- if ( 'top' == $which ) { ?>
177
- <div class="tablenav top">
178
- <div class="alignright actions">
179
- <?php
180
- if ( in_array( $tab, array( 'dashboard', 'search' ) ) ) {
181
- ?>
182
- <?php Sputnik_Admin::search_form(); ?>
183
- <?php
184
- }
185
-
186
- switch ($this->view) {
187
- case 'list':
188
- $view = 'grid';
189
- $name = __('Grid', 'wpsc' );
190
- break;
191
- case 'grid':
192
- $view = 'list';
193
- $name = __('List', 'wpsc' );
194
- break;
195
- }
196
- ?>
197
- <!--<a href="<?php echo add_query_arg('view', $view) ?>" class="view-as-<?php echo $view; ?> button"><?php echo $name ?></a>-->
198
- </div>
199
- <?php
200
- $this->pagination($which);
201
- ?>
202
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-loading list-ajax-loading" alt="" />
203
- <br class="clear" />
204
- </div>
205
- <?php } else { ?>
206
- <div class="tablenav bottom">
207
- <?php $this->pagination($which); ?>
208
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-loading list-ajax-loading" alt="" />
209
- <br class="clear" />
210
- </div>
211
- <?php
212
- }
213
- }
214
-
215
- public function get_table_classes() {
216
- extract( $this->_args );
217
-
218
- return array( 'plugin-install', 'widefat', $plural );
219
- }
220
-
221
- public function get_columns() {
222
- return array(
223
- 'name' => _x( 'Name', 'plugin name', 'wpsc' ),
224
- 'version' => __( 'Version', 'wpsc' ),
225
- 'price' => __( 'Action', 'wpsc' ),
226
- 'rating' => __( 'Rating', 'wpsc' ),
227
- 'description' => __( 'Description', 'wpsc' ),
228
- );
229
- }
230
-
231
- public function display_rows() {
232
- $plugins_allowedtags = array(
233
- 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
234
- 'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ),
235
- 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
236
- 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()
237
- );
238
-
239
- list( $columns, $hidden ) = $this->get_column_info();
240
-
241
- $style = array();
242
- foreach ( $columns as $column_name => $column_display_name ) {
243
- $style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : '';
244
- }
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
259
- $plugin->description = trim( $plugin->description );
260
- $plugin->description = preg_replace( "|(\r?\n)+|", "\n", $plugin->description );
261
- //\n => <br>
262
- $plugin->description = nl2br( $plugin->description );
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;
279
- default:
280
- self::display_as_grid($plugin, $style);
281
- break;
282
- }
283
- }
284
- }
285
-
286
- protected static function display_row($plugin, $style) {
287
- $name = strip_tags( $plugin->name . ' ' . $plugin->version );
288
- $action_links = array();
289
- $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true))
290
- . '" class="thickbox info" title="' .
291
- esc_attr( sprintf( __( 'More information about %s', 'wpsc' ), $name ) ) . '">' . __( 'Details' ) . '</a>';
292
-
293
- $purchase_link = $plugin->price;
294
-
295
- if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
296
- $status = Sputnik_Admin::install_status( $plugin );
297
-
298
- switch ( $status['status'] ) {
299
- case 'purchase':
300
- if ( $status['url'] ) {
301
- $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy" href="' . $status['url'] . '" title="'
302
- . esc_attr(sprintf(__( 'Buy %s', 'wpsc' ), $name)) . '">' . sprintf(__('<span>%s</span> Buy Now</a>', 'wpsc' ), $plugin->price);
303
- }
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 {
312
- $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc' ) . '">'
313
- . __('Install', 'wpsc' ) . '</span>';
314
- }
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 {
323
- $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc' ) . '">'
324
- . __('Update', 'wpsc' ) . '</span>';
325
- }
326
- break;
327
- case 'latest_installed':
328
- case 'newer_installed':
329
- $purchase_link = '<span title="' . esc_attr__('This plugin is already installed and is up to date', 'wpsc' ) . ' ">'
330
- . __('Installed', 'wpsc' ) . '</span>';
331
- break;
332
- }
333
- }
334
-
335
- $action_links = apply_filters( 'sputnik_install_row_action_links', $action_links, $plugin );
336
- ?>
337
- <tr>
338
- <td class="name column-name"<?php echo $style['name']; ?>><strong><?php echo $plugin->title; ?></strong>
339
- <div class="action-links"><?php if ( !empty( $action_links ) ) echo implode( ' | ', $action_links ); ?></div>
340
- </td>
341
- <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $plugin->version; ?></td>
342
- <td class="vers column-price"<?php echo $style['price']; ?>><?php echo $purchase_link; ?></td>
343
- <td style="display:none" class="vers column-rating"<?php echo $style['rating']; ?>>
344
- <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 ) ) ?>">
345
- <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average) ?>px"></div>
346
- <?php
347
- $color = get_user_option('admin_color');
348
- if ( empty($color) || 'fresh' == $color )
349
- $star_url = admin_url( 'images/stars.png?v=20110615' ); // 'Fresh' Gray star for list tables
350
- else
351
- $star_url = admin_url( 'images/stars.png?v=20110615' ); // 'Classic' Blue star
352
- ?>
353
- <div class="star star5"><img src="<?php echo $star_url; ?>" alt="" /></div>
354
- <div class="star star4"><img src="<?php echo $star_url; ?>" alt="" /></div>
355
- <div class="star star3"><img src="<?php echo $star_url; ?>" alt="" /></div>
356
- <div class="star star2"><img src="<?php echo $star_url; ?>" alt="" /></div>
357
- <div class="star star1"><img src="<?php echo $star_url; ?>" alt="" /></div>
358
- </div>
359
- </td>
360
- <td class="desc column-description"<?php echo $style['description']; ?>><?php echo $plugin->description, $plugin->author; ?></td>
361
- </tr>
362
- <?php
363
- }
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="' .
371
- esc_attr( sprintf( __( 'More information about %s', 'wpsc' ), $name ) ) . '">' . __( 'Details', 'wpsc' ) . '</a>';
372
-
373
- $purchase_link = $plugin->price;
374
-
375
- if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
376
- $status = Sputnik_Admin::install_status( $plugin );
377
-
378
- switch ( $status['status'] ) {
379
- case 'purchase':
380
- if ( $status['url'] ) {
381
- $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy status" href="' . $status['url'] . '" title="'
382
- . esc_attr(sprintf(__( 'Buy %s', 'wpsc' ), $name)) . '">' . __('Buy Now', 'wpsc' ) . '</a>';
383
- }
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
- }
391
- else {
392
- $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc' ) . '">'
393
- . __('Install', 'wpsc' ) . '</span>';
394
- }
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
- }
402
- else {
403
- $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc' ) . '">'
404
- . __('Update', 'wpsc' ) . '</span>';
405
- }
406
- break;
407
- case 'latest_installed':
408
- case 'newer_installed':
409
- $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'wpsc' ) . ' ">'
410
- . __('Installed', 'wpsc' ) . '</span>';
411
- break;
412
- }
413
- }
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 ) ) ?>">
444
- <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average) ?>px"></div>
445
- <?php
446
- $color = get_user_option('admin_color');
447
- if ( empty($color) || 'fresh' == $color )
448
- $star_url = admin_url( 'images/stars.png?v=20110615' ); // 'Fresh' Gray star for list tables
449
- else
450
- $star_url = admin_url( 'images/stars.png?v=20110615' ); // 'Classic' Blue star
451
- ?>
452
- <div class="star star5"><img src="<?php echo $star_url; ?>" alt="" /></div>
453
- <div class="star star4"><img src="<?php echo $star_url; ?>" alt="" /></div>
454
- <div class="star star3"><img src="<?php echo $star_url; ?>" alt="" /></div>
455
- <div class="star star2"><img src="<?php echo $star_url; ?>" alt="" /></div>
456
- <div class="star star1"><img src="<?php echo $star_url; ?>" alt="" /></div>
457
- </div>
458
- </div>
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Consumer.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_OAuth_Consumer {
4
- public $key;
5
- public $secret;
6
-
7
- function __construct($key, $secret, $callback_url=NULL) {
8
- $this->key = $key;
9
- $this->secret = $secret;
10
- $this->callback_url = $callback_url;
11
- }
12
-
13
- function __toString() {
14
- return "Sputnik_OAuth_Consumer[key=$this->key,secret=$this->secret]";
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/DataStore.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_OAuth_DataStore {
4
- function lookup_consumer($consumer_key) {
5
- // implement me
6
- }
7
-
8
- function lookup_token($consumer, $token_type, $token) {
9
- // implement me
10
- }
11
-
12
- function lookup_nonce($consumer, $token, $nonce, $timestamp) {
13
- // implement me
14
- }
15
-
16
- function new_request_token($consumer, $callback = null) {
17
- // return a new token attached to this consumer
18
- }
19
-
20
- function new_access_token($token, $consumer, $verifier = null) {
21
- // return a new access token attached to this consumer
22
- // for the user associated with this token if the request token
23
- // is authorized
24
- // should also invalidate the request token
25
- }
26
-
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Exception.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- /* Generic exception class
4
- */
5
- class Sputnik_OAuth_Exception extends Exception {
6
- // pass
7
- }
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Request.php DELETED
@@ -1,261 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_OAuth_Request {
4
- protected $parameters;
5
- protected $http_method;
6
- protected $http_url;
7
- // for debug purposes
8
- public $base_string;
9
- public static $version = '1.0';
10
- public static $POST_INPUT = 'php://input';
11
-
12
- function __construct($http_method, $http_url, $parameters=NULL) {
13
- $parameters = ($parameters) ? $parameters : array();
14
- $parameters = array_merge( Sputnik_OAuth_Util::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
15
- $this->parameters = $parameters;
16
- $this->http_method = $http_method;
17
- $this->http_url = $http_url;
18
- }
19
-
20
-
21
- /**
22
- * attempt to build up a request from what was passed to the server
23
- */
24
- public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
25
- $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
26
- ? 'http'
27
- : 'https';
28
- $http_url = ($http_url) ? $http_url : $scheme .
29
- '://' . $_SERVER['SERVER_NAME'] .
30
- ':' .
31
- $_SERVER['SERVER_PORT'] .
32
- $_SERVER['REQUEST_URI'];
33
- $http_method = ($http_method) ? $http_method : $_SERVER['REQUEST_METHOD'];
34
-
35
- // We weren't handed any parameters, so let's find the ones relevant to
36
- // this request.
37
- // If you run XML-RPC or similar you should use this to provide your own
38
- // parsed parameter-list
39
- if (!$parameters) {
40
- // Find request headers
41
- $request_headers = Sputnik_OAuth_Util::get_headers();
42
-
43
- // Parse the query-string to find GET parameters
44
- $parameters = Sputnik_OAuth_Util::parse_parameters($_SERVER['QUERY_STRING']);
45
-
46
- // It's a POST request of the proper content-type, so parse POST
47
- // parameters and add those overriding any duplicates from GET
48
- if ($http_method == "POST"
49
- && isset($request_headers['Content-Type'])
50
- && strstr($request_headers['Content-Type'],
51
- 'application/x-www-form-urlencoded')
52
- ) {
53
- $post_data = Sputnik_OAuth_Util::parse_parameters(
54
- file_get_contents(self::$POST_INPUT)
55
- );
56
- $parameters = array_merge($parameters, $post_data);
57
- }
58
-
59
- // We have a Authorization-header with OAuth data. Parse the header
60
- // and add those overriding any duplicates from GET or POST
61
- if (isset($request_headers['Authorization']) && substr($request_headers['Authorization'], 0, 6) == 'OAuth ') {
62
- $header_parameters = Sputnik_OAuth_Util::split_header(
63
- $request_headers['Authorization']
64
- );
65
- $parameters = array_merge($parameters, $header_parameters);
66
- }
67
-
68
- }
69
-
70
- return new Sputnik_OAuth_Request($http_method, $http_url, $parameters);
71
- }
72
-
73
- /**
74
- * pretty much a helper function to set up the request
75
- */
76
- public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
77
- $parameters = ($parameters) ? $parameters : array();
78
- $defaults = array("oauth_version" => Sputnik_OAuth_Request::$version,
79
- "oauth_nonce" => Sputnik_OAuth_Request::generate_nonce(),
80
- "oauth_timestamp" => Sputnik_OAuth_Request::generate_timestamp(),
81
- "oauth_consumer_key" => $consumer->key);
82
- if ($token)
83
- $defaults['oauth_token'] = $token->key;
84
-
85
- $parameters = array_merge($defaults, $parameters);
86
-
87
- return new Sputnik_OAuth_Request($http_method, $http_url, $parameters);
88
- }
89
-
90
- public function set_parameter($name, $value, $allow_duplicates = true) {
91
- if ($allow_duplicates && isset($this->parameters[$name])) {
92
- // We have already added parameter(s) with this name, so add to the list
93
- if (is_scalar($this->parameters[$name])) {
94
- // This is the first duplicate, so transform scalar (string)
95
- // into an array so we can add the duplicates
96
- $this->parameters[$name] = array($this->parameters[$name]);
97
- }
98
-
99
- $this->parameters[$name][] = $value;
100
- } else {
101
- $this->parameters[$name] = $value;
102
- }
103
- }
104
-
105
- public function get_parameter($name) {
106
- return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
107
- }
108
-
109
- public function get_parameters() {
110
- return $this->parameters;
111
- }
112
-
113
- public function unset_parameter($name) {
114
- unset($this->parameters[$name]);
115
- }
116
-
117
- /**
118
- * The request parameters, sorted and concatenated into a normalized string.
119
- * @return string
120
- */
121
- public function get_signable_parameters() {
122
- // Grab all parameters
123
- $params = $this->parameters;
124
-
125
- // Remove oauth_signature if present
126
- // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
127
- if (isset($params['oauth_signature'])) {
128
- unset($params['oauth_signature']);
129
- }
130
-
131
- return Sputnik_OAuth_Util::build_http_query($params);
132
- }
133
-
134
- /**
135
- * Returns the base string of this request
136
- *
137
- * The base string defined as the method, the url
138
- * and the parameters (normalized), each urlencoded
139
- * and the concated with &.
140
- */
141
- public function get_signature_base_string() {
142
- $parts = array(
143
- $this->get_normalized_http_method(),
144
- $this->get_normalized_http_url(),
145
- $this->get_signable_parameters()
146
- );
147
-
148
- $parts = Sputnik_OAuth_Util::urlencode_rfc3986($parts);
149
-
150
- return implode('&', $parts);
151
- }
152
-
153
- /**
154
- * just uppercases the http method
155
- */
156
- public function get_normalized_http_method() {
157
- return strtoupper($this->http_method);
158
- }
159
-
160
- /**
161
- * parses the url and rebuilds it to be
162
- * scheme://host/path
163
- */
164
- public function get_normalized_http_url() {
165
- $parts = parse_url($this->http_url);
166
-
167
- $scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
168
- $port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' : '80');
169
- $host = (isset($parts['host'])) ? strtolower($parts['host']) : '';
170
- $path = (isset($parts['path'])) ? $parts['path'] : '';
171
-
172
- if (($scheme == 'https' && $port != '443')
173
- || ($scheme == 'http' && $port != '80')) {
174
- $host = "$host:$port";
175
- }
176
- return "$scheme://$host$path";
177
- }
178
-
179
- /**
180
- * builds a url usable for a GET request
181
- */
182
- public function to_url() {
183
- $post_data = $this->to_postdata();
184
- $out = $this->get_normalized_http_url();
185
- if ($post_data) {
186
- $out .= '?'.$post_data;
187
- }
188
- return $out;
189
- }
190
-
191
- /**
192
- * builds the data one would send in a POST request
193
- */
194
- public function to_postdata() {
195
- return Sputnik_OAuth_Util::build_http_query($this->parameters);
196
- }
197
-
198
- /**
199
- * builds the Authorization: header
200
- */
201
- public function to_header($realm=null) {
202
- $first = true;
203
- if($realm) {
204
- $out = 'Authorization: OAuth realm="' . Sputnik_OAuth_Util::urlencode_rfc3986($realm) . '"';
205
- $first = false;
206
- } else
207
- $out = 'Authorization: OAuth';
208
-
209
- $total = array();
210
- foreach ($this->parameters as $k => $v) {
211
- if (substr($k, 0, 5) != "oauth") continue;
212
- if (is_array($v)) {
213
- throw new Sputnik_OAuth_Exception('Arrays not supported in headers');
214
- }
215
- $out .= ($first) ? ' ' : ',';
216
- $out .= Sputnik_OAuth_Util::urlencode_rfc3986($k) .
217
- '="' .
218
- Sputnik_OAuth_Util::urlencode_rfc3986($v) .
219
- '"';
220
- $first = false;
221
- }
222
- return $out;
223
- }
224
-
225
- public function __toString() {
226
- return $this->to_url();
227
- }
228
-
229
-
230
- public function sign_request($signature_method, $consumer, $token) {
231
- $this->set_parameter(
232
- "oauth_signature_method",
233
- $signature_method->get_name(),
234
- false
235
- );
236
- $signature = $this->build_signature($signature_method, $consumer, $token);
237
- $this->set_parameter("oauth_signature", $signature, false);
238
- }
239
-
240
- public function build_signature($signature_method, $consumer, $token) {
241
- $signature = $signature_method->build_signature($this, $consumer, $token);
242
- return $signature;
243
- }
244
-
245
- /**
246
- * util function: current timestamp
247
- */
248
- private static function generate_timestamp() {
249
- return time();
250
- }
251
-
252
- /**
253
- * util function: current nonce
254
- */
255
- private static function generate_nonce() {
256
- $mt = microtime();
257
- $rand = mt_rand();
258
-
259
- return md5($mt . $rand); // md5s look nicer than numbers
260
- }
261
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Server.php DELETED
@@ -1,225 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_OAuth_Server {
4
- protected $timestamp_threshold = 1200; // in seconds, twenty minutes
5
- protected $version = '1.0'; // hi blaine
6
- protected $signature_methods = array();
7
-
8
- protected $data_store;
9
-
10
- function __construct($data_store) {
11
- $this->data_store = $data_store;
12
- }
13
-
14
- public function add_signature_method($signature_method) {
15
- $this->signature_methods[$signature_method->get_name()] =
16
- $signature_method;
17
- }
18
-
19
- // high level functions
20
-
21
- /**
22
- * process a request_token request
23
- * returns the request token on success
24
- */
25
- public function fetch_request_token(&$request) {
26
- $this->get_version($request);
27
-
28
- $consumer = $this->get_consumer($request);
29
-
30
- // no token required for the initial token request
31
- $token = NULL;
32
-
33
- $this->check_signature($request, $consumer, $token);
34
-
35
- // Rev A change
36
- $callback = $request->get_parameter('oauth_callback');
37
- $new_token = $this->data_store->new_request_token($consumer, $callback);
38
-
39
- return $new_token;
40
- }
41
-
42
- /**
43
- * process an access_token request
44
- * returns the access token on success
45
- */
46
- public function fetch_access_token(&$request) {
47
- $this->get_version($request);
48
-
49
- $consumer = $this->get_consumer($request);
50
-
51
- // requires authorized request token
52
- $token = $this->get_token($request, $consumer, "request");
53
-
54
- $this->check_signature($request, $consumer, $token);
55
-
56
- // Rev A change
57
- $verifier = $request->get_parameter('oauth_verifier');
58
- $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
59
-
60
- return $new_token;
61
- }
62
-
63
- /**
64
- * verify an api call, checks all the parameters
65
- */
66
- public function verify_request(&$request) {
67
- $this->get_version($request);
68
- $consumer = $this->get_consumer($request);
69
- $token = $this->get_token($request, $consumer, "access");
70
- $this->check_signature($request, $consumer, $token);
71
- return array($consumer, $token);
72
- }
73
-
74
- // Internals from here
75
- /**
76
- * version 1
77
- */
78
- private function get_version(&$request) {
79
- $version = $request->get_parameter("oauth_version");
80
- if (!$version) {
81
- // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
82
- // Chapter 7.0 ("Accessing Protected Ressources")
83
- $version = '1.0';
84
- }
85
- if ($version !== $this->version) {
86
- throw new Sputnik_OAuth_Exception("OAuth version '$version' not supported");
87
- }
88
- return $version;
89
- }
90
-
91
- /**
92
- * figure out the signature with some defaults
93
- */
94
- private function get_signature_method($request) {
95
- $signature_method = $request instanceof Sputnik_OAuth_Request
96
- ? $request->get_parameter("oauth_signature_method")
97
- : NULL;
98
-
99
- if (!$signature_method) {
100
- // According to chapter 7 ("Accessing Protected Ressources") the signature-method
101
- // parameter is required, and we can't just fallback to PLAINTEXT
102
- throw new Sputnik_OAuth_Exception('No signature method parameter. This parameter is required');
103
- }
104
-
105
- if (!in_array($signature_method,
106
- array_keys($this->signature_methods))) {
107
- throw new Sputnik_OAuth_Exception(
108
- "Signature method '$signature_method' not supported " .
109
- "try one of the following: " .
110
- implode(", ", array_keys($this->signature_methods))
111
- );
112
- }
113
- return $this->signature_methods[$signature_method];
114
- }
115
-
116
- /**
117
- * try to find the consumer for the provided request's consumer key
118
- */
119
- private function get_consumer($request) {
120
- $consumer_key = $request instanceof Sputnik_OAuth_Request
121
- ? $request->get_parameter("oauth_consumer_key")
122
- : NULL;
123
-
124
- if (!$consumer_key) {
125
- throw new Sputnik_OAuth_Exception("Invalid consumer key");
126
- }
127
-
128
- $consumer = $this->data_store->lookup_consumer($consumer_key);
129
- if (!$consumer) {
130
- throw new Sputnik_OAuth_Exception("Invalid consumer");
131
- }
132
-
133
- return $consumer;
134
- }
135
-
136
- /**
137
- * try to find the token for the provided request's token key
138
- */
139
- private function get_token($request, $consumer, $token_type="access") {
140
- $token_field = $request instanceof Sputnik_OAuth_Request
141
- ? $request->get_parameter('oauth_token')
142
- : NULL;
143
-
144
-
145
-
146
- $token = $this->data_store->lookup_token(
147
- $consumer, $token_type, $token_field
148
- );
149
- if (!$token) {
150
- throw new Sputnik_OAuth_Exception("Invalid $token_type token: $token_field");
151
- }
152
- return $token;
153
- }
154
-
155
- /**
156
- * all-in-one function to check the signature on a request
157
- * should guess the signature method appropriately
158
- */
159
- private function check_signature($request, $consumer, $token) {
160
- // this should probably be in a different method
161
- $timestamp = $request instanceof Sputnik_OAuth_Request
162
- ? $request->get_parameter('oauth_timestamp')
163
- : NULL;
164
- $nonce = $request instanceof Sputnik_OAuth_Request
165
- ? $request->get_parameter('oauth_nonce')
166
- : NULL;
167
-
168
- $this->check_timestamp($timestamp);
169
- $this->check_nonce($consumer, $token, $nonce, $timestamp);
170
-
171
- $signature_method = $this->get_signature_method($request);
172
-
173
- $signature = $request->get_parameter('oauth_signature');
174
- $valid_sig = $signature_method->check_signature(
175
- $request,
176
- $consumer,
177
- $token,
178
- $signature
179
- );
180
-
181
- if (!$valid_sig) {
182
- throw new Sputnik_OAuth_Exception("Invalid signature");
183
- }
184
- }
185
-
186
- /**
187
- * check that the timestamp is new enough
188
- */
189
- private function check_timestamp($timestamp) {
190
- if( ! $timestamp )
191
- throw new Sputnik_OAuth_Exception(
192
- 'Missing timestamp parameter. The parameter is required'
193
- );
194
-
195
- // verify that timestamp is recentish
196
- $now = time();
197
- if (abs($now - $timestamp) > $this->timestamp_threshold) {
198
- throw new Sputnik_OAuth_Exception(
199
- "Expired timestamp, yours $timestamp, ours $now"
200
- );
201
- }
202
- }
203
-
204
- /**
205
- * check that the nonce is not repeated
206
- */
207
- private function check_nonce($consumer, $token, $nonce, $timestamp) {
208
- if( ! $nonce )
209
- throw new Sputnik_OAuth_Exception(
210
- 'Missing nonce parameter. The parameter is required'
211
- );
212
-
213
- // verify that the nonce is uniqueish
214
- $found = $this->data_store->lookup_nonce(
215
- $consumer,
216
- $token,
217
- $nonce,
218
- $timestamp
219
- );
220
-
221
- if ($found) {
222
- throw new Sputnik_OAuth_Exception("Nonce already used: $nonce");
223
- }
224
- }
225
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * A class for implementing a Signature Method
5
- * See section 9 ("Signing Requests") in the spec
6
- */
7
- abstract class Sputnik_OAuth_SignatureMethod {
8
- /**
9
- * Needs to return the name of the Signature Method (ie HMAC-SHA1)
10
- * @return string
11
- */
12
- abstract public function get_name();
13
-
14
- /**
15
- * Build up the signature
16
- * NOTE: The output of this function MUST NOT be urlencoded.
17
- * the encoding is handled in Sputnik_OAuth_Request when the final
18
- * request is serialized
19
- * @param Sputnik_OAuth_Request $request
20
- * @param Sputnik_OAuth_Consumer $consumer
21
- * @param Sputnik_OAuth_Token $token
22
- * @return string
23
- */
24
- abstract public function build_signature($request, $consumer, $token);
25
-
26
- /**
27
- * Verifies that a given signature is correct
28
- * @param Sputnik_OAuth_Request $request
29
- * @param Sputnik_OAuth_Consumer $consumer
30
- * @param Sputnik_OAuth_Token $token
31
- * @param string $signature
32
- * @return bool
33
- */
34
- public function check_signature($request, $consumer, $token, $signature) {
35
- $built = $this->build_signature($request, $consumer, $token);
36
-
37
- // Check for zero length, although unlikely here
38
- if (strlen($built) == 0 || strlen($signature) == 0) {
39
- return false;
40
- }
41
-
42
- if (strlen($built) != strlen($signature)) {
43
- return false;
44
- }
45
-
46
- // Avoid a timing leak with a (hopefully) time insensitive compare
47
- $result = 0;
48
- for ($i = 0; $i < strlen($signature); $i++) {
49
- $result |= ord($built{$i}) ^ ord($signature{$i});
50
- }
51
-
52
- return $result == 0;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod/HMAC/SHA1.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
5
- * where the Signature Base String is the text and the key is the concatenated values (each first
6
- * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
7
- * character (ASCII code 38) even if empty.
8
- * - Chapter 9.2 ("HMAC-SHA1")
9
- */
10
- class Sputnik_OAuth_SignatureMethod_HMAC_SHA1 extends Sputnik_OAuth_SignatureMethod {
11
- function get_name() {
12
- return "HMAC-SHA1";
13
- }
14
-
15
- public function build_signature($request, $consumer, $token) {
16
- $base_string = $request->get_signature_base_string();
17
- $request->base_string = $base_string;
18
-
19
- $key_parts = array(
20
- $consumer->secret,
21
- ($token) ? $token->secret : ""
22
- );
23
-
24
- $key_parts = Sputnik_OAuth_Util::urlencode_rfc3986($key_parts);
25
- $key = implode('&', $key_parts);
26
-
27
- return base64_encode(hash_hmac('sha1', $base_string, $key, true));
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod/PLAINTEXT.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The PLAINTEXT method does not provide any security protection and SHOULD only be used
5
- * over a secure channel such as HTTPS. It does not use the Signature Base String.
6
- * - Chapter 9.4 ("PLAINTEXT")
7
- */
8
- class Sputnik_OAuth_SignatureMethod_PLAINTEXT extends Sputnik_OAuth_SignatureMethod {
9
- public function get_name() {
10
- return "PLAINTEXT";
11
- }
12
-
13
- /**
14
- * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
15
- * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
16
- * empty. The result MUST be encoded again.
17
- * - Chapter 9.4.1 ("Generating Signatures")
18
- *
19
- * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
20
- * Sputnik_OAuth_Request handles this!
21
- */
22
- public function build_signature($request, $consumer, $token) {
23
- $key_parts = array(
24
- $consumer->secret,
25
- ($token) ? $token->secret : ""
26
- );
27
-
28
- $key_parts = Sputnik_OAuth_Util::urlencode_rfc3986($key_parts);
29
- $key = implode('&', $key_parts);
30
- $request->base_string = $key;
31
-
32
- return $key;
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/SignatureMethod/RSA/SHA1.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
5
- * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
6
- * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
7
- * verified way to the Service Provider, in a manner which is beyond the scope of this
8
- * specification.
9
- * - Chapter 9.3 ("RSA-SHA1")
10
- */
11
- abstract class Sputnik_OAuth_SignatureMethod_RSA_SHA1 extends Sputnik_OAuth_SignatureMethod {
12
- public function get_name() {
13
- return "RSA-SHA1";
14
- }
15
-
16
- // Up to the SP to implement this lookup of keys. Possible ideas are:
17
- // (1) do a lookup in a table of trusted certs keyed off of consumer
18
- // (2) fetch via http using a url provided by the requester
19
- // (3) some sort of specific discovery code based on request
20
- //
21
- // Either way should return a string representation of the certificate
22
- protected abstract function fetch_public_cert(&$request);
23
-
24
- // Up to the SP to implement this lookup of keys. Possible ideas are:
25
- // (1) do a lookup in a table of trusted certs keyed off of consumer
26
- //
27
- // Either way should return a string representation of the certificate
28
- protected abstract function fetch_private_cert(&$request);
29
-
30
- public function build_signature($request, $consumer, $token) {
31
- $base_string = $request->get_signature_base_string();
32
- $request->base_string = $base_string;
33
-
34
- // Fetch the private key cert based on the request
35
- $cert = $this->fetch_private_cert($request);
36
-
37
- // Pull the private key ID from the certificate
38
- $privatekeyid = openssl_get_privatekey($cert);
39
-
40
- // Sign using the key
41
- $ok = openssl_sign($base_string, $signature, $privatekeyid);
42
-
43
- // Release the key resource
44
- openssl_free_key($privatekeyid);
45
-
46
- return base64_encode($signature);
47
- }
48
-
49
- public function check_signature($request, $consumer, $token, $signature) {
50
- $decoded_sig = base64_decode($signature);
51
-
52
- $base_string = $request->get_signature_base_string();
53
-
54
- // Fetch the public key cert based on the request
55
- $cert = $this->fetch_public_cert($request);
56
-
57
- // Pull the public key ID from the certificate
58
- $publickeyid = openssl_get_publickey($cert);
59
-
60
- // Check the computed signature against the one passed in the query
61
- $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
62
-
63
- // Release the key resource
64
- openssl_free_key($publickeyid);
65
-
66
- return $ok == 1;
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Token.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_OAuth_Token {
4
- // access tokens and request tokens
5
- public $key;
6
- public $secret;
7
-
8
- /**
9
- * key = the token
10
- * secret = the token secret
11
- */
12
- function __construct($key, $secret) {
13
- $this->key = $key;
14
- $this->secret = $secret;
15
- }
16
-
17
- /**
18
- * generates the basic string serialization of a token that a server
19
- * would respond to request_token and access_token calls with
20
- */
21
- function to_string() {
22
- return "oauth_token=" .
23
- Sputnik_OAuth_Util::urlencode_rfc3986($this->key) .
24
- "&oauth_token_secret=" .
25
- Sputnik_OAuth_Util::urlencode_rfc3986($this->secret);
26
- }
27
-
28
- function __toString() {
29
- return $this->to_string();
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/OAuth/Util.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_OAuth_Util {
4
- public static function urlencode_rfc3986($input) {
5
- if (is_array($input)) {
6
- return array_map(array('Sputnik_OAuth_Util', 'urlencode_rfc3986'), $input);
7
- } else if (is_scalar($input)) {
8
- return str_replace(
9
- '+',
10
- ' ',
11
- str_replace('%7E', '~', rawurlencode($input))
12
- );
13
- } else {
14
- return '';
15
- }
16
- }
17
-
18
-
19
- // This decode function isn't taking into consideration the above
20
- // modifications to the encoding process. However, this method doesn't
21
- // seem to be used anywhere so leaving it as is.
22
- public static function urldecode_rfc3986($string) {
23
- return urldecode($string);
24
- }
25
-
26
- // Utility function for turning the Authorization: header into
27
- // parameters, has to do some unescaping
28
- // Can filter out any non-oauth parameters if needed (default behaviour)
29
- // May 28th, 2010 - method updated to tjerk.meesters for a speed improvement.
30
- // see http://code.google.com/p/oauth/issues/detail?id=163
31
- public static function split_header($header, $only_allow_oauth_parameters = true) {
32
- $params = array();
33
- if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
34
- foreach ($matches[1] as $i => $h) {
35
- $params[$h] = Sputnik_OAuth_Util::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
36
- }
37
- if (isset($params['realm'])) {
38
- unset($params['realm']);
39
- }
40
- }
41
- return $params;
42
- }
43
-
44
- // helper to try to sort out headers for people who aren't running apache
45
- public static function get_headers() {
46
- if (function_exists('apache_request_headers')) {
47
- // we need this to get the actual Authorization: header
48
- // because apache tends to tell us it doesn't exist
49
- $headers = apache_request_headers();
50
-
51
- // sanitize the output of apache_request_headers because
52
- // we always want the keys to be Cased-Like-This and arh()
53
- // returns the headers in the same case as they are in the
54
- // request
55
- $out = array();
56
- foreach ($headers AS $key => $value) {
57
- $key = str_replace(
58
- " ",
59
- "-",
60
- ucwords(strtolower(str_replace("-", " ", $key)))
61
- );
62
- $out[$key] = $value;
63
- }
64
- } else {
65
- // otherwise we don't have apache and are just going to have to hope
66
- // that $_SERVER actually contains what we need
67
- $out = array();
68
- if( isset($_SERVER['CONTENT_TYPE']) )
69
- $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
70
- if( isset($_ENV['CONTENT_TYPE']) )
71
- $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
72
-
73
- foreach ($_SERVER as $key => $value) {
74
- if (substr($key, 0, 5) == "HTTP_") {
75
- // this is chaos, basically it is just there to capitalize the first
76
- // letter of every word that is not an initial HTTP and strip HTTP
77
- // code from przemek
78
- $key = str_replace(
79
- " ",
80
- "-",
81
- ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
82
- );
83
- $out[$key] = $value;
84
- }
85
- }
86
- }
87
- return $out;
88
- }
89
-
90
- // This function takes a input like a=b&a=c&d=e and returns the parsed
91
- // parameters like this
92
- // array('a' => array('b','c'), 'd' => 'e')
93
- public static function parse_parameters( $input ) {
94
- if (!isset($input) || !$input) return array();
95
-
96
- $pairs = explode('&', $input);
97
-
98
- $parsed_parameters = array();
99
- foreach ($pairs as $pair) {
100
- $split = explode('=', $pair, 2);
101
- $parameter = Sputnik_OAuth_Util::urldecode_rfc3986($split[0]);
102
- $value = isset($split[1]) ? Sputnik_OAuth_Util::urldecode_rfc3986($split[1]) : '';
103
-
104
- if (isset($parsed_parameters[$parameter])) {
105
- // We have already recieved parameter(s) with this name, so add to the list
106
- // of parameters with this name
107
-
108
- if (is_scalar($parsed_parameters[$parameter])) {
109
- // This is the first duplicate, so transform scalar (string) into an array
110
- // so we can add the duplicates
111
- $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
112
- }
113
-
114
- $parsed_parameters[$parameter][] = $value;
115
- } else {
116
- $parsed_parameters[$parameter] = $value;
117
- }
118
- }
119
- return $parsed_parameters;
120
- }
121
-
122
- public static function build_http_query($params) {
123
- if (!$params) return '';
124
-
125
- // Urlencode both keys and values
126
- $keys = Sputnik_OAuth_Util::urlencode_rfc3986(array_keys($params));
127
- $values = Sputnik_OAuth_Util::urlencode_rfc3986(array_values($params));
128
- $params = array_combine($keys, $values);
129
-
130
- // Parameters are sorted by name, using lexicographical byte value ordering.
131
- // Ref: Spec: 9.1.1 (1)
132
- uksort($params, 'strcmp');
133
-
134
- $pairs = array();
135
- foreach ($params as $parameter => $value) {
136
- if (is_array($value)) {
137
- // If two or more parameters share the same name, they are sorted by their value
138
- // Ref: Spec: 9.1.1 (1)
139
- // June 12th, 2010 - changed to sort because of issue 164 by hidetaka
140
- sort($value, SORT_STRING);
141
- foreach ($value as $duplicate_value) {
142
- $pairs[] = $parameter . '=' . $duplicate_value;
143
- }
144
- } else {
145
- $pairs[] = $parameter . '=' . $value;
146
- }
147
- }
148
- // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
149
- // Each name-value pair is separated by an '&' character (ASCII code 38)
150
- return implode('&', $pairs);
151
- }
152
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Pointers.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_Pointers {
4
-
5
- public static function bootstrap() {
6
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
7
-
8
- }
9
-
10
- public static function enqueue_scripts() {
11
- $enqueue = false;
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
22
- wp_enqueue_script( 'wp-pointer' );
23
- wp_enqueue_style( 'wp-pointer' );
24
- }
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({
41
- content: '<?php echo $content; ?>',
42
- position: {
43
- edge: 'left',
44
- align: 'center'
45
- },
46
- close: function() {
47
- $.post( ajaxurl, {
48
- pointer: 'wpsc_marketplace_pointer',
49
- action: 'dismiss-wp-pointer'
50
- });
51
- }
52
- }).pointer('open');
53
- });
54
- // ]]></script>
55
- <?php
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/ThemeUpgrader.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- class Sputnik_ThemeUpgrader extends Theme_Upgrader {
3
- public function download_package($package) {
4
- if (!preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package)) {
5
- return $package; //must be a local file..
6
- }
7
-
8
- if (empty($package)) {
9
- return new WP_Error('no_package', $this->strings['no_package']);
10
- }
11
-
12
- $this->skin->feedback('downloading_package', $package);
13
-
14
- $download_file = self::download($package);
15
-
16
- if (is_wp_error($download_file)) {
17
- return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
18
- }
19
-
20
- return $download_file;
21
- }
22
-
23
- protected static function download( $url, $timeout = 300 ) {
24
- //WARNING: The file is not automatically deleted, The script must unlink() the file.
25
- if ( ! $url )
26
- return new WP_Error('http_no_url', __('Invalid URL Provided.'));
27
-
28
- $tmpfname = wp_tempnam($url);
29
- if ( ! $tmpfname )
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);
41
-
42
- $response = wp_remote_get($url, $args);
43
-
44
- if ( is_wp_error( $response ) ) {
45
- unlink( $tmpfname );
46
- return $response;
47
- }
48
-
49
- if ( 200 != wp_remote_retrieve_response_code( $response ) ){
50
- unlink( $tmpfname );
51
- return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
52
- }
53
-
54
- return $tmpfname;
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Theme_Upgrader.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- class Sputnik_ThemeUpgrader extends Theme_Upgrader {
3
- public function download_package($package) {
4
- if (!preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package)) {
5
- return $package; //must be a local file..
6
- }
7
-
8
- if (empty($package)) {
9
- return new WP_Error('no_package', $this->strings['no_package']);
10
- }
11
-
12
- $this->skin->feedback('downloading_package', $package);
13
-
14
- $download_file = self::download($package);
15
-
16
- if (is_wp_error($download_file)) {
17
- return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
18
- }
19
-
20
- return $download_file;
21
- }
22
-
23
- protected static function download( $url, $timeout = 300 ) {
24
- //WARNING: The file is not automatically deleted, The script must unlink() the file.
25
- if ( ! $url )
26
- return new WP_Error('http_no_url', __('Invalid URL Provided.'));
27
-
28
- $tmpfname = wp_tempnam($url);
29
- if ( ! $tmpfname )
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);
41
-
42
- $response = wp_remote_get($url, $args);
43
-
44
- if ( is_wp_error( $response ) ) {
45
- unlink( $tmpfname );
46
- return $response;
47
- }
48
-
49
- if ( 200 != wp_remote_retrieve_response_code( $response ) ){
50
- unlink( $tmpfname );
51
- return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
52
- }
53
-
54
- return $tmpfname;
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Updater.php DELETED
@@ -1,200 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_Updater {
4
- public static function bootstrap() {
5
- add_filter('pre_set_site_transient_update_plugins', array(get_class(), 'mangle_update_plugins'));
6
- add_filter('pre_set_site_transient_update_themes', array(get_class(), 'mangle_update_themes'));
7
- add_action('admin_action_update-selected', array(get_class(), 'prepare_bulk_mangle'));
8
- }
9
-
10
- public static function mangle_update_plugins($plugins) {
11
- // WP saves once before checking, in case it fails
12
- static $tried = false;
13
- if (!$tried) {
14
- $tried = true;
15
- return $plugins;
16
- }
17
-
18
- $ours = Sputnik::get_installed(true);
19
-
20
- if (empty($ours)) {
21
- return $plugins;
22
- }
23
-
24
- $data = array();
25
- $files = array();
26
- foreach ($ours as $file => $plugin) {
27
- // If something accidentally slipped in...
28
- if (empty($plugin['Sputnik ID'])) {
29
- // ...ignore it.
30
- continue;
31
- }
32
-
33
- $name = $plugin['Sputnik ID'];
34
-
35
- $files[$name] = $file;
36
- $data[$name] = $plugin['Version'];
37
- }
38
-
39
- $url = Sputnik::API_BASE . '/version';
40
-
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;
51
- }
52
-
53
- $response = json_decode($req['body']);
54
-
55
- if (empty($response)) {
56
- return $plugins;
57
- }
58
-
59
- foreach ($response as $name => $result) {
60
- $file = $files[$name];
61
-
62
- if ($result->status === 410) {
63
- self::$suspended[$name] = $result;
64
- Sputnik::suspend_plugin($name, $file, $result);
65
- continue;
66
- }
67
- if ($result->status !== 200) {
68
- continue;
69
- }
70
-
71
- $info = (object) array(
72
- 'package' => $result->location,
73
- 'url' => $result->url,
74
- 'new_version' => $result->version,
75
- 'slug' => 'sputnik-' . $name,
76
- 'sputnik_id' => $name
77
- );
78
- $plugins->response[$file] = $info;
79
- }
80
-
81
- return $plugins;
82
- }
83
-
84
- public static function mangle_update_themes( $themes ) {
85
- // WP saves once before checking, in case it fails
86
- static $tried = false;
87
- if ( ! $tried) {
88
- $tried = true;
89
- return $themes;
90
- }
91
-
92
- $ours = Sputnik::get_installed( true );
93
-
94
- if ( empty( $ours ) ) {
95
- return $themes;
96
- }
97
-
98
- $data = array();
99
- $files = array();
100
- foreach ( $ours as $file => $theme ) {
101
- // If something accidentally slipped in...
102
- if ( empty( $theme['Sputnik ID'] ) ) {
103
- // ...ignore it.
104
- continue;
105
- }
106
-
107
- $name = $theme['Sputnik ID'];
108
-
109
- $files[$name] = $file;
110
- $data[$name] = $theme['Version'];
111
- }
112
-
113
- $url = Sputnik::API_BASE . '/version';
114
-
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;
125
- }
126
-
127
- $response = json_decode( $req['body'] );
128
-
129
- if ( empty( $response ) ) {
130
- return $themes;
131
- }
132
-
133
- foreach ( $response as $name => $result ) {
134
- $file = $files[$name];
135
-
136
- if ( $result->status === 410 ) {
137
- self::$suspended[$name] = $result;
138
- Sputnik::suspend_plugin( $name, $file, $result );
139
- continue;
140
- }
141
- if ( $result->status !== 200 ) {
142
- continue;
143
- }
144
-
145
- $info = (object) array(
146
- 'package' => $result->location,
147
- 'url' => $result->url,
148
- 'new_version' => $result->version,
149
- 'slug' => 'sputnik-' . $name,
150
- 'sputnik_id' => $name
151
- );
152
- $themes->response[$file] = $info;
153
- }
154
-
155
- return $themes;
156
- }
157
-
158
- /**
159
- * Callback for {@see Sputnik} to confirm suspension
160
- *
161
- * The use of this confirmation system is to ensure that only the updater
162
- * can disable other plugins.
163
- */
164
- public static function confirm_suspend($plugin, $data) {
165
- return (isset(self::$suspended[$plugin]) && self::$suspended[$plugin] === $data);
166
- }
167
-
168
- public static function mangle_bulk($current) {
169
- return $current;
170
- }
171
-
172
- public static function prepare_bulk_mangle() {
173
- add_filter('http_request_args', array(get_class(), 'mangle_bulk_http'), 10, 2);
174
- }
175
-
176
- public static function mangle_bulk_http($r, $url) {
177
-
178
- if (strpos($url, Sputnik::API_BASE) === false) {
179
- return $r;
180
- }
181
-
182
- $auth_header = Sputnik_API::get_auth_for_download($url);
183
- list($key, $auth_header) = explode(':', $auth_header);
184
-
185
- $r['headers']['X-WP-Domain'] = Sputnik_API::domain();
186
- $r['headers']['Authorization'] = $auth_header;
187
-
188
- return $r;
189
- }
190
-
191
- protected static function domain() {
192
- $wp_install = home_url( '/' );
193
-
194
- if ( is_multisite() )
195
- $wp_install = network_site_url();
196
-
197
- $wp_install = parse_url( $wp_install );
198
- return $wp_install['host'];
199
- }
200
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Upgrader.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- class Sputnik_Upgrader extends Plugin_Upgrader {
3
- public function download_package($package) {
4
- if (!preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package)) {
5
- return $package; //must be a local file..
6
- }
7
-
8
- if (empty($package)) {
9
- return new WP_Error('no_package', $this->strings['no_package']);
10
- }
11
-
12
- $this->skin->feedback('downloading_package', $package);
13
-
14
- $download_file = self::download($package);
15
-
16
- if (is_wp_error($download_file)) {
17
- return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
18
- }
19
-
20
- return $download_file;
21
- }
22
-
23
- protected static function download( $url, $timeout = 300 ) {
24
- //WARNING: The file is not automatically deleted, The script must unlink() the file.
25
- if ( ! $url )
26
- return new WP_Error('http_no_url', __('Invalid URL Provided.'));
27
-
28
- $tmpfname = wp_tempnam($url);
29
- if ( ! $tmpfname )
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);
41
-
42
- $response = wp_remote_get($url, $args);
43
-
44
- if ( is_wp_error( $response ) ) {
45
- unlink( $tmpfname );
46
- return $response;
47
- }
48
-
49
- if ( 200 != wp_remote_retrieve_response_code( $response ) ){
50
- unlink( $tmpfname );
51
- return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
52
- }
53
-
54
- return $tmpfname;
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/Upgrader/Skin.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_Upgrader_Skin extends WP_Upgrader_Skin {
4
- public $api;
5
- public $type;
6
-
7
- function __construct($args = array()) {
8
- $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
9
- $args = wp_parse_args($args, $defaults);
10
-
11
- $this->type = $args['type'];
12
- $this->api = isset($args['api']) ? $args['api'] : array();
13
-
14
- parent::__construct($args);
15
- }
16
-
17
- function before() {
18
-
19
- if ( ! empty( $this->api ) ) {
20
- $asset_type = in_array( 'theme', $this->api->categories ) ? 'theme' : 'plugin';
21
- $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the %s <strong>%s %s</strong>.'), $asset_type, $this->api->name, $this->api->version);
22
- }
23
-
24
- echo '<script>if (window.parent.tb_showIframe) { window.parent.tb_showIframe(); }</script>';
25
- }
26
-
27
- function after() {
28
-
29
- $plugin_file = $this->upgrader->plugin_info();
30
-
31
- $install_actions = array();
32
-
33
- $from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins';
34
-
35
- // One-Click flow
36
- if (!empty($_GET['also']) && $_GET['also'] == 'activate') {
37
- if (!$this->result || is_wp_error($this->result)) {
38
- show_message(__('Cannot activate plugin.', 'wpsc' ));
39
- }
40
- else {
41
- show_message(__('Activating the plugin&#8230;', 'wpsc' ));
42
- 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>';
43
- }
44
- }
45
- else {
46
- $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>';
47
-
48
- if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
49
- $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>';
50
- unset( $install_actions['activate_plugin'] );
51
- }
52
- }
53
-
54
- $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>';
55
-
56
-
57
- if (!$this->result || is_wp_error($this->result)) {
58
- unset( $install_actions['activate_plugin'] );
59
- unset( $install_actions['network_activate'] );
60
- }
61
- $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
62
- if ( ! empty($install_actions) )
63
- $this->feedback(implode(' | ', (array)$install_actions));
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
-
3
- abstract class Sputnik_View {
4
- protected $title = 'WATWATWATWAT';
5
-
6
- public function __construct($title) {
7
- $this->title = $title;
8
- }
9
-
10
- public function render() {
11
- $this->header();
12
- $this->display();
13
- $this->footer();
14
- }
15
-
16
- protected function header($title = false, $account = false) {
17
- if (func_num_args() !== 0) {
18
- debug_print_backtrace();
19
- die();
20
- }
21
-
22
- $title = $this->title;
23
-
24
- $account = false;
25
- try {
26
- $account = Sputnik::get_account();
27
- }
28
- catch (Exception $e) {
29
- //
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(),
38
- 'account' => menu_page_url( 'sputnik-account', false ),
39
- );
40
-
41
- $current = Sputnik_Admin::$page;
42
- }
43
- ?>
44
- <div class="wrap" id="sputnik-page">
45
- <?php
46
- if ($account !== false) {
47
- ?>
48
- <?php screen_icon( 'sputnik' ); ?>
49
- <h2 class="nav-tab-wrapper">
50
- <?php
51
- foreach ($tabs as $page => $title) {
52
- ?>
53
- <a href="<?php echo $hrefs[$page] ?>" class="nav-tab<?php if ($current === $page) echo ' nav-tab-active';?>"><?php echo $title ?></a>
54
- <?php
55
- }
56
- ?>
57
- </h2>
58
- <?php
59
- }
60
- elseif ($title !== false) {
61
- ?>
62
- <?php screen_icon( 'sputnik' ); ?>
63
- <h2><?php echo $title ?></h2>
64
- <?php
65
- }
66
- ?>
67
-
68
- <?php
69
- do_action('sputnik_messages');
70
- }
71
-
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
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Account.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
- /**
3
- * Account browser view
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Account browser view
11
- *
12
- * @package Sputnik
13
- * @subpackage Admin View
14
- */
15
- class Sputnik_View_Account extends Sputnik_View_Browser {
16
- protected $title = 'Account';
17
-
18
- protected function header() {
19
- parent::header();
20
- $account = Sputnik::get_account();
21
- ?>
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
-
36
- <?php
37
- }
38
-
39
- public function get_view_url($view) {
40
- $bits = array('tab' => $view);
41
- if ($this->view->id !== 'grid') {
42
- $bits['view'] = $this->view->id;
43
- }
44
- return Sputnik_Admin::build_account_url($bits);
45
- }
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
-
54
- public function get_data($tab) {
55
- try {
56
- switch ( $tab ) {
57
- case 'yours':
58
- add_filter('sputnik_install_row_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
59
- add_filter('sputnik_install_grid_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
60
- $api = Sputnik_API::get_own();
61
- break;
62
-
63
- default:
64
- case 'purchased':
65
- $api = Sputnik_API::get_purchased();
66
- break;
67
- }
68
- }
69
- catch (Exception $e) {
70
- $this->connect_error = true;
71
- return false;
72
- }
73
-
74
- $this->count = count($api['body']);
75
-
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' => '',
84
- 'author' => '',
85
- 'author_slug' => '',
86
- 'thumb' => false
87
- );
88
- }
89
-
90
- $count = 1;
91
- if (!empty($api['headers']['x-pagecount'])) {
92
- $count = $api['headers']['x-pagecount'];
93
- }
94
-
95
- return array('items' => $api['body'], 'pages' => $count);
96
- }
97
-
98
- public function get_views() {
99
- global $tabs, $tab;
100
-
101
- $display_tabs = array();
102
- foreach ( (array) $tabs as $action => $text ) {
103
- $class = ( $action == $tab ) ? ' class="current"' : '';
104
- $bits = array('tab' => $action);
105
- if ($this->view !== 'grid') {
106
- $bits['view'] = $this->view;
107
- }
108
- $href = Sputnik_Admin::build_account_url($bits);
109
- $display_tabs['plugin-install-'.$action] = "<a href='$href'$class>$text</a>";
110
- }
111
-
112
- return $display_tabs;
113
- }
114
-
115
- public function no_items() {
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
- }
126
-
127
- public static function mangle_action_for_own($actions, $plugin) {
128
- if ($plugin->slug === '__add_new') {
129
- return $actions;
130
- }
131
-
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
- }
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Auth.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Authentication handler view
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Authentication handler view
11
- *
12
- * @package Sputnik
13
- * @subpackage Admin View
14
- */
15
- class Sputnik_View_Auth extends Sputnik_View {
16
- public function __construct() {
17
- parent::__construct(false);
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();
25
- $oauth_url = Sputnik_Admin::build_url(array('oauth' => 'request'));
26
-
27
- ?>
28
- <div id="sputnik-auth">
29
- <iframe src="<?php echo $oauth_url; ?>"></iframe>
30
- </div>
31
- <?php
32
- $this->footer();
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
- /**
3
- * Product browser view
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Product browser view
11
- *
12
- * @package Sputnik
13
- * @subpackage Admin View
14
- */
15
- class Sputnik_View_Browser extends Sputnik_View {
16
- protected $title = 'Browse';
17
-
18
- protected $view = null;
19
- public $view_type = 'grid';
20
- protected $connect_error = false;
21
-
22
- public function __construct() {
23
- $class = 'Sputnik_View_Browser_Grid';
24
- if (!empty($_REQUEST['view'])) {
25
- switch ($_REQUEST['view']) {
26
- case 'list':
27
- $class = 'Sputnik_View_Browser_List';
28
- break;
29
- case 'grid':
30
- default:
31
- $class = 'Sputnik_View_Browser_Grid';
32
- break;
33
- }
34
- }
35
-
36
- $this->view = new $class();
37
- $this->view->parent = $this;
38
- $this->view->prepare_items();
39
- }
40
-
41
- public function get_view_url($view) {
42
- $bits = array('tab' => $view);
43
- if ($this->view->id !== 'grid') {
44
- $bits['view'] = $this->view->id;
45
- }
46
- return Sputnik_Admin::build_url($bits);
47
- }
48
-
49
- protected function display() {
50
- $this->view->views();
51
- $this->view->display();
52
- }
53
-
54
- public function get_tabs() {
55
- return array();
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
-
70
- public function get_data($tab) {
71
- global $paged;
72
- try {
73
- switch ( $tab ) {
74
- case 'search':
75
- $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
76
- $api = Sputnik_API::search($term);
77
- break;
78
-
79
- case 'account':
80
- $api = Sputnik_API::get_purchased();
81
- break;
82
-
83
- case 'featured':
84
- case 'popular':
85
- case 'new':
86
- case 'updated':
87
- case 'price':
88
- default:
89
- $api = Sputnik_API::get_all($paged, array('browse' => $tab));
90
- break;
91
- }
92
- }
93
- catch (Exception $e) {
94
- $this->connect_error = true;
95
- return false;
96
- }
97
-
98
- return array('items' => $api['body'], 'pages' => $api['headers']['x-pagecount']);
99
- }
100
-
101
- public function no_items() {
102
- echo '<p>' . __( 'No plugins match your request.', 'wpsc' ) . '</p>';
103
- }
104
-
105
- public function footer() {
106
- ?>
107
- <script type="text/html" id="tmpl-sputnik-modal">
108
- <div class="sputnik-modal">
109
- <h3 class="sputnik-modal-title">{{ title }}</h3>
110
- <a class="sputnik-modal-close" href="" title="<?php esc_attr_e('Close'); ?>">&times;</a>
111
- </div>
112
- <div class="sputnik-modal-backdrop">
113
- <div></div>
114
- </div>
115
- </script>
116
- <?php
117
-
118
- parent::footer();
119
- }
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/Grid.php DELETED
@@ -1,327 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_View_Browser_Grid extends WP_List_Table {
4
- public $id = 'grid';
5
-
6
- protected $connect_error = false;
7
-
8
- public function __construct() {
9
- parent::__construct(array(
10
- 'screen' => 'sputnik-browser'
11
- ));
12
- }
13
-
14
- public function ajax_user_can() {
15
- return current_user_can('install_plugins');
16
- }
17
-
18
- public function old_prepare_items() {
19
- $this->parent->prepare_items();
20
- }
21
-
22
- public function prepare_items() {
23
- require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
24
-
25
- global $tabs, $tab, $paged, $type, $term;
26
-
27
- wp_reset_vars( array( 'tab' ) );
28
-
29
- $paged = $this->get_pagenum();
30
-
31
- // These are the tabs which are shown on the page
32
- $tabs = $this->parent->get_tabs();
33
-
34
- $nonmenu_tabs = array( 'account' ); //Valid actions to perform which do not have a Menu item.
35
-
36
- $tabs = apply_filters( 'install_plugins_tabs', $tabs );
37
- $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
38
-
39
- // If a non-valid menu tab has been selected, and its not a non-menu action.
40
- if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
41
- $tab = key( $tabs );
42
-
43
- $args = array();
44
-
45
- $data = $this->parent->get_data($tab);
46
- $this->items = $data['items'];
47
-
48
- $this->set_pagination_args( array(
49
- 'total_items' => $data['pages'],
50
- 'per_page' => 30,
51
- ) );
52
- }
53
-
54
- public function no_items() {
55
- $this->parent->no_items();
56
- }
57
-
58
- public function get_views() {
59
- global $tabs, $tab;
60
-
61
- $display_tabs = array();
62
- foreach ( (array) $tabs as $action => $text ) {
63
- $class = ( $action == $tab ) ? ' class="current"' : '';
64
- $href = $this->parent->get_view_url($action);
65
- $display_tabs['sputnik-browse-' . $action] = "<a href='$href'$class>$text</a>";
66
- }
67
-
68
- return $display_tabs;
69
- }
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
- ?>
78
- <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
79
- <div class="view-switch">
80
- <?php
81
- foreach ( $modes as $mode => $title ) {
82
- $class = ( $current_mode == $mode ) ? 'class="current"' : '';
83
- echo "<a href='" . esc_url( add_query_arg( 'view', $mode, $_SERVER['REQUEST_URI'] ) ) . "' $class><img id='view-switch-$mode' src='" . esc_url( includes_url( 'images/blank.gif' ) ) . "' width='20' height='20' title='$title' alt='$title' /></a>\n";
84
- }
85
- ?>
86
- </div>
87
- <?php
88
- }
89
-
90
- public function pagination( $which ) {
91
- global $mode;
92
-
93
- parent::pagination( $which );
94
-
95
- if ( 'top' == $which )
96
- $this->view_switcher();
97
- }
98
-
99
- public function display() {
100
- if ($this->connect_error) {
101
- ?>
102
- <div class="connect-error">
103
- <h2>Whoops!</h2>
104
- <p>We don't appear to be able to connect to the WPEconomy server right now.
105
- Try again later!</p>
106
- </div>
107
- <?php
108
- return;
109
- }
110
-
111
- $this->display_grid();
112
- }
113
-
114
- protected function display_grid() {
115
- extract( $this->_args );
116
-
117
- $this->display_tablenav( 'top' );
118
- ?>
119
- <div class="grid-view">
120
- <?php
121
- $this->display_rows_or_placeholder();
122
- ?>
123
- </div>
124
- <?php
125
- $this->display_tablenav( 'bottom' );
126
- }
127
-
128
- public function display_tablenav( $which ) {
129
- global $tab;
130
-
131
- if ($tab === 'account')
132
- return;
133
-
134
- $account = Sputnik::get_account();
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
- ?>
142
- <?php Sputnik_Admin::search_form(); ?>
143
- <?php
144
- }
145
- ?>
146
- </div>
147
- <?php
148
- $this->pagination($which);
149
- ?>
150
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-loading list-ajax-loading" alt="" />
151
- <br class="clear" />
152
- </div>
153
- <?php } else { ?>
154
- <div class="tablenav bottom">
155
- <?php $this->pagination($which); ?>
156
- <img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-loading list-ajax-loading" alt="" />
157
- <br class="clear" />
158
- </div>
159
- <?php
160
- }
161
- }
162
-
163
- public function get_table_classes() {
164
- extract( $this->_args );
165
-
166
- return array( 'plugin-install', 'widefat', $plural );
167
- }
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
-
179
- public function display_rows() {
180
- $plugins_allowedtags = array(
181
- 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
182
- 'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ),
183
- 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
184
- 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()
185
- );
186
-
187
- list( $columns, $hidden ) = $this->get_column_info();
188
-
189
- $style = array();
190
- foreach ( $columns as $column_name => $column_display_name ) {
191
- $style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : '';
192
- }
193
-
194
- foreach ( (array) $this->items as $plugin ) {
195
-
196
- $plugin->name = wp_kses( $plugin->name, $plugins_allowedtags );
197
- //Limit description to 400char, and remove any HTML.
198
- $plugin->description = strip_tags( $plugin->description );
199
- if ( strlen( $plugin->description ) > 400 )
200
- $plugin->description = mb_substr( $plugin->description, 0, 400 ) . '&#8230;';
201
- //remove any trailing entities
202
- $plugin->description = preg_replace( '/&[^;\s]{0,6}$/', '', $plugin->description );
203
- //strip leading/trailing & multiple consecutive lines
204
- $plugin->description = trim( $plugin->description );
205
- $plugin->description = preg_replace( "|(\r?\n)+|", "\n", $plugin->description );
206
- //\n => <br>
207
- $plugin->description = nl2br( $plugin->description );
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
-
219
- $this->display_row($plugin, $style);
220
- }
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
-
232
- if ($plugin->slug === '__add_new') {
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 );
241
-
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
- }
278
-
279
- $action_links = apply_filters( 'sputnik_install_grid_action_links', $action_links, $plugin );
280
-
281
- $thumb = false;
282
- if (isset($plugin->thumb) && $plugin->thumb !== false) {
283
- $thumb = $plugin->thumb;
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
326
- }
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Browser/List.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_View_Browser_List extends Sputnik_View_Browser_Grid {
4
- public $id = 'list';
5
-
6
- protected function display_grid() {
7
- WP_List_Table::display();
8
- }
9
- protected function display_row($plugin, $style) {
10
- $name = strip_tags( $plugin->name . ' ' . $plugin->version );
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
-
18
- if ($plugin->slug === '__add_new') {
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 );
27
-
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
- }
64
-
65
- $action_links = apply_filters( 'sputnik_install_row_action_links', $action_links, $plugin );
66
- ?>
67
- <tr>
68
- <td class="name column-name"<?php echo $style['name']; ?>><strong><?php echo $plugin->name; ?></strong>
69
- <div class="action-links"><?php if ( !empty( $action_links ) ) echo implode( ' ', $action_links ); ?></div>
70
- </td>
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>
78
- <td class="desc column-description"<?php echo $style['description']; ?>><?php echo $plugin->description, $plugin->author; ?></td>
79
- </tr>
80
- <?php
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Info.php DELETED
@@ -1,202 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin information view
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Plugin information view
11
- *
12
- * @package Sputnik
13
- * @subpackage Admin View
14
- */
15
- class Sputnik_View_Info extends Sputnik_View_Mini {
16
- protected $body_id = 'sputnik-plugin-information';
17
-
18
- protected $plugin;
19
- protected $api;
20
-
21
- public function __construct() {
22
- parent::__construct( __('Plugin Information', 'wpsc') );
23
- $this->plugin = $_GET['info'];
24
-
25
- try {
26
- $account = Sputnik::get_account();
27
- $this->api = Sputnik::get_plugin($this->plugin, $account->ID);
28
- }
29
- catch (Exception $e) {
30
- status_header(500);
31
- iframe_header( __('', 'wpsc') );
32
- echo $e->getMessage();
33
- iframe_footer();
34
- die();
35
- }
36
- }
37
- public function display() {
38
- global $tab;
39
- require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
40
-
41
- $api = $this->api;
42
-
43
- $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
44
- 'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
45
- 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
46
- 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
47
- 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
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;
60
- $api->author = links_add_target($api->author, '_blank');
61
- foreach ( $api->sections as $section_name => $content )
62
- $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
63
-
64
- $api->screenshots = (array) $api->screenshots;
65
- foreach ( $api->screenshots as &$data ) {
66
- if (!isset($data->caption) || !isset($data->location)) {
67
- continue;
68
- }
69
-
70
- $data->caption = wp_kses($data->caption, $plugins_allowedtags);
71
- $data->location = esc_url($data->location, array('http', 'https'));
72
- }
73
- unset($data);
74
-
75
- foreach ( array( 'version', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
76
- if ( isset( $api->$key ) )
77
- $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
78
- }
79
-
80
- $section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
81
- if ( empty($section) || (!isset($api->sections[ $section ]) && ($section !== 'screenshots' || empty($api->screenshots))) )
82
- $section = array_shift( $section_titles = array_keys((array)$api->sections) );
83
-
84
- ?>
85
- <div class="alignleft fyi">
86
- <h1><?php echo $api->name ?></h1>
87
- <?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>
88
- <p class="action-button">
89
- <?php
90
- $status = Sputnik_Admin::install_status($api);
91
- switch ( $status['status'] ) {
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
- ?>
113
- </p>
114
- <?php endif; ?>
115
- <?php
116
- echo "<div id='plugin-information-header'>\n";
117
- echo "<ul id='sidemenu'>\n";
118
- foreach ( (array)$api->sections as $section_name => $content ) {
119
- if ( isset( $plugins_section_titles[ $section_name ] ) )
120
- $title = $plugins_section_titles[ $section_name ];
121
- else
122
- $title = ucwords( str_replace( '_', ' ', $section_name ) );
123
-
124
- $class = ( $section_name == $section ) ? ' class="current"' : '';
125
- $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
126
- $href = esc_url($href);
127
- $san_section = esc_attr($section_name);
128
- echo "\t<li><a name='$san_section' href='$href'$class>$title</a></li>\n";
129
- }
130
- if (!empty($api->screenshots)) {
131
- $title = $plugins_section_titles['screenshots'];
132
- $class = ( 'screenshots' == $section ) ? ' class="current"' : '';
133
- $href = add_query_arg( array('tab' => $tab, 'section' => 'screenshots') );
134
- $href = esc_url($href);
135
- echo "\t<li><a name='screenshots' href='$href'$class>$title</a></li>\n";
136
- }
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
-
160
- </div>
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 ] ) )
171
- $title = $plugins_section_titles[ $section_name ];
172
- else
173
- $title = ucwords( str_replace( '_', ' ', $section_name ) );
174
-
175
- $content = links_add_base_url($content, $api->permalink);
176
- $content = links_add_target($content, '_blank');
177
-
178
- $san_section = esc_attr($title);
179
-
180
- $display = ( $section_name == $section ) ? 'block' : 'none';
181
-
182
- echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
183
- echo "\t\t<h2 class='long-header'>$title</h2>";
184
- echo $content;
185
- echo "\t</div>\n";
186
- }
187
-
188
- if (!empty($api->screenshots)) {
189
- $display = ( 'screenshots' == $section ) ? 'block' : 'none';
190
- echo "\t<div id='section-screenshots' class='section' style='display: {$display};'>\n";
191
- echo "\t\t<h2 class='long-header'>Screenshots</h2>\n";
192
- echo "\t\t<ol>\n";
193
- foreach ($api->screenshots as $data) {
194
- echo "\t\t\t<li><img src='{$data->location}' class='screenshot' /><p>{$data->caption}</p></li>\n";
195
- }
196
- echo "\t\t</ol>\n";
197
- echo "\t</div>\n";
198
- }
199
-
200
- echo "</div>\n";
201
- }
202
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Install.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
- /**
3
- * Popup installer view
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Popup installer view
11
- *
12
- * @package Sputnik
13
- * @subpackage Admin View
14
- */
15
- class Sputnik_View_Install extends Sputnik_View_Mini {
16
- protected $body_id = 'sputnik-install';
17
-
18
- protected $id;
19
- protected $nonce_prefix = 'sputnik_install-plugin_';
20
- protected $title_format = 'Installing Plugin: %s';
21
- protected $upgrader = null;
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);
35
- }
36
- catch (Exception $e) {
37
- status_header(500);
38
-
39
- $this->header();
40
- echo '<p>' . $e->getMessage() . '</p>';
41
- $this->footer();
42
- return;
43
- }
44
-
45
- if (!Sputnik::is_purchased($this->api->slug)) {
46
- wp_redirect(Sputnik_Admin::build_url(array('buy' => $this->id)));
47
- die();
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
-
55
- include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
56
-
57
- $title = sprintf( $this->title_format, $this->api->name . ' ' . $this->api->version );
58
- $nonce = $this->nonce_prefix . $this->id;
59
- $url = 'update.php?action=install-plugin&plugin=' . $this->id;
60
- if ( isset($_GET['from']) )
61
- $url .= '&from=' . urlencode(stripslashes($_GET['from']));
62
-
63
- $type = 'web'; //Install plugin type, From Web or an Upload.
64
-
65
- if ( $this->api->is_theme )
66
- $this->upgrader = new Sputnik_ThemeUpgrader( new Sputnik_View_Install_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
67
- else
68
- $this->upgrader = new Sputnik_Upgrader( new Sputnik_View_Install_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
69
-
70
- }
71
-
72
- public function render() {
73
- $this->prepare();
74
- $this->header();
75
- add_filter('http_request_args', array('Sputnik_Updater', 'mangle_http'), 10, 2);
76
- $this->upgrader->install($this->api->download_link);
77
- remove_filter('http_request_args', array('Sputnik_Updater', 'mangle_http'), 10, 2);
78
- $this->footer();
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Install/Skin.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
-
3
- class Sputnik_View_Install_Skin extends WP_Upgrader_Skin {
4
- public $api;
5
- public $type;
6
-
7
- function __construct($args = array()) {
8
- $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
9
- $args = wp_parse_args($args, $defaults);
10
-
11
- $this->type = $args['type'];
12
- $this->api = isset($args['api']) ? $args['api'] : array();
13
-
14
- parent::__construct($args);
15
- }
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
-
23
- echo '<script>if (window.parent.tb_showIframe) { window.parent.tb_showIframe(); }</script>';
24
- }
25
-
26
- function after() {
27
-
28
- $plugin_file = $this->upgrader->plugin_info();
29
-
30
- $install_actions = array();
31
-
32
- $from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins';
33
-
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)) {
57
- unset( $install_actions['activate_plugin'] );
58
- unset( $install_actions['network_activate'] );
59
- }
60
- $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
61
- if ( ! empty($install_actions) )
62
- $this->feedback(implode(' | ', (array)$install_actions));
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Mini.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * Mini view superclass
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Mini view superclass
11
- *
12
- * This is used for embedded views, appearing in an iframe
13
- *
14
- * @package Sputnik
15
- * @subpackage Admin View
16
- */
17
- abstract class Sputnik_View_Mini extends Sputnik_View {
18
- protected $body_id = 'sputnik-unknown';
19
-
20
- protected function header() {
21
- define( 'IFRAME_REQUEST', true );
22
-
23
- global $body_id;
24
- $body_id = $this->body_id;
25
- iframe_header($this->title);
26
- }
27
-
28
- protected function footer() {
29
- iframe_footer();
30
- die();
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/View/Upgrade.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- * Popup upgrader view
4
- *
5
- * @package Sputnik
6
- * @subpackage Admin View
7
- */
8
-
9
- /**
10
- * Popup upgrader view
11
- *
12
- * @package Sputnik
13
- * @subpackage Admin View
14
- */
15
- class Sputnik_View_Upgrade extends Sputnik_View_Install {
16
- protected $file;
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() {
28
- try {
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();
42
- }
43
-
44
- parent::prepare();
45
- }
46
-
47
- public function render() {
48
- $this->prepare();
49
- $this->header();
50
- $this->upgrader->upgrade($this->file);
51
- $this->footer();
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/library/Sputnik/index.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // Silence is golden.
 
 
wpsc-components/marketplace-core-v1/marketplace-core-v1.php DELETED
@@ -1,11 +0,0 @@
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__ );
9
- Sputnik::bootstrap();
10
- }
11
- }
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/static/admin.css DELETED
@@ -1,480 +0,0 @@
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%);
96
- background-image: url('icons.png'), -o-linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
97
- background-image: url('icons.png'), -moz-linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
98
- background-image: url('icons.png'), -webkit-linear-gradient(bottom, rgb(237,237,237) 38%, rgb(255,255,255) 85%);
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 */
129
- .button.buy span {
130
- border-right: 1px solid #C6C6C6;
131
- border-right: 1px solid rgba(0, 0, 0, 0.2);
132
- padding-right: 5px;
133
- }
134
- .button-primary.buy span {
135
- border-right: 1px solid #529DC0;
136
- border-right: 1px solid rgba(255, 255, 255, 0.2);
137
- padding-right: 5px;
138
- }
139
- .action-button .buy span {
140
- padding-right: 7px;
141
- margin-right: 2px;
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 {
280
- margin-bottom: -3px;
281
- }
282
- #sputnik-install, #sputnik-upgrade {
283
- padding: 0 20px;
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 {
450
- max-width: 800px;
451
- overflow: hidden;
452
- background: #fafafa;
453
- border: 1px solid #ccc;
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/static/admin.js DELETED
@@ -1,111 +0,0 @@
1
- jQuery(document).ready(function($) {
2
- var receiveMessage = function() {
3
- if ( event.data == 'tb_close' )
4
- tb_remove();
5
- }
6
- window.addEventListener( 'message', receiveMessage ,false );
7
-
8
- if ( sputnikL10n.buy_id && sputnikL10n.buy_href ) {
9
- var dg = new PAYPAL.apps.DGFlow({trigger:sputnikL10n.buy_id});
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) {
20
- var score = Sputnik.rating_from_event(event);
21
- $('#rateme .star-rating').width(score * 20);
22
- }).mouseleave(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')
30
- }, function (data) {
31
- $('#rateme').data('rating', data.rating);
32
- $('#rateme .star-rating').width(data.rating * 20);
33
- alert('Rating set!');
34
- });
35
- });
36
-
37
- $('.thickbox.info').click(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
-
46
- $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
47
- $('#TB_ajaxWindowTitle').html('<strong>' + sputnikL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
48
-
49
- return false;
50
- });
51
-
52
- $('.button.install').click(function () {
53
- tb_click.call(this);
54
- return false;
55
- });
56
-
57
- $('#sputnik-install a.close,#sputnik-upgrade a.close').click(function () {
58
- if (window.parent !== window) {
59
- window.parent.tb_remove();
60
- return false;
61
- }
62
- });
63
-
64
- $('.buy').click(function(){
65
- var href = $(this).attr('href');
66
- if (href.indexOf('TB_iframe') !== -1) {
67
- tb_show($(this).attr('title'), href);
68
- return false;
69
- }
70
-
71
- var dg = new PAYPAL.apps.DGFlow({trigger:$(this).attr('id')});
72
- dg.startFlow($(this).attr('href'));
73
- return false;
74
- });
75
-
76
- var $_GET = getQueryParams(window.location.search);
77
- if($_GET['run-installer'] != null && $_GET['run-installer'].length > 0 && $('div').closest('#TB_window').size() == 0){
78
- var t = 'Installing ...';
79
- var a = $_GET['run-installer'];
80
-
81
- tb_show(t,a,false);
82
- }
83
-
84
- function getQueryParams(qs) {
85
- qs = qs.split("+").join(" ");
86
- var params = {},
87
- tokens,
88
- re = /[?&]?([^=]+)=([^&]*)/g;
89
-
90
- while (tokens = re.exec(qs)) {
91
- params[decodeURIComponent(tokens[1])]
92
- = decodeURIComponent(tokens[2]);
93
- }
94
- return params;
95
- }
96
- });
97
-
98
- var Sputnik = {
99
- rating_from_event: function (event) {
100
- var score = (event.pageX - jQuery(event.target).offset().left) / 20;
101
- return Math.floor(score) + 1;
102
- },
103
- window_dimensions: function () {
104
- var de = document.documentElement;
105
- var width = window.innerWidth || self.innerWidth
106
- || (de&&de.clientWidth) || document.body.clientWidth;
107
- var height = window.innerHeight || self.innerHeight
108
- || (de&&de.clientHeight) || document.body.clientHeight;
109
- return [width, height];
110
- }
111
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/static/gray-star.png DELETED
Binary file
wpsc-components/marketplace-core-v1/static/grid.png DELETED
Binary file
wpsc-components/marketplace-core-v1/static/icon16.png DELETED
Binary file
wpsc-components/marketplace-core-v1/static/icon32.png DELETED
Binary file
wpsc-components/marketplace-core-v1/static/icons.png DELETED
Binary file
wpsc-components/marketplace-core-v1/static/logo.png DELETED
Binary file
wpsc-components/marketplace-core-v1/static/modal.css DELETED
@@ -1,1628 +0,0 @@
1
- /**
2
- * Base Styles
3
- */
4
- .sputnik-modal,
5
- .sputnik-frame {
6
- font-family: sans-serif;
7
- font-size: 12px;
8
- }
9
-
10
- .sputnik-frame input,
11
- .sputnik-frame textarea {
12
- padding: 6px 8px;
13
- line-height: 16px;
14
- }
15
-
16
- .sputnik-frame select,
17
- .wp-admin .sputnik-frame select {
18
- line-height: 28px;
19
- margin-top: 3px;
20
- }
21
-
22
- .sputnik-frame a {
23
- border-bottom: none;
24
- color: #21759b;
25
- }
26
-
27
- .sputnik-frame a:hover {
28
- color: #d54e21;
29
- }
30
-
31
- .sputnik-frame a.button {
32
- color: #333;
33
- }
34
-
35
- .sputnik-frame a.button:hover {
36
- color: #222;
37
- }
38
-
39
- .sputnik-frame a.button-primary,
40
- .sputnik-frame a.button-primary:hover {
41
- color: #fff;
42
- }
43
-
44
- .sputnik-frame input[type="text"],
45
- .sputnik-frame input[type="password"],
46
- .sputnik-frame input[type="number"],
47
- .sputnik-frame input[type="search"],
48
- .sputnik-frame input[type="email"],
49
- .sputnik-frame input[type="url"],
50
- .sputnik-frame textarea,
51
- .sputnik-frame select {
52
- font-family: sans-serif;
53
- font-size: 12px;
54
- -moz-box-sizing: border-box;
55
- -webkit-box-sizing: border-box;
56
- -ms-box-sizing: border-box; /* ie8 only */
57
- box-sizing: border-box;
58
- -webkit-border-radius: 3px;
59
- border-radius: 3px;
60
- border-width: 1px;
61
- border-style: solid;
62
- border-color: #dfdfdf;
63
- }
64
-
65
- .sputnik-frame select {
66
- height: 24px;
67
- padding: 2px;
68
- }
69
-
70
- .sputnik-frame input:disabled,
71
- .sputnik-frame textarea:disabled,
72
- .sputnik-frame input[readonly],
73
- .sputnik-frame textarea[readonly] {
74
- background-color: #eee;
75
- }
76
-
77
- .sputnik-frame input[type="search"] {
78
- -webkit-appearance: textfield;
79
- }
80
-
81
- .sputnik-frame :-moz-placeholder {
82
- color: #a9a9a9;
83
- }
84
-
85
- /**
86
- * Modal
87
- */
88
- .sputnik-modal {
89
- position: fixed;
90
- top: 30px;
91
- left: 30px;
92
- right: 30px;
93
- bottom: 30px;
94
- z-index: 160000;
95
- }
96
-
97
- .sputnik-modal-backdrop {
98
- position: fixed;
99
- top: 0;
100
- left: 0;
101
- right: 0;
102
- bottom: 0;
103
- min-height: 360px;
104
- background: #000;
105
- opacity: 0.7;
106
- z-index: 159900;
107
- }
108
-
109
- .sputnik-modal-close {
110
- position: absolute;
111
- top: 7px;
112
- right: 7px;
113
- width: 30px;
114
- height: 30px;
115
- z-index: 1000;
116
- }
117
- .sputnik-modal-close span {
118
- display: block;
119
- margin: 8px auto 0;
120
- width: 15px;
121
- height: 15px;
122
- background-position: -100px 0;
123
- }
124
-
125
- .sputnik-modal-close:active {
126
- outline: 0;
127
- }
128
-
129
- .sputnik-modal-content {
130
- position: absolute;
131
- top: 0;
132
- left: 0;
133
- right: 0;
134
- bottom: 0;
135
- overflow: auto;
136
- min-height: 300px;
137
- background: #fff;
138
- }
139
-
140
- .sputnik-modal-icon {
141
- background-image: url(../images/uploader-icons.png);
142
- background-repeat: no-repeat;
143
- }
144
-
145
- /**
146
- * Sidebar
147
- */
148
- .sputnik-sidebar {
149
- position: absolute;
150
- top: 0;
151
- right: 0;
152
- bottom: 0;
153
- width: 267px;
154
- padding: 0 16px 24px;
155
- z-index: 75;
156
- background: #f5f5f5;
157
- border-left: 1px solid #dfdfdf;
158
- overflow: auto;
159
- -webkit-overflow-scrolling: touch;
160
- }
161
-
162
- .hide-toolbar .sputnik-sidebar {
163
- bottom: 0;
164
- }
165
-
166
- .sputnik-sidebar .sidebar-title {
167
- font-weight: 200;
168
- font-size: 20px;
169
- margin: 0;
170
- padding: 12px 10px 10px;
171
- line-height: 28px;
172
- }
173
-
174
- .sputnik-sidebar .sidebar-content {
175
- padding: 0 10px;
176
- margin-bottom: 130px;
177
- }
178
-
179
- .sputnik-sidebar .search {
180
- display: block;
181
- width: 100%;
182
- }
183
-
184
- .sputnik-sidebar h3 {
185
- position: relative;
186
- font-weight: bold;
187
- text-transform: uppercase;
188
- font-size: 12px;
189
- color: #777;
190
- text-shadow: 0 1px 0 #fff;
191
- margin: 24px 0 8px;
192
- }
193
-
194
- .sputnik-sidebar .setting {
195
- display: block;
196
- float: left;
197
- width: 100%;
198
- margin: 1px 0;
199
- }
200
-
201
- .sputnik-sidebar .setting label {
202
- display: block;
203
- }
204
-
205
- .sputnik-sidebar .setting .link-to-custom {
206
- margin: 3px 0;
207
- }
208
-
209
- .sputnik-sidebar .setting span {
210
- min-width: 30%;
211
- margin-right: 4%;
212
- font-size: 12px;
213
- }
214
-
215
- .sputnik-sidebar .setting select {
216
- max-width: 65%;
217
- }
218
-
219
- .sputnik-sidebar .setting input[type="checkbox"] {
220
- width: auto;
221
- float: none;
222
- margin-top: 8px;
223
- padding: 0;
224
- }
225
-
226
- .sputnik-sidebar .setting span,
227
- .compat-item label span {
228
- float: left;
229
- min-height: 22px;
230
- padding-top: 8px;
231
- line-height: 16px;
232
- text-align: right;
233
- font-weight: normal;
234
- color: #999;
235
- text-shadow: 0 1px 0 #fff;
236
- }
237
-
238
- .sputnik-sidebar .setting input,
239
- .sputnik-sidebar .setting textarea {
240
- width: 65%;
241
- float: right;
242
- }
243
-
244
- .sputnik-sidebar .setting textarea,
245
- .compat-item .field textarea {
246
- height: 62px;
247
- resize: vertical;
248
- }
249
-
250
- .sputnik-sidebar select {
251
- margin-top: 3px;
252
- }
253
-
254
- .compat-item {
255
- float: left;
256
- width: 100%;
257
- overflow: hidden;
258
- }
259
-
260
- .compat-item table {
261
- width: 100%;
262
- table-layout: fixed;
263
- border-spacing: 0;
264
- border: 0;
265
- }
266
-
267
- .compat-item tr {
268
- padding: 2px 0;
269
- display: block;
270
- overflow: hidden;
271
- }
272
-
273
- .compat-item .label,
274
- .compat-item .field {
275
- display: block;
276
- margin: 0;
277
- padding: 0;
278
- }
279
-
280
- .compat-item .label {
281
- min-width: 30%;
282
- margin-right: 4%;
283
- float: left;
284
- text-align: right;
285
- }
286
-
287
- .compat-item .label span {
288
- display: block;
289
- width: 100%;
290
- }
291
-
292
- .compat-item .field {
293
- float: right;
294
- width: 65%;
295
- padding-right: 1px;
296
- }
297
-
298
- .compat-item .field input {
299
- width: 100%;
300
- margin: 0;
301
- }
302
-
303
-
304
- /**
305
- * Menu
306
- */
307
- .sputnik-menu {
308
- position: absolute;
309
- top: 0;
310
- left: 0;
311
- right: 0;
312
- bottom: 0;
313
- margin: 0;
314
- padding: 16px 0;
315
- border-right: 1px solid #d9d9d9;
316
- box-shadow: inset -6px 0 6px -6px rgba( 0, 0, 0, 0.2 );
317
- -webkit-user-select: none;
318
- -moz-user-select: none;
319
- -ms-user-select: none;
320
- user-select: none;
321
- }
322
-
323
- .sputnik-menu > a {
324
- display: block;
325
- position: relative;
326
- padding: 4px 20px;
327
- margin: 0;
328
- line-height: 18px;
329
- font-size: 14px;
330
- color: #21759B;
331
- text-shadow: 0 1px 0 #fff;
332
- text-decoration: none;
333
- }
334
-
335
- .sputnik-menu > a:hover {
336
- color: #21759B;
337
- background: rgba( 0, 0, 0, 0.04 );
338
- }
339
-
340
- .sputnik-menu > a:active {
341
- outline: none;
342
- }
343
-
344
- .sputnik-menu .active,
345
- .sputnik-menu .active:hover {
346
- color: #333;
347
- font-weight: bold;
348
- }
349
-
350
- .sputnik-menu .separator {
351
- height: 0;
352
- margin: 12px 20px;
353
- padding: 0;
354
- border-top: 1px solid #dfdfdf;
355
- border-bottom: 1px solid #fff;
356
- }
357
-
358
- /**
359
- * Menu
360
- */
361
- .sputnik-router {
362
- position: relative;
363
- padding: 0 6px;
364
- margin: 0;
365
- clear: both;
366
- -webkit-user-select: none;
367
- -moz-user-select: none;
368
- -ms-user-select: none;
369
- user-select: none;
370
- }
371
-
372
- .sputnik-router > a {
373
- position: relative;
374
- float: left;
375
- padding: 2px 10px;
376
- margin: 0;
377
- height: 18px;
378
- line-height: 18px;
379
- font-size: 14px;
380
- border-right: 1px solid #dfdfdf;
381
- text-shadow: 0 1px 0 #fff;
382
- text-decoration: none;
383
- }
384
-
385
- .sputnik-router > a:last-child {
386
- border-right: 0;
387
- }
388
-
389
- .sputnik-router > a:active,
390
- .sputnik-router > a:focus {
391
- outline: none;
392
- }
393
-
394
- .sputnik-router .active,
395
- .sputnik-router .active:hover {
396
- color: #333;
397
- }
398
-
399
- .sputnik-router .active:after {
400
- content: '';
401
- display: block;
402
- margin: -100px auto 0;
403
- width: 7px;
404
- height: 7px;
405
- background: #fff;
406
- box-shadow: 1px 1px 1px rgba( 0, 0, 0, 0.2 );
407
- z-index: 300;
408
-
409
- -webkit-transform: rotate( 45deg ) translate( 75px, 75px );
410
- -moz-transform: rotate( 45deg ) translate( 75px, 75px );
411
- -ms-transform: rotate( 45deg ) translate( 75px, 75px );
412
- -o-transform: rotate( 45deg ) translate( 75px, 75px );
413
- transform: rotate( 45deg ) translate( 75px, 75px );
414
- }
415
-
416
- /**
417
- * Frame
418
- */
419
- .sputnik-frame {
420
- overflow: hidden;
421
- position: absolute;
422
- top: 0;
423
- left: 0;
424
- right: 0;
425
- bottom: 0;
426
- }
427
-
428
- .sputnik-frame-menu {
429
- position: absolute;
430
- top: 0;
431
- left: 0;
432
- bottom: 0;
433
- width: 199px;
434
- z-index: 150;
435
- }
436
-
437
- .sputnik-frame-title {
438
- position: absolute;
439
- top: 0;
440
- left: 200px;
441
- right: 0;
442
- height: 45px;
443
- z-index: 200;
444
- }
445
-
446
- .sputnik-frame-router {
447
- position: absolute;
448
- top: 45px;
449
- left: 200px;
450
- right: 0;
451
- height: 30px;
452
- z-index: 200;
453
- border-bottom: 1px solid #dfdfdf;
454
- box-shadow: 0 4px 4px -4px rgba( 0, 0, 0, 0.1 );
455
- }
456
-
457
- .sputnik-frame-content {
458
- position: absolute;
459
- top: 75px;
460
- left: 200px;
461
- right: 0;
462
- bottom: 61px;
463
- height: auto;
464
- width: auto;
465
- margin: 0;
466
- overflow: auto;
467
- }
468
-
469
- .sputnik-frame-toolbar {
470
- position: absolute;
471
- left: 200px;
472
- right: 0;
473
- bottom: 0;
474
- height: 60px;
475
- z-index: 100;
476
- border: 0 solid #dfdfdf;
477
- border-width: 1px 0 0 0;
478
- box-shadow: 0 -4px 4px -4px rgba( 0, 0, 0, 0.1 );
479
- }
480
-
481
- .sputnik-frame.hide-menu .sputnik-frame-title,
482
- .sputnik-frame.hide-menu .sputnik-frame-router,
483
- .sputnik-frame.hide-menu .sputnik-frame-toolbar,
484
- .sputnik-frame.hide-menu .sputnik-frame-content {
485
- left: 0;
486
- }
487
-
488
- .sputnik-frame.hide-menu .sputnik-frame-menu {
489
- left: -200px;
490
- }
491
-
492
- .sputnik-frame.hide-toolbar .sputnik-frame-content {
493
- bottom: 0;
494
- }
495
-
496
- .sputnik-frame.hide-toolbar .sputnik-frame-toolbar {
497
- bottom: -61px;
498
- }
499
-
500
- .sputnik-frame.hide-router .sputnik-frame-content {
501
- top: 45px;
502
- }
503
-
504
- .sputnik-frame.hide-router .sputnik-frame-router {
505
- display: none;
506
- }
507
-
508
- .sputnik-frame.hide-router .sputnik-frame-title {
509
- border-bottom: 1px solid #dfdfdf;
510
- box-shadow: 0 4px 4px -4px rgba( 0, 0, 0, 0.1 );
511
- }
512
-
513
- .sputnik-frame .sputnik-toolbar .add-to-gallery {
514
- display: none;
515
- }
516
-
517
- .sputnik-frame-title h1 {
518
- padding: 0 16px;
519
- font-size: 22px;
520
- font-weight: 200;
521
- line-height: 45px;
522
- margin: 0;
523
- }
524
-
525
- /**
526
- * Iframes
527
- */
528
- .sputnik-frame .sputnik-iframe {
529
- overflow: hidden;
530
- }
531
-
532
- .sputnik-frame .sputnik-iframe,
533
- .sputnik-frame .sputnik-iframe iframe {
534
- height: 100%;
535
- width: 100%;
536
- border: 0;
537
- }
538
-
539
- /**
540
- * Attachment Browser Filters
541
- */
542
- .sputnik-frame select.attachment-filters {
543
- margin-top: 11px;
544
- margin-right: 10px;
545
- }
546
-
547
- /**
548
- * Search
549
- */
550
- .sputnik-frame .search {
551
- margin-top: 11px;
552
- padding: 4px;
553
- line-height: 18px;
554
- font-size: 13px;
555
- color: #464646;
556
- font-family: sans-serif;
557
- -webkit-appearance: none;
558
- }
559
-
560
- .sputnik-toolbar-secondary .search {
561
- margin-right: 16px;
562
- }
563
-
564
- /**
565
- * Attachments
566
- */
567
- .attachments {
568
- margin: 0;
569
- padding-right: 16px;
570
- -webkit-overflow-scrolling: touch;
571
- }
572
-
573
- /**
574
- * Attachment
575
- */
576
- .attachment {
577
- position: relative;
578
- float: left;
579
-
580
- padding: 0;
581
- margin: 0 10px 20px;
582
- color: #464646;
583
- list-style: none;
584
- text-align: center;
585
-
586
- -webkit-user-select: none;
587
- -moz-user-select: none;
588
- -ms-user-select: none;
589
- -o-user-select: none;
590
- user-select: none;
591
- }
592
-
593
- .selected.attachment {
594
- box-shadow:
595
- 0 0 0 1px #fff,
596
- 0 0 0 3px #ccc;
597
- }
598
-
599
- .details.attachment {
600
- box-shadow:
601
- 0 0 0 1px #fff,
602
- 0 0 0 5px #1e8cbe;
603
- }
604
-
605
- .attachment-preview {
606
- position: relative;
607
- width: 199px;
608
- height: 199px;
609
- box-shadow:
610
- inset 0 0 15px rgba( 0, 0, 0, 0.1 ),
611
- inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );
612
- background: #eee;
613
- cursor: pointer;
614
- }
615
-
616
- .attachment .icon {
617
- margin: 0 auto;
618
- overflow: hidden;
619
- padding-top: 20%;
620
- }
621
-
622
- .attachment .thumbnail {
623
- display: block;
624
- position: absolute;
625
- top: 0;
626
- left: 0;
627
- margin: 0 auto;
628
- overflow: hidden;
629
- max-width: 100%;
630
- max-height: 100%;
631
- }
632
-
633
- .attachment-preview .thumbnail:after {
634
- content: '';
635
- display: block;
636
- position: absolute;
637
- top: 0;
638
- left: 0;
639
- right: 0;
640
- bottom: 0;
641
- box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.1 );
642
- overflow: hidden;
643
- }
644
-
645
- .attachment .thumbnail img {
646
- top: 0;
647
- left: 0;
648
- }
649
-
650
- .attachment .thumbnail .centered {
651
- position: absolute;
652
- top: 0;
653
- left: 0;
654
- width: 100%;
655
- height: 100%;
656
- -webkit-transform: translate( 50%, 50% );
657
- -moz-transform: translate( 50%, 50% );
658
- -ms-transform: translate( 50%, 50% );
659
- -o-transform: translate( 50%, 50% );
660
- transform: translate( 50%, 50% );
661
- }
662
-
663
- .attachment .thumbnail .centered img {
664
- -webkit-transform: translate( -50%, -50% );
665
- -moz-transform: translate( -50%, -50% );
666
- -ms-transform: translate( -50%, -50% );
667
- -o-transform: translate( -50%, -50% );
668
- transform: translate( -50%, -50% );
669
- }
670
-
671
- .attachment .filename {
672
- position: absolute;
673
- left: 0;
674
- right: 0;
675
- bottom: 0;
676
- overflow: hidden;
677
- max-height: 100%;
678
-
679
- word-wrap: break-word;
680
- text-align: center;
681
- font-weight: bold;
682
- background: rgba( 255, 255, 255, 0.8 );
683
- box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.15 );
684
- }
685
-
686
- .attachment .filename div {
687
- padding: 5px 10px;
688
- }
689
-
690
- .attachment-preview .thumbnail {
691
- width: 199px;
692
- height: 199px;
693
- }
694
-
695
- .attachment .thumbnail img {
696
- position: absolute;
697
- }
698
-
699
- .attachment .close {
700
- display: none;
701
- position: absolute;
702
- top: 5px;
703
- right: 5px;
704
- height: 22px;
705
- width: 22px;
706
- padding: 0;
707
- font-size: 20px;
708
- line-height: 20px;
709
- text-align: center;
710
- text-decoration: none;
711
- color: #464646;
712
- background-color: #fff;
713
- background-position: -96px 4px;
714
- border-width: 0;
715
- border-radius: 3px;
716
- box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.3 );
717
- }
718
-
719
- .attachment .close:hover {
720
- box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.6 );
721
- }
722
-
723
- .attachment:hover .close {
724
- display: block;
725
- }
726
-
727
- .attachment .check {
728
- display: none;
729
- height: 24px;
730
- width: 24px;
731
- position: absolute;
732
- top: -7px;
733
- right: -7px;
734
- outline: none;
735
-
736
- border: 1px solid #fff;
737
- border-radius: 3px;
738
- box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.4 );
739
-
740
- background: #f1f1f1;
741
- background-image: -webkit-gradient(linear, left top, left bottom, from(#f1f1f1), to(#e1e1e1));
742
- background-image: -webkit-linear-gradient(top, #f1f1f1, #e1e1e1);
743
- background-image: -moz-linear-gradient(top, #f1f1f1, #e1e1e1);
744
- background-image: -o-linear-gradient(top, #f1f1f1, #e1e1e1);
745
- background-image: linear-gradient(to bottom, #f1f1f1, #e1e1e1);
746
- }
747
-
748
- .attachment .check div {
749
- background-position: -1px 0;
750
- height: 15px;
751
- width: 15px;
752
- margin: 5px;
753
- }
754
-
755
- .attachment .check:hover div {
756
- background-position: -40px 0;
757
- }
758
-
759
- .attachment.selected .check {
760
- display: block;
761
- }
762
-
763
- .attachment.details .check {
764
- box-shadow: 0 0 0 1px #1e8cbe;
765
-
766
- background: #1e8cbe;
767
- background-image: -webkit-gradient(linear, left top, left bottom, from(#1e8cbe), to(#0074a2));
768
- background-image: -webkit-linear-gradient(top, #1e8cbe, #0074a2);
769
- background-image: -moz-linear-gradient(top, #1e8cbe, #0074a2);
770
- background-image: -o-linear-gradient(top, #1e8cbe, #0074a2);
771
- background-image: linear-gradient(to bottom, #1e8cbe, #0074a2);
772
- }
773
-
774
- .attachment.details .check div {
775
- background-position: -21px 0;
776
- }
777
-
778
- .attachment.details .check:hover div {
779
- background-position: -60px 0;
780
- }
781
-
782
- .sputnik-frame .attachment .describe {
783
- position: relative;
784
- display: block;
785
- width: 100%;
786
- margin: -1px 0 0;
787
- padding: 8px;
788
- font-size: 12px;
789
- border-radius: 0;
790
- }
791
-
792
- /**
793
- * Attachments Browser
794
- */
795
- .sputnik-frame .attachments-browser {
796
- position: relative;
797
- width: 100%;
798
- height: 100%;
799
- overflow: hidden;
800
- }
801
-
802
- .attachments-browser .sputnik-toolbar {
803
- right: 300px;
804
- height: 50px;
805
- }
806
-
807
- .attachments-browser .sputnik-toolbar-primary > .sputnik-button,
808
- .attachments-browser .sputnik-toolbar-primary > .sputnik-button-group,
809
- .attachments-browser .sputnik-toolbar-secondary > .sputnik-button,
810
- .attachments-browser .sputnik-toolbar-secondary > .sputnik-button-group {
811
- margin-top: 10px;
812
- }
813
-
814
- .attachments-browser .attachments,
815
- .attachments-browser .uploader-inline {
816
- position: absolute;
817
- top: 50px;
818
- left: 0;
819
- right: 300px;
820
- bottom: 0;
821
- overflow: auto;
822
- }
823
-
824
- .attachments-browser .instructions {
825
- display: inline-block;
826
- margin-top: 16px;
827
- line-height: 18px;
828
- font-size: 13px;
829
- color: #999;
830
- }
831
-
832
- /**
833
- * Progress Bar
834
- */
835
- .sputnik-progress-bar {
836
- position: relative;
837
- height: 10px;
838
- width: 70%;
839
- margin: 10px auto;
840
- border-radius: 10px;
841
- background: #dfdfdf;
842
- background: rgba( 0, 0, 0, 0.1 );
843
- }
844
-
845
- .sputnik-progress-bar div {
846
- height: 10px;
847
- min-width: 20px;
848
- width: 0;
849
- background: #aaa;
850
- background: rgba( 0, 0, 0, 0.2 );
851
- border-radius: 10px;
852
- -webkit-transition: width 300ms;
853
- -moz-transition: width 300ms;
854
- -ms-transition: width 300ms;
855
- -o-transition: width 300ms;
856
- transition: width 300ms;
857
- }
858
-
859
- .sputnik-uploader-status .sputnik-progress-bar {
860
- display: none;
861
- width: 100%;
862
- }
863
-
864
- .uploading.sputnik-uploader-status .sputnik-progress-bar {
865
- display: block;
866
- }
867
-
868
- .attachment-preview .sputnik-progress-bar {
869
- position: absolute;
870
- top: 50%;
871
- left: 15%;
872
- width: 70%;
873
- margin: -5px 0 0 0;
874
- }
875
-
876
- .sputnik-uploader-status {
877
- position: relative;
878
- margin: 0 auto;
879
- padding-bottom: 10px;
880
- max-width: 400px;
881
- }
882
-
883
- .sputnik-sidebar .sputnik-uploader-status {
884
- border-bottom: 1px solid #dfdfdf;
885
- box-shadow: 0 1px 0 #fff;
886
- }
887
-
888
- .uploader-inline .sputnik-uploader-status h3 {
889
- display: none;
890
- }
891
-
892
- .sputnik-uploader-status .upload-details {
893
- display: none;
894
- font-size: 12px;
895
- color: #666;
896
- text-shadow: 0 1px 0 #fff;
897
- }
898
-
899
- .uploading.sputnik-uploader-status .upload-details {
900
- display: block;
901
- }
902
-
903
- .sputnik-uploader-status .upload-detail-separator {
904
- padding: 0 4px;
905
- }
906
-
907
- .sputnik-uploader-status .upload-count {
908
- color: #464646;
909
- }
910
-
911
- .sputnik-uploader-status .upload-dismiss-errors,
912
- .sputnik-uploader-status .upload-errors {
913
- display: none;
914
- }
915
-
916
- .errors.sputnik-uploader-status .upload-dismiss-errors,
917
- .errors.sputnik-uploader-status .upload-errors {
918
- display: block;
919
- }
920
-
921
- .sputnik-uploader-status .upload-dismiss-errors {
922
- text-decoration: none;
923
- }
924
-
925
- .sputnik-sidebar .sputnik-uploader-status .upload-dismiss-errors {
926
- position: absolute;
927
- top: 0;
928
- right: 0;
929
- }
930
-
931
- .upload-errors .upload-error {
932
- margin: 8px auto 0 auto;
933
- padding: 8px;
934
- border: 1px #c00 solid;
935
- background: #ffebe8;
936
- border-radius: 3px;
937
- }
938
-
939
- .upload-errors .upload-error-label {
940
- padding: 2px 4px;
941
- margin-right: 8px;
942
- font-weight: bold;
943
- color: #fff;
944
- background: #e00;
945
- background-image: -webkit-gradient(linear, left top, left bottom, from(#e00), to(#a00));
946
- background-image: -webkit-linear-gradient(top, #e00, #a00);
947
- background-image: -moz-linear-gradient(top, #e00, #a00);
948
- background-image: -o-linear-gradient(top, #e00, #a00);
949
- background-image: linear-gradient(to bottom, #e00, #a00);
950
- border-radius: 3px;
951
- }
952
-
953
- .upload-errors .upload-error-message {
954
- display: block;
955
- padding-top: 8px;
956
- color: #b44;
957
- word-wrap: break-word;
958
- }
959
-
960
- .uploader-window {
961
- position: fixed;
962
- top: 0;
963
- left: 0;
964
- right: 0;
965
- bottom: 0;
966
- background: rgba( 0, 86, 132, 0.9 );
967
-
968
- z-index: 250000;
969
- display: none;
970
- text-align: center;
971
- opacity: 0;
972
-
973
- -webkit-transition: opacity 250ms;
974
- -moz-transition: opacity 250ms;
975
- -ms-transition: opacity 250ms;
976
- -o-transition: opacity 250ms;
977
- transition: opacity 250ms;
978
- }
979
-
980
- .uploader-window-content {
981
- position: absolute;
982
- top: 10px;
983
- left: 10px;
984
- right: 10px;
985
- bottom: 10px;
986
- border: 1px dashed #fff;
987
- }
988
-
989
- .uploader-window h3 {
990
- position: absolute;
991
- top: 50%;
992
- left: 0;
993
- right: 0;
994
- -webkit-transform: translateY( -50% );
995
- -moz-transform: translateY( -50% );
996
- -ms-transform: translateY( -50% );
997
- -o-transform: translateY( -50% );
998
- transform: translateY( -50% );
999
-
1000
- font-size: 20px;
1001
- font-weight: 200;
1002
- color: #fff;
1003
- padding: 0;
1004
- }
1005
-
1006
- .uploader-window .sputnik-progress-bar {
1007
- margin-top: 20px;
1008
- max-width: 300px;
1009
- background: transparent;
1010
- border-color: #fff;
1011
- display: none;
1012
- }
1013
-
1014
- .uploader-window .sputnik-progress-bar div {
1015
- background: #fff;
1016
- }
1017
-
1018
- .uploading .uploader-window .sputnik-progress-bar {
1019
- display: block;
1020
- }
1021
-
1022
- .sputnik-frame .uploader-inline {
1023
- margin: 20px;
1024
- padding: 20px;
1025
- text-align: center;
1026
- }
1027
-
1028
- .uploader-inline-content {
1029
- position: absolute;
1030
- top: 30%;
1031
- left: 0;
1032
- right: 0;
1033
- }
1034
-
1035
- .uploader-inline-content .upload-ui {
1036
- margin: 4em 0;
1037
- }
1038
-
1039
- .uploader-inline-content .post-upload-ui {
1040
- margin-bottom: 2em;
1041
- }
1042
-
1043
- .uploader-inline .has-upload-message .upload-ui {
1044
- margin: 0 0 4em;
1045
- }
1046
-
1047
- .uploader-inline h3 {
1048
- font-size: 20px;
1049
- line-height: 28px;
1050
- font-weight: 200;
1051
- margin-bottom: 1.6em;
1052
- }
1053
-
1054
- .uploader-inline .has-upload-message .upload-instructions {
1055
- font-size: 14px;
1056
- color: #464646;
1057
- font-weight: normal;
1058
- }
1059
-
1060
- .uploader-inline .drop-instructions {
1061
- display: none;
1062
- }
1063
-
1064
- .supports-drag-drop .uploader-inline .drop-instructions {
1065
- display: block;
1066
- }
1067
-
1068
- .uploader-inline p {
1069
- font-size: 12px;
1070
- }
1071
-
1072
- .uploader-inline .sputnik-progress-bar {
1073
- display: none;
1074
- }
1075
-
1076
- .uploading.uploader-inline .sputnik-progress-bar {
1077
- display: block;
1078
- }
1079
-
1080
- .uploader-inline .browser {
1081
- display: inline-block !important;
1082
- }
1083
-
1084
- /**
1085
- * Selection
1086
- */
1087
- .sputnik-selection {
1088
- position: absolute;
1089
- top: 0;
1090
- left: 0;
1091
- right: 350px;
1092
- height: 60px;
1093
- padding: 0 0 0 16px;
1094
- overflow: hidden;
1095
- white-space: nowrap;
1096
- }
1097
-
1098
- .sputnik-selection .selection-info {
1099
- display: inline-block;
1100
- font-size: 12px;
1101
- height: 60px;
1102
- margin-right: 10px;
1103
- vertical-align: top;
1104
- }
1105
-
1106
- .sputnik-selection.empty,
1107
- .sputnik-selection.editing {
1108
- display: none;
1109
- }
1110
-
1111
- .sputnik-selection.one .edit-selection {
1112
- display: none;
1113
- }
1114
-
1115
- .sputnik-selection .count {
1116
- display: block;
1117
- padding-top: 12px;
1118
- font-size: 14px;
1119
- line-height: 20px;
1120
- font-weight: bold;
1121
- }
1122
-
1123
- .sputnik-selection .selection-info a {
1124
- display: block;
1125
- float: left;
1126
- padding: 1px 8px;
1127
- margin: 1px 8px 1px -8px;
1128
- line-height: 16px;
1129
- text-decoration: none;
1130
- border-right: 1px solid #dfdfdf;
1131
- color: #21759B;
1132
- }
1133
-
1134
- .sputnik-selection .selection-info a:hover {
1135
- background: #21759B;
1136
- color: #fff;
1137
- border-color: transparent;
1138
- }
1139
-
1140
- .sputnik-selection .selection-info a:last-child {
1141
- border-right: 0;
1142
- margin-right: 0;
1143
- }
1144
-
1145
- .sputnik-selection .selection-info .clear-selection {
1146
- color: red;
1147
- }
1148
-
1149
- .sputnik-selection .selection-info .clear-selection:hover {
1150
- background: red;
1151
- }
1152
-
1153
- .sputnik-selection .selection-view {
1154
- display: inline-block;
1155
- vertical-align: top;
1156
- }
1157
-
1158
- .sputnik-selection .attachments {
1159
- display: inline-block;
1160
- height: 48px;
1161
- margin-top: 5px;
1162
- overflow: hidden;
1163
- vertical-align: top;
1164
- }
1165
-
1166
- .sputnik-selection .attachment .icon {
1167
- width: 50%;
1168
- }
1169
-
1170
- .attachment.selection.selected {
1171
- box-shadow: none;
1172
- }
1173
-
1174
- .attachment.selection.details {
1175
- box-shadow:
1176
- 0 0 0 1px #fff,
1177
- 0 0 0 4px #1e8cbe;
1178
- }
1179
-
1180
- .sputnik-selection .attachment.selection.details {
1181
- box-shadow:
1182
- 0 0 0 1px #fff,
1183
- 0 0 0 3px #1e8cbe;
1184
- }
1185
-
1186
- .sputnik-selection:after {
1187
- content: '';
1188
- display: block;
1189
- position: absolute;
1190
- top: 0;
1191
- right: 0;
1192
- bottom: 0;
1193
- width: 25px;
1194
- background-image: -webkit-gradient(linear, right top, left top, from( rgba( 255, 255, 255, 1 ) ), to( rgba( 255, 255, 255, 0 ) ));
1195
- background-image: -webkit-linear-gradient(right, rgba( 255, 255, 255, 1 ) , rgba( 255, 255, 255, 0 ) );
1196
- background-image: -moz-linear-gradient(right, rgba( 255, 255, 255, 1 ) , rgba( 255, 255, 255, 0 ) );
1197
- background-image: -o-linear-gradient(right, rgba( 255, 255, 255, 1 ) , rgba( 255, 255, 255, 0 ) );
1198
- background-image: linear-gradient(to left, rgba( 255, 255, 255, 1 ) , rgba( 255, 255, 255, 0 ) );
1199
- }
1200
-
1201
- .sputnik-selection .attachment .filename {
1202
- display: none;
1203
- }
1204
-
1205
- /**
1206
- * Spinner
1207
- */
1208
-
1209
- .sputnik-frame .spinner {
1210
- background: url(../images/spinner.gif) no-repeat;
1211
- background-size: 16px 16px;
1212
- display: none;
1213
- opacity: 0.7;
1214
- filter: alpha(opacity=70);
1215
- width: 16px;
1216
- height: 16px;
1217
- margin: 0;
1218
- }
1219
-
1220
- .sputnik-sidebar .settings-save-status {
1221
- background: #f5f5f5;
1222
- float: right;
1223
- text-transform: none;
1224
- z-index: 10;
1225
- }
1226
-
1227
- .sputnik-sidebar .settings-save-status .spinner {
1228
- margin: 0 5px 0;
1229
- }
1230
-
1231
- .sputnik-sidebar .settings-save-status .saved {
1232
- float: right;
1233
- display: none;
1234
- }
1235
-
1236
- .sputnik-sidebar .save-waiting .settings-save-status .spinner,
1237
- .sputnik-sidebar .save-complete .settings-save-status .saved {
1238
- display: block;
1239
- }
1240
-
1241
- /**
1242
- * Attachment Details
1243
- */
1244
- .attachment-details {
1245
- position: relative;
1246
- overflow: auto;
1247
- }
1248
-
1249
- .attachment-info {
1250
- overflow: hidden;
1251
- min-height: 60px;
1252
- margin-bottom: 16px;
1253
- line-height: 18px;
1254
- color: #999;
1255
- border-bottom: 1px solid #e5e5e5;
1256
- box-shadow: 0 1px 0 #fff;
1257
- padding-bottom: 11px;
1258
- }
1259
-
1260
- .attachment-info .filename {
1261
- font-weight: bold;
1262
- color: #464646;
1263
- word-wrap: break-word;
1264
- }
1265
-
1266
- .attachment-info .thumbnail {
1267
- position: relative;
1268
- float: left;
1269
- max-width: 120px;
1270
- max-height: 120px;
1271
- margin-top: 5px;
1272
- margin-right: 10px;
1273
- margin-bottom: 5px;
1274
- }
1275
-
1276
- .uploading .attachment-info .thumbnail {
1277
- width: 120px;
1278
- height: 80px;
1279
- box-shadow: inset 0 0 15px rgba( 0, 0, 0, 0.1 );
1280
- }
1281
-
1282
- .uploading .attachment-info .sputnik-progress-bar {
1283
- margin-top: 35px;
1284
- }
1285
-
1286
- .attachment-info .thumbnail:after {
1287
- content: '';
1288
- display: block;
1289
- position: absolute;
1290
- top: 0;
1291
- left: 0;
1292
- right: 0;
1293
- bottom: 0;
1294
- box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.15 );
1295
- overflow: hidden;
1296
- }
1297
-
1298
- .attachment-info .thumbnail img {
1299
- display: block;
1300
- max-width: 120px;
1301
- max-height: 120px;
1302
- margin: 0 auto;
1303
- }
1304
-
1305
- .attachment-info .details {
1306
- float: left;
1307
- font-size: 12px;
1308
- max-width: 100%;
1309
- }
1310
-
1311
- .attachment-info .edit-attachment,
1312
- .attachment-info .refresh-attachment,
1313
- .attachment-info .delete-attachment {
1314
- display: block;
1315
- text-decoration: none;
1316
- white-space: nowrap;
1317
- }
1318
-
1319
- .attachment-info .refresh-attachment,
1320
- .attachment-details.needs-refresh .attachment-info .edit-attachment {
1321
- display: none;
1322
- }
1323
-
1324
- .attachment-details.needs-refresh .attachment-info .refresh-attachment,
1325
- .attachment-info .edit-attachment {
1326
- display: block;
1327
- }
1328
-
1329
- .attachment-info .delete-attachment {
1330
- color: #bc0b0b;
1331
- }
1332
-
1333
- .attachment-info .delete-attachment:hover {
1334
- color: red;
1335
- }
1336
-
1337
- /**
1338
- * Attachment Display Settings
1339
- */
1340
- .attachment-display-settings {
1341
- width: 100%;
1342
- float: left;
1343
- overflow: hidden;
1344
- }
1345
-
1346
- .attachment-display-settings h4 {
1347
- margin: 1.4em 0 0.4em;
1348
- }
1349
-
1350
- .gallery-settings {
1351
- overflow: hidden;
1352
- }
1353
-
1354
- /**
1355
- * Embed from URL
1356
- */
1357
- .embed-url {
1358
- display: block;
1359
- position: relative;
1360
- padding: 0 16px 7px;
1361
- margin: 0;
1362
- z-index: 250;
1363
- background: #fff;
1364
- border-bottom: 1px solid #dfdfdf;
1365
- box-shadow: 0 4px 4px -4px rgba( 0, 0, 0, 0.1 );
1366
- font-size: 18px;
1367
- font-weight: 200;
1368
- }
1369
-
1370
- .sputnik-frame .embed-url input {
1371
- font-size: 18px;
1372
- padding: 12px 14px;
1373
- width: 100%;
1374
- min-width: 200px;
1375
- box-shadow: inset 2px 2px 4px -2px rgba( 0, 0, 0, 0.1 );
1376
- }
1377
-
1378
- .sputnik-frame .embed-url .spinner {
1379
- position: absolute;
1380
- top: 16px;
1381
- right: 26px;
1382
- }
1383
-
1384
- .sputnik-frame .embed-loading .embed-url .spinner {
1385
- display: block;
1386
- }
1387
-
1388
- .embed-link-settings,
1389
- .embed-image-settings {
1390
- position: absolute;
1391
- background: #f5f5f5;
1392
- top: 57px;
1393
- left: 0;
1394
- right: 0;
1395
- bottom: 0;
1396
- padding: 16px 16px 32px;
1397
- overflow: auto;
1398
- }
1399
-
1400
- .sputnik-embed .thumbnail {
1401
- max-width: 100%;
1402
- max-height: 200px;
1403
- position: relative;
1404
- float: left;
1405
- }
1406
-
1407
- .sputnik-embed .thumbnail img {
1408
- max-height: 200px;
1409
- display: block;
1410
- }
1411
-
1412
- .sputnik-embed .thumbnail:after {
1413
- content: '';
1414
- display: block;
1415
- position: absolute;
1416
- top: 0;
1417
- left: 0;
1418
- right: 0;
1419
- bottom: 0;
1420
- box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.1 );
1421
- overflow: hidden;
1422
- }
1423
-
1424
- .sputnik-embed .setting {
1425
- width: 100%;
1426
- margin-top: 10px;
1427
- float: left;
1428
- display: block;
1429
- clear: both;
1430
- }
1431
-
1432
- .sputnik-embed .setting span {
1433
- display: block;
1434
- width: 200px;
1435
- font-size: 13px;
1436
- line-height: 24px;
1437
- color: #999;
1438
- text-shadow: 0 1px 0 #fff;
1439
- }
1440
-
1441
- .sputnik-embed .setting .button-group {
1442
- margin: 2px 0;
1443
- }
1444
-
1445
- .sputnik-embed .setting input,
1446
- .sputnik-embed .setting textarea {
1447
- display: block;
1448
- width: 100%;
1449
- max-width: 400px;
1450
- margin: 1px 0;
1451
- }
1452
-
1453
- /**
1454
- * IE7 Fixes
1455
- */
1456
- .ie7 .sputnik-frame .attachments-browser {
1457
- position: static;
1458
- }
1459
-
1460
- .ie7 .sputnik-frame .embed-url input {
1461
- margin-top: 4px;
1462
- width: 90%;
1463
- }
1464
-
1465
- .ie7 .compat-item {
1466
- width: 99%;
1467
- }
1468
-
1469
- .ie7 .attachment-display-settings {
1470
- width: auto;
1471
- }
1472
-
1473
- .ie7 .attachment-preview,
1474
- .ie7 .attachment-preview .thumbnail {
1475
- width: 120px;
1476
- height: 120px;
1477
- }
1478
-
1479
- .ie7 .sputnik-frame .attachment .describe {
1480
- width: 102px;
1481
- }
1482
-
1483
- .ie7 .sputnik-sidebar .setting select {
1484
- max-width: 55%;
1485
- }
1486
-
1487
- .ie7 .sputnik-sidebar .setting input,
1488
- .ie7 .sputnik-sidebar .setting textarea {
1489
- width: 55%;
1490
- }
1491
-
1492
- .ie7 .sputnik-sidebar .setting .link-to-custom {
1493
- float: left;
1494
- }
1495
-
1496
- @media only screen and (max-width: 960px) {
1497
- .sputnik-frame-content .sputnik-toolbar-primary .search,
1498
- .sputnik-frame-content .sputnik-toolbar-secondary .attachment-filters {
1499
- max-width: 120px;
1500
- }
1501
- }
1502
-
1503
- /**
1504
- * Responsive layout
1505
- */
1506
- @media only screen and (max-width: 900px) {
1507
- .sputnik-frame-menu {
1508
- width: 139px;
1509
- }
1510
-
1511
- .sputnik-menu > a {
1512
- padding: 4px 10px;
1513
- }
1514
-
1515
- .sputnik-frame-title,
1516
- .sputnik-frame-router,
1517
- .sputnik-frame-content,
1518
- .sputnik-frame-toolbar {
1519
- left: 140px;
1520
- }
1521
-
1522
- .sputnik-sidebar {
1523
- width: 159px;
1524
- padding: 0 10px 24px;
1525
- }
1526
-
1527
- .attachments-browser .attachments,
1528
- .attachments-browser .uploader-inline,
1529
- .attachments-browser .sputnik-toolbar {
1530
- right: 180px;
1531
- }
1532
-
1533
- .sputnik-sidebar .setting input,
1534
- .sputnik-sidebar .setting textarea,
1535
- .sputnik-sidebar .setting span,
1536
- .compat-item label span {
1537
- float: none;
1538
- }
1539
-
1540
- .sputnik-sidebar .setting span,
1541
- .compat-item label span {
1542
- text-align: inherit;
1543
- display: block;
1544
- min-height: 16px;
1545
- margin: 0;
1546
- padding: 8px 2px 0;
1547
- }
1548
-
1549
- .sputnik-sidebar .setting input,
1550
- .sputnik-sidebar .setting textarea,
1551
- .sputnik-sidebar .setting select {
1552
- width: 98%;
1553
- max-width: none;
1554
- }
1555
-
1556
- .sputnik-sidebar .setting select.columns {
1557
- width: auto;
1558
- }
1559
-
1560
- .sputnik-frame input,
1561
- .sputnik-frame textarea,
1562
- .sputnik-frame .search {
1563
- padding: 3px 6px;
1564
- }
1565
-
1566
- .sputnik-frame-content .attachment .icon {
1567
- top: 40%;
1568
- }
1569
-
1570
- .sputnik-selection {
1571
- min-width: 120px;
1572
- }
1573
-
1574
- .sputnik-selection:after {
1575
- background: none;
1576
- }
1577
-
1578
- .sputnik-selection .attachments {
1579
- display: none;
1580
- }
1581
-
1582
- .sputnik-menu .separator {
1583
- margin: 12px 10px;
1584
- }
1585
- }
1586
-
1587
- @media only screen and (max-width: 800px) {
1588
- .sputnik-frame-content .sputnik-toolbar .instructions {
1589
- display: none;
1590
- }
1591
- }
1592
-
1593
- @media only screen and (max-width: 680px) {
1594
- .sputnik-frame-content .sputnik-toolbar .search,
1595
- .sputnik-frame-content .sputnik-toolbar .attachment-filters {
1596
- max-width: 85px;
1597
- }
1598
- }
1599
-
1600
- /* Use the same min-width as in the admin */
1601
- @media only screen and (max-width: 600px) {
1602
- .sputnik-modal {
1603
- width: 540px;
1604
- position: absolute;
1605
- }
1606
-
1607
- .sputnik-modal-backdrop {
1608
- width: 600px;
1609
- position: absolute;
1610
- }
1611
- }
1612
-
1613
- /**
1614
- * HiDPI Displays
1615
- */
1616
- @media print,
1617
- (-o-min-device-pixel-ratio: 5/4),
1618
- (-webkit-min-device-pixel-ratio: 1.25),
1619
- (min-resolution: 120dpi) {
1620
- .sputnik-modal-icon {
1621
- background-image: url(../images/uploader-icons-2x.png);
1622
- background-size: 134px 15px;
1623
- }
1624
-
1625
- .sputnik-frame .spinner {
1626
- background-image: url(../images/spinner-2x.gif);
1627
- }
1628
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/static/modal.js DELETED
@@ -1,313 +0,0 @@
1
- window.sputnik = window.sputnik || {};
2
-
3
- (function($){
4
- sputnik = function( attributes ) {
5
- //if ( media.view.MediaFrame.Post )
6
- // return new media.view.MediaFrame.Post( attributes ).render().attach().open();
7
- };
8
-
9
- _.extend( sputnik, { model: {}, view: {}, controller: {} });
10
-
11
- // Link any localized strings.
12
- //l10n = media.model.l10n = _.isUndefined( _wpMediaModelsL10n ) ? {} : _wpMediaModelsL10n;
13
-
14
- _.extend( sputnik, {
15
- /**
16
- * sputnik.template( id )
17
- *
18
- * Fetches a template by id.
19
- *
20
- * @param {string} id A string that corresponds to a DOM element with an id prefixed with "tmpl-".
21
- * For example, "attachment" maps to "tmpl-attachment".
22
- * @return {function} A function that lazily-compiles the template requested.
23
- */
24
- template: _.memoize( function( id ) {
25
- var compiled,
26
- options = {
27
- evaluate: /<#([\s\S]+?)#>/g,
28
- interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
29
- escape: /\{\{([\s\S]+?)\}\}/g
30
- };
31
-
32
- return function( data ) {
33
- compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
34
- return compiled( data );
35
- };
36
- }),
37
- });
38
-
39
- sputnik.controller.Region = function( options ) {
40
- _.extend( this, _.pick( options || {}, 'id', 'controller' ) );
41
-
42
- this.on( 'activate:empty', this.empty, this );
43
- this.mode('empty');
44
- };
45
-
46
- // Use Backbone's self-propagating `extend` inheritance method.
47
- sputnik.controller.Region.extend = Backbone.Model.extend;
48
-
49
- _.extend( sputnik.controller.Region.prototype, Backbone.Events, {
50
- trigger: (function() {
51
- var eventSplitter = /\s+/,
52
- trigger = Backbone.Events.trigger;
53
-
54
- return function( events ) {
55
- var mode = ':' + this._mode,
56
- modeEvents = events.split( eventSplitter ).join( mode ) + mode;
57
-
58
- trigger.apply( this, arguments );
59
- trigger.apply( this, [ modeEvents ].concat( _.rest( arguments ) ) );
60
- return this;
61
- };
62
- }()),
63
-
64
- mode: function( mode ) {
65
- if ( mode ) {
66
- this.trigger('deactivate');
67
- this._mode = mode;
68
- return this.trigger('activate');
69
- }
70
- return this._mode;
71
- },
72
-
73
- view: function( view ) {
74
- var previous = this._view,
75
- mode = this._mode,
76
- id = this.id;
77
-
78
- // If no argument is provided, return the current view.
79
- if ( ! view )
80
- return previous;
81
-
82
- // If we're attempting to switch to the current view, bail.
83
- if ( view === previous )
84
- return;
85
-
86
- // Add classes to the new view.
87
- if ( id )
88
- view.$el.addClass( 'region-' + id );
89
-
90
- if ( mode )
91
- view.$el.addClass( 'mode-' + mode );
92
-
93
- // Remove the hide class.
94
- // this.$el.removeClass( 'hide-' + subview );
95
-
96
- if ( previous ) {
97
- // Replace the view in place.
98
- previous.$el.replaceWith( view.$el );
99
-
100
- // Fire the view's `destroy` event if it exists.
101
- if ( previous.destroy )
102
- previous.destroy();
103
- // Undelegate events.
104
- previous.undelegateEvents();
105
- }
106
-
107
- this._view = view;
108
- },
109
-
110
- empty: function() {
111
- this.view( new Backbone.View() );
112
- }
113
- });
114
-
115
- sputnik.model.Plugin = Backbone.Model.extend({
116
- defaults: {
117
- title: '',
118
- version: '',
119
- tested: '',
120
- requires: '',
121
- rating: 0,
122
- user_rating: 0,
123
- }
124
- })
125
-
126
- /*sputnik.model.Plugin = Backbone.Model.extend({
127
- sync: function( method, model, options ) {
128
- if ( 'read' === method ) {
129
- options = options || {};
130
- options.context = this;
131
- options.data = _.extend( options.data || {}, {
132
- action: 'sputnik-get-plugin',
133
- id: this.id
134
- });
135
- return media.ajax( options );
136
- }
137
- },
138
-
139
- parse: function( resp, xhr ) {
140
- if ( ! resp )
141
- return resp;
142
-
143
- // Convert date strings into Date objects.
144
- resp.date = new Date( resp.date );
145
- resp.modified = new Date( resp.modified );
146
- return resp;
147
- }
148
- }, {
149
- create: function( attrs ) {
150
- return Attachments.all.push( attrs );
151
- },
152
-
153
- get: _.memoize( function( id, attachment ) {
154
- return Attachments.all.push( attachment || { id: id } );
155
- })
156
- });*/
157
-
158
-
159
- /**
160
- * wp.media.view.Frame
161
- */
162
- sputnik.view.Frame = Backbone.View.extend({
163
- className: 'sputnik-frame',
164
- regions: ['menu', 'content'],
165
-
166
- initialize: function() {
167
- this._createRegions();
168
- this._createStates();
169
-
170
- _.defaults( this.options, {
171
- title: '',
172
- modal: true
173
- });
174
-
175
- // Initialize modal container view.
176
- if ( this.options.modal ) {
177
- this.modal = new sputnik.view.Modal({
178
- controller: this,
179
- $content: this.$el,
180
- title: this.options.title
181
- });
182
- }
183
- },
184
-
185
- _createRegions: function() {
186
- // Clone the regions array.
187
- this.regions = this.regions ? this.regions.slice() : [];
188
-
189
- // Initialize regions.
190
- _.each( this.regions, function( region ) {
191
- this[ region ] = new sputnik.controller.Region({
192
- controller: this,
193
- id: region
194
- });
195
- }, this );
196
- },
197
-
198
- _createStates: function() {
199
- // Create the default `states` collection.
200
- this.states = new Backbone.Collection();
201
-
202
- // Ensure states have a reference to the frame.
203
- this.states.on( 'add', function( model ) {
204
- model.frame = this;
205
- }, this );
206
- },
207
-
208
- render: function() {
209
- if ( this.modal )
210
- this.modal.render();
211
-
212
- var els = _.map( this.regions, function( region ) {
213
- return this[ region ].view().el;
214
- }, this );
215
-
216
- // Detach the current views to maintain event bindings.
217
- $( els ).detach();
218
- this.$el.html( els );
219
-
220
- return this;
221
- },
222
-
223
- reset: function() {
224
- this.states.invoke( 'trigger', 'reset' );
225
- }
226
- });
227
-
228
- // Make the `Frame` a `StateMachine`.
229
- //_.extend( media.view.Frame.prototype, media.controller.StateMachine.prototype );
230
-
231
- // Map some of the modal's methods to the frame.
232
- _.each(['open','close','attach','detach'], function( method ) {
233
- sputnik.view.Frame.prototype[ method ] = function( view ) {
234
- if ( this.modal )
235
- this.modal[ method ].apply( this.modal, arguments );
236
- return this;
237
- };
238
- });
239
-
240
- sputnik.view.Modal = Backbone.View.extend({
241
- tagName: 'div',
242
- template: sputnik.template('sputnik-modal'),
243
-
244
- events: {
245
- 'click .sputnik-modal-backdrop, .sputnik-modal-close' : 'closeHandler'
246
- },
247
-
248
- initialize: function() {
249
- //this.controller = this.options.controller;
250
-
251
- _.defaults( this.options, {
252
- container: document.body,
253
- title: ''
254
- });
255
- },
256
-
257
- render: function() {
258
- // Ensure content div exists.
259
- this.options.$content = this.options.$content || $('<div />');
260
-
261
- // Detach the content element from the DOM to prevent
262
- // `this.$el.html()` from garbage collecting its events.
263
- this.options.$content.detach();
264
-
265
- this.$el.html( this.template({
266
- title: this.options.title
267
- }) );
268
-
269
- this.options.$content.addClass('sputnik-modal-content');
270
- this.$('.sputnik-modal').append( this.options.$content );
271
- return this;
272
- },
273
-
274
- attach: function() {
275
- this.$el.appendTo( this.options.container );
276
- //this.controller.trigger( 'attach', this.controller );
277
- return this;
278
- },
279
-
280
- detach: function() {
281
- this.$el.detach();
282
- //this.controller.trigger( 'detach', this.controller );
283
- return this;
284
- },
285
-
286
- open: function() {
287
- this.$el.show();
288
- //this.controller.trigger( 'open', this.controller );
289
- return this;
290
- },
291
-
292
- close: function() {
293
- this.$el.hide();
294
- //this.controller.trigger( 'close', this.controller );
295
- return this;
296
- },
297
-
298
- closeHandler: function( event ) {
299
- event.preventDefault();
300
- this.close();
301
- },
302
-
303
- content: function( $content ) {
304
- // Detach any existing content to prevent events from being lost.
305
- if ( this.options.$content )
306
- this.options.$content.detach();
307
-
308
- // Set and render the content.
309
- this.options.$content = ( $content instanceof Backbone.View ) ? $content.$el : $content;
310
- return this.render();
311
- }
312
- });
313
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/static/sputnik.css DELETED
@@ -1,61 +0,0 @@
1
- div.sputnik-message {
2
- margin: 5px 0 15px;
3
- background-color: rgb( 237, 249, 255 );
4
- border-style: solid;
5
- border-width: 1px 1px 1px 4px;
6
- border-color: rgb(204, 222, 230) rgb(204, 222, 230) rgb(204, 222, 230) rgb(33, 117, 155) ;
7
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
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;
29
- height: 30px;
30
- width: 200px;
31
- line-height: 30px;
32
- margin-right: -7px;
33
- margin-top: -7px;
34
- }
35
- .sputnik-plugin-row-note:hover {
36
- background: #D94C45;
37
- }
38
- .sputnik-plugin-row-note:hover .powered {
39
- display: block;
40
- }
41
- .sputnik-plugin-row-note:hover .corner {
42
- display: none;
43
- }
44
-
45
- .sputnik-plugin-row-note .powered {
46
- display: none;
47
- text-align: center;
48
- color: #fff;
49
- }
50
-
51
- .sputnik-plugin-row-note .corner {
52
- border-left: 15px solid transparent;
53
- border-top: 15px solid transparent;
54
- border-right: 15px solid #D94C45;
55
- border-bottom: 15px solid #D94C45;
56
-
57
- display: block;
58
- float: right;
59
- height: 0;
60
- width: 0;
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-components/marketplace-core-v1/static/sputnik.js DELETED
@@ -1,4 +0,0 @@
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
- });
 
 
 
 
wpsc-components/marketplace-core-v1/static/star.png DELETED
Binary file
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
 
@@ -109,7 +78,7 @@ function _wpsc_filter_merchant_v2_gateway_form( $form, $selected_gateway ) {
109
  $output = ob_get_clean();
110
  $return = array(
111
  'name' => $selected_gateway_data['name'],
112
- 'form_fields' => $output . call_user_func( $selected_gateway_data['form'] ),
113
  'has_submit_button' => 0,
114
  );
115
  }
26
  2
27
  );
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  function _wpsc_filter_merchant_v2_gateway_form( $form, $selected_gateway ) {
30
  global $nzshpcrt_gateways;
31
 
78
  $output = ob_get_clean();
79
  $return = array(
80
  'name' => $selected_gateway_data['name'],
81
+ 'form_fields' => $output . $selected_gateway_data['form'](),
82
  'has_submit_button' => 0,
83
  );
84
  }
wpsc-components/merchant-core-v2/helpers/checkout.php CHANGED
@@ -2,219 +2,26 @@
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
 
52
- function _wpsc_filter_merchant_v2_payment_method_form_fields( $fields ) {
53
- $selected_value = isset( $_POST['wpsc_payment_method'] )
54
- ? $_POST['wpsc_payment_method']
55
- : '';
56
-
57
- if ( empty( $selected_value ) ) {
58
- $current_purchase_log_id = wpsc_get_customer_meta( 'current_purchase_log_id' );
59
- $purchase_log = new WPSC_Purchase_Log( $current_purchase_log_id );
60
- $selected_value = $purchase_log->get( 'gateway' );
61
- }
62
-
63
- foreach ( _wpsc_merchant_v2_get_active_gateways() as $gateway ) {
64
- $gateway = (object) $gateway;
65
- $title = $gateway->name;
66
- if ( ! empty( $gateway->image ) )
67
- $title .= ' <img src="' . $gateway->image . '" alt="' . $gateway->name . '" />';
68
-
69
- $field = array(
70
- 'title' => $title,
71
- 'type' => 'radio',
72
- 'value' => $gateway->internalname,
73
- 'name' => 'wpsc_payment_method',
74
- 'checked' => $selected_value == $gateway->internalname,
75
- );
76
-
77
- $fields[] = $field;
78
- }
79
-
80
- // check the first payment gateway by default
81
- if ( empty( $selected_value ) )
82
- $fields[0]['checked'] = true;
83
-
84
- return $fields;
85
- }
86
-
87
- add_filter(
88
- 'wpsc_payment_method_form_fields',
89
- '_wpsc_filter_merchant_v2_payment_method_form_fields'
90
- );
91
-
92
- function _wpsc_filter_merchant_v2_field_after( $output, $field, $r ) {
93
- if ( $field['name'] != 'wpsc_payment_method' )
94
- return $output;
95
-
96
- foreach ( _wpsc_merchant_v2_get_active_gateways() as $gateway ) {
97
- if ( $gateway['internalname'] == $field['value'] ) {
98
- $extra_form = _wpsc_merchant_v2_get_gateway_form( $gateway );
99
- $extra_form = _wpsc_merchant_v2_hack_gateway_field_names( $extra_form, $gateway );
100
- if ( ! empty( $extra_form ) ) {
101
- $output .= '<table class="wpsc-payment-gateway-extra-form wpsc-payment-gateway-extra-form-' . $gateway['internalname'] . '"><tbody>';
102
- $output .= $extra_form;
103
- $output .= '</tbody></table>';
104
- }
105
- break;
106
- }
107
- }
108
-
109
- return $output;
110
- }
111
- add_filter( 'wpsc_field_after', '_wpsc_filter_merchant_v2_field_after', 10, 3 );
112
-
113
- function _wpsc_merchant_v2_hack_gateway_field_names( $extra_form, $gateway ) {
114
- $fields = array(
115
- 'card_number',
116
- 'card_number1',
117
- 'card_number2',
118
- 'card_number3',
119
- 'card_number4',
120
- 'expiry',
121
- 'card_code',
122
- 'cctype',
123
- );
124
-
125
- $regexp = '/(name\s*=\s*[\'"])(' . implode( '|', $fields ) . ')(["\'\[])/';
126
- $replace = '/$1extra_form[' . $gateway['internalname'] . '][$2]$3';
127
- $extra_form = preg_replace( $regexp, $replace, $extra_form );
128
- return $extra_form;
129
- }
130
-
131
- function _wpsc_merchant_v2_get_active_gateways() {
132
- global $nzshpcrt_gateways;
133
- static $gateways = null;
134
-
135
- if ( is_null( $gateways ) ) {
136
- $active = get_option( 'custom_gateway_options' );
137
- foreach ( $nzshpcrt_gateways as $gateway ) {
138
- if ( in_array( $gateway['internalname'], (array) $active ) )
139
- $gateways[] = $gateway;
140
- }
141
- }
142
-
143
- return $gateways;
144
- }
145
-
146
- function _wpsc_merchant_v2_get_gateway_form( $gateway ) {
147
- global $gateway_checkout_form_fields, $wpsc_gateway_error_messages;
148
-
149
- $submitted_gateway = isset( $_POST['wpsc_payment_method'] )
150
- ? $_POST['wpsc_payment_method']
151
- : '';
152
-
153
- $error = array(
154
- 'card_number' => '',
155
- 'expdate' => '',
156
- 'card_code' => '',
157
- 'cctype' => '',
158
- );
159
-
160
- if (
161
- ! empty( $submitted_gateway )
162
- && $submitted_gateway == $gateway['internalname']
163
- && is_array( $wpsc_gateway_error_messages )
164
- )
165
- $error = array_merge( $error, $wpsc_gateway_error_messages );
166
-
167
- $classes = array();
168
- foreach ( array( 'card_number', 'expdate', 'card_code', 'cctype' ) as $field ) {
169
- if ( empty( $error[$field] ) )
170
- $classes[$field] = '';
171
- else
172
- $classes[$field] = 'class="validation-error"';
173
- }
174
-
175
- // Match fields to gateway
176
- switch ( $gateway['internalname'] ) {
177
- case 'paypal_pro' : // legacy
178
- case 'wpsc_merchant_paypal_pro' :
179
- $output = sprintf(
180
- $gateway_checkout_form_fields[$gateway['internalname']],
181
- $classes['card_number'], $error['card_number'],
182
- $classes['expdate'], $error['expdate'],
183
- $classes['card_code'], $error['card_code'],
184
- $classes['cctype'], $error['cctype']
185
- );
186
- break;
187
-
188
- case 'authorize' :
189
- case 'paypal_payflow' :
190
- $output = @sprintf( $gateway_checkout_form_fields[$gateway['internalname']], $classes['card_number'], $error['card_number'],
191
- $classes['expdate'], $error['expdate'],
192
- $classes['card_code'], $error['card_code']
193
- );
194
- break;
195
-
196
- case 'eway' :
197
- case 'bluepay' :
198
- $output = sprintf( $gateway_checkout_form_fields[$gateway['internalname']], $classes['card_number'], $error['card_number'],
199
- $classes['expdate'], $error['expdate']
200
- );
201
- break;
202
- case 'linkpoint' :
203
- $output = sprintf( $gateway_checkout_form_fields[$gateway['internalname']], $classes['card_number'], $error['card_number'],
204
- $classes['expdate'], $error['expdate']
205
- );
206
- break;
207
-
208
- }
209
-
210
- if ( isset( $output ) && ! empty( $output ) )
211
- return $output;
212
- elseif ( isset( $gateway_checkout_form_fields[$gateway['internalname']] ) )
213
- return $gateway_checkout_form_fields[$gateway['internalname']];
214
- return '';
215
- }
216
-
217
-
218
  add_filter( 'wpsc_gateway_count', '_wpsc_filter_merchant_v2_gateway_count' );
219
 
220
  function _wpsc_filter_merchant_v2_gateway_count( $count ) {
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
+ <img src="<?php echo wpsc_gateway_image_url(); ?>" alt="<?php echo wpsc_gateway_name(); ?>" style="position:relative; top:5px;" />
12
+ <?php endif; ?>
 
 
 
 
 
 
 
 
 
13
  </label>
14
+
15
+ <?php if(wpsc_gateway_form_fields()): ?>
16
+ <table class='wpsc_checkout_table <?php echo wpsc_gateway_form_field_style();?>'>
17
+ <?php echo wpsc_gateway_form_fields();?>
18
  </table>
19
  <?php endif; ?>
20
  </div>
21
+ <?php endwhile;
 
22
  return ob_get_clean();
23
  }
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  add_filter( 'wpsc_gateway_count', '_wpsc_filter_merchant_v2_gateway_count' );
26
 
27
  function _wpsc_filter_merchant_v2_gateway_count( $count ) {
wpsc-components/merchant-core-v2/helpers/gateways.php CHANGED
@@ -1,23 +1,4 @@
1
  <?php
2
- /**
3
- * nzshpcrt_get_gateways()
4
- *
5
- * Deprecated function for returning the merchants global
6
- *
7
- * @global array $nzshpcrt_gateways
8
- * @return array
9
- */
10
- function nzshpcrt_get_gateways() {
11
-
12
- global $nzshpcrt_gateways;
13
-
14
- if ( !is_array( $nzshpcrt_gateways ) )
15
- wpsc_core_load_gateways();
16
-
17
- return $nzshpcrt_gateways;
18
-
19
- }
20
-
21
 
22
  /**
23
  * The WPSC Gateway functions
@@ -67,12 +48,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 +56,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
@@ -263,80 +220,3 @@ add_action(
263
  function _wpsc_merchant_v2_before_shopping_cart() {
264
  $GLOBALS['wpsc_gateway'] = new wpsc_gateways();
265
  }
266
-
267
- add_filter(
268
- '_wpsc_merchant_v2_validate_payment_method',
269
- '_wpsc_action_merchant_v2_validate_payment_method',
270
- 10,
271
- 2
272
- );
273
-
274
- function _wpsc_action_merchant_v2_validate_payment_method( $valid, $controller ) {
275
- $fields = array(
276
- 'card_number',
277
- 'card_number1',
278
- 'card_number2',
279
- 'card_number3',
280
- 'card_number4',
281
- 'card_code',
282
- 'cctype',
283
- );
284
-
285
- $selected_gateway = $_POST['wpsc_payment_method'];
286
- if (
287
- ! isset( $_POST['extra_form'] )
288
- || ! isset( $_POST['extra_form'][$selected_gateway] )
289
- )
290
- return $valid;
291
-
292
- $extra = $_POST['extra_form'][$selected_gateway];
293
- $card_number_error = false;
294
- $messages = array();
295
- foreach ( $fields as $field ) {
296
- if ( isset( $extra[$field] ) && trim( $extra[$field] ) == '' ) {
297
- switch ( $field ) {
298
- case 'card_number':
299
- case 'card_number1':
300
- case 'card_number2':
301
- case 'card_number3':
302
- case 'card_number4':
303
- if ( $card_number_error )
304
- continue;
305
-
306
- $messages['card_number'] = __( 'Please enter a valid credit card number', 'wpsc' );
307
- $card_number_error = true;
308
- break;
309
- case 'card_code':
310
- $messages[$field] = __( 'Please enter a valid CVV', 'wpsc' );
311
- break;
312
- case 'cctype':
313
- $messages[$field] = __( 'Please select a valid credit card type', 'wpsc' );
314
- break;
315
- }
316
- }
317
- }
318
-
319
- if ( ! empty( $extra['expiry'] ) )
320
- foreach ( array( 'month', 'year' ) as $element ) {
321
- if (
322
- empty( $extra['expiry'][$element] )
323
- || ! is_numeric( $extra['expiry'][$element] )
324
- ) {
325
- $messages['expdate'] = __( 'Please specify a valid expiration date.', 'wpsc' );
326
- break;
327
- }
328
- }
329
-
330
- if ( ! empty( $messages ) ) {
331
- foreach ( $messages as $field => $message ) {
332
- $controller->message_collection->add( $message, 'validation' );
333
- }
334
- $GLOBALS['wpsc_gateway_error_messages'] = $messages;
335
- return false;
336
- }
337
-
338
- foreach ( $extra as $key => $value ) {
339
- $_POST[$key] = $value;
340
- }
341
- return true;
342
- }
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
  * The WPSC Gateway functions
48
 
49
  /**
50
  * Return the current gateway's name.
51
+ * @return string The current gateway's name.
 
 
 
 
 
52
  */
53
  function wpsc_gateway_name() {
54
  global $wpsc_gateway;
56
 
57
  $payment_gateway_names = get_option( 'payment_gateway_names' );
58
 
59
+ if ( isset( $payment_gateway_names[$wpsc_gateway->gateway['internalname']] ) && ( $payment_gateway_names[$wpsc_gateway->gateway['internalname']] != '' || wpsc_show_gateway_image() ) ) {
60
+ $display_name = $payment_gateway_names[$wpsc_gateway->gateway['internalname']];
61
+ } elseif ( isset( $wpsc_gateway->gateway['payment_type'] ) ) {
62
+ switch ( $wpsc_gateway->gateway['payment_type'] ) {
63
+ case "paypal":
64
+ case "paypal_pro":
65
+ case "wpsc_merchant_paypal_pro";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  $display_name = __( 'PayPal', 'wpsc' );
67
  break;
68
 
69
+ case "manual_payment":
70
  $display_name = __( 'Manual Payment', 'wpsc' );
71
  break;
72
 
73
+ case "google_checkout":
74
+ $display_name = __( 'Google Wallet', 'wpsc' );
75
+ break;
76
+
77
+ case "credit_card":
78
  default:
79
  $display_name = __( 'Credit Card', 'wpsc' );
80
  break;
81
  }
82
  }
83
+ if ( $display_name == '' && !wpsc_show_gateway_image() ) {
84
+ $display_name = __( 'Credit Card', 'wpsc' );
85
+ }
86
  return $display_name;
87
  }
88
 
 
89
 
90
  /**
91
  * Return the current gateway's internal name
220
  function _wpsc_merchant_v2_before_shopping_cart() {
221
  $GLOBALS['wpsc_gateway'] = new wpsc_gateways();
222
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_