WooCommerce Multilingual – run WooCommerce with WPML - Version 4.2.1

Version Description

  • Added the ability to set custom currencies for orders created via the REST API
  • Filter by translation status displays wrong results on WooCommerce Multilingual products list page
  • Prices were not synced when creating a product translation via REST API
  • Missing Woocommerce pages were created in default language
  • Fatal error while custom call not active currency switcher template
  • Duplicating from WooCommerce resulted in losing language data for the original product
  • Coupon with category restriction removed when switching language on cart page
  • PHP errors were shown on the admin dashboard when no orders existed and displaying errors was on
  • Fixed issue with problem in downloadable products in secondary language with different domain per language is enabled
  • A fatal error (undefiend get_current_screen) was occurring in some conditions on the WP admin side
  • Cart widget shows wrong product names
  • Fixed a small but that defualt currency template didn't load correctly in new installation
  • Added compatibility for grouped products
  • Fixed an issue in lost password endpoint when edit it
  • The cart total in a secondary currencies could have been added a previously removed shipping tax
  • Post translation won't save when Product Bundles plugin is active
  • Fixed comp issue with dynamic price with translated variations don't work in secondary language
  • Cart reset button point to wrong language
  • Fix issue with not matched translated labels because of special characters
  • Fixed an issue when sold individually is enabled and different variations of the same product
  • Fix the ability to set custom download files in downloadable variable products with WCML product editor
  • Fixed small issue in separate file control in downloadable variation product
  • Fix a bug where Variations were made downloadable after their description was updated.
  • Checkout Field Editor compatibility fix
  • Fixed issue with displaying custom prices in Bundles Products
  • Add filter for 'woocommerce_subscriptions_product_price'
  • Fixed compatibi;ity issue with coupos not applied correctly in a subscription product
  • The wcml_raw_price_amount filter could not be used to convert to a different currency than the current user currency
Download this release

Release Info

Developer sergey.r
Plugin Icon 128x128 WooCommerce Multilingual – run WooCommerce with WPML
Version 4.2.1
Comparing to
See all releases

Code changes from version 4.2.0.1 to 4.2.1

Files changed (248) hide show
  1. changelog/4.2.0.md +3 -2
  2. changelog/4.2.1.md +31 -0
  3. compatibility/class-wcml-bookings.php +15 -10
  4. compatibility/class-wcml-checkout-field-editor.php +42 -12
  5. compatibility/class-wcml-dynamic-pricing.php +49 -22
  6. compatibility/class-wcml-product-addons.php +21 -0
  7. compatibility/class-wcml-product-bundles-legacy.php +40 -28
  8. compatibility/class-wcml-product-bundles.php +81 -45
  9. compatibility/class-wcml-table-rate-shipping.php +18 -8
  10. compatibility/class-wcml-wc-subscriptions.php +57 -28
  11. inc/class-wcml-attributes.php +4 -5
  12. inc/class-wcml-cart-switch-lang-functions.php +80 -0
  13. inc/class-wcml-cart.php +51 -13
  14. inc/class-wcml-compatibility.php +5 -1
  15. inc/class-wcml-coupons.php +39 -2
  16. inc/class-wcml-endpoints.php +10 -3
  17. inc/class-wcml-locale.php +7 -1
  18. inc/class-wcml-orders.php +14 -5
  19. inc/class-wcml-products.php +66 -5
  20. inc/class-wcml-resources.php +2 -1
  21. inc/class-wcml-tp-support.php +1 -1
  22. inc/class-wcml-upgrade.php +4 -3
  23. inc/class-wcml-wc-shipping.php +21 -9
  24. inc/class-woocommerce-wpml.php +2 -0
  25. inc/currencies/class-wcml-custom-prices.php +2 -2
  26. inc/currencies/class-wcml-multi-currency-orders.php +10 -7
  27. inc/currencies/class-wcml-multi-currency-prices.php +631 -524
  28. inc/currencies/class-wcml-multi-currency-reports.php +5 -3
  29. inc/currencies/class-wcml-multi-currency-resources.php +1 -1
  30. inc/currencies/class-wcml-multi-currency-shipping.php +53 -42
  31. inc/currencies/class-wcml-multi-currency-table-rate-shipping.php +5 -12
  32. inc/currencies/class-wcml-multi-currency.php +6 -2
  33. inc/currencies/currency-switcher/class-wcml-currency-switcher-templates.php +8 -4
  34. inc/rest-api-support/class-wcml-rest-api-support-v1.php +12 -0
  35. inc/rest-api-support/class-wcml-rest-api-support.php +32 -2
  36. inc/template-classes/class-wcml-products-ui.php +39 -34
  37. inc/template-classes/currency-switcher/class-wcml-currency-switcher-template.php +3 -15
  38. inc/translation-editor/class-wcml-downloadable-products.php +24 -11
  39. inc/translation-editor/class-wcml-editor-ui-product-job.php +2 -2
  40. inc/translation-editor/class-wcml-synchronize-product-data.php +32 -87
  41. readme.txt +34 -6
  42. res/js/cart_widget.js +3 -0
  43. res/js/cart_widget.min.js +1 -1
  44. res/js/lock_fields.js +4 -1
  45. res/js/lock_fields.min.js +1 -1
  46. res/js/lock_fields.min.min.js +1 -0
  47. vendor/autoload.php +1 -1
  48. vendor/autoload_52.php +1 -1
  49. vendor/composer/autoload_classmap.php +1 -172
  50. vendor/composer/autoload_psr4.php +0 -1
  51. vendor/composer/autoload_real.php +4 -4
  52. vendor/composer/autoload_real_52.php +3 -3
  53. vendor/composer/autoload_static.php +6 -185
  54. vendor/otgs/installer/includes/class-installer-dependencies.php +291 -291
  55. vendor/otgs/installer/includes/class-installer-theme.php +978 -978
  56. vendor/otgs/installer/includes/class-installer-upgrader-skins.php +37 -37
  57. vendor/otgs/installer/includes/class-translation-service-info.php +39 -39
  58. vendor/otgs/installer/includes/class-wp-installer-api.php +133 -133
  59. vendor/otgs/installer/includes/class-wp-installer-channels.php +270 -270
  60. vendor/otgs/installer/includes/class-wp-installer.php +2768 -2768
  61. vendor/otgs/installer/includes/functions-core.php +9 -9
  62. vendor/otgs/installer/includes/functions-templates.php +6 -6
  63. vendor/otgs/installer/installer.php +18 -18
  64. vendor/otgs/installer/loader.php +150 -150
  65. vendor/otgs/installer/locale/orig/installer.po +230 -230
  66. vendor/otgs/installer/res/css/admin.css +293 -293
  67. vendor/otgs/installer/res/js/admin.js +460 -460
  68. vendor/otgs/installer/res/js/channels.js +260 -260
  69. vendor/otgs/installer/res/js/iframeResizer.min.js +10 -10
  70. vendor/otgs/installer/res/js/installer_theme_install.js +96 -96
  71. vendor/otgs/installer/templates/channel-selector.php +67 -67
  72. vendor/otgs/installer/templates/downloads-list-compact.php +80 -80
  73. vendor/otgs/installer/templates/downloads-list.php +109 -109
  74. vendor/otgs/installer/templates/products-compact.php +147 -147
  75. vendor/otgs/installer/templates/repository-listing.php +199 -199
  76. vendor/twig/twig/CHANGELOG +0 -43
  77. vendor/twig/twig/ext/twig/php_twig.h +1 -1
  78. vendor/twig/twig/lib/Twig/BaseNodeVisitor.php +0 -4
  79. vendor/twig/twig/lib/Twig/Cache/Filesystem.php +2 -9
  80. vendor/twig/twig/lib/Twig/Cache/Null.php +0 -2
  81. vendor/twig/twig/lib/Twig/CacheInterface.php +0 -2
  82. vendor/twig/twig/lib/Twig/Compiler.php +1 -4
  83. vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php +0 -2
  84. vendor/twig/twig/lib/Twig/Environment.php +7 -26
  85. vendor/twig/twig/lib/Twig/Error.php +5 -3
  86. vendor/twig/twig/lib/Twig/Error/Loader.php +0 -2
  87. vendor/twig/twig/lib/Twig/Error/Runtime.php +0 -2
  88. vendor/twig/twig/lib/Twig/Error/Syntax.php +0 -2
  89. vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php +0 -2
  90. vendor/twig/twig/lib/Twig/ExpressionParser.php +0 -2
  91. vendor/twig/twig/lib/Twig/Extension.php +0 -4
  92. vendor/twig/twig/lib/Twig/Extension/Core.php +29 -63
  93. vendor/twig/twig/lib/Twig/Extension/Debug.php +1 -3
  94. vendor/twig/twig/lib/Twig/Extension/Escaper.php +0 -2
  95. vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php +0 -2
  96. vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php +0 -2
  97. vendor/twig/twig/lib/Twig/Extension/Optimizer.php +0 -2
  98. vendor/twig/twig/lib/Twig/Extension/Profiler.php +0 -3
  99. vendor/twig/twig/lib/Twig/Extension/Sandbox.php +0 -2
  100. vendor/twig/twig/lib/Twig/Extension/Staging.php +0 -2
  101. vendor/twig/twig/lib/Twig/Extension/StringLoader.php +0 -2
  102. vendor/twig/twig/lib/Twig/ExtensionInterface.php +0 -3
  103. vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php +0 -2
  104. vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php +0 -2
  105. vendor/twig/twig/lib/Twig/Lexer.php +0 -2
  106. vendor/twig/twig/lib/Twig/Loader/Array.php +1 -3
  107. vendor/twig/twig/lib/Twig/Loader/Chain.php +0 -2
  108. vendor/twig/twig/lib/Twig/Loader/Filesystem.php +0 -2
  109. vendor/twig/twig/lib/Twig/LoaderInterface.php +0 -2
  110. vendor/twig/twig/lib/Twig/Markup.php +0 -2
  111. vendor/twig/twig/lib/Twig/Node.php +0 -3
  112. vendor/twig/twig/lib/Twig/Node/AutoEscape.php +0 -2
  113. vendor/twig/twig/lib/Twig/Node/Block.php +0 -2
  114. vendor/twig/twig/lib/Twig/Node/BlockReference.php +0 -2
  115. vendor/twig/twig/lib/Twig/Node/Body.php +0 -2
  116. vendor/twig/twig/lib/Twig/Node/CheckSecurity.php +0 -2
  117. vendor/twig/twig/lib/Twig/Node/Do.php +0 -2
  118. vendor/twig/twig/lib/Twig/Node/Embed.php +0 -2
  119. vendor/twig/twig/lib/Twig/Node/Expression.php +0 -2
  120. vendor/twig/twig/lib/Twig/Node/Expression/Array.php +0 -2
  121. vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php +0 -2
  122. vendor/twig/twig/lib/Twig/Node/Expression/Binary.php +0 -2
  123. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php +0 -2
  124. vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php +0 -2
  125. vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php +0 -2
  126. vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php +0 -2
  127. vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php +0 -2
  128. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php +0 -2
  129. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php +0 -2
  130. vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php +0 -2
  131. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php +0 -2
  132. vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php +0 -2
  133. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php +0 -2
  134. vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php +0 -2
  135. vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php +0 -2
  136. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php +0 -2
  137. vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php +0 -2
  138. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php +0 -2
  139. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php +0 -2
  140. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php +0 -2
  141. vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php +0 -2
  142. vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php +0 -2
  143. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php +0 -2
  144. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php +0 -2
  145. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php +0 -2
  146. vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php +0 -2
  147. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php +0 -2
  148. vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +0 -2
  149. vendor/twig/twig/lib/Twig/Node/Expression/Call.php +0 -2
  150. vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php +0 -2
  151. vendor/twig/twig/lib/Twig/Node/Expression/Constant.php +0 -2
  152. vendor/twig/twig/lib/Twig/Node/Expression/Filter.php +0 -2
  153. vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php +0 -2
  154. vendor/twig/twig/lib/Twig/Node/Expression/Function.php +0 -2
  155. vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php +0 -2
  156. vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php +0 -2
  157. vendor/twig/twig/lib/Twig/Node/Expression/Name.php +0 -2
  158. vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php +0 -2
  159. vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +0 -2
  160. vendor/twig/twig/lib/Twig/Node/Expression/TempName.php +0 -2
  161. vendor/twig/twig/lib/Twig/Node/Expression/Test.php +0 -2
  162. vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php +0 -2
  163. vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php +0 -2
  164. vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php +0 -2
  165. vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php +0 -2
  166. vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php +0 -2
  167. vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php +0 -2
  168. vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php +0 -2
  169. vendor/twig/twig/lib/Twig/Node/Expression/Unary.php +0 -2
  170. vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php +0 -2
  171. vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php +0 -2
  172. vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php +0 -2
  173. vendor/twig/twig/lib/Twig/Node/Flush.php +0 -2
  174. vendor/twig/twig/lib/Twig/Node/For.php +0 -2
  175. vendor/twig/twig/lib/Twig/Node/ForLoop.php +0 -2
  176. vendor/twig/twig/lib/Twig/Node/If.php +0 -2
  177. vendor/twig/twig/lib/Twig/Node/Import.php +0 -2
  178. vendor/twig/twig/lib/Twig/Node/Include.php +0 -2
  179. vendor/twig/twig/lib/Twig/Node/Macro.php +0 -2
  180. vendor/twig/twig/lib/Twig/Node/Module.php +0 -2
  181. vendor/twig/twig/lib/Twig/Node/Print.php +0 -2
  182. vendor/twig/twig/lib/Twig/Node/Sandbox.php +0 -2
  183. vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php +0 -2
  184. vendor/twig/twig/lib/Twig/Node/Set.php +0 -2
  185. vendor/twig/twig/lib/Twig/Node/SetTemp.php +0 -5
  186. vendor/twig/twig/lib/Twig/Node/Spaceless.php +0 -2
  187. vendor/twig/twig/lib/Twig/Node/Text.php +0 -2
  188. vendor/twig/twig/lib/Twig/Node/With.php +0 -2
  189. vendor/twig/twig/lib/Twig/NodeCaptureInterface.php +0 -2
  190. vendor/twig/twig/lib/Twig/NodeOutputInterface.php +0 -2
  191. vendor/twig/twig/lib/Twig/NodeTraverser.php +0 -2
  192. vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php +0 -2
  193. vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +0 -2
  194. vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php +0 -2
  195. vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +0 -2
  196. vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +0 -4
  197. vendor/twig/twig/lib/Twig/Parser.php +0 -4
  198. vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php +1 -3
  199. vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php +1 -3
  200. vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php +38 -3
  201. vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php +0 -2
  202. vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php +0 -2
  203. vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php +0 -2
  204. vendor/twig/twig/lib/Twig/Profiler/Profile.php +0 -2
  205. vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php +0 -2
  206. vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php +0 -2
  207. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php +0 -2
  208. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php +0 -2
  209. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php +0 -2
  210. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php +0 -2
  211. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php +0 -2
  212. vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php +0 -2
  213. vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php +0 -2
  214. vendor/twig/twig/lib/Twig/SimpleFilter.php +0 -2
  215. vendor/twig/twig/lib/Twig/SimpleFunction.php +0 -2
  216. vendor/twig/twig/lib/Twig/SimpleTest.php +0 -2
  217. vendor/twig/twig/lib/Twig/Source.php +0 -2
  218. vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php +0 -2
  219. vendor/twig/twig/lib/Twig/Template.php +5 -10
  220. vendor/twig/twig/lib/Twig/TemplateWrapper.php +0 -2
  221. vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +2 -23
  222. vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +1 -8
  223. vendor/twig/twig/lib/Twig/Token.php +0 -2
  224. vendor/twig/twig/lib/Twig/TokenParser.php +0 -2
  225. vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +0 -2
  226. vendor/twig/twig/lib/Twig/TokenParser/Block.php +0 -2
  227. vendor/twig/twig/lib/Twig/TokenParser/Do.php +0 -2
  228. vendor/twig/twig/lib/Twig/TokenParser/Embed.php +0 -2
  229. vendor/twig/twig/lib/Twig/TokenParser/Extends.php +0 -2
  230. vendor/twig/twig/lib/Twig/TokenParser/Filter.php +0 -2
  231. vendor/twig/twig/lib/Twig/TokenParser/Flush.php +0 -2
  232. vendor/twig/twig/lib/Twig/TokenParser/For.php +0 -2
  233. vendor/twig/twig/lib/Twig/TokenParser/From.php +0 -2
  234. vendor/twig/twig/lib/Twig/TokenParser/If.php +0 -2
  235. vendor/twig/twig/lib/Twig/TokenParser/Import.php +0 -2
  236. vendor/twig/twig/lib/Twig/TokenParser/Include.php +2 -2
  237. vendor/twig/twig/lib/Twig/TokenParser/Macro.php +0 -2
  238. vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php +0 -2
  239. vendor/twig/twig/lib/Twig/TokenParser/Set.php +0 -2
  240. vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php +0 -2
  241. vendor/twig/twig/lib/Twig/TokenParser/Use.php +0 -2
  242. vendor/twig/twig/lib/Twig/TokenParser/With.php +0 -2
  243. vendor/twig/twig/lib/Twig/TokenParserInterface.php +0 -4
  244. vendor/twig/twig/lib/Twig/TokenStream.php +0 -2
  245. vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php +0 -2
  246. vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php +0 -2
  247. wpml-config.xml +2 -1
  248. wpml-woocommerce.php +9 -9
changelog/4.2.0.md CHANGED
@@ -1,10 +1,11 @@
1
  # Features
2
  * [wcml-496] Added the ability to translate Sensei question custom post types
3
- * [wcml-1920] Added the ability to translate serialized custom fields in the Translation Editor
4
  * [wcml-1681] Payment method title not displaying in emails Mollie Payment's payment processor compatibility
5
  * [wcml-1672] Show an admin notice for environments in which switching the language or currency on the front end, could corrupt the cart contents
6
 
7
  # Fixes
 
8
  * [wcml-2037] When selecting the currencylayer provider for automatic exchange rate, the API KEY filter was not visible
9
  * [wcml-2025] The multi-currency component made the admin dashboard page loading unnecessarily slow
10
  * [wcml-2019] Variations with custom attributes could not be duplicated as translations
@@ -19,5 +20,5 @@
19
  * [wcml-1936] It was not possible to use the clear cart feature with enabled WPML Ajax cookies only
20
  * [wcml-1934] WooCommerce Product Bundles: Bundled items filtering by variation was not synced with translations
21
  * [wcml-1923] Bookings max availability value was changing after adding bookable product to cart few times
22
- * [wcml-1832] In some cases the option to prompt for a confirmation about resetting the cart when switching the language was not working
23
  * [wcml-1765] The variation names were, sometimes, displayed in the wrong language in the orders, on the back-end
1
  # Features
2
  * [wcml-496] Added the ability to translate Sensei question custom post types
3
+ * [wcml-1920] Added the ability to translate serialized custom fields with in the Translation Editor
4
  * [wcml-1681] Payment method title not displaying in emails Mollie Payment's payment processor compatibility
5
  * [wcml-1672] Show an admin notice for environments in which switching the language or currency on the front end, could corrupt the cart contents
6
 
7
  # Fixes
8
+ * [wcml-2050] Changing the order of the variations was disconnecting them from their translations
9
  * [wcml-2037] When selecting the currencylayer provider for automatic exchange rate, the API KEY filter was not visible
10
  * [wcml-2025] The multi-currency component made the admin dashboard page loading unnecessarily slow
11
  * [wcml-2019] Variations with custom attributes could not be duplicated as translations
20
  * [wcml-1936] It was not possible to use the clear cart feature with enabled WPML Ajax cookies only
21
  * [wcml-1934] WooCommerce Product Bundles: Bundled items filtering by variation was not synced with translations
22
  * [wcml-1923] Bookings max availability value was changing after adding bookable product to cart few times
23
+ * [wcml-1832] In some cases the the option to prompt for a confirmation about resetting the cart when switching the language was not working
24
  * [wcml-1765] The variation names were, sometimes, displayed in the wrong language in the orders, on the back-end
changelog/4.2.1.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Features
2
+ * [wcml-2079] Added the ability to set custom currencies for orders created via the REST API
3
+
4
+ # Fixes
5
+ * [wcml-2104] Filter by translation status displays wrong results on WooCommerce Multilingual products list page
6
+ * [wcml-2103] Prices were not synced when creating a product translation via REST API
7
+ * [wcml-2098] Missing Woocommerce pages were created in default language
8
+ * [wcml-2085] Fatal error while custom call not active currency switcher template
9
+ * [wcml-2075] Duplicating from WooCommerce resulted in losing language data for the original product
10
+ * [wcml-2074] Coupon with category restriction removed when switching language on cart page
11
+ * [wcml-2064] PHP errors were shown on the admin dashboard when no orders existed and displaying errors was on
12
+ * [wcml-2063] Fixed issue with problem in downloadable products in secondary language with different domain per language is enabled
13
+ * [wcml-2061] A fatal error (undefiend get_current_screen) was occurring in some conditions on the WP admin side
14
+ * [wcml-2059] Cart widget shows wrong product names
15
+ * [wcml-2058] Fixed a small but that defualt currency template didn't load correctly in new installation
16
+ * [wcml-2057] Added compatibility for grouped products
17
+ * [wcml-2053] Fixed an issue in lost password endpoint when edit it
18
+ * [wcml-2047] The cart total in a secondary currencies could have been added a previously removed shipping tax
19
+ * [wcml-2046] Post translation won't save when Product Bundles plugin is active
20
+ * [wcml-2043] Fixed comp issue with dynamic price with translated variations don't work in secondary language
21
+ * [wcml-2042] Cart reset button point to wrong language
22
+ * [wcml-2041] Fix issue with not matched translated labels because of special characters
23
+ * [wcml-2036] Fixed an issue when sold individually is enabled and different variations of the same product
24
+ * [wcml-2016] Fix the ability to set custom download files in downloadable variable products with WCML product editor
25
+ * [wcml-2014] Fixed small issue in separate file control in downloadable variation product
26
+ * [wcml-2008] Fix a bug where Variations were made downloadable after their description was updated.
27
+ * [wcml-2007] Checkout Field Editor compatibility fix
28
+ * [wcml-2006] Fixed issue with displaying custom prices in Bundles Products
29
+ * [wcml-2004] Add filter for 'woocommerce_subscriptions_product_price'
30
+ * [wcml-2003] Fixed compatibi;ity issue with coupos not applied correctly in a subscription product
31
+ * [wcml-1978] The `wcml_raw_price_amount` filter could not be used to convert to a different currency than the current user currency
compatibility/class-wcml-bookings.php CHANGED
@@ -164,7 +164,20 @@ class WCML_Bookings {
164
 
165
  //allow filtering resources by language
166
  add_filter( 'get_booking_resources_args', array( $this, 'filter_get_booking_resources_args' ) );
167
- add_filter( 'get_translatable_documents', array( $this, 'filter_translatable_documents' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  add_filter( 'pre_wpml_is_translated_post_type', array( $this, 'filter_is_translated_post_type' ) );
169
 
170
  add_action( 'woocommerce_product_data_panels', array( $this, 'show_pointer_info' ) );
@@ -175,15 +188,7 @@ class WCML_Bookings {
175
  if ( ! is_admin() || isset( $_POST['action'] ) && $_POST['action'] == 'wc_bookings_calculate_costs' ) {
176
  add_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
177
  }
178
-
179
- //@TODO review after WPML 3.6
180
- if ( $this->sitepress->get_wp_api()->version_compare( $this->sitepress->get_wp_api()->constant( 'ICL_SITEPRESS_VERSION' ), '3.6', '<' ) ) {
181
- add_action( 'added_post_meta', array(
182
- $this,
183
- 'maybe_fix_double_serialized_wc_booking_availability'
184
- ), 10, 4 );
185
- }
186
-
187
  add_filter( 'wpml_language_filter_extra_conditions_snippet', array( $this, 'extra_conditions_to_filter_bookings' ) );
188
 
189
  $this->clear_transient_fields();
164
 
165
  //allow filtering resources by language
166
  add_filter( 'get_booking_resources_args', array( $this, 'filter_get_booking_resources_args' ) );
167
+
168
+ if ( $this->sitepress->get_wp_api()->version_compare( $this->sitepress->get_wp_api()->constant( 'ICL_SITEPRESS_VERSION' ), '3.8.0', '<' ) ) {
169
+ add_filter( 'get_translatable_documents', array( $this, 'filter_translatable_documents' ) );
170
+
171
+ //@TODO review after WPML 3.6
172
+ if ( $this->sitepress->get_wp_api()->version_compare( $this->sitepress->get_wp_api()->constant( 'ICL_SITEPRESS_VERSION' ), '3.6', '<' ) ) {
173
+ add_action( 'added_post_meta', array(
174
+ $this,
175
+ 'maybe_fix_double_serialized_wc_booking_availability'
176
+ ), 10, 4 );
177
+ }
178
+ }
179
+ add_filter( 'get_translatable_documents_all', array( $this, 'filter_translatable_documents' ) );
180
+
181
  add_filter( 'pre_wpml_is_translated_post_type', array( $this, 'filter_is_translated_post_type' ) );
182
 
183
  add_action( 'woocommerce_product_data_panels', array( $this, 'show_pointer_info' ) );
188
  if ( ! is_admin() || isset( $_POST['action'] ) && $_POST['action'] == 'wc_bookings_calculate_costs' ) {
189
  add_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
190
  }
191
+
 
 
 
 
 
 
 
 
192
  add_filter( 'wpml_language_filter_extra_conditions_snippet', array( $this, 'extra_conditions_to_filter_bookings' ) );
193
 
194
  $this->clear_transient_fields();
compatibility/class-wcml-checkout-field-editor.php CHANGED
@@ -4,26 +4,51 @@ class WCML_Checkout_Field_Editor {
4
 
5
  protected $package, $billing, $shipping, $additional;
6
 
7
- function __construct() {
8
- $this->package = (object) array(
9
- 'kind' => 'WooCommerce Add-On',
10
  'kind_slug' => 'woocommerce-add-on',
11
- 'name' => 'checkout-field-editor',
12
- 'title' => 'WooCommerce Checkout Field Editor'
13
  );
 
 
 
14
  global $supress_field_modification;
15
- if ( !is_admin() && !$supress_field_modification ) {
16
- add_filter( 'pre_option_wc_fields_billing', array($this, 'get_billing') );
17
- add_filter( 'pre_option_wc_fields_shipping', array($this, 'get_shipping') );
18
- add_filter( 'pre_option_wc_fields_additional', array($this, 'get_additional') );
19
  }
20
- add_filter( 'pre_update_option_wc_fields_billing', array($this, 'register_fields') );
21
- add_filter( 'pre_update_option_wc_fields_shipping', array($this, 'register_fields') );
22
- add_filter( 'pre_update_option_wc_fields_additional', array($this, 'register_fields') );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
  public function register_fields( $fields ) {
26
  foreach ( $fields as $string_name => $field ) {
 
 
 
 
 
27
  // Translate label
28
  if ( !empty( $field['label'] ) ) {
29
  do_action( 'wpml_register_string',
@@ -64,6 +89,11 @@ class WCML_Checkout_Field_Editor {
64
 
65
  public function translate_fields( $fields ) {
66
  foreach ( $fields as $string_name => &$field ) {
 
 
 
 
 
67
  // Translate label
68
  if ( !empty( $field['label'] ) ) {
69
  $field['label'] = apply_filters( 'wpml_translate_string',
4
 
5
  protected $package, $billing, $shipping, $additional;
6
 
7
+ function __construct( $package = false ){
8
+ $this->package = $package ? $package : (object) array(
9
+ 'kind' => 'WooCommerce Add-On',
10
  'kind_slug' => 'woocommerce-add-on',
11
+ 'name' => 'checkout-field-editor',
12
+ 'title' => 'WooCommerce Checkout Field Editor'
13
  );
14
+ }
15
+
16
+ function add_hooks() {
17
  global $supress_field_modification;
18
+ if ( ! is_admin() && ! $supress_field_modification ) {
19
+ add_filter( 'pre_option_wc_fields_billing', array( $this, 'get_billing' ) );
20
+ add_filter( 'pre_option_wc_fields_shipping', array( $this, 'get_shipping' ) );
21
+ add_filter( 'pre_option_wc_fields_additional', array( $this, 'get_additional' ) );
22
  }
23
+ add_filter( 'pre_update_option_wc_fields_billing', array( $this, 'register_fields' ) );
24
+ add_filter( 'pre_update_option_wc_fields_shipping', array( $this, 'register_fields' ) );
25
+ add_filter( 'pre_update_option_wc_fields_additional', array( $this, 'register_fields' ) );
26
+ }
27
+
28
+ private function get_exclude_fields() {
29
+
30
+ $exclude_fields = array(
31
+ 'shipping_address_1',
32
+ 'shipping_city',
33
+ 'shipping_state',
34
+ 'shipping_postcode',
35
+ 'billing_address_1',
36
+ 'billing_city',
37
+ 'billing_state',
38
+ 'billing_postcode'
39
+ );
40
+
41
+ return apply_filters( 'wcml_cfe_exclude_fields_to_register', $exclude_fields );
42
+
43
  }
44
 
45
  public function register_fields( $fields ) {
46
  foreach ( $fields as $string_name => $field ) {
47
+
48
+ if ( in_array( $string_name, $this->get_exclude_fields() ) ) {
49
+ continue;
50
+ }
51
+
52
  // Translate label
53
  if ( !empty( $field['label'] ) ) {
54
  do_action( 'wpml_register_string',
89
 
90
  public function translate_fields( $fields ) {
91
  foreach ( $fields as $string_name => &$field ) {
92
+
93
+ if ( in_array( $string_name, $this->get_exclude_fields() ) ) {
94
+ continue;
95
+ }
96
+
97
  // Translate label
98
  if ( !empty( $field['label'] ) ) {
99
  $field['label'] = apply_filters( 'wpml_translate_string',
compatibility/class-wcml-dynamic-pricing.php CHANGED
@@ -5,25 +5,24 @@
5
  */
6
  class WCML_Dynamic_Pricing {
7
 
8
- /**
9
- * @var SitePress
10
- */
11
- public $sitepress;
12
 
13
- /**
14
- * WCML_Dynamic_Pricing constructor.
15
- *
16
- * @param $sitepress
17
- */
18
- function __construct( &$sitepress ) {
19
  if ( ! is_admin() ) {
20
- $this->sitepress = $sitepress;
21
  add_filter( 'wc_dynamic_pricing_load_modules', array( $this, 'filter_price' ) );
22
- add_filter( 'woocommerce_dynamic_pricing_is_applied_to', array( $this, 'woocommerce_dynamic_pricing_is_applied_to' ), 10, 5 );
23
- add_filter( 'woocommerce_dynamic_pricing_get_rule_amount', array( $this, 'woocommerce_dynamic_pricing_get_rule_amount' ), 10, 2 );
 
 
 
 
 
 
24
  add_filter( 'dynamic_pricing_product_rules', array( $this, 'dynamic_pricing_product_rules' ) );
25
  add_filter( 'wcml_calculate_totals_exception', array( $this, 'calculate_totals_exception' ) );
 
 
26
  }
 
27
  }
28
 
29
  /**
@@ -55,18 +54,26 @@ class WCML_Dynamic_Pricing {
55
 
56
 
57
  /**
58
- * @param $process_discounts
59
- * @param $_product
60
- * @param $module_id
61
- * @param $obj
62
- * @param $cat_id
63
  *
64
  * @return bool|WP_Error
65
  */
66
- function woocommerce_dynamic_pricing_is_applied_to( $process_discounts, $_product, $module_id, $obj, $cat_id ) {
67
- if ( $cat_id && isset( $obj->available_rulesets ) && count( $obj->available_rulesets ) > 0 ) {
68
- $cat_id = apply_filters( 'translate_object_id', $cat_id, 'product_cat', true, $this->sitepress->get_current_language() );
69
- $process_discounts = is_object_in_term( WooCommerce_Functions_Wrapper::get_product_id( $_product ), 'product_cat', $cat_id );
 
 
 
 
 
 
 
 
70
  }
71
 
72
  return $process_discounts;
@@ -113,4 +120,24 @@ class WCML_Dynamic_Pricing {
113
  function calculate_totals_exception() {
114
  return false;
115
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
5
  */
6
  class WCML_Dynamic_Pricing {
7
 
8
+ public function add_hooks() {
 
 
 
9
 
 
 
 
 
 
 
10
  if ( ! is_admin() ) {
 
11
  add_filter( 'wc_dynamic_pricing_load_modules', array( $this, 'filter_price' ) );
12
+ add_filter( 'woocommerce_dynamic_pricing_is_applied_to', array(
13
+ $this,
14
+ 'woocommerce_dynamic_pricing_is_applied_to'
15
+ ), 10, 5 );
16
+ add_filter( 'woocommerce_dynamic_pricing_get_rule_amount', array(
17
+ $this,
18
+ 'woocommerce_dynamic_pricing_get_rule_amount'
19
+ ), 10, 2 );
20
  add_filter( 'dynamic_pricing_product_rules', array( $this, 'dynamic_pricing_product_rules' ) );
21
  add_filter( 'wcml_calculate_totals_exception', array( $this, 'calculate_totals_exception' ) );
22
+ } else {
23
+ add_filter( 'woocommerce_product_get__pricing_rules', array( $this, 'translate_variations_in_rules' ) );
24
  }
25
+
26
  }
27
 
28
  /**
54
 
55
 
56
  /**
57
+ * @param bool $process_discounts
58
+ * @param WC_Product $_product
59
+ * @param int $module_id
60
+ * @param WC_Dynamic_Pricing_Simple_Base $obj
61
+ * @param array|int $cat_ids
62
  *
63
  * @return bool|WP_Error
64
  */
65
+ function woocommerce_dynamic_pricing_is_applied_to( $process_discounts, $_product, $module_id, $obj, $cat_ids ) {
66
+ if ( $cat_ids && isset( $obj->available_rulesets ) && count( $obj->available_rulesets ) > 0 ) {
67
+
68
+ if ( ! is_array( $cat_ids ) ) {
69
+ $cat_ids = array( $cat_ids );
70
+ }
71
+
72
+ foreach ( $cat_ids as $i => $cat_id ) {
73
+ $cat_ids[$i] = apply_filters( 'translate_object_id', $cat_id, 'product_cat', true );
74
+ }
75
+
76
+ $process_discounts = is_object_in_term( WooCommerce_Functions_Wrapper::get_product_id( $_product ), 'product_cat', $cat_ids );
77
  }
78
 
79
  return $process_discounts;
120
  function calculate_totals_exception() {
121
  return false;
122
  }
123
+
124
+ /**
125
+ * @param $rules
126
+ *
127
+ * @return array
128
+ */
129
+ function translate_variations_in_rules( $rules ) {
130
+ if ( is_array( $rules ) ) {
131
+ foreach ( $rules as $r_key => $rule ) {
132
+ if ( array_key_exists( 'variation_rules', $rule ) ) {
133
+ foreach ( $rule['variation_rules']['args']['variations'] as $i => $variation_id ) {
134
+ $rules[ $r_key ]['variation_rules']['args']['variations'][ $i ] = apply_filters( 'translate_object_id', $variation_id, 'product_variation', true );
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ return $rules;
141
+ }
142
+
143
  }
compatibility/class-wcml-product-addons.php CHANGED
@@ -50,6 +50,11 @@ class WCML_Product_Addons {
50
  add_filter( 'wcml_do_not_display_custom_fields_for_product', array( $this, 'replace_tm_editor_custom_fields_with_own_sections' ) );
51
  }
52
 
 
 
 
 
 
53
  }
54
 
55
  /**
@@ -274,4 +279,20 @@ class WCML_Product_Addons {
274
  return $fields;
275
  }
276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
50
  add_filter( 'wcml_do_not_display_custom_fields_for_product', array( $this, 'replace_tm_editor_custom_fields_with_own_sections' ) );
51
  }
52
 
53
+ add_filter( 'wcml_cart_contents_not_changed', array(
54
+ $this,
55
+ 'filter_booking_addon_product_in_cart_contents'
56
+ ), 20 );
57
+
58
  }
59
 
60
  /**
279
  return $fields;
280
  }
281
 
282
+ // special case for WC Bookings plugin - need add addon cost after re-calculating booking costs #wcml-1877
283
+ public function filter_booking_addon_product_in_cart_contents( $cart_item ) {
284
+
285
+ if ( $cart_item['data'] instanceof WC_Product_Booking && isset( $cart_item['addons'] ) ) {
286
+ $cost = $cart_item['data']->get_price();
287
+
288
+ foreach( $cart_item['addons'] as $addon ){
289
+ $cost += $addon['price'];
290
+ }
291
+
292
+ $cart_item['data']->set_price( $cost );
293
+ }
294
+
295
+ return $cart_item;
296
+ }
297
+
298
  }
compatibility/class-wcml-product-bundles-legacy.php CHANGED
@@ -332,7 +332,7 @@ class WCML_Product_Bundles_Legacy{
332
 
333
  function resync_bundle_clean( $cart ) {
334
  foreach ( $cart->cart_contents as $cart_item_key => $cart_item ) {
335
- if ( isset( $cart_item[ 'bundled_items' ] ) && WooCommerce_Functions_Wrapper::get_product_type( $cart_item[ 'product_id' ] ) === 'bundle' ) {
336
  if ( isset( $cart_item[ 'remapped_bundled_item_ids' ] ) ) {
337
  unset( WC()->cart->cart_contents[ $cart_item_key ][ 'remapped_bundled_item_ids' ] );
338
  }
@@ -373,45 +373,49 @@ class WCML_Product_Bundles_Legacy{
373
 
374
  function save_bundle_data_translation( $post_id, $data, $job ){
375
 
376
- remove_action( 'wcml_after_duplicate_product_post_meta', array( $this, 'sync_bundled_ids' ), 10, 2 );
377
 
378
- $bundle_data = get_post_meta( $post_id, '_bundle_data', true );
379
 
380
- $bundle_data_original = get_post_meta( $job->original_doc_id , '_bundle_data', true );
381
 
382
- $translated_bundle_pieces = array();
383
 
384
- foreach( $data as $value){
385
 
386
- if( preg_match( '/product_bundles:([0-9]+):(.+)/', $value[ 'field_type' ], $matches ) ){
387
 
388
- $bundle_key = $matches[1];
389
- $field = $matches[2];
390
 
391
- $key_data = $this->translate_bundle_key( $bundle_key, $job->language_code );
 
392
 
393
- if( !isset( $bundle_data[ $key_data->tr_key ] ) ){
394
- $bundle_data[ $key_data->tr_key ] = array(
395
- 'product_id' => $key_data->tr_id,
396
- 'hide_thumbnail' => $bundle_data_original[ $bundle_key ][ 'hide_thumbnail' ],
397
- 'override_title' => $bundle_data_original[ $bundle_key ][ 'override_title' ],
398
- 'product_title' => '',
399
- 'override_description' => $bundle_data_original[ $bundle_key ][ 'override_description' ],
400
- 'product_description' => '',
401
- 'optional' => $bundle_data_original[ $bundle_key ][ 'optional' ],
402
- 'bundle_quantity' => $bundle_data_original[ $bundle_key ][ 'bundle_quantity' ],
403
- 'bundle_quantity_max' => $bundle_data_original[ $bundle_key ][ 'bundle_quantity_max' ],
404
- 'bundle_discount' => $bundle_data_original[ $bundle_key ][ 'bundle_discount' ],
405
- 'visibility' => $bundle_data_original[ $bundle_key ][ 'visibility' ],
406
- );
407
- }
 
 
408
 
409
- $bundle_data[ $key_data->tr_key ][ 'product_'.$field ] = $value[ 'data' ];
410
 
 
411
  }
412
- }
413
 
414
- update_post_meta( $post_id, '_bundle_data', $bundle_data );
 
 
415
 
416
  }
417
 
@@ -421,4 +425,12 @@ class WCML_Product_Bundles_Legacy{
421
  return $fields;
422
  }
423
 
 
 
 
 
 
 
 
 
424
  }
332
 
333
  function resync_bundle_clean( $cart ) {
334
  foreach ( $cart->cart_contents as $cart_item_key => $cart_item ) {
335
+ if ( isset( $cart_item[ 'bundled_items' ] ) && $this->is_bundle_product( $cart_item[ 'product_id' ] ) ) {
336
  if ( isset( $cart_item[ 'remapped_bundled_item_ids' ] ) ) {
337
  unset( WC()->cart->cart_contents[ $cart_item_key ][ 'remapped_bundled_item_ids' ] );
338
  }
373
 
374
  function save_bundle_data_translation( $post_id, $data, $job ){
375
 
376
+ if ( $this->is_bundle_product( $post_id ) ) {
377
 
378
+ remove_action( 'wcml_after_duplicate_product_post_meta', array( $this, 'sync_bundled_ids' ), 10, 2 );
379
 
380
+ $bundle_data = get_post_meta( $post_id, '_bundle_data', true );
381
 
382
+ $bundle_data_original = get_post_meta( $job->original_doc_id , '_bundle_data', true );
383
 
384
+ $translated_bundle_pieces = array();
385
 
386
+ foreach( $data as $value){
387
 
388
+ if( preg_match( '/product_bundles:([0-9]+):(.+)/', $value[ 'field_type' ], $matches ) ){
 
389
 
390
+ $bundle_key = $matches[1];
391
+ $field = $matches[2];
392
 
393
+ $key_data = $this->translate_bundle_key( $bundle_key, $job->language_code );
394
+
395
+ if( !isset( $bundle_data[ $key_data->tr_key ] ) ){
396
+ $bundle_data[ $key_data->tr_key ] = array(
397
+ 'product_id' => $key_data->tr_id,
398
+ 'hide_thumbnail' => $bundle_data_original[ $bundle_key ][ 'hide_thumbnail' ],
399
+ 'override_title' => $bundle_data_original[ $bundle_key ][ 'override_title' ],
400
+ 'product_title' => '',
401
+ 'override_description' => $bundle_data_original[ $bundle_key ][ 'override_description' ],
402
+ 'product_description' => '',
403
+ 'optional' => $bundle_data_original[ $bundle_key ][ 'optional' ],
404
+ 'bundle_quantity' => $bundle_data_original[ $bundle_key ][ 'bundle_quantity' ],
405
+ 'bundle_quantity_max' => $bundle_data_original[ $bundle_key ][ 'bundle_quantity_max' ],
406
+ 'bundle_discount' => $bundle_data_original[ $bundle_key ][ 'bundle_discount' ],
407
+ 'visibility' => $bundle_data_original[ $bundle_key ][ 'visibility' ],
408
+ );
409
+ }
410
 
411
+ $bundle_data[ $key_data->tr_key ][ 'product_'.$field ] = $value[ 'data' ];
412
 
413
+ }
414
  }
 
415
 
416
+ update_post_meta( $post_id, '_bundle_data', $bundle_data );
417
+
418
+ }
419
 
420
  }
421
 
425
  return $fields;
426
  }
427
 
428
+ public function is_bundle_product( $product_id ){
429
+ if ( 'bundle' === WooCommerce_Functions_Wrapper::get_product_type( $product_id ) ) {
430
+ return true;
431
+ }
432
+
433
+ return false;
434
+ }
435
+
436
  }
compatibility/class-wcml-product-bundles.php CHANGED
@@ -56,6 +56,8 @@ class WCML_Product_Bundles {
56
  // product bundle using separate custom fields for prices
57
  if ( wcml_is_multi_currency_on() ) {
58
  add_filter( 'wcml_price_custom_fields_filtered', array( $this, 'get_price_custom_fields' ) );
 
 
59
  }
60
 
61
  }
@@ -139,7 +141,7 @@ class WCML_Product_Bundles {
139
 
140
  public function sync_product_bundle_meta_with_translations( $bundle_id ) {
141
 
142
- if ( WooCommerce_Functions_Wrapper::get_product_type( $bundle_id ) === 'bundle' ) {
143
 
144
  $trid = $this->sitepress->get_element_trid( $bundle_id, 'post_product' );
145
  $translations = $this->sitepress->get_element_translations( $trid, 'post_product' );
@@ -558,7 +560,7 @@ class WCML_Product_Bundles {
558
 
559
  public function resync_bundle_clean( $cart ) {
560
  foreach ( $cart->cart_contents as $cart_item_key => $cart_item ) {
561
- if ( isset( $cart_item['bundled_items'] ) && WooCommerce_Functions_Wrapper::get_product_type( $cart_item['product_id'] ) === 'bundle' ) {
562
  if ( isset( $cart_item['remapped_bundled_item_ids'] ) ) {
563
  unset( WC()->cart->cart_contents[ $cart_item_key ]['remapped_bundled_item_ids'] );
564
  }
@@ -568,62 +570,65 @@ class WCML_Product_Bundles {
568
 
569
  public function save_bundle_data_translation( $translated_bundle_id, $data, $job ) {
570
 
571
- remove_action( 'wcml_after_duplicate_product_post_meta', array( $this, 'sync_bundled_ids' ), 10, 2 );
572
 
573
- $translated_bundle_data = $this->get_product_bundle_data( $translated_bundle_id );
574
 
575
- $bundle_id =& $job->original_doc_id;
576
 
577
- $bundle_data = $this->get_product_bundle_data( $bundle_id );
578
 
579
- foreach ( $data as $value ) {
580
 
581
- if ( preg_match( '/product_bundles:([0-9]+):(.+)/', $value['field_type'], $matches ) ) {
582
 
583
- $product_id = $matches[1];
584
- $field = $matches[2];
585
 
586
- $translated_product_id = apply_filters( 'translate_object_id', $product_id, get_post_type( $product_id ), false, $job->language_code );
587
- $translated_item_id = $this->get_item_id_for_product_id( $translated_product_id, $translated_bundle_id );
588
- if ( empty( $translated_item_id ) ) {
589
- $translated_item_id = $this->add_product_to_bundle( $translated_product_id, $translated_bundle_id, $bundle_id, $product_id );
590
- }
591
 
592
- $item_id = $this->get_item_id_for_product_id( $product_id, $bundle_id );
593
-
594
- if ( ! isset( $translated_bundle_data[ $translated_item_id ] ) ) {
595
- $translated_bundle_data[ $translated_item_id ] = array(
596
- 'product_id' => $translated_product_id,
597
- 'hide_thumbnail' => $bundle_data[ $item_id ]['hide_thumbnail'],
598
- 'override_title' => $bundle_data[ $item_id ]['override_title'],
599
- 'product_title' => '',
600
- 'override_description' => $bundle_data[ $item_id ]['override_description'],
601
- 'product_description' => '',
602
- 'optional' => $bundle_data[ $item_id ]['optional'],
603
- 'bundle_quantity' => $bundle_data[ $item_id ]['bundle_quantity'],
604
- 'bundle_quantity_max' => $bundle_data[ $item_id ]['bundle_quantity_max'],
605
- 'bundle_discount' => $bundle_data[ $item_id ]['bundle_discount'],
606
- 'single_product_visibility' => $bundle_data[ $item_id ]['single_product_visibility'],
607
- 'cart_visibility' => $bundle_data[ $item_id ]['cart_visibility'],
608
- 'order_visibility' => $bundle_data[ $item_id ]['order_visibility'],
609
- 'stock_status' => $bundle_data[ $item_id ]['stock_status'],
610
- 'max_stock' => $bundle_data[ $item_id ]['max_stock'],
611
- 'quantity_min' => $bundle_data[ $item_id ]['quantity_min'],
612
- 'quantity_max' => $bundle_data[ $item_id ]['quantity_max'],
613
- 'shipped_individually' => $bundle_data[ $item_id ]['shipped_individually'],
614
- 'priced_individually' => $bundle_data[ $item_id ]['priced_individually'],
615
- 'single_product_price_visibility' => $bundle_data[ $item_id ]['single_product_price_visibility'],
616
- 'cart_price_visibility' => $bundle_data[ $item_id ]['cart_price_visibility'],
617
- 'order_price_visibility' => $bundle_data[ $item_id ]['order_price_visibility']
618
- );
 
 
 
 
 
 
 
 
 
619
  }
620
 
621
- $translated_bundle_data[ $translated_item_id ][ $field ] = $value['data'];
622
  }
623
 
 
624
  }
625
-
626
- $this->save_product_bundle_data( $translated_bundle_id, $translated_bundle_data );
627
  }
628
 
629
  private function add_product_to_bundle( $product_id, $bundle_id, $original_bundle_id, $original_product_id ) {
@@ -661,4 +666,35 @@ class WCML_Product_Bundles {
661
 
662
  return $custom_fields;
663
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
664
  }
56
  // product bundle using separate custom fields for prices
57
  if ( wcml_is_multi_currency_on() ) {
58
  add_filter( 'wcml_price_custom_fields_filtered', array( $this, 'get_price_custom_fields' ) );
59
+ add_filter( 'wcml_update_custom_prices_values', array( $this, 'update_bundles_custom_prices_values' ), 10, 2 );
60
+ add_filter( 'wcml_after_save_custom_prices', array( $this, 'update_bundles_base_price' ), 10, 4 );
61
  }
62
 
63
  }
141
 
142
  public function sync_product_bundle_meta_with_translations( $bundle_id ) {
143
 
144
+ if ( $this->is_bundle_product( $bundle_id ) ) {
145
 
146
  $trid = $this->sitepress->get_element_trid( $bundle_id, 'post_product' );
147
  $translations = $this->sitepress->get_element_translations( $trid, 'post_product' );
560
 
561
  public function resync_bundle_clean( $cart ) {
562
  foreach ( $cart->cart_contents as $cart_item_key => $cart_item ) {
563
+ if ( isset( $cart_item['bundled_items'] ) && $this->is_bundle_product( $cart_item['product_id'] ) ) {
564
  if ( isset( $cart_item['remapped_bundled_item_ids'] ) ) {
565
  unset( WC()->cart->cart_contents[ $cart_item_key ]['remapped_bundled_item_ids'] );
566
  }
570
 
571
  public function save_bundle_data_translation( $translated_bundle_id, $data, $job ) {
572
 
573
+ if ( $this->is_bundle_product( $translated_bundle_id ) ) {
574
 
575
+ remove_action( 'wcml_after_duplicate_product_post_meta', array( $this, 'sync_bundled_ids' ), 10, 2 );
576
 
577
+ $translated_bundle_data = $this->get_product_bundle_data( $translated_bundle_id );
578
 
579
+ $bundle_id =& $job->original_doc_id;
580
 
581
+ $bundle_data = $this->get_product_bundle_data( $bundle_id );
582
 
583
+ foreach ( $data as $value ) {
584
 
585
+ if ( preg_match( '/product_bundles:([0-9]+):(.+)/', $value['field_type'], $matches ) ) {
 
586
 
587
+ $product_id = $matches[1];
588
+ $field = $matches[2];
 
 
 
589
 
590
+ $translated_product_id = apply_filters( 'translate_object_id', $product_id, get_post_type( $product_id ), false, $job->language_code );
591
+ $translated_item_id = $this->get_item_id_for_product_id( $translated_product_id, $translated_bundle_id );
592
+ if ( empty( $translated_item_id ) ) {
593
+ $translated_item_id = $this->add_product_to_bundle( $translated_product_id, $translated_bundle_id, $bundle_id, $product_id );
594
+ }
595
+
596
+ $item_id = $this->get_item_id_for_product_id( $product_id, $bundle_id );
597
+
598
+ if ( ! isset( $translated_bundle_data[ $translated_item_id ] ) ) {
599
+ $translated_bundle_data[ $translated_item_id ] = array(
600
+ 'product_id' => $translated_product_id,
601
+ 'hide_thumbnail' => $bundle_data[ $item_id ]['hide_thumbnail'],
602
+ 'override_title' => $bundle_data[ $item_id ]['override_title'],
603
+ 'product_title' => '',
604
+ 'override_description' => $bundle_data[ $item_id ]['override_description'],
605
+ 'product_description' => '',
606
+ 'optional' => $bundle_data[ $item_id ]['optional'],
607
+ 'bundle_quantity' => $bundle_data[ $item_id ]['bundle_quantity'],
608
+ 'bundle_quantity_max' => $bundle_data[ $item_id ]['bundle_quantity_max'],
609
+ 'bundle_discount' => $bundle_data[ $item_id ]['bundle_discount'],
610
+ 'single_product_visibility' => $bundle_data[ $item_id ]['single_product_visibility'],
611
+ 'cart_visibility' => $bundle_data[ $item_id ]['cart_visibility'],
612
+ 'order_visibility' => $bundle_data[ $item_id ]['order_visibility'],
613
+ 'stock_status' => $bundle_data[ $item_id ]['stock_status'],
614
+ 'max_stock' => $bundle_data[ $item_id ]['max_stock'],
615
+ 'quantity_min' => $bundle_data[ $item_id ]['quantity_min'],
616
+ 'quantity_max' => $bundle_data[ $item_id ]['quantity_max'],
617
+ 'shipped_individually' => $bundle_data[ $item_id ]['shipped_individually'],
618
+ 'priced_individually' => $bundle_data[ $item_id ]['priced_individually'],
619
+ 'single_product_price_visibility' => $bundle_data[ $item_id ]['single_product_price_visibility'],
620
+ 'cart_price_visibility' => $bundle_data[ $item_id ]['cart_price_visibility'],
621
+ 'order_price_visibility' => $bundle_data[ $item_id ]['order_price_visibility']
622
+ );
623
+ }
624
+
625
+ $translated_bundle_data[ $translated_item_id ][ $field ] = $value['data'];
626
  }
627
 
 
628
  }
629
 
630
+ $this->save_product_bundle_data( $translated_bundle_id, $translated_bundle_data );
631
  }
 
 
632
  }
633
 
634
  private function add_product_to_bundle( $product_id, $bundle_id, $original_bundle_id, $original_product_id ) {
666
 
667
  return $custom_fields;
668
  }
669
+
670
+
671
+ function update_bundles_custom_prices_values( $prices, $code ){
672
+
673
+ if( isset( $_POST[ '_custom_regular_price' ][ $code ] ) ){
674
+ $prices[ '_wc_pb_base_regular_price' ] = wc_format_decimal( $_POST[ '_custom_regular_price' ][ $code ] );
675
+ }
676
+
677
+ if( isset( $_POST[ '_custom_sale_price' ][ $code ] ) ){
678
+ $prices[ '_wc_pb_base_sale_price' ] = wc_format_decimal( $_POST[ '_custom_sale_price' ][ $code ] );
679
+ }
680
+
681
+ return $prices;
682
+
683
+ }
684
+
685
+ function update_bundles_base_price( $post_id, $product_price, $custom_prices, $code ){
686
+
687
+ if( isset ( $custom_prices[ '_wc_pb_base_regular_price' ] ) ){
688
+ update_post_meta( $post_id, '_wc_pb_base_price_'.$code, $product_price );
689
+ }
690
+
691
+ }
692
+
693
+ public function is_bundle_product( $product_id ){
694
+ if ( 'bundle' === WooCommerce_Functions_Wrapper::get_product_type( $product_id ) ) {
695
+ return true;
696
+ }
697
+
698
+ return false;
699
+ }
700
  }
compatibility/class-wcml-table-rate-shipping.php CHANGED
@@ -18,19 +18,28 @@ class WCML_Table_Rate_Shipping {
18
  /**
19
  * WCML_Table_Rate_Shipping constructor.
20
  *
21
- * @param $sitepress
22
- * @param $woocommerce_wpml
23
  */
24
- function __construct( &$sitepress, &$woocommerce_wpml ) {
25
  $this->sitepress = $sitepress;
26
  $this->woocommerce_wpml = $woocommerce_wpml;
 
 
 
 
27
  add_action( 'init', array( $this, 'init' ), 9 );
28
 
29
- add_filter( 'get_the_terms',array( $this, 'shipping_class_id_in_default_language' ), 10, 3 );
 
 
30
 
31
- if( wcml_is_multi_currency_on() ){
32
  add_filter( 'woocommerce_table_rate_query_rates_args', array( $this, 'filter_query_rates_args' ) );
33
- add_filter( 'woocommerce_table_rate_package_row_base_price', array( $this, 'filter_product_base_price' ), 10, 3 );
 
 
 
34
  }
35
 
36
  }
@@ -78,9 +87,10 @@ class WCML_Table_Rate_Shipping {
78
  * @return mixed
79
  */
80
  public function shipping_class_id_in_default_language( $terms, $post_id, $taxonomy ) {
81
- global $icl_adjust_id_url_filter_off, $pagenow;
82
 
83
- if( $terms && $pagenow != 'post.php' && ( get_post_type( $post_id ) == 'product' || get_post_type( $post_id ) == 'product_variation' ) && $taxonomy == 'product_shipping_class' ){
 
84
 
85
  if( is_admin() ){
86
  $shipp_class_language = $this->woocommerce_wpml->products->get_original_product_language( $post_id );
18
  /**
19
  * WCML_Table_Rate_Shipping constructor.
20
  *
21
+ * @param SitePress $sitepress
22
+ * @param woocommerce_wpml $woocommerce_wpml
23
  */
24
+ function __construct( SitePress $sitepress, woocommerce_wpml $woocommerce_wpml ) {
25
  $this->sitepress = $sitepress;
26
  $this->woocommerce_wpml = $woocommerce_wpml;
27
+ }
28
+
29
+ public function add_hooks(){
30
+
31
  add_action( 'init', array( $this, 'init' ), 9 );
32
 
33
+ if ( ! is_admin() ) {
34
+ add_filter( 'get_the_terms', array( $this, 'shipping_class_id_in_default_language' ), 10, 3 );
35
+ }
36
 
37
+ if ( wcml_is_multi_currency_on() ) {
38
  add_filter( 'woocommerce_table_rate_query_rates_args', array( $this, 'filter_query_rates_args' ) );
39
+ add_filter( 'woocommerce_table_rate_package_row_base_price', array(
40
+ $this,
41
+ 'filter_product_base_price'
42
+ ), 10, 3 );
43
  }
44
 
45
  }
87
  * @return mixed
88
  */
89
  public function shipping_class_id_in_default_language( $terms, $post_id, $taxonomy ) {
90
+ global $icl_adjust_id_url_filter_off;
91
 
92
+ $is_product_object = 'product' === get_post_type( $post_id ) || 'product_variation' === get_post_type( $post_id );
93
+ if( $terms && $is_product_object && 'product_shipping_class' === $taxonomy ){
94
 
95
  if( is_admin() ){
96
  $shipp_class_language = $this->woocommerce_wpml->products->get_original_product_language( $post_id );
compatibility/class-wcml-wc-subscriptions.php CHANGED
@@ -4,27 +4,41 @@ class WCML_WC_Subscriptions{
4
 
5
  private $new_subscription = false;
6
 
7
- function __construct(){
 
 
 
8
 
9
- add_action('init', array($this, 'init'),9);
10
- add_filter('wcml_variation_term_taxonomy_ids',array($this,'wcml_variation_term_taxonomy_ids'));
11
- add_filter('woocommerce_subscription_lengths', array($this, 'woocommerce_subscription_lengths'), 10, 2);
 
 
 
 
 
 
 
12
 
13
- add_filter('wcml_register_endpoints_query_vars', array($this, 'register_endpoint' ), 10, 3 );
14
- add_filter('wcml_endpoint_permalink_filter', array($this, 'endpoint_permalink_filter'), 10, 2);
15
 
16
  //custom prices
17
  add_filter( 'wcml_custom_prices_fields', array( $this, 'set_prices_fields' ), 10, 2 );
18
  add_filter( 'wcml_custom_prices_strings', array( $this, 'set_labels_for_prices_fields' ), 10, 2 );
19
  add_filter( 'wcml_custom_prices_fields_labels', array( $this, 'set_labels_for_prices_fields' ), 10, 2 );
20
- add_filter( 'wcml_update_custom_prices_values', array( $this, 'update_custom_prices_values' ), 10 ,3 );
21
- add_action( 'wcml_after_custom_prices_block', array( $this, 'new_subscription_prices_block') );
22
 
23
- // reenable coupons for subscriptions when multicurrency is on
24
- add_action('woocommerce_subscription_cart_after_grouping', array($this, 'woocommerce_subscription_cart_after_grouping'));
25
 
26
- add_action( 'woocommerce_subscriptions_product_options_pricing', array( $this, 'show_pointer_info' ) );
27
- add_action( 'woocommerce_variable_subscription_pricing', array( $this, 'show_pointer_info' ) );
 
 
 
 
28
  }
29
 
30
  function init(){
@@ -44,8 +58,8 @@ class WCML_WC_Subscriptions{
44
  }
45
 
46
  function wcml_variation_term_taxonomy_ids($get_variation_term_taxonomy_ids){
47
- global $wpdb;
48
- $get_variation_term_taxonomy_id = $wpdb->get_var("SELECT tt.term_taxonomy_id FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.slug = 'variable-subscription'");
49
 
50
  if(!empty($get_variation_term_taxonomy_id)){
51
  $get_variation_term_taxonomy_ids[] = $get_variation_term_taxonomy_id;
@@ -72,15 +86,6 @@ class WCML_WC_Subscriptions{
72
  return isset($new_subscription_ranges) ? $new_subscription_ranges : $subscription_ranges;
73
  }
74
 
75
- public function woocommerce_subscription_cart_after_grouping() {
76
- global $woocommerce_wpml;
77
-
78
- if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
79
- remove_action('woocommerce_before_calculate_totals', 'WC_Subscriptions_Coupon::remove_coupons', 10);
80
- }
81
-
82
- }
83
-
84
  function set_prices_fields( $fields, $product_id ){
85
  if( $this->is_subscriptions_product( $product_id ) || $this->new_subscription ){
86
  $fields[] = '_subscription_sign_up_fee';
@@ -116,23 +121,28 @@ class WCML_WC_Subscriptions{
116
  }
117
 
118
  function is_subscriptions_product( $product_id ){
119
- global $wpdb;
120
- $get_variation_term_taxonomy_ids = $wpdb->get_col("SELECT tt.term_taxonomy_id FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.slug IN ( 'subscription', 'variable-subscription' ) AND tt.taxonomy = 'product_type'");
121
 
122
  if( get_post_type( $product_id ) == 'product_variation' ){
123
  $product_id = wp_get_post_parent_id( $product_id );
124
  }
125
 
126
- $is_subscriptions_product = $wpdb->get_var($wpdb->prepare("SELECT count(object_id) FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN (".join(',',$get_variation_term_taxonomy_ids).")",$product_id));
 
 
 
 
 
127
  return $is_subscriptions_product;
128
  }
129
 
130
  function new_subscription_prices_block( $product_id ){
131
- global $woocommerce_wpml;
132
  if( $product_id == 'new' ){
133
  $this->new_subscription = true;
134
  echo '<div class="wcml_prices_if_subscription" style="display: none">';
135
- $custom_prices_ui = new WCML_Custom_Prices_UI( $woocommerce_wpml, 'new' );
136
  $custom_prices_ui->show();
137
  echo '</div>';
138
  ?>
@@ -220,4 +230,23 @@ class WCML_WC_Subscriptions{
220
  }
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
4
 
5
  private $new_subscription = false;
6
 
7
+ /** @var woocommerce_wpml */
8
+ private $woocommerce_wpml;
9
+ /** @var wpdb */
10
+ private $wpdb;
11
 
12
+ function __construct( woocommerce_wpml $woocommerce_wpml, wpdb $wpdb ){
13
+ $this->woocommerce_wpml = $woocommerce_wpml;
14
+ $this->wpdb = $wpdb;
15
+ }
16
+
17
+ public function add_hooks(){
18
+
19
+ add_action( 'init', array( $this, 'init' ), 9 );
20
+ add_filter( 'wcml_variation_term_taxonomy_ids', array( $this, 'wcml_variation_term_taxonomy_ids' ) );
21
+ add_filter( 'woocommerce_subscription_lengths', array( $this, 'woocommerce_subscription_lengths' ), 10, 2 );
22
 
23
+ add_filter( 'wcml_register_endpoints_query_vars', array( $this, 'register_endpoint' ), 10, 3 );
24
+ add_filter( 'wcml_endpoint_permalink_filter', array( $this, 'endpoint_permalink_filter' ), 10, 2 );
25
 
26
  //custom prices
27
  add_filter( 'wcml_custom_prices_fields', array( $this, 'set_prices_fields' ), 10, 2 );
28
  add_filter( 'wcml_custom_prices_strings', array( $this, 'set_labels_for_prices_fields' ), 10, 2 );
29
  add_filter( 'wcml_custom_prices_fields_labels', array( $this, 'set_labels_for_prices_fields' ), 10, 2 );
30
+ add_filter( 'wcml_update_custom_prices_values', array( $this, 'update_custom_prices_values' ), 10, 3 );
31
+ add_action( 'wcml_after_custom_prices_block', array( $this, 'new_subscription_prices_block' ) );
32
 
33
+ add_action( 'woocommerce_subscriptions_product_options_pricing', array( $this, 'show_pointer_info' ) );
34
+ add_action( 'woocommerce_variable_subscription_pricing', array( $this, 'show_pointer_info' ) );
35
 
36
+ add_filter( 'woocommerce_subscriptions_product_price', array(
37
+ $this,
38
+ 'woocommerce_subscription_price_from'
39
+ ), 10, 2 );
40
+
41
+ add_filter( 'wcml_calculate_totals_exception', array( $this, '__return_false' ) );
42
  }
43
 
44
  function init(){
58
  }
59
 
60
  function wcml_variation_term_taxonomy_ids($get_variation_term_taxonomy_ids){
61
+
62
+ $get_variation_term_taxonomy_id = $this->wpdb->get_var("SELECT tt.term_taxonomy_id FROM {$this->wpdb->terms} AS t LEFT JOIN {$this->wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.slug = 'variable-subscription'");
63
 
64
  if(!empty($get_variation_term_taxonomy_id)){
65
  $get_variation_term_taxonomy_ids[] = $get_variation_term_taxonomy_id;
86
  return isset($new_subscription_ranges) ? $new_subscription_ranges : $subscription_ranges;
87
  }
88
 
 
 
 
 
 
 
 
 
 
89
  function set_prices_fields( $fields, $product_id ){
90
  if( $this->is_subscriptions_product( $product_id ) || $this->new_subscription ){
91
  $fields[] = '_subscription_sign_up_fee';
121
  }
122
 
123
  function is_subscriptions_product( $product_id ){
124
+
125
+ $get_variation_term_taxonomy_ids = $this->wpdb->get_col("SELECT tt.term_taxonomy_id FROM {$this->wpdb->terms} AS t LEFT JOIN {$this->wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.slug IN ( 'subscription', 'variable-subscription' ) AND tt.taxonomy = 'product_type'");
126
 
127
  if( get_post_type( $product_id ) == 'product_variation' ){
128
  $product_id = wp_get_post_parent_id( $product_id );
129
  }
130
 
131
+ $is_subscriptions_product = $this->wpdb->get_var(
132
+ $this->wpdb->prepare(
133
+ "SELECT count(object_id) FROM {$this->wpdb->term_relationships}
134
+ WHERE object_id = %d AND term_taxonomy_id IN (" . wpml_prepare_in( $get_variation_term_taxonomy_ids, '%d' ) . ")",
135
+ $product_id )
136
+ );
137
  return $is_subscriptions_product;
138
  }
139
 
140
  function new_subscription_prices_block( $product_id ){
141
+
142
  if( $product_id == 'new' ){
143
  $this->new_subscription = true;
144
  echo '<div class="wcml_prices_if_subscription" style="display: none">';
145
+ $custom_prices_ui = new WCML_Custom_Prices_UI( $this->woocommerce_wpml, 'new' );
146
  $custom_prices_ui->show();
147
  echo '</div>';
148
  ?>
230
  }
231
  }
232
 
233
+ function woocommerce_subscription_price_from( $price, $product ){
234
+
235
+ if( 'variable-subscription' === $product->get_type() ){
236
+
237
+ $variation_id = $product->get_meta( '_min_price_variation_id', true );
238
+
239
+ if( $variation_id && get_post_meta( $variation_id, '_wcml_custom_prices_status', true ) ){
240
+ $client_currency = $this->woocommerce_wpml->multi_currency->get_client_currency();
241
+
242
+ $price = get_post_meta( $variation_id, '_price_'.$client_currency, true );
243
+ }else{
244
+ $price = apply_filters( 'wcml_raw_price_amount', $price );
245
+ }
246
+
247
+ }
248
+
249
+ return $price;
250
+ }
251
+
252
  }
inc/class-wcml-attributes.php CHANGED
@@ -514,18 +514,17 @@ class WCML_Attributes{
514
  * needs handle special chars accordingly
515
  * https://onthegosystems.myjetbrains.com/youtrack/issue/wcml-1785
516
  */
517
- function filter_attribute_name( $attribute_name, $product_id, $return_sanitized = false ){
518
 
519
- if( !is_admin() && $product_id ) {
520
  $orig_lang = $this->woocommerce_wpml->products->get_original_product_language( $product_id );
521
- if ( in_array( $orig_lang, array('de', 'da' ) ) ) {
522
  $attribute_name = $this->sitepress->locale_utils->filter_sanitize_title( remove_accents( $attribute_name ), $attribute_name );
523
  remove_filter( 'sanitize_title', array( $this->sitepress->locale_utils, 'filter_sanitize_title' ), 10 );
524
- return $attribute_name;
525
  }
526
  }
527
 
528
- if( $return_sanitized ){
529
  $attribute_name = sanitize_title( $attribute_name );
530
  }
531
 
514
  * needs handle special chars accordingly
515
  * https://onthegosystems.myjetbrains.com/youtrack/issue/wcml-1785
516
  */
517
+ function filter_attribute_name( $attribute_name, $product_id, $return_sanitized = false ) {
518
 
519
+ if ( ! is_admin() && $product_id ) {
520
  $orig_lang = $this->woocommerce_wpml->products->get_original_product_language( $product_id );
521
+ if ( in_array( $orig_lang, array( 'de', 'da' ) ) ) {
522
  $attribute_name = $this->sitepress->locale_utils->filter_sanitize_title( remove_accents( $attribute_name ), $attribute_name );
523
  remove_filter( 'sanitize_title', array( $this->sitepress->locale_utils, 'filter_sanitize_title' ), 10 );
 
524
  }
525
  }
526
 
527
+ if ( $return_sanitized ) {
528
  $attribute_name = sanitize_title( $attribute_name );
529
  }
530
 
inc/class-wcml-cart-switch-lang-functions.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCML_Cart_Switch_Lang_Functions{
4
+
5
+ private $lang_from;
6
+ private $lang_to;
7
+
8
+ public function add_actions(){
9
+ add_action( 'wp_footer', array( $this, 'wcml_language_switch_dialog' ) );
10
+ add_action( 'wp_loaded', array( $this, 'wcml_language_force_switch' ) );
11
+ add_action( 'wcml_user_switch_language', array( $this, 'language_has_switched' ), 10 , 2 );
12
+ }
13
+
14
+ public function language_has_switched( $lang_from, $lang_to ){
15
+
16
+ $settings = get_option( '_wcml_settings' );
17
+
18
+ if(
19
+ !isset( $_GET[ 'force_switch' ] ) &&
20
+ $lang_from != $lang_to &&
21
+ !empty( $settings ) &&
22
+ $settings[ 'cart_sync' ][ 'lang_switch' ] == WCML_CART_CLEAR
23
+ ){
24
+ $this->lang_from = $lang_from;
25
+ $this->lang_to = $lang_to;
26
+ }
27
+ }
28
+
29
+ public function wcml_language_force_switch(){
30
+ global $woocommerce_wpml, $woocommerce;
31
+
32
+ if( isset( $_GET[ 'force_switch' ] ) && $_GET[ 'force_switch' ] == true ){
33
+ $woocommerce_wpml->cart->empty_cart_if_needed( 'lang_switch' );
34
+ $woocommerce->session->set( 'wcml_switched_type', 'lang_switch' );
35
+ }
36
+ }
37
+
38
+ public function wcml_language_switch_dialog( ){
39
+ global $woocommerce_wpml, $sitepress, $wp, $post;
40
+
41
+ $dependencies = new WCML_Dependencies;
42
+
43
+ if( $dependencies->check() ){
44
+
45
+ $current_url = home_url( add_query_arg( array(), $wp->request ) );
46
+
47
+ if( isset( $post->ID ) ){
48
+ $requested_page_id = apply_filters( 'translate_object_id', $post->ID, get_post_type( $post->ID ), true, $this->lang_from );
49
+ $request_url = add_query_arg( 'force_switch', 0, $sitepress->convert_url( get_permalink( $requested_page_id ), $this->lang_from ) );
50
+ }else{
51
+ $request_url = $current_url;
52
+ }
53
+
54
+ $cart_for_session = false;
55
+ if( isset( WC()->cart ) ){
56
+ $cart_for_session = WC()->cart->get_cart_for_session();
57
+ }
58
+
59
+ if( $this->lang_from && $this->lang_to && $request_url && !empty( $cart_for_session ) ) {
60
+
61
+ $force_cart_url = add_query_arg( 'force_switch', 1, $current_url );
62
+ $active_languages = apply_filters( 'wpml_active_languages', null, null );
63
+ $dialog_title = __( 'Switching language?', 'woocommerce-multilingual' );
64
+
65
+ $confirmation_message = sprintf(
66
+ __( "You've switched the language and there are items in the cart. If you keep the %s language, the cart will be emptied and you will have to add the items again to the cart.",
67
+ 'woocommerce-multilingual' ),
68
+ $active_languages[ $this->lang_to ]['translated_name']
69
+ );
70
+ $stay_in = sprintf( __( 'Keep %s', 'woocommerce-multilingual' ), $active_languages[ $this->lang_to ]['translated_name'] );
71
+ $switch_to = sprintf( __( 'Switch back to %s', 'woocommerce-multilingual' ), $active_languages[ $this->lang_from ]['translated_name'] );
72
+
73
+ $woocommerce_wpml->cart->cart_alert( $dialog_title, $confirmation_message, $stay_in, $switch_to, $force_cart_url, $request_url, true );
74
+ }
75
+
76
+ }
77
+
78
+ }
79
+
80
+ }
inc/class-wcml-cart.php CHANGED
@@ -48,7 +48,7 @@ class WCML_Cart
48
  add_action( 'woocommerce_before_checkout_process', array( $this, 'wcml_refresh_cart_total' ) );
49
 
50
  add_filter('woocommerce_paypal_args', array($this, 'filter_paypal_args'));
51
- add_filter( 'woocommerce_add_to_cart_sold_individually_quantity', array( $this, 'woocommerce_add_to_cart_sold_individually_quantity' ), 10, 5 );
52
 
53
  $this->localize_flat_rates_shipping_classes();
54
  }
@@ -155,8 +155,8 @@ class WCML_Cart
155
 
156
  public function cart_alert( $dialog_title, $confirmation_message, $switch_to, $stay_in, $switch_to_value, $stay_in_value = false, $language_switch = false ){
157
  ?>
158
- <div id="wcml-cart-dialog-confirm" title="<?php echo $dialog_title ?>">
159
- <p><?php echo $confirmation_message; ?></p>
160
  </div>
161
 
162
  <script type="text/javascript">
@@ -176,21 +176,21 @@ class WCML_Cart
176
  "<?php echo $switch_to; ?>": function() {
177
  jQuery( this ).dialog( "close" );
178
  <?php if( $language_switch ): ?>
179
- window.location = '<?php echo $switch_to_value; ?>';
180
  <?php else: ?>
181
  jQuery('.wcml_currency_switcher').parent().find('img').remove();
182
- wcml_load_currency( "<?php echo $switch_to_value; ?>", true );
183
  <?php endif; ?>
184
 
185
  },
186
  "<?php echo $stay_in; ?>": function() {
187
  jQuery( this ).dialog( "close" );
188
  <?php if( $language_switch ): ?>
189
- window.location = '<?php echo $stay_in_value; ?>';
190
  <?php else: ?>
191
  jQuery('.wcml_currency_switcher').parent().find('img').remove();
192
  jQuery('.wcml_currency_switcher').removeAttr('disabled');
193
- jQuery('.wcml_currency_switcher').val( '<?php echo $stay_in_value; ?>' );
194
  <?php endif; ?>
195
  }
196
  }
@@ -465,18 +465,56 @@ class WCML_Cart
465
  return $args;
466
  }
467
 
468
- public function woocommerce_add_to_cart_sold_individually_quantity( $qt, $quantity, $product_id, $variation_id, $cart_item_data ){
 
 
 
 
 
469
 
470
  //check if product already added to cart in another language
471
- $current_product_trid = $this->sitepress->get_element_trid( $product_id, 'post_product' );
 
 
 
 
472
 
473
- foreach( WC()->cart->cart_contents as $cart_item ){
474
- $cart_element_trid = $this->sitepress->get_element_trid( $cart_item[ 'product_id' ], 'post_product' );
475
- if( apply_filters( 'wcml_add_to_cart_sold_individually', true, $cart_item_data, $product_id, $quantity ) && $current_product_trid == $cart_element_trid && $cart_item[ 'quantity' ] > 0 ){
476
- throw new Exception( sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( wc_get_cart_url() ), __( 'View Cart', 'woocommerce' ), sprintf( __( 'You cannot add another &quot;%s&quot; to your cart.', 'woocommerce' ), get_the_title( $product_id ) ) ) );
477
  }
478
  }
479
 
480
  return $qt;
481
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  }
48
  add_action( 'woocommerce_before_checkout_process', array( $this, 'wcml_refresh_cart_total' ) );
49
 
50
  add_filter('woocommerce_paypal_args', array($this, 'filter_paypal_args'));
51
+ add_filter( 'woocommerce_add_to_cart_sold_individually_quantity', array( $this, 'add_to_cart_sold_individually_exception' ), 10, 5 );
52
 
53
  $this->localize_flat_rates_shipping_classes();
54
  }
155
 
156
  public function cart_alert( $dialog_title, $confirmation_message, $switch_to, $stay_in, $switch_to_value, $stay_in_value = false, $language_switch = false ){
157
  ?>
158
+ <div id="wcml-cart-dialog-confirm" title="<?php echo esc_attr( $dialog_title ) ?>">
159
+ <p><?php echo esc_html( $confirmation_message ); ?></p>
160
  </div>
161
 
162
  <script type="text/javascript">
176
  "<?php echo $switch_to; ?>": function() {
177
  jQuery( this ).dialog( "close" );
178
  <?php if( $language_switch ): ?>
179
+ window.location = '<?php echo esc_js( $switch_to_value ); ?>';
180
  <?php else: ?>
181
  jQuery('.wcml_currency_switcher').parent().find('img').remove();
182
+ wcml_load_currency( "<?php echo esc_js( $switch_to_value ); ?>", true );
183
  <?php endif; ?>
184
 
185
  },
186
  "<?php echo $stay_in; ?>": function() {
187
  jQuery( this ).dialog( "close" );
188
  <?php if( $language_switch ): ?>
189
+ window.location = '<?php echo esc_js( $stay_in_value ); ?>';
190
  <?php else: ?>
191
  jQuery('.wcml_currency_switcher').parent().find('img').remove();
192
  jQuery('.wcml_currency_switcher').removeAttr('disabled');
193
+ jQuery('.wcml_currency_switcher').val( '<?php echo esc_js ( $stay_in_value ); ?>' );
194
  <?php endif; ?>
195
  }
196
  }
465
  return $args;
466
  }
467
 
468
+ public function add_to_cart_sold_individually_exception( $qt, $quantity, $product_id, $variation_id, $cart_item_data ) {
469
+
470
+ $post_id = $product_id;
471
+ if ( $variation_id ) {
472
+ $post_id = $variation_id;
473
+ }
474
 
475
  //check if product already added to cart in another language
476
+ foreach ( WC()->cart->cart_contents as $cart_item ) {
477
+
478
+ if ( $this->sold_individually_product( $cart_item, $cart_item_data, $post_id, $quantity ) ) {
479
+
480
+ $this->sold_individually_exception( $post_id );
481
 
 
 
 
 
482
  }
483
  }
484
 
485
  return $qt;
486
  }
487
+
488
+ public function sold_individually_product( $cart_item, $cart_item_data, $post_id, $quantity ){
489
+
490
+ $current_product_trid = $this->sitepress->get_element_trid( $post_id, 'post_' . get_post_type( $post_id ) );
491
+
492
+ if ( $cart_item['variation_id'] ) {
493
+ $cart_element_trid = $this->sitepress->get_element_trid( $cart_item['variation_id'], 'post_product_variation' );
494
+ } else {
495
+ $cart_element_trid = $this->sitepress->get_element_trid( $cart_item['product_id'], 'post_product' );
496
+ }
497
+
498
+ if ( apply_filters( 'wcml_add_to_cart_sold_individually', true, $cart_item_data, $post_id, $quantity ) &&
499
+ $current_product_trid == $cart_element_trid &&
500
+ $cart_item['quantity'] > 0
501
+ ) {
502
+ return true;
503
+ } else {
504
+ return false;
505
+ }
506
+ }
507
+
508
+ public function sold_individually_exception( $post_id ){
509
+
510
+ $wc_cart_url = esc_url( wc_get_cart_url() );
511
+ $message_title = sprintf( esc_html__( 'You cannot add another &quot;%s&quot; to your cart.', 'woocommerce' ), get_the_title( $post_id ) );
512
+
513
+ $message = '<a href="' . $wc_cart_url . '" class="button wc-forward">' . esc_html__( 'View Cart', 'woocommerce' ) . '</a>';
514
+ $message .= ' ' . $message_title;
515
+
516
+ throw new Exception( $message );
517
+
518
+ }
519
+
520
  }
inc/class-wcml-compatibility.php CHANGED
@@ -47,11 +47,13 @@ class WCML_Compatibility {
47
  //WooCommerce Table Rate Shipping plugin
48
  if ( defined( 'TABLE_RATE_SHIPPING_VERSION' ) ) {
49
  $this->table_rate_shipping = new WCML_Table_Rate_Shipping( $this->sitepress, $this->woocommerce_wpml );
 
50
  }
51
 
52
  //WooCommerce Subscriptions
53
  if ( class_exists( 'WC_Subscriptions' ) ) {
54
- $this->wp_subscriptions = new WCML_WC_Subscriptions();
 
55
  }
56
 
57
  //WooCommerce Name Your Price
@@ -113,6 +115,7 @@ class WCML_Compatibility {
113
  // Dynamic Pricing
114
  if ( class_exists( 'WC_Dynamic_Pricing' ) ) {
115
  $this->dynamic_pricing = new WCML_Dynamic_Pricing( $this->sitepress );
 
116
  }
117
 
118
  // WooCommerce Bookings
@@ -129,6 +132,7 @@ class WCML_Compatibility {
129
  // WooCommerce Checkout Field Editor
130
  if ( function_exists( 'woocommerce_init_checkout_field_editor' ) ) {
131
  $this->checkout_field_editor = new WCML_Checkout_Field_Editor();
 
132
  }
133
 
134
  if ( class_exists( 'WC_Bulk_Stock_Management' ) ) {
47
  //WooCommerce Table Rate Shipping plugin
48
  if ( defined( 'TABLE_RATE_SHIPPING_VERSION' ) ) {
49
  $this->table_rate_shipping = new WCML_Table_Rate_Shipping( $this->sitepress, $this->woocommerce_wpml );
50
+ $this->table_rate_shipping->add_hooks();
51
  }
52
 
53
  //WooCommerce Subscriptions
54
  if ( class_exists( 'WC_Subscriptions' ) ) {
55
+ $this->wp_subscriptions = new WCML_WC_Subscriptions( $this->woocommerce_wpml, $this->wpdb );
56
+ $this->wp_subscriptions->add_hooks();
57
  }
58
 
59
  //WooCommerce Name Your Price
115
  // Dynamic Pricing
116
  if ( class_exists( 'WC_Dynamic_Pricing' ) ) {
117
  $this->dynamic_pricing = new WCML_Dynamic_Pricing( $this->sitepress );
118
+ $this->dynamic_pricing->add_hooks();
119
  }
120
 
121
  // WooCommerce Bookings
132
  // WooCommerce Checkout Field Editor
133
  if ( function_exists( 'woocommerce_init_checkout_field_editor' ) ) {
134
  $this->checkout_field_editor = new WCML_Checkout_Field_Editor();
135
+ $this->checkout_field_editor->add_hooks();
136
  }
137
 
138
  if ( class_exists( 'WC_Bulk_Stock_Management' ) ) {
inc/class-wcml-coupons.php CHANGED
@@ -2,15 +2,22 @@
2
 
3
  class WCML_Coupons{
4
 
 
5
  private $woocommerce_wpml;
 
6
  private $sitepress;
7
 
8
- public function __construct( &$woocommerce_wpml, &$sitepress ){
9
  $this->woocommerce_wpml = $woocommerce_wpml;
10
- $this->sitepress = $sitepress;
 
 
 
11
 
12
  add_action( 'woocommerce_coupon_loaded', array( $this, 'wcml_coupon_loaded' ) );
13
  add_action( 'admin_init', array( $this, 'icl_adjust_terms_filtering' ) );
 
 
14
  }
15
 
16
  public function wcml_coupon_loaded( $coupons_data ){
@@ -85,4 +92,34 @@ class WCML_Coupons{
85
  }
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
2
 
3
  class WCML_Coupons{
4
 
5
+ /** @var woocommerce_wpml */
6
  private $woocommerce_wpml;
7
+ /** @var Sitepress */
8
  private $sitepress;
9
 
10
+ public function __construct( woocommerce_wpml $woocommerce_wpml, SitePress $sitepress ) {
11
  $this->woocommerce_wpml = $woocommerce_wpml;
12
+ $this->sitepress = $sitepress;
13
+ }
14
+
15
+ public function add_hooks(){
16
 
17
  add_action( 'woocommerce_coupon_loaded', array( $this, 'wcml_coupon_loaded' ) );
18
  add_action( 'admin_init', array( $this, 'icl_adjust_terms_filtering' ) );
19
+
20
+ add_filter( 'woocommerce_coupon_is_valid_for_product', array( $this, 'is_valid_for_product' ), 10, 4 );
21
  }
22
 
23
  public function wcml_coupon_loaded( $coupons_data ){
92
  }
93
  }
94
 
95
+
96
+ /**
97
+ * @param bool $valid
98
+ * @param WC_Product $product
99
+ * @param WC_Coupon $object
100
+ * @param array $values
101
+ *
102
+ * @return bool
103
+ */
104
+ public function is_valid_for_product( $valid, $product, $object, $values )
105
+ {
106
+
107
+ $product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
108
+
109
+ $translated_product_id = apply_filters( 'translate_object_id', $product_id, 'product', false, $this->sitepress->get_current_language() );
110
+
111
+ if ( $product_id !== $translated_product_id ) {
112
+
113
+ remove_filter( 'woocommerce_coupon_is_valid_for_product', array( $this, 'is_valid_for_product' ), 10, 4 );
114
+
115
+ $valid = $object->is_valid_for_product( wc_get_product( $translated_product_id ), $values );
116
+
117
+ add_filter( 'woocommerce_coupon_is_valid_for_product', array( $this, 'is_valid_for_product' ), 10, 4 );
118
+
119
+ }
120
+
121
+ return $valid;
122
+
123
+ }
124
+
125
  }
inc/class-wcml-endpoints.php CHANGED
@@ -321,11 +321,18 @@ class WCML_Endpoints{
321
  function filter_get_endpoint_url( $url, $endpoint, $value, $permalink ){
322
 
323
  // return translated edit account slugs
324
- if( isset( WC()->query->query_vars[ 'edit-address' ] ) && WC()->query->query_vars[ 'edit-address' ] == $endpoint && in_array( $value, array('shipping','billing'))){
325
- remove_filter('woocommerce_get_endpoint_url', array( $this, 'filter_get_endpoint_url'),10,4);
 
 
 
 
326
  $url = wc_get_endpoint_url( 'edit-address', $this->get_translated_edit_address_slug( $value ) );
327
- add_filter('woocommerce_get_endpoint_url', array( $this, 'filter_get_endpoint_url'),10,4);
 
 
328
  }
 
329
 
330
  return $url;
331
  }
321
  function filter_get_endpoint_url( $url, $endpoint, $value, $permalink ){
322
 
323
  // return translated edit account slugs
324
+ remove_filter( 'woocommerce_get_endpoint_url', array( $this, 'filter_get_endpoint_url' ), 10, 4 );
325
+ if ( isset( WC()->query->query_vars['edit-address'] ) && WC()->query->query_vars['edit-address'] == $endpoint && in_array( $value, array(
326
+ 'shipping',
327
+ 'billing'
328
+ ) )
329
+ ) {
330
  $url = wc_get_endpoint_url( 'edit-address', $this->get_translated_edit_address_slug( $value ) );
331
+ } elseif ( $endpoint === get_option( 'woocommerce_myaccount_lost_password_endpoint' ) ) {
332
+ $translated_lost_password_endpoint = apply_filters( 'wpml_translate_single_string', $endpoint, 'WooCommerce Endpoints', 'lost-password' );
333
+ $url = wc_get_endpoint_url( $translated_lost_password_endpoint );
334
  }
335
+ add_filter( 'woocommerce_get_endpoint_url', array( $this, 'filter_get_endpoint_url' ), 10, 4 );
336
 
337
  return $url;
338
  }
inc/class-wcml-locale.php CHANGED
@@ -23,13 +23,19 @@ class WCML_Locale{
23
  }
24
 
25
  public function switch_locale( $lang_code = false ) {
26
- global $l10n;
27
  static $original_l10n;
28
  if ( ! empty( $lang_code ) ) {
 
 
 
 
 
29
  $original_l10n = isset( $l10n[ 'woocommerce-multilingual' ] ) ? $l10n[ 'woocommerce-multilingual' ] : null;
30
  if ( $original_l10n !== null ) {
31
  unset( $l10n[ 'woocommerce-multilingual' ] );
32
  }
 
33
  return load_textdomain( 'woocommerce-multilingual',
34
  WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $this->sitepress->get_locale( $lang_code ) . '.mo' );
35
 
23
  }
24
 
25
  public function switch_locale( $lang_code = false ) {
26
+ global $l10n, $st_gettext_hooks;
27
  static $original_l10n;
28
  if ( ! empty( $lang_code ) ) {
29
+
30
+ if ( null !== $st_gettext_hooks ) {
31
+ $st_gettext_hooks->switch_language_hook( $lang_code );
32
+ }
33
+
34
  $original_l10n = isset( $l10n[ 'woocommerce-multilingual' ] ) ? $l10n[ 'woocommerce-multilingual' ] : null;
35
  if ( $original_l10n !== null ) {
36
  unset( $l10n[ 'woocommerce-multilingual' ] );
37
  }
38
+
39
  return load_textdomain( 'woocommerce-multilingual',
40
  WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $this->sitepress->get_locale( $lang_code ) . '.mo' );
41
 
inc/class-wcml-orders.php CHANGED
@@ -4,10 +4,19 @@ class WCML_Orders{
4
  private $woocommerce_wpml;
5
  private $sitepress;
6
 
7
- private $standart_order_notes = array('Order status changed from %s to %s.',
8
- 'Order item stock reduced successfully.','Item #%s stock reduced from %s to %s.','Item #%s stock increased from %s to %s.','Awaiting BACS payment','Awaiting cheque payment','Payment to be made upon delivery.',
9
- 'Validation error: PayPal amounts do not match (gross %s).','Validation error: PayPal IPN response from a different email address (%s).','Payment pending: %s',
10
- 'Payment %s via IPN.','Validation error: PayPal amounts do not match (amt %s).','IPN payment completed','PDT payment completed'
 
 
 
 
 
 
 
 
 
11
  );
12
 
13
  public function __construct( &$woocommerce_wpml, &$sitepress ){
@@ -59,7 +68,7 @@ class WCML_Orders{
59
  }
60
 
61
  function filtered_woocommerce_new_order_note_data($translations, $text, $domain ){
62
- if(in_array($text,$this->standart_order_notes)){
63
 
64
  $language = $this->woocommerce_wpml->strings->get_string_language( $text, 'woocommerce' );
65
 
4
  private $woocommerce_wpml;
5
  private $sitepress;
6
 
7
+ private $standard_order_notes = array(
8
+ 'Order status changed from %s to %s.',
9
+ 'Order item stock reduced successfully.',
10
+ 'Item #%s stock reduced from %s to %s.',
11
+ 'Item #%s stock increased from %s to %s.',
12
+ 'Awaiting BACS payment','Awaiting cheque payment',
13
+ 'Payment to be made upon delivery.',
14
+ 'Validation error: PayPal amounts do not match (gross %s).',
15
+ 'Validation error: PayPal IPN response from a different email address (%s).',
16
+ 'Payment pending: %s',
17
+ 'Payment %s via IPN.',
18
+ 'Validation error: PayPal amounts do not match (amt %s).',
19
+ 'IPN payment completed','PDT payment completed'
20
  );
21
 
22
  public function __construct( &$woocommerce_wpml, &$sitepress ){
68
  }
69
 
70
  function filtered_woocommerce_new_order_note_data($translations, $text, $domain ){
71
+ if(in_array($text,$this->standard_order_notes)){
72
 
73
  $language = $this->woocommerce_wpml->strings->get_string_language( $text, 'woocommerce' );
74
 
inc/class-wcml-products.php CHANGED
@@ -13,14 +13,27 @@ class WCML_Products{
13
  /**
14
  * @var wpdb
15
  */
16
- private $wpdb;
 
 
 
17
 
18
 
19
- public function __construct( &$woocommerce_wpml, &$sitepress, &$wpdb )
20
- {
 
 
 
 
 
 
 
21
  $this->woocommerce_wpml = $woocommerce_wpml;
22
- $this->sitepress = $sitepress;
23
- $this->wpdb = $wpdb;
 
 
 
24
 
25
  }
26
 
@@ -38,6 +51,8 @@ class WCML_Products{
38
  add_filter( 'woocommerce_json_search_found_products', array( $this, 'filter_found_products_by_language' ) );
39
  add_filter( 'woocommerce_related_products_args', array( $this, 'filter_related_products_args' ) );
40
  add_filter( 'woocommerce_shortcode_products_query', array( $this, 'add_lang_to_shortcode_products_query' ) );
 
 
41
  }
42
 
43
  add_filter( 'woocommerce_upsell_crosssell_search_products', array( $this, 'filter_woocommerce_upsell_crosssell_posts_by_language' ) );
@@ -113,6 +128,33 @@ class WCML_Products{
113
  return $is_variable_product;
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  public function is_grouped_product($product_id){
117
  $get_variation_term_taxonomy_id = $this->wpdb->get_var( "SELECT tt.term_taxonomy_id FROM {$this->wpdb->terms} AS t LEFT JOIN {$this->wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.name = 'grouped'" );
118
  $is_grouped_product = $this->wpdb->get_var( $this->wpdb->prepare( "SELECT count(object_id) FROM {$this->wpdb->term_relationships} WHERE object_id = %d AND term_taxonomy_id = %d ",$product_id,$get_variation_term_taxonomy_id ) );
@@ -586,4 +628,23 @@ class WCML_Products{
586
  return $query_args;
587
  }
588
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
  }
13
  /**
14
  * @var wpdb
15
  */
16
+ private $wpdb;/**
17
+ * @var WPML_WP_Cache
18
+ */
19
+ private $wpml_cache;
20
 
21
 
22
+ /**
23
+ * WCML_Products constructor.
24
+ *
25
+ * @param woocommerce_wpml $woocommerce_wpml
26
+ * @param SitePress $sitepress
27
+ * @param wpdb $wpdb
28
+ * @param WPML_WP_Cache $wpml_cache
29
+ */
30
+ public function __construct( woocommerce_wpml $woocommerce_wpml, SitePress $sitepress, wpdb $wpdb, WPML_WP_Cache $wpml_cache = null ) {
31
  $this->woocommerce_wpml = $woocommerce_wpml;
32
+ $this->sitepress = $sitepress;
33
+ $this->wpdb = $wpdb;
34
+
35
+ $cache_group = 'WCML_Products';
36
+ $this->wpml_cache = is_null( $wpml_cache ) ? new WPML_WP_Cache( $cache_group ) : $wpml_cache;
37
 
38
  }
39
 
51
  add_filter( 'woocommerce_json_search_found_products', array( $this, 'filter_found_products_by_language' ) );
52
  add_filter( 'woocommerce_related_products_args', array( $this, 'filter_related_products_args' ) );
53
  add_filter( 'woocommerce_shortcode_products_query', array( $this, 'add_lang_to_shortcode_products_query' ) );
54
+
55
+ add_filter( 'woocommerce_product_file_download_path', array( $this, 'filter_file_download_path' ) );
56
  }
57
 
58
  add_filter( 'woocommerce_upsell_crosssell_search_products', array( $this, 'filter_woocommerce_upsell_crosssell_posts_by_language' ) );
128
  return $is_variable_product;
129
  }
130
 
131
+ public function is_downloadable_product( $product ) {
132
+
133
+ $cache_key = 'is_downloadable_product_'.$product->get_id();
134
+
135
+ $found = false;
136
+ $is_downloadable = $this->wpml_cache->get( $cache_key, $found );
137
+ if ( ! $found ) {
138
+ if ( $product->is_downloadable() ) {
139
+ $is_downloadable = true;
140
+ } elseif ( $this->is_variable_product( $product->get_id() ) ) {
141
+ $variations = $product->get_available_variations();
142
+ if ( ! empty( $variations ) ) {
143
+ foreach ( $variations as $variation ) {
144
+ if ( $variation['is_downloadable'] ) {
145
+ $is_downloadable = true;
146
+ break;
147
+ }
148
+ }
149
+ }
150
+ }
151
+ $this->wpml_cache->set( $cache_key, $is_downloadable );
152
+ }
153
+
154
+ return $is_downloadable;
155
+
156
+ }
157
+
158
  public function is_grouped_product($product_id){
159
  $get_variation_term_taxonomy_id = $this->wpdb->get_var( "SELECT tt.term_taxonomy_id FROM {$this->wpdb->terms} AS t LEFT JOIN {$this->wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE t.name = 'grouped'" );
160
  $is_grouped_product = $this->wpdb->get_var( $this->wpdb->prepare( "SELECT count(object_id) FROM {$this->wpdb->term_relationships} WHERE object_id = %d AND term_taxonomy_id = %d ",$product_id,$get_variation_term_taxonomy_id ) );
628
  return $query_args;
629
  }
630
 
631
+
632
+ /**
633
+ * Get file download path in correct domain
634
+ *
635
+ * @param string $file_path file path URL
636
+ * @return string
637
+ */
638
+ public function filter_file_download_path( $file_path ) {
639
+
640
+ $is_per_domain = $this->sitepress->get_wp_api()->constant( 'WPML_LANGUAGE_NEGOTIATION_TYPE_DOMAIN' ) === (int) $this->sitepress->get_setting( 'language_negotiation_type' );
641
+
642
+ if ( $is_per_domain ) {
643
+ $file_path = $this->sitepress->convert_url( $file_path );
644
+ }
645
+
646
+ return $file_path;
647
+
648
+ }
649
+
650
  }
inc/class-wcml-resources.php CHANGED
@@ -141,7 +141,8 @@ class WCML_Resources {
141
  wp_enqueue_script( 'cart-widget' );
142
  wp_localize_script( 'cart-widget', 'actions', array(
143
  'is_lang_switched' => self::$sitepress->get_language_from_url( $referer ) != self::$sitepress->get_current_language() ? 1 : 0,
144
- 'is_currency_switched' => isset( $_GET[ 'wcmlc' ] ) ? 1 : 0
 
145
  ) );
146
  } elseif( is_admin() ) {
147
 
141
  wp_enqueue_script( 'cart-widget' );
142
  wp_localize_script( 'cart-widget', 'actions', array(
143
  'is_lang_switched' => self::$sitepress->get_language_from_url( $referer ) != self::$sitepress->get_current_language() ? 1 : 0,
144
+ 'is_currency_switched' => isset( $_GET[ 'wcmlc' ] ) ? 1 : 0,
145
+ 'cart_fragment' => apply_filters( 'woocommerce_cart_fragment_name', 'wc_fragments_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) ) ),
146
  ) );
147
  } elseif( is_admin() ) {
148
 
inc/class-wcml-tp-support.php CHANGED
@@ -284,7 +284,7 @@ class WCML_TP_Support {
284
  $image_data = array();
285
 
286
  foreach ( $data as $data_key => $value ) {
287
- if ( $value['finished'] ) {
288
  if ( strpos( $value['field_type'], 'image-id-' . $image_id ) === 0 ) {
289
  if ( $value['field_type'] === 'image-id-' . $image_id . '-title' ) {
290
  $image_data['title'] = $value['data'];
284
  $image_data = array();
285
 
286
  foreach ( $data as $data_key => $value ) {
287
+ if ( $value['finished'] && isset( $value['field_type'] ) ) {
288
  if ( strpos( $value['field_type'], 'image-id-' . $image_id ) === 0 ) {
289
  if ( $value['field_type'] === 'image-id-' . $image_id . '-title' ) {
290
  $image_data['title'] = $value['data'];
inc/class-wcml-upgrade.php CHANGED
@@ -86,7 +86,7 @@ class WCML_Upgrade{
86
  }
87
 
88
  function run(){
89
-
90
  $version_in_db = get_option('_wcml_version');
91
 
92
  // exception - starting in 2.3.2
@@ -541,10 +541,11 @@ class WCML_Upgrade{
541
  if( !class_exists( 'WooCommerce' ) ){
542
  update_option( '_wcml_4_1_0_migration_required', true );
543
  }else{
544
- $results = $wpdb->get_results("
 
545
  SELECT *
546
  FROM {$wpdb->postmeta}
547
- WHERE meta_key LIKE '_price_%' OR meta_key LIKE '_regular_price_%' OR ( meta_key LIKE '_sale_price_%' AND meta_key NOT LIKE '_sale_price_dates%' )
548
  ");
549
 
550
  foreach( $results as $price ){
86
  }
87
 
88
  function run(){
89
+
90
  $version_in_db = get_option('_wcml_version');
91
 
92
  // exception - starting in 2.3.2
541
  if( !class_exists( 'WooCommerce' ) ){
542
  update_option( '_wcml_4_1_0_migration_required', true );
543
  }else{
544
+
545
+ $results = $wpdb->get_results( "
546
  SELECT *
547
  FROM {$wpdb->postmeta}
548
+ WHERE meta_key LIKE '\\_price\\_%' OR meta_key LIKE '\\_regular_price\\_%' OR ( meta_key LIKE '\\_sale_price\\_%' AND meta_key NOT LIKE '\\_sale\\_price\\_dates%' )
549
  ");
550
 
551
  foreach( $results as $price ){
inc/class-wcml-wc-shipping.php CHANGED
@@ -120,9 +120,16 @@ class WCML_WC_Shipping{
120
  return $available_methods;
121
  }
122
 
123
- function translate_shipping_method_title( $title, $shipping_id, $language = false ) {
124
-
125
- if ( is_admin() ) {
 
 
 
 
 
 
 
126
  $screen = get_current_screen();
127
  $is_edit_order = $screen->id === 'shop_order';
128
  } else {
@@ -181,8 +188,7 @@ class WCML_WC_Shipping{
181
  }
182
  }
183
 
184
- function update_woocommerce_shipping_settings_for_class_costs( $settings ){
185
-
186
  remove_filter( 'get_term', array( $this->sitepress, 'get_term_adjust_id' ), 1 );
187
  foreach( $settings as $setting_key => $value ){
188
 
@@ -195,7 +201,6 @@ class WCML_WC_Shipping{
195
  }else{
196
  $shipp_class = get_term_by( 'slug', $shipp_class_key, 'product_shipping_class' );
197
  }
198
-
199
  $trid = $this->sitepress->get_element_trid( $shipp_class->term_taxonomy_id, 'tax_product_shipping_class' );
200
 
201
  $translations = $this->sitepress->get_element_translations( $trid, 'tax_product_shipping_class' );
@@ -233,12 +238,19 @@ class WCML_WC_Shipping{
233
  }
234
  }
235
 
236
- function sync_flat_rate_class_cost( $data, $inst_settings ){
 
 
 
 
 
 
237
 
238
  $settings = array();
239
  foreach ( $data as $key => $value ) {
240
- if ( substr( $key, 0, 33) == 'woocommerce_flat_rate_class_cost_' ) {
241
- $settings[ substr( $key, 22 ) ] = $value;
 
242
  }
243
  }
244
 
120
  return $available_methods;
121
  }
122
 
123
+ /**
124
+ * @param string $title
125
+ * @param string $shipping_id
126
+ * @param string|bool $language
127
+ *
128
+ * @return string
129
+ */
130
+ public function translate_shipping_method_title( $title, $shipping_id, $language = false ) {
131
+
132
+ if ( is_admin() && did_action( 'admin_init' ) && did_action( 'current_screen' ) ) {
133
  $screen = get_current_screen();
134
  $is_edit_order = $screen->id === 'shop_order';
135
  } else {
188
  }
189
  }
190
 
191
+ public function update_woocommerce_shipping_settings_for_class_costs( $settings ){
 
192
  remove_filter( 'get_term', array( $this->sitepress, 'get_term_adjust_id' ), 1 );
193
  foreach( $settings as $setting_key => $value ){
194
 
201
  }else{
202
  $shipp_class = get_term_by( 'slug', $shipp_class_key, 'product_shipping_class' );
203
  }
 
204
  $trid = $this->sitepress->get_element_trid( $shipp_class->term_taxonomy_id, 'tax_product_shipping_class' );
205
 
206
  $translations = $this->sitepress->get_element_translations( $trid, 'tax_product_shipping_class' );
238
  }
239
  }
240
 
241
+ /**
242
+ * @param array $data
243
+ * @param array $inst_settings
244
+ *
245
+ * @return array|mixed
246
+ */
247
+ public function sync_flat_rate_class_cost( $data, $inst_settings ){
248
 
249
  $settings = array();
250
  foreach ( $data as $key => $value ) {
251
+ if ( 0 === strpos( $key, 'woocommerce_flat_rate_class_cost_') ) {
252
+ $limit = strlen( 'woocommerce_flat_rate_' );
253
+ $settings[ substr( $key, $limit ) ] = stripslashes( $value );
254
  }
255
  }
256
 
inc/class-woocommerce-wpml.php CHANGED
@@ -202,9 +202,11 @@ class woocommerce_wpml {
202
  $this->cart = new WCML_Cart( $this, $sitepress, $woocommerce );
203
  $this->cart->add_hooks();
204
  $this->coupons = new WCML_Coupons( $this, $sitepress );
 
205
  $this->locale = new WCML_Locale( $this, $sitepress );
206
  $this->media = new WCML_Media( $this, $sitepress, $wpdb );
207
  $this->downloadable = new WCML_Downloadable_Products( $this, $sitepress );
 
208
  $this->page_builders = new WCML_Page_Builders( $sitepress );
209
  $this->reports = new WCML_Reports;
210
  $this->wcml_products_screen = new WCML_Products_Screen_Options();
202
  $this->cart = new WCML_Cart( $this, $sitepress, $woocommerce );
203
  $this->cart->add_hooks();
204
  $this->coupons = new WCML_Coupons( $this, $sitepress );
205
+ $this->coupons->add_hooks();
206
  $this->locale = new WCML_Locale( $this, $sitepress );
207
  $this->media = new WCML_Media( $this, $sitepress, $wpdb );
208
  $this->downloadable = new WCML_Downloadable_Products( $this, $sitepress );
209
+ $this->downloadable->add_hooks();
210
  $this->page_builders = new WCML_Page_Builders( $sitepress );
211
  $this->reports = new WCML_Reports;
212
  $this->wcml_products_screen = new WCML_Products_Screen_Options();
inc/currencies/class-wcml-custom-prices.php CHANGED
@@ -59,11 +59,11 @@ class WCML_Custom_Prices{
59
 
60
  if(!empty($product_meta['_wcml_custom_prices_status'][0])){
61
 
62
- $prices_keys = array(
63
  '_price', '_regular_price', '_sale_price',
64
  '_min_variation_price', '_max_variation_price',
65
  '_min_variation_regular_price', '_max_variation_regular_price',
66
- '_min_variation_sale_price', '_max_variation_sale_price');
67
 
68
  foreach($prices_keys as $key){
69
 
59
 
60
  if(!empty($product_meta['_wcml_custom_prices_status'][0])){
61
 
62
+ $prices_keys = apply_filters( 'wcml_price_custom_fields_filtered', array(
63
  '_price', '_regular_price', '_sale_price',
64
  '_min_variation_price', '_max_variation_price',
65
  '_min_variation_regular_price', '_max_variation_regular_price',
66
+ '_min_variation_sale_price', '_max_variation_sale_price' ));
67
 
68
  foreach($prices_keys as $key){
69
 
inc/currencies/class-wcml-multi-currency-orders.php CHANGED
@@ -265,6 +265,7 @@ class WCML_Multi_Currency_Orders {
265
 
266
  if ( ! isset( $this->multi_currency->prices ) ) {
267
  $this->multi_currency->prices = new WCML_Multi_Currency_Prices( $this->multi_currency );
 
268
  $this->multi_currency->prices->prices_init();
269
  }
270
 
@@ -376,17 +377,19 @@ class WCML_Multi_Currency_Orders {
376
  }
377
 
378
  public function get_currency_for_new_order( $value, $order ) {
379
- $current_screen = get_current_screen();
380
- if ( ! empty( $current_screen ) && $current_screen->id == 'shop_order' ) {
381
- $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
382
- $order_currency = get_post_meta( $order_id, '_order_currency', true );
383
- if ( empty( $order_currency ) ) {
384
- $value = $this->get_order_currency_cookie();
 
 
 
385
  }
386
  }
387
 
388
  return $value;
389
  }
390
 
391
-
392
  }
265
 
266
  if ( ! isset( $this->multi_currency->prices ) ) {
267
  $this->multi_currency->prices = new WCML_Multi_Currency_Prices( $this->multi_currency );
268
+ $this->multi_currency->prices->add_hooks();
269
  $this->multi_currency->prices->prices_init();
270
  }
271
 
377
  }
378
 
379
  public function get_currency_for_new_order( $value, $order ) {
380
+
381
+ if ( did_action( 'current_screen' ) ) {
382
+ $current_screen = get_current_screen();
383
+ if ( ! empty( $current_screen ) && $current_screen->id == 'shop_order' ) {
384
+ $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
385
+ $order_currency = get_post_meta( $order_id, '_order_currency', true );
386
+ if ( empty( $order_currency ) ) {
387
+ $value = $this->get_order_currency_cookie();
388
+ }
389
  }
390
  }
391
 
392
  return $value;
393
  }
394
 
 
395
  }
inc/currencies/class-wcml-multi-currency-prices.php CHANGED
@@ -1,684 +1,791 @@
1
  <?php
2
 
3
- class WCML_Multi_Currency_Prices{
4
 
5
- /**
6
- * @var woocommerce_wpml
7
- */
8
- private $woocommerce_wpml;
9
- /**
10
- * @var WCML_Multi_Currency
11
- */
12
- private $multi_currency;
13
- /**
14
- * @var orders_list_currency
15
- */
16
- private $orders_list_currency;
17
-
18
- public function __construct( &$multi_currency ){
19
-
20
- $this->multi_currency =& $multi_currency;
21
 
22
- if( $this->multi_currency->load_filters ) {
23
- add_filter('init', array($this, 'prices_init'), 5);
 
24
 
25
- // Currency and Amount filters
26
- add_filter('woocommerce_currency', array($this, 'currency_filter'));
27
 
28
- add_filter( 'wcml_price_currency', array($this, 'price_currency_filter') ); // WCML filters
29
- add_filter( 'wcml_raw_price_amount', array($this, 'raw_price_filter'), 10, 2 ); // WCML filters
30
- add_filter( 'wcml_product_price_by_currency', array($this, 'get_product_price_in_currency'), 10, 2 ); // WCML filters
31
 
32
- add_filter('get_post_metadata', array($this, 'product_price_filter'), 10, 4);
33
- add_filter('get_post_metadata', array($this, 'variation_prices_filter'), 12, 4); // second
34
 
35
- add_filter('woocommerce_price_filter_widget_max_amount', array($this, 'raw_price_filter'), 99);
36
- add_filter('woocommerce_price_filter_widget_min_amount', array($this, 'raw_price_filter'), 99);
 
 
 
37
 
38
- add_filter('woocommerce_adjust_price', array($this, 'raw_price_filter'), 10);
 
39
 
40
- add_filter('wcml_formatted_price', array($this, 'formatted_price'), 10, 2); // WCML filters
 
41
 
42
- // Shipping prices
43
- add_filter('woocommerce_paypal_args', array($this, 'filter_price_woocommerce_paypal_args'));
44
- add_filter('woocommerce_get_variation_prices_hash', array($this, 'add_currency_to_variation_prices_hash'));
45
- add_filter('woocommerce_cart_contents_total', array($this, 'filter_woocommerce_cart_contents_total'), 100);
46
- add_filter('woocommerce_cart_subtotal', array($this, 'filter_woocommerce_cart_subtotal'), 100, 3);
47
 
48
- //filters for wc-widget-price-filter
49
- add_filter('woocommerce_price_filter_results', array($this, 'filter_price_filter_results'), 10, 3);
50
- add_filter('woocommerce_price_filter_widget_amount', array($this, 'filter_price_filter_widget_amount'));
51
 
52
- add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'filter_currency_num_decimals_in_cart' ) );
 
 
 
 
 
 
 
 
 
 
53
 
54
- if( version_compare( WOOCOMMERCE_VERSION, '2.3', '<' ) ){
55
- add_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
56
- }
57
 
58
- add_filter( 'wc_price_args', array( $this, 'filter_wc_price_args') );
 
 
 
59
 
60
- WCML_Multi_Currency_Table_Rate_Shipping::set_up();
61
- }
62
 
63
- // formatting options
64
- add_filter('option_woocommerce_price_thousand_sep', array($this, 'filter_currency_thousand_sep_option'));
65
- add_filter('option_woocommerce_price_decimal_sep', array($this, 'filter_currency_decimal_sep_option'));
66
- add_filter('option_woocommerce_price_num_decimals', array($this, 'filter_currency_num_decimals_option'));
67
- add_filter('option_woocommerce_currency_pos', array($this, 'filter_currency_position_option'));
68
 
69
- //need for display correct price format for order on orders list page
70
- add_filter( 'get_post_metadata', array( $this, 'save_order_currency_for_filter' ), 10, 4);
 
 
 
71
 
72
- }
 
 
73
 
74
- public function prices_init(){
75
- global $woocommerce_wpml;
76
- $this->woocommerce_wpml =& $woocommerce_wpml;
77
 
78
- }
79
 
80
- public function currency_filter($currency){
81
 
82
- $currency = apply_filters('wcml_price_currency', $currency);
83
 
84
- return $currency;
85
- }
86
 
87
- public function price_currency_filter( $currency ){
88
 
89
- if(isset($this->order_currency)){
90
- $currency = $this->order_currency;
91
- }else{
92
- $currency = $this->multi_currency->get_client_currency();
93
- }
94
 
95
- return $currency;
96
- }
97
 
98
- public function raw_price_filter($price, $currency = false) {
99
 
100
- if( $currency === false ){
101
- $currency = $this->multi_currency->get_client_currency();
102
- }
103
 
104
- if( $currency != get_option('woocommerce_currency')) {
105
- $price = $this->convert_price_amount( $price, $currency );
106
- $price = $this->apply_rounding_rules( $price, $currency );
107
- }
108
 
109
- return $price;
110
 
111
- }
112
 
113
- public function get_product_price_in_currency( $product_id, $currency = false ){
114
 
115
- if( !$currency ){
116
- $currency = $this->multi_currency->get_client_currency();
117
- }
118
 
119
- remove_filter( 'get_post_metadata', array( $this->woocommerce_wpml->multi_currency->prices, 'product_price_filter' ), 10, 4 );
 
 
 
120
 
121
- $manual_prices = $this->multi_currency->custom_prices->get_product_custom_prices( $product_id, $currency );
122
 
123
- if( $manual_prices && !empty( $manual_prices[ '_price' ] ) ){
124
 
125
- $price = $manual_prices[ '_price' ];
126
 
127
- }else{
128
 
129
- $product = wc_get_product( $product_id );
130
- $price = $this->raw_price_filter( $product->get_price(), $currency );
131
 
132
- }
133
 
134
- add_filter( 'get_post_metadata', array( $this->woocommerce_wpml->multi_currency->prices, 'product_price_filter' ), 10, 4 );
 
 
 
135
 
136
- return $price;
137
 
138
- }
139
 
140
- public function product_price_filter($null, $object_id, $meta_key, $single){
141
- global $sitepress;
142
 
143
- static $no_filter = false;
144
 
145
- if(empty($no_filter) && in_array(get_post_type($object_id), array('product', 'product_variation'))){
146
 
147
- $price_keys = apply_filters( 'wcml_price_custom_fields_filtered', array(
148
- '_price',
149
- '_regular_price',
150
- '_sale_price',
151
- '_min_variation_price',
152
- '_max_variation_price',
153
- '_min_variation_regular_price',
154
- '_max_variation_regular_price',
155
- '_min_variation_sale_price',
156
- '_max_variation_sale_price'
157
- ) );
158
 
159
- if(in_array($meta_key, $price_keys)){
160
- $no_filter = true;
161
 
162
- // exception for products migrated from before WCML 3.1 with independent prices
163
- // legacy prior 3.1
164
- $original_object_id = apply_filters( 'translate_object_id',$object_id, get_post_type($object_id), false, $sitepress->get_default_language());
165
- $ccr = get_post_meta($original_object_id, '_custom_conversion_rate', true);
166
- if(in_array($meta_key, array('_price', '_regular_price', '_sale_price')) && !empty($ccr) && isset($ccr[$meta_key][$this->multi_currency->get_client_currency()])){
167
- $price_original = get_post_meta($original_object_id, $meta_key, $single);
168
- $price = $price_original * $ccr[$meta_key][$this->multi_currency->get_client_currency()];
 
 
 
 
 
169
 
170
- }else{
171
 
172
- // normal filtering
173
- // 1. manual prices
174
- $manual_prices = $this->multi_currency->custom_prices->get_product_custom_prices($object_id, $this->multi_currency->get_client_currency());
175
 
176
- if($manual_prices && !empty($manual_prices[$meta_key])){
177
 
178
- $price = $manual_prices[$meta_key];
179
 
180
- }else{
181
- // 2. automatic conversion
182
- $price = get_post_meta($object_id, $meta_key, $single);
183
- $price = apply_filters('wcml_raw_price_amount', $price );
184
 
185
- }
186
 
187
- }
188
 
189
 
190
- $no_filter = false;
191
- }
192
 
193
- }
194
 
195
- return !empty($price) ? $price : $null;
196
- }
197
 
198
- public function variation_prices_filter($null, $object_id, $meta_key, $single){
199
 
200
- if(empty($meta_key) && get_post_type($object_id) == 'product_variation'){
201
- static $no_filter = false;
202
 
203
- if(empty($no_filter)){
204
- $no_filter = true;
205
 
206
- $variation_fields = get_post_meta($object_id);
207
 
208
- $manual_prices = $this->multi_currency->custom_prices->get_product_custom_prices($object_id, $this->multi_currency->get_client_currency());
209
 
210
- foreach($variation_fields as $k => $v){
211
 
212
- if(in_array($k, array('_price', '_regular_price', '_sale_price'))){
213
 
214
- foreach($v as $j => $amount){
215
 
216
- if(isset($manual_prices[$k])){
217
- $variation_fields[$k][$j] = $manual_prices[$k]; // manual price
218
 
219
- }else{
220
- $variation_fields[$k][$j] = apply_filters('wcml_raw_price_amount', $amount ); // automatic conversion
221
- }
222
 
223
- }
224
 
225
- }
226
 
227
- }
228
 
229
- $no_filter = false;
230
- }
231
 
232
- }
233
 
234
- return !empty($variation_fields) ? $variation_fields : $null;
235
 
236
- }
237
 
238
- public function convert_price_amount($amount, $currency = false){
239
 
240
- if( empty( $currency ) ){
241
- $currency = $this->multi_currency->get_client_currency();
242
- }
243
 
244
- if( $currency != get_option('woocommerce_currency')){
245
 
246
- $exchange_rates = $this->multi_currency->get_exchange_rates();
247
 
248
- if(isset($exchange_rates[$currency]) && is_numeric($amount)){
249
- $amount = $amount * $exchange_rates[$currency];
250
 
251
- // exception - currencies_without_cents
252
- if(in_array($currency, $this->multi_currency->get_currencies_without_cents())){
253
- $amount = $this->round_up( $amount );
254
- }
255
 
256
- }else{
257
- $amount = 0;
258
- }
259
 
260
- }
261
 
262
- return $amount;
263
 
264
- }
265
 
266
- // convert back to default currency
267
- public function unconvert_price_amount($amount, $currency = false){
268
 
269
- if(empty($currency)){
270
- $currency = $this->multi_currency->get_client_currency();
271
- }
272
 
273
- if($currency != get_option('woocommerce_currency')){
274
 
275
- $exchange_rates = $this->multi_currency->get_exchange_rates();
276
 
277
- if(isset($exchange_rates[$currency]) && is_numeric($amount)){
278
- $amount = $amount / $exchange_rates[$currency];
279
 
280
- // exception - currencies_without_cents
281
- if(in_array($currency, $this->multi_currency->get_currencies_without_cents())){
282
- $amount = $this->round_up( $amount );
283
- }
284
 
285
- }else{
286
- $amount = 0;
287
- }
288
 
289
- }
290
 
291
- return $amount;
292
 
293
- }
294
 
295
- public function apply_rounding_rules($price, $currency = false ){
296
 
297
- if( is_null($this->woocommerce_wpml) ){
298
- global $woocommerce_wpml;
299
- $this->woocommerce_wpml = $woocommerce_wpml;
300
- }
301
 
302
- if( !$currency ){
303
- $currency = $this->multi_currency->get_client_currency();
304
- }
305
 
306
- $currency_options = $this->woocommerce_wpml->settings['currency_options'][$currency];
307
 
308
- if( $currency_options['rounding'] != 'disabled' ){
309
 
310
- if($currency_options['rounding_increment'] > 1){
311
- $price = $price / $currency_options['rounding_increment'];
312
- }
313
 
314
- switch($currency_options['rounding']){
315
- case 'up':
316
- $rounded_price = ceil($price);
317
- break;
318
- case 'down':
319
- $rounded_price = floor($price);
320
- break;
321
- case 'nearest':
322
- $rounded_price = $this->round_up( $price );
323
- break;
324
- }
325
 
326
- if($rounded_price > 0){
327
- $price = $rounded_price;
328
- }
329
 
330
- if($currency_options['rounding_increment'] > 1){
331
- $price = $price * $currency_options['rounding_increment'];
332
- }
333
 
334
- if($currency_options['auto_subtract'] && $currency_options['auto_subtract'] < $price){
335
- $price = $price - $currency_options['auto_subtract'];
336
- }
337
 
338
- } else {
339
 
340
- // Use configured number of decimals
341
- $price = floor( $price * pow( 10, $currency_options['num_decimals']) + 0.0001 ) / pow( 10, $currency_options['num_decimals'] );
342
 
343
- }
344
 
345
 
346
- return apply_filters( 'wcml_rounded_price', $price, $currency );
347
 
348
- }
349
 
350
  /**
351
  * The PHP 5.2 compatible equivalent to "round($amount, 0, PHP_ROUND_HALF_UP)"
 
352
  * @param int $amount
 
353
  * @return int
354
  *
355
  */
356
- private function round_up( $amount ){
357
- if( $amount - floor( $amount ) < 0.5 ){
358
- $amount = floor( $amount );
359
- }else{
360
- $amount = ceil( $amount );
361
- }
362
- return $amount;
363
- }
364
-
365
- /*
366
- * Converts the price from the default currency to the given currency and applies the format
367
- */
368
- public function formatted_price($amount, $currency = false){
369
-
370
- if( $currency === false ){
371
- $currency = $this->multi_currency->get_client_currency();
372
- }
373
-
374
- $amount = $this->raw_price_filter($amount, $currency);
375
-
376
- $currency_details = $this->woocommerce_wpml->multi_currency->get_currency_details_by_code( $currency );
377
-
378
- switch ( $currency_details[ 'position' ] ) {
379
- case 'left' :
380
- $format = '%1$s%2$s';
381
- break;
382
- case 'right' :
383
- $format = '%2$s%1$s';
384
- break;
385
- case 'left_space' :
386
- $format = '%1$s&nbsp;%2$s';
387
- break;
388
- case 'right_space' :
389
- $format = '%2$s&nbsp;%1$s';
390
- break;
391
- }
392
-
393
- $wc_price_args = array(
394
-
395
- 'currency' => $currency,
396
- 'decimal_separator' => $currency_details['decimal_sep'],
397
- 'thousand_separator' => $currency_details['thousand_sep'],
398
- 'decimals' => $currency_details['num_decimals'],
399
- 'price_format' => $format,
400
-
401
-
402
- );
403
-
404
- $price = wc_price($amount, $wc_price_args);
405
-
406
- return $price;
407
- }
408
-
409
- // Exposed function
410
- public function apply_currency_position( $price, $currency_code ){
411
-
412
- $currencies = $this->woocommerce_wpml->multi_currency->get_currencies();
413
-
414
- if( isset( $currencies[$currency_code]['position'] ) ){
415
- $position = $currencies[$currency_code]['position'];
416
- }else{
417
- remove_filter( 'option_woocommerce_currency_pos', array( $this->woocommerce_wpml->multi_currency->prices, 'filter_currency_position_option' ) );
418
- $position = get_option('woocommerce_currency_pos');
419
- add_filter( 'option_woocommerce_currency_pos', array( $this->woocommerce_wpml->multi_currency->prices, 'filter_currency_position_option' ) );
420
- }
421
-
422
- switch( $position ){
423
- case 'left': $price = sprintf( '%s%s', get_woocommerce_currency_symbol( $currency_code ), $price ); break;
424
- case 'right': $price = sprintf( '%s%s', $price, get_woocommerce_currency_symbol( $currency_code ) ); break;
425
- case 'left_space': $price = sprintf( '%s %s', get_woocommerce_currency_symbol( $currency_code ), $price ); break;
426
- case 'right_space': $price = sprintf( '%s %s', $price, get_woocommerce_currency_symbol( $currency_code ) ); break;
427
- }
428
-
429
- return $price;
430
- }
431
-
432
- public function filter_price_woocommerce_paypal_args( $args ){
433
-
434
- foreach( $args as $key => $value ){
435
- if( substr( $key, 0, 7 ) == 'amount_' ){
436
-
437
- $currency_details = $this->woocommerce_wpml->multi_currency->get_currency_details_by_code( $args['currency_code'] );
438
-
439
- $args[ $key ] = number_format( $value, $currency_details['num_decimals'], '.', '' );
440
- }
441
- }
442
-
443
- return $args;
444
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
 
446
- public function add_currency_to_variation_prices_hash($data){
 
 
 
 
 
 
447
 
448
- $data['currency'] = $this->multi_currency->get_client_currency();
449
- $data['exchange_rates_hash'] = md5( json_encode( $this->multi_currency->get_exchange_rates() ) );
450
 
451
- return $data;
452
 
453
- }
 
 
 
454
 
455
- public function filter_woocommerce_cart_contents_total( $cart_contents_total ){
456
- global $woocommerce;
457
- remove_filter( 'woocommerce_cart_contents_total', array( $this, 'filter_woocommerce_cart_contents_total'), 100 );
458
- $woocommerce->cart->calculate_totals();
459
- $cart_contents_total = $woocommerce->cart->get_cart_total();
460
- add_filter( 'woocommerce_cart_contents_total', array( $this, 'filter_woocommerce_cart_contents_total'), 100 );
461
 
462
- return $cart_contents_total;
463
- }
464
 
465
- public function filter_woocommerce_cart_subtotal( $cart_subtotal, $compound, $obj ){
466
- global $woocommerce;
467
- remove_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal'), 100, 3 );
468
- if( apply_filters( 'wcml_calculate_totals_exception', true ) ) {
469
- $woocommerce->cart->calculate_totals();
470
- }
471
- $cart_subtotal = $woocommerce->cart->get_cart_subtotal( $compound );
472
- add_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal'), 100, 3 );
473
 
474
- return $cart_subtotal;
475
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
 
477
- public function filter_price_filter_results( $matched_products, $min, $max ){
478
- global $wpdb;
479
 
480
- $current_currency = $this->multi_currency->get_client_currency();
481
- if( $current_currency != get_option('woocommerce_currency') ){
482
- $filtered_min = $this->unconvert_price_amount( $min, $current_currency );
483
- $filtered_max = $this->unconvert_price_amount( $max, $current_currency );
 
 
 
 
 
 
 
 
 
484
 
485
- $matched_products = $wpdb->get_results( $wpdb->prepare("
486
- SELECT DISTINCT ID, post_parent, post_type FROM $wpdb->posts
487
- INNER JOIN $wpdb->postmeta ON ID = post_id
488
- WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = 'publish' AND meta_key = %s AND meta_value BETWEEN %d AND %d
489
- ", '_price', $filtered_min, $filtered_max ), OBJECT_K );
490
 
491
- foreach( $matched_products as $key => $matched_product ){
492
- $custom_price = get_post_meta( $matched_product->ID, '_price_'.$current_currency, true );
493
- if( $custom_price && ( $custom_price < $min || $custom_price > $max ) ){
494
- unset( $matched_products[$key] );
495
- }
496
- }
497
- }
498
 
499
- return $matched_products;
500
- }
501
 
502
- public function filter_price_filter_widget_amount( $amount ){
503
 
504
- $current_currency = $this->multi_currency->get_client_currency();
505
- if( $current_currency != get_option('woocommerce_currency') ){
506
- $amount = apply_filters('wcml_raw_price_amount', $amount );
507
- }
508
 
509
- return $amount;
510
 
511
- }
 
 
 
 
 
 
 
 
 
 
512
 
513
- private function check_admin_order_currency_code()
514
- {
515
- global $pagenow;
516
 
517
- $actions = array('woocommerce_add_order_item', 'woocommerce_save_order_items', 'woocommerce_calc_line_taxes');
518
- $is_ajax_order_action =
519
- is_ajax() &&
520
- (
521
- (
522
- isset($_POST['action']) &&
523
- in_array($_POST['action'], $actions) ||
524
- (
525
- isset($_GET['action']) &&
526
- $_GET['action'] == 'woocommerce_json_search_products_and_variations'
527
- )
528
- )
529
- );
530
 
531
- $is_shop_order_new = $pagenow == 'post-new.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'shop_order';
 
532
 
533
- if (($is_ajax_order_action || $is_shop_order_new) && isset($_COOKIE['_wcml_order_currency'])) {
534
- $currency_code = $_COOKIE['_wcml_order_currency'];
535
- } elseif (isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order') {
536
- $currency_code = get_post_meta($_GET['post'], '_order_currency', true);
537
- }elseif( isset( $_GET[ 'post_type' ] ) && $_GET[ 'post_type' ] == 'shop_order' && !is_null( $this->orders_list_currency ) ){
538
- $currency_code = $this->orders_list_currency;
539
- }elseif( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wc-reports' && isset( $_COOKIE[ '_wcml_reports_currency' ] ) ){
540
- $currency_code = $_COOKIE[ '_wcml_reports_currency' ];
541
- }elseif( isset( $_COOKIE[ '_wcml_dashboard_currency' ] ) && is_admin() && !defined( 'DOING_AJAX' ) && $pagenow == 'index.php' ){
542
- $currency_code = $_COOKIE[ '_wcml_dashboard_currency' ];
543
- }else{
544
- $currency_code = $this->multi_currency->get_client_currency();
545
- }
546
 
547
- return apply_filters( 'wcml_filter_currency_position', $currency_code );
 
548
 
549
- }
550
 
551
- public function get_admin_order_currency_code(){
 
552
 
553
- return $this->check_admin_order_currency_code();
 
554
 
555
- }
556
 
557
- public function save_order_currency_for_filter( $null, $object_id, $meta_key, $single ){
 
558
 
559
- if(
560
- $meta_key == '_order_currency' &&
561
- isset( $_GET[ 'post_type' ] ) &&
562
- $_GET[ 'post_type' ] == 'shop_order' &&
563
- !isset( $_GET[ 'post' ] ) &&
564
- get_post_type( $object_id ) == 'shop_order'
565
- ){
566
- remove_filter( 'get_post_metadata', array( $this, 'save_order_currency_for_filter' ), 10, 4);
567
- $this->orders_list_currency = get_post_meta( $object_id, $meta_key, true );
568
- add_filter( 'get_post_metadata', array( $this, 'save_order_currency_for_filter' ), 10, 4);
569
- }
570
-
571
- return $null;
572
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
 
574
- public function filter_currency_thousand_sep_option($value){
 
 
 
 
 
 
 
 
 
575
 
576
- $default_currency = $this->multi_currency->get_default_currency();
577
- $currency_code = $this->check_admin_order_currency_code();
578
 
579
- if( $currency_code !== $default_currency && isset( $this->multi_currency->currencies[$currency_code]['thousand_sep'] ) ){
580
- $value = $this->multi_currency->currencies[$currency_code]['thousand_sep'];
581
- }
582
- return $value;
583
- }
 
 
 
 
 
584
 
585
- public function filter_currency_decimal_sep_option($value){
586
 
587
- $default_currency = $this->multi_currency->get_default_currency();
588
- $currency_code = $this->check_admin_order_currency_code();
 
589
 
590
- if( $currency_code !== $default_currency && isset( $this->multi_currency->currencies[$currency_code]['decimal_sep'] ) ){
591
- $value = $this->multi_currency->currencies[$currency_code]['decimal_sep'];
 
 
 
 
 
 
 
 
592
 
593
- }
594
 
595
- return $value;
596
- }
597
 
598
- public function filter_currency_num_decimals_option($value){
599
- // no other way available (at the moment) to filter currency_num_decimals_option
600
- $default_currency = $this->multi_currency->get_default_currency();
601
-
602
- $db = debug_backtrace();
603
- if(
604
- isset( $db['8']['function'] ) && isset( $db['5']['function'] ) &&
605
- $db['8']['function'] == 'calculate_shipping_for_package' && $db['5']['function'] == 'add_rate'
606
- ||
607
- isset( $db['7']['function'] ) && isset( $db['4']['function'] ) &&
608
- $db['7']['function'] == 'calculate_shipping_for_package' && $db['4']['function'] == 'add_rate'
609
- ){
610
- $currency_code = $default_currency;
611
- }else{
612
- $currency_code = $this->check_admin_order_currency_code();
613
- }
614
-
615
- if( $currency_code !== $default_currency && isset($this->multi_currency->currencies[$currency_code]['num_decimals']) ){
616
- $value = $this->multi_currency->currencies[$currency_code]['num_decimals'];
617
- }
618
-
619
- return $value;
620
- }
621
-
622
- public function filter_currency_position_option($value){
623
-
624
- $default_currency = $this->multi_currency->get_default_currency();
625
- $currency_code = $this->get_admin_order_currency_code();
626
-
627
- if( $currency_code !== $default_currency &&
628
- isset($this->multi_currency->currencies[$currency_code]['position']) && get_option('woocommerce_currency') != $currency_code &&
629
- in_array($this->multi_currency->currencies[$currency_code]['position'], array('left', 'right', 'left_space', 'right_space'))){
630
- $value = $this->multi_currency->currencies[$currency_code]['position'];
631
- }
632
- return $value;
633
- }
634
-
635
- public function filter_currency_num_decimals_in_cart( $cart ){
636
- $cart->dp = wc_get_price_decimals();
637
- }
638
-
639
- /*
640
- * Limitation: If the default currency is configured to display more decimals than the other currencies,
641
- * the prices in the secondary currencies would be approximated to the number of decimals that they have more.
642
- */
643
- public function price_in_specific_currency( $return, $price, $args ){
644
-
645
- if(isset($args['currency']) && $this->multi_currency->get_client_currency() != $args['currency']){
646
- remove_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
647
- $this->multi_currency->set_client_currency( $args['currency'] );
648
- $return = wc_price($price, $args);
649
- add_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
650
- }
651
-
652
- return $return;
653
-
654
- }
655
-
656
- public function filter_wc_price_args( $args ){
657
-
658
- if( isset($args['currency']) ){
659
-
660
- if(isset($this->multi_currency->currencies[$args['currency']]['decimal_sep']) ){
661
- $args['decimal_separator'] = $this->multi_currency->currencies[$args['currency']]['decimal_sep'];
662
- }
663
-
664
- if(isset($this->multi_currency->currencies[$args['currency']]['thousand_sep']) ){
665
- $args['thousand_separator'] = $this->multi_currency->currencies[$args['currency']]['thousand_sep'];
666
- }
667
-
668
- if(isset($this->multi_currency->currencies[$args['currency']]['num_decimals']) ){
669
- $args['decimals'] = $this->multi_currency->currencies[$args['currency']]['num_decimals'];
670
- }
671
-
672
- if( isset($this->multi_currency->currencies[$args['currency']]['position']) ){
673
- $current_currency = $this->multi_currency->get_client_currency();
674
- $this->multi_currency->set_client_currency( $args['currency'] );
675
- $args['price_format'] = get_woocommerce_price_format();
676
- $this->multi_currency->set_client_currency( $current_currency ); //restore
677
- }
678
-
679
- }
680
-
681
- return $args;
682
- }
683
 
684
  }
1
  <?php
2
 
3
+ class WCML_Multi_Currency_Prices {
4
 
5
+ /**
6
+ * @var woocommerce_wpml
7
+ */
8
+ private $woocommerce_wpml;
9
+ /**
10
+ * @var WCML_Multi_Currency
11
+ */
12
+ private $multi_currency;
13
+ /**
14
+ * @var orders_list_currency
15
+ */
16
+ private $orders_list_currency;
 
 
 
 
17
 
18
+ public function __construct( $multi_currency ) {
19
+ $this->multi_currency = $multi_currency;
20
+ }
21
 
22
+ public function add_hooks() {
23
+ add_filter( 'wcml_raw_price_amount', array( $this, 'raw_price_filter' ), 10, 2 ); // WCML filters
24
 
25
+ if ( $this->multi_currency->load_filters ) {
26
+ add_filter( 'init', array( $this, 'prices_init' ), 5 );
 
27
 
28
+ // Currency and Amount filters
29
+ add_filter( 'woocommerce_currency', array( $this, 'currency_filter' ) );
30
 
31
+ add_filter( 'wcml_price_currency', array( $this, 'price_currency_filter' ) ); // WCML filters
32
+ add_filter( 'wcml_product_price_by_currency', array(
33
+ $this,
34
+ 'get_product_price_in_currency'
35
+ ), 10, 2 ); // WCML filters
36
 
37
+ add_filter( 'get_post_metadata', array( $this, 'product_price_filter' ), 10, 4 );
38
+ add_filter( 'get_post_metadata', array( $this, 'variation_prices_filter' ), 12, 4 ); // second
39
 
40
+ add_filter( 'woocommerce_price_filter_widget_max_amount', array( $this, 'raw_price_filter' ), 99 );
41
+ add_filter( 'woocommerce_price_filter_widget_min_amount', array( $this, 'raw_price_filter' ), 99 );
42
 
43
+ add_filter( 'woocommerce_adjust_price', array( $this, 'raw_price_filter' ), 10 );
 
 
 
 
44
 
45
+ add_filter( 'wcml_formatted_price', array( $this, 'formatted_price' ), 10, 2 ); // WCML filters
 
 
46
 
47
+ // Shipping prices
48
+ add_filter( 'woocommerce_paypal_args', array( $this, 'filter_price_woocommerce_paypal_args' ) );
49
+ add_filter( 'woocommerce_get_variation_prices_hash', array(
50
+ $this,
51
+ 'add_currency_to_variation_prices_hash'
52
+ ) );
53
+ add_filter( 'woocommerce_cart_contents_total', array(
54
+ $this,
55
+ 'filter_woocommerce_cart_contents_total'
56
+ ), 100 );
57
+ add_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal' ), 100, 3 );
58
 
59
+ //filters for wc-widget-price-filter
60
+ add_filter( 'woocommerce_price_filter_results', array( $this, 'filter_price_filter_results' ), 10, 3 );
61
+ add_filter( 'woocommerce_price_filter_widget_amount', array( $this, 'filter_price_filter_widget_amount' ) );
62
 
63
+ add_action( 'woocommerce_cart_loaded_from_session', array(
64
+ $this,
65
+ 'filter_currency_num_decimals_in_cart'
66
+ ) );
67
 
68
+ add_filter( 'wc_price_args', array( $this, 'filter_wc_price_args' ) );
 
69
 
70
+ }
 
 
 
 
71
 
72
+ // formatting options
73
+ add_filter( 'option_woocommerce_price_thousand_sep', array( $this, 'filter_currency_thousand_sep_option' ) );
74
+ add_filter( 'option_woocommerce_price_decimal_sep', array( $this, 'filter_currency_decimal_sep_option' ) );
75
+ add_filter( 'option_woocommerce_price_num_decimals', array( $this, 'filter_currency_num_decimals_option' ) );
76
+ add_filter( 'option_woocommerce_currency_pos', array( $this, 'filter_currency_position_option' ) );
77
 
78
+ //need for display correct price format for order on orders list page
79
+ add_filter( 'get_post_metadata', array( $this, 'save_order_currency_for_filter' ), 10, 4 );
80
+ }
81
 
82
+ public function prices_init() {
83
+ global $woocommerce_wpml;
84
+ $this->woocommerce_wpml =& $woocommerce_wpml;
85
 
86
+ }
87
 
88
+ public function currency_filter( $currency ) {
89
 
90
+ $currency = apply_filters( 'wcml_price_currency', $currency );
91
 
92
+ return $currency;
93
+ }
94
 
95
+ public function price_currency_filter( $currency ) {
96
 
97
+ if ( isset( $this->order_currency ) ) {
98
+ $currency = $this->order_currency;
99
+ } else {
100
+ $currency = $this->multi_currency->get_client_currency();
101
+ }
102
 
103
+ return $currency;
104
+ }
105
 
106
+ public function raw_price_filter( $price, $currency = false ) {
107
 
108
+ if ( $currency === false ) {
109
+ $currency = $this->multi_currency->get_client_currency();
110
+ }
111
 
112
+ if ( $currency != get_option( 'woocommerce_currency' ) ) {
113
+ $price = $this->convert_price_amount( $price, $currency );
114
+ $price = $this->apply_rounding_rules( $price, $currency );
115
+ }
116
 
117
+ return $price;
118
 
119
+ }
120
 
121
+ public function get_product_price_in_currency( $product_id, $currency = false ) {
122
 
123
+ if ( ! $currency ) {
124
+ $currency = $this->multi_currency->get_client_currency();
125
+ }
126
 
127
+ remove_filter( 'get_post_metadata', array(
128
+ $this->woocommerce_wpml->multi_currency->prices,
129
+ 'product_price_filter'
130
+ ), 10, 4 );
131
 
132
+ $manual_prices = $this->multi_currency->custom_prices->get_product_custom_prices( $product_id, $currency );
133
 
134
+ if ( $manual_prices && ! empty( $manual_prices['_price'] ) ) {
135
 
136
+ $price = $manual_prices['_price'];
137
 
138
+ } else {
139
 
140
+ $product = wc_get_product( $product_id );
141
+ $price = $this->raw_price_filter( $product->get_price(), $currency );
142
 
143
+ }
144
 
145
+ add_filter( 'get_post_metadata', array(
146
+ $this->woocommerce_wpml->multi_currency->prices,
147
+ 'product_price_filter'
148
+ ), 10, 4 );
149
 
150
+ return $price;
151
 
152
+ }
153
 
154
+ public function product_price_filter( $null, $object_id, $meta_key, $single ) {
155
+ global $sitepress;
156
 
157
+ static $no_filter = false;
158
 
159
+ if ( empty( $no_filter ) && in_array( get_post_type( $object_id ), array( 'product', 'product_variation' ) ) ) {
160
 
161
+ $price_keys = apply_filters( 'wcml_price_custom_fields_filtered', array(
162
+ '_price',
163
+ '_regular_price',
164
+ '_sale_price',
165
+ '_min_variation_price',
166
+ '_max_variation_price',
167
+ '_min_variation_regular_price',
168
+ '_max_variation_regular_price',
169
+ '_min_variation_sale_price',
170
+ '_max_variation_sale_price'
171
+ ) );
172
 
173
+ if ( in_array( $meta_key, $price_keys ) ) {
174
+ $no_filter = true;
175
 
176
+ // exception for products migrated from before WCML 3.1 with independent prices
177
+ // legacy prior 3.1
178
+ $original_object_id = apply_filters( 'translate_object_id', $object_id, get_post_type( $object_id ), false, $sitepress->get_default_language() );
179
+ $ccr = get_post_meta( $original_object_id, '_custom_conversion_rate', true );
180
+ if ( in_array( $meta_key, array(
181
+ '_price',
182
+ '_regular_price',
183
+ '_sale_price'
184
+ ) ) && ! empty( $ccr ) && isset( $ccr[ $meta_key ][ $this->multi_currency->get_client_currency() ] )
185
+ ) {
186
+ $price_original = get_post_meta( $original_object_id, $meta_key, $single );
187
+ $price = $price_original * $ccr[ $meta_key ][ $this->multi_currency->get_client_currency() ];
188
 
189
+ } else {
190
 
191
+ // normal filtering
192
+ // 1. manual prices
193
+ $manual_prices = $this->multi_currency->custom_prices->get_product_custom_prices( $object_id, $this->multi_currency->get_client_currency() );
194
 
195
+ if ( $manual_prices && ! empty( $manual_prices[ $meta_key ] ) ) {
196
 
197
+ $price = $manual_prices[ $meta_key ];
198
 
199
+ } else {
200
+ // 2. automatic conversion
201
+ $price = get_post_meta( $object_id, $meta_key, $single );
202
+ $price = apply_filters( 'wcml_raw_price_amount', $price );
203
 
204
+ }
205
 
206
+ }
207
 
208
 
209
+ $no_filter = false;
210
+ }
211
 
212
+ }
213
 
214
+ return ! empty( $price ) ? $price : $null;
215
+ }
216
 
217
+ public function variation_prices_filter( $null, $object_id, $meta_key, $single ) {
218
 
219
+ if ( empty( $meta_key ) && get_post_type( $object_id ) == 'product_variation' ) {
220
+ static $no_filter = false;
221
 
222
+ if ( empty( $no_filter ) ) {
223
+ $no_filter = true;
224
 
225
+ $variation_fields = get_post_meta( $object_id );
226
 
227
+ $manual_prices = $this->multi_currency->custom_prices->get_product_custom_prices( $object_id, $this->multi_currency->get_client_currency() );
228
 
229
+ foreach ( $variation_fields as $k => $v ) {
230
 
231
+ if ( in_array( $k, array( '_price', '_regular_price', '_sale_price' ) ) ) {
232
 
233
+ foreach ( $v as $j => $amount ) {
234
 
235
+ if ( isset( $manual_prices[ $k ] ) ) {
236
+ $variation_fields[ $k ][ $j ] = $manual_prices[ $k ]; // manual price
237
 
238
+ } else {
239
+ $variation_fields[ $k ][ $j ] = apply_filters( 'wcml_raw_price_amount', $amount ); // automatic conversion
240
+ }
241
 
242
+ }
243
 
244
+ }
245
 
246
+ }
247
 
248
+ $no_filter = false;
249
+ }
250
 
251
+ }
252
 
253
+ return ! empty( $variation_fields ) ? $variation_fields : $null;
254
 
255
+ }
256
 
257
+ public function convert_price_amount( $amount, $currency = false ) {
258
 
259
+ if ( empty( $currency ) ) {
260
+ $currency = $this->multi_currency->get_client_currency();
261
+ }
262
 
263
+ if ( $currency != get_option( 'woocommerce_currency' ) ) {
264
 
265
+ $exchange_rates = $this->multi_currency->get_exchange_rates();
266
 
267
+ if ( isset( $exchange_rates[ $currency ] ) && is_numeric( $amount ) ) {
268
+ $amount = $amount * $exchange_rates[ $currency ];
269
 
270
+ // exception - currencies_without_cents
271
+ if ( in_array( $currency, $this->multi_currency->get_currencies_without_cents() ) ) {
272
+ $amount = $this->round_up( $amount );
273
+ }
274
 
275
+ } else {
276
+ $amount = 0;
277
+ }
278
 
279
+ }
280
 
281
+ return $amount;
282
 
283
+ }
284
 
285
+ // convert back to default currency
286
+ public function unconvert_price_amount( $amount, $currency = false ) {
287
 
288
+ if ( empty( $currency ) ) {
289
+ $currency = $this->multi_currency->get_client_currency();
290
+ }
291
 
292
+ if ( $currency != get_option( 'woocommerce_currency' ) ) {
293
 
294
+ $exchange_rates = $this->multi_currency->get_exchange_rates();
295
 
296
+ if ( isset( $exchange_rates[ $currency ] ) && is_numeric( $amount ) ) {
297
+ $amount = $amount / $exchange_rates[ $currency ];
298
 
299
+ // exception - currencies_without_cents
300
+ if ( in_array( $currency, $this->multi_currency->get_currencies_without_cents() ) ) {
301
+ $amount = $this->round_up( $amount );
302
+ }
303
 
304
+ } else {
305
+ $amount = 0;
306
+ }
307
 
308
+ }
309
 
310
+ return $amount;
311
 
312
+ }
313
 
314
+ public function apply_rounding_rules( $price, $currency = false ) {
315
 
316
+ if ( is_null( $this->woocommerce_wpml ) ) {
317
+ global $woocommerce_wpml;
318
+ $this->woocommerce_wpml = $woocommerce_wpml;
319
+ }
320
 
321
+ if ( ! $currency ) {
322
+ $currency = $this->multi_currency->get_client_currency();
323
+ }
324
 
325
+ $currency_options = $this->woocommerce_wpml->settings['currency_options'][ $currency ];
326
 
327
+ if ( $currency_options['rounding'] != 'disabled' ) {
328
 
329
+ if ( $currency_options['rounding_increment'] > 1 ) {
330
+ $price = $price / $currency_options['rounding_increment'];
331
+ }
332
 
333
+ switch ( $currency_options['rounding'] ) {
334
+ case 'up':
335
+ $rounded_price = ceil( $price );
336
+ break;
337
+ case 'down':
338
+ $rounded_price = floor( $price );
339
+ break;
340
+ case 'nearest':
341
+ $rounded_price = $this->round_up( $price );
342
+ break;
343
+ }
344
 
345
+ if ( $rounded_price > 0 ) {
346
+ $price = $rounded_price;
347
+ }
348
 
349
+ if ( $currency_options['rounding_increment'] > 1 ) {
350
+ $price = $price * $currency_options['rounding_increment'];
351
+ }
352
 
353
+ if ( $currency_options['auto_subtract'] && $currency_options['auto_subtract'] < $price ) {
354
+ $price = $price - $currency_options['auto_subtract'];
355
+ }
356
 
357
+ } else {
358
 
359
+ // Use configured number of decimals
360
+ $price = floor( $price * pow( 10, $currency_options['num_decimals'] ) + 0.0001 ) / pow( 10, $currency_options['num_decimals'] );
361
 
362
+ }
363
 
364
 
365
+ return apply_filters( 'wcml_rounded_price', $price, $currency );
366
 
367
+ }
368
 
369
  /**
370
  * The PHP 5.2 compatible equivalent to "round($amount, 0, PHP_ROUND_HALF_UP)"
371
+ *
372
  * @param int $amount
373
+ *
374
  * @return int
375
  *
376
  */
377
+ private function round_up( $amount ) {
378
+ if ( $amount - floor( $amount ) < 0.5 ) {
379
+ $amount = floor( $amount );
380
+ } else {
381
+ $amount = ceil( $amount );
382
+ }
383
+
384
+ return $amount;
385
+ }
386
+
387
+ /*
388
+ * Converts the price from the default currency to the given currency and applies the format
389
+ */
390
+ public function formatted_price( $amount, $currency = false ) {
391
+
392
+ if ( $currency === false ) {
393
+ $currency = $this->multi_currency->get_client_currency();
394
+ }
395
+
396
+ $amount = $this->raw_price_filter( $amount, $currency );
397
+
398
+ $currency_details = $this->woocommerce_wpml->multi_currency->get_currency_details_by_code( $currency );
399
+
400
+ switch ( $currency_details['position'] ) {
401
+ case 'left' :
402
+ $format = '%1$s%2$s';
403
+ break;
404
+ case 'right' :
405
+ $format = '%2$s%1$s';
406
+ break;
407
+ case 'left_space' :
408
+ $format = '%1$s&nbsp;%2$s';
409
+ break;
410
+ case 'right_space' :
411
+ $format = '%2$s&nbsp;%1$s';
412
+ break;
413
+ }
414
+
415
+ $wc_price_args = array(
416
+
417
+ 'currency' => $currency,
418
+ 'decimal_separator' => $currency_details['decimal_sep'],
419
+ 'thousand_separator' => $currency_details['thousand_sep'],
420
+ 'decimals' => $currency_details['num_decimals'],
421
+ 'price_format' => $format,
422
+
423
+
424
+ );
425
+
426
+ $price = wc_price( $amount, $wc_price_args );
427
+
428
+ return $price;
429
+ }
430
+
431
+ // Exposed function
432
+ public function apply_currency_position( $price, $currency_code ) {
433
+
434
+ $currencies = $this->woocommerce_wpml->multi_currency->get_currencies();
435
+
436
+ if ( isset( $currencies[ $currency_code ]['position'] ) ) {
437
+ $position = $currencies[ $currency_code ]['position'];
438
+ } else {
439
+ remove_filter( 'option_woocommerce_currency_pos', array(
440
+ $this->woocommerce_wpml->multi_currency->prices,
441
+ 'filter_currency_position_option'
442
+ ) );
443
+ $position = get_option( 'woocommerce_currency_pos' );
444
+ add_filter( 'option_woocommerce_currency_pos', array(
445
+ $this->woocommerce_wpml->multi_currency->prices,
446
+ 'filter_currency_position_option'
447
+ ) );
448
+ }
449
+
450
+ switch ( $position ) {
451
+ case 'left':
452
+ $price = sprintf( '%s%s', get_woocommerce_currency_symbol( $currency_code ), $price );
453
+ break;
454
+ case 'right':
455
+ $price = sprintf( '%s%s', $price, get_woocommerce_currency_symbol( $currency_code ) );
456
+ break;
457
+ case 'left_space':
458
+ $price = sprintf( '%s %s', get_woocommerce_currency_symbol( $currency_code ), $price );
459
+ break;
460
+ case 'right_space':
461
+ $price = sprintf( '%s %s', $price, get_woocommerce_currency_symbol( $currency_code ) );
462
+ break;
463
+ }
464
+
465
+ return $price;
466
+ }
467
+
468
+ public function filter_price_woocommerce_paypal_args( $args ) {
469
+
470
+ foreach ( $args as $key => $value ) {
471
+ if ( substr( $key, 0, 7 ) == 'amount_' ) {
472
+
473
+ $currency_details = $this->woocommerce_wpml->multi_currency->get_currency_details_by_code( $args['currency_code'] );
474
+
475
+ $args[ $key ] = number_format( $value, $currency_details['num_decimals'], '.', '' );
476
+ }
477
+ }
478
+
479
+ return $args;
480
+ }
481
+
482
+ public function add_currency_to_variation_prices_hash( $data ) {
483
+
484
+ $data['currency'] = $this->multi_currency->get_client_currency();
485
+ $data['exchange_rates_hash'] = md5( json_encode( $this->multi_currency->get_exchange_rates() ) );
486
+
487
+ return $data;
488
+
489
+ }
490
+
491
+ public function filter_woocommerce_cart_contents_total( $cart_contents_total ) {
492
+ global $woocommerce;
493
+ remove_filter( 'woocommerce_cart_contents_total', array(
494
+ $this,
495
+ 'filter_woocommerce_cart_contents_total'
496
+ ), 100 );
497
+ $woocommerce->cart->calculate_totals();
498
+ $cart_contents_total = $woocommerce->cart->get_cart_total();
499
+ add_filter( 'woocommerce_cart_contents_total', array( $this, 'filter_woocommerce_cart_contents_total' ), 100 );
500
+
501
+ return $cart_contents_total;
502
+ }
503
+
504
+ public function filter_woocommerce_cart_subtotal( $cart_subtotal, $compound, $obj ) {
505
+ global $woocommerce;
506
+ remove_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal' ), 100, 3 );
507
+ if ( apply_filters( 'wcml_calculate_totals_exception', true ) ) {
508
+ $woocommerce->cart->calculate_totals();
509
+ }
510
+ $cart_subtotal = $woocommerce->cart->get_cart_subtotal( $compound );
511
+ add_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal' ), 100, 3 );
512
+
513
+ return $cart_subtotal;
514
+ }
515
+
516
+ public function filter_price_filter_results( $matched_products, $min, $max ) {
517
+ global $wpdb;
518
+
519
+ $current_currency = $this->multi_currency->get_client_currency();
520
+ if ( $current_currency != get_option( 'woocommerce_currency' ) ) {
521
+ $filtered_min = $this->unconvert_price_amount( $min, $current_currency );
522
+ $filtered_max = $this->unconvert_price_amount( $max, $current_currency );
523
+
524
+ $matched_products = $wpdb->get_results( $wpdb->prepare( "
525
+ SELECT DISTINCT ID, post_parent, post_type FROM $wpdb->posts
526
+ INNER JOIN $wpdb->postmeta ON ID = post_id
527
+ WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = 'publish' AND meta_key = %s AND meta_value BETWEEN %d AND %d
528
+ ", '_price', $filtered_min, $filtered_max ), OBJECT_K );
529
 
530
+ foreach ( $matched_products as $key => $matched_product ) {
531
+ $custom_price = get_post_meta( $matched_product->ID, '_price_' . $current_currency, true );
532
+ if ( $custom_price && ( $custom_price < $min || $custom_price > $max ) ) {
533
+ unset( $matched_products[ $key ] );
534
+ }
535
+ }
536
+ }
537
 
538
+ return $matched_products;
539
+ }
540
 
541
+ public function filter_price_filter_widget_amount( $amount ) {
542
 
543
+ $current_currency = $this->multi_currency->get_client_currency();
544
+ if ( $current_currency != get_option( 'woocommerce_currency' ) ) {
545
+ $amount = apply_filters( 'wcml_raw_price_amount', $amount );
546
+ }
547
 
548
+ return $amount;
 
 
 
 
 
549
 
550
+ }
 
551
 
552
+ private function check_admin_order_currency_code() {
553
+ global $pagenow;
 
 
 
 
 
 
554
 
555
+ $actions = array(
556
+ 'woocommerce_add_order_item',
557
+ 'woocommerce_save_order_items',
558
+ 'woocommerce_calc_line_taxes'
559
+ );
560
+ $is_ajax_order_action =
561
+ is_ajax() &&
562
+ (
563
+ (
564
+ isset( $_POST['action'] ) &&
565
+ in_array( $_POST['action'], $actions ) ||
566
+ (
567
+ isset( $_GET['action'] ) &&
568
+ $_GET['action'] == 'woocommerce_json_search_products_and_variations'
569
+ )
570
+ )
571
+ );
572
 
573
+ $is_shop_order_new = $pagenow == 'post-new.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'shop_order';
 
574
 
575
+ if ( ( $is_ajax_order_action || $is_shop_order_new ) && isset( $_COOKIE['_wcml_order_currency'] ) ) {
576
+ $currency_code = $_COOKIE['_wcml_order_currency'];
577
+ } elseif ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'shop_order' ) {
578
+ $currency_code = get_post_meta( $_GET['post'], '_order_currency', true );
579
+ } elseif ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'shop_order' && ! is_null( $this->orders_list_currency ) ) {
580
+ $currency_code = $this->orders_list_currency;
581
+ } elseif ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-reports' && isset( $_COOKIE['_wcml_reports_currency'] ) ) {
582
+ $currency_code = $_COOKIE['_wcml_reports_currency'];
583
+ } elseif ( isset( $_COOKIE['_wcml_dashboard_currency'] ) && is_admin() && ! defined( 'DOING_AJAX' ) && $pagenow == 'index.php' ) {
584
+ $currency_code = $_COOKIE['_wcml_dashboard_currency'];
585
+ } else {
586
+ $currency_code = $this->multi_currency->get_client_currency();
587
+ }
588
 
589
+ return apply_filters( 'wcml_filter_currency_position', $currency_code );
 
 
 
 
590
 
591
+ }
 
 
 
 
 
 
592
 
593
+ public function get_admin_order_currency_code() {
 
594
 
595
+ return $this->check_admin_order_currency_code();
596
 
597
+ }
 
 
 
598
 
599
+ public function save_order_currency_for_filter( $null, $object_id, $meta_key, $single ) {
600
 
601
+ if (
602
+ $meta_key == '_order_currency' &&
603
+ isset( $_GET['post_type'] ) &&
604
+ $_GET['post_type'] == 'shop_order' &&
605
+ ! isset( $_GET['post'] ) &&
606
+ get_post_type( $object_id ) == 'shop_order'
607
+ ) {
608
+ remove_filter( 'get_post_metadata', array( $this, 'save_order_currency_for_filter' ), 10, 4 );
609
+ $this->orders_list_currency = get_post_meta( $object_id, $meta_key, true );
610
+ add_filter( 'get_post_metadata', array( $this, 'save_order_currency_for_filter' ), 10, 4 );
611
+ }
612
 
613
+ return $null;
614
+ }
 
615
 
616
+ public function filter_currency_thousand_sep_option( $value ) {
 
 
 
 
 
 
 
 
 
 
 
 
617
 
618
+ $default_currency = $this->multi_currency->get_default_currency();
619
+ $currency_code = $this->check_admin_order_currency_code();
620
 
621
+ if ( $currency_code !== $default_currency && isset( $this->multi_currency->currencies[ $currency_code ]['thousand_sep'] ) ) {
622
+ $value = $this->multi_currency->currencies[ $currency_code ]['thousand_sep'];
623
+ }
 
 
 
 
 
 
 
 
 
 
624
 
625
+ return $value;
626
+ }
627
 
628
+ public function filter_currency_decimal_sep_option( $value ) {
629
 
630
+ $default_currency = $this->multi_currency->get_default_currency();
631
+ $currency_code = $this->check_admin_order_currency_code();
632
 
633
+ if ( $currency_code !== $default_currency && isset( $this->multi_currency->currencies[ $currency_code ]['decimal_sep'] ) ) {
634
+ $value = $this->multi_currency->currencies[ $currency_code ]['decimal_sep'];
635
 
636
+ }
637
 
638
+ return $value;
639
+ }
640
 
641
+ public function filter_currency_num_decimals_option( $value ) {
642
+ // no other way available (at the moment) to filter currency_num_decimals_option
643
+ $default_currency = $this->multi_currency->get_default_currency();
644
+
645
+ $db = debug_backtrace();
646
+ if (
647
+ isset( $db['8']['function'] ) && isset( $db['5']['function'] ) &&
648
+ $db['8']['function'] == 'calculate_shipping_for_package' && $db['5']['function'] == 'add_rate'
649
+ ||
650
+ isset( $db['7']['function'] ) && isset( $db['4']['function'] ) &&
651
+ $db['7']['function'] == 'calculate_shipping_for_package' && $db['4']['function'] == 'add_rate'
652
+ ) {
653
+ $currency_code = $default_currency;
654
+ } else {
655
+ $currency_code = $this->check_admin_order_currency_code();
656
+ }
657
+
658
+ if ( $currency_code !== $default_currency && isset( $this->multi_currency->currencies[ $currency_code ]['num_decimals'] ) ) {
659
+ $value = $this->multi_currency->currencies[ $currency_code ]['num_decimals'];
660
+ }
661
+
662
+ return $value;
663
+ }
664
+
665
+ public function filter_currency_position_option( $value ) {
666
+
667
+ $default_currency = $this->multi_currency->get_default_currency();
668
+ $currency_code = $this->get_admin_order_currency_code();
669
+
670
+ if ( $currency_code !== $default_currency &&
671
+ isset( $this->multi_currency->currencies[ $currency_code ]['position'] ) && get_option( 'woocommerce_currency' ) != $currency_code &&
672
+ in_array( $this->multi_currency->currencies[ $currency_code ]['position'], array(
673
+ 'left',
674
+ 'right',
675
+ 'left_space',
676
+ 'right_space'
677
+ ) )
678
+ ) {
679
+ $value = $this->multi_currency->currencies[ $currency_code ]['position'];
680
+ }
681
+
682
+ return $value;
683
+ }
684
+
685
+ public function filter_currency_num_decimals_in_cart( $cart ) {
686
+ $cart->dp = wc_get_price_decimals();
687
+ }
688
+
689
+ /*
690
+ * Limitation: If the default currency is configured to display more decimals than the other currencies,
691
+ * the prices in the secondary currencies would be approximated to the number of decimals that they have more.
692
+ */
693
+ public function price_in_specific_currency( $return, $price, $args ) {
694
+
695
+ if ( isset( $args['currency'] ) && $this->multi_currency->get_client_currency() != $args['currency'] ) {
696
+ remove_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
697
+ $this->multi_currency->set_client_currency( $args['currency'] );
698
+ $return = wc_price( $price, $args );
699
+ add_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
700
+ }
701
+
702
+ return $return;
703
+
704
+ }
705
+
706
+ public function filter_wc_price_args( $args ) {
707
+
708
+ if ( isset( $args['currency'] ) ) {
709
+
710
+ if ( isset( $this->multi_currency->currencies[ $args['currency'] ]['decimal_sep'] ) ) {
711
+ $args['decimal_separator'] = $this->multi_currency->currencies[ $args['currency'] ]['decimal_sep'];
712
+ }
713
+
714
+ if ( isset( $this->multi_currency->currencies[ $args['currency'] ]['thousand_sep'] ) ) {
715
+ $args['thousand_separator'] = $this->multi_currency->currencies[ $args['currency'] ]['thousand_sep'];
716
+ }
717
+
718
+ if ( isset( $this->multi_currency->currencies[ $args['currency'] ]['num_decimals'] ) ) {
719
+ $args['decimals'] = $this->multi_currency->currencies[ $args['currency'] ]['num_decimals'];
720
+ }
721
+
722
+ if ( isset( $this->multi_currency->currencies[ $args['currency'] ]['position'] ) ) {
723
+ $current_currency = $this->multi_currency->get_client_currency();
724
+ $this->multi_currency->set_client_currency( $args['currency'] );
725
+ $args['price_format'] = get_woocommerce_price_format();
726
+ $this->multi_currency->set_client_currency( $current_currency ); //restore
727
+ }
728
+
729
+ }
730
+
731
+ return $args;
732
+ }
733
 
734
+ /**
735
+ * @param float $price
736
+ * @param null|string $currency
737
+ *
738
+ * @return float
739
+ */
740
+ public function convert_raw_woocommerce_price( $price, $currency = null ) {
741
+ if ( null === $currency ) {
742
+ $currency = $this->multi_currency->get_client_currency();
743
+ }
744
 
745
+ return apply_filters( 'wcml_raw_price_amount', $price, $currency );
746
+ }
747
 
748
+ /**
749
+ * @param woocommerce_wpml $woocommerce_wpml
750
+ * @param string $currency
751
+ *
752
+ * @return string
753
+ */
754
+ public function get_cart_subtotal_in_given_currency( woocommerce_wpml $woocommerce_wpml, $currency ) {
755
+ $multi_currency = $woocommerce_wpml->multi_currency;
756
+ $client_currency = $multi_currency->get_client_currency();
757
+ $woocommerce_currency = get_option( 'woocommerce_currency' );
758
 
759
+ $multi_currency->set_client_currency( $currency );
760
 
761
+ if ( $client_currency === $woocommerce_currency ) {
762
+ $cart_object = $woocommerce_wpml->cart;
763
+ $cart_object->woocommerce_calculate_totals( WC()->cart, $currency );
764
 
765
+ add_filter( 'raw_woocommerce_price', array( $this, 'convert_raw_woocommerce_price' ) );
766
+ add_filter( 'woocommerce_currency', array( $multi_currency, 'get_client_currency' ) );
767
+ $cart_subtotal = WC()->cart->get_cart_subtotal();
768
+ remove_filter( 'raw_woocommerce_price', array( $this, 'convert_raw_woocommerce_price' ) );
769
+ remove_filter( 'woocommerce_currency', array( $multi_currency, 'get_client_currency' ) );
770
+ } else {
771
+ add_filter( 'woocommerce_product_get_price', array( $this, 'get_original_product_price' ), 10, 2 );
772
+ $cart_subtotal = WC()->cart->get_cart_subtotal();
773
+ remove_filter( 'woocommerce_product_get_price', array( $this, 'get_original_product_price' ), 10, 2 );
774
+ }
775
 
776
+ $multi_currency->set_client_currency( $client_currency );
777
 
778
+ return $cart_subtotal;
779
+ }
780
 
781
+ /**
782
+ * @param float $value
783
+ * @param WC_Product $product
784
+ *
785
+ * @return float
786
+ */
787
+ public function get_original_product_price( $value, $product ) {
788
+ return get_post_meta( $product->get_id(), '_price', 1 );
789
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790
 
791
  }
inc/currencies/class-wcml-multi-currency-reports.php CHANGED
@@ -22,7 +22,7 @@ class WCML_Multi_Currency_Reports {
22
  * @param wpdb $wpdb
23
  * @param WPML_WP_Cache $wpml_cache
24
  */
25
- public function __construct( woocommerce_wpml $woocommerce_wpml, Sitepress $sitepress, wpdb $wpdb, WPML_WP_Cache $wpml_cache = null ) {
26
 
27
  $this->woocommerce_wpml = $woocommerce_wpml;
28
  $this->sitepress = $sitepress;
@@ -213,7 +213,9 @@ class WCML_Multi_Currency_Reports {
213
  public function filter_dashboard_status_widget_sales_query( $query ) {
214
  $order_ids_list = $this->get_dashboard_currency_list_of_orders_ids();
215
 
216
- $query['where'] .= " AND posts.ID IN ( " . $order_ids_list . " ) ";
 
 
217
 
218
  return $query;
219
  }
@@ -236,7 +238,7 @@ class WCML_Multi_Currency_Reports {
236
  ", $currency
237
  )
238
  );
239
- $orders_ids = implode( ',', $order_ids_array );
240
 
241
  $this->wpml_cache->set( $cache_key, $orders_ids );
242
  }
22
  * @param wpdb $wpdb
23
  * @param WPML_WP_Cache $wpml_cache
24
  */
25
+ public function __construct( woocommerce_wpml $woocommerce_wpml, Sitepress $sitepress, wpdb $wpdb, $wpml_cache = null ) {
26
 
27
  $this->woocommerce_wpml = $woocommerce_wpml;
28
  $this->sitepress = $sitepress;
213
  public function filter_dashboard_status_widget_sales_query( $query ) {
214
  $order_ids_list = $this->get_dashboard_currency_list_of_orders_ids();
215
 
216
+ if( $order_ids_list ){
217
+ $query['where'] .= " AND posts.ID IN (" . $order_ids_list . ") ";
218
+ }
219
 
220
  return $query;
221
  }
238
  ", $currency
239
  )
240
  );
241
+ $orders_ids = wpml_prepare_in( $order_ids_array, '%d' );
242
 
243
  $this->wpml_cache->set( $cache_key, $orders_ids );
244
  }
inc/currencies/class-wcml-multi-currency-resources.php CHANGED
@@ -17,7 +17,7 @@ class WCML_Multi_Currency_Resources{
17
  self::$multi_currency = $multi_currency;
18
  self::$woocommerce_wpml = $woocommerce_wpml;
19
 
20
- if( !is_admin() && $pagenow != 'wp-login.php' && $woocommerce_wpml->cs_templates->get_active_templates() ){
21
  self::load_inline_js();
22
  }
23
 
17
  self::$multi_currency = $multi_currency;
18
  self::$woocommerce_wpml = $woocommerce_wpml;
19
 
20
+ if( !is_admin() && $pagenow != 'wp-login.php' && $woocommerce_wpml->cs_templates->get_active_templates( true ) ){
21
  self::load_inline_js();
22
  }
23
 
inc/currencies/class-wcml-multi-currency-shipping.php CHANGED
@@ -2,23 +2,32 @@
2
 
3
  class WCML_Multi_Currency_Shipping{
4
 
5
- /**
6
- * @var WCML_Multi_Currency
7
- */
8
  private $multi_currency;
 
 
 
 
9
 
10
- public function __construct( &$multi_currency ) {
11
- global $wpdb;
12
 
13
- $this->multi_currency =& $multi_currency;
 
 
 
 
 
14
 
15
  // shipping method cost settings
16
- if( version_compare( WC()->version, '2.6.0', '>=' ) ) {
17
- $rates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE method_id IN('flat_rate', 'local_pickup', 'free_shipping')" );
18
  foreach ( $rates as $method ) {
19
  $option_name = sprintf( 'woocommerce_%s_%d_settings', $method->method_id, $method->instance_id );
20
  add_filter( 'option_' . $option_name, array($this, 'convert_shipping_method_cost_settings') );
21
  }
 
 
 
22
  }
23
 
24
  // Used for table rate shipping compatibility class
@@ -27,28 +36,30 @@ class WCML_Multi_Currency_Shipping{
27
 
28
  add_filter( 'woocommerce_evaluate_shipping_cost_args', array( $this, 'woocommerce_evaluate_shipping_cost_args') );
29
 
30
- add_filter( 'woocommerce_shipping_packages', array( $this, 'convert_shipping_taxes'), 10 );
31
 
32
- add_filter( 'woocommerce_package_rates', array($this, 'convert_shipping_costs_in_package_rates'), 10, 2 );
 
33
 
34
- // Before WooCommerce 2.6
35
- if( version_compare( WC()->version, '2.6.0', '<' ) ){
36
- new WCML_Multi_Currency_Shipping_Legacy();
37
- }
38
 
 
39
 
40
- }
 
41
 
42
- public function convert_shipping_costs_in_package_rates( $rates, $package ){
 
43
 
44
- $client_currency = $this->multi_currency->get_client_currency();
45
- foreach( $rates as $rate_id => $rate ){
46
- if( isset( $rate->cost ) && $rate->cost ){
47
- $rate->cost = $this->multi_currency->prices->raw_price_filter( $rate->cost, $client_currency);
48
- }
49
- }
 
50
 
51
- return $rates;
52
  }
53
 
54
  public function convert_shipping_method_cost_settings( $settings ){
@@ -76,7 +87,7 @@ class WCML_Multi_Currency_Shipping{
76
  if(
77
  $settings['requires'] == 'min_amount' ||
78
  $settings['requires'] == 'either' ||
79
- $settings['requires'] == 'both' && $has_free_shipping_coupon
80
  ){
81
  $settings['min_amount'] = apply_filters( 'wcml_shipping_free_min_amount', $settings['min_amount'] );
82
  }
@@ -85,16 +96,14 @@ class WCML_Multi_Currency_Shipping{
85
  return $settings;
86
  }
87
 
88
- /**
89
- * @param $args
90
- * @param $sum
91
- * @param $method
92
- * @return array
93
- *
94
- * When using [cost] in the shipping class costs, we need to use the not-converted cart total
95
- * It will be converted as part of the total cost
96
- *
97
- */
98
  public function woocommerce_evaluate_shipping_cost_args( $args ){
99
 
100
  $args['cost'] = $this->multi_currency->prices->unconvert_price_amount( $args['cost'] );
@@ -104,14 +113,16 @@ class WCML_Multi_Currency_Shipping{
104
 
105
  public function convert_shipping_taxes( $packages ){
106
 
107
- foreach( $packages as $package_id => $package ){
108
- if( isset( $package['rates'] ) ){
109
- foreach( $package['rates'] as $rate_id => $rate ){
110
- $packages[$package_id]['rates'][$rate_id]->taxes =
111
- WC_Tax::calc_shipping_tax( $packages[$package_id]['rates'][$rate_id]->cost, WC_Tax::get_shipping_tax_rates() );
112
- }
113
- }
114
- }
 
 
115
 
116
  return $packages;
117
  }
2
 
3
  class WCML_Multi_Currency_Shipping{
4
 
5
+ /** @var WCML_Multi_Currency */
 
 
6
  private $multi_currency;
7
+ /** @var Sitepress */
8
+ private $sitepress;
9
+ /** @var wpdb */
10
+ private $wpdb;
11
 
12
+ public function __construct( WCML_Multi_Currency $multi_currency, Sitepress $sitepress, wpdb $wpdb ) {
 
13
 
14
+ $this->multi_currency = $multi_currency;
15
+ $this->sitepress = $sitepress;
16
+ $this->wpdb = $wpdb;
17
+ }
18
+
19
+ public function add_hooks(){
20
 
21
  // shipping method cost settings
22
+ if( $this->sitepress->get_wp_api()->version_compare( $this->sitepress->get_wp_api()->constant( 'WC_VERSION' ), '2.6.0', '>=' ) ) {
23
+ $rates = $this->wpdb->get_results( "SELECT * FROM {$this->wpdb->prefix}woocommerce_shipping_zone_methods WHERE method_id IN('flat_rate', 'local_pickup', 'free_shipping')" );
24
  foreach ( $rates as $method ) {
25
  $option_name = sprintf( 'woocommerce_%s_%d_settings', $method->method_id, $method->instance_id );
26
  add_filter( 'option_' . $option_name, array($this, 'convert_shipping_method_cost_settings') );
27
  }
28
+ }else{
29
+ // Before WooCommerce 2.6
30
+ new WCML_Multi_Currency_Shipping_Legacy();
31
  }
32
 
33
  // Used for table rate shipping compatibility class
36
 
37
  add_filter( 'woocommerce_evaluate_shipping_cost_args', array( $this, 'woocommerce_evaluate_shipping_cost_args') );
38
 
39
+ add_filter( 'woocommerce_shipping_packages', array( $this, 'convert_shipping_taxes') );
40
 
41
+ add_filter( 'woocommerce_package_rates', array($this, 'convert_shipping_costs_in_package_rates') );
42
+ }
43
 
44
+ public function convert_shipping_costs_in_package_rates( $rates ) {
 
 
 
45
 
46
+ $cache_group = 'converted_shipping_cost';
47
 
48
+ $client_currency = $this->multi_currency->get_client_currency();
49
+ foreach ( $rates as $rate_id => $rate ) {
50
 
51
+ $cache_key = $rate_id;
52
+ $cached_converted_shipping_cost = wp_cache_get( $cache_key, $cache_group );
53
 
54
+ if ( $cached_converted_shipping_cost ) {
55
+ $rate->cost = $cached_converted_shipping_cost;
56
+ } elseif ( isset( $rate->cost ) && $rate->cost ) {
57
+ $rate->cost = $this->multi_currency->prices->raw_price_filter( $rate->cost, $client_currency );
58
+ wp_cache_set( $cache_key, $rate->cost, $cache_group );
59
+ }
60
+ }
61
 
62
+ return $rates;
63
  }
64
 
65
  public function convert_shipping_method_cost_settings( $settings ){
87
  if(
88
  $settings['requires'] == 'min_amount' ||
89
  $settings['requires'] == 'either' ||
90
+ ( $settings['requires'] == 'both' && $has_free_shipping_coupon )
91
  ){
92
  $settings['min_amount'] = apply_filters( 'wcml_shipping_free_min_amount', $settings['min_amount'] );
93
  }
96
  return $settings;
97
  }
98
 
99
+ /**
100
+ * @param array $args
101
+ *
102
+ * When using [cost] in the shipping class costs, we need to use the not-converted cart total
103
+ * It will be converted as part of the total cost
104
+ *
105
+ * @return array
106
+ */
 
 
107
  public function woocommerce_evaluate_shipping_cost_args( $args ){
108
 
109
  $args['cost'] = $this->multi_currency->prices->unconvert_price_amount( $args['cost'] );
113
 
114
  public function convert_shipping_taxes( $packages ){
115
 
116
+ if( 'yes' === get_option( 'woocommerce_calc_taxes' ) ) {
117
+ foreach ( $packages as $package_id => $package ) {
118
+ if ( isset( $package['rates'] ) ) {
119
+ foreach ( $package['rates'] as $rate_id => $rate ) {
120
+ $packages[ $package_id ]['rates'][ $rate_id ]->taxes =
121
+ WC_Tax::calc_shipping_tax( $packages[ $package_id ]['rates'][ $rate_id ]->cost, WC_Tax::get_shipping_tax_rates() );
122
+ }
123
+ }
124
+ }
125
+ }
126
 
127
  return $packages;
128
  }
inc/currencies/class-wcml-multi-currency-table-rate-shipping.php CHANGED
@@ -8,29 +8,24 @@
8
 
9
  class WCML_Multi_Currency_Table_Rate_Shipping{
10
 
11
- public static function set_up(){
12
  // table rate shipping support
13
  if( defined('TABLE_RATE_SHIPPING_VERSION' ) && version_compare( TABLE_RATE_SHIPPING_VERSION, '3.0', '<' ) ){
14
- add_filter('woocommerce_table_rate_query_rates', array(__CLASS__, 'table_rate_shipping_rates'));
15
- add_filter('woocommerce_table_rate_instance_settings', array(__CLASS__, 'table_rate_instance_settings'));
16
  }
17
  }
18
 
19
- public static function table_rate_shipping_rates($rates){
20
-
21
  foreach($rates as $k => $rate){
22
-
23
  $rates[$k]->rate_cost = apply_filters('wcml_shipping_price_amount', $rates[$k]->rate_cost);
24
  $rates[$k]->rate_cost_per_item = apply_filters('wcml_shipping_price_amount', $rates[$k]->rate_cost_per_item);
25
  $rates[$k]->rate_cost_per_weight_unit = apply_filters('wcml_shipping_price_amount', $rates[$k]->rate_cost_per_weight_unit);
26
-
27
  }
28
-
29
  return $rates;
30
  }
31
 
32
- public static function table_rate_instance_settings($settings){
33
-
34
  if(is_numeric($settings['handling_fee'])){
35
  $settings['handling_fee'] = apply_filters('wcml_shipping_price_amount', $settings['handling_fee']);
36
  }
@@ -38,6 +33,4 @@ class WCML_Multi_Currency_Table_Rate_Shipping{
38
 
39
  return $settings;
40
  }
41
-
42
-
43
  }
8
 
9
  class WCML_Multi_Currency_Table_Rate_Shipping{
10
 
11
+ public function add_hooks(){
12
  // table rate shipping support
13
  if( defined('TABLE_RATE_SHIPPING_VERSION' ) && version_compare( TABLE_RATE_SHIPPING_VERSION, '3.0', '<' ) ){
14
+ add_filter('woocommerce_table_rate_query_rates', array($this, 'table_rate_shipping_rates'));
15
+ add_filter('woocommerce_table_rate_instance_settings', array($this, 'table_rate_instance_settings'));
16
  }
17
  }
18
 
19
+ public function table_rate_shipping_rates($rates){
 
20
  foreach($rates as $k => $rate){
 
21
  $rates[$k]->rate_cost = apply_filters('wcml_shipping_price_amount', $rates[$k]->rate_cost);
22
  $rates[$k]->rate_cost_per_item = apply_filters('wcml_shipping_price_amount', $rates[$k]->rate_cost_per_item);
23
  $rates[$k]->rate_cost_per_weight_unit = apply_filters('wcml_shipping_price_amount', $rates[$k]->rate_cost_per_weight_unit);
 
24
  }
 
25
  return $rates;
26
  }
27
 
28
+ public function table_rate_instance_settings($settings){
 
29
  if(is_numeric($settings['handling_fee'])){
30
  $settings['handling_fee'] = apply_filters('wcml_shipping_price_amount', $settings['handling_fee']);
31
  }
33
 
34
  return $settings;
35
  }
 
 
36
  }
inc/currencies/class-wcml-multi-currency.php CHANGED
@@ -100,10 +100,14 @@ class WCML_Multi_Currency{
100
 
101
  $this->load_filters = $this->_load_filters();
102
  $this->prices = new WCML_Multi_Currency_Prices( $this );
 
 
 
 
103
 
104
- if( $this->load_filters ) {
105
  $this->coupons = new WCML_Multi_Currency_Coupons();
106
- $this->shipping = new WCML_Multi_Currency_Shipping( $this );
 
107
  }
108
  $this->reports = new WCML_Multi_Currency_Reports( $woocommerce_wpml, $sitepress, $wpdb );
109
  $this->reports->add_hooks();
100
 
101
  $this->load_filters = $this->_load_filters();
102
  $this->prices = new WCML_Multi_Currency_Prices( $this );
103
+ $this->prices->add_hooks();
104
+ if( $this->load_filters ) {
105
+ $table_rate_shipping_multi_currency = new WCML_Multi_Currency_Table_Rate_Shipping();
106
+ $table_rate_shipping_multi_currency->add_hooks();
107
 
 
108
  $this->coupons = new WCML_Multi_Currency_Coupons();
109
+ $this->shipping = new WCML_Multi_Currency_Shipping( $this, $sitepress, $wpdb );
110
+ $this->shipping->add_hooks();
111
  }
112
  $this->reports = new WCML_Multi_Currency_Reports( $woocommerce_wpml, $sitepress, $wpdb );
113
  $this->reports->add_hooks();
inc/currencies/currency-switcher/class-wcml-currency-switcher-templates.php CHANGED
@@ -314,12 +314,12 @@ class WCML_Currency_Switcher_Templates {
314
  public function enqueue_template_resources( $templates = false ) {
315
 
316
  if( !$templates ){
317
- $templates = $this->get_active_templates();
318
  }
319
 
320
  $wcml_settings = $this->woocommerce_wpml->get_settings();
321
 
322
- foreach( $templates as $slug => $template ) {
323
 
324
  foreach ( $template->get_scripts() as $k => $url ) {
325
  wp_enqueue_script( $template->get_resource_handler( $k ), $url, array(), WCML_VERSION );
@@ -327,7 +327,6 @@ class WCML_Currency_Switcher_Templates {
327
 
328
  foreach ( $template->get_styles() as $k => $url ) {
329
  wp_enqueue_style( $template->get_resource_handler( $k ), $url, array(), WCML_VERSION );
330
-
331
  }
332
 
333
  if ( $template->has_styles() ) {
@@ -340,6 +339,11 @@ class WCML_Currency_Switcher_Templates {
340
  foreach( $wcml_settings[ 'currency_switchers' ] as $key => $switcher_data ){
341
 
342
  $switcher_template = $switcher_data['switcher_style'];
 
 
 
 
 
343
  $css = $this->get_color_picket_css( $key, $switcher_data );
344
  $template = $templates[ $switcher_template ];
345
 
@@ -354,7 +358,7 @@ class WCML_Currency_Switcher_Templates {
354
  if ( ! empty( $wcml_settings['currency_switcher_additional_css'] ) ) {
355
  $additional_css = $this->sanitize_css( $wcml_settings['currency_switcher_additional_css'] );
356
 
357
- if( $style_handler ){
358
  wp_add_inline_style( $style_handler, $additional_css );
359
  }else{
360
  echo $this->get_inline_style( 'currency_switcher', 'additional_css', $additional_css );
314
  public function enqueue_template_resources( $templates = false ) {
315
 
316
  if( !$templates ){
317
+ $templates = $this->get_active_templates( true );
318
  }
319
 
320
  $wcml_settings = $this->woocommerce_wpml->get_settings();
321
 
322
+ foreach ( $templates as $slug => $template ) {
323
 
324
  foreach ( $template->get_scripts() as $k => $url ) {
325
  wp_enqueue_script( $template->get_resource_handler( $k ), $url, array(), WCML_VERSION );
327
 
328
  foreach ( $template->get_styles() as $k => $url ) {
329
  wp_enqueue_style( $template->get_resource_handler( $k ), $url, array(), WCML_VERSION );
 
330
  }
331
 
332
  if ( $template->has_styles() ) {
339
  foreach( $wcml_settings[ 'currency_switchers' ] as $key => $switcher_data ){
340
 
341
  $switcher_template = $switcher_data['switcher_style'];
342
+
343
+ if ( ! isset( $templates[ $switcher_template ] ) ) {
344
+ continue;
345
+ }
346
+
347
  $css = $this->get_color_picket_css( $key, $switcher_data );
348
  $template = $templates[ $switcher_template ];
349
 
358
  if ( ! empty( $wcml_settings['currency_switcher_additional_css'] ) ) {
359
  $additional_css = $this->sanitize_css( $wcml_settings['currency_switcher_additional_css'] );
360
 
361
+ if( !empty( $style_handler ) ){
362
  wp_add_inline_style( $style_handler, $additional_css );
363
  }else{
364
  echo $this->get_inline_style( 'currency_switcher', 'additional_css', $additional_css );
inc/rest-api-support/class-wcml-rest-api-support-v1.php CHANGED
@@ -36,6 +36,7 @@ class WCML_REST_API_Support_V1{
36
  add_action( 'woocommerce_rest_update_product', array( $this, 'set_product_custom_prices' ), 10, 2 );
37
 
38
  add_action( 'woocommerce_rest_prepare_product', array( $this, 'copy_product_custom_fields' ), 10 , 3 );
 
39
 
40
  // Orders
41
  add_filter( 'woocommerce_rest_shop_order_query', array( $this, 'filter_orders_by_language' ), 20, 2 );
@@ -279,6 +280,17 @@ class WCML_REST_API_Support_V1{
279
 
280
  }
281
 
 
 
 
 
 
 
 
 
 
 
 
282
  /**
283
  * @param WP_REST_Response $response
284
  * @param mixed $object
36
  add_action( 'woocommerce_rest_update_product', array( $this, 'set_product_custom_prices' ), 10, 2 );
37
 
38
  add_action( 'woocommerce_rest_prepare_product', array( $this, 'copy_product_custom_fields' ), 10 , 3 );
39
+ add_action( 'woocommerce_rest_insert_product', array( $this, 'copy_custom_fields_from_original' ), 10, 1 );
40
 
41
  // Orders
42
  add_filter( 'woocommerce_rest_shop_order_query', array( $this, 'filter_orders_by_language' ), 20, 2 );
280
 
281
  }
282
 
283
+ /**
284
+ * @param WP_Post $post
285
+ */
286
+ public function copy_custom_fields_from_original( $post ){
287
+ $original_post_id = $this->sitepress->get_original_element_id_filter('', $post->ID, 'post_product' );
288
+
289
+ if( $original_post_id !== $post->ID ){
290
+ $this->sitepress->copy_custom_fields( $original_post_id, $post->ID );
291
+ }
292
+ }
293
+
294
  /**
295
  * @param WP_REST_Response $response
296
  * @param mixed $object
inc/rest-api-support/class-wcml-rest-api-support.php CHANGED
@@ -16,7 +16,7 @@ class WCML_REST_API_Support{
16
  * Adding hooks
17
  */
18
  public function initialize(){
19
-
20
  $this->prevent_default_lang_url_redirect();
21
 
22
  add_action( 'rest_api_init', array( $this, 'set_language_for_request' ) );
@@ -29,12 +29,15 @@ class WCML_REST_API_Support{
29
  add_filter( 'woocommerce_rest_product_query', array( $this, 'filter_products_query' ), 10, 2 );
30
  add_action( 'woocommerce_rest_insert_product_object', array( $this, 'set_product_language' ), 10, 2 );
31
  add_action( 'woocommerce_rest_insert_product_object', array( $this, 'set_product_custom_prices' ), 10, 2 );
 
 
32
  add_action( 'woocommerce_rest_prepare_product_object', array( $this, 'copy_product_custom_fields' ), 10 , 3 );
33
 
34
  // Orders
35
  add_filter( 'woocommerce_rest_shop_order_object_query', array( $this, 'filter_orders_by_language' ), 20, 2 );
36
  add_action( 'woocommerce_rest_prepare_shop_order_object', array( $this, 'filter_order_items_by_language'), 10, 3 );
37
  add_action( 'woocommerce_rest_insert_shop_order_object' , array( $this, 'set_order_language' ), 10, 2 );
 
38
 
39
  // Terms
40
  add_action( 'woocommerce_rest_product_cat_query', array($this, 'filter_terms_query' ), 10, 2 );
@@ -322,6 +325,17 @@ class WCML_REST_API_Support{
322
 
323
  }
324
 
 
 
 
 
 
 
 
 
 
 
 
325
  /**
326
  * @param WP_REST_Response $response
327
  * @param mixed $object
@@ -434,6 +448,22 @@ class WCML_REST_API_Support{
434
 
435
  }
436
 
437
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
 
439
  }
16
  * Adding hooks
17
  */
18
  public function initialize(){
19
+
20
  $this->prevent_default_lang_url_redirect();
21
 
22
  add_action( 'rest_api_init', array( $this, 'set_language_for_request' ) );
29
  add_filter( 'woocommerce_rest_product_query', array( $this, 'filter_products_query' ), 10, 2 );
30
  add_action( 'woocommerce_rest_insert_product_object', array( $this, 'set_product_language' ), 10, 2 );
31
  add_action( 'woocommerce_rest_insert_product_object', array( $this, 'set_product_custom_prices' ), 10, 2 );
32
+ add_action( 'woocommerce_rest_insert_product_object', array( $this, 'copy_custom_fields_from_original' ), 10, 1 );
33
+
34
  add_action( 'woocommerce_rest_prepare_product_object', array( $this, 'copy_product_custom_fields' ), 10 , 3 );
35
 
36
  // Orders
37
  add_filter( 'woocommerce_rest_shop_order_object_query', array( $this, 'filter_orders_by_language' ), 20, 2 );
38
  add_action( 'woocommerce_rest_prepare_shop_order_object', array( $this, 'filter_order_items_by_language'), 10, 3 );
39
  add_action( 'woocommerce_rest_insert_shop_order_object' , array( $this, 'set_order_language' ), 10, 2 );
40
+ add_action( 'woocommerce_rest_insert_shop_order_object' , array( $this, 'set_order_currency' ), 10, 2 );
41
 
42
  // Terms
43
  add_action( 'woocommerce_rest_product_cat_query', array($this, 'filter_terms_query' ), 10, 2 );
325
 
326
  }
327
 
328
+ /**
329
+ * @param WC_Product $product
330
+ */
331
+ public function copy_custom_fields_from_original( WC_Product $product ){
332
+ $original_post_id = $this->sitepress->get_original_element_id_filter('', $product->get_id(), 'post_product' );
333
+
334
+ if( $original_post_id !== $product->get_id() ){
335
+ $this->sitepress->copy_custom_fields( $original_post_id, $product->get_id() );
336
+ }
337
+ }
338
+
339
  /**
340
  * @param WP_REST_Response $response
341
  * @param mixed $object
448
 
449
  }
450
 
451
+ /**
452
+ * @param WC_Order $order
453
+ * @param WP_REST_Request $request
454
+ *
455
+ * @throws WC_REST_Exception
456
+ */
457
+ public function set_order_currency( $order, $request ) {
458
+ $data = $request->get_params();
459
+ if ( isset( $data['currency'] ) ) {
460
+ $order_id = $order->get_id();
461
+ $currencies = get_woocommerce_currencies();
462
+ if ( ! isset( $currencies[ $data['currency'] ] ) ) {
463
+ throw new WC_REST_Exception( '404', sprintf( __( 'Invalid currency parameter: %s' ), $data['currency'] ), '404' );
464
+ }
465
+ update_post_meta( $order_id, '_order_currency', $data['currency'] );
466
+ }
467
+ }
468
 
469
  }
inc/template-classes/class-wcml-products-ui.php CHANGED
@@ -416,7 +416,7 @@ class WCML_Products_UI extends WPML_Templates_Factory {
416
  $sql .= " AND p.post_status = %s ";
417
  $prepare_arg[] = $product_status;
418
  }else{
419
- $sql .= " AND p.post_status NOT IN ('trash','auto-draft','inherit') ";
420
  }
421
 
422
  if($category){
@@ -424,52 +424,57 @@ class WCML_Products_UI extends WPML_Templates_Factory {
424
  $prepare_arg[] = $category;
425
  }
426
 
427
- if(in_array($translation_status,array('not','need_update','in_progress','complete'))){
428
  $sql .= " AND (";
429
- switch($translation_status){
430
  case 'not':
431
- foreach($this->sitepress->get_active_languages() as $lang){
432
- if($lang['code'] == $slang) continue;
433
- $tbl_alias_suffix = str_replace('-','_',$lang['code']);
434
- $sql .= sprintf( "( p.ID iN (
435
- SELECT iclt_orig.element_id
436
- FROM {$wpdb->prefix}icl_translations iclt_orig
437
- LEFT JOIN {$wpdb->prefix}icl_translations iclt_%s
438
- ON iclt_%s.trid= iclt_orig.trid AND
439
- iclt_%s.language_code='%s'
440
- WHERE iclt_orig.source_language_code IS NULL AND
441
- iclt_%s.element_id IS NULL AND
442
- iclt_%s.element_type IN ('post_product', 'post_product_variation')
443
- )
444
- ) OR ",
445
- esc_sql( $tbl_alias_suffix ), esc_sql( $tbl_alias_suffix ), esc_sql( $tbl_alias_suffix ),
446
- esc_sql( $lang['code'] ), esc_sql( $tbl_alias_suffix ), esc_sql( $tbl_alias_suffix )
447
- );
448
- }
449
  break;
450
  case ( $translation_status == 'need_update' || $translation_status == 'not' ):
451
- foreach($this->sitepress->get_active_languages() as $lang){
452
- if($lang['code'] == $slang) continue;
453
- $tbl_alias_suffix = str_replace('-','_',$lang['code']);
454
- $sql .= "( iclts_{$tbl_alias_suffix}.needs_update = 1 ) OR\n";
 
 
455
  }
456
  break;
457
  case 'in_progress':
458
- foreach($this->sitepress->get_active_languages() as $lang){
459
- if($lang['code'] == $slang) continue;
460
- $tbl_alias_suffix = str_replace('-','_',$lang['code']);
461
- $sql .= "( iclts_{$tbl_alias_suffix}.status = ".ICL_TM_IN_PROGRESS.") OR\n";
 
 
462
  }
463
  break;
464
  case 'complete':
465
- foreach($this->sitepress->get_active_languages() as $lang){
466
- if($lang['code'] == $slang) continue;
467
- $tbl_alias_suffix = str_replace('-','_',$lang['code']);
468
- $sql .= "( (iclts_{$tbl_alias_suffix}.status = ".ICL_TM_COMPLETE." OR iclts_{$tbl_alias_suffix}.status = ".ICL_TM_DUPLICATE.") AND iclts_{$tbl_alias_suffix}.needs_update = 0 ) OR\n";
 
 
469
  }
470
  break;
471
  }
472
- $sql = substr($sql, 0, -3);
473
  $sql .= " ) ";
474
  }
475
 
416
  $sql .= " AND p.post_status = %s ";
417
  $prepare_arg[] = $product_status;
418
  }else{
419
+ $sql .= " AND p.post_status NOT IN ( 'trash','auto-draft','inherit' ) ";
420
  }
421
 
422
  if($category){
424
  $prepare_arg[] = $category;
425
  }
426
 
427
+ if ( in_array( $translation_status, array( 'not', 'need_update', 'in_progress', 'complete' ) ) ) {
428
  $sql .= " AND (";
429
+ switch ( $translation_status ) {
430
  case 'not':
431
+ $sql .= $wpdb->prepare( " t.trid IN ( SELECT trid FROM {$wpdb->prefix}icl_translations iclt
432
+ LEFT OUTER JOIN {$wpdb->prefix}icl_translation_status tls ON iclt.translation_id = tls.translation_id
433
+ WHERE
434
+ element_type = 'post_product'
435
+ AND (
436
+ tls.status IN (0)
437
+ OR tls.status IS NULL
438
+ AND (
439
+ SELECT
440
+ COUNT(trid)
441
+ FROM
442
+ {$wpdb->prefix}icl_translations
443
+ WHERE
444
+ trid = t.trid
445
+ ) < %d
446
+ )
447
+ ) OR\n", count( $this->sitepress->get_active_languages() ) );
 
448
  break;
449
  case ( $translation_status == 'need_update' || $translation_status == 'not' ):
450
+ foreach ( $this->sitepress->get_active_languages() as $lang ) {
451
+ if ( $lang['code'] == $slang ) {
452
+ continue;
453
+ }
454
+ $tbl_alias_suffix = str_replace( '-', '_', $lang['code'] );
455
+ $sql .= "( iclts_{$tbl_alias_suffix}.needs_update = 1 ) OR\n";
456
  }
457
  break;
458
  case 'in_progress':
459
+ foreach ( $this->sitepress->get_active_languages() as $lang ) {
460
+ if ( $lang['code'] == $slang ) {
461
+ continue;
462
+ }
463
+ $tbl_alias_suffix = str_replace( '-', '_', $lang['code'] );
464
+ $sql .= "( iclts_{$tbl_alias_suffix}.status = " . ICL_TM_IN_PROGRESS . " OR iclts_{$tbl_alias_suffix}.status = " . ICL_TM_WAITING_FOR_TRANSLATOR . ") OR\n";
465
  }
466
  break;
467
  case 'complete':
468
+ foreach ( $this->sitepress->get_active_languages() as $lang ) {
469
+ if ( $lang['code'] == $slang ) {
470
+ continue;
471
+ }
472
+ $tbl_alias_suffix = str_replace( '-', '_', $lang['code'] );
473
+ $sql .= "( (iclts_{$tbl_alias_suffix}.status = " . ICL_TM_COMPLETE . " OR iclts_{$tbl_alias_suffix}.status = " . ICL_TM_DUPLICATE . ") AND iclts_{$tbl_alias_suffix}.needs_update = 0 ) OR\n";
474
  }
475
  break;
476
  }
477
+ $sql = substr( $sql, 0, - 3 );
478
  $sql .= " ) ";
479
  }
480
 
inc/template-classes/currency-switcher/class-wcml-currency-switcher-template.php CHANGED
@@ -53,22 +53,14 @@ class WCML_Currency_Switcher_Template extends WPML_Templates_Factory {
53
  }
54
 
55
  public function get_formatted_price( $currency, $format ){
56
-
57
  $wc_currencies = get_woocommerce_currencies();
58
- if( preg_match( '#%subtotal%#', $format ) ){ // include cart total
59
- $cart_object =& $this->woocommerce_wpml->cart;
60
- }
61
  $wcml_settings = $this->woocommerce_wpml->get_settings();
62
- $multi_currency =& $this->woocommerce_wpml->multi_currency;
63
- $client_currency = $multi_currency->get_client_currency();
64
 
65
  if( preg_match( '#%subtotal%#', $format ) ) { // include cart total
66
  if( !is_admin() ){
67
-
68
- $multi_currency->set_client_currency( $currency );
69
- $cart_object->woocommerce_calculate_totals( WC()->cart, $currency );
70
- $cart_subtotal = WC()->cart->get_cart_subtotal();
71
-
72
  }else{
73
  switch( $wcml_settings['currency_options'][$currency]['position'] ){
74
  case 'left' :
@@ -107,10 +99,6 @@ class WCML_Currency_Switcher_Template extends WPML_Templates_Factory {
107
 
108
  ), $format );
109
 
110
- if( preg_match( '#%subtotal%#', $format ) && !is_admin() ) { // include cart total
111
- $multi_currency->set_client_currency( $client_currency );
112
- }
113
-
114
  return $currency_format;
115
  }
116
 
53
  }
54
 
55
  public function get_formatted_price( $currency, $format ){
 
56
  $wc_currencies = get_woocommerce_currencies();
57
+
 
 
58
  $wcml_settings = $this->woocommerce_wpml->get_settings();
59
+ $multi_currency = $this->woocommerce_wpml->multi_currency;
 
60
 
61
  if( preg_match( '#%subtotal%#', $format ) ) { // include cart total
62
  if( !is_admin() ){
63
+ $cart_subtotal = $multi_currency->prices->get_cart_subtotal_in_given_currency( $this->woocommerce_wpml, $currency );
 
 
 
 
64
  }else{
65
  switch( $wcml_settings['currency_options'][$currency]['position'] ){
66
  case 'left' :
99
 
100
  ), $format );
101
 
 
 
 
 
102
  return $currency_format;
103
  }
104
 
inc/translation-editor/class-wcml-downloadable-products.php CHANGED
@@ -2,19 +2,23 @@
2
 
3
  class WCML_Downloadable_Products{
4
 
 
5
  private $woocommerce_wpml;
 
6
  private $sitepress;
7
 
8
  /**
9
  * WCML_Downloadable_Products constructor.
10
  *
11
  * @param woocommerce_wpml $woocommerce_wpml
12
- * @param SitePress $sitepress
13
  */
14
- public function __construct( &$woocommerce_wpml, &$sitepress ) {
15
- $this->woocommerce_wpml = &$woocommerce_wpml;
16
- $this->sitepress = &$sitepress;
 
17
 
 
18
  //downloadable files custom
19
  add_action( 'woocommerce_product_options_downloads', array( $this, 'product_options_downloads_custom_option' ) );
20
  add_action( 'woocommerce_variation_options_download', array( $this, 'product_options_downloads_custom_option' ), 10, 3 );
@@ -30,16 +34,20 @@ class WCML_Downloadable_Products{
30
 
31
  $product_id = false;
32
  $is_variation = false;
33
- if( $pagenow === 'post.php' && isset( $_GET['post'] ) ){
34
  $product_id = $_GET['post'];
35
  }elseif( isset( $_POST['product_id'] ) ){
36
  $product_id = $_POST['product_id'];
37
  }
38
 
39
- if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['source_lang'] ) )
40
- || ( get_post_type( $product_id ) !== 'product' || ! $this->woocommerce_wpml->products->is_original_product( $product_id ) )
41
- ){
42
- return;
 
 
 
 
43
  }
44
 
45
  $this->load_custom_files_js_css();
@@ -55,8 +63,13 @@ class WCML_Downloadable_Products{
55
  }
56
 
57
  public function load_custom_files_js_css(){
58
- wp_register_style( 'wpml-wcml-files', WCML_PLUGIN_URL . '/res/css/wcml-files.css', null, WCML_VERSION );
59
- wp_register_script( 'wcml-scripts-files', WCML_PLUGIN_URL . '/res/js/files' . WCML_JS_MIN . '.js', array( 'jquery' ), WCML_VERSION );
 
 
 
 
 
60
 
61
  wp_enqueue_style('wpml-wcml-files');
62
  wp_enqueue_script('wcml-scripts-files');
2
 
3
  class WCML_Downloadable_Products{
4
 
5
+ /** @var woocommerce_wpml */
6
  private $woocommerce_wpml;
7
+ /** @var Sitepress */
8
  private $sitepress;
9
 
10
  /**
11
  * WCML_Downloadable_Products constructor.
12
  *
13
  * @param woocommerce_wpml $woocommerce_wpml
14
+ * @param Sitepress $sitepress
15
  */
16
+ public function __construct( woocommerce_wpml $woocommerce_wpml, Sitepress $sitepress ) {
17
+ $this->woocommerce_wpml = $woocommerce_wpml;
18
+ $this->sitepress = $sitepress;
19
+ }
20
 
21
+ public function add_hooks(){
22
  //downloadable files custom
23
  add_action( 'woocommerce_product_options_downloads', array( $this, 'product_options_downloads_custom_option' ) );
24
  add_action( 'woocommerce_variation_options_download', array( $this, 'product_options_downloads_custom_option' ), 10, 3 );
34
 
35
  $product_id = false;
36
  $is_variation = false;
37
+ if( 'post.php' === $pagenow && isset( $_GET['post'] ) ){
38
  $product_id = $_GET['post'];
39
  }elseif( isset( $_POST['product_id'] ) ){
40
  $product_id = $_POST['product_id'];
41
  }
42
 
43
+ $native_editor_translation_product_page = isset( $_GET['post_type'] ) && 'product' === $_GET['post_type'] && isset( $_GET['source_lang'] );
44
+ if ( $native_editor_translation_product_page) {
45
+ return false;
46
+ }
47
+
48
+ $is_not_original_product = $product_id && ( 'product' !== get_post_type( $product_id ) || ! $this->woocommerce_wpml->products->is_original_product( $product_id ) );
49
+ if ( $is_not_original_product) {
50
+ return false;
51
  }
52
 
53
  $this->load_custom_files_js_css();
63
  }
64
 
65
  public function load_custom_files_js_css(){
66
+
67
+ $wcml_plugin_url = $this->sitepress->get_wp_api()->constant( 'WCML_PLUGIN_URL' );
68
+ $wcml_version = $this->sitepress->get_wp_api()->constant( 'WCML_VERSION' );
69
+ $wcml_js_min = $this->sitepress->get_wp_api()->constant( 'WCML_JS_MIN' );
70
+
71
+ wp_register_style( 'wpml-wcml-files', $wcml_plugin_url . '/res/css/wcml-files.css', null, $wcml_version );
72
+ wp_register_script( 'wcml-scripts-files', $wcml_plugin_url . '/res/js/files' . $wcml_js_min . '.js', array( 'jquery' ), $wcml_version );
73
 
74
  wp_enqueue_style('wpml-wcml-files');
75
  wp_enqueue_script('wcml-scripts-files');
inc/translation-editor/class-wcml-editor-ui-product-job.php CHANGED
@@ -35,7 +35,7 @@ class WCML_Editor_UI_Product_Job extends WPML_Editor_UI_Job {
35
  '_min_variation_regular_price', '_max_variation_regular_price',
36
  '_min_variation_sale_price', '_max_variation_sale_price','_downloadable_files' );
37
 
38
- $this->not_display_custom_fields_for_product = array( '_upsell_ids', '_crosssell_ids','_downloadable_files' );
39
 
40
  $this->job_details = $job_details;
41
  $this->product = wc_get_product( $job_details[ 'job_id' ] );
@@ -218,7 +218,7 @@ class WCML_Editor_UI_Product_Job extends WPML_Editor_UI_Job {
218
  }
219
  }
220
 
221
- if( $this->product->is_downloadable() ){
222
  $is_variable = false;
223
  if( $this->woocommerce_wpml->products->is_variable_product( $this->product_id ) ){
224
  $files_data = $this->get_files_for_variations();
35
  '_min_variation_regular_price', '_max_variation_regular_price',
36
  '_min_variation_sale_price', '_max_variation_sale_price','_downloadable_files' );
37
 
38
+ $this->not_display_custom_fields_for_product = array( '_upsell_ids', '_crosssell_ids', '_children', '_downloadable_files' );
39
 
40
  $this->job_details = $job_details;
41
  $this->product = wc_get_product( $job_details[ 'job_id' ] );
218
  }
219
  }
220
 
221
+ if( $this->woocommerce_wpml->products->is_downloadable_product( $this->product ) ){
222
  $is_variable = false;
223
  if( $this->woocommerce_wpml->products->is_variable_product( $this->product_id ) ){
224
  $files_data = $this->get_files_for_variations();
inc/translation-editor/class-wcml-synchronize-product-data.php CHANGED
@@ -36,12 +36,6 @@ class WCML_Synchronize_Product_Data{
36
 
37
  add_filter( 'icl_make_duplicate', array( $this, 'icl_make_duplicate'), 110, 4 );
38
 
39
- if ( $this->sitepress->get_wp_api()->version_compare( $this->sitepress->get_wp_api()->constant( 'WC_VERSION' ), '3.0.0', '<' ) ) {
40
- add_action('woocommerce_duplicate_product', array($this, 'woocommerce_duplicate_product'), 10, 2);
41
- }else{
42
- add_action( 'woocommerce_product_duplicate', array( $this, 'woocommerce_duplicate_product' ), 10, 2 );
43
- }
44
-
45
  //quick & bulk edit
46
  add_action( 'woocommerce_product_quick_edit_save', array( $this, 'woocommerce_product_quick_edit_save' ) );
47
  add_action( 'woocommerce_product_bulk_edit_save', array( $this, 'woocommerce_product_quick_edit_save' ) );
@@ -247,7 +241,22 @@ class WCML_Synchronize_Product_Data{
247
  }
248
 
249
  public function sync_linked_products( $product_id, $translated_product_id, $lang ){
250
- //sync up-sells
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  $original_up_sells = maybe_unserialize( get_post_meta( $product_id, '_upsell_ids', true ) );
252
  $trnsl_up_sells = array();
253
  if( $original_up_sells ){
@@ -256,7 +265,11 @@ class WCML_Synchronize_Product_Data{
256
  }
257
  }
258
  update_post_meta( $translated_product_id, '_upsell_ids', $trnsl_up_sells );
259
- //sync cross-sells
 
 
 
 
260
  $original_cross_sells = maybe_unserialize( get_post_meta( $product_id, '_crosssell_ids', true ) );
261
  $trnsl_cross_sells = array();
262
  if( $original_cross_sells )
@@ -264,15 +277,20 @@ class WCML_Synchronize_Product_Data{
264
  $trnsl_cross_sells[] = apply_filters( 'translate_object_id', $original_cross_sell_product, get_post_type( $original_cross_sell_product ), false, $lang );
265
  }
266
  update_post_meta( $translated_product_id, '_crosssell_ids', $trnsl_cross_sells );
267
- // refresh parent-children transients (e.g. this child goes to private or draft)
268
- $translated_product_parent_id = wp_get_post_parent_id( $translated_product_id );
269
- if ( $translated_product_parent_id ) {
270
- delete_transient( 'wc_product_children_' . $translated_product_parent_id );
271
- delete_transient( '_transient_wc_product_children_ids_' . $translated_product_parent_id );
272
- }
273
  }
274
 
 
275
 
 
 
 
 
 
 
 
 
 
276
 
277
  public function sync_product_stocks_reduce( $order ){
278
  return $this->sync_product_stocks( $order, 'reduce' );
@@ -564,79 +582,6 @@ class WCML_Synchronize_Product_Data{
564
  return $array;
565
  }
566
 
567
-
568
- public function woocommerce_duplicate_product( $new_id, $post ){
569
- $duplicated_products = array();
570
-
571
- //duplicate original first
572
- $trid = $this->sitepress->get_element_trid( $post->ID, 'post_' . $post->post_type );
573
- $orig_id = $this->sitepress->get_original_element_id_by_trid( $trid );
574
- $orig_lang = $this->woocommerce_wpml->products->get_original_product_language( $post->ID );
575
-
576
- $wc_admin = new WC_Admin_Duplicate_Product();
577
-
578
- if( $orig_id == $post->ID ){
579
- $this->sitepress->set_element_language_details( $new_id, 'post_' . $post->post_type, false, $orig_lang );
580
- $new_trid = $this->sitepress->get_element_trid( $new_id, 'post_' . $post->post_type );
581
- $new_orig_id = $new_id;
582
- }else{
583
- $post_to_duplicate = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM {$this->wpdb->posts} WHERE ID=%d", $orig_id ) );
584
- if ( ! empty( $post_to_duplicate ) ) {
585
- $new_orig_id = $wc_admin->duplicate_product( $post_to_duplicate );
586
- do_action( 'wcml_after_duplicate_product' , $new_id, $post_to_duplicate );
587
- $this->sitepress->set_element_language_details( $new_orig_id, 'post_' . $post->post_type, false, $orig_lang );
588
- $new_trid = $this->sitepress->get_element_trid( $new_orig_id, 'post_' . $post->post_type );
589
- if( get_post_meta( $orig_id, '_icl_lang_duplicate_of' ) ){
590
- update_post_meta( $new_id, '_icl_lang_duplicate_of', $new_orig_id );
591
- }
592
- $this->sitepress->set_element_language_details( $new_id, 'post_' . $post->post_type, $new_trid, $this->sitepress->get_current_language() );
593
- }
594
- }
595
-
596
- // Set language info for variations
597
- if ( $children_products = get_children( 'post_parent=' . $new_orig_id . '&post_type=product_variation' ) ) {
598
- foreach ( $children_products as $child ) {
599
- $this->sitepress->set_element_language_details( $child->ID, 'post_product_variation', false, $orig_lang );
600
- }
601
- }
602
-
603
- $translations = $this->sitepress->get_element_translations( $trid, 'post_' . $post->post_type );
604
- $duplicated_products[ 'translations' ] = array();
605
- if( $translations ){
606
- foreach( $translations as $translation ){
607
- if( !$translation->original && $translation->element_id != $post->ID ){
608
- $post_to_duplicate = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM {$this->wpdb->posts} WHERE ID=%d", $translation->element_id ) );
609
-
610
- if( ! empty( $post_to_duplicate ) ) {
611
- $new_id = $wc_admin->duplicate_product( $post_to_duplicate );
612
- $new_id_obj = get_post( $new_id );
613
- $new_slug = wp_unique_post_slug( sanitize_title( $new_id_obj->post_title ), $new_id, $post_to_duplicate->post_status, $post_to_duplicate->post_type, $new_id_obj->post_parent );
614
-
615
- $this->wpdb->update(
616
- $this->wpdb->posts,
617
- array(
618
- 'post_name' => $new_slug,
619
- 'post_status' => 'draft'
620
- ),
621
- array( 'ID' => $new_id )
622
- );
623
-
624
- do_action( 'wcml_after_duplicate_product' , $new_id, $post_to_duplicate );
625
- $this->sitepress->set_element_language_details( $new_id, 'post_' . $post->post_type, $new_trid, $translation->language_code );
626
- if( get_post_meta( $translation->element_id, '_icl_lang_duplicate_of' ) ){
627
- update_post_meta( $new_id, '_icl_lang_duplicate_of', $new_orig_id );
628
- }
629
- $duplicated_products[ 'translations' ][] = $new_id;
630
- }
631
- }
632
- }
633
- }
634
-
635
- $duplicated_products[ 'original' ] = $new_orig_id;
636
-
637
- return $duplicated_products;
638
- }
639
-
640
  public function icl_connect_translations_action(){
641
  if( isset( $_POST[ 'icl_ajx_action' ] ) && $_POST[ 'icl_ajx_action' ] == 'connect_translations' ) {
642
  $new_trid = $_POST['new_trid'];
36
 
37
  add_filter( 'icl_make_duplicate', array( $this, 'icl_make_duplicate'), 110, 4 );
38
 
 
 
 
 
 
 
39
  //quick & bulk edit
40
  add_action( 'woocommerce_product_quick_edit_save', array( $this, 'woocommerce_product_quick_edit_save' ) );
41
  add_action( 'woocommerce_product_bulk_edit_save', array( $this, 'woocommerce_product_quick_edit_save' ) );
241
  }
242
 
243
  public function sync_linked_products( $product_id, $translated_product_id, $lang ){
244
+
245
+ $this->sync_up_sells_products( $product_id, $translated_product_id, $lang );
246
+ $this->sync_cross_sells_products( $product_id, $translated_product_id, $lang );
247
+ $this->sync_grouped_products( $product_id, $translated_product_id, $lang );
248
+
249
+ // refresh parent-children transients (e.g. this child goes to private or draft)
250
+ $translated_product_parent_id = wp_get_post_parent_id( $translated_product_id );
251
+ if ( $translated_product_parent_id ) {
252
+ delete_transient( 'wc_product_children_' . $translated_product_parent_id );
253
+ delete_transient( '_transient_wc_product_children_ids_' . $translated_product_parent_id );
254
+ }
255
+
256
+ }
257
+
258
+ public function sync_up_sells_products( $product_id, $translated_product_id, $lang ){
259
+
260
  $original_up_sells = maybe_unserialize( get_post_meta( $product_id, '_upsell_ids', true ) );
261
  $trnsl_up_sells = array();
262
  if( $original_up_sells ){
265
  }
266
  }
267
  update_post_meta( $translated_product_id, '_upsell_ids', $trnsl_up_sells );
268
+
269
+ }
270
+
271
+ public function sync_cross_sells_products( $product_id, $translated_product_id, $lang ){
272
+
273
  $original_cross_sells = maybe_unserialize( get_post_meta( $product_id, '_crosssell_ids', true ) );
274
  $trnsl_cross_sells = array();
275
  if( $original_cross_sells )
277
  $trnsl_cross_sells[] = apply_filters( 'translate_object_id', $original_cross_sell_product, get_post_type( $original_cross_sell_product ), false, $lang );
278
  }
279
  update_post_meta( $translated_product_id, '_crosssell_ids', $trnsl_cross_sells );
280
+
 
 
 
 
 
281
  }
282
 
283
+ public function sync_grouped_products( $product_id, $translated_product_id, $lang ){
284
 
285
+ $original_children = maybe_unserialize( get_post_meta( $product_id, '_children', true ) );
286
+ $translated_children = array();
287
+ if( $original_children )
288
+ foreach( $original_children as $original_children_product ){
289
+ $translated_children[] = apply_filters( 'translate_object_id', $original_children_product, get_post_type( $original_children_product ), false, $lang );
290
+ }
291
+ update_post_meta( $translated_product_id, '_children', $translated_children );
292
+
293
+ }
294
 
295
  public function sync_product_stocks_reduce( $order ){
296
  return $this->sync_product_stocks( $order, 'reduce' );
582
  return $array;
583
  }
584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  public function icl_connect_translations_action(){
586
  if( isset( $_POST[ 'icl_ajx_action' ] ) && $_POST[ 'icl_ajx_action' ] == 'connect_translations' ) {
587
  $new_trid = $_POST['new_trid'];
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WooCommerce Multilingual - run WooCommerce with WPML ===
2
- Contributors: AmirHelzer, sergey.r, mihaimihai, EduardMaghakyan
3
  Donate link: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
4
  Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
5
  License: GPLv2
6
  Requires at least: 3.9
7
  Tested up to: 4.8.1
8
- Stable tag: 4.2.0.1
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -142,14 +142,42 @@ WooCommerce Multilingual is compatible with all major WooCommerce extensions. We
142
 
143
  == Changelog ==
144
 
145
- = 4.2.0.1 =
146
- * Updated the embedded Installer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  = 4.2.0 =
149
  * Added the ability to translate Sensei question custom post types
150
- * Added the ability to translate serialized custom fields in the Translation Editor
151
  * Payment method title not displaying in emails Mollie Payment's payment processor compatibility
152
  * Show an admin notice for environments in which switching the language or currency on the front end, could corrupt the cart contents
 
153
  * When selecting the currencylayer provider for automatic exchange rate, the API KEY filter was not visible
154
  * The multi-currency component made the admin dashboard page loading unnecessarily slow
155
  * Variations with custom attributes could not be duplicated as translations
@@ -164,7 +192,7 @@ WooCommerce Multilingual is compatible with all major WooCommerce extensions. We
164
  * It was not possible to use the clear cart feature with enabled WPML Ajax cookies only
165
  * WooCommerce Product Bundles: Bundled items filtering by variation was not synced with translations
166
  * Bookings max availability value was changing after adding bookable product to cart few times
167
- * In some cases the option to prompt for a confirmation about resetting the cart when switching the language was not working
168
  * The variation names were, sometimes, displayed in the wrong language in the orders, on the back-end
169
 
170
  = 4.1.4 =
1
  === WooCommerce Multilingual - run WooCommerce with WPML ===
2
+ Contributors: AmirHelzer, sergey.r, mihaimihai, EduardMaghakyan, andrewp-2
3
  Donate link: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
4
  Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
5
  License: GPLv2
6
  Requires at least: 3.9
7
  Tested up to: 4.8.1
8
+ Stable tag: 4.2.1
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
142
 
143
  == Changelog ==
144
 
145
+ = 4.2.1 =
146
+ * Added the ability to set custom currencies for orders created via the REST API
147
+ * Filter by translation status displays wrong results on WooCommerce Multilingual products list page
148
+ * Prices were not synced when creating a product translation via REST API
149
+ * Missing Woocommerce pages were created in default language
150
+ * Fatal error while custom call not active currency switcher template
151
+ * Duplicating from WooCommerce resulted in losing language data for the original product
152
+ * Coupon with category restriction removed when switching language on cart page
153
+ * PHP errors were shown on the admin dashboard when no orders existed and displaying errors was on
154
+ * Fixed issue with problem in downloadable products in secondary language with different domain per language is enabled
155
+ * A fatal error (undefiend get_current_screen) was occurring in some conditions on the WP admin side
156
+ * Cart widget shows wrong product names
157
+ * Fixed a small but that defualt currency template didn't load correctly in new installation
158
+ * Added compatibility for grouped products
159
+ * Fixed an issue in lost password endpoint when edit it
160
+ * The cart total in a secondary currencies could have been added a previously removed shipping tax
161
+ * Post translation won't save when Product Bundles plugin is active
162
+ * Fixed comp issue with dynamic price with translated variations don't work in secondary language
163
+ * Cart reset button point to wrong language
164
+ * Fix issue with not matched translated labels because of special characters
165
+ * Fixed an issue when sold individually is enabled and different variations of the same product
166
+ * Fix the ability to set custom download files in downloadable variable products with WCML product editor
167
+ * Fixed small issue in separate file control in downloadable variation product
168
+ * Fix a bug where Variations were made downloadable after their description was updated.
169
+ * Checkout Field Editor compatibility fix
170
+ * Fixed issue with displaying custom prices in Bundles Products
171
+ * Add filter for 'woocommerce_subscriptions_product_price'
172
+ * Fixed compatibi;ity issue with coupos not applied correctly in a subscription product
173
+ * The `wcml_raw_price_amount` filter could not be used to convert to a different currency than the current user currency
174
 
175
  = 4.2.0 =
176
  * Added the ability to translate Sensei question custom post types
177
+ * Added the ability to translate serialized custom fields with in the Translation Editor
178
  * Payment method title not displaying in emails Mollie Payment's payment processor compatibility
179
  * Show an admin notice for environments in which switching the language or currency on the front end, could corrupt the cart contents
180
+ * Changing the order of the variations was disconnecting them from their translations
181
  * When selecting the currencylayer provider for automatic exchange rate, the API KEY filter was not visible
182
  * The multi-currency component made the admin dashboard page loading unnecessarily slow
183
  * Variations with custom attributes could not be duplicated as translations
192
  * It was not possible to use the clear cart feature with enabled WPML Ajax cookies only
193
  * WooCommerce Product Bundles: Bundled items filtering by variation was not synced with translations
194
  * Bookings max availability value was changing after adding bookable product to cart few times
195
+ * In some cases the the option to prompt for a confirmation about resetting the cart when switching the language was not working
196
  * The variation names were, sometimes, displayed in the wrong language in the orders, on the back-end
197
 
198
  = 4.1.4 =
res/js/cart_widget.js CHANGED
@@ -3,6 +3,9 @@ jQuery(document).ready(function($){
3
  var cart_hash_key = wc_cart_fragments_params.ajax_url.toString() + '-wc_cart_hash';
4
 
5
  if (sessionStorage.getItem( 'woocommerce_cart_hash' ) == '' || actions.is_lang_switched == 1 || actions.is_currency_switched == 1 ) {
 
 
 
6
  sessionStorage.removeItem( 'wc_fragments' );
7
  }
8
  } catch(err){
3
  var cart_hash_key = wc_cart_fragments_params.ajax_url.toString() + '-wc_cart_hash';
4
 
5
  if (sessionStorage.getItem( 'woocommerce_cart_hash' ) == '' || actions.is_lang_switched == 1 || actions.is_currency_switched == 1 ) {
6
+ sessionStorage.removeItem( actions.cart_fragment );
7
+
8
+ //backward compatibility for WC < 3.0
9
  sessionStorage.removeItem( 'wc_fragments' );
10
  }
11
  } catch(err){
res/js/cart_widget.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){try{wc_cart_fragments_params.ajax_url.toString();""!=sessionStorage.getItem("woocommerce_cart_hash")&&1!=actions.is_lang_switched&&1!=actions.is_currency_switched||sessionStorage.removeItem("wc_fragments")}catch(a){}});
1
+ jQuery(document).ready(function($){try{var cart_hash_key=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash";if(sessionStorage.getItem("woocommerce_cart_hash")==""||actions.is_lang_switched==1||actions.is_currency_switched==1){sessionStorage.removeItem(actions.cart_fragment);sessionStorage.removeItem("wc_fragments")}}catch(err){}});
res/js/lock_fields.js CHANGED
@@ -15,6 +15,7 @@ jQuery(document).ready(function($){
15
  'parent_id',
16
  'crosssell_ids',
17
  'upsell_ids',
 
18
  'product_shipping_class'
19
  ];
20
 
@@ -184,7 +185,9 @@ var wcml_lock_variation_fields = function( file_path_sync ){
184
  for (i = 0; i < var_checkboxes.length; i++) {
185
  jQuery('input[name^="variable'+var_checkboxes[i]+'"]').each(function(){
186
  jQuery(this).attr('disabled','disabled');
187
- jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr('name')+'" value="'+jQuery(this).val()+'" />');
 
 
188
  jQuery(this).after(jQuery('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
189
  });
190
  }
15
  'parent_id',
16
  'crosssell_ids',
17
  'upsell_ids',
18
+ 'grouped_products',
19
  'product_shipping_class'
20
  ];
21
 
185
  for (i = 0; i < var_checkboxes.length; i++) {
186
  jQuery('input[name^="variable'+var_checkboxes[i]+'"]').each(function(){
187
  jQuery(this).attr('disabled','disabled');
188
+ if( jQuery(this).prop('checked') ){
189
+ jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr('name')+'" value="'+jQuery(this).val()+'" />');
190
+ }
191
  jQuery(this).after(jQuery('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
192
  });
193
  }
res/js/lock_fields.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){var b,c=["_virtual","_downloadable","product-type","_backorders","_manage_stock","_stock","_stock_status","_sold_individually","comment_status","_tax_status","_tax_class","parent_id","crosssell_ids","upsell_ids","product_shipping_class"];for(1==unlock_fields.file_paths&&c.push("_download_type"),c=c.concat(non_standard_fields.ids),a(".wcml_prod_hidden_notice").prependTo("#woocommerce-product-data"),b=0;b<c.length;b++)a("#"+c[b]).attr("disabled","disabled"),a("#"+c[b]).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show());var d=["add_variation","link_all_variations","attribute_taxonomy","save_attributes","add_new_attribute","product_attributes .remove_row","add_attribute","select_all_attributes","select_no_attributes","edit-visibility"];for(d=d.concat(non_standard_fields.classes),1==unlock_fields.file_paths&&(d.push("upload_file_button"),d.push("insert"),d.push("delete"),a(".upload_file_button,.insert,.delete").bind({click:function(a){return!1}})),b=0;b<d.length;b++)a("."+d[b]).attr("disabled","disabled"),a("."+d[b]).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show());a("#visibility .edit-visibility span").bind({click:function(a){return!1}}),a(".remove_variation").each(function(){a(this).attr("disabled","disabled"),a(this).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","right"))});var e=["_width","_height","_sku","_length","_weight","product_length","_regular_price","_sale_price","_sale_price_dates_from","_sale_price_dates_to"];for(1==unlock_fields.file_paths&&(e.push("_download_limit"),e.push("_download_expiry"),e.push("_wc_file_names[]"),e.push("_wc_file_urls[]")),e=e.concat(non_standard_fields.input_names),1==unlock_fields.menu_order&&e.push("menu_order"),b=0;b<e.length;b++)a('input[name="'+e[b]+'"]').attr("readonly","readonly"),a(".dimensions_field span.wrap").css("float","left"),"_width"!=e[b]&&"_height"!=e[b]&&"_length"!=e[b]||(a('input[name="'+e[b]+'"]').css("margin-right",0),a('input[name="'+e[b]+'"]').css("float","none"),a('input[name="'+e[b]+'"]').css("width","29%")),"_sale_price_dates_to"==e[b]?a('input[name="'+e[b]+'"]').after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").css("float","left").show()):a('input[name="'+e[b]+'"]').after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show());a('#product_attributes td textarea,#product_attributes input[type="text"]').each(function(){a(this).attr("readonly","readonly"),a(this).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}),a('#product_attributes input[type="checkbox"]').each(function(){a(this).attr("disabled","disabled"),a(this).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}),a('form#post input[type="submit"]').click(function(){for(b=0;b<c.length;b++)a("#"+c[b]).removeAttr("disabled");a('.woocommerce_variation select,#variable_product_options .toolbar select,.woocommerce_variation input[type="checkbox"],#product_attributes input[type="checkbox"]').each(function(){a(this).removeAttr("disabled")})})});var wcml_lock_variation_fields=function(a){var b=jQuery(".woocommerce_variation>h3 select").attr("disabled");if(void 0===b||b===!1){jQuery(".woocommerce_variation>h3 select, #variable_product_options .toolbar select, .show_if_variation_manage_stock select").each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var c=0,d=["_width","_height","_sku","_length","_weight","product_length","_regular_price","_sale_price","_sale_price_dates_from","_sale_price_dates_to","_stock","_download_limit","_download_expiry"];for(c=0;c<d.length;c++)jQuery('input[name^="variable'+d[c]+'"]').each(function(){jQuery(this).attr("readonly","readonly"),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var e=["_enabled","_is_downloadable","_is_virtual","_manage_stock"];for(c=0;c<e.length;c++)jQuery('input[name^="variable'+e[c]+'"]').each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var f=["_stock_status","_shipping_class","_tax_class"];for(c=0;c<f.length;c++)jQuery('select[name^="variable'+f[c]+'"]').each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});if(a)for(var g in a)1==a[g]&&(jQuery('input[name^="_wc_variation_file_names['+g+']"]').each(function(){jQuery(this).attr("readonly","readonly")}),jQuery('input[name^="_wc_variation_file_urls['+g+']"]').each(function(){jQuery(this).attr("readonly","readonly"),jQuery(this).closest("tr").find(".upload_file_button").attr("disabled","disabled"),jQuery(this).closest("tr").find(".delete").attr("disabled","disabled"),jQuery(this).closest("tr").find(".delete").after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","right"))}),jQuery('input[name^="_wc_variation_file_urls['+g+']"]').closest("table").find(".insert").attr("disabled","disabled"),jQuery('input[name^="_wc_variation_file_urls['+g+']"]').closest("table").find(".insert").after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","left")))}};
1
+ jQuery(document).ready(function(a){var b,c=["_virtual","_downloadable","product-type","_backorders","_manage_stock","_stock","_stock_status","_sold_individually","comment_status","_tax_status","_tax_class","parent_id","crosssell_ids","upsell_ids","grouped_products","product_shipping_class"];for(1==unlock_fields.file_paths&&c.push("_download_type"),c=c.concat(non_standard_fields.ids),a(".wcml_prod_hidden_notice").prependTo("#woocommerce-product-data"),b=0;b<c.length;b++)a("#"+c[b]).attr("disabled","disabled"),a("#"+c[b]).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show());var d=["add_variation","link_all_variations","attribute_taxonomy","save_attributes","add_new_attribute","product_attributes .remove_row","add_attribute","select_all_attributes","select_no_attributes","edit-visibility"];for(d=d.concat(non_standard_fields.classes),1==unlock_fields.file_paths&&(d.push("upload_file_button"),d.push("insert"),d.push("delete"),a(".upload_file_button,.insert,.delete").bind({click:function(a){return!1}})),b=0;b<d.length;b++)a("."+d[b]).attr("disabled","disabled"),a("."+d[b]).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show());a("#visibility .edit-visibility span").bind({click:function(a){return!1}}),a(".remove_variation").each(function(){a(this).attr("disabled","disabled"),a(this).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","right"))});var e=["_width","_height","_sku","_length","_weight","product_length","_regular_price","_sale_price","_sale_price_dates_from","_sale_price_dates_to"];for(1==unlock_fields.file_paths&&(e.push("_download_limit"),e.push("_download_expiry"),e.push("_wc_file_names[]"),e.push("_wc_file_urls[]")),e=e.concat(non_standard_fields.input_names),1==unlock_fields.menu_order&&e.push("menu_order"),b=0;b<e.length;b++)a('input[name="'+e[b]+'"]').attr("readonly","readonly"),a(".dimensions_field span.wrap").css("float","left"),("_width"==e[b]||"_height"==e[b]||"_length"==e[b])&&(a('input[name="'+e[b]+'"]').css("margin-right",0),a('input[name="'+e[b]+'"]').css("float","none"),a('input[name="'+e[b]+'"]').css("width","29%")),"_sale_price_dates_to"==e[b]?a('input[name="'+e[b]+'"]').after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").css("float","left").show()):a('input[name="'+e[b]+'"]').after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show());a('#product_attributes td textarea,#product_attributes input[type="text"]').each(function(){a(this).attr("readonly","readonly"),a(this).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}),a('#product_attributes input[type="checkbox"]').each(function(){a(this).attr("disabled","disabled"),a(this).after(a(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}),a('form#post input[type="submit"]').click(function(){for(b=0;b<c.length;b++)a("#"+c[b]).removeAttr("disabled");a('.woocommerce_variation select,#variable_product_options .toolbar select,.woocommerce_variation input[type="checkbox"],#product_attributes input[type="checkbox"]').each(function(){a(this).removeAttr("disabled")})})});var wcml_lock_variation_fields=function(a){var b=jQuery(".woocommerce_variation>h3 select").attr("disabled");if("undefined"==typeof b||b===!1){jQuery(".woocommerce_variation>h3 select, #variable_product_options .toolbar select, .show_if_variation_manage_stock select").each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var c=0,d=["_width","_height","_sku","_length","_weight","product_length","_regular_price","_sale_price","_sale_price_dates_from","_sale_price_dates_to","_stock","_download_limit","_download_expiry"];for(c=0;c<d.length;c++)jQuery('input[name^="variable'+d[c]+'"]').each(function(){jQuery(this).attr("readonly","readonly"),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var e=["_enabled","_is_downloadable","_is_virtual","_manage_stock"];for(c=0;c<e.length;c++)jQuery('input[name^="variable'+e[c]+'"]').each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var f=["_stock_status","_shipping_class","_tax_class"];for(c=0;c<f.length;c++)jQuery('select[name^="variable'+f[c]+'"]').each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});if(a)for(var g in a)1==a[g]&&(jQuery('input[name^="_wc_variation_file_names['+g+']"]').each(function(){jQuery(this).attr("readonly","readonly")}),jQuery('input[name^="_wc_variation_file_urls['+g+']"]').each(function(){jQuery(this).attr("readonly","readonly"),jQuery(this).closest("tr").find(".upload_file_button").attr("disabled","disabled"),jQuery(this).closest("tr").find(".delete").attr("disabled","disabled"),jQuery(this).closest("tr").find(".delete").after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","right"))}),jQuery('input[name^="_wc_variation_file_urls['+g+']"]').closest("table").find(".insert").attr("disabled","disabled"),jQuery('input[name^="_wc_variation_file_urls['+g+']"]').closest("table").find(".insert").after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","left")))}};
res/js/lock_fields.min.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(g){var f,j=["_virtual","_downloadable","product-type","_backorders","_manage_stock","_stock","_stock_status","_sold_individually","comment_status","_tax_status","_tax_class","parent_id","crosssell_ids","upsell_ids","product_shipping_class"];for(1==unlock_fields.file_paths&&j.push("_download_type"),j=j.concat(non_standard_fields.ids),g(".wcml_prod_hidden_notice").prependTo("#woocommerce-product-data"),f=0;f<j.length;f++){g("#"+j[f]).attr("disabled","disabled"),g("#"+j[f]).after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}var i=["add_variation","link_all_variations","attribute_taxonomy","save_attributes","add_new_attribute","product_attributes .remove_row","add_attribute","select_all_attributes","select_no_attributes","edit-visibility"];for(i=i.concat(non_standard_fields.classes),1==unlock_fields.file_paths&&(i.push("upload_file_button"),i.push("insert"),i.push("delete"),g(".upload_file_button,.insert,.delete").bind({click:function(b){return !1}})),f=0;f<i.length;f++){g("."+i[f]).attr("disabled","disabled"),g("."+i[f]).after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}g("#visibility .edit-visibility span").bind({click:function(b){return !1}}),g(".remove_variation").each(function(){g(this).attr("disabled","disabled"),g(this).after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","right"))});var h=["_width","_height","_sku","_length","_weight","product_length","_regular_price","_sale_price","_sale_price_dates_from","_sale_price_dates_to"];for(1==unlock_fields.file_paths&&(h.push("_download_limit"),h.push("_download_expiry"),h.push("_wc_file_names[]"),h.push("_wc_file_urls[]")),h=h.concat(non_standard_fields.input_names),1==unlock_fields.menu_order&&h.push("menu_order"),f=0;f<h.length;f++){g('input[name="'+h[f]+'"]').attr("readonly","readonly"),g(".dimensions_field span.wrap").css("float","left"),"_width"!=h[f]&&"_height"!=h[f]&&"_length"!=h[f]||(g('input[name="'+h[f]+'"]').css("margin-right",0),g('input[name="'+h[f]+'"]').css("float","none"),g('input[name="'+h[f]+'"]').css("width","29%")),"_sale_price_dates_to"==h[f]?g('input[name="'+h[f]+'"]').after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").css("float","left").show()):g('input[name="'+h[f]+'"]').after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}g('#product_attributes td textarea,#product_attributes input[type="text"]').each(function(){g(this).attr("readonly","readonly"),g(this).after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}),g('#product_attributes input[type="checkbox"]').each(function(){g(this).attr("disabled","disabled"),g(this).after(g(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())}),g('form#post input[type="submit"]').click(function(){for(f=0;f<j.length;f++){g("#"+j[f]).removeAttr("disabled")}g('.woocommerce_variation select,#variable_product_options .toolbar select,.woocommerce_variation input[type="checkbox"],#product_attributes input[type="checkbox"]').each(function(){g(this).removeAttr("disabled")})})});var wcml_lock_variation_fields=function(i){var h=jQuery(".woocommerce_variation>h3 select").attr("disabled");if(void 0===h||h===!1){jQuery(".woocommerce_variation>h3 select, #variable_product_options .toolbar select, .show_if_variation_manage_stock select").each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())});var n=0,m=["_width","_height","_sku","_length","_weight","product_length","_regular_price","_sale_price","_sale_price_dates_from","_sale_price_dates_to","_stock","_download_limit","_download_expiry"];for(n=0;n<m.length;n++){jQuery('input[name^="variable'+m[n]+'"]').each(function(){jQuery(this).attr("readonly","readonly"),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())})}var l=["_enabled","_is_downloadable","_is_virtual","_manage_stock"];for(n=0;n<l.length;n++){jQuery('input[name^="variable'+l[n]+'"]').each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())})}var k=["_stock_status","_shipping_class","_tax_class"];for(n=0;n<k.length;n++){jQuery('select[name^="variable'+k[n]+'"]').each(function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parent().append('<input type="hidden" name="'+jQuery(this).attr("name")+'" value="'+jQuery(this).val()+'" />'),jQuery(this).after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show())})}if(i){for(var j in i){1==i[j]&&(jQuery('input[name^="_wc_variation_file_names['+j+']"]').each(function(){jQuery(this).attr("readonly","readonly")}),jQuery('input[name^="_wc_variation_file_urls['+j+']"]').each(function(){jQuery(this).attr("readonly","readonly"),jQuery(this).closest("tr").find(".upload_file_button").attr("disabled","disabled"),jQuery(this).closest("tr").find(".delete").attr("disabled","disabled"),jQuery(this).closest("tr").find(".delete").after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","right"))}),jQuery('input[name^="_wc_variation_file_urls['+j+']"]').closest("table").find(".insert").attr("disabled","disabled"),jQuery('input[name^="_wc_variation_file_urls['+j+']"]').closest("table").find(".insert").after(jQuery(".wcml_lock_img").clone().removeClass("wcml_lock_img").show().css("float","left")))}}}};
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit1e950a3498b2b701753514ff78661529::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit28144429d23dfe0e4a31fd11d74fe167::getLoader();
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInit47e7b07dd515551e87cf2efd9df54aba::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit2aba23511a80a5fa71d9e6ab2604461b::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -87,176 +87,6 @@ return array(
87
  'Composer\\Installers\\YawikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/YawikInstaller.php',
88
  'Composer\\Installers\\ZendInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZendInstaller.php',
89
  'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
90
- 'Twig\\Cache\\CacheInterface' => $vendorDir . '/twig/twig/src/Cache/CacheInterface.php',
91
- 'Twig\\Cache\\FilesystemCache' => $vendorDir . '/twig/twig/src/Cache/FilesystemCache.php',
92
- 'Twig\\Cache\\NullCache' => $vendorDir . '/twig/twig/src/Cache/NullCache.php',
93
- 'Twig\\Compiler' => $vendorDir . '/twig/twig/src/Compiler.php',
94
- 'Twig\\Environment' => $vendorDir . '/twig/twig/src/Environment.php',
95
- 'Twig\\Error\\Error' => $vendorDir . '/twig/twig/src/Error/Error.php',
96
- 'Twig\\Error\\LoaderError' => $vendorDir . '/twig/twig/src/Error/LoaderError.php',
97
- 'Twig\\Error\\RuntimeError' => $vendorDir . '/twig/twig/src/Error/RuntimeError.php',
98
- 'Twig\\Error\\SyntaxError' => $vendorDir . '/twig/twig/src/Error/SyntaxError.php',
99
- 'Twig\\ExpressionParser' => $vendorDir . '/twig/twig/src/ExpressionParser.php',
100
- 'Twig\\Extension\\AbstractExtension' => $vendorDir . '/twig/twig/src/Extension/AbstractExtension.php',
101
- 'Twig\\Extension\\CoreExtension' => $vendorDir . '/twig/twig/src/Extension/CoreExtension.php',
102
- 'Twig\\Extension\\DebugExtension' => $vendorDir . '/twig/twig/src/Extension/DebugExtension.php',
103
- 'Twig\\Extension\\EscaperExtension' => $vendorDir . '/twig/twig/src/Extension/EscaperExtension.php',
104
- 'Twig\\Extension\\ExtensionInterface' => $vendorDir . '/twig/twig/src/Extension/ExtensionInterface.php',
105
- 'Twig\\Extension\\GlobalsInterface' => $vendorDir . '/twig/twig/src/Extension/GlobalsInterface.php',
106
- 'Twig\\Extension\\InitRuntimeInterface' => $vendorDir . '/twig/twig/src/Extension/InitRuntimeInterface.php',
107
- 'Twig\\Extension\\OptimizerExtension' => $vendorDir . '/twig/twig/src/Extension/OptimizerExtension.php',
108
- 'Twig\\Extension\\ProfilerExtension' => $vendorDir . '/twig/twig/src/Extension/ProfilerExtension.php',
109
- 'Twig\\Extension\\SandboxExtension' => $vendorDir . '/twig/twig/src/Extension/SandboxExtension.php',
110
- 'Twig\\Extension\\StagingExtension' => $vendorDir . '/twig/twig/src/Extension/StagingExtension.php',
111
- 'Twig\\Extension\\StringLoaderExtension' => $vendorDir . '/twig/twig/src/Extension/StringLoaderExtension.php',
112
- 'Twig\\FileExtensionEscapingStrategy' => $vendorDir . '/twig/twig/src/FileExtensionEscapingStrategy.php',
113
- 'Twig\\Lexer' => $vendorDir . '/twig/twig/src/Lexer.php',
114
- 'Twig\\Loader\\ArrayLoader' => $vendorDir . '/twig/twig/src/Loader/ArrayLoader.php',
115
- 'Twig\\Loader\\ChainLoader' => $vendorDir . '/twig/twig/src/Loader/ChainLoader.php',
116
- 'Twig\\Loader\\ExistsLoaderInterface' => $vendorDir . '/twig/twig/src/Loader/ExistsLoaderInterface.php',
117
- 'Twig\\Loader\\FilesystemLoader' => $vendorDir . '/twig/twig/src/Loader/FilesystemLoader.php',
118
- 'Twig\\Loader\\LoaderInterface' => $vendorDir . '/twig/twig/src/Loader/LoaderInterface.php',
119
- 'Twig\\Loader\\SourceContextLoaderInterface' => $vendorDir . '/twig/twig/src/Loader/SourceContextLoaderInterface.php',
120
- 'Twig\\Markup' => $vendorDir . '/twig/twig/src/Markup.php',
121
- 'Twig\\NodeTraverser' => $vendorDir . '/twig/twig/src/NodeTraverser.php',
122
- 'Twig\\NodeVisitor\\AbstractNodeVisitor' => $vendorDir . '/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php',
123
- 'Twig\\NodeVisitor\\EscaperNodeVisitor' => $vendorDir . '/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php',
124
- 'Twig\\NodeVisitor\\NodeVisitorInterface' => $vendorDir . '/twig/twig/src/NodeVisitor/NodeVisitorInterface.php',
125
- 'Twig\\NodeVisitor\\OptimizerNodeVisitor' => $vendorDir . '/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php',
126
- 'Twig\\NodeVisitor\\SafeAnalysisNodeVisitor' => $vendorDir . '/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php',
127
- 'Twig\\NodeVisitor\\SandboxNodeVisitor' => $vendorDir . '/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php',
128
- 'Twig\\Node\\AutoEscapeNode' => $vendorDir . '/twig/twig/src/Node/AutoEscapeNode.php',
129
- 'Twig\\Node\\BlockNode' => $vendorDir . '/twig/twig/src/Node/BlockNode.php',
130
- 'Twig\\Node\\BlockReferenceNode' => $vendorDir . '/twig/twig/src/Node/BlockReferenceNode.php',
131
- 'Twig\\Node\\BodyNode' => $vendorDir . '/twig/twig/src/Node/BodyNode.php',
132
- 'Twig\\Node\\CheckSecurityNode' => $vendorDir . '/twig/twig/src/Node/CheckSecurityNode.php',
133
- 'Twig\\Node\\DoNode' => $vendorDir . '/twig/twig/src/Node/DoNode.php',
134
- 'Twig\\Node\\EmbedNode' => $vendorDir . '/twig/twig/src/Node/EmbedNode.php',
135
- 'Twig\\Node\\Expression\\AbstractExpression' => $vendorDir . '/twig/twig/src/Node/Expression/AbstractExpression.php',
136
- 'Twig\\Node\\Expression\\ArrayExpression' => $vendorDir . '/twig/twig/src/Node/Expression/ArrayExpression.php',
137
- 'Twig\\Node\\Expression\\AssignNameExpression' => $vendorDir . '/twig/twig/src/Node/Expression/AssignNameExpression.php',
138
- 'Twig\\Node\\Expression\\Binary\\AbstractBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/AbstractBinary.php',
139
- 'Twig\\Node\\Expression\\Binary\\AddBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/AddBinary.php',
140
- 'Twig\\Node\\Expression\\Binary\\AndBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/AndBinary.php',
141
- 'Twig\\Node\\Expression\\Binary\\BitwiseAndBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php',
142
- 'Twig\\Node\\Expression\\Binary\\BitwiseOrBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php',
143
- 'Twig\\Node\\Expression\\Binary\\BitwiseXorBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php',
144
- 'Twig\\Node\\Expression\\Binary\\ConcatBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/ConcatBinary.php',
145
- 'Twig\\Node\\Expression\\Binary\\DivBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/DivBinary.php',
146
- 'Twig\\Node\\Expression\\Binary\\EndsWithBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php',
147
- 'Twig\\Node\\Expression\\Binary\\EqualBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/EqualBinary.php',
148
- 'Twig\\Node\\Expression\\Binary\\FloorDivBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php',
149
- 'Twig\\Node\\Expression\\Binary\\GreaterBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/GreaterBinary.php',
150
- 'Twig\\Node\\Expression\\Binary\\GreaterEqualBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php',
151
- 'Twig\\Node\\Expression\\Binary\\InBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/InBinary.php',
152
- 'Twig\\Node\\Expression\\Binary\\LessBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/LessBinary.php',
153
- 'Twig\\Node\\Expression\\Binary\\LessEqualBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php',
154
- 'Twig\\Node\\Expression\\Binary\\MatchesBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/MatchesBinary.php',
155
- 'Twig\\Node\\Expression\\Binary\\ModBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/ModBinary.php',
156
- 'Twig\\Node\\Expression\\Binary\\MulBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/MulBinary.php',
157
- 'Twig\\Node\\Expression\\Binary\\NotEqualBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php',
158
- 'Twig\\Node\\Expression\\Binary\\NotInBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/NotInBinary.php',
159
- 'Twig\\Node\\Expression\\Binary\\OrBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/OrBinary.php',
160
- 'Twig\\Node\\Expression\\Binary\\PowerBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/PowerBinary.php',
161
- 'Twig\\Node\\Expression\\Binary\\RangeBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/RangeBinary.php',
162
- 'Twig\\Node\\Expression\\Binary\\StartsWithBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php',
163
- 'Twig\\Node\\Expression\\Binary\\SubBinary' => $vendorDir . '/twig/twig/src/Node/Expression/Binary/SubBinary.php',
164
- 'Twig\\Node\\Expression\\BlockReferenceExpression' => $vendorDir . '/twig/twig/src/Node/Expression/BlockReferenceExpression.php',
165
- 'Twig\\Node\\Expression\\CallExpression' => $vendorDir . '/twig/twig/src/Node/Expression/CallExpression.php',
166
- 'Twig\\Node\\Expression\\ConditionalExpression' => $vendorDir . '/twig/twig/src/Node/Expression/ConditionalExpression.php',
167
- 'Twig\\Node\\Expression\\ConstantExpression' => $vendorDir . '/twig/twig/src/Node/Expression/ConstantExpression.php',
168
- 'Twig\\Node\\Expression\\FilterExpression' => $vendorDir . '/twig/twig/src/Node/Expression/FilterExpression.php',
169
- 'Twig\\Node\\Expression\\Filter\\DefaultFilter' => $vendorDir . '/twig/twig/src/Node/Expression/Filter/DefaultFilter.php',
170
- 'Twig\\Node\\Expression\\FunctionExpression' => $vendorDir . '/twig/twig/src/Node/Expression/FunctionExpression.php',
171
- 'Twig\\Node\\Expression\\GetAttrExpression' => $vendorDir . '/twig/twig/src/Node/Expression/GetAttrExpression.php',
172
- 'Twig\\Node\\Expression\\MethodCallExpression' => $vendorDir . '/twig/twig/src/Node/Expression/MethodCallExpression.php',
173
- 'Twig\\Node\\Expression\\NameExpression' => $vendorDir . '/twig/twig/src/Node/Expression/NameExpression.php',
174
- 'Twig\\Node\\Expression\\NullCoalesceExpression' => $vendorDir . '/twig/twig/src/Node/Expression/NullCoalesceExpression.php',
175
- 'Twig\\Node\\Expression\\ParentExpression' => $vendorDir . '/twig/twig/src/Node/Expression/ParentExpression.php',
176
- 'Twig\\Node\\Expression\\TempNameExpression' => $vendorDir . '/twig/twig/src/Node/Expression/TempNameExpression.php',
177
- 'Twig\\Node\\Expression\\TestExpression' => $vendorDir . '/twig/twig/src/Node/Expression/TestExpression.php',
178
- 'Twig\\Node\\Expression\\Test\\ConstantTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/ConstantTest.php',
179
- 'Twig\\Node\\Expression\\Test\\DefinedTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/DefinedTest.php',
180
- 'Twig\\Node\\Expression\\Test\\DivisiblebyTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php',
181
- 'Twig\\Node\\Expression\\Test\\EvenTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/EvenTest.php',
182
- 'Twig\\Node\\Expression\\Test\\NullTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/NullTest.php',
183
- 'Twig\\Node\\Expression\\Test\\OddTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/OddTest.php',
184
- 'Twig\\Node\\Expression\\Test\\SameasTest' => $vendorDir . '/twig/twig/src/Node/Expression/Test/SameasTest.php',
185
- 'Twig\\Node\\Expression\\Unary\\AbstractUnary' => $vendorDir . '/twig/twig/src/Node/Expression/Unary/AbstractUnary.php',
186
- 'Twig\\Node\\Expression\\Unary\\NegUnary' => $vendorDir . '/twig/twig/src/Node/Expression/Unary/NegUnary.php',
187
- 'Twig\\Node\\Expression\\Unary\\NotUnary' => $vendorDir . '/twig/twig/src/Node/Expression/Unary/NotUnary.php',
188
- 'Twig\\Node\\Expression\\Unary\\PosUnary' => $vendorDir . '/twig/twig/src/Node/Expression/Unary/PosUnary.php',
189
- 'Twig\\Node\\FlushNode' => $vendorDir . '/twig/twig/src/Node/FlushNode.php',
190
- 'Twig\\Node\\ForLoopNode' => $vendorDir . '/twig/twig/src/Node/ForLoopNode.php',
191
- 'Twig\\Node\\ForNode' => $vendorDir . '/twig/twig/src/Node/ForNode.php',
192
- 'Twig\\Node\\IfNode' => $vendorDir . '/twig/twig/src/Node/IfNode.php',
193
- 'Twig\\Node\\ImportNode' => $vendorDir . '/twig/twig/src/Node/ImportNode.php',
194
- 'Twig\\Node\\IncludeNode' => $vendorDir . '/twig/twig/src/Node/IncludeNode.php',
195
- 'Twig\\Node\\MacroNode' => $vendorDir . '/twig/twig/src/Node/MacroNode.php',
196
- 'Twig\\Node\\ModuleNode' => $vendorDir . '/twig/twig/src/Node/ModuleNode.php',
197
- 'Twig\\Node\\Node' => $vendorDir . '/twig/twig/src/Node/Node.php',
198
- 'Twig\\Node\\NodeCaptureInterface' => $vendorDir . '/twig/twig/src/Node/NodeCaptureInterface.php',
199
- 'Twig\\Node\\NodeOutputInterface' => $vendorDir . '/twig/twig/src/Node/NodeOutputInterface.php',
200
- 'Twig\\Node\\PrintNode' => $vendorDir . '/twig/twig/src/Node/PrintNode.php',
201
- 'Twig\\Node\\SandboxNode' => $vendorDir . '/twig/twig/src/Node/SandboxNode.php',
202
- 'Twig\\Node\\SandboxedPrintNode' => $vendorDir . '/twig/twig/src/Node/SandboxedPrintNode.php',
203
- 'Twig\\Node\\SetNode' => $vendorDir . '/twig/twig/src/Node/SetNode.php',
204
- 'Twig\\Node\\SetTempNode' => $vendorDir . '/twig/twig/src/Node/SetTempNode.php',
205
- 'Twig\\Node\\SpacelessNode' => $vendorDir . '/twig/twig/src/Node/SpacelessNode.php',
206
- 'Twig\\Node\\TextNode' => $vendorDir . '/twig/twig/src/Node/TextNode.php',
207
- 'Twig\\Node\\WithNode' => $vendorDir . '/twig/twig/src/Node/WithNode.php',
208
- 'Twig\\Parser' => $vendorDir . '/twig/twig/src/Parser.php',
209
- 'Twig\\Profiler\\Dumper\\BaseDumper' => $vendorDir . '/twig/twig/src/Profiler/Dumper/BaseDumper.php',
210
- 'Twig\\Profiler\\Dumper\\BlackfireDumper' => $vendorDir . '/twig/twig/src/Profiler/Dumper/BlackfireDumper.php',
211
- 'Twig\\Profiler\\Dumper\\HtmlDumper' => $vendorDir . '/twig/twig/src/Profiler/Dumper/HtmlDumper.php',
212
- 'Twig\\Profiler\\Dumper\\TextDumper' => $vendorDir . '/twig/twig/src/Profiler/Dumper/TextDumper.php',
213
- 'Twig\\Profiler\\NodeVisitor\\ProfilerNodeVisitor' => $vendorDir . '/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php',
214
- 'Twig\\Profiler\\Node\\EnterProfileNode' => $vendorDir . '/twig/twig/src/Profiler/Node/EnterProfileNode.php',
215
- 'Twig\\Profiler\\Node\\LeaveProfileNode' => $vendorDir . '/twig/twig/src/Profiler/Node/LeaveProfileNode.php',
216
- 'Twig\\Profiler\\Profile' => $vendorDir . '/twig/twig/src/Profiler/Profile.php',
217
- 'Twig\\RuntimeLoader\\ContainerRuntimeLoader' => $vendorDir . '/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php',
218
- 'Twig\\RuntimeLoader\\FactoryRuntimeLoader' => $vendorDir . '/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php',
219
- 'Twig\\RuntimeLoader\\RuntimeLoaderInterface' => $vendorDir . '/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php',
220
- 'Twig\\Sandbox\\SecurityError' => $vendorDir . '/twig/twig/src/Sandbox/SecurityError.php',
221
- 'Twig\\Sandbox\\SecurityNotAllowedFilterError' => $vendorDir . '/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php',
222
- 'Twig\\Sandbox\\SecurityNotAllowedFunctionError' => $vendorDir . '/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php',
223
- 'Twig\\Sandbox\\SecurityNotAllowedMethodError' => $vendorDir . '/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php',
224
- 'Twig\\Sandbox\\SecurityNotAllowedPropertyError' => $vendorDir . '/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php',
225
- 'Twig\\Sandbox\\SecurityNotAllowedTagError' => $vendorDir . '/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php',
226
- 'Twig\\Sandbox\\SecurityPolicy' => $vendorDir . '/twig/twig/src/Sandbox/SecurityPolicy.php',
227
- 'Twig\\Sandbox\\SecurityPolicyInterface' => $vendorDir . '/twig/twig/src/Sandbox/SecurityPolicyInterface.php',
228
- 'Twig\\Source' => $vendorDir . '/twig/twig/src/Source.php',
229
- 'Twig\\Template' => $vendorDir . '/twig/twig/src/Template.php',
230
- 'Twig\\TemplateWrapper' => $vendorDir . '/twig/twig/src/TemplateWrapper.php',
231
- 'Twig\\Test\\IntegrationTestCase' => $vendorDir . '/twig/twig/src/Test/IntegrationTestCase.php',
232
- 'Twig\\Test\\NodeTestCase' => $vendorDir . '/twig/twig/src/Test/NodeTestCase.php',
233
- 'Twig\\Token' => $vendorDir . '/twig/twig/src/Token.php',
234
- 'Twig\\TokenParser\\AbstractTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/AbstractTokenParser.php',
235
- 'Twig\\TokenParser\\AutoEscapeTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/AutoEscapeTokenParser.php',
236
- 'Twig\\TokenParser\\BlockTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/BlockTokenParser.php',
237
- 'Twig\\TokenParser\\DoTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/DoTokenParser.php',
238
- 'Twig\\TokenParser\\EmbedTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/EmbedTokenParser.php',
239
- 'Twig\\TokenParser\\ExtendsTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/ExtendsTokenParser.php',
240
- 'Twig\\TokenParser\\FilterTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/FilterTokenParser.php',
241
- 'Twig\\TokenParser\\FlushTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/FlushTokenParser.php',
242
- 'Twig\\TokenParser\\ForTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/ForTokenParser.php',
243
- 'Twig\\TokenParser\\FromTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/FromTokenParser.php',
244
- 'Twig\\TokenParser\\IfTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/IfTokenParser.php',
245
- 'Twig\\TokenParser\\ImportTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/ImportTokenParser.php',
246
- 'Twig\\TokenParser\\IncludeTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/IncludeTokenParser.php',
247
- 'Twig\\TokenParser\\MacroTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/MacroTokenParser.php',
248
- 'Twig\\TokenParser\\SandboxTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/SandboxTokenParser.php',
249
- 'Twig\\TokenParser\\SetTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/SetTokenParser.php',
250
- 'Twig\\TokenParser\\SpacelessTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/SpacelessTokenParser.php',
251
- 'Twig\\TokenParser\\TokenParserInterface' => $vendorDir . '/twig/twig/src/TokenParser/TokenParserInterface.php',
252
- 'Twig\\TokenParser\\UseTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/UseTokenParser.php',
253
- 'Twig\\TokenParser\\WithTokenParser' => $vendorDir . '/twig/twig/src/TokenParser/WithTokenParser.php',
254
- 'Twig\\TokenStream' => $vendorDir . '/twig/twig/src/TokenStream.php',
255
- 'Twig\\TwigFilter' => $vendorDir . '/twig/twig/src/TwigFilter.php',
256
- 'Twig\\TwigFunction' => $vendorDir . '/twig/twig/src/TwigFunction.php',
257
- 'Twig\\TwigTest' => $vendorDir . '/twig/twig/src/TwigTest.php',
258
- 'Twig\\Util\\DeprecationCollector' => $vendorDir . '/twig/twig/src/Util/DeprecationCollector.php',
259
- 'Twig\\Util\\TemplateDirIterator' => $vendorDir . '/twig/twig/src/Util/TemplateDirIterator.php',
260
  'Twig_Autoloader' => $vendorDir . '/twig/twig/lib/Twig/Autoloader.php',
261
  'Twig_BaseNodeVisitor' => $vendorDir . '/twig/twig/lib/Twig/BaseNodeVisitor.php',
262
  'Twig_CacheInterface' => $vendorDir . '/twig/twig/lib/Twig/CacheInterface.php',
@@ -396,7 +226,6 @@ return array(
396
  'Twig_Node_With' => $vendorDir . '/twig/twig/lib/Twig/Node/With.php',
397
  'Twig_Parser' => $vendorDir . '/twig/twig/lib/Twig/Parser.php',
398
  'Twig_ParserInterface' => $vendorDir . '/twig/twig/lib/Twig/ParserInterface.php',
399
- 'Twig_Profiler_Dumper_Base' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Base.php',
400
  'Twig_Profiler_Dumper_Blackfire' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php',
401
  'Twig_Profiler_Dumper_Html' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Html.php',
402
  'Twig_Profiler_Dumper_Text' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Text.php',
@@ -469,7 +298,7 @@ return array(
469
  'WCML_Capabilities' => $baseDir . '/inc/class-wcml-capabilities.php',
470
  'WCML_Cart' => $baseDir . '/inc/class-wcml-cart.php',
471
  'WCML_Cart_Removed_Items_Widget' => $baseDir . '/inc/class-wcml-cart-removed-items-widget.php',
472
- 'WCML_Cart_Switch_Lang_Functions' => $baseDir . '/inc/wcml-cart-switch-lang-functions.php',
473
  'WCML_Cart_Sync_Warnings' => $baseDir . '/inc/class-wcml-cart-sync-warnings.php',
474
  'WCML_Checkout_Addons' => $baseDir . '/compatibility/class-wcml-checkout-addons.php',
475
  'WCML_Checkout_Field_Editor' => $baseDir . '/compatibility/class-wcml-checkout-field-editor.php',
87
  'Composer\\Installers\\YawikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/YawikInstaller.php',
88
  'Composer\\Installers\\ZendInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZendInstaller.php',
89
  'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  'Twig_Autoloader' => $vendorDir . '/twig/twig/lib/Twig/Autoloader.php',
91
  'Twig_BaseNodeVisitor' => $vendorDir . '/twig/twig/lib/Twig/BaseNodeVisitor.php',
92
  'Twig_CacheInterface' => $vendorDir . '/twig/twig/lib/Twig/CacheInterface.php',
226
  'Twig_Node_With' => $vendorDir . '/twig/twig/lib/Twig/Node/With.php',
227
  'Twig_Parser' => $vendorDir . '/twig/twig/lib/Twig/Parser.php',
228
  'Twig_ParserInterface' => $vendorDir . '/twig/twig/lib/Twig/ParserInterface.php',
 
229
  'Twig_Profiler_Dumper_Blackfire' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php',
230
  'Twig_Profiler_Dumper_Html' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Html.php',
231
  'Twig_Profiler_Dumper_Text' => $vendorDir . '/twig/twig/lib/Twig/Profiler/Dumper/Text.php',
298
  'WCML_Capabilities' => $baseDir . '/inc/class-wcml-capabilities.php',
299
  'WCML_Cart' => $baseDir . '/inc/class-wcml-cart.php',
300
  'WCML_Cart_Removed_Items_Widget' => $baseDir . '/inc/class-wcml-cart-removed-items-widget.php',
301
+ 'WCML_Cart_Switch_Lang_Functions' => $baseDir . '/inc/class-wcml-cart-switch-lang-functions.php',
302
  'WCML_Cart_Sync_Warnings' => $baseDir . '/inc/class-wcml-cart-sync-warnings.php',
303
  'WCML_Checkout_Addons' => $baseDir . '/compatibility/class-wcml-checkout-addons.php',
304
  'WCML_Checkout_Field_Editor' => $baseDir . '/compatibility/class-wcml-checkout-field-editor.php',
vendor/composer/autoload_psr4.php CHANGED
@@ -6,6 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
- 'Twig\\' => array($vendorDir . '/twig/twig/src'),
10
  'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
11
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
10
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit1e950a3498b2b701753514ff78661529
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit1e950a3498b2b701753514ff78661529
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit1e950a3498b2b701753514ff78661529', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit1e950a3498b2b701753514ff78661529', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInit1e950a3498b2b701753514ff78661529::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit28144429d23dfe0e4a31fd11d74fe167
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit28144429d23dfe0e4a31fd11d74fe167', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit28144429d23dfe0e4a31fd11d74fe167', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit28144429d23dfe0e4a31fd11d74fe167::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
vendor/composer/autoload_real_52.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
- class ComposerAutoloaderInit47e7b07dd515551e87cf2efd9df54aba {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit47e7b07dd515551e87cf2efd9df54aba {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit47e7b07dd515551e87cf2efd9df54aba', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit47e7b07dd515551e87cf2efd9df54aba', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
+ class ComposerAutoloaderInit2aba23511a80a5fa71d9e6ab2604461b {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit2aba23511a80a5fa71d9e6ab2604461b', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit2aba23511a80a5fa71d9e6ab2604461b', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
vendor/composer/autoload_static.php CHANGED
@@ -4,13 +4,9 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit1e950a3498b2b701753514ff78661529
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
- 'T' =>
11
- array (
12
- 'Twig\\' => 5,
13
- ),
14
  'C' =>
15
  array (
16
  'Composer\\Installers\\' => 20,
@@ -18,10 +14,6 @@ class ComposerStaticInit1e950a3498b2b701753514ff78661529
18
  );
19
 
20
  public static $prefixDirsPsr4 = array (
21
- 'Twig\\' =>
22
- array (
23
- 0 => __DIR__ . '/..' . '/twig/twig/src',
24
- ),
25
  'Composer\\Installers\\' =>
26
  array (
27
  0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
@@ -127,176 +119,6 @@ class ComposerStaticInit1e950a3498b2b701753514ff78661529
127
  'Composer\\Installers\\YawikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/YawikInstaller.php',
128
  'Composer\\Installers\\ZendInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZendInstaller.php',
129
  'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
130
- 'Twig\\Cache\\CacheInterface' => __DIR__ . '/..' . '/twig/twig/src/Cache/CacheInterface.php',
131
- 'Twig\\Cache\\FilesystemCache' => __DIR__ . '/..' . '/twig/twig/src/Cache/FilesystemCache.php',
132
- 'Twig\\Cache\\NullCache' => __DIR__ . '/..' . '/twig/twig/src/Cache/NullCache.php',
133
- 'Twig\\Compiler' => __DIR__ . '/..' . '/twig/twig/src/Compiler.php',
134
- 'Twig\\Environment' => __DIR__ . '/..' . '/twig/twig/src/Environment.php',
135
- 'Twig\\Error\\Error' => __DIR__ . '/..' . '/twig/twig/src/Error/Error.php',
136
- 'Twig\\Error\\LoaderError' => __DIR__ . '/..' . '/twig/twig/src/Error/LoaderError.php',
137
- 'Twig\\Error\\RuntimeError' => __DIR__ . '/..' . '/twig/twig/src/Error/RuntimeError.php',
138
- 'Twig\\Error\\SyntaxError' => __DIR__ . '/..' . '/twig/twig/src/Error/SyntaxError.php',
139
- 'Twig\\ExpressionParser' => __DIR__ . '/..' . '/twig/twig/src/ExpressionParser.php',
140
- 'Twig\\Extension\\AbstractExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/AbstractExtension.php',
141
- 'Twig\\Extension\\CoreExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/CoreExtension.php',
142
- 'Twig\\Extension\\DebugExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/DebugExtension.php',
143
- 'Twig\\Extension\\EscaperExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/EscaperExtension.php',
144
- 'Twig\\Extension\\ExtensionInterface' => __DIR__ . '/..' . '/twig/twig/src/Extension/ExtensionInterface.php',
145
- 'Twig\\Extension\\GlobalsInterface' => __DIR__ . '/..' . '/twig/twig/src/Extension/GlobalsInterface.php',
146
- 'Twig\\Extension\\InitRuntimeInterface' => __DIR__ . '/..' . '/twig/twig/src/Extension/InitRuntimeInterface.php',
147
- 'Twig\\Extension\\OptimizerExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/OptimizerExtension.php',
148
- 'Twig\\Extension\\ProfilerExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/ProfilerExtension.php',
149
- 'Twig\\Extension\\SandboxExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/SandboxExtension.php',
150
- 'Twig\\Extension\\StagingExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/StagingExtension.php',
151
- 'Twig\\Extension\\StringLoaderExtension' => __DIR__ . '/..' . '/twig/twig/src/Extension/StringLoaderExtension.php',
152
- 'Twig\\FileExtensionEscapingStrategy' => __DIR__ . '/..' . '/twig/twig/src/FileExtensionEscapingStrategy.php',
153
- 'Twig\\Lexer' => __DIR__ . '/..' . '/twig/twig/src/Lexer.php',
154
- 'Twig\\Loader\\ArrayLoader' => __DIR__ . '/..' . '/twig/twig/src/Loader/ArrayLoader.php',
155
- 'Twig\\Loader\\ChainLoader' => __DIR__ . '/..' . '/twig/twig/src/Loader/ChainLoader.php',
156
- 'Twig\\Loader\\ExistsLoaderInterface' => __DIR__ . '/..' . '/twig/twig/src/Loader/ExistsLoaderInterface.php',
157
- 'Twig\\Loader\\FilesystemLoader' => __DIR__ . '/..' . '/twig/twig/src/Loader/FilesystemLoader.php',
158
- 'Twig\\Loader\\LoaderInterface' => __DIR__ . '/..' . '/twig/twig/src/Loader/LoaderInterface.php',
159
- 'Twig\\Loader\\SourceContextLoaderInterface' => __DIR__ . '/..' . '/twig/twig/src/Loader/SourceContextLoaderInterface.php',
160
- 'Twig\\Markup' => __DIR__ . '/..' . '/twig/twig/src/Markup.php',
161
- 'Twig\\NodeTraverser' => __DIR__ . '/..' . '/twig/twig/src/NodeTraverser.php',
162
- 'Twig\\NodeVisitor\\AbstractNodeVisitor' => __DIR__ . '/..' . '/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php',
163
- 'Twig\\NodeVisitor\\EscaperNodeVisitor' => __DIR__ . '/..' . '/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php',
164
- 'Twig\\NodeVisitor\\NodeVisitorInterface' => __DIR__ . '/..' . '/twig/twig/src/NodeVisitor/NodeVisitorInterface.php',
165
- 'Twig\\NodeVisitor\\OptimizerNodeVisitor' => __DIR__ . '/..' . '/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php',
166
- 'Twig\\NodeVisitor\\SafeAnalysisNodeVisitor' => __DIR__ . '/..' . '/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php',
167
- 'Twig\\NodeVisitor\\SandboxNodeVisitor' => __DIR__ . '/..' . '/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php',
168
- 'Twig\\Node\\AutoEscapeNode' => __DIR__ . '/..' . '/twig/twig/src/Node/AutoEscapeNode.php',
169
- 'Twig\\Node\\BlockNode' => __DIR__ . '/..' . '/twig/twig/src/Node/BlockNode.php',
170
- 'Twig\\Node\\BlockReferenceNode' => __DIR__ . '/..' . '/twig/twig/src/Node/BlockReferenceNode.php',
171
- 'Twig\\Node\\BodyNode' => __DIR__ . '/..' . '/twig/twig/src/Node/BodyNode.php',
172
- 'Twig\\Node\\CheckSecurityNode' => __DIR__ . '/..' . '/twig/twig/src/Node/CheckSecurityNode.php',
173
- 'Twig\\Node\\DoNode' => __DIR__ . '/..' . '/twig/twig/src/Node/DoNode.php',
174
- 'Twig\\Node\\EmbedNode' => __DIR__ . '/..' . '/twig/twig/src/Node/EmbedNode.php',
175
- 'Twig\\Node\\Expression\\AbstractExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/AbstractExpression.php',
176
- 'Twig\\Node\\Expression\\ArrayExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/ArrayExpression.php',
177
- 'Twig\\Node\\Expression\\AssignNameExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/AssignNameExpression.php',
178
- 'Twig\\Node\\Expression\\Binary\\AbstractBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/AbstractBinary.php',
179
- 'Twig\\Node\\Expression\\Binary\\AddBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/AddBinary.php',
180
- 'Twig\\Node\\Expression\\Binary\\AndBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/AndBinary.php',
181
- 'Twig\\Node\\Expression\\Binary\\BitwiseAndBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php',
182
- 'Twig\\Node\\Expression\\Binary\\BitwiseOrBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php',
183
- 'Twig\\Node\\Expression\\Binary\\BitwiseXorBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php',
184
- 'Twig\\Node\\Expression\\Binary\\ConcatBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/ConcatBinary.php',
185
- 'Twig\\Node\\Expression\\Binary\\DivBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/DivBinary.php',
186
- 'Twig\\Node\\Expression\\Binary\\EndsWithBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php',
187
- 'Twig\\Node\\Expression\\Binary\\EqualBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/EqualBinary.php',
188
- 'Twig\\Node\\Expression\\Binary\\FloorDivBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php',
189
- 'Twig\\Node\\Expression\\Binary\\GreaterBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/GreaterBinary.php',
190
- 'Twig\\Node\\Expression\\Binary\\GreaterEqualBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php',
191
- 'Twig\\Node\\Expression\\Binary\\InBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/InBinary.php',
192
- 'Twig\\Node\\Expression\\Binary\\LessBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/LessBinary.php',
193
- 'Twig\\Node\\Expression\\Binary\\LessEqualBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php',
194
- 'Twig\\Node\\Expression\\Binary\\MatchesBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/MatchesBinary.php',
195
- 'Twig\\Node\\Expression\\Binary\\ModBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/ModBinary.php',
196
- 'Twig\\Node\\Expression\\Binary\\MulBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/MulBinary.php',
197
- 'Twig\\Node\\Expression\\Binary\\NotEqualBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php',
198
- 'Twig\\Node\\Expression\\Binary\\NotInBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/NotInBinary.php',
199
- 'Twig\\Node\\Expression\\Binary\\OrBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/OrBinary.php',
200
- 'Twig\\Node\\Expression\\Binary\\PowerBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/PowerBinary.php',
201
- 'Twig\\Node\\Expression\\Binary\\RangeBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/RangeBinary.php',
202
- 'Twig\\Node\\Expression\\Binary\\StartsWithBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php',
203
- 'Twig\\Node\\Expression\\Binary\\SubBinary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Binary/SubBinary.php',
204
- 'Twig\\Node\\Expression\\BlockReferenceExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/BlockReferenceExpression.php',
205
- 'Twig\\Node\\Expression\\CallExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/CallExpression.php',
206
- 'Twig\\Node\\Expression\\ConditionalExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/ConditionalExpression.php',
207
- 'Twig\\Node\\Expression\\ConstantExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/ConstantExpression.php',
208
- 'Twig\\Node\\Expression\\FilterExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/FilterExpression.php',
209
- 'Twig\\Node\\Expression\\Filter\\DefaultFilter' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Filter/DefaultFilter.php',
210
- 'Twig\\Node\\Expression\\FunctionExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/FunctionExpression.php',
211
- 'Twig\\Node\\Expression\\GetAttrExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/GetAttrExpression.php',
212
- 'Twig\\Node\\Expression\\MethodCallExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/MethodCallExpression.php',
213
- 'Twig\\Node\\Expression\\NameExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/NameExpression.php',
214
- 'Twig\\Node\\Expression\\NullCoalesceExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/NullCoalesceExpression.php',
215
- 'Twig\\Node\\Expression\\ParentExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/ParentExpression.php',
216
- 'Twig\\Node\\Expression\\TempNameExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/TempNameExpression.php',
217
- 'Twig\\Node\\Expression\\TestExpression' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/TestExpression.php',
218
- 'Twig\\Node\\Expression\\Test\\ConstantTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/ConstantTest.php',
219
- 'Twig\\Node\\Expression\\Test\\DefinedTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/DefinedTest.php',
220
- 'Twig\\Node\\Expression\\Test\\DivisiblebyTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php',
221
- 'Twig\\Node\\Expression\\Test\\EvenTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/EvenTest.php',
222
- 'Twig\\Node\\Expression\\Test\\NullTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/NullTest.php',
223
- 'Twig\\Node\\Expression\\Test\\OddTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/OddTest.php',
224
- 'Twig\\Node\\Expression\\Test\\SameasTest' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Test/SameasTest.php',
225
- 'Twig\\Node\\Expression\\Unary\\AbstractUnary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Unary/AbstractUnary.php',
226
- 'Twig\\Node\\Expression\\Unary\\NegUnary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Unary/NegUnary.php',
227
- 'Twig\\Node\\Expression\\Unary\\NotUnary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Unary/NotUnary.php',
228
- 'Twig\\Node\\Expression\\Unary\\PosUnary' => __DIR__ . '/..' . '/twig/twig/src/Node/Expression/Unary/PosUnary.php',
229
- 'Twig\\Node\\FlushNode' => __DIR__ . '/..' . '/twig/twig/src/Node/FlushNode.php',
230
- 'Twig\\Node\\ForLoopNode' => __DIR__ . '/..' . '/twig/twig/src/Node/ForLoopNode.php',
231
- 'Twig\\Node\\ForNode' => __DIR__ . '/..' . '/twig/twig/src/Node/ForNode.php',
232
- 'Twig\\Node\\IfNode' => __DIR__ . '/..' . '/twig/twig/src/Node/IfNode.php',
233
- 'Twig\\Node\\ImportNode' => __DIR__ . '/..' . '/twig/twig/src/Node/ImportNode.php',
234
- 'Twig\\Node\\IncludeNode' => __DIR__ . '/..' . '/twig/twig/src/Node/IncludeNode.php',
235
- 'Twig\\Node\\MacroNode' => __DIR__ . '/..' . '/twig/twig/src/Node/MacroNode.php',
236
- 'Twig\\Node\\ModuleNode' => __DIR__ . '/..' . '/twig/twig/src/Node/ModuleNode.php',
237
- 'Twig\\Node\\Node' => __DIR__ . '/..' . '/twig/twig/src/Node/Node.php',
238
- 'Twig\\Node\\NodeCaptureInterface' => __DIR__ . '/..' . '/twig/twig/src/Node/NodeCaptureInterface.php',
239
- 'Twig\\Node\\NodeOutputInterface' => __DIR__ . '/..' . '/twig/twig/src/Node/NodeOutputInterface.php',
240
- 'Twig\\Node\\PrintNode' => __DIR__ . '/..' . '/twig/twig/src/Node/PrintNode.php',
241
- 'Twig\\Node\\SandboxNode' => __DIR__ . '/..' . '/twig/twig/src/Node/SandboxNode.php',
242
- 'Twig\\Node\\SandboxedPrintNode' => __DIR__ . '/..' . '/twig/twig/src/Node/SandboxedPrintNode.php',
243
- 'Twig\\Node\\SetNode' => __DIR__ . '/..' . '/twig/twig/src/Node/SetNode.php',
244
- 'Twig\\Node\\SetTempNode' => __DIR__ . '/..' . '/twig/twig/src/Node/SetTempNode.php',
245
- 'Twig\\Node\\SpacelessNode' => __DIR__ . '/..' . '/twig/twig/src/Node/SpacelessNode.php',
246
- 'Twig\\Node\\TextNode' => __DIR__ . '/..' . '/twig/twig/src/Node/TextNode.php',
247
- 'Twig\\Node\\WithNode' => __DIR__ . '/..' . '/twig/twig/src/Node/WithNode.php',
248
- 'Twig\\Parser' => __DIR__ . '/..' . '/twig/twig/src/Parser.php',
249
- 'Twig\\Profiler\\Dumper\\BaseDumper' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Dumper/BaseDumper.php',
250
- 'Twig\\Profiler\\Dumper\\BlackfireDumper' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Dumper/BlackfireDumper.php',
251
- 'Twig\\Profiler\\Dumper\\HtmlDumper' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Dumper/HtmlDumper.php',
252
- 'Twig\\Profiler\\Dumper\\TextDumper' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Dumper/TextDumper.php',
253
- 'Twig\\Profiler\\NodeVisitor\\ProfilerNodeVisitor' => __DIR__ . '/..' . '/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php',
254
- 'Twig\\Profiler\\Node\\EnterProfileNode' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Node/EnterProfileNode.php',
255
- 'Twig\\Profiler\\Node\\LeaveProfileNode' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Node/LeaveProfileNode.php',
256
- 'Twig\\Profiler\\Profile' => __DIR__ . '/..' . '/twig/twig/src/Profiler/Profile.php',
257
- 'Twig\\RuntimeLoader\\ContainerRuntimeLoader' => __DIR__ . '/..' . '/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php',
258
- 'Twig\\RuntimeLoader\\FactoryRuntimeLoader' => __DIR__ . '/..' . '/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php',
259
- 'Twig\\RuntimeLoader\\RuntimeLoaderInterface' => __DIR__ . '/..' . '/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php',
260
- 'Twig\\Sandbox\\SecurityError' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityError.php',
261
- 'Twig\\Sandbox\\SecurityNotAllowedFilterError' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php',
262
- 'Twig\\Sandbox\\SecurityNotAllowedFunctionError' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php',
263
- 'Twig\\Sandbox\\SecurityNotAllowedMethodError' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php',
264
- 'Twig\\Sandbox\\SecurityNotAllowedPropertyError' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php',
265
- 'Twig\\Sandbox\\SecurityNotAllowedTagError' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php',
266
- 'Twig\\Sandbox\\SecurityPolicy' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityPolicy.php',
267
- 'Twig\\Sandbox\\SecurityPolicyInterface' => __DIR__ . '/..' . '/twig/twig/src/Sandbox/SecurityPolicyInterface.php',
268
- 'Twig\\Source' => __DIR__ . '/..' . '/twig/twig/src/Source.php',
269
- 'Twig\\Template' => __DIR__ . '/..' . '/twig/twig/src/Template.php',
270
- 'Twig\\TemplateWrapper' => __DIR__ . '/..' . '/twig/twig/src/TemplateWrapper.php',
271
- 'Twig\\Test\\IntegrationTestCase' => __DIR__ . '/..' . '/twig/twig/src/Test/IntegrationTestCase.php',
272
- 'Twig\\Test\\NodeTestCase' => __DIR__ . '/..' . '/twig/twig/src/Test/NodeTestCase.php',
273
- 'Twig\\Token' => __DIR__ . '/..' . '/twig/twig/src/Token.php',
274
- 'Twig\\TokenParser\\AbstractTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/AbstractTokenParser.php',
275
- 'Twig\\TokenParser\\AutoEscapeTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/AutoEscapeTokenParser.php',
276
- 'Twig\\TokenParser\\BlockTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/BlockTokenParser.php',
277
- 'Twig\\TokenParser\\DoTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/DoTokenParser.php',
278
- 'Twig\\TokenParser\\EmbedTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/EmbedTokenParser.php',
279
- 'Twig\\TokenParser\\ExtendsTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/ExtendsTokenParser.php',
280
- 'Twig\\TokenParser\\FilterTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/FilterTokenParser.php',
281
- 'Twig\\TokenParser\\FlushTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/FlushTokenParser.php',
282
- 'Twig\\TokenParser\\ForTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/ForTokenParser.php',
283
- 'Twig\\TokenParser\\FromTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/FromTokenParser.php',
284
- 'Twig\\TokenParser\\IfTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/IfTokenParser.php',
285
- 'Twig\\TokenParser\\ImportTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/ImportTokenParser.php',
286
- 'Twig\\TokenParser\\IncludeTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/IncludeTokenParser.php',
287
- 'Twig\\TokenParser\\MacroTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/MacroTokenParser.php',
288
- 'Twig\\TokenParser\\SandboxTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/SandboxTokenParser.php',
289
- 'Twig\\TokenParser\\SetTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/SetTokenParser.php',
290
- 'Twig\\TokenParser\\SpacelessTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/SpacelessTokenParser.php',
291
- 'Twig\\TokenParser\\TokenParserInterface' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/TokenParserInterface.php',
292
- 'Twig\\TokenParser\\UseTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/UseTokenParser.php',
293
- 'Twig\\TokenParser\\WithTokenParser' => __DIR__ . '/..' . '/twig/twig/src/TokenParser/WithTokenParser.php',
294
- 'Twig\\TokenStream' => __DIR__ . '/..' . '/twig/twig/src/TokenStream.php',
295
- 'Twig\\TwigFilter' => __DIR__ . '/..' . '/twig/twig/src/TwigFilter.php',
296
- 'Twig\\TwigFunction' => __DIR__ . '/..' . '/twig/twig/src/TwigFunction.php',
297
- 'Twig\\TwigTest' => __DIR__ . '/..' . '/twig/twig/src/TwigTest.php',
298
- 'Twig\\Util\\DeprecationCollector' => __DIR__ . '/..' . '/twig/twig/src/Util/DeprecationCollector.php',
299
- 'Twig\\Util\\TemplateDirIterator' => __DIR__ . '/..' . '/twig/twig/src/Util/TemplateDirIterator.php',
300
  'Twig_Autoloader' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Autoloader.php',
301
  'Twig_BaseNodeVisitor' => __DIR__ . '/..' . '/twig/twig/lib/Twig/BaseNodeVisitor.php',
302
  'Twig_CacheInterface' => __DIR__ . '/..' . '/twig/twig/lib/Twig/CacheInterface.php',
@@ -436,7 +258,6 @@ class ComposerStaticInit1e950a3498b2b701753514ff78661529
436
  'Twig_Node_With' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Node/With.php',
437
  'Twig_Parser' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Parser.php',
438
  'Twig_ParserInterface' => __DIR__ . '/..' . '/twig/twig/lib/Twig/ParserInterface.php',
439
- 'Twig_Profiler_Dumper_Base' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Base.php',
440
  'Twig_Profiler_Dumper_Blackfire' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php',
441
  'Twig_Profiler_Dumper_Html' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Html.php',
442
  'Twig_Profiler_Dumper_Text' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Text.php',
@@ -509,7 +330,7 @@ class ComposerStaticInit1e950a3498b2b701753514ff78661529
509
  'WCML_Capabilities' => __DIR__ . '/../..' . '/inc/class-wcml-capabilities.php',
510
  'WCML_Cart' => __DIR__ . '/../..' . '/inc/class-wcml-cart.php',
511
  'WCML_Cart_Removed_Items_Widget' => __DIR__ . '/../..' . '/inc/class-wcml-cart-removed-items-widget.php',
512
- 'WCML_Cart_Switch_Lang_Functions' => __DIR__ . '/../..' . '/inc/wcml-cart-switch-lang-functions.php',
513
  'WCML_Cart_Sync_Warnings' => __DIR__ . '/../..' . '/inc/class-wcml-cart-sync-warnings.php',
514
  'WCML_Checkout_Addons' => __DIR__ . '/../..' . '/compatibility/class-wcml-checkout-addons.php',
515
  'WCML_Checkout_Field_Editor' => __DIR__ . '/../..' . '/compatibility/class-wcml-checkout-field-editor.php',
@@ -654,10 +475,10 @@ class ComposerStaticInit1e950a3498b2b701753514ff78661529
654
  public static function getInitializer(ClassLoader $loader)
655
  {
656
  return \Closure::bind(function () use ($loader) {
657
- $loader->prefixLengthsPsr4 = ComposerStaticInit1e950a3498b2b701753514ff78661529::$prefixLengthsPsr4;
658
- $loader->prefixDirsPsr4 = ComposerStaticInit1e950a3498b2b701753514ff78661529::$prefixDirsPsr4;
659
- $loader->prefixesPsr0 = ComposerStaticInit1e950a3498b2b701753514ff78661529::$prefixesPsr0;
660
- $loader->classMap = ComposerStaticInit1e950a3498b2b701753514ff78661529::$classMap;
661
 
662
  }, null, ClassLoader::class);
663
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit28144429d23dfe0e4a31fd11d74fe167
8
  {
9
  public static $prefixLengthsPsr4 = array (
 
 
 
 
10
  'C' =>
11
  array (
12
  'Composer\\Installers\\' => 20,
14
  );
15
 
16
  public static $prefixDirsPsr4 = array (
 
 
 
 
17
  'Composer\\Installers\\' =>
18
  array (
19
  0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
119
  'Composer\\Installers\\YawikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/YawikInstaller.php',
120
  'Composer\\Installers\\ZendInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZendInstaller.php',
121
  'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  'Twig_Autoloader' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Autoloader.php',
123
  'Twig_BaseNodeVisitor' => __DIR__ . '/..' . '/twig/twig/lib/Twig/BaseNodeVisitor.php',
124
  'Twig_CacheInterface' => __DIR__ . '/..' . '/twig/twig/lib/Twig/CacheInterface.php',
258
  'Twig_Node_With' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Node/With.php',
259
  'Twig_Parser' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Parser.php',
260
  'Twig_ParserInterface' => __DIR__ . '/..' . '/twig/twig/lib/Twig/ParserInterface.php',
 
261
  'Twig_Profiler_Dumper_Blackfire' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php',
262
  'Twig_Profiler_Dumper_Html' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Html.php',
263
  'Twig_Profiler_Dumper_Text' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Profiler/Dumper/Text.php',
330
  'WCML_Capabilities' => __DIR__ . '/../..' . '/inc/class-wcml-capabilities.php',
331
  'WCML_Cart' => __DIR__ . '/../..' . '/inc/class-wcml-cart.php',
332
  'WCML_Cart_Removed_Items_Widget' => __DIR__ . '/../..' . '/inc/class-wcml-cart-removed-items-widget.php',
333
+ 'WCML_Cart_Switch_Lang_Functions' => __DIR__ . '/../..' . '/inc/class-wcml-cart-switch-lang-functions.php',
334
  'WCML_Cart_Sync_Warnings' => __DIR__ . '/../..' . '/inc/class-wcml-cart-sync-warnings.php',
335
  'WCML_Checkout_Addons' => __DIR__ . '/../..' . '/compatibility/class-wcml-checkout-addons.php',
336
  'WCML_Checkout_Field_Editor' => __DIR__ . '/../..' . '/compatibility/class-wcml-checkout-field-editor.php',
475
  public static function getInitializer(ClassLoader $loader)
476
  {
477
  return \Closure::bind(function () use ($loader) {
478
+ $loader->prefixLengthsPsr4 = ComposerStaticInit28144429d23dfe0e4a31fd11d74fe167::$prefixLengthsPsr4;
479
+ $loader->prefixDirsPsr4 = ComposerStaticInit28144429d23dfe0e4a31fd11d74fe167::$prefixDirsPsr4;
480
+ $loader->prefixesPsr0 = ComposerStaticInit28144429d23dfe0e4a31fd11d74fe167::$prefixesPsr0;
481
+ $loader->classMap = ComposerStaticInit28144429d23dfe0e4a31fd11d74fe167::$classMap;
482
 
483
  }, null, ClassLoader::class);
484
  }
vendor/otgs/installer/includes/class-installer-dependencies.php CHANGED
@@ -1,291 +1,291 @@
1
- <?php
2
-
3
- class Installer_Dependencies {
4
-
5
- private $uploading_allowed = null;
6
- private $is_win_paths_exception = array();
7
-
8
-
9
- function __construct() {
10
-
11
- add_action( 'admin_init', array( $this, 'prevent_plugins_update_on_plugins_page' ), 100 );
12
-
13
-
14
- global $pagenow;
15
- if ( $pagenow == 'update.php' ) {
16
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'update-selected' ) {
17
- add_action( 'admin_head', array(
18
- $this,
19
- 'prevent_plugins_update_on_updates_screen'
20
- ) ); //iframe/bulk
21
- } else {
22
- add_action( 'all_admin_notices', array(
23
- $this,
24
- 'prevent_plugins_update_on_updates_screen'
25
- ) ); //regular/singular
26
- }
27
- }
28
- add_action( 'wp_ajax_update-plugin', array(
29
- $this,
30
- 'prevent_plugins_update_on_updates_screen'
31
- ), 0 ); // high priority, before WP
32
-
33
- }
34
-
35
- public function is_win_paths_exception( $repository_id ) {
36
-
37
- if ( ! isset( $this->is_win_paths_exception[ $repository_id ] ) ) {
38
-
39
- $this->is_win_paths_exception[ $repository_id ] = false;
40
-
41
- if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) {
42
-
43
- $windows_max_path_length = 256;
44
- $longest_path['wpml'] = 109;
45
- $longest_path['toolset'] = 99;
46
-
47
- $margin = 15;
48
-
49
- $upgrade_path_length = strlen( WP_CONTENT_DIR . '/upgrade' );
50
-
51
- $installer_settings = WP_Installer()->settings;
52
-
53
- if ( isset($installer_settings['repositories'][$repository_id]['data']) && is_array( $installer_settings['repositories'][$repository_id]['data']['downloads']['plugins'] ) ) {
54
- $a_plugin = current( $installer_settings['repositories'][$repository_id]['data']['downloads']['plugins'] );
55
- $url = WP_Installer()->append_site_key_to_download_url( $a_plugin['url'], 'xxxxxx', $repository_id );
56
- $tmpfname = wp_tempnam( $url );
57
-
58
- $tmpname_length = strlen( basename( $tmpfname ) ) - 4; // -.tmp
59
-
60
- if ( $upgrade_path_length + $tmpname_length + $longest_path[ $repository_id ] + $margin > $windows_max_path_length ) {
61
-
62
- $this->is_win_paths_exception[ $repository_id ] = true;
63
-
64
- }
65
-
66
- }
67
-
68
-
69
- }
70
-
71
- }
72
-
73
- return $this->is_win_paths_exception[ $repository_id ];
74
-
75
- }
76
-
77
- public function is_uploading_allowed() {
78
-
79
- if ( ! isset( $this->uploading_allowed ) ) {
80
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
81
- require_once WP_Installer()->plugin_path() . '/includes/class-installer-upgrader-skins.php';
82
-
83
- $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
84
- $upgrader = new Plugin_Upgrader( $upgrader_skins );
85
-
86
- ob_start();
87
- $res = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
88
- ob_end_clean();
89
-
90
- if ( ! $res || is_wp_error( $res ) ) {
91
- $this->uploading_allowed = false;
92
- } else {
93
- $this->uploading_allowed = true;
94
- }
95
- }
96
-
97
- return $this->uploading_allowed;
98
-
99
- }
100
-
101
- public function cant_download( $repository_id ) {
102
-
103
- return ! $this->is_uploading_allowed() || $this->is_win_paths_exception( $repository_id );
104
-
105
- }
106
-
107
- public function win_paths_exception_message() {
108
- return __( 'Downloading is not possible. WordPress cannot create required folders because of the
109
- 256 characters limitation of the current Windows environment.', 'installer' );
110
- }
111
-
112
- public function prevent_plugins_update_on_plugins_page() {
113
-
114
- $plugins = get_site_transient( 'update_plugins' );
115
- if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
116
- $plugins_with_updates = array_keys( $plugins->response );
117
- }
118
-
119
- if ( ! empty( $plugins_with_updates ) ) {
120
-
121
- $plugins = get_plugins();
122
-
123
- $installer_settings = WP_Installer()->settings;
124
- if ( isset( $installer_settings['repositories'] ) ) {
125
- foreach ( $installer_settings['repositories'] as $repository_id => $repository ) {
126
-
127
- if ( $this->is_win_paths_exception( $repository_id ) ) {
128
-
129
- $repositories_plugins = array();
130
- foreach ( $repository['data']['packages'] as $package ) {
131
- foreach ( $package['products'] as $product ) {
132
- foreach ( $product['plugins'] as $plugin_slug ) {
133
- $download = $installer_settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
134
- if ( empty( $download['free-on-wporg'] ) ) {
135
- $repositories_plugins[ $download['slug'] ] = $download['name'];
136
- }
137
- }
138
- }
139
- }
140
-
141
- foreach ( $plugins as $plugin_id => $plugin ) {
142
-
143
- if ( in_array( $plugin_id, $plugins_with_updates ) ) {
144
-
145
- $wp_plugin_slug = dirname( $plugin_id );
146
- if ( empty( $wp_plugin_slug ) ) {
147
- $wp_plugin_slug = basename( $plugin_id, '.php' );
148
- }
149
-
150
- foreach ( $repositories_plugins as $slug => $name ) {
151
- if ( $wp_plugin_slug == $slug || $name == $plugin['Name'] || $name == $plugin['Title'] ) { //match order: slug, name, title
152
-
153
- remove_action( "after_plugin_row_$plugin_id", 'wp_plugin_update_row', 10, 2 );
154
- add_action( "after_plugin_row_$plugin_id", array(
155
- $this,
156
- 'wp_plugin_update_row_win_exception',
157
- ), 10, 2 );
158
-
159
- }
160
- }
161
-
162
- }
163
-
164
- }
165
-
166
- }
167
-
168
-
169
- }
170
- }
171
-
172
- }
173
-
174
- }
175
-
176
- public function wp_plugin_update_row_win_exception() {
177
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
178
- echo '<tr class="plugin-update-tr">';
179
- echo '<td class="plugin-update colspanchange" colspan="' . esc_attr( $wp_list_table->get_column_count() ) .
180
- '"><div class="update-message">' . $this->win_paths_exception_message() . '</div></td>';
181
- echo '</tr>';
182
- }
183
-
184
- public function prevent_plugins_update_on_updates_screen() {
185
-
186
- if ( isset( $_REQUEST['action'] ) ) {
187
-
188
- $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
189
-
190
- $installer_settings = WP_Installer()->settings;
191
-
192
- //bulk mode
193
- if ( 'update-selected' == $action ) {
194
-
195
- global $plugins;
196
-
197
- if ( isset( $plugins ) && is_array( $plugins ) ) {
198
-
199
- foreach ( $plugins as $k => $plugin ) {
200
-
201
- $wp_plugin_slug = dirname( $plugin );
202
-
203
- foreach ( $installer_settings['repositories'] as $repository_id => $repository ) {
204
-
205
- if ( $this->is_win_paths_exception( $repository_id ) ) {
206
-
207
- foreach ( $repository['data']['packages'] as $package ) {
208
-
209
- foreach ( $package['products'] as $product ) {
210
-
211
- foreach ( $product['plugins'] as $plugin_slug ) {
212
-
213
- $download = $installer_settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
214
-
215
- if ( $download['slug'] == $wp_plugin_slug && empty( $download['free-on-wporg'] ) ) {
216
-
217
- echo '<div class="updated error"><p>' . $this->win_paths_exception_message() .
218
- ' <strong>(' . $download['name'] . ')</strong>' . '</p></div>';
219
- unset( $plugins[ $k ] );
220
-
221
- break( 3 );
222
-
223
- }
224
-
225
- }
226
-
227
- }
228
-
229
- }
230
-
231
-
232
- }
233
-
234
- }
235
-
236
- }
237
-
238
- }
239
-
240
- }
241
-
242
-
243
- if ( 'upgrade-plugin' == $action || 'update-plugin' == $action ) {
244
-
245
- $plugin = isset( $_REQUEST['plugin'] ) ? trim( sanitize_text_field( $_REQUEST['plugin'] ) ) : '';
246
-
247
- $wp_plugin_slug = dirname( $plugin );
248
-
249
- foreach ( $installer_settings['repositories'] as $repository_id => $repository ) {
250
-
251
- if ( $this->is_win_paths_exception( $repository_id ) ) {
252
- foreach ( $repository['data']['packages'] as $package ) {
253
-
254
- foreach ( $package['products'] as $product ) {
255
-
256
- foreach ( $product['plugins'] as $plugin_slug ) {
257
- $download = $installer_settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
258
-
259
- //match by folder, will change to match by name and folder
260
- if ( $download['slug'] == $wp_plugin_slug && empty ( $download['free-on-wporg'] ) ) {
261
-
262
- echo '<div class="updated error"><p>' . $this->win_paths_exception_message() . '</p></div>';
263
-
264
- echo '<div class="wrap">';
265
- echo '<h2>' . __( 'Update Plugin' ) . '</h2>';
266
- echo '<a href="' . admin_url( 'update-core.php' ) . '">' . __( 'Return to the updates page', 'installer' ) . '</a>';
267
- echo '</div>';
268
- require_once( ABSPATH . 'wp-admin/admin-footer.php' );
269
- exit;
270
-
271
- }
272
-
273
- }
274
-
275
- }
276
-
277
- }
278
- }
279
-
280
- }
281
-
282
- }
283
- }
284
-
285
- }
286
-
287
-
288
- }
289
-
290
-
291
-
1
+ <?php
2
+
3
+ class Installer_Dependencies {
4
+
5
+ private $uploading_allowed = null;
6
+ private $is_win_paths_exception = array();
7
+
8
+
9
+ function __construct() {
10
+
11
+ add_action( 'admin_init', array( $this, 'prevent_plugins_update_on_plugins_page' ), 100 );
12
+
13
+
14
+ global $pagenow;
15
+ if ( $pagenow == 'update.php' ) {
16
+ if ( isset( $_GET['action'] ) && $_GET['action'] == 'update-selected' ) {
17
+ add_action( 'admin_head', array(
18
+ $this,
19
+ 'prevent_plugins_update_on_updates_screen'
20
+ ) ); //iframe/bulk
21
+ } else {
22
+ add_action( 'all_admin_notices', array(
23
+ $this,
24
+ 'prevent_plugins_update_on_updates_screen'
25
+ ) ); //regular/singular
26
+ }
27
+ }
28
+ add_action( 'wp_ajax_update-plugin', array(
29
+ $this,
30
+ 'prevent_plugins_update_on_updates_screen'
31
+ ), 0 ); // high priority, before WP
32
+
33
+ }
34
+
35
+ public function is_win_paths_exception( $repository_id ) {
36
+
37
+ if ( ! isset( $this->is_win_paths_exception[ $repository_id ] ) ) {
38
+
39
+ $this->is_win_paths_exception[ $repository_id ] = false;
40
+
41
+ if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) {
42
+
43
+ $windows_max_path_length = 256;
44
+ $longest_path['wpml'] = 109;
45
+ $longest_path['toolset'] = 99;
46
+
47
+ $margin = 15;
48
+
49
+ $upgrade_path_length = strlen( WP_CONTENT_DIR . '/upgrade' );
50
+
51
+ $installer_settings = WP_Installer()->settings;
52
+
53
+ if ( isset($installer_settings['repositories'][$repository_id]['data']) && is_array( $installer_settings['repositories'][$repository_id]['data']['downloads']['plugins'] ) ) {
54
+ $a_plugin = current( $installer_settings['repositories'][$repository_id]['data']['downloads']['plugins'] );
55
+ $url = WP_Installer()->append_site_key_to_download_url( $a_plugin['url'], 'xxxxxx', $repository_id );
56
+ $tmpfname = wp_tempnam( $url );
57
+
58
+ $tmpname_length = strlen( basename( $tmpfname ) ) - 4; // -.tmp
59
+
60
+ if ( $upgrade_path_length + $tmpname_length + $longest_path[ $repository_id ] + $margin > $windows_max_path_length ) {
61
+
62
+ $this->is_win_paths_exception[ $repository_id ] = true;
63
+
64
+ }
65
+
66
+ }
67
+
68
+
69
+ }
70
+
71
+ }
72
+
73
+ return $this->is_win_paths_exception[ $repository_id ];
74
+
75
+ }
76
+
77
+ public function is_uploading_allowed() {
78
+
79
+ if ( ! isset( $this->uploading_allowed ) ) {
80
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
81
+ require_once WP_Installer()->plugin_path() . '/includes/class-installer-upgrader-skins.php';
82
+
83
+ $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
84
+ $upgrader = new Plugin_Upgrader( $upgrader_skins );
85
+
86
+ ob_start();
87
+ $res = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
88
+ ob_end_clean();
89
+
90
+ if ( ! $res || is_wp_error( $res ) ) {
91
+ $this->uploading_allowed = false;
92
+ } else {
93
+ $this->uploading_allowed = true;
94
+ }
95
+ }
96
+
97
+ return $this->uploading_allowed;
98
+
99
+ }
100
+
101
+ public function cant_download( $repository_id ) {
102
+
103
+ return ! $this->is_uploading_allowed() || $this->is_win_paths_exception( $repository_id );
104
+
105
+ }
106
+
107
+ public function win_paths_exception_message() {
108
+ return __( 'Downloading is not possible. WordPress cannot create required folders because of the
109
+ 256 characters limitation of the current Windows environment.', 'installer' );
110
+ }
111
+
112
+ public function prevent_plugins_update_on_plugins_page() {
113
+
114
+ $plugins = get_site_transient( 'update_plugins' );
115
+ if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
116
+ $plugins_with_updates = array_keys( $plugins->response );
117
+ }
118
+
119
+ if ( ! empty( $plugins_with_updates ) ) {
120
+
121
+ $plugins = get_plugins();
122
+
123
+ $installer_settings = WP_Installer()->settings;
124
+ if ( isset( $installer_settings['repositories'] ) ) {
125
+ foreach ( $installer_settings['repositories'] as $repository_id => $repository ) {
126
+
127
+ if ( $this->is_win_paths_exception( $repository_id ) ) {
128
+
129
+ $repositories_plugins = array();
130
+ foreach ( $repository['data']['packages'] as $package ) {
131
+ foreach ( $package['products'] as $product ) {
132
+ foreach ( $product['plugins'] as $plugin_slug ) {
133
+ $download = $installer_settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
134
+ if ( empty( $download['free-on-wporg'] ) ) {
135
+ $repositories_plugins[ $download['slug'] ] = $download['name'];
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ foreach ( $plugins as $plugin_id => $plugin ) {
142
+
143
+ if ( in_array( $plugin_id, $plugins_with_updates ) ) {
144
+
145
+ $wp_plugin_slug = dirname( $plugin_id );
146
+ if ( empty( $wp_plugin_slug ) ) {
147
+ $wp_plugin_slug = basename( $plugin_id, '.php' );
148
+ }
149
+
150
+ foreach ( $repositories_plugins as $slug => $name ) {
151
+ if ( $wp_plugin_slug == $slug || $name == $plugin['Name'] || $name == $plugin['Title'] ) { //match order: slug, name, title
152
+
153
+ remove_action( "after_plugin_row_$plugin_id", 'wp_plugin_update_row', 10, 2 );
154
+ add_action( "after_plugin_row_$plugin_id", array(
155
+ $this,
156
+ 'wp_plugin_update_row_win_exception',
157
+ ), 10, 2 );
158
+
159
+ }
160
+ }
161
+
162
+ }
163
+
164
+ }
165
+
166
+ }
167
+
168
+
169
+ }
170
+ }
171
+
172
+ }
173
+
174
+ }
175
+
176
+ public function wp_plugin_update_row_win_exception() {
177
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
178
+ echo '<tr class="plugin-update-tr">';
179
+ echo '<td class="plugin-update colspanchange" colspan="' . esc_attr( $wp_list_table->get_column_count() ) .
180
+ '"><div class="update-message">' . $this->win_paths_exception_message() . '</div></td>';
181
+ echo '</tr>';
182
+ }
183
+
184
+ public function prevent_plugins_update_on_updates_screen() {
185
+
186
+ if ( isset( $_REQUEST['action'] ) ) {
187
+
188
+ $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
189
+
190
+ $installer_settings = WP_Installer()->settings;
191
+
192
+ //bulk mode
193
+ if ( 'update-selected' == $action ) {
194
+
195
+ global $plugins;
196
+
197
+ if ( isset( $plugins ) && is_array( $plugins ) ) {
198
+
199
+ foreach ( $plugins as $k => $plugin ) {
200
+
201
+ $wp_plugin_slug = dirname( $plugin );
202
+
203
+ foreach ( $installer_settings['repositories'] as $repository_id => $repository ) {
204
+
205
+ if ( $this->is_win_paths_exception( $repository_id ) ) {
206
+
207
+ foreach ( $repository['data']['packages'] as $package ) {
208
+
209
+ foreach ( $package['products'] as $product ) {
210
+
211
+ foreach ( $product['plugins'] as $plugin_slug ) {
212
+
213
+ $download = $installer_settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
214
+
215
+ if ( $download['slug'] == $wp_plugin_slug && empty( $download['free-on-wporg'] ) ) {
216
+
217
+ echo '<div class="updated error"><p>' . $this->win_paths_exception_message() .
218
+ ' <strong>(' . $download['name'] . ')</strong>' . '</p></div>';
219
+ unset( $plugins[ $k ] );
220
+
221
+ break( 3 );
222
+
223
+ }
224
+
225
+ }
226
+
227
+ }
228
+
229
+ }
230
+
231
+
232
+ }
233
+
234
+ }
235
+
236
+ }
237
+
238
+ }
239
+
240
+ }
241
+
242
+
243
+ if ( 'upgrade-plugin' == $action || 'update-plugin' == $action ) {
244
+
245
+ $plugin = isset( $_REQUEST['plugin'] ) ? trim( sanitize_text_field( $_REQUEST['plugin'] ) ) : '';
246
+
247
+ $wp_plugin_slug = dirname( $plugin );
248
+
249
+ foreach ( $installer_settings['repositories'] as $repository_id => $repository ) {
250
+
251
+ if ( $this->is_win_paths_exception( $repository_id ) ) {
252
+ foreach ( $repository['data']['packages'] as $package ) {
253
+
254
+ foreach ( $package['products'] as $product ) {
255
+
256
+ foreach ( $product['plugins'] as $plugin_slug ) {
257
+ $download = $installer_settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
258
+
259
+ //match by folder, will change to match by name and folder
260
+ if ( $download['slug'] == $wp_plugin_slug && empty ( $download['free-on-wporg'] ) ) {
261
+
262
+ echo '<div class="updated error"><p>' . $this->win_paths_exception_message() . '</p></div>';
263
+
264
+ echo '<div class="wrap">';
265
+ echo '<h2>' . __( 'Update Plugin' ) . '</h2>';
266
+ echo '<a href="' . admin_url( 'update-core.php' ) . '">' . __( 'Return to the updates page', 'installer' ) . '</a>';
267
+ echo '</div>';
268
+ require_once( ABSPATH . 'wp-admin/admin-footer.php' );
269
+ exit;
270
+
271
+ }
272
+
273
+ }
274
+
275
+ }
276
+
277
+ }
278
+ }
279
+
280
+ }
281
+
282
+ }
283
+ }
284
+
285
+ }
286
+
287
+
288
+ }
289
+
290
+
291
+
vendor/otgs/installer/includes/class-installer-theme.php CHANGED
@@ -1,979 +1,979 @@
1
- <?php
2
- /**
3
- * Installer Class for Theme Support
4
- *
5
- * Supports automatic updates and installation of Toolset/WPML Themes
6
- *
7
- * @class Installer_Theme_Class
8
- * @version 1.6
9
- * @category Class
10
- * @author OnTheGoSystems
11
- */
12
-
13
- if ( !defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- /**
18
- * Installer_Theme_Class
19
- */
20
- class Installer_Theme_Class {
21
-
22
- /** Theme Repository */
23
- private $theme_repo;
24
-
25
- /** Repository API */
26
- private $repository_api;
27
-
28
- /** Repository Theme Products */
29
- private $repository_theme_products;
30
-
31
- /** Site URL */
32
- private $installer_site_url;
33
-
34
- /** Site Key */
35
- private $installer_site_key;
36
-
37
- /** The Themes Option */
38
- protected $installer_themes_option;
39
-
40
- /** Update settings */
41
- protected $installer_themes_available_updates;
42
-
43
- /** The Themes */
44
- protected $installer_themes = array();
45
-
46
- /** Repository with themes */
47
- protected $installer_repo_with_themes;
48
-
49
- /** Active tab */
50
- protected $installer_theme_active_tab;
51
-
52
- /** Theme user registration */
53
- protected $theme_user_registration;
54
-
55
- /** Client active subscription */
56
- protected $installer_theme_subscription_type;
57
-
58
- public function __construct() {
59
-
60
- /** Properties */
61
-
62
- //Get installer repositories
63
- $installer_repositories = WP_Installer()->get_repositories();
64
-
65
- //Get repos with themes
66
- $repos_with_themes = $this->installer_theme_reposities_that_has_themes( $installer_repositories );
67
-
68
- if ( is_array( $repos_with_themes ) ) {
69
- //Assign to property
70
- $this->installer_repo_with_themes = $repos_with_themes;
71
-
72
- //Let's looped through repos with themes
73
- foreach ( $repos_with_themes as $k => $repo ) {
74
-
75
- //$repo could be 'toolset' or 'wpml'
76
- //Assign each repo with theme to property
77
- $this->theme_repo[] = $repo;
78
-
79
- if ( (isset($installer_repositories[$repo]['api-url'])) && (isset($installer_repositories[$repo]['products'])) ) {
80
-
81
- //Define the rest of the properties based on the given repo
82
- $this->repository_api[$repo] = $installer_repositories[$repo]['api-url'];
83
- $this->repository_theme_products[$repo] = $installer_repositories[$repo]['products'];
84
- $this->installer_site_url[$repo] = WP_Installer()->get_installer_site_url( $repo );
85
- $this->installer_site_key[$repo] = WP_Installer()->get_site_key( $repo );
86
- $this->theme_user_registration[$repo] = false;
87
-
88
- if ( WP_Installer()->repository_has_valid_subscription( $repo ) ) {
89
-
90
- $this->installer_theme_subscription_type = WP_Installer()->get_subscription_type_for_repository( $repo );
91
- $this->installer_themes_option[$repo] = 'wp_installer_' . $repo . '_themes';
92
- $this->installer_themes_available_updates[$repo] = 'wp_installer_' . $repo . '_updated_themes';
93
- $this->installer_theme_active_tab = '';
94
-
95
- //We only set themes available to this validated subscription
96
- $this->installer_theme_available( $repo, $this->installer_theme_subscription_type );
97
-
98
- add_action( 'installer_themes_support_set_up', array($this, 'installer_theme_sets_active_tab_on_init'), 10 );
99
- $this->theme_user_registration[$repo] = true;
100
- }
101
-
102
- /** We are ready.. let's initialize .... */
103
- $this->init();
104
- }
105
- }
106
- add_action( 'installer_themes_support_set_up', array($this, 'installer_theme_loaded_hooks') );
107
- }
108
- }
109
-
110
- /** Init */
111
- public function init() {
112
- add_action( 'admin_enqueue_scripts', array($this, 'installer_theme_enqueue_scripts') );
113
- add_filter( 'themes_api', array($this, 'installer_theme_api_override'), 10, 3 );
114
- add_filter( 'themes_api_result', array($this, 'installer_theme_api_override_response'), 10, 3 );
115
- add_filter( 'site_transient_update_themes', array($this, 'installer_theme_upgrade_check'), 10, 1 );
116
- add_action( 'http_api_debug', array($this, 'installer_theme_sync_native_wp_api'), 10, 5 );
117
- add_filter( 'installer_theme_hook_response_theme', array($this, 'installer_theme_add_num_ratings'), 10, 1 );
118
- add_filter( 'themes_update_check_locales', array($this, 'installer_theme_sync_call_wp_theme_api'), 10, 1 );
119
- add_filter( 'admin_url', array($this, 'installer_theme_add_query_arg_tab'), 10, 3 );
120
- add_filter( 'network_admin_url', array($this, 'installer_theme_add_query_arg_tab'), 10, 2 );
121
- add_action( 'wp_ajax_installer_theme_frontend_selected_tab', array($this, 'installer_theme_frontend_selected_tab'), 0 );
122
- add_action( 'wp_loaded', array($this, 'installer_themes_support_set_up_func') );
123
- }
124
-
125
- /** Enqueue scripts */
126
- public function installer_theme_enqueue_scripts() {
127
- $current_screen = $this->installer_theme_current_screen();
128
- $commercial_plugin_screen = $this->installer_theme_is_commercial_plugin_screen( $current_screen );
129
- if ( ('theme-install' == $current_screen) || ($commercial_plugin_screen) || ('theme-install-network' == $current_screen) ) {
130
- $repo_with_themes = $this->installer_repo_with_themes;
131
- $js_array = array();
132
- if ( is_array( $repo_with_themes ) ) {
133
- foreach ( $repo_with_themes as $k => $v ) {
134
-
135
- //Hyperlink text
136
- $theme_repo_name = $this->installer_theme_get_repo_product_name( $v );
137
- $the_hyperlink_text = esc_js( $theme_repo_name );
138
-
139
- if ( is_multisite() ) {
140
- $admin_url_passed = network_admin_url();
141
- } else {
142
- $admin_url_passed = admin_url();
143
- }
144
-
145
- //Define
146
- $js_array[$v] = array(
147
- 'the_hyperlink_text' => $the_hyperlink_text,
148
- 'registration_status' => $this->theme_user_registration[$v],
149
- 'is_commercial_plugin_tab' => $commercial_plugin_screen,
150
- 'registration_url' => $admin_url_passed . 'plugin-install.php?tab=commercial#installer_repo_' . $v
151
- );
152
-
153
- }
154
- }
155
-
156
- if ( !(empty($js_array)) ) {
157
- wp_enqueue_script( 'installer-theme-install', WP_Installer()->res_url() . '/res/js/installer_theme_install.js', array('jquery', 'installer-admin'), WP_Installer()->version() );
158
- $installer_ajax_url = admin_url( 'admin-ajax.php' );
159
-
160
- if ( is_ssl() ) {
161
- $installer_ajax_url = str_replace( 'http://', 'https://', $installer_ajax_url );
162
- } else {
163
- $installer_ajax_url = str_replace( 'https://', 'http://', $installer_ajax_url );
164
- }
165
-
166
- //Case where user is subscribed to a subscription that does not have themes
167
- $subscription_js_check = $this->installer_theme_subscription_does_not_have_theme( $js_array );
168
-
169
- wp_localize_script( 'installer-theme-install', 'installer_theme_install_localize',
170
- array(
171
- 'js_array_installer' => $js_array,
172
- 'ajaxurl' => $installer_ajax_url,
173
- 'no_associated_themes' => $subscription_js_check,
174
- 'installer_theme_frontend_selected_tab_nonce' => wp_create_nonce( 'installer_theme_frontend_selected_tab' )
175
- )
176
- );
177
- }
178
- }
179
- }
180
-
181
- /** Case where user is subscribed to a subscription that does not have themes */
182
- protected function installer_theme_subscription_does_not_have_theme( $js_array ) {
183
-
184
- $any_subscription_has_theme = array();
185
- $number_of_registrations = array();
186
-
187
- //Step1, we looped through JS array
188
- foreach ( $js_array as $repo_slug => $js_details ) {
189
-
190
- //Step2, checked if user is registered
191
- if ( isset($this->theme_user_registration[$repo_slug]) ) {
192
- $registration_status = $this->theme_user_registration[$repo_slug];
193
- if ( $registration_status ) {
194
-
195
- //Registered
196
- $number_of_registrations[] = $repo_slug;
197
-
198
- //Step3, we checked if the $repo_slug has available theme
199
- $themes_available = false;
200
- if ( isset($this->installer_themes[$repo_slug]) ) {
201
- $themes_available = $this->installer_themes[$repo_slug];
202
- if ( !(empty($themes_available)) ) {
203
- //This subscription has theme
204
- $themes_available = true;
205
- }
206
- }
207
-
208
- if ( $themes_available ) {
209
- $any_subscription_has_theme[] = $repo_slug;
210
- }
211
- }
212
- }
213
-
214
- }
215
-
216
- //Step4, we are done looping, check if there are any repos that have themes
217
- if ( empty($registration_status) ) {
218
-
219
- //No registration on any repos
220
- return FALSE;
221
-
222
- } elseif ( !(empty($registration_status)) ) {
223
-
224
- //Has some registration on some repos
225
- //We then checked if this user has any active subscriptions
226
- if ( empty($any_subscription_has_theme) ) {
227
- //No subscription
228
- return TRUE;
229
- } else {
230
- //Has subscription found
231
- return FALSE;
232
- }
233
- }
234
- }
235
-
236
- /** Check if its the commercial plugin screen */
237
- private function installer_theme_is_commercial_plugin_screen( $current_screen ) {
238
- $commercial = false;
239
- if ( ('plugin-install' == $current_screen) || ('plugin-install-network' == $current_screen) ) {
240
- if ( isset($_GET['tab']) ) {
241
- $tab = sanitize_text_field( $_GET['tab'] );
242
- if ( 'commercial' == $tab ) {
243
- $commercial = true;
244
- }
245
- }
246
- }
247
- return $commercial;
248
- }
249
-
250
- /** Current screen */
251
- private function installer_theme_current_screen() {
252
-
253
- $current_screen_loaded = false;
254
-
255
- if ( function_exists( 'get_current_screen' ) ) {
256
-
257
- $screen_output = get_current_screen();
258
- $current_screen_loaded = $screen_output->id;
259
-
260
- }
261
-
262
- return $current_screen_loaded;
263
-
264
- }
265
-
266
- /** Override WordPress Themes API */
267
- public function installer_theme_api_override( $api_boolean, $action, $args ) {
268
-
269
- //Let's checked if user is browsing our themes
270
- if ( isset($args->browse) ) {
271
- $browse = $args->browse;
272
- if ( in_array( $browse, $this->theme_repo ) ) {
273
- //Uniquely validated for our Themes
274
- if ( 'query_themes' == $action ) {
275
- //User is querying or asking information about our themes, let's override
276
- $api_boolean = true;
277
- }
278
- }
279
- } elseif ( isset($args->slug) ) {
280
- //We are installing our themes
281
- $theme_to_install = $args->slug;
282
-
283
- //Lets uniquely validate if this belongs to us
284
- //Check if this is OTGS theme
285
- $validate_check = $this->installer_themes_belong_to_us( $theme_to_install );
286
- if ( $validate_check ) {
287
- //Belongs to us
288
- if ( !(empty($theme_to_install)) ) {
289
- $api_boolean = true;
290
- }
291
- }
292
- }
293
-
294
- return $api_boolean;
295
- }
296
-
297
- /** Override WordPress Themes API response with our own themes API*/
298
- public function installer_theme_api_override_response( $res, $action, $args ) {
299
-
300
- if ( true === $res ) {
301
- if ( isset($args->browse) ) {
302
- $browse = $args->browse;
303
- if ( in_array( $browse, $this->theme_repo ) ) {
304
- //Uniquely validated for our themes
305
- if ( 'query_themes' == $action ) {
306
- //Client querying OTGS themes
307
- //Check for registration status
308
- if ( isset($this->theme_user_registration[$browse]) ) {
309
- //Set
310
- if ( !($this->theme_user_registration[$browse]) ) {
311
- //Not registered yet
312
- $res = new stdClass();
313
- $res->info = array();
314
- $res->themes = array();
315
- return $res;
316
- } else {
317
- //Registered
318
- $themes = $this->installer_theme_get_themes( '', $browse );
319
- $res = $this->installer_theme_format_response( $themes, $action );
320
- }
321
- }
322
- }
323
- }
324
- } elseif ( isset($args->slug) ) {
325
- //We are installing theme
326
- //Lets uniquely validate if this belongs to our theme
327
- $theme_to_install = $args->slug;
328
-
329
- //Lets uniquely validate if this belongs to us
330
- //Check if this is OTGS theme
331
- $validate_check = $this->installer_themes_belong_to_us( $theme_to_install );
332
- if ( $validate_check ) {
333
- //Belongs to us
334
- if ( ($res) && ('theme_information' == $action) ) {
335
- $themes = $this->installer_theme_get_themes( '', $this->installer_theme_active_tab );
336
- $res = $this->installer_theme_format_response( $themes, $action, $args->slug );
337
- }
338
- }
339
- }
340
- return $res;
341
- } else {
342
- //Default WP Themes here
343
- $client_side_active_tab = get_option( 'wp_installer_clientside_active_tab' );
344
- if ( $client_side_active_tab ) {
345
- if ( !(in_array( $client_side_active_tab, $this->theme_repo )) ) {
346
- //Not OTGS tab
347
- return $res;
348
- }
349
- }
350
-
351
- }
352
- }
353
-
354
- /** Get Themes */
355
- private function installer_theme_get_themes( $product_url = '', $repo_source = '' ) {
356
-
357
- //Query API
358
- if ( empty($product_url) ) {
359
- //Not set
360
- if ( isset($this->repository_theme_products[$this->installer_theme_active_tab]) ) {
361
- $query_remote_url = $this->repository_theme_products[$this->installer_theme_active_tab];
362
- }
363
-
364
- } else {
365
- $query_remote_url = $product_url;
366
- }
367
-
368
- //Let's retrieved current installer settings so we won't be querying all the time
369
- $current_installer_settings = WP_Installer()->get_settings();
370
-
371
- //Set $themes to FALSE by default
372
- $themes = false;
373
-
374
- if ( (is_array( $current_installer_settings )) && (!(empty($current_installer_settings))) ) {
375
-
376
- //Set and already defined, retrieved $products
377
- if ( isset($current_installer_settings['repositories'][$repo_source]['data']) ) {
378
- $products = $current_installer_settings['repositories'][$repo_source]['data'];
379
- if ( isset($products['downloads']['themes']) ) {
380
- $themes = $products['downloads']['themes'];
381
- }
382
- }
383
-
384
- } else {
385
-
386
- //Call API
387
- $response = wp_remote_get( $query_remote_url );
388
-
389
- if ( is_wp_error( $response ) ) {
390
- //Error detected: http fallback
391
- $query_remote_url = preg_replace( "@^https://@", 'http://', $query_remote_url );
392
- $response = wp_remote_get( $query_remote_url );
393
- }
394
-
395
- if ( !(is_wp_error( $response )) ) {
396
- //Not WP error
397
- //Evaluate response
398
- if ( $response && isset($response['response']['code']) && $response['response']['code'] == 200 ) {
399
- //In this case, response is set and defined, proceed...
400
- $body = wp_remote_retrieve_body( $response );
401
- if ( $body ) {
402
- $products = json_decode( $body, true );
403
- if ( isset($products['downloads']['themes']) ) {
404
- $themes = $products['downloads']['themes'];
405
- }
406
- }
407
-
408
- }
409
- }
410
- }
411
-
412
- //Return themes, can be filtered by user subscription type
413
- return apply_filters( 'installer_theme_get_themes', $themes, $this->installer_theme_active_tab );
414
- }
415
-
416
- /** Format response in compatibility with WordPress Theme API response */
417
- private function installer_theme_format_response( $themes, $action, $slug = '' ) {
418
-
419
- //Let's append download link only when retrieving theme information for installation
420
- if ( ('theme_information' == $action) && (!(empty($slug))) ) {
421
-
422
- //Only return one result -> the theme to be installed
423
- foreach ( $themes as $k => $theme ) {
424
- if ( $slug == $theme['basename'] ) {
425
- $theme['download_link'] = WP_Installer()->append_site_key_to_download_url( $theme['url'], $this->installer_site_key[$this->installer_theme_active_tab], $this->installer_theme_active_tab );
426
- $theme = json_decode( json_encode( $theme ), FALSE );
427
- return $theme;
428
- }
429
- }
430
-
431
- } else {
432
-
433
- $res = new stdClass();
434
- $res->info = array();
435
- $res->themes = array();
436
-
437
- //Define info
438
- $res->info['page'] = 1;
439
- $res->info['pages'] = 10;
440
-
441
- //Let's count available themes ;
442
- $res->info['results'] = count( $themes );
443
-
444
- //Let's saved themes for easy access later on
445
- $this->installer_theme_savethemes_by_slug( $themes );
446
-
447
- //Let's defined available themes
448
- if ( isset($this->installer_theme_subscription_type) ) {
449
- //Has subscription type defined, let's saved what is associated with this subscription
450
- $this->installer_theme_available( $this->installer_theme_active_tab, $this->installer_theme_subscription_type );
451
- } else {
452
- $this->installer_theme_available( $this->installer_theme_active_tab );
453
- }
454
-
455
- //Let's add themes to the overriden WordPress API Theme response
456
- /** Installer 1.7.6: Update to compatible data format response from WP Theme API */
457
- $theme_compatible_array=array();
458
- if ((is_array($themes))) {
459
- foreach ($themes as $k=>$v) {
460
- $theme_compatible_array[]=(object)($v);
461
- }
462
- }
463
- $res->themes = $theme_compatible_array;
464
- $res->themes = apply_filters( 'installer_theme_hook_response_theme', $res->themes );
465
- return $res;
466
- }
467
- }
468
-
469
- /** Let's save all available themes by its slug after any latest API query */
470
- private function installer_theme_savethemes_by_slug( $themes, $doing_query = false ) {
471
-
472
- if ( !($doing_query) ) {
473
- $this->installer_themes[$this->installer_theme_active_tab] = array();
474
- }
475
-
476
- if ( !(empty($themes)) ) {
477
- $themes_for_saving = array();
478
- foreach ( $themes as $k => $theme ) {
479
- if ( !($doing_query) ) {
480
- if ( isset($theme['slug']) ) {
481
- $theme_slug = $theme['slug'];
482
- if ( !(empty($theme_slug)) ) {
483
- $themes_for_saving[] = $theme_slug;
484
- }
485
- }
486
- } else {
487
-
488
- if ( ((isset($theme['slug'])) && (isset($theme['version'])) &&
489
- (isset($theme['theme_page_url']))) && (isset($theme['url']))
490
- ) {
491
- $theme_slug = $theme['slug'];
492
- $theme_version = $theme['version'];
493
- $theme_page_url = $theme['theme_page_url'];
494
- $theme_url = $theme['url'];
495
- if ( (!(empty($theme_slug))) && (!(empty($theme_version))) &&
496
- (!(empty($theme_page_url))) && (!(empty($theme_url)))
497
- ) {
498
- //$theme_slug is unique for every theme
499
- $themes_for_saving[$theme_slug] = array(
500
- 'version' => $theme_version,
501
- 'theme_page_url' => $theme_page_url,
502
- 'url' => $theme_url
503
- );
504
-
505
- }
506
- }
507
- }
508
-
509
- }
510
-
511
- if ( !(empty($themes_for_saving)) ) {
512
- //Has themes for saving
513
- if ( !($doing_query) ) {
514
- //Not doing query
515
- $existing_themes = get_option( $this->installer_themes_option[$this->installer_theme_active_tab] );
516
- if ( !($existing_themes) ) {
517
- //Does not yet exists
518
- delete_option( $this->installer_themes_option[$this->installer_theme_active_tab] );
519
- update_option( $this->installer_themes_option[$this->installer_theme_active_tab], $themes_for_saving );
520
- } else {
521
- //exists, check if we need to update
522
- if ( $existing_themes == $themes_for_saving ) {
523
- //Equal, no need to update here
524
- } else {
525
- //Update
526
- delete_option( $this->installer_themes_option[$this->installer_theme_active_tab] );
527
- update_option( $this->installer_themes_option[$this->installer_theme_active_tab], $themes_for_saving );
528
- }
529
- }
530
- } else {
531
- //Used for query purposes only, don't save anything
532
- return $themes_for_saving;
533
- }
534
- }
535
- }
536
- }
537
-
538
- /** Available themes */
539
- private function installer_theme_available( $repo, $subscription_type = '' ) {
540
-
541
- $subscription_type = intval( $subscription_type );
542
- if ( $subscription_type > 0 ) {
543
-
544
- //Here we have a case of validated subscription
545
- //We need to set themes that is available to this subscription
546
- $themes_associated_with_subscription = $this->installer_themes[$repo] = $this->installer_theme_get_themes_by_subscription( $subscription_type, $repo );
547
- if ( !(empty($themes_associated_with_subscription)) ) {
548
- //Has themes
549
- $this->installer_themes[$repo] = $themes_associated_with_subscription;
550
- }
551
- } else {
552
-
553
- //Get themes
554
- $this->installer_themes[$repo] = get_option( $this->installer_themes_option[$repo] );
555
- }
556
- }
557
-
558
- /** Theme upgrade check */
559
- public function installer_theme_upgrade_check( $the_value ) {
560
-
561
- //Step1: Let's looped through repos with themes and check if we have updates available for them.
562
- if ( (is_array( $this->installer_repo_with_themes )) && (!(empty($this->installer_repo_with_themes))) ) {
563
- foreach ( $this->installer_repo_with_themes as $k => $repo_slug ) {
564
- //Step2: Let's checked if we have update for this theme
565
- $update_available = get_option( $this->installer_themes_available_updates[$repo_slug] );
566
- if ( $update_available ) {
567
- if ( (is_array( $update_available )) && (!(empty($update_available))) ) {
568
- //Has updates available coming from this specific theme repo
569
- //Let's loop through the themes that needs update
570
- foreach ( $update_available as $theme_slug => $v ) {
571
- //Add to response API
572
- $the_value->response [$theme_slug] = array(
573
- 'theme' => $theme_slug,
574
- 'new_version' => $v['new_version'],
575
- 'url' => $v['url'],
576
- 'package' => $v['package']
577
- );
578
- }
579
- }
580
- }
581
- }
582
- }
583
- //Return
584
- return $the_value;
585
- }
586
-
587
- /** Return repositories that has themes */
588
- private function installer_theme_reposities_that_has_themes( $repositories, $ret_value = true, $doing_api_query = false ) {
589
-
590
- $repositories_with_themes = array();
591
-
592
- if ( (is_array( $repositories )) && (!(empty($repositories))) ) {
593
-
594
- //Let's checked if we have something before
595
- $themes = get_option( 'installer_repositories_with_theme' );
596
-
597
- if ( (!($themes)) || ($doing_api_query) ) {
598
- //Not yet defined
599
- //Loop through each repositories and check whether they have themes
600
- foreach ( $repositories as $k => $v ) {
601
- if ( isset($v['products']) ) {
602
- $products_url = $v['products'];
603
- $themes = $this->installer_theme_get_themes( $products_url, $k );
604
- if ( (is_array( $themes )) && (!(empty($themes))) ) {
605
- //Repo has themes
606
- $repositories_with_themes[] = $k;
607
- }
608
- }
609
- }
610
- } else {
611
- //Already set
612
- $repositories_with_themes = $themes;
613
- }
614
-
615
- if ( (((is_array( $repositories_with_themes )) && (!(empty($repositories_with_themes)))) && (!($themes))) || ($doing_api_query) ) {
616
- //Save to db
617
- update_option( 'installer_repositories_with_theme', $repositories_with_themes );
618
- }
619
- }
620
-
621
- if ( $ret_value ) {
622
- return $repositories_with_themes;
623
- }
624
-
625
- }
626
-
627
- /** When WordPress queries its own Themes API, we sync with our own */
628
- public function installer_theme_sync_native_wp_api( $response, $responsetext, $class, $args, $url ) {
629
-
630
- $api_native_string = 'api.wordpress.org/themes/';
631
- if ( (strpos( $url, $api_native_string ) !== false) ) {
632
- //WordPress is querying its own themes API
633
- $installer_repositories = WP_Installer()->get_repositories();
634
-
635
- //Query our own API and update repository values too
636
- $this->installer_theme_reposities_that_has_themes( $installer_repositories, false, true );
637
- }
638
- }
639
-
640
- /** Returns product name by theme repo slug */
641
- private function installer_theme_get_repo_product_name( $theme_repo ) {
642
-
643
- $theme_repo_name = false;
644
-
645
- if ( isset(WP_Installer()->settings['repositories'][$theme_repo]['data']['product-name']) ) {
646
- //Set
647
- $prod_name = WP_Installer()->settings['repositories'][$theme_repo]['data']['product-name'];
648
- if ( !(empty($prod_name)) ) {
649
- $theme_repo_name = $prod_name;
650
- }
651
- } else {
652
- //Not yet
653
- if ( $theme_repo == $this->theme_repo ) {
654
- $result = $this->installer_theme_general_api_query();
655
- if ( isset($result['product-name']) ) {
656
- $product_name = $result['product-name'];
657
- if ( !(empty($product_name)) ) {
658
- $theme_repo_name = $product_name;
659
- }
660
- }
661
- }
662
- }
663
-
664
- return $theme_repo_name;
665
- }
666
-
667
- /** General query API method, returns $products */
668
- private function installer_theme_general_api_query() {
669
- $products = false;
670
- $response = wp_remote_get( $this->repository_theme_products );
671
- if ( !(is_wp_error( $response )) ) {
672
- //Not WP error
673
- //Evaluate response
674
- if ( $response && isset($response['response']['code']) && $response['response']['code'] == 200 ) {
675
- //In this case, response is set and defined, proceed...
676
- $body = wp_remote_retrieve_body( $response );
677
- if ( $body ) {
678
- $result = json_decode( $body, true );
679
- if ( (is_array( $result )) && (!(empty($result))) ) {
680
- $products = $result;
681
- }
682
- }
683
-
684
- }
685
- }
686
-
687
- return $products;
688
- }
689
-
690
- /** General method to check if themes are OTGS themes based on its slug*/
691
- private function installer_themes_belong_to_us( $theme_slug ) {
692
-
693
- $found = false;
694
- $theme_slug = trim( $theme_slug );
695
-
696
- foreach ( $this->installer_themes as $repo_with_theme => $themes ) {
697
- foreach ( $themes as $k => $otgs_theme_slug ) {
698
- if ( $theme_slug == $otgs_theme_slug ) {
699
- //match found! Theme belongs to otgs
700
- return true;
701
- }
702
- }
703
- }
704
- return $found;
705
-
706
- }
707
-
708
- /** Sets active tab on init */
709
- public function installer_theme_sets_active_tab_on_init() {
710
-
711
- if ( isset ($_SERVER ['REQUEST_URI']) ) {
712
- $request_uri = $_SERVER ['REQUEST_URI'];
713
- if ( isset ($_GET ['browse']) ) {
714
- $active_tab = sanitize_text_field( $_GET['browse'] );
715
- $this->installer_theme_active_tab = $active_tab;
716
- } elseif ( isset ($_POST ['request'] ['browse']) ) {
717
- $active_tab = sanitize_text_field ( $_POST['request']['browse'] );
718
- $this->installer_theme_active_tab = $active_tab;
719
- } elseif ( (isset ($_GET ['theme_repo'])) && (isset ($_GET ['action'])) ) {
720
- $theme_repo = sanitize_text_field( $_GET['theme_repo'] );
721
- $the_action = sanitize_text_field( $_GET['action'] );
722
- if ( ('install-theme' == $the_action) && (!(empty($theme_repo))) ) {
723
- $this->installer_theme_active_tab = $theme_repo;
724
- }
725
- } elseif ( wp_get_referer() ) {
726
- $referer = wp_get_referer();
727
- $parts = parse_url( $referer );
728
- if ( isset($parts['query']) ) {
729
- parse_str( $parts['query'], $query );
730
- if ( isset($query['browse']) ) {
731
- $this->installer_theme_active_tab = $query['browse'];
732
- }
733
- }
734
- }
735
- }
736
- }
737
-
738
- /** WP Theme API compatibility- added num ratings */
739
- /** Installer 1.7.6+ Added updated 'rating' field */
740
- public function installer_theme_add_num_ratings( $themes ) {
741
-
742
- if ( (is_array( $themes )) && (!(empty($themes))) ) {
743
- foreach ( $themes as $k => $v ) {
744
- if ( !(isset($v->num_ratings)) ) {
745
- $themes[$k]->num_ratings = 100;
746
- }
747
- if ( !(isset($v->rating)) ) {
748
- $themes[$k]->rating = 100;
749
- }
750
- }
751
- }
752
-
753
- return $themes;
754
- }
755
-
756
- /** When WordPress.org makes a call to its repository, let's run our own upgrade checks too */
757
- public function installer_theme_sync_call_wp_theme_api( $locales ) {
758
-
759
- $this->installer_theme_upgrade_theme_check();
760
-
761
- return $locales;
762
- }
763
-
764
- /** Upgrade theme check */
765
- private function installer_theme_upgrade_theme_check() {
766
-
767
- // Step1-> we get all installed themes in clients local themes directory
768
- $installed_themes = wp_get_themes();
769
-
770
- // Step2: We need to loop through each repository with themes
771
- foreach ( $this->installer_repo_with_themes as $k => $repo_slug ) {
772
-
773
- // We then need to retrieved the products URL for each of this repo
774
- $products_url = $this->repository_theme_products [$repo_slug];
775
-
776
- // Step3-> we get all available themes in our repository via API based on this URL
777
- $available_themes = $this->installer_theme_get_themes( $products_url, $repo_slug );
778
-
779
- if ( !($available_themes) ) {
780
-
781
- // API is not available as of the moment, return..
782
- return;
783
- } else {
784
-
785
- // We have available themes here...
786
- // Step4->let's simplify available themes data by slugs
787
- $simplified_available_themes = $this->installer_theme_savethemes_by_slug( $available_themes, true );
788
-
789
- // Step5->Let's loop through installed themes
790
- if ( (is_array( $installed_themes )) && (!(empty ($installed_themes))) ) {
791
- $otgs_theme_updates_available = array();
792
- foreach ( $installed_themes as $theme_slug => $theme_object ) {
793
- if ( array_key_exists( $theme_slug, $simplified_available_themes ) ) {
794
-
795
- // This is our theme
796
- // Step6->Let's get version of the local theme installed
797
- $local_version = $theme_object->get( 'Version' );
798
-
799
- // Step7->Let's get the latest version of this theme, page URL and download URL from our repository
800
- $repository_version = $simplified_available_themes [$theme_slug] ['version'];
801
- $theme_page_url = $simplified_available_themes [$theme_slug] ['theme_page_url'];
802
- $theme_download_url = $simplified_available_themes [$theme_slug] ['url'];
803
-
804
- // Step8->Let's compare the version
805
- if ( version_compare( $repository_version, $local_version, '>' ) ) {
806
-
807
- // Update available for this theme
808
- // Step9-> Define download URL with site key
809
- $package_url = WP_Installer()->append_site_key_to_download_url( $theme_download_url, $this->installer_site_key [$repo_slug], $repo_slug );
810
-
811
- //Step10-> Assign to updates array for later accessing.
812
- $otgs_theme_updates_available[$theme_slug] = array(
813
- 'theme' => $theme_slug,
814
- 'new_version' => $repository_version,
815
- 'url' => $theme_page_url,
816
- 'package' => $package_url
817
- );
818
- }
819
- }
820
- }
821
- //Exited the upgrade loop for this specific theme repository
822
- if ( !(empty($otgs_theme_updates_available)) ) {
823
- //Has updates
824
- update_option( $this->installer_themes_available_updates[$repo_slug], $otgs_theme_updates_available );
825
- } else {
826
- //No updates
827
- delete_option( $this->installer_themes_available_updates[$repo_slug] );
828
- }
829
-
830
- }
831
- }
832
- }
833
- }
834
-
835
- /** When the user is on Themes install page OTG themes repository, let's the currently selected tab */
836
- public function installer_theme_add_query_arg_tab( $url, $path, $blog_id = null ) {
837
-
838
- $wp_install_string = 'update.php?action=install-theme';
839
- if ( $path == $wp_install_string ) {
840
- if ( isset($this->installer_theme_active_tab) ) {
841
- if ( !(empty($this->installer_theme_active_tab)) ) {
842
- $url = add_query_arg( array(
843
- 'theme_repo' => $this->installer_theme_active_tab
844
- ), $url );
845
- }
846
- }
847
- }
848
- return $url;
849
- }
850
-
851
- /** Save frontend theme tab selected */
852
- public function installer_theme_frontend_selected_tab() {
853
- if ( isset($_POST["frontend_tab_selected"]) ) {
854
- check_ajax_referer( 'installer_theme_frontend_selected_tab', 'installer_theme_frontend_selected_tab_nonce' );
855
-
856
- //Client_side_active_tab
857
- $frontend_tab_selected = sanitize_text_field( $_POST['frontend_tab_selected'] );
858
- if ( !(empty($frontend_tab_selected)) ) {
859
- //Front end tab selected
860
- update_option( 'wp_installer_clientside_active_tab', $frontend_tab_selected, false );
861
-
862
- //Check for registration status
863
- if ( isset($this->theme_user_registration[$frontend_tab_selected]) ) {
864
- //Set
865
- if ( !($this->theme_user_registration[$frontend_tab_selected]) ) {
866
- //Not registered yet
867
-
868
- if ( is_multisite() ) {
869
- $admin_url_passed = network_admin_url();
870
- } else {
871
- $admin_url_passed = admin_url();
872
- }
873
-
874
- $registration_url = $admin_url_passed . 'plugin-install.php?tab=commercial#installer_repo_' . $frontend_tab_selected;
875
-
876
- //Message and link
877
- $theme_repo_name = $this->installer_theme_get_repo_product_name( $frontend_tab_selected );;
878
- $response['unregistered_messages'] = sprintf( __( 'To install and update %s, please %sregister%s %s for this site.', 'installer' ),
879
- $theme_repo_name, '<a href="' . $registration_url . '">', '</a>', $theme_repo_name );
880
-
881
- }
882
- }
883
-
884
- $response['output'] = $frontend_tab_selected;
885
- echo json_encode( $response );
886
- }
887
- die();
888
- }
889
- die();
890
- }
891
-
892
- /** Installer loaded aux hooks */
893
- public function installer_theme_loaded_hooks() {
894
-
895
- if ( isset($this->installer_theme_subscription_type) ) {
896
- $subscription_type = intval( $this->installer_theme_subscription_type );
897
- if ( $subscription_type > 0 ) {
898
- //Client is subscribed
899
- add_filter( 'installer_theme_get_themes', array($this, 'installer_theme_filter_themes_by_subscription'), 10, 2 );
900
- }
901
- }
902
-
903
- }
904
-
905
- /** Get themes by subscription type */
906
- protected function installer_theme_get_themes_by_subscription( $subscription_type, $repo ) {
907
-
908
- $themes_associated_with_subscription = array();
909
- if ( isset(WP_Installer()->settings['repositories'][$repo]['data']['packages']) ) {
910
- //Set
911
- $packages = WP_Installer()->settings['repositories'][$repo]['data']['packages'];
912
- $available_themes_subscription = array();
913
- foreach ( $packages as $package_id => $package_details ) {
914
- if ( isset($package_details['products']) ) {
915
- $the_products = $package_details['products'];
916
- foreach ( $the_products as $product_slug => $product_details ) {
917
- if ( isset($product_details['subscription_type']) ) {
918
- $subscription_type_from_settings = intval( $product_details['subscription_type'] );
919
- if ( $subscription_type_from_settings == $subscription_type ) {
920
- //We found the subscription
921
- if ( isset($product_details['themes']) ) {
922
- $themes_associated_with_subscription = $product_details['themes'];
923
- return $themes_associated_with_subscription;
924
- }
925
- }
926
- }
927
-
928
- }
929
- }
930
- }
931
- }
932
- return $themes_associated_with_subscription;
933
- }
934
-
935
- /** Filter API theme response according to user subscription */
936
- public function installer_theme_filter_themes_by_subscription( $themes, $active_tab ) {
937
-
938
- //Step1, we only filter OTGS themes
939
- $orig = count( $themes );
940
- if ( in_array( $active_tab, $this->theme_repo ) ) {
941
- //OTGS Theme
942
- //Step2, we retrieved the available themes based on client subscription
943
- if ( isset($this->installer_themes[$active_tab]) ) {
944
- $available_themes = $this->installer_themes[$active_tab];
945
- //Step3, we filter $themes based on this info
946
- if ( (is_array( $themes )) && (!(empty($themes))) ) {
947
- foreach ( $themes as $k => $theme ) {
948
- //Step4, get theme slug
949
- if ( isset($theme['slug']) ) {
950
- $theme_slug = $theme['slug'];
951
- if ( !(empty($theme_slug)) ) {
952
- if ( !(in_array( $theme_slug, $available_themes )) ) {
953
- //This theme is not in available themes
954
- unset($themes[$k]);
955
- }
956
- }
957
- }
958
- }
959
- }
960
- }
961
- }
962
- $new = count( $themes );
963
- if ( $orig != $new ) {
964
- //It is filtered
965
- $themes = array_values( $themes );
966
- }
967
-
968
- return $themes;
969
- }
970
-
971
- /** Hook to wp_loaded, fires when all Installer theme class is ready */
972
- public function installer_themes_support_set_up_func() {
973
- do_action( 'installer_themes_support_set_up' );
974
- }
975
-
976
- }
977
-
978
- /** Instantiate Installer Theme Class */
979
  new Installer_Theme_Class;
1
+ <?php
2
+ /**
3
+ * Installer Class for Theme Support
4
+ *
5
+ * Supports automatic updates and installation of Toolset/WPML Themes
6
+ *
7
+ * @class Installer_Theme_Class
8
+ * @version 1.6
9
+ * @category Class
10
+ * @author OnTheGoSystems
11
+ */
12
+
13
+ if ( !defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Installer_Theme_Class
19
+ */
20
+ class Installer_Theme_Class {
21
+
22
+ /** Theme Repository */
23
+ private $theme_repo;
24
+
25
+ /** Repository API */
26
+ private $repository_api;
27
+
28
+ /** Repository Theme Products */
29
+ private $repository_theme_products;
30
+
31
+ /** Site URL */
32
+ private $installer_site_url;
33
+
34
+ /** Site Key */
35
+ private $installer_site_key;
36
+
37
+ /** The Themes Option */
38
+ protected $installer_themes_option;
39
+
40
+ /** Update settings */
41
+ protected $installer_themes_available_updates;
42
+
43
+ /** The Themes */
44
+ protected $installer_themes = array();
45
+
46
+ /** Repository with themes */
47
+ protected $installer_repo_with_themes;
48
+
49
+ /** Active tab */
50
+ protected $installer_theme_active_tab;
51
+
52
+ /** Theme user registration */
53
+ protected $theme_user_registration;
54
+
55
+ /** Client active subscription */
56
+ protected $installer_theme_subscription_type;
57
+
58
+ public function __construct() {
59
+
60
+ /** Properties */
61
+
62
+ //Get installer repositories
63
+ $installer_repositories = WP_Installer()->get_repositories();
64
+
65
+ //Get repos with themes
66
+ $repos_with_themes = $this->installer_theme_reposities_that_has_themes( $installer_repositories );
67
+
68
+ if ( is_array( $repos_with_themes ) ) {
69
+ //Assign to property
70
+ $this->installer_repo_with_themes = $repos_with_themes;
71
+
72
+ //Let's looped through repos with themes
73
+ foreach ( $repos_with_themes as $k => $repo ) {
74
+
75
+ //$repo could be 'toolset' or 'wpml'
76
+ //Assign each repo with theme to property
77
+ $this->theme_repo[] = $repo;
78
+
79
+ if ( (isset($installer_repositories[$repo]['api-url'])) && (isset($installer_repositories[$repo]['products'])) ) {
80
+
81
+ //Define the rest of the properties based on the given repo
82
+ $this->repository_api[$repo] = $installer_repositories[$repo]['api-url'];
83
+ $this->repository_theme_products[$repo] = $installer_repositories[$repo]['products'];
84
+ $this->installer_site_url[$repo] = WP_Installer()->get_installer_site_url( $repo );
85
+ $this->installer_site_key[$repo] = WP_Installer()->get_site_key( $repo );
86
+ $this->theme_user_registration[$repo] = false;
87
+
88
+ if ( WP_Installer()->repository_has_valid_subscription( $repo ) ) {
89
+
90
+ $this->installer_theme_subscription_type = WP_Installer()->get_subscription_type_for_repository( $repo );
91
+ $this->installer_themes_option[$repo] = 'wp_installer_' . $repo . '_themes';
92
+ $this->installer_themes_available_updates[$repo] = 'wp_installer_' . $repo . '_updated_themes';
93
+ $this->installer_theme_active_tab = '';
94
+
95
+ //We only set themes available to this validated subscription
96
+ $this->installer_theme_available( $repo, $this->installer_theme_subscription_type );
97
+
98
+ add_action( 'installer_themes_support_set_up', array($this, 'installer_theme_sets_active_tab_on_init'), 10 );
99
+ $this->theme_user_registration[$repo] = true;
100
+ }
101
+
102
+ /** We are ready.. let's initialize .... */
103
+ $this->init();
104
+ }
105
+ }
106
+ add_action( 'installer_themes_support_set_up', array($this, 'installer_theme_loaded_hooks') );
107
+ }
108
+ }
109
+
110
+ /** Init */
111
+ public function init() {
112
+ add_action( 'admin_enqueue_scripts', array($this, 'installer_theme_enqueue_scripts') );
113
+ add_filter( 'themes_api', array($this, 'installer_theme_api_override'), 10, 3 );
114
+ add_filter( 'themes_api_result', array($this, 'installer_theme_api_override_response'), 10, 3 );
115
+ add_filter( 'site_transient_update_themes', array($this, 'installer_theme_upgrade_check'), 10, 1 );
116
+ add_action( 'http_api_debug', array($this, 'installer_theme_sync_native_wp_api'), 10, 5 );
117
+ add_filter( 'installer_theme_hook_response_theme', array($this, 'installer_theme_add_num_ratings'), 10, 1 );
118
+ add_filter( 'themes_update_check_locales', array($this, 'installer_theme_sync_call_wp_theme_api'), 10, 1 );
119
+ add_filter( 'admin_url', array($this, 'installer_theme_add_query_arg_tab'), 10, 3 );
120
+ add_filter( 'network_admin_url', array($this, 'installer_theme_add_query_arg_tab'), 10, 2 );
121
+ add_action( 'wp_ajax_installer_theme_frontend_selected_tab', array($this, 'installer_theme_frontend_selected_tab'), 0 );
122
+ add_action( 'wp_loaded', array($this, 'installer_themes_support_set_up_func') );
123
+ }
124
+
125
+ /** Enqueue scripts */
126
+ public function installer_theme_enqueue_scripts() {
127
+ $current_screen = $this->installer_theme_current_screen();
128
+ $commercial_plugin_screen = $this->installer_theme_is_commercial_plugin_screen( $current_screen );
129
+ if ( ('theme-install' == $current_screen) || ($commercial_plugin_screen) || ('theme-install-network' == $current_screen) ) {
130
+ $repo_with_themes = $this->installer_repo_with_themes;
131
+ $js_array = array();
132
+ if ( is_array( $repo_with_themes ) ) {
133
+ foreach ( $repo_with_themes as $k => $v ) {
134
+
135
+ //Hyperlink text
136
+ $theme_repo_name = $this->installer_theme_get_repo_product_name( $v );
137
+ $the_hyperlink_text = esc_js( $theme_repo_name );
138
+
139
+ if ( is_multisite() ) {
140
+ $admin_url_passed = network_admin_url();
141
+ } else {
142
+ $admin_url_passed = admin_url();
143
+ }
144
+
145
+ //Define
146
+ $js_array[$v] = array(
147
+ 'the_hyperlink_text' => $the_hyperlink_text,
148
+ 'registration_status' => $this->theme_user_registration[$v],
149
+ 'is_commercial_plugin_tab' => $commercial_plugin_screen,
150
+ 'registration_url' => $admin_url_passed . 'plugin-install.php?tab=commercial#installer_repo_' . $v
151
+ );
152
+
153
+ }
154
+ }
155
+
156
+ if ( !(empty($js_array)) ) {
157
+ wp_enqueue_script( 'installer-theme-install', WP_Installer()->res_url() . '/res/js/installer_theme_install.js', array('jquery', 'installer-admin'), WP_Installer()->version() );
158
+ $installer_ajax_url = admin_url( 'admin-ajax.php' );
159
+
160
+ if ( is_ssl() ) {
161
+ $installer_ajax_url = str_replace( 'http://', 'https://', $installer_ajax_url );
162
+ } else {
163
+ $installer_ajax_url = str_replace( 'https://', 'http://', $installer_ajax_url );
164
+ }
165
+
166
+ //Case where user is subscribed to a subscription that does not have themes
167
+ $subscription_js_check = $this->installer_theme_subscription_does_not_have_theme( $js_array );
168
+
169
+ wp_localize_script( 'installer-theme-install', 'installer_theme_install_localize',
170
+ array(
171
+ 'js_array_installer' => $js_array,
172
+ 'ajaxurl' => $installer_ajax_url,
173
+ 'no_associated_themes' => $subscription_js_check,
174
+ 'installer_theme_frontend_selected_tab_nonce' => wp_create_nonce( 'installer_theme_frontend_selected_tab' )
175
+ )
176
+ );
177
+ }
178
+ }
179
+ }
180
+
181
+ /** Case where user is subscribed to a subscription that does not have themes */
182
+ protected function installer_theme_subscription_does_not_have_theme( $js_array ) {
183
+
184
+ $any_subscription_has_theme = array();
185
+ $number_of_registrations = array();
186
+
187
+ //Step1, we looped through JS array
188
+ foreach ( $js_array as $repo_slug => $js_details ) {
189
+
190
+ //Step2, checked if user is registered
191
+ if ( isset($this->theme_user_registration[$repo_slug]) ) {
192
+ $registration_status = $this->theme_user_registration[$repo_slug];
193
+ if ( $registration_status ) {
194
+
195
+ //Registered
196
+ $number_of_registrations[] = $repo_slug;
197
+
198
+ //Step3, we checked if the $repo_slug has available theme
199
+ $themes_available = false;
200
+ if ( isset($this->installer_themes[$repo_slug]) ) {
201
+ $themes_available = $this->installer_themes[$repo_slug];
202
+ if ( !(empty($themes_available)) ) {
203
+ //This subscription has theme
204
+ $themes_available = true;
205
+ }
206
+ }
207
+
208
+ if ( $themes_available ) {
209
+ $any_subscription_has_theme[] = $repo_slug;
210
+ }
211
+ }
212
+ }
213
+
214
+ }
215
+
216
+ //Step4, we are done looping, check if there are any repos that have themes
217
+ if ( empty($registration_status) ) {
218
+
219
+ //No registration on any repos
220
+ return FALSE;
221
+
222
+ } elseif ( !(empty($registration_status)) ) {
223
+
224
+ //Has some registration on some repos
225
+ //We then checked if this user has any active subscriptions
226
+ if ( empty($any_subscription_has_theme) ) {
227
+ //No subscription
228
+ return TRUE;
229
+ } else {
230
+ //Has subscription found
231
+ return FALSE;
232
+ }
233
+ }
234
+ }
235
+
236
+ /** Check if its the commercial plugin screen */
237
+ private function installer_theme_is_commercial_plugin_screen( $current_screen ) {
238
+ $commercial = false;
239
+ if ( ('plugin-install' == $current_screen) || ('plugin-install-network' == $current_screen) ) {
240
+ if ( isset($_GET['tab']) ) {
241
+ $tab = sanitize_text_field( $_GET['tab'] );
242
+ if ( 'commercial' == $tab ) {
243
+ $commercial = true;
244
+ }
245
+ }
246
+ }
247
+ return $commercial;
248
+ }
249
+
250
+ /** Current screen */
251
+ private function installer_theme_current_screen() {
252
+
253
+ $current_screen_loaded = false;
254
+
255
+ if ( function_exists( 'get_current_screen' ) ) {
256
+
257
+ $screen_output = get_current_screen();
258
+ $current_screen_loaded = $screen_output->id;
259
+
260
+ }
261
+
262
+ return $current_screen_loaded;
263
+
264
+ }
265
+
266
+ /** Override WordPress Themes API */
267
+ public function installer_theme_api_override( $api_boolean, $action, $args ) {
268
+
269
+ //Let's checked if user is browsing our themes
270
+ if ( isset($args->browse) ) {
271
+ $browse = $args->browse;
272
+ if ( in_array( $browse, $this->theme_repo ) ) {
273
+ //Uniquely validated for our Themes
274
+ if ( 'query_themes' == $action ) {
275
+ //User is querying or asking information about our themes, let's override
276
+ $api_boolean = true;
277
+ }
278
+ }
279
+ } elseif ( isset($args->slug) ) {
280
+ //We are installing our themes
281
+ $theme_to_install = $args->slug;
282
+
283
+ //Lets uniquely validate if this belongs to us
284
+ //Check if this is OTGS theme
285
+ $validate_check = $this->installer_themes_belong_to_us( $theme_to_install );
286
+ if ( $validate_check ) {
287
+ //Belongs to us
288
+ if ( !(empty($theme_to_install)) ) {
289
+ $api_boolean = true;
290
+ }
291
+ }
292
+ }
293
+
294
+ return $api_boolean;
295
+ }
296
+
297
+ /** Override WordPress Themes API response with our own themes API*/
298
+ public function installer_theme_api_override_response( $res, $action, $args ) {
299
+
300
+ if ( true === $res ) {
301
+ if ( isset($args->browse) ) {
302
+ $browse = $args->browse;
303
+ if ( in_array( $browse, $this->theme_repo ) ) {
304
+ //Uniquely validated for our themes
305
+ if ( 'query_themes' == $action ) {
306
+ //Client querying OTGS themes
307
+ //Check for registration status
308
+ if ( isset($this->theme_user_registration[$browse]) ) {
309
+ //Set
310
+ if ( !($this->theme_user_registration[$browse]) ) {
311
+ //Not registered yet
312
+ $res = new stdClass();
313
+ $res->info = array();
314
+ $res->themes = array();
315
+ return $res;
316
+ } else {
317
+ //Registered
318
+ $themes = $this->installer_theme_get_themes( '', $browse );
319
+ $res = $this->installer_theme_format_response( $themes, $action );
320
+ }
321
+ }
322
+ }
323
+ }
324
+ } elseif ( isset($args->slug) ) {
325
+ //We are installing theme
326
+ //Lets uniquely validate if this belongs to our theme
327
+ $theme_to_install = $args->slug;
328
+
329
+ //Lets uniquely validate if this belongs to us
330
+ //Check if this is OTGS theme
331
+ $validate_check = $this->installer_themes_belong_to_us( $theme_to_install );
332
+ if ( $validate_check ) {
333
+ //Belongs to us
334
+ if ( ($res) && ('theme_information' == $action) ) {
335
+ $themes = $this->installer_theme_get_themes( '', $this->installer_theme_active_tab );
336
+ $res = $this->installer_theme_format_response( $themes, $action, $args->slug );
337
+ }
338
+ }
339
+ }
340
+ return $res;
341
+ } else {
342
+ //Default WP Themes here
343
+ $client_side_active_tab = get_option( 'wp_installer_clientside_active_tab' );
344
+ if ( $client_side_active_tab ) {
345
+ if ( !(in_array( $client_side_active_tab, $this->theme_repo )) ) {
346
+ //Not OTGS tab
347
+ return $res;
348
+ }
349
+ }
350
+
351
+ }
352
+ }
353
+
354
+ /** Get Themes */
355
+ private function installer_theme_get_themes( $product_url = '', $repo_source = '' ) {
356
+
357
+ //Query API
358
+ if ( empty($product_url) ) {
359
+ //Not set
360
+ if ( isset($this->repository_theme_products[$this->installer_theme_active_tab]) ) {
361
+ $query_remote_url = $this->repository_theme_products[$this->installer_theme_active_tab];
362
+ }
363
+
364
+ } else {
365
+ $query_remote_url = $product_url;
366
+ }
367
+
368
+ //Let's retrieved current installer settings so we won't be querying all the time
369
+ $current_installer_settings = WP_Installer()->get_settings();
370
+
371
+ //Set $themes to FALSE by default
372
+ $themes = false;
373
+
374
+ if ( (is_array( $current_installer_settings )) && (!(empty($current_installer_settings))) ) {
375
+
376
+ //Set and already defined, retrieved $products
377
+ if ( isset($current_installer_settings['repositories'][$repo_source]['data']) ) {
378
+ $products = $current_installer_settings['repositories'][$repo_source]['data'];
379
+ if ( isset($products['downloads']['themes']) ) {
380
+ $themes = $products['downloads']['themes'];
381
+ }
382
+ }
383
+
384
+ } else {
385
+
386
+ //Call API
387
+ $response = wp_remote_get( $query_remote_url );
388
+
389
+ if ( is_wp_error( $response ) ) {
390
+ //Error detected: http fallback
391
+ $query_remote_url = preg_replace( "@^https://@", 'http://', $query_remote_url );
392
+ $response = wp_remote_get( $query_remote_url );
393
+ }
394
+
395
+ if ( !(is_wp_error( $response )) ) {
396
+ //Not WP error
397
+ //Evaluate response
398
+ if ( $response && isset($response['response']['code']) && $response['response']['code'] == 200 ) {
399
+ //In this case, response is set and defined, proceed...
400
+ $body = wp_remote_retrieve_body( $response );
401
+ if ( $body ) {
402
+ $products = json_decode( $body, true );
403
+ if ( isset($products['downloads']['themes']) ) {
404
+ $themes = $products['downloads']['themes'];
405
+ }
406
+ }
407
+
408
+ }
409
+ }
410
+ }
411
+
412
+ //Return themes, can be filtered by user subscription type
413
+ return apply_filters( 'installer_theme_get_themes', $themes, $this->installer_theme_active_tab );
414
+ }
415
+
416
+ /** Format response in compatibility with WordPress Theme API response */
417
+ private function installer_theme_format_response( $themes, $action, $slug = '' ) {
418
+
419
+ //Let's append download link only when retrieving theme information for installation
420
+ if ( ('theme_information' == $action) && (!(empty($slug))) ) {
421
+
422
+ //Only return one result -> the theme to be installed
423
+ foreach ( $themes as $k => $theme ) {
424
+ if ( $slug == $theme['basename'] ) {
425
+ $theme['download_link'] = WP_Installer()->append_site_key_to_download_url( $theme['url'], $this->installer_site_key[$this->installer_theme_active_tab], $this->installer_theme_active_tab );
426
+ $theme = json_decode( json_encode( $theme ), FALSE );
427
+ return $theme;
428
+ }
429
+ }
430
+
431
+ } else {
432
+
433
+ $res = new stdClass();
434
+ $res->info = array();
435
+ $res->themes = array();
436
+
437
+ //Define info
438
+ $res->info['page'] = 1;
439
+ $res->info['pages'] = 10;
440
+
441
+ //Let's count available themes ;
442
+ $res->info['results'] = count( $themes );
443
+
444
+ //Let's saved themes for easy access later on
445
+ $this->installer_theme_savethemes_by_slug( $themes );
446
+
447
+ //Let's defined available themes
448
+ if ( isset($this->installer_theme_subscription_type) ) {
449
+ //Has subscription type defined, let's saved what is associated with this subscription
450
+ $this->installer_theme_available( $this->installer_theme_active_tab, $this->installer_theme_subscription_type );
451
+ } else {
452
+ $this->installer_theme_available( $this->installer_theme_active_tab );
453
+ }
454
+
455
+ //Let's add themes to the overriden WordPress API Theme response
456
+ /** Installer 1.7.6: Update to compatible data format response from WP Theme API */
457
+ $theme_compatible_array=array();
458
+ if ((is_array($themes))) {
459
+ foreach ($themes as $k=>$v) {
460
+ $theme_compatible_array[]=(object)($v);
461
+ }
462
+ }
463
+ $res->themes = $theme_compatible_array;
464
+ $res->themes = apply_filters( 'installer_theme_hook_response_theme', $res->themes );
465
+ return $res;
466
+ }
467
+ }
468
+
469
+ /** Let's save all available themes by its slug after any latest API query */
470
+ private function installer_theme_savethemes_by_slug( $themes, $doing_query = false ) {
471
+
472
+ if ( !($doing_query) ) {
473
+ $this->installer_themes[$this->installer_theme_active_tab] = array();
474
+ }
475
+
476
+ if ( !(empty($themes)) ) {
477
+ $themes_for_saving = array();
478
+ foreach ( $themes as $k => $theme ) {
479
+ if ( !($doing_query) ) {
480
+ if ( isset($theme['slug']) ) {
481
+ $theme_slug = $theme['slug'];
482
+ if ( !(empty($theme_slug)) ) {
483
+ $themes_for_saving[] = $theme_slug;
484
+ }
485
+ }
486
+ } else {
487
+
488
+ if ( ((isset($theme['slug'])) && (isset($theme['version'])) &&
489
+ (isset($theme['theme_page_url']))) && (isset($theme['url']))
490
+ ) {
491
+ $theme_slug = $theme['slug'];
492
+ $theme_version = $theme['version'];
493
+ $theme_page_url = $theme['theme_page_url'];
494
+ $theme_url = $theme['url'];
495
+ if ( (!(empty($theme_slug))) && (!(empty($theme_version))) &&
496
+ (!(empty($theme_page_url))) && (!(empty($theme_url)))
497
+ ) {
498
+ //$theme_slug is unique for every theme
499
+ $themes_for_saving[$theme_slug] = array(
500
+ 'version' => $theme_version,
501
+ 'theme_page_url' => $theme_page_url,
502
+ 'url' => $theme_url
503
+ );
504
+
505
+ }
506
+ }
507
+ }
508
+
509
+ }
510
+
511
+ if ( !(empty($themes_for_saving)) ) {
512
+ //Has themes for saving
513
+ if ( !($doing_query) ) {
514
+ //Not doing query
515
+ $existing_themes = get_option( $this->installer_themes_option[$this->installer_theme_active_tab] );
516
+ if ( !($existing_themes) ) {
517
+ //Does not yet exists
518
+ delete_option( $this->installer_themes_option[$this->installer_theme_active_tab] );
519
+ update_option( $this->installer_themes_option[$this->installer_theme_active_tab], $themes_for_saving );
520
+ } else {
521
+ //exists, check if we need to update
522
+ if ( $existing_themes == $themes_for_saving ) {
523
+ //Equal, no need to update here
524
+ } else {
525
+ //Update
526
+ delete_option( $this->installer_themes_option[$this->installer_theme_active_tab] );
527
+ update_option( $this->installer_themes_option[$this->installer_theme_active_tab], $themes_for_saving );
528
+ }
529
+ }
530
+ } else {
531
+ //Used for query purposes only, don't save anything
532
+ return $themes_for_saving;
533
+ }
534
+ }
535
+ }
536
+ }
537
+
538
+ /** Available themes */
539
+ private function installer_theme_available( $repo, $subscription_type = '' ) {
540
+
541
+ $subscription_type = intval( $subscription_type );
542
+ if ( $subscription_type > 0 ) {
543
+
544
+ //Here we have a case of validated subscription
545
+ //We need to set themes that is available to this subscription
546
+ $themes_associated_with_subscription = $this->installer_themes[$repo] = $this->installer_theme_get_themes_by_subscription( $subscription_type, $repo );
547
+ if ( !(empty($themes_associated_with_subscription)) ) {
548
+ //Has themes
549
+ $this->installer_themes[$repo] = $themes_associated_with_subscription;
550
+ }
551
+ } else {
552
+
553
+ //Get themes
554
+ $this->installer_themes[$repo] = get_option( $this->installer_themes_option[$repo] );
555
+ }
556
+ }
557
+
558
+ /** Theme upgrade check */
559
+ public function installer_theme_upgrade_check( $the_value ) {
560
+
561
+ //Step1: Let's looped through repos with themes and check if we have updates available for them.
562
+ if ( (is_array( $this->installer_repo_with_themes )) && (!(empty($this->installer_repo_with_themes))) ) {
563
+ foreach ( $this->installer_repo_with_themes as $k => $repo_slug ) {
564
+ //Step2: Let's checked if we have update for this theme
565
+ $update_available = get_option( $this->installer_themes_available_updates[$repo_slug] );
566
+ if ( $update_available ) {
567
+ if ( (is_array( $update_available )) && (!(empty($update_available))) ) {
568
+ //Has updates available coming from this specific theme repo
569
+ //Let's loop through the themes that needs update
570
+ foreach ( $update_available as $theme_slug => $v ) {
571
+ //Add to response API
572
+ $the_value->response [$theme_slug] = array(
573
+ 'theme' => $theme_slug,
574
+ 'new_version' => $v['new_version'],
575
+ 'url' => $v['url'],
576
+ 'package' => $v['package']
577
+ );
578
+ }
579
+ }
580
+ }
581
+ }
582
+ }
583
+ //Return
584
+ return $the_value;
585
+ }
586
+
587
+ /** Return repositories that has themes */
588
+ private function installer_theme_reposities_that_has_themes( $repositories, $ret_value = true, $doing_api_query = false ) {
589
+
590
+ $repositories_with_themes = array();
591
+
592
+ if ( (is_array( $repositories )) && (!(empty($repositories))) ) {
593
+
594
+ //Let's checked if we have something before
595
+ $themes = get_option( 'installer_repositories_with_theme' );
596
+
597
+ if ( (!($themes)) || ($doing_api_query) ) {
598
+ //Not yet defined
599
+ //Loop through each repositories and check whether they have themes
600
+ foreach ( $repositories as $k => $v ) {
601
+ if ( isset($v['products']) ) {
602
+ $products_url = $v['products'];
603
+ $themes = $this->installer_theme_get_themes( $products_url, $k );
604
+ if ( (is_array( $themes )) && (!(empty($themes))) ) {
605
+ //Repo has themes
606
+ $repositories_with_themes[] = $k;
607
+ }
608
+ }
609
+ }
610
+ } else {
611
+ //Already set
612
+ $repositories_with_themes = $themes;
613
+ }
614
+
615
+ if ( (((is_array( $repositories_with_themes )) && (!(empty($repositories_with_themes)))) && (!($themes))) || ($doing_api_query) ) {
616
+ //Save to db
617
+ update_option( 'installer_repositories_with_theme', $repositories_with_themes );
618
+ }
619
+ }
620
+
621
+ if ( $ret_value ) {
622
+ return $repositories_with_themes;
623
+ }
624
+
625
+ }
626
+
627
+ /** When WordPress queries its own Themes API, we sync with our own */
628
+ public function installer_theme_sync_native_wp_api( $response, $responsetext, $class, $args, $url ) {
629
+
630
+ $api_native_string = 'api.wordpress.org/themes/';
631
+ if ( (strpos( $url, $api_native_string ) !== false) ) {
632
+ //WordPress is querying its own themes API
633
+ $installer_repositories = WP_Installer()->get_repositories();
634
+
635
+ //Query our own API and update repository values too
636
+ $this->installer_theme_reposities_that_has_themes( $installer_repositories, false, true );
637
+ }
638
+ }
639
+
640
+ /** Returns product name by theme repo slug */
641
+ private function installer_theme_get_repo_product_name( $theme_repo ) {
642
+
643
+ $theme_repo_name = false;
644
+
645
+ if ( isset(WP_Installer()->settings['repositories'][$theme_repo]['data']['product-name']) ) {
646
+ //Set
647
+ $prod_name = WP_Installer()->settings['repositories'][$theme_repo]['data']['product-name'];
648
+ if ( !(empty($prod_name)) ) {
649
+ $theme_repo_name = $prod_name;
650
+ }
651
+ } else {
652
+ //Not yet
653
+ if ( $theme_repo == $this->theme_repo ) {
654
+ $result = $this->installer_theme_general_api_query();
655
+ if ( isset($result['product-name']) ) {
656
+ $product_name = $result['product-name'];
657
+ if ( !(empty($product_name)) ) {
658
+ $theme_repo_name = $product_name;
659
+ }
660
+ }
661
+ }
662
+ }
663
+
664
+ return $theme_repo_name;
665
+ }
666
+
667
+ /** General query API method, returns $products */
668
+ private function installer_theme_general_api_query() {
669
+ $products = false;
670
+ $response = wp_remote_get( $this->repository_theme_products );
671
+ if ( !(is_wp_error( $response )) ) {
672
+ //Not WP error
673
+ //Evaluate response
674
+ if ( $response && isset($response['response']['code']) && $response['response']['code'] == 200 ) {
675
+ //In this case, response is set and defined, proceed...
676
+ $body = wp_remote_retrieve_body( $response );
677
+ if ( $body ) {
678
+ $result = json_decode( $body, true );
679
+ if ( (is_array( $result )) && (!(empty($result))) ) {
680
+ $products = $result;
681
+ }
682
+ }
683
+
684
+ }
685
+ }
686
+
687
+ return $products;
688
+ }
689
+
690
+ /** General method to check if themes are OTGS themes based on its slug*/
691
+ private function installer_themes_belong_to_us( $theme_slug ) {
692
+
693
+ $found = false;
694
+ $theme_slug = trim( $theme_slug );
695
+
696
+ foreach ( $this->installer_themes as $repo_with_theme => $themes ) {
697
+ foreach ( $themes as $k => $otgs_theme_slug ) {
698
+ if ( $theme_slug == $otgs_theme_slug ) {
699
+ //match found! Theme belongs to otgs
700
+ return true;
701
+ }
702
+ }
703
+ }
704
+ return $found;
705
+
706
+ }
707
+
708
+ /** Sets active tab on init */
709
+ public function installer_theme_sets_active_tab_on_init() {
710
+
711
+ if ( isset ($_SERVER ['REQUEST_URI']) ) {
712
+ $request_uri = $_SERVER ['REQUEST_URI'];
713
+ if ( isset ($_GET ['browse']) ) {
714
+ $active_tab = sanitize_text_field( $_GET['browse'] );
715
+ $this->installer_theme_active_tab = $active_tab;
716
+ } elseif ( isset ($_POST ['request'] ['browse']) ) {
717
+ $active_tab = sanitize_text_field ( $_POST['request']['browse'] );
718
+ $this->installer_theme_active_tab = $active_tab;
719
+ } elseif ( (isset ($_GET ['theme_repo'])) && (isset ($_GET ['action'])) ) {
720
+ $theme_repo = sanitize_text_field( $_GET['theme_repo'] );
721
+ $the_action = sanitize_text_field( $_GET['action'] );
722
+ if ( ('install-theme' == $the_action) && (!(empty($theme_repo))) ) {
723
+ $this->installer_theme_active_tab = $theme_repo;
724
+ }
725
+ } elseif ( wp_get_referer() ) {
726
+ $referer = wp_get_referer();
727
+ $parts = parse_url( $referer );
728
+ if ( isset($parts['query']) ) {
729
+ parse_str( $parts['query'], $query );
730
+ if ( isset($query['browse']) ) {
731
+ $this->installer_theme_active_tab = $query['browse'];
732
+ }
733
+ }
734
+ }
735
+ }
736
+ }
737
+
738
+ /** WP Theme API compatibility- added num ratings */
739
+ /** Installer 1.7.6+ Added updated 'rating' field */
740
+ public function installer_theme_add_num_ratings( $themes ) {
741
+
742
+ if ( (is_array( $themes )) && (!(empty($themes))) ) {
743
+ foreach ( $themes as $k => $v ) {
744
+ if ( !(isset($v->num_ratings)) ) {
745
+ $themes[$k]->num_ratings = 100;
746
+ }
747
+ if ( !(isset($v->rating)) ) {
748
+ $themes[$k]->rating = 100;
749
+ }
750
+ }
751
+ }
752
+
753
+ return $themes;
754
+ }
755
+
756
+ /** When WordPress.org makes a call to its repository, let's run our own upgrade checks too */
757
+ public function installer_theme_sync_call_wp_theme_api( $locales ) {
758
+
759
+ $this->installer_theme_upgrade_theme_check();
760
+
761
+ return $locales;
762
+ }
763
+
764
+ /** Upgrade theme check */
765
+ private function installer_theme_upgrade_theme_check() {
766
+
767
+ // Step1-> we get all installed themes in clients local themes directory
768
+ $installed_themes = wp_get_themes();
769
+
770
+ // Step2: We need to loop through each repository with themes
771
+ foreach ( $this->installer_repo_with_themes as $k => $repo_slug ) {
772
+
773
+ // We then need to retrieved the products URL for each of this repo
774
+ $products_url = $this->repository_theme_products [$repo_slug];
775
+
776
+ // Step3-> we get all available themes in our repository via API based on this URL
777
+ $available_themes = $this->installer_theme_get_themes( $products_url, $repo_slug );
778
+
779
+ if ( !($available_themes) ) {
780
+
781
+ // API is not available as of the moment, return..
782
+ return;
783
+ } else {
784
+
785
+ // We have available themes here...
786
+ // Step4->let's simplify available themes data by slugs
787
+ $simplified_available_themes = $this->installer_theme_savethemes_by_slug( $available_themes, true );
788
+
789
+ // Step5->Let's loop through installed themes
790
+ if ( (is_array( $installed_themes )) && (!(empty ($installed_themes))) ) {
791
+ $otgs_theme_updates_available = array();
792
+ foreach ( $installed_themes as $theme_slug => $theme_object ) {
793
+ if ( array_key_exists( $theme_slug, $simplified_available_themes ) ) {
794
+
795
+ // This is our theme
796
+ // Step6->Let's get version of the local theme installed
797
+ $local_version = $theme_object->get( 'Version' );
798
+
799
+ // Step7->Let's get the latest version of this theme, page URL and download URL from our repository
800
+ $repository_version = $simplified_available_themes [$theme_slug] ['version'];
801
+ $theme_page_url = $simplified_available_themes [$theme_slug] ['theme_page_url'];
802
+ $theme_download_url = $simplified_available_themes [$theme_slug] ['url'];
803
+
804
+ // Step8->Let's compare the version
805
+ if ( version_compare( $repository_version, $local_version, '>' ) ) {
806
+
807
+ // Update available for this theme
808
+ // Step9-> Define download URL with site key
809
+ $package_url = WP_Installer()->append_site_key_to_download_url( $theme_download_url, $this->installer_site_key [$repo_slug], $repo_slug );
810
+
811
+ //Step10-> Assign to updates array for later accessing.
812
+ $otgs_theme_updates_available[$theme_slug] = array(
813
+ 'theme' => $theme_slug,
814
+ 'new_version' => $repository_version,
815
+ 'url' => $theme_page_url,
816
+ 'package' => $package_url
817
+ );
818
+ }
819
+ }
820
+ }
821
+ //Exited the upgrade loop for this specific theme repository
822
+ if ( !(empty($otgs_theme_updates_available)) ) {
823
+ //Has updates
824
+ update_option( $this->installer_themes_available_updates[$repo_slug], $otgs_theme_updates_available );
825
+ } else {
826
+ //No updates
827
+ delete_option( $this->installer_themes_available_updates[$repo_slug] );
828
+ }
829
+
830
+ }
831
+ }
832
+ }
833
+ }
834
+
835
+ /** When the user is on Themes install page OTG themes repository, let's the currently selected tab */
836
+ public function installer_theme_add_query_arg_tab( $url, $path, $blog_id = null ) {
837
+
838
+ $wp_install_string = 'update.php?action=install-theme';
839
+ if ( $path == $wp_install_string ) {
840
+ if ( isset($this->installer_theme_active_tab) ) {
841
+ if ( !(empty($this->installer_theme_active_tab)) ) {
842
+ $url = add_query_arg( array(
843
+ 'theme_repo' => $this->installer_theme_active_tab
844
+ ), $url );
845
+ }
846
+ }
847
+ }
848
+ return $url;
849
+ }
850
+
851
+ /** Save frontend theme tab selected */
852
+ public function installer_theme_frontend_selected_tab() {
853
+ if ( isset($_POST["frontend_tab_selected"]) ) {
854
+ check_ajax_referer( 'installer_theme_frontend_selected_tab', 'installer_theme_frontend_selected_tab_nonce' );
855
+
856
+ //Client_side_active_tab
857
+ $frontend_tab_selected = sanitize_text_field( $_POST['frontend_tab_selected'] );
858
+ if ( !(empty($frontend_tab_selected)) ) {
859
+ //Front end tab selected
860
+ update_option( 'wp_installer_clientside_active_tab', $frontend_tab_selected, false );
861
+
862
+ //Check for registration status
863
+ if ( isset($this->theme_user_registration[$frontend_tab_selected]) ) {
864
+ //Set
865
+ if ( !($this->theme_user_registration[$frontend_tab_selected]) ) {
866
+ //Not registered yet
867
+
868
+ if ( is_multisite() ) {
869
+ $admin_url_passed = network_admin_url();
870
+ } else {
871
+ $admin_url_passed = admin_url();
872
+ }
873
+
874
+ $registration_url = $admin_url_passed . 'plugin-install.php?tab=commercial#installer_repo_' . $frontend_tab_selected;
875
+
876
+ //Message and link
877
+ $theme_repo_name = $this->installer_theme_get_repo_product_name( $frontend_tab_selected );;
878
+ $response['unregistered_messages'] = sprintf( __( 'To install and update %s, please %sregister%s %s for this site.', 'installer' ),
879
+ $theme_repo_name, '<a href="' . $registration_url . '">', '</a>', $theme_repo_name );
880
+
881
+ }
882
+ }
883
+
884
+ $response['output'] = $frontend_tab_selected;
885
+ echo json_encode( $response );
886
+ }
887
+ die();
888
+ }
889
+ die();
890
+ }
891
+
892
+ /** Installer loaded aux hooks */
893
+ public function installer_theme_loaded_hooks() {
894
+
895
+ if ( isset($this->installer_theme_subscription_type) ) {
896
+ $subscription_type = intval( $this->installer_theme_subscription_type );
897
+ if ( $subscription_type > 0 ) {
898
+ //Client is subscribed
899
+ add_filter( 'installer_theme_get_themes', array($this, 'installer_theme_filter_themes_by_subscription'), 10, 2 );
900
+ }
901
+ }
902
+
903
+ }
904
+
905
+ /** Get themes by subscription type */
906
+ protected function installer_theme_get_themes_by_subscription( $subscription_type, $repo ) {
907
+
908
+ $themes_associated_with_subscription = array();
909
+ if ( isset(WP_Installer()->settings['repositories'][$repo]['data']['packages']) ) {
910
+ //Set
911
+ $packages = WP_Installer()->settings['repositories'][$repo]['data']['packages'];
912
+ $available_themes_subscription = array();
913
+ foreach ( $packages as $package_id => $package_details ) {
914
+ if ( isset($package_details['products']) ) {
915
+ $the_products = $package_details['products'];
916
+ foreach ( $the_products as $product_slug => $product_details ) {
917
+ if ( isset($product_details['subscription_type']) ) {
918
+ $subscription_type_from_settings = intval( $product_details['subscription_type'] );
919
+ if ( $subscription_type_from_settings == $subscription_type ) {
920
+ //We found the subscription
921
+ if ( isset($product_details['themes']) ) {
922
+ $themes_associated_with_subscription = $product_details['themes'];
923
+ return $themes_associated_with_subscription;
924
+ }
925
+ }
926
+ }
927
+
928
+ }
929
+ }
930
+ }
931
+ }
932
+ return $themes_associated_with_subscription;
933
+ }
934
+
935
+ /** Filter API theme response according to user subscription */
936
+ public function installer_theme_filter_themes_by_subscription( $themes, $active_tab ) {
937
+
938
+ //Step1, we only filter OTGS themes
939
+ $orig = count( $themes );
940
+ if ( in_array( $active_tab, $this->theme_repo ) ) {
941
+ //OTGS Theme
942
+ //Step2, we retrieved the available themes based on client subscription
943
+ if ( isset($this->installer_themes[$active_tab]) ) {
944
+ $available_themes = $this->installer_themes[$active_tab];
945
+ //Step3, we filter $themes based on this info
946
+ if ( (is_array( $themes )) && (!(empty($themes))) ) {
947
+ foreach ( $themes as $k => $theme ) {
948
+ //Step4, get theme slug
949
+ if ( isset($theme['slug']) ) {
950
+ $theme_slug = $theme['slug'];
951
+ if ( !(empty($theme_slug)) ) {
952
+ if ( !(in_array( $theme_slug, $available_themes )) ) {
953
+ //This theme is not in available themes
954
+ unset($themes[$k]);
955
+ }
956
+ }
957
+ }
958
+ }
959
+ }
960
+ }
961
+ }
962
+ $new = count( $themes );
963
+ if ( $orig != $new ) {
964
+ //It is filtered
965
+ $themes = array_values( $themes );
966
+ }
967
+
968
+ return $themes;
969
+ }
970
+
971
+ /** Hook to wp_loaded, fires when all Installer theme class is ready */
972
+ public function installer_themes_support_set_up_func() {
973
+ do_action( 'installer_themes_support_set_up' );
974
+ }
975
+
976
+ }
977
+
978
+ /** Instantiate Installer Theme Class */
979
  new Installer_Theme_Class;
vendor/otgs/installer/includes/class-installer-upgrader-skins.php CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
-
3
- class Installer_Upgrader_Skins extends WP_Upgrader_Skin {
4
-
5
- function __construct( $args = array() ) {
6
- $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
7
- $this->options = wp_parse_args( $args, $defaults );
8
- }
9
-
10
- function header() {
11
-
12
- }
13
-
14
- function footer() {
15
-
16
- }
17
-
18
- function error( $error ) {
19
- $this->installer_error = $error;
20
- }
21
-
22
- function add_strings() {
23
-
24
- }
25
-
26
- function feedback( $string ) {
27
-
28
- }
29
-
30
- function before() {
31
-
32
- }
33
-
34
- function after() {
35
-
36
- }
37
-
38
  }
1
+ <?php
2
+
3
+ class Installer_Upgrader_Skins extends WP_Upgrader_Skin {
4
+
5
+ function __construct( $args = array() ) {
6
+ $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
7
+ $this->options = wp_parse_args( $args, $defaults );
8
+ }
9
+
10
+ function header() {
11
+
12
+ }
13
+
14
+ function footer() {
15
+
16
+ }
17
+
18
+ function error( $error ) {
19
+ $this->installer_error = $error;
20
+ }
21
+
22
+ function add_strings() {
23
+
24
+ }
25
+
26
+ function feedback( $string ) {
27
+
28
+ }
29
+
30
+ function before() {
31
+
32
+ }
33
+
34
+ function after() {
35
+
36
+ }
37
+
38
  }
vendor/otgs/installer/includes/class-translation-service-info.php CHANGED
@@ -1,40 +1,40 @@
1
- <?php
2
-
3
- class Translation_Service_Info {
4
-
5
- function __construct() {
6
-
7
- add_action( 'installer_fetched_subscription_data', array( $this, 'save_info' ), 10, 2 );
8
-
9
- }
10
-
11
- function save_info( $data, $repository_id ) {
12
-
13
- $ts_info = isset( WP_Installer()->settings['repositories'][ $repository_id ]['ts_info'] ) ?
14
- WP_Installer()->settings['repositories'][ $repository_id ]['ts_info'] : false;
15
-
16
- $save_settings = false;
17
- if ( isset( $data->ts_info['preferred'] ) && empty( $ts_info['preferred'] ) ) {
18
- WP_Installer()->settings['repositories'][ $repository_id ]['ts_info']['preferred'] = $data->ts_info['preferred'];
19
- $save_settings = true;
20
- }
21
-
22
- if ( isset( $data->ts_info['referal'] ) && empty( $ts_info['referal'] ) ) {
23
- WP_Installer()->settings['repositories'][ $repository_id ]['ts_info']['referal'] = $data->ts_info['referal'];
24
- $save_settings = true;
25
- }
26
-
27
- if ( ! empty( $data->ts_info['client_id'] ) ) { // can be updated
28
- WP_Installer()->settings['repositories'][ $repository_id ]['ts_info']['client_id'] = $data->ts_info['client_id'];
29
- $save_settings = true;
30
- }
31
-
32
- if ( $save_settings ) {
33
- WP_Installer()->save_settings();
34
- }
35
-
36
- }
37
-
38
- }
39
-
40
  new Translation_Service_Info();
1
+ <?php
2
+
3
+ class Translation_Service_Info {
4
+
5
+ function __construct() {
6
+
7
+ add_action( 'installer_fetched_subscription_data', array( $this, 'save_info' ), 10, 2 );
8
+
9
+ }
10
+
11
+ function save_info( $data, $repository_id ) {
12
+
13
+ $ts_info = isset( WP_Installer()->settings['repositories'][ $repository_id ]['ts_info'] ) ?
14
+ WP_Installer()->settings['repositories'][ $repository_id ]['ts_info'] : false;
15
+
16
+ $save_settings = false;
17
+ if ( isset( $data->ts_info['preferred'] ) && empty( $ts_info['preferred'] ) ) {
18
+ WP_Installer()->settings['repositories'][ $repository_id ]['ts_info']['preferred'] = $data->ts_info['preferred'];
19
+ $save_settings = true;
20
+ }
21
+
22
+ if ( isset( $data->ts_info['referal'] ) && empty( $ts_info['referal'] ) ) {
23
+ WP_Installer()->settings['repositories'][ $repository_id ]['ts_info']['referal'] = $data->ts_info['referal'];
24
+ $save_settings = true;
25
+ }
26
+
27
+ if ( ! empty( $data->ts_info['client_id'] ) ) { // can be updated
28
+ WP_Installer()->settings['repositories'][ $repository_id ]['ts_info']['client_id'] = $data->ts_info['client_id'];
29
+ $save_settings = true;
30
+ }
31
+
32
+ if ( $save_settings ) {
33
+ WP_Installer()->save_settings();
34
+ }
35
+
36
+ }
37
+
38
+ }
39
+
40
  new Translation_Service_Info();
vendor/otgs/installer/includes/class-wp-installer-api.php CHANGED
@@ -1,134 +1,134 @@
1
- <?php
2
-
3
- class WP_Installer_API{
4
-
5
- public static function get_product_installer_link($repository_id, $package_id = false){
6
-
7
- $menu_url = WP_Installer()->menu_url();
8
-
9
- $url = $menu_url . '#' . $repository_id;
10
- if($package_id){
11
- $url .= '/' . $package_id;
12
- }
13
-
14
- return $url;
15
-
16
- }
17
-
18
- public static function get_product_price($repository_id, $package_id, $product_id, $incl_discount = false){
19
-
20
- $price = WP_Installer()->get_product_price($repository_id, $package_id, $product_id, $incl_discount);
21
-
22
- return $price;
23
- }
24
-
25
- /**
26
- * Retrieve the preferred translation service.
27
- *
28
- * @since 1.6.5
29
- *
30
- * @param string The repository id (e.g. wpml)
31
- * @return string The translation service id
32
- */
33
- public static function get_preferred_ts($repository_id = 'wpml'){
34
-
35
- if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'])){
36
- return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'];
37
- }
38
-
39
- return false;
40
-
41
- }
42
-
43
- /**
44
- * Set the preferred translation service.
45
- *
46
- * @since 1.6.5
47
- *
48
- * @param string The translation service id
49
- * @param string The repository id (e.g. wpml)
50
- */
51
- public static function set_preferred_ts( $value, $repository_id = 'wpml' ){
52
-
53
- if( isset( WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] ) ){
54
-
55
- WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] = $value;
56
-
57
- WP_Installer()->save_settings();
58
-
59
- }
60
-
61
- }
62
-
63
- /**
64
- * Retrieve the referring translation service (if any)
65
- *
66
- * @since 1.6.5
67
- *
68
- * @param string The repository id (e.g. wpml)
69
- * @return string The translation service id or false
70
- */
71
- public static function get_ts_referal($repository_id = 'wpml'){
72
-
73
- if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'])){
74
- return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'];
75
- }
76
-
77
- return false;
78
-
79
- }
80
-
81
- /**
82
- * Retrieve the translation services client id for a specific repository (if any)
83
- *
84
- * @since 1.7.9
85
- *
86
- * @param string The repository id (e.g. wpml)
87
- * @return string The client id or false
88
- */
89
- public static function get_ts_client_id( $repository_id = 'wpml' ){
90
-
91
- if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['client_id'])){
92
- return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['client_id'];
93
- }
94
-
95
- return false;
96
-
97
- }
98
-
99
- /**
100
- * Retrieve the site key corresponding to a repository.
101
- * This is a wrapper of WP_Installer::get_site_key()
102
- * @see WP_Installer::get_site_key()
103
- *
104
- * @since 1.7.9
105
- *
106
- * @param string The repository id (e.g. wpml)
107
- * @return string The site key (or false)
108
- */
109
- public static function get_site_key( $repository_id = 'wpml' ){
110
-
111
- return WP_Installer()->get_site_key( $repository_id );
112
-
113
- }
114
-
115
- /**
116
- * Retrieve the ID of the last user who registered a repository.
117
- *
118
- * @since 1.7.16
119
- *
120
- * @param string The repository id (e.g. wpml)
121
- * @return int The user id (or zero)
122
- */
123
- public static function get_registering_user_id( $repository_id = 'wpml' ){
124
-
125
- $user_id = 0;
126
- if( isset( WP_Installer()->settings['repositories'][$repository_id]['subscription']['registered_by'] ) ){
127
- $user_id = WP_Installer()->settings['repositories'][$repository_id]['subscription']['registered_by'];
128
- }
129
-
130
- return $user_id;
131
- }
132
-
133
-
134
  }
1
+ <?php
2
+
3
+ class WP_Installer_API{
4
+
5
+ public static function get_product_installer_link($repository_id, $package_id = false){
6
+
7
+ $menu_url = WP_Installer()->menu_url();
8
+
9
+ $url = $menu_url . '#' . $repository_id;
10
+ if($package_id){
11
+ $url .= '/' . $package_id;
12
+ }
13
+
14
+ return $url;
15
+
16
+ }
17
+
18
+ public static function get_product_price($repository_id, $package_id, $product_id, $incl_discount = false){
19
+
20
+ $price = WP_Installer()->get_product_price($repository_id, $package_id, $product_id, $incl_discount);
21
+
22
+ return $price;
23
+ }
24
+
25
+ /**
26
+ * Retrieve the preferred translation service.
27
+ *
28
+ * @since 1.6.5
29
+ *
30
+ * @param string The repository id (e.g. wpml)
31
+ * @return string The translation service id
32
+ */
33
+ public static function get_preferred_ts($repository_id = 'wpml'){
34
+
35
+ if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'])){
36
+ return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'];
37
+ }
38
+
39
+ return false;
40
+
41
+ }
42
+
43
+ /**
44
+ * Set the preferred translation service.
45
+ *
46
+ * @since 1.6.5
47
+ *
48
+ * @param string The translation service id
49
+ * @param string The repository id (e.g. wpml)
50
+ */
51
+ public static function set_preferred_ts( $value, $repository_id = 'wpml' ){
52
+
53
+ if( isset( WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] ) ){
54
+
55
+ WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] = $value;
56
+
57
+ WP_Installer()->save_settings();
58
+
59
+ }
60
+
61
+ }
62
+
63
+ /**
64
+ * Retrieve the referring translation service (if any)
65
+ *
66
+ * @since 1.6.5
67
+ *
68
+ * @param string The repository id (e.g. wpml)
69
+ * @return string The translation service id or false
70
+ */
71
+ public static function get_ts_referal($repository_id = 'wpml'){
72
+
73
+ if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'])){
74
+ return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'];
75
+ }
76
+
77
+ return false;
78
+
79
+ }
80
+
81
+ /**
82
+ * Retrieve the translation services client id for a specific repository (if any)
83
+ *
84
+ * @since 1.7.9
85
+ *
86
+ * @param string The repository id (e.g. wpml)
87
+ * @return string The client id or false
88
+ */
89
+ public static function get_ts_client_id( $repository_id = 'wpml' ){
90
+
91
+ if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['client_id'])){
92
+ return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['client_id'];
93
+ }
94
+
95
+ return false;
96
+
97
+ }
98
+
99
+ /**
100
+ * Retrieve the site key corresponding to a repository.
101
+ * This is a wrapper of WP_Installer::get_site_key()
102
+ * @see WP_Installer::get_site_key()
103
+ *
104
+ * @since 1.7.9
105
+ *
106
+ * @param string The repository id (e.g. wpml)
107
+ * @return string The site key (or false)
108
+ */
109
+ public static function get_site_key( $repository_id = 'wpml' ){
110
+
111
+ return WP_Installer()->get_site_key( $repository_id );
112
+
113
+ }
114
+
115
+ /**
116
+ * Retrieve the ID of the last user who registered a repository.
117
+ *
118
+ * @since 1.7.16
119
+ *
120
+ * @param string The repository id (e.g. wpml)
121
+ * @return int The user id (or zero)
122
+ */
123
+ public static function get_registering_user_id( $repository_id = 'wpml' ){
124
+
125
+ $user_id = 0;
126
+ if( isset( WP_Installer()->settings['repositories'][$repository_id]['subscription']['registered_by'] ) ){
127
+ $user_id = WP_Installer()->settings['repositories'][$repository_id]['subscription']['registered_by'];
128
+ }
129
+
130
+ return $user_id;
131
+ }
132
+
133
+
134
  }
vendor/otgs/installer/includes/class-wp-installer-channels.php CHANGED
@@ -1,271 +1,271 @@
1
- <?php
2
-
3
- /**
4
- * Class WP_Installer_Channels
5
- * @since 1.8
6
- */
7
- class WP_Installer_Channels{
8
-
9
- const CHANNEL_PRODUCTION = 'production';
10
- const CHANNEL_BETA = 'beta';
11
- const CHANNEL_DEVELOPMENT = 'development';
12
-
13
- protected static $_instance = null;
14
-
15
- function __construct() {
16
- add_action( 'init', array( $this, 'init' ), 20 ); // after Installer
17
- }
18
-
19
- /**
20
- * @return null|WP_Installer_Channels
21
- */
22
- public static function instance() {
23
-
24
- if ( is_null( self::$_instance ) ) {
25
- self::$_instance = new self();
26
- }
27
-
28
- return self::$_instance;
29
- }
30
-
31
- /**
32
- * Get the channel literal id based on the numeric id
33
- *
34
- * @param mixed $id
35
- *
36
- * @return string
37
- */
38
- public static function channel_name_by_id( $id ) {
39
- if ( self::CHANNEL_DEVELOPMENT === $id ) {
40
- $channel = __( 'Development', 'installer' );
41
- } elseif ( self::CHANNEL_BETA === $id ) {
42
- $channel = __( 'Beta', 'installer' );
43
- } else {
44
- $channel = __( 'Production', 'installer' );
45
- }
46
-
47
- return $channel;
48
- }
49
-
50
- /**
51
- * Initialization
52
- */
53
- public function init(){
54
- global $pagenow;
55
-
56
- if ( defined( 'DOING_AJAX' ) ) {
57
- add_action( 'wp_ajax_installer_set_channel', array( $this, 'set_channel' ) );
58
- }
59
-
60
- if ( $pagenow === 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] === 'commercial' ) {
61
- wp_enqueue_script( 'installer-channels', WP_Installer()->res_url() . '/res/js/channels.js', array( 'jquery' ), WP_Installer()->version() );
62
- }
63
-
64
- }
65
-
66
- /**
67
- * Ajax handler for channel switching
68
- */
69
- public function set_channel(){
70
- $repository_id = sanitize_text_field( $_POST['repository_id'] );
71
- $channel = sanitize_text_field( $_POST['channel'] );
72
-
73
- $response = array();
74
-
75
- if( $_POST['nonce'] === wp_create_nonce( 'installer_set_channel:' . $repository_id ) ){
76
-
77
- if( isset( WP_Installer()->settings['repositories'][$repository_id] ) ){
78
- WP_Installer()->settings['repositories'][$repository_id]['channel'] = $channel;
79
- WP_Installer()->settings['repositories'][$repository_id]['no-prompt'] = $_POST['noprompt'] === 'true';
80
- WP_Installer()->save_settings();
81
- }
82
-
83
- WP_Installer()->refresh_repositories_data();
84
-
85
- $response['status'] = 'OK';
86
- }
87
-
88
- echo json_encode( $response );
89
- exit;
90
- }
91
-
92
- /**
93
- * @param string $repository_id
94
- *
95
- * @return int
96
- */
97
- public function get_channel( $repository_id ){
98
- $channel = self::CHANNEL_PRODUCTION;
99
- if( isset( WP_Installer()->settings['repositories'][$repository_id]['channel'] ) ){
100
- $channel = WP_Installer()->settings['repositories'][$repository_id]['channel'];
101
- }
102
- return $channel;
103
- }
104
-
105
- /**
106
- * @param string $repository_id
107
- * @param array $downloads
108
- */
109
- public function load_channel_selector( $repository_id, $downloads ) {
110
-
111
- $available_channels = $this->get_available_channels( $repository_id );
112
-
113
- if ( $available_channels ) {
114
- $args = array(
115
- 'can_switch' => $this->can_use_unstable_channels( $downloads ) || $this->get_channel( $repository_id ) > 1,
116
- 'channels' => $available_channels,
117
- 'repository_id' => $repository_id,
118
- 'current_channel' => $this->get_channel( $repository_id ),
119
- 'no_prompt' => !empty( WP_Installer()->settings['repositories'][ $repository_id ]['no-prompt'] ),
120
- 'nonce' => wp_create_nonce( 'installer_set_channel:' . $repository_id )
121
- );
122
- extract( $args );
123
- include WP_Installer()->plugin_path() . '/templates/channel-selector.php';
124
- }
125
- }
126
-
127
- /**
128
- * The beta and development channels can be used only when already using the most up to date versions
129
- * @param array $downloads
130
- *
131
- * @return bool
132
- */
133
- public function can_use_unstable_channels( $downloads ){
134
-
135
- $can = true;
136
- foreach( $downloads as $download ){
137
- $available_version = $download['version'];
138
- $installed_version = WP_Installer()->plugin_is_installed( $download['name'], $download['slug'] );
139
- if( $installed_version !== false && version_compare( $available_version, $installed_version, '>' ) ){
140
- $can = false;
141
- break;
142
- }
143
- }
144
-
145
- return $can;
146
- }
147
-
148
- /**
149
- * Get available updates channels. Only include channels with actual downloads available.
150
- *
151
- * @param string $repository_id
152
- *
153
- * @return array
154
- */
155
- public function get_available_channels( $repository_id ) {
156
-
157
- $beta = false;
158
- $dev = false;
159
-
160
- $downloads = WP_Installer()->settings['repositories'][ $repository_id ]['data']['downloads'];
161
- foreach ( $downloads as $type => $download_types ) {
162
- foreach ( $download_types as $download ) {
163
- $extra_channels = isset( $download['extra_channels'] ) ? array_keys( $download['extra_channels'] ) : array();
164
- if ( ! $beta && in_array( self::CHANNEL_BETA, $extra_channels ) ) {
165
- $beta = true;
166
- }
167
- if ( ! $dev && in_array( self::CHANNEL_DEVELOPMENT, $extra_channels ) ) {
168
- $dev = true;
169
- }
170
- if ( $beta && $dev ) {
171
- break;
172
- }
173
- }
174
- }
175
-
176
- $channels = array();
177
- if ( $beta || $dev ) {
178
- $channels[ self::CHANNEL_PRODUCTION ] = self::channel_name_by_id( self::CHANNEL_PRODUCTION );
179
- if ( $beta ) {
180
- $channels[ self::CHANNEL_BETA ] = self::channel_name_by_id( self::CHANNEL_BETA );
181
- }
182
- if ( $dev ) {
183
- $channels[ self::CHANNEL_DEVELOPMENT ] = self::channel_name_by_id( self::CHANNEL_DEVELOPMENT );
184
- }
185
- }
186
-
187
- return $channels;
188
- }
189
-
190
- /**
191
- * @param string $repository_id
192
- * @param array $downloads
193
- *
194
- * @return array
195
- */
196
- public function filter_downloads_by_channel( $repository_id, $downloads ) {
197
-
198
- $current_channel = $this->get_channel( $repository_id );
199
-
200
- foreach ( $downloads as $type => $type_downloads ) {
201
- foreach ( $type_downloads as $slug => $download ) {
202
-
203
- $override_download = array();
204
- if ( $current_channel === self::CHANNEL_DEVELOPMENT ) {
205
- if( ! empty( $download['channels']['development'] ) ){
206
- $override_download = $download['channels']['development'];
207
- $override_download['channel'] = self::CHANNEL_DEVELOPMENT;
208
- }elseif( ! empty( $download['channels']['beta'] ) ){
209
- $override_download = $download['channels']['beta'];
210
- $override_download['channel'] = self::CHANNEL_BETA;
211
- }
212
- }elseif ( $current_channel === self::CHANNEL_BETA && ! empty( $download['channels']['beta'] ) ) {
213
- $override_download = $download['channels']['beta'];
214
- $override_download['channel'] = self::CHANNEL_BETA;
215
- }
216
-
217
- if ( $override_download ) {
218
- foreach ( $override_download as $key => $value ) {
219
- $downloads[ $type ][ $slug ][ $key ] = $value;
220
- }
221
- } else {
222
- $downloads[ $type ][ $slug ]['channel'] = self::CHANNEL_PRODUCTION;
223
- }
224
- unset ( $downloads[ $type ][ $slug ]['channels'] );
225
-
226
- $downloads[ $type ][ $slug ]['extra_channels'] = array();
227
- if( isset( $download['channels'] ) ) {
228
- foreach( $download['channels'] as $channel_id => $channel ){
229
- $downloads[ $type ][ $slug ]['extra_channels'][$channel_id] = array(
230
- 'version' => $channel['version']
231
- );
232
- }
233
- }
234
-
235
- }
236
- }
237
-
238
- return $downloads;
239
- }
240
-
241
- /**
242
- * Get the source channel for the installed version when on the Beta or Development channel
243
- * @param string $version
244
- * @param string $repository_id
245
- * @param string $download_id
246
- * @param string $download_kind
247
- *
248
- * @return string
249
- */
250
- public function get_download_source_channel( $version, $repository_id, $download_id, $download_kind ) {
251
-
252
- $version_channel = '';
253
- $installer_settings = WP_Installer()->get_settings();
254
- if ( isset( $installer_settings['repositories'][ $repository_id ] ) ) {
255
- $repository_data = $installer_settings['repositories'][ $repository_id ]['data'];
256
- if ( isset( $repository_data['downloads'][ $download_kind ][ $download_id ]['extra_channels'] ) ) {
257
-
258
- foreach ( $repository_data['downloads'][ $download_kind ][ $download_id ]['extra_channels'] as $channel_id => $channel_data ) {
259
- if ( $version === $channel_data['version'] ) {
260
- $version_channel = self::channel_name_by_id( $channel_id );
261
- break;
262
- }
263
-
264
- }
265
- }
266
-
267
- }
268
-
269
- return $version_channel;
270
- }
271
  }
1
+ <?php
2
+
3
+ /**
4
+ * Class WP_Installer_Channels
5
+ * @since 1.8
6
+ */
7
+ class WP_Installer_Channels{
8
+
9
+ const CHANNEL_PRODUCTION = 'production';
10
+ const CHANNEL_BETA = 'beta';
11
+ const CHANNEL_DEVELOPMENT = 'development';
12
+
13
+ protected static $_instance = null;
14
+
15
+ function __construct() {
16
+ add_action( 'init', array( $this, 'init' ), 20 ); // after Installer
17
+ }
18
+
19
+ /**
20
+ * @return null|WP_Installer_Channels
21
+ */
22
+ public static function instance() {
23
+
24
+ if ( is_null( self::$_instance ) ) {
25
+ self::$_instance = new self();
26
+ }
27
+
28
+ return self::$_instance;
29
+ }
30
+
31
+ /**
32
+ * Get the channel literal id based on the numeric id
33
+ *
34
+ * @param mixed $id
35
+ *
36
+ * @return string
37
+ */
38
+ public static function channel_name_by_id( $id ) {
39
+ if ( self::CHANNEL_DEVELOPMENT === $id ) {
40
+ $channel = __( 'Development', 'installer' );
41
+ } elseif ( self::CHANNEL_BETA === $id ) {
42
+ $channel = __( 'Beta', 'installer' );
43
+ } else {
44
+ $channel = __( 'Production', 'installer' );
45
+ }
46
+
47
+ return $channel;
48
+ }
49
+
50
+ /**
51
+ * Initialization
52
+ */
53
+ public function init(){
54
+ global $pagenow;
55
+
56
+ if ( defined( 'DOING_AJAX' ) ) {
57
+ add_action( 'wp_ajax_installer_set_channel', array( $this, 'set_channel' ) );
58
+ }
59
+
60
+ if ( $pagenow === 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] === 'commercial' ) {
61
+ wp_enqueue_script( 'installer-channels', WP_Installer()->res_url() . '/res/js/channels.js', array( 'jquery' ), WP_Installer()->version() );
62
+ }
63
+
64
+ }
65
+
66
+ /**
67
+ * Ajax handler for channel switching
68
+ */
69
+ public function set_channel(){
70
+ $repository_id = sanitize_text_field( $_POST['repository_id'] );
71
+ $channel = sanitize_text_field( $_POST['channel'] );
72
+
73
+ $response = array();
74
+
75
+ if( $_POST['nonce'] === wp_create_nonce( 'installer_set_channel:' . $repository_id ) ){
76
+
77
+ if( isset( WP_Installer()->settings['repositories'][$repository_id] ) ){
78
+ WP_Installer()->settings['repositories'][$repository_id]['channel'] = $channel;
79
+ WP_Installer()->settings['repositories'][$repository_id]['no-prompt'] = $_POST['noprompt'] === 'true';
80
+ WP_Installer()->save_settings();
81
+ }
82
+
83
+ WP_Installer()->refresh_repositories_data();
84
+
85
+ $response['status'] = 'OK';
86
+ }
87
+
88
+ echo json_encode( $response );
89
+ exit;
90
+ }
91
+
92
+ /**
93
+ * @param string $repository_id
94
+ *
95
+ * @return int
96
+ */
97
+ public function get_channel( $repository_id ){
98
+ $channel = self::CHANNEL_PRODUCTION;
99
+ if( isset( WP_Installer()->settings['repositories'][$repository_id]['channel'] ) ){
100
+ $channel = WP_Installer()->settings['repositories'][$repository_id]['channel'];
101
+ }
102
+ return $channel;
103
+ }
104
+
105
+ /**
106
+ * @param string $repository_id
107
+ * @param array $downloads
108
+ */
109
+ public function load_channel_selector( $repository_id, $downloads ) {
110
+
111
+ $available_channels = $this->get_available_channels( $repository_id );
112
+
113
+ if ( $available_channels ) {
114
+ $args = array(
115
+ 'can_switch' => $this->can_use_unstable_channels( $downloads ) || $this->get_channel( $repository_id ) > 1,
116
+ 'channels' => $available_channels,
117
+ 'repository_id' => $repository_id,
118
+ 'current_channel' => $this->get_channel( $repository_id ),
119
+ 'no_prompt' => !empty( WP_Installer()->settings['repositories'][ $repository_id ]['no-prompt'] ),
120
+ 'nonce' => wp_create_nonce( 'installer_set_channel:' . $repository_id )
121
+ );
122
+ extract( $args );
123
+ include WP_Installer()->plugin_path() . '/templates/channel-selector.php';
124
+ }
125
+ }
126
+
127
+ /**
128
+ * The beta and development channels can be used only when already using the most up to date versions
129
+ * @param array $downloads
130
+ *
131
+ * @return bool
132
+ */
133
+ public function can_use_unstable_channels( $downloads ){
134
+
135
+ $can = true;
136
+ foreach( $downloads as $download ){
137
+ $available_version = $download['version'];
138
+ $installed_version = WP_Installer()->plugin_is_installed( $download['name'], $download['slug'] );
139
+ if( $installed_version !== false && version_compare( $available_version, $installed_version, '>' ) ){
140
+ $can = false;
141
+ break;
142
+ }
143
+ }
144
+
145
+ return $can;
146
+ }
147
+
148
+ /**
149
+ * Get available updates channels. Only include channels with actual downloads available.
150
+ *
151
+ * @param string $repository_id
152
+ *
153
+ * @return array
154
+ */
155
+ public function get_available_channels( $repository_id ) {
156
+
157
+ $beta = false;
158
+ $dev = false;
159
+
160
+ $downloads = WP_Installer()->settings['repositories'][ $repository_id ]['data']['downloads'];
161
+ foreach ( $downloads as $type => $download_types ) {
162
+ foreach ( $download_types as $download ) {
163
+ $extra_channels = isset( $download['extra_channels'] ) ? array_keys( $download['extra_channels'] ) : array();
164
+ if ( ! $beta && in_array( self::CHANNEL_BETA, $extra_channels ) ) {
165
+ $beta = true;
166
+ }
167
+ if ( ! $dev && in_array( self::CHANNEL_DEVELOPMENT, $extra_channels ) ) {
168
+ $dev = true;
169
+ }
170
+ if ( $beta && $dev ) {
171
+ break;
172
+ }
173
+ }
174
+ }
175
+
176
+ $channels = array();
177
+ if ( $beta || $dev ) {
178
+ $channels[ self::CHANNEL_PRODUCTION ] = self::channel_name_by_id( self::CHANNEL_PRODUCTION );
179
+ if ( $beta ) {
180
+ $channels[ self::CHANNEL_BETA ] = self::channel_name_by_id( self::CHANNEL_BETA );
181
+ }
182
+ if ( $dev ) {
183
+ $channels[ self::CHANNEL_DEVELOPMENT ] = self::channel_name_by_id( self::CHANNEL_DEVELOPMENT );
184
+ }
185
+ }
186
+
187
+ return $channels;
188
+ }
189
+
190
+ /**
191
+ * @param string $repository_id
192
+ * @param array $downloads
193
+ *
194
+ * @return array
195
+ */
196
+ public function filter_downloads_by_channel( $repository_id, $downloads ) {
197
+
198
+ $current_channel = $this->get_channel( $repository_id );
199
+
200
+ foreach ( $downloads as $type => $type_downloads ) {
201
+ foreach ( $type_downloads as $slug => $download ) {
202
+
203
+ $override_download = array();
204
+ if ( $current_channel === self::CHANNEL_DEVELOPMENT ) {
205
+ if( ! empty( $download['channels']['development'] ) ){
206
+ $override_download = $download['channels']['development'];
207
+ $override_download['channel'] = self::CHANNEL_DEVELOPMENT;
208
+ }elseif( ! empty( $download['channels']['beta'] ) ){
209
+ $override_download = $download['channels']['beta'];
210
+ $override_download['channel'] = self::CHANNEL_BETA;
211
+ }
212
+ }elseif ( $current_channel === self::CHANNEL_BETA && ! empty( $download['channels']['beta'] ) ) {
213
+ $override_download = $download['channels']['beta'];
214
+ $override_download['channel'] = self::CHANNEL_BETA;
215
+ }
216
+
217
+ if ( $override_download ) {
218
+ foreach ( $override_download as $key => $value ) {
219
+ $downloads[ $type ][ $slug ][ $key ] = $value;
220
+ }
221
+ } else {
222
+ $downloads[ $type ][ $slug ]['channel'] = self::CHANNEL_PRODUCTION;
223
+ }
224
+ unset ( $downloads[ $type ][ $slug ]['channels'] );
225
+
226
+ $downloads[ $type ][ $slug ]['extra_channels'] = array();
227
+ if( isset( $download['channels'] ) ) {
228
+ foreach( $download['channels'] as $channel_id => $channel ){
229
+ $downloads[ $type ][ $slug ]['extra_channels'][$channel_id] = array(
230
+ 'version' => $channel['version']
231
+ );
232
+ }
233
+ }
234
+
235
+ }
236
+ }
237
+
238
+ return $downloads;
239
+ }
240
+
241
+ /**
242
+ * Get the source channel for the installed version when on the Beta or Development channel
243
+ * @param string $version
244
+ * @param string $repository_id
245
+ * @param string $download_id
246
+ * @param string $download_kind
247
+ *
248
+ * @return string
249
+ */
250
+ public function get_download_source_channel( $version, $repository_id, $download_id, $download_kind ) {
251
+
252
+ $version_channel = '';
253
+ $installer_settings = WP_Installer()->get_settings();
254
+ if ( isset( $installer_settings['repositories'][ $repository_id ] ) ) {
255
+ $repository_data = $installer_settings['repositories'][ $repository_id ]['data'];
256
+ if ( isset( $repository_data['downloads'][ $download_kind ][ $download_id ]['extra_channels'] ) ) {
257
+
258
+ foreach ( $repository_data['downloads'][ $download_kind ][ $download_id ]['extra_channels'] as $channel_id => $channel_data ) {
259
+ if ( $version === $channel_data['version'] ) {
260
+ $version_channel = self::channel_name_by_id( $channel_id );
261
+ break;
262
+ }
263
+
264
+ }
265
+ }
266
+
267
+ }
268
+
269
+ return $version_channel;
270
+ }
271
  }
vendor/otgs/installer/includes/class-wp-installer.php CHANGED
@@ -1,2768 +1,2768 @@
1
- <?php
2
-
3
- final class WP_Installer {
4
- protected static $_instance = null;
5
-
6
- public $settings = array();
7
-
8
- private $repositories = array();
9
-
10
- protected $api_debug = '';
11
-
12
- private $config = array();
13
-
14
- protected $_plugins_renew_warnings = array();
15
-
16
- protected $_gz_on = false;
17
-
18
- private $admin_messages = array();
19
-
20
- private $_using_icl = false;
21
- private $_wpml_version = false;
22
-
23
- private $package_source = array();
24
-
25
- const SITE_KEY_VALIDATION_SOURCE_OTHER = 0;
26
- const SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_SPECIFIC = 1;
27
- const SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_REPORT = 2;
28
- const SITE_KEY_VALIDATION_SOURCE_REGISTRATION = 3;
29
- const SITE_KEY_VALIDATION_SOURCE_REVALIDATION = 4;
30
- const SITE_KEY_VALIDATION_SOURCE_UPDATES_CHECK = 5;
31
-
32
- public $dependencies;
33
-
34
- public static function instance() {
35
-
36
- if ( is_null( self::$_instance ) ) {
37
- self::$_instance = new self();
38
- }
39
-
40
- return self::$_instance;
41
- }
42
-
43
- public function __construct() {
44
-
45
- if ( ! is_admin() || ! is_user_logged_in() ) {
46
- return;
47
- } //Only for admin
48
-
49
- $this->_gz_on = function_exists( 'gzuncompress' ) && function_exists( 'gzcompress' );
50
- $this->settings = $this->get_settings();
51
-
52
- add_action( 'admin_notices', array( $this, 'show_site_key_nags' ) );
53
-
54
- add_action( 'admin_notices', array( $this, 'show_admin_messages' ) );
55
-
56
- add_action( 'admin_init', array( $this, 'load_embedded_plugins' ), 0 );
57
-
58
- add_action( 'admin_menu', array( $this, 'menu_setup' ) );
59
- add_action( 'network_admin_menu', array( $this, 'menu_setup' ) );
60
-
61
- if ( defined( 'DOING_AJAX' ) && isset( $_POST['action'] ) && $_POST['action'] == 'installer_download_plugin' ) {
62
- add_filter( 'site_transient_update_plugins', array( $this, 'plugins_upgrade_check' ) );
63
- }
64
- add_filter( 'plugins_api', array( $this, 'custom_plugins_api_call' ), 10, 3 );
65
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'plugins_upgrade_check' ) );
66
-
67
- // register repositories
68
- $this->load_repositories_list();
69
-
70
- // default config
71
- $this->config['plugins_install_tab'] = false;
72
-
73
- add_action( 'init', array( $this, 'init' ) );
74
-
75
- //add_filter('wp_installer_buy_url', array($this, 'append_parameters_to_buy_url'));
76
-
77
- add_action( 'init', array( $this, 'load_locale' ) );
78
-
79
- }
80
-
81
- public function get_repositories() {
82
-
83
- return $this->repositories;
84
-
85
- }
86
-
87
- public function set_config( $key, $value ) {
88
-
89
- $this->config[ $key ] = $value;
90
-
91
- }
92
-
93
- public function init() {
94
- global $pagenow;
95
-
96
- if ( empty( $this->settings['last_repositories_update'] ) || time() - $this->settings['last_repositories_update'] > 86400
97
- || ( isset( $_GET['force-check'] ) && $_GET['force-check'] == 1 )
98
- ) {
99
- $this->refresh_repositories_data();
100
- }
101
-
102
- $this->dependencies = new Installer_Dependencies;
103
-
104
- if ( empty( $this->settings['_pre_1_0_clean_up'] ) ) {
105
- $this->_pre_1_0_clean_up();
106
- }
107
-
108
- $this->settings = $this->_old_products_format_backwards_compatibility( $this->settings );
109
-
110
- if ( ! function_exists( 'get_plugins' ) ) {
111
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
112
- }
113
-
114
- $this->_using_icl = function_exists( 'wpml_site_uses_icl' ) && wpml_site_uses_icl();
115
- $this->_wpml_version = defined( 'ICL_SITEPRESS_VERSION' ) ? ICL_SITEPRESS_VERSION : '';
116
-
117
- wp_enqueue_script( 'installer-admin', $this->res_url() . '/res/js/admin.js', array( 'jquery' ), $this->version() );
118
- wp_enqueue_style( 'installer-admin', $this->res_url() . '/res/css/admin.css', array(), $this->version() );
119
-
120
- $translation_array = array(
121
- 'installing' => __( 'Installing %s', 'installer' ),
122
- 'updating' => __( 'Updating %s', 'installer' ),
123
- 'activating' => __( 'Activating %s', 'installer' )
124
- );
125
-
126
- wp_localize_script( 'installer-admin', 'installer_strings', $translation_array );
127
-
128
- if ( $pagenow == 'plugins.php' ) {
129
- add_action( 'admin_notices', array( $this, 'setup_plugins_page_notices' ) );
130
- add_action( 'admin_notices', array( $this, 'setup_plugins_renew_warnings' ), 10 );
131
- add_action( 'admin_notices', array( $this, 'queue_plugins_renew_warnings' ), 20 );
132
-
133
- add_action( 'admin_init', array( $this, 'setup_plugins_action_links' ) );
134
-
135
- }
136
-
137
- if ( $this->is_repositories_page() ) {
138
- add_action( 'admin_init', array( $this, 'validate_repository_subscription' ) );
139
- }
140
-
141
- if ( defined( 'DOING_AJAX' ) ) {
142
- add_action( 'wp_ajax_save_site_key', array( $this, 'save_site_key' ) );
143
- add_action( 'wp_ajax_remove_site_key', array( $this, 'remove_site_key_ajax' ) );
144
- add_action( 'wp_ajax_update_site_key', array( $this, 'update_site_key' ) );
145
-
146
- add_action( 'wp_ajax_installer_download_plugin', array( $this, 'download_plugin_ajax_handler' ) );
147
- add_action( 'wp_ajax_installer_activate_plugin', array( $this, 'activate_plugin' ) );
148
-
149
- add_action( 'wp_ajax_installer_dismiss_nag', array( $this, 'dismiss_nag' ) );
150
- }
151
-
152
- if ( $pagenow == 'update.php' ) {
153
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'update-selected' ) {
154
- add_action( 'admin_head', array( $this, 'plugin_upgrade_custom_errors' ) ); //iframe/bulk
155
- } else {
156
- add_action( 'all_admin_notices', array( $this, 'plugin_upgrade_custom_errors' ) ); //regular/singular
157
- }
158
- }
159
-
160
- // WP 4.2
161
- if ( defined( 'DOING_AJAX' ) ) {
162
- add_action( 'wp_ajax_update-plugin', array(
163
- $this,
164
- 'plugin_upgrade_custom_errors'
165
- ), 0 ); // high priority, before WP
166
- }
167
-
168
- //Include theme support
169
- include_once $this->plugin_path() . '/includes/class-installer-theme.php';
170
-
171
- // Extra information about the source of Installer
172
- $package_source_file = $this->plugin_path() . '/installer-source.json';
173
- if ( file_exists( $package_source_file ) ) {
174
- WP_Filesystem();
175
- global $wp_filesystem;
176
- $this->package_source = json_decode( $wp_filesystem->get_contents( $package_source_file ) );
177
- }
178
- }
179
-
180
- protected function log( $message ) {
181
- require_once ABSPATH . 'wp-admin/includes/file.php';
182
- WP_Filesystem();
183
- global $wp_filesystem;
184
- if ( defined( 'WPML_INSTALLER_LOGGING' ) && WPML_INSTALLER_LOGGING ) {
185
- $wp_filesystem->put_contents( $this->plugin_path() . '/installer.log', current_time( 'mysql' ) . "\t" . $message . "\n" );
186
- }
187
- }
188
-
189
- public function register_admin_message( $text, $type = 'updated' ) {
190
- $this->admin_messages[] = array( 'text' => $text, 'type' => $type );
191
- }
192
-
193
- public function show_admin_messages() {
194
- if ( ! empty( $this->admin_messages ) ) {
195
- $types = array( 'error', 'updated', 'notice' );
196
- foreach ( $this->admin_messages as $message ) {
197
- $class = in_array( $message['type'], $types ) ? $message['type'] : 'updated';
198
- ?>
199
- <div class="<?php echo $class ?>">
200
- <p>
201
- <?php echo $message['text'] ?>
202
- </p>
203
- </div>
204
- <?php
205
- }
206
- }
207
- }
208
-
209
- public function load_locale() {
210
- if ( function_exists( 'get_user_locale' ) ) {
211
- $locale = get_user_locale();
212
- } else {
213
- $locale = get_locale();
214
- }
215
- $locale = apply_filters( 'plugin_locale', $locale, 'installer' );
216
- $mo_file = $this->plugin_path() . '/locale/installer-' . $locale . '.mo';
217
- if ( file_exists( $mo_file ) ) {
218
- load_textdomain( 'installer', $mo_file );
219
- }
220
- }
221
-
222
- public function load_embedded_plugins() {
223
- if ( file_exists( $this->plugin_path() . '/embedded-plugins' ) ) {
224
- include_once $this->plugin_path() . '/embedded-plugins/embedded-plugins.class.php';
225
- $this->installer_embedded_plugins = new Installer_Embedded_Plugins();
226
- }
227
- }
228
-
229
- public function menu_setup() {
230
- global $pagenow;
231
-
232
- if ( is_multisite() && ! is_network_admin() ) {
233
- $this->menu_multisite_redirect();
234
- add_options_page( __( 'Installer', 'installer' ), __( 'Installer', 'installer' ), 'manage_options', 'installer', array(
235
- $this,
236
- 'show_products'
237
- ) );
238
- } else {
239
- if ( $this->config['plugins_install_tab'] && is_admin() && $pagenow == 'plugin-install.php' ) {
240
- // Default GUI, under Plugins -> Install
241
- add_filter( 'install_plugins_tabs', array( $this, 'add_install_plugins_tab' ) );
242
- add_action( 'install_plugins_commercial', array( $this, 'show_products' ) );
243
- }
244
- }
245
-
246
- }
247
-
248
- public function menu_url() {
249
- if ( is_multisite() ) {
250
- if ( is_network_admin() ) {
251
- $url = network_admin_url( 'plugin-install.php?tab=commercial' );
252
- } else {
253
- $url = admin_url( 'options-general.php?page=installer' );
254
- }
255
- } else {
256
- $url = admin_url( 'plugin-install.php?tab=commercial' );
257
- }
258
-
259
- return $url;
260
- }
261
-
262
- private function menu_multisite_redirect() {
263
- global $pagenow;
264
-
265
- if ( $pagenow == 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] == 'commercial' ) {
266
- wp_redirect( $this->menu_url() );
267
- exit;
268
- }
269
-
270
- }
271
-
272
- private function _pre_1_0_clean_up() {
273
- global $wpdb;
274
-
275
- if ( ! defined( 'WPRC_VERSION' ) ) {
276
- $old_tables = array(
277
- $wpdb->prefix . 'wprc_cached_requests',
278
- $wpdb->prefix . 'wprc_extension_types',
279
- $wpdb->prefix . 'wprc_extensions',
280
- $wpdb->prefix . 'wprc_repositories',
281
- $wpdb->prefix . 'wprc_repositories_relationships',
282
- );
283
-
284
- foreach ( $old_tables as $table ) {
285
- $wpdb->query( sprintf( "DROP TABLE IF EXISTS %s", $table ) );
286
- }
287
-
288
- }
289
-
290
- $this->settings['_pre_1_0_clean_up'] = true;
291
- $this->save_settings();
292
- }
293
-
294
- public function setup_plugins_action_links() {
295
-
296
- $plugins = get_plugins();
297
-
298
- $repositories_plugins = array();
299
-
300
- if ( ! empty( $this->settings['repositories'] ) ) {
301
-
302
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
303
-
304
- foreach ( $repository['data']['packages'] as $package ) {
305
-
306
- foreach ( $package['products'] as $product ) {
307
-
308
- foreach ( $product['plugins'] as $plugin_slug ) {
309
-
310
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
311
-
312
- if ( ! isset( $repositories_plugins[ $repository_id ][ $download['slug'] ] ) ) {
313
- $repositories_plugins[ $repository_id ][ $download['slug'] ] = array(
314
- 'name' => $download['name'],
315
- 'registered' => $this->plugin_is_registered( $repository_id, $download['slug'] ) ? 1 : 0
316
- );
317
- }
318
-
319
- }
320
-
321
- }
322
-
323
- }
324
-
325
- foreach ( $plugins as $plugin_id => $plugin ) {
326
-
327
- $wp_plugin_slug = dirname( $plugin_id );
328
- if ( empty( $wp_plugin_slug ) ) {
329
- $wp_plugin_slug = basename( $plugin_id, '.php' );
330
- }
331
-
332
- foreach ( $repositories_plugins as $repository_id => $r_plugins ) {
333
-
334
- foreach ( $r_plugins as $slug => $r_plugin ) {
335
-
336
- if ( $wp_plugin_slug == $slug || $r_plugin['name'] == $plugin['Name'] || $r_plugin['name'] == $plugin['Title'] ) { //match order: slug, name, title
337
-
338
- if ( $r_plugin['registered'] ) {
339
- add_filter( 'plugin_action_links_' . $plugin_id, array(
340
- $this,
341
- 'plugins_action_links_registered'
342
- ) );
343
- } else {
344
- add_filter( 'plugin_action_links_' . $plugin_id, array(
345
- $this,
346
- 'plugins_action_links_not_registered'
347
- ) );
348
- }
349
-
350
- }
351
-
352
- }
353
-
354
- }
355
-
356
-
357
- }
358
-
359
- }
360
- }
361
-
362
- }
363
-
364
- public function plugins_action_links_registered( $links ) {
365
- $links[] = '<a href="' . $this->menu_url() . '">' . __( 'Registered', 'installer' ) . '</a>';
366
-
367
- return $links;
368
- }
369
-
370
- public function plugins_action_links_not_registered( $links ) {
371
- $links[] = '<a href="' . $this->menu_url() . '">' . __( 'Register', 'installer' ) . '</a>';
372
-
373
- return $links;
374
- }
375
-
376
- public function plugin_is_registered( $repository_id, $slug ) {
377
-
378
- $registered = false;
379
-
380
- if ( $this->repository_has_valid_subscription( $repository_id ) ) {
381
-
382
- $subscription_type = $this->get_subscription_type_for_repository( $repository_id );
383
- $r_plugins = array();
384
-
385
- foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
386
-
387
- foreach ( $package['products'] as $product ) {
388
-
389
- if ( $product['subscription_type'] == $subscription_type || $this->have_superior_subscription( $subscription_type, $product ) ) {
390
-
391
- foreach ( $product['plugins'] as $plugin_slug ) {
392
-
393
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
394
-
395
- if ( ! isset( $rep_plugins[ $download['slug'] ] ) ) {
396
- $r_plugins[ $download['slug'] ] = $download['slug'];
397
- }
398
-
399
- }
400
-
401
- }
402
-
403
- }
404
-
405
- }
406
-
407
- $registered = isset( $r_plugins[ $slug ] );
408
-
409
- }
410
-
411
-
412
- return $registered;
413
-
414
- }
415
-
416
- public function version() {
417
- return WP_INSTALLER_VERSION;
418
- }
419
-
420
- public function plugin_path() {
421
- return untrailingslashit( plugin_dir_path( dirname( __FILE__ ) ) );
422
- }
423
-
424
- public function plugin_url() {
425
- if ( isset( $this->config['in_theme_folder'] ) && ! empty( $this->config['in_theme_folder'] ) ) {
426
- $url = untrailingslashit( get_template_directory_uri() . '/' . $this->config['in_theme_folder'] );
427
- } else {
428
- $url = untrailingslashit( plugins_url( '/', dirname( __FILE__ ) ) );
429
- }
430
-
431
- return $url;
432
- }
433
-
434
- public function is_repositories_page() {
435
- global $pagenow;
436
-
437
- return $pagenow == 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] == 'commercial';
438
- }
439
-
440
- public function res_url() {
441
- if ( isset( $this->config['in_theme_folder'] ) && ! empty( $this->config['in_theme_folder'] ) ) {
442
- $url = untrailingslashit( get_template_directory_uri() . '/' . $this->config['in_theme_folder'] );
443
- } else {
444
- $url = $this->plugin_url();
445
- }
446
-
447
- return $url;
448
- }
449
-
450
- public function save_settings() {
451
-
452
- $_settings = serialize( $this->settings );
453
- if ( $this->_gz_on ) {
454
- $_settings = gzcompress( $_settings );
455
- }
456
- $_settings = base64_encode( $_settings );
457
-
458
- update_option( 'wp_installer_settings', $_settings );
459
-
460
- if ( is_multisite() && is_main_site() && isset( $this->settings['repositories'] ) ) {
461
- $network_settings = array();
462
-
463
- foreach ( $this->settings['repositories'] as $rep_id => $repository ) {
464
- if ( isset( $repository['subscription'] ) ) {
465
- $network_settings[ $rep_id ] = $repository['subscription'];
466
- }
467
- }
468
-
469
- update_site_option( 'wp_installer_network', $network_settings );
470
-
471
-
472
- }
473
-
474
- }
475
-
476
- public function get_settings( $refresh = false ) {
477
-
478
- if ( $refresh || empty( $this->settings ) ) {
479
-
480
- $_settings = get_option( 'wp_installer_settings' );
481
-
482
-
483
- if ( is_array( $_settings ) || empty( $_settings ) ) { //backward compatibility 1.1
484
- $this->settings = $_settings;
485
-
486
- } else {
487
- $_settings = base64_decode( $_settings );
488
- if ( $this->_gz_on ) {
489
- $_settings = gzuncompress( $_settings );
490
- }
491
- $this->settings = unserialize( $_settings );
492
- }
493
-
494
- // Initialize
495
- if ( empty( $this->settings ) ) {
496
- $this->settings = array(
497
- 'repositories' => array()
498
- );
499
- }
500
-
501
- if ( is_multisite() ) {
502
- $network_settings = maybe_unserialize( get_site_option( 'wp_installer_network' ) );
503
- if ( $network_settings ) {
504
- foreach ( $this->settings['repositories'] as $rep_id => $repository ) {
505
- if ( isset( $network_settings[ $rep_id ] ) ) {
506
- $this->settings['repositories'][ $rep_id ]['subscription'] = $network_settings[ $rep_id ];
507
- }
508
- }
509
- }
510
- }
511
-
512
- $this->load_hardcoded_site_keys();
513
-
514
- $this->_pre_1_8_backwards_compatibility( $this->settings );
515
-
516
- $this->settings = $this->_old_products_format_backwards_compatibility( $this->settings );
517
-
518
- }
519
-
520
- return $this->settings;
521
- }
522
-
523
- private function load_hardcoded_site_keys() {
524
-
525
- if ( ! empty( $this->settings['repositories'] ) ) {
526
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
527
-
528
- if ( $site_key = self::get_repository_hardcoded_site_key( $repository_id ) ) {
529
-
530
- $site_key_missing = empty( $this->settings['repositories'][ $repository_id ]['subscription']['data'] );
531
- $site_key_changed = ! $site_key_missing &&
532
- $this->settings['repositories'][ $repository_id ]['subscription']['key'] != $site_key;
533
-
534
- if ( $site_key_missing || $site_key_changed ) {
535
-
536
- if ( ! function_exists( 'get_plugins' ) ) {
537
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
538
- }
539
- $this->load_repositories_list();
540
- $response = $this->save_site_key(
541
- array(
542
- 'repository_id' => $repository_id,
543
- 'site_key' => $site_key,
544
- 'return' => true,
545
- 'nonce' => wp_create_nonce( 'save_site_key_' . $repository_id )
546
- )
547
- );
548
-
549
- if ( ! empty( $response['error'] ) ) {
550
- $this->remove_site_key( $repository_id );
551
-
552
- $this->admin_messages[] = array(
553
- 'type' => 'error',
554
- 'text' => sprintf( __( 'You are using an invalid site key defined as the constant %s (most likely in wp-config.php).
555
- Please remove it or use the correct value in order to be able to register correctly.', 'installer' ), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper( $repository_id ) )
556
- );
557
-
558
- }
559
-
560
- }
561
-
562
- }
563
-
564
- }
565
- }
566
-
567
- }
568
-
569
- public static function get_repository_hardcoded_site_key( $repository_id ) {
570
-
571
- $site_key = false;
572
-
573
- $site_key_constant = 'OTGS_INSTALLER_SITE_KEY_' . strtoupper( $repository_id );
574
- if ( defined( $site_key_constant ) ) {
575
- $site_key = constant( $site_key_constant );
576
- }
577
-
578
- return $site_key;
579
- }
580
-
581
- //backward compatibility, add channel
582
- private function _pre_1_8_backwards_compatibility( &$settings ) {
583
- if ( empty( $settings['_pre_1_8_clean_up'] ) ) {
584
- foreach ( $settings['repositories'] as $repository_id => $repository ) {
585
- foreach ( $repository['data']['downloads']['plugins'] as $slug => $download ) {
586
- if( !isset( $download['channel'] ) ){
587
- $settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $slug ]['channel'] = '';
588
- }
589
- }
590
- }
591
- $this->save_settings();
592
- }
593
- }
594
-
595
- //backward compatibility - support old products list format (downloads under products instead of global downloads list)
596
- private function _old_products_format_backwards_compatibility( $settings ) {
597
-
598
- if ( version_compare( $this->version(), '1.8', '<' ) && ! empty( $settings['repositories'] ) && empty( $this->_old_products_format_backwards_compatibility ) ) {
599
-
600
- foreach ( $settings['repositories'] as $repository_id => $repository ) {
601
- $populate_downloads = false;
602
- if ( isset( $repository['data'] ) ) {
603
-
604
- foreach ( $repository['data']['packages'] as $package_id => $package ) {
605
- foreach ( $package['products'] as $product_id => $product ) {
606
- if ( ! isset( $product['plugins'] ) ) {
607
- $populate_downloads = true;
608
- foreach ( $product['downloads'] as $download_id => $download ) {
609
- $settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['plugins'][] = $download['slug'];
610
- }
611
- }
612
- }
613
- }
614
-
615
- if ( $populate_downloads ) {
616
- // Add downloads branch
617
- foreach ( $repository['data']['packages'] as $package_id => $package ) {
618
- foreach ( $package['products'] as $product_id => $product ) {
619
- foreach ( $product['downloads'] as $download_id => $download ) {
620
- if ( ! isset( $settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $download['slug'] ] ) ) {
621
- $settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $download['slug'] ] = $download;
622
- }
623
- $settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['plugins'][] = $download['slug'];
624
- }
625
- unset( $settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['downloads'] );
626
- }
627
- }
628
- }
629
- }
630
- }
631
-
632
- $this->_old_products_format_backwards_compatibility = true;
633
- }
634
-
635
- return $settings;
636
- }
637
-
638
- public function get_installer_site_url( $repository_id = false ) {
639
- global $current_site;
640
-
641
- $site_url = get_site_url();
642
-
643
- if ( $repository_id && is_multisite() && isset( $this->settings['repositories'] ) ) {
644
- $network_settings = maybe_unserialize( get_site_option( 'wp_installer_network' ) );
645
-
646
- if ( isset( $network_settings[ $repository_id ] ) ) {
647
- $site_url = get_site_url( $current_site->blog_id );
648
- }
649
-
650
- }
651
-
652
- return $site_url;
653
- }
654
-
655
- public function show_site_key_nags() {
656
- $screen = get_current_screen();
657
-
658
- if ( $screen->base == 'settings_page_installer' || ( $screen->base == 'plugin-install' && isset( $_GET['tab'] ) && $_GET['tab'] == 'commercial' ) ) {
659
- return;
660
- }
661
-
662
- if ( ! empty( $this->config['site_key_nags'] ) ) {
663
-
664
- foreach ( $this->config['site_key_nags'] as $nag ) {
665
-
666
- if ( ! $this->repository_has_subscription( $nag['repository_id'] ) ) {
667
- $show = true;
668
- if ( ! empty( $nag['condition_cb'] ) ) {
669
- $show = call_user_func( $nag['condition_cb'] );
670
- }
671
-
672
- if ( empty( $this->settings['dismissed_nags'][ $nag['repository_id'] ] ) && $show ) {
673
- echo '<div class="updated error otgs-is-dismissible"><p>';
674
- printf( __( "To get automatic updates, you need to register %s for this site. %sRegister %s%s", 'sitepress' ),
675
- $nag['product_name'], '<a class="button-primary" href="' . $this->menu_url() . '">', $nag['product_name'], '</a>' );
676
-
677
- echo '</p>';
678
- echo '<span class="installer-dismiss-nag notice-dismiss" data-repository="' . $nag['repository_id'] . '"><span class="screen-reader-text">' . __( 'Dismiss', 'sitepress' ) . '</span></span>';
679
- echo '</div>';
680
- }
681
- }
682
-
683
- }
684
-
685
- }
686
-
687
- }
688
-
689
- public function dismiss_nag() {
690
- $this->settings['dismissed_nags'][ $_POST['repository'] ] = 1;
691
-
692
- $this->save_settings();
693
-
694
- echo json_encode( array() );
695
- exit;
696
- }
697
-
698
- public function add_install_plugins_tab( $tabs ) {
699
-
700
- $tabs['commercial'] = __( 'Commercial', 'installer' );
701
-
702
- return $tabs;
703
- }
704
-
705
- public function load_repositories_list() {
706
- global $wp_installer_instances;
707
-
708
- foreach ( $wp_installer_instances as $instance ) {
709
-
710
- if ( file_exists( dirname( $instance['bootfile'] ) . '/repositories.xml' ) ) {
711
- $config_file = dirname( $instance['bootfile'] ) . '/repositories.xml';
712
-
713
- if ( file_exists( dirname( $instance['bootfile'] ) . '/repositories.sandbox.xml' ) ) {
714
- $config_file = dirname( $instance['bootfile'] ) . '/repositories.sandbox.xml';
715
- add_filter( 'https_ssl_verify', '__return_false' );
716
- }
717
-
718
- $repos = simplexml_load_file( $config_file );
719
-
720
- if ( $repos ) {
721
- foreach ( $repos as $repo ) {
722
- $id = strval( $repo->id );
723
-
724
- $data['api-url'] = strval( $repo->apiurl );
725
- $data['products'] = strval( $repo->products );
726
-
727
- // excludes rule;
728
- if ( isset( $this->config['repositories_exclude'] ) && in_array( $id, $this->config['repositories_exclude'] ) ) {
729
- continue;
730
- }
731
-
732
- // includes rule;
733
- if ( isset( $this->config['repositories_include'] ) && ! in_array( $id, $this->config['repositories_include'] ) ) {
734
- continue;
735
- }
736
-
737
- $this->repositories[ $id ] = $data;
738
-
739
- }
740
- }
741
-
742
- }
743
- }
744
-
745
- }
746
-
747
- public function filter_repositories_list() {
748
-
749
- if ( ! empty( $this->settings['repositories'] ) ) {
750
- foreach ( $this->settings['repositories'] as $id => $repo_data ) {
751
-
752
- // excludes rule;
753
- if ( isset( $this->config['repositories_exclude'] ) && in_array( $id, $this->config['repositories_exclude'] ) ) {
754
- unset( $this->settings['repositories'][ $id ] );
755
- }
756
-
757
- // includes rule;
758
- if ( isset( $this->config['repositories_include'] ) && ! in_array( $id, $this->config['repositories_include'] ) ) {
759
- unset( $this->settings['repositories'][ $id ] );
760
- }
761
-
762
-
763
- }
764
- }
765
-
766
-
767
- }
768
-
769
- public function refresh_repositories_data() {
770
- static $checked = false;
771
-
772
- if ( defined( 'OTGS_DISABLE_AUTO_UPDATES' ) && OTGS_DISABLE_AUTO_UPDATES && empty( $_GET['force-check'] ) || $checked ) {
773
-
774
- if ( empty( $this->settings['repositories'] ) && $this->is_repositories_page() ) {
775
-
776
- foreach ( $this->repositories as $id => $data ) {
777
- $repository_names[] = $id;
778
-
779
- }
780
-
781
- $error = sprintf( __( "Installer cannot display the products information because the automatic updating for %s was explicitly disabled with the configuration below (usually in wp-config.php):", 'installer' ), strtoupper( join( ', ', $repository_names ) ) );
782
- $error .= '<br /><br /><code>define("OTGS_DISABLE_AUTO_UPDATES", true);</code><br /><br />';
783
- $error .= sprintf( __( "In order to see the products information, please run the %smanual updates check%s to initialize the products list or (temporarily) remove the above code.", 'installer' ), '<a href="' . admin_url( 'update-core.php' ) . '">', '</a>' );
784
-
785
- $this->register_admin_message( $error, 'error' );
786
-
787
-
788
- }
789
-
790
- return;
791
- }
792
-
793
- $checked = true;
794
-
795
- foreach ( $this->repositories as $id => $data ) {
796
-
797
- $response = wp_remote_get( $data['products'] );
798
-
799
- if ( is_wp_error( $response ) ) {
800
- // http fallback
801
- $data['products'] = preg_replace( "@^https://@", 'http://', $data['products'] );
802
- $response = wp_remote_get( $data['products'] );
803
- }
804
-
805
- if ( is_wp_error( $response ) ) {
806
-
807
- $error = sprintf( __( "Installer cannot contact our updates server to get information about the available products and check for new versions. If you are seeing this message for the first time, you can ignore it, as it may be a temporary communication problem. If the problem persists and your WordPress admin is slowing down, you can disable automated version checks. Add the following line to your wp-config.php file:", 'installer' ), strtoupper( $id ) );
808
- $error .= '<br /><br /><code>define("OTGS_DISABLE_AUTO_UPDATES", true);</code>';
809
-
810
- $this->register_admin_message( $error, 'error' );
811
-
812
- continue;
813
- }
814
-
815
- if ( $response && isset( $response['response']['code'] ) && $response['response']['code'] == 200 ) {
816
- $body = wp_remote_retrieve_body( $response );
817
- if ( $body ) {
818
- $products = json_decode( $body, true );
819
-
820
- if ( is_array( $products ) ) {
821
- $products['downloads'] = WP_Installer_Channels()->filter_downloads_by_channel( $id, $products['downloads'] );
822
- $this->set_release_notes( $products['downloads'] );
823
-
824
- $this->settings['repositories'][ $id ]['data'] = $products;
825
- $this->_pre_1_8_backwards_compatibility( $this->settings );
826
- }
827
- }
828
-
829
- }
830
-
831
- $this->log( sprintf( "Checked for %s updates: %s", $id, $data['products'] ) );
832
-
833
-
834
- }
835
-
836
- // cleanup
837
- if ( empty( $this->settings['repositories'] ) ) {
838
- $this->settings['repositories'] = array();
839
- }
840
- foreach ( $this->settings['repositories'] as $id => $data ) {
841
- if ( ! in_array( $id, array_keys( $this->repositories ) ) ) {
842
- unset( $this->settings['repositories'][ $id ] );
843
- }
844
- }
845
-
846
- $this->settings['last_repositories_update'] = time();
847
-
848
- $this->save_settings();
849
-
850
- }
851
-
852
- /**
853
- * Gets the release notes for the available version from the changelog
854
- *
855
- * @param array $all_downloads
856
- */
857
- private function set_release_notes( &$all_downloads ) {
858
- foreach ( $all_downloads as $kind => $downloads ) {
859
- foreach ( $downloads as $slug => $download ) {
860
- $start = strpos( $download['changelog'], '<h4>' . $download['version'] . '</h4>' );
861
- if ( $start !== false ) {
862
- $start += strlen( $download['version'] ) + 9;
863
- $end = strpos( $download['changelog'], '<h4>', 4 );
864
- if ( $end ) {
865
- $release_notes = substr( $download['changelog'], $start, $end - $start );
866
- } else {
867
- $release_notes = substr( $download['changelog'], $start );
868
- }
869
- }
870
- $all_downloads[ $kind ][ $slug ]['release-notes'] = ! empty( $release_notes ) ? $release_notes : '';
871
- }
872
- }
873
- }
874
-
875
- public function show_products( $args = array() ) {
876
-
877
- $screen = get_current_screen();
878
-
879
- if ( $screen->base == 'settings_page_installer' ) { // settings page
880
- echo '<div class="wrap">';
881
- echo '<h2>' . __( 'Installer', 'installer' ) . '</h2>';
882
- echo '<br />';
883
- }
884
-
885
- if ( ! is_array( $args ) ) {
886
- $args = array();
887
- }
888
- if ( empty( $args['template'] ) ) {
889
- $args['template'] = 'default';
890
- }
891
-
892
- $this->filter_repositories_list();
893
-
894
- if ( ! empty( $this->settings['repositories'] ) ) {
895
-
896
- $this->localize_strings();
897
- $this->set_filtered_prices( $args );
898
- $this->set_hierarchy_and_order();
899
-
900
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
901
-
902
- if ( $args['template'] == 'compact' ) {
903
-
904
- if ( isset( $args['repository'] ) && $args['repository'] == $repository_id ) {
905
- include $this->plugin_path() . '/templates/products-compact.php';
906
- }
907
-
908
- } else {
909
-
910
- include $this->plugin_path() . '/templates/repository-listing.php';
911
-
912
- }
913
-
914
- unset( $site_key, $subscription_type, $expired, $upgrade_options, $products_avaliable );
915
-
916
- }
917
-
918
- } else {
919
-
920
- echo '<center>' . __( 'No repositories defined.', 'installer' ) . '</center>';
921
-
922
- }
923
-
924
- if ( $screen->base == 'settings_page_installer' ) { // settings page
925
- echo '</div>';
926
- }
927
-
928
-
929
- }
930
-
931
- public function get_product_price( $repository_id, $package_id, $product_id, $incl_discount = false ) {
932
-
933
- $price = false;
934
-
935
- foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
936
-
937
- if ( $package['id'] == $package_id ) {
938
- if ( isset( $package['products'][ $product_id ] ) ) {
939
- if ( $incl_discount && isset( $package['products'][ $product_id ]['price_disc'] ) ) {
940
- $price = $package['products'][ $product_id ]['price_disc'];
941
- } elseif ( isset( $package['products'][ $product_id ]['price'] ) ) {
942
- $price = $package['products'][ $product_id ]['price'];
943
- }
944
- }
945
- break;
946
- }
947
- }
948
-
949
- return $price;
950
- }
951
-
952
- private function _render_product_packages( $packages, $subscription_type, $expired, $upgrade_options, $repository_id ) {
953
-
954
- $data = array();
955
-
956
- foreach ( $packages as $package_id => $package ) {
957
-
958
- $row = array( 'products' => array(), 'downloads' => array() );
959
- foreach ( $package['products'] as $product ) {
960
-
961
- // filter out free subscriptions from being displayed as buying options
962
- if ( empty( $product['price'] ) && ( empty( $subscription_type ) || $expired ) ) {
963
- continue;
964
- }
965
-
966
- //consider equivalent subscriptions
967
- if ( empty( $product['subscription_type_equivalent'] ) ) {
968
- $product['subscription_type_equivalent'] = '';
969
- }
970
-
971
- // buy base
972
- if ( empty( $subscription_type ) || $expired ) {
973
-
974
- $p['url'] = $this->append_parameters_to_buy_url( $product['url'], $repository_id );
975
- if ( ! empty( $product['price_disc'] ) ) {
976
- $p['label'] = $product['call2action'] . ' - ' . sprintf( '$%s %s$%d%s (USD)', $product['price_disc'], '&nbsp;&nbsp;<del>', $product['price'], '</del>' );
977
- } else {
978
- $p['label'] = $product['call2action'] . ' - ' . sprintf( '$%d (USD)', $product['price'] );
979
- }
980
- $row['products'][] = $p;
981
-
982
- // renew
983
- } elseif ( isset( $subscription_type ) && ( $product['subscription_type'] == $subscription_type || $product['subscription_type_equivalent'] == $subscription_type ) ) {
984
-
985
- if ( $product['renewals'] ) {
986
- foreach ( $product['renewals'] as $renewal ) {
987
- $p['url'] = $this->append_parameters_to_buy_url( $renewal['url'], $repository_id );
988
- $p['label'] = $renewal['call2action'] . ' - ' . sprintf( '$%d (USD)', $renewal['price'] );
989
- }
990
-
991
- $row['products'][] = $p;
992
- }
993
-
994
- }
995
-
996
- // upgrades
997
- if ( ! empty( $upgrade_options[ $product['subscription_type'] ] ) ) {
998
-
999
- foreach ( $upgrade_options[ $product['subscription_type'] ] as $stype => $upgrade ) {
1000
- if ( $stype != $subscription_type ) {
1001
- continue;
1002
- }
1003
-
1004
- $p['url'] = $this->append_parameters_to_buy_url( $upgrade['url'], $repository_id );
1005
- if ( ! empty( $upgrade['price_disc'] ) ) {
1006
- $p['label'] = $upgrade['call2action'] . ' - ' . sprintf( '$%s %s$%d%s (USD)', $upgrade['price_disc'], '&nbsp;&nbsp;<del>', $upgrade['price'], '</del>' );
1007
- } else {
1008
- $p['label'] = $upgrade['call2action'] . ' - ' . sprintf( '$%d (USD)', $upgrade['price'] );
1009
- }
1010
- $row['products'][] = $p;
1011
-
1012
- }
1013
-
1014
- }
1015
-
1016
- // downloads
1017
- if ( isset( $subscription_type ) && ! $expired && ( $product['subscription_type'] == $subscription_type || $product['subscription_type_equivalent'] == $subscription_type ) ) {
1018
-
1019
- foreach ( $product['plugins'] as $plugin_slug ) {
1020
- $row['downloads'][ $plugin_slug ] = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1021
- }
1022
-
1023
- }
1024
-
1025
- //subpackages
1026
- if ( ! empty( $package['sub-packages'] ) ) {
1027
- $row['sub-packages'] = $package['sub-packages'];
1028
- }
1029
-
1030
- }
1031
-
1032
- $row['id'] = $package['id'];
1033
- $row['image_url'] = $package['image_url'];
1034
- $row['name'] = $package['name'];
1035
- $row['description'] = $package['description'];
1036
-
1037
- if ( ! empty( $row['products'] ) || ! empty( $row['downloads'] ) || ! empty( $row['sub-packages'] ) ) {
1038
- $data[] = $row;
1039
- }
1040
-
1041
-
1042
- }
1043
-
1044
- return $data;
1045
-
1046
- }
1047
-
1048
- public function get_extra_url_parameters() {
1049
-
1050
- $parameters = array();
1051
-
1052
- if ( ! empty( $this->package_source ) ) {
1053
- foreach ( $this->package_source as $key => $val ) {
1054
- $parameters[ $key ] = $val;
1055
- }
1056
- }
1057
-
1058
- $parameters['installer_version'] = WP_INSTALLER_VERSION;
1059
- $parameters['theme'] = wp_get_theme()->get( 'Name' );
1060
- $parameters['site_name'] = get_bloginfo( 'name' );
1061
-
1062
- return $parameters;
1063
- }
1064
-
1065
- public function append_parameters_to_buy_url( $url, $repository_id, $args = array() ) {
1066
-
1067
- $url = add_query_arg( array( 'icl_site_url' => $this->get_installer_site_url( $repository_id ) ), $url );
1068
-
1069
- $affiliate_id = false;
1070
- $affiliate_key = false;
1071
-
1072
- // Add extra parameters for custom Installer packages
1073
- if ( ! empty( $this->package_source ) ) {
1074
- $extra = $this->get_extra_url_parameters();
1075
-
1076
- if ( ! empty( $extra['repository'] ) && $extra['repository'] == $repository_id ) {
1077
-
1078
- if ( ! empty( $extra['affiliate_key'] ) && ! empty( $extra['user_id'] ) ) {
1079
- $this->config[ 'affiliate_id:' . $repository_id ] = $extra['user_id'];
1080
- $this->config[ 'affiliate_key:' . $repository_id ] = $extra['affiliate_key'];
1081
- unset( $extra['affiliate_key'], $extra['user_id'], $extra['repository'] ); // no need to include these ones
1082
- }
1083
-
1084
- $url = add_query_arg( $extra, $url );
1085
- }
1086
-
1087
- }
1088
-
1089
- if ( isset( $this->config[ 'affiliate_id:' . $repository_id ] ) && isset( $this->config[ 'affiliate_key:' . $repository_id ] ) ) {
1090
-
1091
- $affiliate_id = $this->config[ 'affiliate_id:' . $repository_id ];
1092
- $affiliate_key = $this->config[ 'affiliate_key:' . $repository_id ];
1093
-
1094
- } elseif ( isset( $args[ 'affiliate_id:' . $repository_id ] ) && isset( $args[ 'affiliate_key:' . $repository_id ] ) ) {
1095
-
1096
- $affiliate_id = $args[ 'affiliate_id:' . $repository_id ];
1097
- $affiliate_key = $args[ 'affiliate_key:' . $repository_id ];
1098
-
1099
- } elseif ( defined( 'ICL_AFFILIATE_ID' ) && defined( 'ICL_AFFILIATE_KEY' ) ) { //support for 1 repo
1100
-
1101
- $affiliate_id = ICL_AFFILIATE_ID;
1102
- $affiliate_key = ICL_AFFILIATE_KEY;
1103
-
1104
- } elseif ( isset( $this->config['affiliate_id'] ) && isset( $this->config['affiliate_key'] ) ) {
1105
- // BACKWARDS COMPATIBILITY
1106
- $affiliate_id = $this->config['affiliate_id'];
1107
- $affiliate_key = $this->config['affiliate_key'];
1108
- }
1109
-
1110
- if ( $affiliate_id && $affiliate_key ) {
1111
- $url = add_query_arg( array( 'aid' => $affiliate_id, 'affiliate_key' => $affiliate_key ), $url );
1112
- }
1113
-
1114
- if ( $repository_id == 'wpml' ) {
1115
- $url = add_query_arg( array(
1116
- 'using_icl' => $this->_using_icl,
1117
- 'wpml_version' => $this->_wpml_version
1118
- ), $url );
1119
- }
1120
-
1121
- $url = apply_filters( 'wp_installer_buy_url', $url );
1122
-
1123
- $url = esc_url( $url );
1124
-
1125
- return $url;
1126
-
1127
- }
1128
-
1129
- public function save_site_key( $args = array() ) {
1130
-
1131
- $error = '';
1132
-
1133
- if ( isset( $args['repository_id'] ) ) {
1134
- $repository_id = $args['repository_id'];
1135
- } elseif ( isset( $_POST['repository_id'] ) ) {
1136
- $repository_id = sanitize_text_field( $_POST['repository_id'] );
1137
- } else {
1138
- $repository_id = false;
1139
- }
1140
-
1141
- if ( isset( $args['nonce'] ) ) {
1142
- $nonce = $args['nonce'];
1143
- } elseif ( isset( $_POST['nonce'] ) ) {
1144
- $nonce = sanitize_text_field( $_POST['nonce'] );
1145
- } else {
1146
- $nonce = '';
1147
- }
1148
-
1149
- if ( isset( $args['site_key'] ) ) {
1150
- $site_key = $args['site_key'];
1151
- } else {
1152
- $site_key = sanitize_text_field( $_POST[ 'site_key_' . $repository_id ] );
1153
- }
1154
- $site_key = preg_replace( "/[^A-Za-z0-9]/", '', $site_key );
1155
-
1156
- if ( $repository_id && $nonce && wp_create_nonce( 'save_site_key_' . $repository_id ) == $nonce ) {
1157
-
1158
- try {
1159
- $subscription_data = $this->fetch_subscription_data( $repository_id, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REGISTRATION );
1160
-
1161
- if ( $subscription_data ) {
1162
- $this->settings['repositories'][ $repository_id ]['subscription'] = array(
1163
- 'key' => $site_key,
1164
- 'data' => $subscription_data,
1165
- 'registered_by' => get_current_user_id()
1166
- );
1167
- $this->save_settings();
1168
- } else {
1169
- $error = __( 'Invalid site key for the current site.', 'installer' )
1170
- . '<br /><div class="installer-footnote">' . __( 'Please note that the site key is case sensitive.', 'installer' ) . '</div>';
1171
- }
1172
-
1173
- } catch ( Exception $e ) {
1174
- $error = $e->getMessage();
1175
- if ( preg_match( '#Could not resolve host: (.*)#', $error, $matches ) || preg_match( '#Couldn\'t resolve host \'(.*)\'#', $error, $matches ) ) {
1176
- $error = sprintf( __( "%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates.", 'installer' ),
1177
- '<strong><i>' . $this->get_generic_product_name( $repository_id ) . '</i></strong>',
1178
- '<strong><i>' . $matches[1] . '</i></strong>'
1179
- );
1180
- }
1181
- }
1182
-
1183
- }
1184
-
1185
- $return = array( 'error' => $error );
1186
-
1187
- if ( $this->api_debug ) {
1188
- $return['debug'] = $this->api_debug;
1189
- }
1190
-
1191
- if ( ! empty( $args['return'] ) ) {
1192
- return $return;
1193
- } else {
1194
- echo json_encode( $return );
1195
- exit;
1196
- }
1197
-
1198
- }
1199
-
1200
- /**
1201
- * Alias for WP_Installer::get_repository_site_key
1202
- * @see WP_Installer::get_repository_site_key()
1203
- *
1204
- * @param string $repository_id
1205
- *
1206
- * @return string (site key) or bool
1207
- */
1208
- public function get_site_key( $repository_id ) {
1209
- return WP_Installer::get_repository_site_key( $repository_id );
1210
- }
1211
-
1212
- public function remove_site_key( $repository_id ) {
1213
- if ( isset( $this->settings['repositories'][ $repository_id ] ) ) {
1214
- unset( $this->settings['repositories'][ $repository_id ]['subscription'] );
1215
- $this->save_settings();
1216
- $this->refresh_repositories_data();
1217
- }
1218
- }
1219
-
1220
- public function remove_site_key_ajax() {
1221
- if ( $_POST['nonce'] == wp_create_nonce( 'remove_site_key_' . $_POST['repository_id'] ) ) {
1222
- $this->remove_site_key( $_POST['repository_id'] );
1223
- }
1224
- exit;
1225
- }
1226
-
1227
- public function validate_repository_subscription() {
1228
- $repository_id = isset( $_GET['validate_repository'] ) ? sanitize_text_field( $_GET['validate_repository'] ) : false;
1229
- if ( $repository_id ) {
1230
-
1231
- $site_key = $this->get_site_key( $repository_id );
1232
- if ( $site_key ) {
1233
- $subscription_data = $this->fetch_subscription_data( $repository_id, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION );
1234
- if ( empty( $subscription_data ) ) {
1235
- unset( $this->settings['repositories'][ $repository_id ]['subscription'] );
1236
- delete_site_transient( 'update_plugins' );
1237
- $this->save_settings();
1238
- }
1239
- }
1240
-
1241
- wp_redirect( $this->menu_url() . '#repository-' . $repository_id );
1242
- exit;
1243
-
1244
- }
1245
-
1246
- }
1247
-
1248
- public function update_site_key() {
1249
-
1250
- $error = '';
1251
-
1252
- $repository_id = sanitize_text_field( $_POST['repository_id'] );
1253
- if ( $_POST['nonce'] == wp_create_nonce( 'update_site_key_' . $repository_id ) ) {
1254
-
1255
- $site_key = $this->get_site_key( $_POST['repository_id'] );
1256
-
1257
- if ( $site_key ) {
1258
- try {
1259
- $subscription_data = $this->fetch_subscription_data( $repository_id, $site_key, self::SITE_KEY_VALIDATION_SOURCE_UPDATES_CHECK );
1260
-
1261
- if ( $subscription_data ) {
1262
- $this->settings['repositories'][ $repository_id ]['subscription'] = array(
1263
- 'key' => $site_key,
1264
- 'data' => $subscription_data,
1265
- 'registered_by' => get_current_user_id()
1266
- );
1267
-
1268
- //also refresh products information
1269
- $this->refresh_repositories_data();
1270
-
1271
- $this->save_settings();
1272
-
1273
- } else {
1274
- unset( $this->settings['repositories'][ $repository_id ]['subscription'] );
1275
- $error = __( 'Invalid site key for the current site. If the error persists, try to unregister first and then register again with the same site key.', 'installer' );
1276
- }
1277
-
1278
-
1279
- } catch ( Exception $e ) {
1280
- $error = $e->getMessage();
1281
- if ( preg_match( '#Could not resolve host: (.*)#', $error, $matches ) || preg_match( '#Couldn\'t resolve host \'(.*)\'#', $error, $matches ) ) {
1282
- $error = sprintf( __( "%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates.", 'installer' ),
1283
- '<strong><i>' . $this->get_generic_product_name( $repository_id ) . '</i></strong>',
1284
- '<strong><i>' . $matches[1] . '</i></strong>'
1285
- );
1286
- }
1287
- }
1288
-
1289
- }
1290
-
1291
- }
1292
-
1293
- echo json_encode( array( 'error' => $error ) );
1294
-
1295
- exit;
1296
- }
1297
-
1298
- public function api_debug_log( $text ) {
1299
-
1300
- if ( defined( 'WPML_DEBUG_INSTALLER' ) && WPML_DEBUG_INSTALLER ) {
1301
-
1302
- if ( ! is_scalar( $text ) ) {
1303
- $text = print_r( $text, 1 );
1304
- }
1305
-
1306
- $this->api_debug .= $text . "\n";
1307
-
1308
- }
1309
-
1310
- }
1311
-
1312
- public function fetch_subscription_data( $repository_id, $site_key, $source = self::SITE_KEY_VALIDATION_SOURCE_OTHER ) {
1313
-
1314
- $subscription_data = false;
1315
-
1316
- $args['body'] = array(
1317
- 'action' => 'site_key_validation',
1318
- 'site_key' => $site_key,
1319
- 'site_url' => $this->get_installer_site_url( $repository_id ),
1320
- 'source' => $source
1321
- );
1322
-
1323
- if ( $repository_id == 'wpml' ) {
1324
- $args['body']['using_icl'] = $this->_using_icl;
1325
- $args['body']['wpml_version'] = $this->_wpml_version;
1326
- }
1327
-
1328
- $args['body']['installer_version'] = WP_INSTALLER_VERSION;
1329
- $args['body']['theme'] = wp_get_theme()->get( 'Name' );
1330
- $args['body']['site_name'] = get_bloginfo( 'name' );
1331
-
1332
- $args['body']['versions'] = $this->get_local_product_versions( $repository_id );
1333
-
1334
- $args['timeout'] = 45;
1335
-
1336
- // Add extra parameters for custom Installer packages
1337
- if ( ! empty( $this->package_source ) ) {
1338
- $extra = $this->get_extra_url_parameters();
1339
- if ( ! empty( $extra['repository'] ) && $extra['repository'] == $repository_id ) {
1340
- unset( $extra['repository'] );
1341
- foreach ( $extra as $key => $val ) {
1342
- $args['body'][ $key ] = $val;
1343
- }
1344
- }
1345
- }
1346
-
1347
- $response = wp_remote_post( $this->repositories[ $repository_id ]['api-url'], $args );
1348
-
1349
- $this->api_debug_log( "POST {$this->repositories[$repository_id]['api-url']}" );
1350
- $this->api_debug_log( $args );
1351
-
1352
- $this->log( "POST {$this->repositories[$repository_id]['api-url']} - fetch subscription data" );
1353
-
1354
- if ( ! is_wp_error( $response ) ) {
1355
- $datas = wp_remote_retrieve_body( $response );
1356
-
1357
- if ( is_serialized( $datas ) ) {
1358
- $data = unserialize( $datas );
1359
- $this->api_debug_log( $data );
1360
-
1361
- if ( ! empty( $data->subscription_data ) ) {
1362
- $subscription_data = $data->subscription_data;
1363
- }
1364
-
1365
- do_action( 'installer_fetched_subscription_data', $data, $repository_id );
1366
-
1367
- } else {
1368
- $this->api_debug_log( $datas );
1369
- }
1370
-
1371
- } else {
1372
-
1373
- $this->api_debug_log( $response );
1374
- throw new Exception( $response->get_error_message() );
1375
- }
1376
-
1377
- return $subscription_data;
1378
-
1379
- }
1380
-
1381
- function get_local_product_versions( $repository_id ) {
1382
-
1383
- $versions = array();
1384
-
1385
- foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package_id => $package ) {
1386
-
1387
- foreach ( $package['products'] as $product_id => $product ) {
1388
-
1389
- foreach ( $product['plugins'] as $plugin_slug ) {
1390
-
1391
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1392
-
1393
- if ( empty( $versions[ $download['slug'] ] ) ) {
1394
- $v = $this->get_plugin_installed_version( $download['name'], $download['slug'] );
1395
- if ( $v ) {
1396
- $versions[ $download['slug'] ] = $v;
1397
- }
1398
- }
1399
-
1400
- }
1401
-
1402
- }
1403
-
1404
- }
1405
-
1406
- return $versions;
1407
- }
1408
-
1409
- public function get_repository_site_key( $repository_id ) {
1410
- $site_key = false;
1411
-
1412
- if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription']['key'] ) ) {
1413
- $site_key = $this->settings['repositories'][ $repository_id ]['subscription']['key'];
1414
- }
1415
-
1416
- return $site_key;
1417
- }
1418
-
1419
- public function repository_has_valid_subscription( $repository_id ) {
1420
-
1421
- $valid = false;
1422
-
1423
- if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription'] ) ) {
1424
-
1425
- $subscription = $this->settings['repositories'][ $repository_id ]['subscription']['data'];
1426
- $valid = ( $subscription->status == 1 && ( strtotime( $subscription->expires ) > time() || empty( $subscription->expires ) ) ) || $subscription->status == 4;
1427
-
1428
- }
1429
-
1430
- return $valid;
1431
-
1432
- }
1433
-
1434
- public function repository_has_subscription( $repository_id ) {
1435
- $key = false;
1436
- if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription']['key'] ) ) {
1437
- $key = $this->settings['repositories'][ $repository_id ]['subscription']['key'];
1438
- }
1439
-
1440
- return $key;
1441
-
1442
- }
1443
-
1444
- public function repository_has_expired_subscription( $repository_id ) {
1445
-
1446
- return $this->repository_has_subscription( $repository_id ) && ! $this->repository_has_valid_subscription( $repository_id );
1447
-
1448
- }
1449
-
1450
- public function get_generic_product_name( $repository_id ) {
1451
-
1452
- return $this->settings['repositories'][ $repository_id ]['data']['product-name'];
1453
-
1454
- }
1455
-
1456
- public function show_subscription_renew_warning( $repository_id, $subscription_id ) {
1457
-
1458
- $show = false;
1459
-
1460
- $data = $this->settings['repositories'][ $repository_id ]['data'];
1461
- if ( ! empty( $data['subscriptions_meta'] ) ) {
1462
- if ( isset( $data['subscriptions_meta']['expiration'] ) ) {
1463
-
1464
- if ( ! empty( $data['subscriptions_meta']['expiration'][ $subscription_id ] ) ) {
1465
-
1466
- $days = $data['subscriptions_meta']['expiration'][ $subscription_id ]['days_warning'];
1467
- $message = $data['subscriptions_meta']['expiration'][ $subscription_id ]['warning_message'];
1468
-
1469
- } else {
1470
-
1471
- //defaults
1472
- $days = 30;
1473
- $message = __( 'You will have to renew your subscription in order to continue getting the updates and support.', 'installer' );
1474
-
1475
- }
1476
-
1477
- if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription'] ) ) {
1478
- $subscription = $this->settings['repositories'][ $repository_id ]['subscription'];
1479
-
1480
- if ( $subscription['data']->subscription_type == $subscription_id && ! empty( $subscription['data']->expires ) ) {
1481
-
1482
- if ( strtotime( $subscription['data']->expires ) < strtotime( sprintf( "+%d day", $days ) ) ) {
1483
-
1484
- $days_to_expiration = ceil( ( strtotime( $subscription['data']->expires ) - time() ) / 86400 );
1485
-
1486
- echo '<div><p class="installer-warn-box">' .
1487
- sprintf( _n( 'Your subscription expires in %d day.', 'Your subscription expires in %d days.', $days_to_expiration, 'installer' ), $days_to_expiration ) .
1488
- '<br />' . $message .
1489
- '</p></div>';
1490
-
1491
- $show = true;
1492
-
1493
- }
1494
-
1495
- }
1496
-
1497
- }
1498
-
1499
-
1500
- }
1501
- }
1502
-
1503
-
1504
- return $show;
1505
-
1506
- }
1507
-
1508
- public function setup_plugins_renew_warnings() {
1509
-
1510
- $plugins = get_plugins();
1511
-
1512
- $subscriptions_with_warnings = array();
1513
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
1514
-
1515
- if ( $this->repository_has_valid_subscription( $repository_id ) ) {
1516
- $subscription_type = $this->settings['repositories'][ $repository_id ]['subscription']['data']->subscription_type;
1517
- $expires = $this->settings['repositories'][ $repository_id ]['subscription']['data']->expires;
1518
-
1519
- $never_expires = isset( $this->settings['repositories'][ $repository_id ]['subscription'] )
1520
- && empty( $this->settings['repositories'][ $repository_id ]['subscription']['data']->expires )
1521
- && (
1522
- $this->settings['repositories'][ $repository_id ]['subscription']['data']->status == 4 ||
1523
- $this->settings['repositories'][ $repository_id ]['subscription']['data']->status == 1
1524
- );
1525
-
1526
- if ( ! $never_expires ) {
1527
- if ( isset( $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_type ] ) ) {
1528
-
1529
- $days_warning = $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_type ]['days_warning'];
1530
- $custom_message = $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_type ]['warning_message'];
1531
-
1532
- } else {
1533
- //defaults
1534
- $days_warning = 30;
1535
- $custom_message = __( 'You will have to renew your subscription in order to continue getting the updates and support.', 'installer' );
1536
- }
1537
-
1538
- if ( strtotime( $expires ) < strtotime( sprintf( '+%d day', $days_warning ) ) ) {
1539
-
1540
- $days_to_expiration = ceil( ( strtotime( $expires ) - time() ) / 86400 );
1541
-
1542
- $message = sprintf( _n( 'Your subscription expires in %d day.', 'Your subscription expires in %d days.', $days_to_expiration, 'installer' ), $days_to_expiration );
1543
- $subscriptions_with_warnings[ $subscription_type ] = $message . ' ' . $custom_message;
1544
-
1545
- }
1546
- }
1547
-
1548
- }
1549
-
1550
- }
1551
-
1552
-
1553
- foreach ( $plugins as $plugin_id => $plugin ) {
1554
-
1555
- $slug = dirname( $plugin_id );
1556
- if ( empty( $slug ) ) {
1557
- continue;
1558
- }
1559
-
1560
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
1561
-
1562
- if ( $this->repository_has_valid_subscription( $repository_id ) ) {
1563
-
1564
- foreach ( $repository['data']['packages'] as $package ) {
1565
-
1566
- foreach ( $package['products'] as $product ) {
1567
-
1568
- foreach ( $product['plugins'] as $plugin_slug ) {
1569
-
1570
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1571
-
1572
- if ( $download['slug'] == $slug || $download['name'] == $plugin['Name'] || $download['name'] == $plugin['Title'] ) { //match order: slug, name, title
1573
-
1574
- if ( isset( $subscriptions_with_warnings[ $product['subscription_type'] ] ) ) {
1575
-
1576
- $this->_plugins_renew_warnings[ $plugin_id ] = $subscriptions_with_warnings[ $product['subscription_type'] ];
1577
-
1578
- }
1579
-
1580
- }
1581
-
1582
- }
1583
-
1584
- }
1585
-
1586
- }
1587
-
1588
- }
1589
-
1590
- }
1591
-
1592
- }
1593
-
1594
- }
1595
-
1596
- public function queue_plugins_renew_warnings() {
1597
-
1598
- if ( ! empty( $this->_plugins_renew_warnings ) ) {
1599
-
1600
- foreach ( $this->_plugins_renew_warnings as $plugin_id => $message ) {
1601
-
1602
- add_action( "after_plugin_row_" . $plugin_id, array( $this, 'plugins_renew_warning' ), 10, 3 );
1603
- }
1604
-
1605
- }
1606
-
1607
- }
1608
-
1609
- public function plugins_renew_warning( $plugin_file, $plugin_data, $status ) {
1610
-
1611
- if ( empty( $this->_plugins_renew_warnings[ $plugin_file ] ) ) {
1612
- return;
1613
- }
1614
-
1615
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1616
- ?>
1617
-
1618
- <tr class="plugin-update-tr">
1619
- <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-update colspanchange">
1620
- <div class="update-message">
1621
- <?php
1622
- echo $this->_plugins_renew_warnings[ $plugin_file ] . ' ';
1623
- printf( __( '%sRenew here%s.', 'installer' ),
1624
- '<a href="' . $this->menu_url() . '">', '</a>' );
1625
- ?>
1626
- </div>
1627
- </tr>
1628
-
1629
- <?php
1630
-
1631
- }
1632
-
1633
- public function get_subscription_type_for_repository( $repository_id ) {
1634
-
1635
- $subscription_type = false;
1636
-
1637
- if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription'] ) ) {
1638
- $subscription_type = $this->settings['repositories'][ $repository_id ]['subscription']['data']->subscription_type;
1639
- }
1640
-
1641
- return $subscription_type;
1642
-
1643
- }
1644
-
1645
- public function have_superior_subscription( $subscription_type, $product ) {
1646
-
1647
- $have = false;
1648
-
1649
- if ( is_array( $product['upgrades'] ) ) {
1650
- foreach ( $product['upgrades'] as $u ) {
1651
- if ( $u['subscription_type'] == $subscription_type ) {
1652
- $have = true;
1653
- break;
1654
- }
1655
- }
1656
- }
1657
-
1658
- return $have;
1659
- }
1660
-
1661
- public function is_product_available_for_download( $product_name, $repository_id ) {
1662
-
1663
- $available = false;
1664
-
1665
- $subscription_type = $this->get_subscription_type_for_repository( $repository_id );
1666
- $expired = $this->repository_has_expired_subscription( $repository_id );
1667
-
1668
- if ( $this->repository_has_subscription( $repository_id ) && ! $expired ) {
1669
-
1670
- $this->set_hierarchy_and_order();
1671
-
1672
- foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package_id => $package ) {
1673
-
1674
- $has_top_package = false;
1675
-
1676
- foreach ( $package['products'] as $product ) {
1677
-
1678
- if ( $subscription_type == $product['subscription_type'] ) {
1679
- $has_top_package = true;
1680
- if ( $product['name'] == $product_name ) {
1681
- return $available = true;
1682
- }
1683
- }
1684
-
1685
- }
1686
-
1687
- if ( ! empty( $package['sub-packages'] ) ) {
1688
- foreach ( $package['sub-packages'] as $sub_package ) {
1689
- foreach ( $sub_package['products'] as $product ) {
1690
- if ( $product['name'] == $product_name && ( $subscription_type == $product['subscription_type'] || $has_top_package ) ) {
1691
- return $available = true;
1692
- }
1693
- }
1694
- }
1695
- }
1696
-
1697
- }
1698
- }
1699
-
1700
- return $available;
1701
-
1702
- }
1703
-
1704
- public function get_upgrade_options( $repository_id ) {
1705
- $all_upgrades = array();
1706
-
1707
-
1708
- //get all products: packages and subpackages
1709
- $all_products = array();
1710
- foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
1711
- foreach ( $package['products'] as $product ) {
1712
- $all_products[] = $product;
1713
- }
1714
- if ( ! empty( $package['sub-packages'] ) ) {
1715
- foreach ( $package['sub-packages'] as $subpackage ) {
1716
- foreach ( $subpackage['products'] as $product ) {
1717
- $all_products[] = $product;
1718
- }
1719
-
1720
- }
1721
-
1722
- }
1723
-
1724
- }
1725
-
1726
- foreach ( $all_products as $product ) {
1727
- if ( $product['upgrades'] ) {
1728
- foreach ( $product['upgrades'] as $upgrade ) {
1729
- if ( $this->repository_has_valid_subscription( $repository_id ) || ( $this->repository_has_subscription( $repository_id ) && $upgrade['including_expired'] ) ) {
1730
- $all_upgrades[ $upgrade['subscription_type'] ][ $product['subscription_type'] ] = $upgrade;
1731
- }
1732
- }
1733
- }
1734
- }
1735
-
1736
- return $all_upgrades;
1737
-
1738
- }
1739
-
1740
- public function append_site_key_to_download_url( $url, $key, $repository_id ) {
1741
-
1742
- $url_params['site_key'] = $key;
1743
- $url_params['site_url'] = $this->get_installer_site_url( $repository_id );
1744
-
1745
-
1746
- // Add extra parameters for custom Installer packages
1747
- if ( ! empty( $this->package_source ) ) {
1748
- $extra = $this->get_extra_url_parameters();
1749
- if ( ! empty( $extra['repository'] ) && $extra['repository'] == $repository_id ) {
1750
- unset( $extra['repository'] );
1751
- foreach ( $extra as $key => $val ) {
1752
- $url_params[ $key ] = $val;
1753
- }
1754
- }
1755
- }
1756
-
1757
- $url = add_query_arg( $url_params, $url );
1758
-
1759
- if ( $repository_id == 'wpml' ) {
1760
- $url = add_query_arg( array(
1761
- 'using_icl' => $this->_using_icl,
1762
- 'wpml_version' => $this->_wpml_version
1763
- ), $url );
1764
- }
1765
-
1766
- return $url;
1767
-
1768
- }
1769
-
1770
- public function plugin_is_installed( $name, $slug, $version = null ) {
1771
-
1772
- $is = false;
1773
-
1774
- $plugins = get_plugins();
1775
-
1776
- foreach ( $plugins as $plugin_id => $plugin ) {
1777
-
1778
- $wp_plugin_slug = dirname( $plugin_id );
1779
-
1780
- // Exception: embedded plugins
1781
- if ( $wp_plugin_slug == $slug || $plugin['Name'] == $name || $plugin['Title'] == $name || ( $wp_plugin_slug == $slug . '-embedded' || $plugin['Name'] == $name . ' Embedded' ) ) {
1782
- if ( $version ) {
1783
- if ( version_compare( $plugin['Version'], $version, '>=' ) ) {
1784
- $is = $plugin['Version'];
1785
- }
1786
- } else {
1787
- $is = $plugin['Version'];
1788
- }
1789
-
1790
- break;
1791
- }
1792
-
1793
- }
1794
-
1795
- //exception: Types name difference
1796
- if ( ! $is && $name == 'Types' ) {
1797
- return $this->plugin_is_installed( 'Types - Complete Solution for Custom Fields and Types', $slug, $version );
1798
- }
1799
-
1800
- return $is;
1801
- }
1802
-
1803
- public function plugin_is_embedded_version( $name, $slug ) {
1804
- $is = false;
1805
-
1806
- $plugins = get_plugins();
1807
-
1808
- //false if teh full version is also installed
1809
- $is_full_installed = false;
1810
- foreach ( $plugins as $plugin_id => $plugin ) {
1811
-
1812
- if ( ( $plugin['Name'] == $name && ! preg_match( "#-embedded$#", $slug ) ) ) {
1813
- $is_full_installed = true;
1814
- break;
1815
- }
1816
-
1817
- }
1818
-
1819
- if ( $is_full_installed ) {
1820
- return false;
1821
- }
1822
-
1823
- foreach ( $plugins as $plugin_id => $plugin ) {
1824
-
1825
- // TBD
1826
- $wp_plugin_slug = dirname( $plugin_id );
1827
- if ( $wp_plugin_slug == $slug . '-embedded' && $plugin['Name'] == $name . ' Embedded' ) {
1828
- $is = true;
1829
- break;
1830
- }
1831
-
1832
- }
1833
-
1834
- return $is;
1835
-
1836
- }
1837
-
1838
- //Alias for plugin_is_installed
1839
- public function get_plugin_installed_version( $name, $slug ) {
1840
-
1841
- return $this->plugin_is_installed( $name, $slug );
1842
-
1843
- }
1844
-
1845
- public function get_plugin_repository_version( $repository_id, $slug ) {
1846
- $version = false;
1847
-
1848
- if ( ! empty( $this->settings['repositories'][ $repository_id ]['data']['packages'] ) ) {
1849
- foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
1850
- foreach ( $package['products'] as $product ) {
1851
-
1852
- foreach ( $product['plugins'] as $plugin_slug ) {
1853
-
1854
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1855
-
1856
- if ( $download['slug'] == $slug ) {
1857
- $version = $download['version'];
1858
- break ( 3 );
1859
- }
1860
-
1861
- }
1862
-
1863
- }
1864
- }
1865
- }
1866
-
1867
- return $version;
1868
- }
1869
-
1870
- public function is_uploading_allowed() {
1871
-
1872
- //_deprecated_function ( __FUNCTION__, '1.7.3', 'Installer_Dependencies::' . __FUNCTION__ );
1873
- return $this->dependencies->is_uploading_allowed();
1874
-
1875
- }
1876
-
1877
- public function download_plugin_ajax_handler() {
1878
-
1879
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1880
- require_once $this->plugin_path() . '/includes/class-installer-upgrader-skins.php';
1881
-
1882
- $data = json_decode( base64_decode( sanitize_text_field( $_POST['data'] ) ), true );
1883
-
1884
- $ret = false;
1885
- $plugin_id = false;
1886
- $message = '';
1887
-
1888
- //validate subscription
1889
- $site_key = $this->get_repository_site_key( $data['repository_id'] );
1890
- $subscription_data = $this->fetch_subscription_data( $data['repository_id'], $site_key, self::SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_REPORT );
1891
-
1892
- if ( $subscription_data && ! is_wp_error( $subscription_data ) && $this->repository_has_valid_subscription( $data['repository_id'] ) ) {
1893
-
1894
- if ( $data['nonce'] == wp_create_nonce( 'install_plugin_' . $data['url'] ) ) {
1895
-
1896
- $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1897
- $upgrader = new Plugin_Upgrader( $upgrader_skins );
1898
-
1899
- remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
1900
-
1901
- $plugins = get_plugins();
1902
-
1903
- //upgrade or install?
1904
- foreach ( $plugins as $id => $plugin ) {
1905
- $wp_plugin_slug = dirname( $id );
1906
- $is_embedded = $this->plugin_is_embedded_version( preg_replace( '/ Embedded$/', '', $plugin['Name'] ), preg_replace( '/-embedded$/', '', $wp_plugin_slug ) );
1907
-
1908
- if ( $wp_plugin_slug == $data['slug'] || $is_embedded && preg_replace( '/-embedded$/', '', $wp_plugin_slug ) == $data['slug'] ) {
1909
- $plugin_id = $id;
1910
- break;
1911
- }
1912
- }
1913
-
1914
- if ( $plugin_id && empty( $is_embedded ) ) { //upgrade
1915
- $response['upgrade'] = 1;
1916
-
1917
- $plugin_is_active = is_plugin_active( $plugin_id );
1918
-
1919
- $ret = $upgrader->upgrade( $plugin_id );
1920
-
1921
- if ( ! $ret && ! empty( $upgrader->skin->installer_error ) ) {
1922
- if ( is_wp_error( $upgrader->skin->installer_error ) ) {
1923
- $message = $upgrader->skin->installer_error->get_error_message() .
1924
- ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
1925
- }
1926
- $plugin_version = 0;
1927
- }else{
1928
- if ( $plugin_is_active ) {
1929
- //prevent redirects
1930
- add_filter( 'wp_redirect', '__return_false' );
1931
- activate_plugin( $plugin_id );
1932
- }
1933
- $plugin_version = $this->get_plugin_repository_version( $data['repository_id'], $data['slug'] );
1934
- }
1935
-
1936
- } else { //install
1937
-
1938
- if ( $is_embedded ) {
1939
- delete_plugins( array( $plugin_id ) );
1940
- }
1941
-
1942
- $response['install'] = 1;
1943
- $ret = $upgrader->install( $data['url'] );
1944
- if ( ! $ret && ! empty( $upgrader->skin->installer_error ) ) {
1945
- if ( is_wp_error( $upgrader->skin->installer_error ) ) {
1946
- $message = $upgrader->skin->installer_error->get_error_message() .
1947
- ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
1948
- }
1949
- }
1950
- }
1951
-
1952
- $plugins = get_plugins(); //read again
1953
-
1954
- if ( $ret ) {
1955
- foreach ( $plugins as $id => $plugin ) {
1956
- $wp_plugin_slug = dirname( $id );
1957
- if ( $wp_plugin_slug == $data['slug'] ) {
1958
- $plugin_version = $plugin['Version'];
1959
- $plugin_id = $id;
1960
- break;
1961
- }
1962
- }
1963
-
1964
- }
1965
-
1966
- if( WP_Installer_Channels()->get_channel( $data['repository_id'] ) !== WP_Installer_Channels::CHANNEL_PRODUCTION ){
1967
- $download = $this->settings['repositories'][$data['repository_id']]['data']['downloads']['plugins'][$data['slug']];
1968
- $non_stable = WP_Installer_Channels()->get_download_source_channel( $plugin_version, $data['repository_id'], $download['slug'], 'plugins' );
1969
- }
1970
-
1971
- }
1972
-
1973
- } else { //subscription not valid
1974
-
1975
- $ret = false;
1976
- $message = __( 'Your subscription appears to no longer be valid. Please try to register again using a valid site key.', 'installer' );
1977
- }
1978
-
1979
- $response['version'] = isset( $plugin_version ) ? $plugin_version : 0;
1980
- $response['non_stable']= isset( $non_stable ) ? $non_stable : '';
1981
- $response['plugin_id'] = $plugin_id;
1982
- $response['nonce'] = wp_create_nonce( 'activate_' . $plugin_id );
1983
- $response['success'] = $ret;
1984
- $response['message'] = $message;
1985
-
1986
- echo json_encode( $response );
1987
- exit;
1988
-
1989
- }
1990
-
1991
- public function download_plugin( $slug, $url ) {
1992
-
1993
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1994
- require_once $this->plugin_path() . '/includes/class-installer-upgrader-skins.php';
1995
-
1996
- $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1997
- $upgrader = new Plugin_Upgrader( $upgrader_skins );
1998
-
1999
- remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
2000
-
2001
- $plugins = get_plugins();
2002
-
2003
- $plugin_id = false;
2004
-
2005
- //upgrade or install?
2006
- foreach ( $plugins as $id => $plugin ) {
2007
- $wp_plugin_slug = dirname( $id );
2008
- if ( $wp_plugin_slug == $slug ) {
2009
- $plugin_id = $id;
2010
- break;
2011
- }
2012
- }
2013
-
2014
- if ( $plugin_id ) { //upgrade
2015
-
2016
- $plugin_is_active = is_plugin_active( $plugin_id );
2017
-
2018
- $ret = $upgrader->upgrade( $plugin_id );
2019
-
2020
- if ( $plugin_is_active ) {
2021
- activate_plugin( $plugin_id );
2022
- }
2023
-
2024
- } else { //install
2025
- $ret = $upgrader->install( $url );
2026
- }
2027
-
2028
- return $ret;
2029
-
2030
- }
2031
-
2032
- public function activate_plugin() {
2033
-
2034
- $error = '';
2035
-
2036
- $plugin_id = sanitize_text_field( $_POST['plugin_id'] );
2037
- if ( isset( $_POST['nonce'] ) && $plugin_id && $_POST['nonce'] == wp_create_nonce( 'activate_' . $plugin_id ) ) {
2038
-
2039
- // Deactivate any embedded version
2040
- $plugin_slug = dirname( $plugin_id );
2041
- $active_plugins = get_option( 'active_plugins' );
2042
- foreach ( $active_plugins as $plugin ) {
2043
- $wp_plugin_slug = dirname( $plugin );
2044
- if ( $wp_plugin_slug == $plugin_slug . '-embedded' ) {
2045
- deactivate_plugins( array( $plugin ) );
2046
- break;
2047
- }
2048
- }
2049
-
2050
- //prevent redirects
2051
- add_filter( 'wp_redirect', '__return_false', 10000 );
2052
-
2053
- $return = activate_plugin( $plugin_id );
2054
-
2055
- if ( is_wp_error( $return ) ) {
2056
- $error = $return->get_error_message();
2057
- }
2058
-
2059
- } else {
2060
- $error = 'error';
2061
- }
2062
-
2063
- $ret = array( 'error' => $error );
2064
-
2065
- echo json_encode( $ret );
2066
- exit;
2067
-
2068
- }
2069
-
2070
- public function custom_plugins_api_call( $false, $action, $args ) {
2071
-
2072
- if ( $action == 'plugin_information' ) {
2073
-
2074
- $plugins = get_plugins();
2075
- $plugin_names = array();
2076
- foreach ( $plugins as $plugin_id => $plugin ) {
2077
- // plugins by WP slug which (plugin folder) which can be different
2078
- // will use this to compare by title
2079
- $plugin_names[ dirname( $plugin_id ) ] = array(
2080
- 'name' => $plugin['Name'],
2081
- 'title' => $plugin['Title'],
2082
- );
2083
- }
2084
-
2085
- $slug = $args->slug;
2086
-
2087
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2088
-
2089
- if ( ! $this->repository_has_valid_subscription( $repository_id ) ) {
2090
- $site_key = false;
2091
- } else {
2092
- $site_key = $repository['subscription']['key'];
2093
- }
2094
-
2095
- foreach ( $repository['data']['packages'] as $package ) {
2096
-
2097
- foreach ( $package['products'] as $product ) {
2098
-
2099
- foreach ( $product['plugins'] as $plugin_slug ) {
2100
-
2101
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2102
-
2103
- if ( $download['slug'] == $slug ||
2104
- isset( $plugin_names[ $slug ] ) && (
2105
- $plugin_names[ $slug ]['name'] == $download['name'] ||
2106
- $plugin_names[ $slug ]['title'] == $download['name']
2107
- )
2108
- ) {
2109
-
2110
- if ( ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION ) {
2111
- return false; // use data from wordpress.org
2112
- }
2113
-
2114
- $res = new stdClass();
2115
- $res->external = true;
2116
-
2117
- $res->name = $download['name'];
2118
- $res->slug = $slug;
2119
- $res->version = $download['version'];
2120
- $res->author = '';
2121
- $res->author_profile = '';
2122
- $res->last_updated = $download['date'];
2123
-
2124
- if ( $site_key ) {
2125
- $res->download_link = $this->append_site_key_to_download_url( $download['url'], $site_key, $repository_id );
2126
- }
2127
-
2128
- $res->homepage = $repository['data']['url'];
2129
- $res->sections = array(
2130
- 'Description' => $download['description'],
2131
- 'Changelog' => $download['changelog']
2132
- );
2133
-
2134
- return $res;
2135
-
2136
- }
2137
-
2138
- }
2139
-
2140
- }
2141
-
2142
- }
2143
-
2144
- }
2145
-
2146
- }
2147
-
2148
- return $false;
2149
-
2150
- }
2151
-
2152
- public function plugins_upgrade_check( $update_plugins ) {
2153
-
2154
- if ( ! empty( $this->settings['repositories'] ) ) {
2155
-
2156
- $plugins = get_plugins();
2157
-
2158
- foreach ( $plugins as $plugin_id => $plugin ) {
2159
-
2160
- $slug = dirname( $plugin_id );
2161
- if ( empty( $slug ) ) {
2162
- continue;
2163
- }
2164
-
2165
- $version = $plugin['Version'];
2166
- $name = $plugin['Name'];
2167
-
2168
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2169
-
2170
-
2171
- if ( ! $this->repository_has_valid_subscription( $repository_id ) ) {
2172
- $site_key = false;
2173
- } else {
2174
- $site_key = $repository['subscription']['key'];
2175
- //$subscription_type = $this->get_subscription_type_for_repository($repository_id);
2176
- }
2177
-
2178
- foreach ( $repository['data']['packages'] as $package ) {
2179
-
2180
- foreach ( $package['products'] as $product ) {
2181
-
2182
- foreach ( $product['plugins'] as $plugin_slug ) {
2183
-
2184
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2185
-
2186
- if ( ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION ) {
2187
- continue;
2188
- }
2189
-
2190
- $needs_version_update = version_compare( $download['version'], $version, '>' ) ||
2191
- ! empty( $_POST['reset_to_channel'] );
2192
-
2193
- if (
2194
- empty( $update_plugins->response[ $plugin_id ] ) &&
2195
- ( $download['slug'] == $slug || $download['name'] == $name ) &&
2196
- $needs_version_update
2197
- ) {
2198
-
2199
- $response = new stdClass();
2200
- $response->id = 0;
2201
- $response->slug = $slug;
2202
- $response->plugin = $plugin_id;
2203
- $response->new_version = $download['version'];
2204
- $response->upgrade_notice = '';
2205
- $response->url = $download['url'];
2206
- if ( $site_key ) {
2207
- $response->package = $this->append_site_key_to_download_url( $download['url'], $site_key, $repository_id );
2208
- }
2209
- $update_plugins->checked[ $plugin_id ] = $version;
2210
- $update_plugins->response[ $plugin_id ] = $response;
2211
-
2212
- }
2213
-
2214
- }
2215
-
2216
- }
2217
-
2218
- }
2219
-
2220
- }
2221
-
2222
- }
2223
-
2224
- }
2225
-
2226
- return $update_plugins;
2227
-
2228
- }
2229
-
2230
- public function setup_plugins_page_notices() {
2231
-
2232
- $plugins = get_plugins();
2233
-
2234
- foreach ( $plugins as $plugin_id => $plugin ) {
2235
-
2236
- $slug = dirname( $plugin_id );
2237
- if ( empty( $slug ) ) {
2238
- continue;
2239
- }
2240
-
2241
- $name = $plugin['Name'];
2242
-
2243
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2244
-
2245
- if ( ! $this->repository_has_valid_subscription( $repository_id ) ) {
2246
- $site_key = false;
2247
- } else {
2248
- $site_key = $repository['subscription']['key'];
2249
- }
2250
-
2251
- foreach ( $repository['data']['packages'] as $package ) {
2252
-
2253
- foreach ( $package['products'] as $product ) {
2254
-
2255
- foreach ( $product['plugins'] as $plugin_slug ) {
2256
-
2257
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2258
- if ( ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION ) {
2259
- continue;
2260
- }
2261
-
2262
- if ( $download['slug'] == $slug || $download['name'] == $name ) {
2263
-
2264
- if ( ! $site_key || ! $this->plugin_is_registered( $repository_id, $download['slug'] ) ) {
2265
- add_action( "after_plugin_row_" . $plugin_id, array(
2266
- $this,
2267
- 'show_purchase_notice_under_plugin'
2268
- ), 10, 3 );
2269
- }
2270
-
2271
- }
2272
-
2273
- }
2274
-
2275
- }
2276
-
2277
- }
2278
-
2279
- }
2280
-
2281
- }
2282
-
2283
- }
2284
-
2285
- public function show_purchase_notice_under_plugin( $plugin_file, $plugin_data, $status ) {
2286
-
2287
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
2288
- $wp_version = preg_replace( '/-(.+)$/', '', $GLOBALS['wp_version'] );
2289
-
2290
- if ( version_compare( $wp_version, '4.6', '>=' ) ) {
2291
-
2292
- ?>
2293
- <tr class="plugin-update-tr installer-plugin-update-tr">
2294
- <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-update colspanchange">
2295
- <div class="notice inline notice-warning notice-alt">
2296
- <p class="installer-q-icon">
2297
- <?php printf( __( 'You must have a valid subscription in order to get upgrades or support for this plugin. %sPurchase a subscription or enter an existing site key%s.', 'installer' ),
2298
- '<a href="' . $this->menu_url() . '">', '</a>' ); ?>
2299
- </p>
2300
- </div>
2301
- </td>
2302
- </tr>
2303
- <?php
2304
-
2305
- } else {
2306
-
2307
- ?>
2308
- <tr class="plugin-update-tr">
2309
- <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-update colspanchange">
2310
- <div class="update-message installer-q-icon">
2311
- <?php printf( __( 'You must have a valid subscription in order to get upgrades or support for this plugin. %sPurchase a subscription or enter an existing site key%s.', 'installer' ),
2312
- '<a href="' . $this->menu_url() . '">', '</a>' ); ?>
2313
- </div>
2314
- </td>
2315
- </tr>
2316
- <?php
2317
-
2318
- }
2319
-
2320
- }
2321
-
2322
- public function localize_strings() {
2323
-
2324
- if ( ! empty( $this->settings['repositories'] ) ) {
2325
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2326
- //set name as call2action when don't have any
2327
- //products
2328
- foreach ( $repository['data']['packages'] as $package_id => $package ) {
2329
- foreach ( $package['products'] as $product_id => $product ) {
2330
- if ( empty( $product['call2action'] ) ) {
2331
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['call2action'] = $product['name'];
2332
- }
2333
-
2334
- foreach ( $product['upgrades'] as $idx => $upg ) {
2335
- if ( empty( $upg['call2action'] ) ) {
2336
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $idx ]['call2action'] = $upg['name'];
2337
- }
2338
- }
2339
-
2340
- foreach ( $product['renewals'] as $idx => $rnw ) {
2341
- if ( empty( $rnw['call2action'] ) ) {
2342
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['renewals'][ $idx ]['call2action'] = $rnw['name'];
2343
- }
2344
-
2345
- }
2346
-
2347
- }
2348
- }
2349
- }
2350
- }
2351
-
2352
- global $sitepress;
2353
- if ( is_null( $sitepress ) ) {
2354
- return;
2355
- }
2356
-
2357
- // default strings are always in English
2358
- $user_admin_language = $sitepress->get_admin_language();
2359
-
2360
- if ( $user_admin_language != 'en' ) {
2361
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2362
-
2363
- $localization = $repository['data']['localization'];
2364
-
2365
- //packages
2366
- foreach ( $repository['data']['packages'] as $package_id => $package ) {
2367
-
2368
- if ( isset( $localization['packages'][ $package_id ]['name'][ $user_admin_language ] ) ) {
2369
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['name'] = $localization['packages'][ $package_id ]['name'][ $user_admin_language ];
2370
- }
2371
- if ( isset( $localization['packages'][ $package_id ]['description'][ $user_admin_language ] ) ) {
2372
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['description'] = $localization['packages'][ $package_id ]['description'][ $user_admin_language ];
2373
- }
2374
-
2375
- }
2376
-
2377
- //products
2378
- foreach ( $repository['data']['packages'] as $package_id => $package ) {
2379
- foreach ( $package['products'] as $product_id => $product ) {
2380
-
2381
- if ( isset( $localization['products'][ $product_id ]['name'][ $user_admin_language ] ) ) {
2382
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['name']
2383
- = $localization['products'][ $product_id ]['name'][ $user_admin_language ];
2384
- }
2385
- if ( isset( $localization['products'][ $product_id ]['description'][ $user_admin_language ] ) ) {
2386
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['description']
2387
- = $localization['products'][ $product_id ]['description'][ $user_admin_language ];
2388
- }
2389
- if ( isset( $localization['products'][ $product_id ]['call2action'][ $user_admin_language ] ) ) {
2390
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['name']
2391
- = $localization['products'][ $product_id ]['call2action'][ $user_admin_language ];
2392
- }
2393
-
2394
-
2395
- }
2396
- }
2397
-
2398
- //subscription info
2399
- if ( isset( $repository['data']['subscriptions_meta']['expiration'] ) ) {
2400
- foreach ( $repository['data']['subscriptions_meta']['expiration'] as $subscription_id => $note ) {
2401
- if ( isset( $localization['subscriptions-notes'][ $subscription_id ]['expiration-warning'][ $user_admin_language ] ) ) {
2402
- $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_id ]['warning_message']
2403
- = $localization['subscriptions-notes'][ $subscription_id ]['expiration-warning'][ $user_admin_language ];
2404
- }
2405
- }
2406
- }
2407
-
2408
- }
2409
- }
2410
-
2411
- }
2412
-
2413
- public function get_matching_cp( $repository, $args = array() ) {
2414
- $match = false;
2415
-
2416
-
2417
- $cp_name = $cp_author = false;
2418
-
2419
- if ( isset( $this->config['src_name'] ) && isset( $this->config['src_author'] ) ) {
2420
-
2421
- $cp_name = $this->config['src_name'];
2422
- $cp_author = $this->config['src_author'];
2423
-
2424
- } elseif ( isset( $args['src_name'] ) && isset( $args['src_author'] ) ) {
2425
-
2426
- $cp_name = $args['src_name'];
2427
- $cp_author = $args['src_author'];
2428
-
2429
- }
2430
-
2431
- if ( isset( $repository['data']['marketing_cp'] ) ) {
2432
-
2433
- foreach ( $repository['data']['marketing_cp'] as $cp ) {
2434
-
2435
- if ( ! empty( $cp['exp'] ) && time() > $cp['exp'] ) {
2436
- continue;
2437
- }
2438
-
2439
- //Use theme_name for plugins too
2440
- if ( ! empty( $cp['theme_name'] ) ) {
2441
- if ( $cp['author_name'] == $cp_author && $cp['theme_name'] == $cp_name ) {
2442
- $match = $cp;
2443
- continue;
2444
- }
2445
- } else {
2446
- if ( $cp['author_name'] == $cp_author ) {
2447
- $match = $cp;
2448
- continue;
2449
- }
2450
- }
2451
-
2452
- }
2453
-
2454
- }
2455
-
2456
- return $match;
2457
- }
2458
-
2459
- public function set_filtered_prices( $args = array() ) {
2460
-
2461
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2462
-
2463
- $match = $this->get_matching_cp( $repository, $args );
2464
-
2465
- if ( empty( $match ) ) {
2466
- continue;
2467
- }
2468
-
2469
- foreach ( $repository['data']['packages'] as $package_id => $package ) {
2470
-
2471
- foreach ( $package['products'] as $product_id => $product ) {
2472
-
2473
- if ( $match['dtp'] == '%' ) {
2474
- $fprice = round( $product['price'] * ( 1 - $match['amt'] / 100 ), 2 );
2475
- $fprice = $fprice != round( $fprice ) ? sprintf( '%.2f', $fprice ) : round( $fprice, 0 );
2476
- } elseif ( $match['dtp'] == '-' ) {
2477
- $fprice = $product['price'] - $match['amt'];
2478
- } else {
2479
- $fprice = $product['price'];
2480
- }
2481
-
2482
- if ( $fprice ) {
2483
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['price_disc'] = $fprice;
2484
-
2485
- $url_glue = false !== strpos( $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['url'], '?' ) ? '&' : '?';
2486
- $cpndata = base64_encode( json_encode( array(
2487
- 'theme_author' => $match['author_name'],
2488
- 'theme_name' => $match['theme_name'],
2489
- 'vlc' => $match['vlc']
2490
- ) ) );
2491
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['url'] .= $url_glue . 'cpn=' . $cpndata;
2492
-
2493
- foreach ( $product['upgrades'] as $upgrade_id => $upgrade ) {
2494
-
2495
- $fprice = false;
2496
- if ( $match['dtp'] == '%' ) {
2497
- $fprice = round( $upgrade['price'] * ( 1 - $match['amt'] / 100 ), 2 );
2498
- $fprice = $fprice != round( $fprice ) ? sprintf( '%.2f', $fprice ) : round( $fprice, 0 );
2499
- } elseif ( $match['dtp'] == '-' ) {
2500
- $fprice = $upgrade['price'] - $match['amt'];
2501
- }
2502
- if ( $fprice ) {
2503
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $upgrade_id ]['price_disc'] = $fprice;
2504
- $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $upgrade_id ]['url'] .= $url_glue . 'cpn=' . $cpndata;
2505
- }
2506
-
2507
-
2508
- }
2509
-
2510
- }
2511
-
2512
- }
2513
-
2514
- }
2515
-
2516
- }
2517
-
2518
- }
2519
-
2520
- public function set_hierarchy_and_order() {
2521
-
2522
- //2 levels
2523
- if ( ! empty( $this->settings['repositories'] ) ) {
2524
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2525
-
2526
- if ( empty( $repository['data']['packages'] ) ) {
2527
- continue;
2528
- }
2529
-
2530
- $all_packages = $repository['data']['packages'];
2531
- $ordered_packages = array();
2532
-
2533
- //backward compatibility - 'order'
2534
- foreach ( $all_packages as $k => $v ) {
2535
- if ( ! isset( $v['order'] ) ) {
2536
- $all_packages[ $k ]['order'] = 0;
2537
- }
2538
- }
2539
-
2540
- //select parents
2541
- foreach ( $all_packages as $package_id => $package ) {
2542
- if ( empty( $package['parent'] ) ) {
2543
- $ordered_packages[ $package_id ] = $package;
2544
- }
2545
- }
2546
-
2547
- //add sub-packages
2548
- foreach ( $all_packages as $package_id => $package ) {
2549
- if ( ! empty( $package['parent'] ) ) {
2550
- if ( isset( $ordered_packages[ $package['parent'] ] ) ) {
2551
- $ordered_packages[ $package['parent'] ]['sub-packages'][ $package_id ] = $package;
2552
- }
2553
- }
2554
- }
2555
-
2556
- // order parents
2557
- usort( $ordered_packages, array( $this, '_order_packages_callback' ) );
2558
- //order sub-packages
2559
- foreach ( $ordered_packages as $package_id => $package ) {
2560
- if ( ! empty( $package['sub-packages'] ) ) {
2561
- usort( $ordered_packages[ $package_id ]['sub-packages'], create_function( '$a, $b', 'return $a[\'order\'] > $b[\'order\'];' ) );
2562
- }
2563
- }
2564
-
2565
- $this->settings['repositories'][ $repository_id ]['data']['packages'] = $ordered_packages;
2566
-
2567
-
2568
- }
2569
- }
2570
-
2571
-
2572
- }
2573
-
2574
- public function _order_packages_callback( $a, $b ) {
2575
- return $a['order'] > $b['order'];
2576
- }
2577
-
2578
- public function get_support_tag_by_name( $name, $repository ) {
2579
-
2580
- if ( is_array( $this->settings['repositories'][ $repository ]['data']['support_tags'] ) ) {
2581
- foreach ( $this->settings['repositories'][ $repository ]['data']['support_tags'] as $support_tag ) {
2582
- if ( $support_tag['name'] == $name ) {
2583
- return $support_tag['url'];
2584
- }
2585
- }
2586
- }
2587
-
2588
- return false;
2589
- }
2590
-
2591
- public function plugin_upgrade_custom_errors() {
2592
-
2593
- if ( isset( $_REQUEST['action'] ) ) {
2594
-
2595
- $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
2596
-
2597
- //bulk mode
2598
- if ( 'update-selected' == $action ) {
2599
-
2600
- global $plugins;
2601
-
2602
- if ( isset( $plugins ) && is_array( $plugins ) ) {
2603
-
2604
- foreach ( $plugins as $k => $plugin ) {
2605
- $plugin_repository = false;
2606
-
2607
- $wp_plugin_slug = dirname( $plugin );
2608
-
2609
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2610
-
2611
- foreach ( $repository['data']['packages'] as $package ) {
2612
-
2613
- foreach ( $package['products'] as $product ) {
2614
-
2615
- foreach ( $product['plugins'] as $plugin_slug ) {
2616
-
2617
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2618
-
2619
- if ( $download['slug'] == $wp_plugin_slug ) {
2620
- $plugin_repository = $repository_id;
2621
- $product_name = $repository['data']['product-name'];
2622
- $plugin_name = $download['name'];
2623
- $free_on_wporg = ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION;
2624
- break;
2625
- }
2626
-
2627
- }
2628
-
2629
- }
2630
-
2631
- }
2632
-
2633
- }
2634
-
2635
- if ( $plugin_repository ) {
2636
-
2637
- //validate subscription
2638
- static $sub_cache = array();
2639
-
2640
- if ( empty( $sub_cache[ $plugin_repository ] ) ) {
2641
- $site_key = $this->get_repository_site_key( $plugin_repository );
2642
- if ( $site_key ) {
2643
- $subscription_data = $this->fetch_subscription_data( $plugin_repository, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION );
2644
- }
2645
-
2646
- $sub_cache[ $plugin_repository ]['site_key'] = $site_key;
2647
- $sub_cache[ $plugin_repository ]['subscription_data'] = isset( $subscription_data ) ? $subscription_data : false;
2648
- } else {
2649
-
2650
- $site_key = $sub_cache[ $plugin_repository ]['site_key'];
2651
- $subscription_data = $sub_cache[ $plugin_repository ]['subscription_data'];
2652
-
2653
- }
2654
-
2655
- if ( ! $site_key && ! empty( $free_on_wporg ) ) { // allow the download from wp.org
2656
- continue;
2657
- }
2658
-
2659
- if ( empty( $site_key ) || empty( $subscription_data ) ) {
2660
-
2661
-
2662
- $error_message = sprintf( __( "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer' ),
2663
- '<strong>' . $plugin_name . '</strong>', '<a target="_top" href="' . $this->menu_url() . '&validate_repository=' . $plugin_repository .
2664
- '#repository-' . $plugin_repository . '">', $product_name, '</a>' );
2665
-
2666
- echo '<div class="updated error"><p>' . $error_message . '</p></div>';
2667
-
2668
- unset( $plugins[ $k ] );
2669
-
2670
-
2671
- }
2672
-
2673
- }
2674
-
2675
- }
2676
-
2677
- }
2678
-
2679
- }
2680
-
2681
-
2682
- if ( 'upgrade-plugin' == $action || 'update-plugin' == $action ) {
2683
-
2684
- $plugin = isset( $_REQUEST['plugin'] ) ? trim( sanitize_text_field( $_REQUEST['plugin'] ) ) : '';
2685
-
2686
- $wp_plugin_slug = dirname( $plugin );
2687
-
2688
- $plugin_repository = false;
2689
-
2690
- foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2691
-
2692
- foreach ( $repository['data']['packages'] as $package ) {
2693
-
2694
- foreach ( $package['products'] as $product ) {
2695
-
2696
- foreach ( $product['plugins'] as $plugin_slug ) {
2697
- $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2698
-
2699
- //match by folder, will change to match by name and folder
2700
- if ( $download['slug'] == $wp_plugin_slug ) {
2701
- $plugin_repository = $repository_id;
2702
- $product_name = $repository['data']['product-name'];
2703
- $plugin_name = $download['name'];
2704
- $free_on_wporg = ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION;
2705
- break;
2706
- }
2707
-
2708
- }
2709
-
2710
- }
2711
-
2712
- }
2713
-
2714
- }
2715
-
2716
- if ( $plugin_repository ) {
2717
-
2718
- //validate subscription
2719
- $site_key = $this->get_repository_site_key( $plugin_repository );
2720
- if ( $site_key ) {
2721
- $subscription_data = $this->fetch_subscription_data( $plugin_repository, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION );
2722
- }
2723
-
2724
- if ( ( empty( $site_key ) || empty( $subscription_data ) ) && empty( $free_on_wporg ) ) {
2725
-
2726
- $error_message = sprintf( __( "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer' ),
2727
- '<strong>' . $plugin_name . '</strong>', '<a href="' . $this->menu_url() . '&validate_repository=' . $plugin_repository .
2728
- '#repository-' . $plugin_repository . '">', $product_name, '</a>' );
2729
-
2730
- if ( defined( 'DOING_AJAX' ) ) { //WP 4.2
2731
-
2732
- $status = array(
2733
- 'update' => 'plugin',
2734
- 'plugin' => $plugin,
2735
- 'slug' => sanitize_key( $_POST['slug'] ),
2736
- 'oldVersion' => '',
2737
- 'newVersion' => '',
2738
- );
2739
-
2740
- $status['errorCode'] = 'wp_installer_invalid_subscription';
2741
- $status['error'] = $error_message;
2742
-
2743
- wp_send_json_error( $status );
2744
-
2745
- } else { // WP 4.1.1
2746
- echo '<div class="updated error"><p>' . $error_message . '</p></div>';
2747
-
2748
-
2749
- echo '<div class="wrap">';
2750
- echo '<h2>' . __( 'Update Plugin', 'installer' ) . '</h2>';
2751
- echo '<a href="' . admin_url( 'plugins.php' ) . '">' . __( 'Return to the plugins page', 'installer' ) . '</a>';
2752
- echo '</div>';
2753
- require_once( ABSPATH . 'wp-admin/admin-footer.php' );
2754
- exit;
2755
-
2756
- }
2757
-
2758
- }
2759
-
2760
-
2761
- }
2762
-
2763
- }
2764
- }
2765
-
2766
- }
2767
-
2768
- }
1
+ <?php
2
+
3
+ final class WP_Installer {
4
+ protected static $_instance = null;
5
+
6
+ public $settings = array();
7
+
8
+ private $repositories = array();
9
+
10
+ protected $api_debug = '';
11
+
12
+ private $config = array();
13
+
14
+ protected $_plugins_renew_warnings = array();
15
+
16
+ protected $_gz_on = false;
17
+
18
+ private $admin_messages = array();
19
+
20
+ private $_using_icl = false;
21
+ private $_wpml_version = false;
22
+
23
+ private $package_source = array();
24
+
25
+ const SITE_KEY_VALIDATION_SOURCE_OTHER = 0;
26
+ const SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_SPECIFIC = 1;
27
+ const SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_REPORT = 2;
28
+ const SITE_KEY_VALIDATION_SOURCE_REGISTRATION = 3;
29
+ const SITE_KEY_VALIDATION_SOURCE_REVALIDATION = 4;
30
+ const SITE_KEY_VALIDATION_SOURCE_UPDATES_CHECK = 5;
31
+
32
+ public $dependencies;
33
+
34
+ public static function instance() {
35
+
36
+ if ( is_null( self::$_instance ) ) {
37
+ self::$_instance = new self();
38
+ }
39
+
40
+ return self::$_instance;
41
+ }
42
+
43
+ public function __construct() {
44
+
45
+ if ( ! is_admin() || ! is_user_logged_in() ) {
46
+ return;
47
+ } //Only for admin
48
+
49
+ $this->_gz_on = function_exists( 'gzuncompress' ) && function_exists( 'gzcompress' );
50
+ $this->settings = $this->get_settings();
51
+
52
+ add_action( 'admin_notices', array( $this, 'show_site_key_nags' ) );
53
+
54
+ add_action( 'admin_notices', array( $this, 'show_admin_messages' ) );
55
+
56
+ add_action( 'admin_init', array( $this, 'load_embedded_plugins' ), 0 );
57
+
58
+ add_action( 'admin_menu', array( $this, 'menu_setup' ) );
59
+ add_action( 'network_admin_menu', array( $this, 'menu_setup' ) );
60
+
61
+ if ( defined( 'DOING_AJAX' ) && isset( $_POST['action'] ) && $_POST['action'] == 'installer_download_plugin' ) {
62
+ add_filter( 'site_transient_update_plugins', array( $this, 'plugins_upgrade_check' ) );
63
+ }
64
+ add_filter( 'plugins_api', array( $this, 'custom_plugins_api_call' ), 10, 3 );
65
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'plugins_upgrade_check' ) );
66
+
67
+ // register repositories
68
+ $this->load_repositories_list();
69
+
70
+ // default config
71
+ $this->config['plugins_install_tab'] = false;
72
+
73
+ add_action( 'init', array( $this, 'init' ) );
74
+
75
+ //add_filter('wp_installer_buy_url', array($this, 'append_parameters_to_buy_url'));
76
+
77
+ add_action( 'init', array( $this, 'load_locale' ) );
78
+
79
+ }
80
+
81
+ public function get_repositories() {
82
+
83
+ return $this->repositories;
84
+
85
+ }
86
+
87
+ public function set_config( $key, $value ) {
88
+
89
+ $this->config[ $key ] = $value;
90
+
91
+ }
92
+
93
+ public function init() {
94
+ global $pagenow;
95
+
96
+ if ( empty( $this->settings['last_repositories_update'] ) || time() - $this->settings['last_repositories_update'] > 86400
97
+ || ( isset( $_GET['force-check'] ) && $_GET['force-check'] == 1 )
98
+ ) {
99
+ $this->refresh_repositories_data();
100
+ }
101
+
102
+ $this->dependencies = new Installer_Dependencies;
103
+
104
+ if ( empty( $this->settings['_pre_1_0_clean_up'] ) ) {
105
+ $this->_pre_1_0_clean_up();
106
+ }
107
+
108
+ $this->settings = $this->_old_products_format_backwards_compatibility( $this->settings );
109
+
110
+ if ( ! function_exists( 'get_plugins' ) ) {
111
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
112
+ }
113
+
114
+ $this->_using_icl = function_exists( 'wpml_site_uses_icl' ) && wpml_site_uses_icl();
115
+ $this->_wpml_version = defined( 'ICL_SITEPRESS_VERSION' ) ? ICL_SITEPRESS_VERSION : '';
116
+
117
+ wp_enqueue_script( 'installer-admin', $this->res_url() . '/res/js/admin.js', array( 'jquery' ), $this->version() );
118
+ wp_enqueue_style( 'installer-admin', $this->res_url() . '/res/css/admin.css', array(), $this->version() );
119
+
120
+ $translation_array = array(
121
+ 'installing' => __( 'Installing %s', 'installer' ),
122
+ 'updating' => __( 'Updating %s', 'installer' ),
123
+ 'activating' => __( 'Activating %s', 'installer' )
124
+ );
125
+
126
+ wp_localize_script( 'installer-admin', 'installer_strings', $translation_array );
127
+
128
+ if ( $pagenow == 'plugins.php' ) {
129
+ add_action( 'admin_notices', array( $this, 'setup_plugins_page_notices' ) );
130
+ add_action( 'admin_notices', array( $this, 'setup_plugins_renew_warnings' ), 10 );
131
+ add_action( 'admin_notices', array( $this, 'queue_plugins_renew_warnings' ), 20 );
132
+
133
+ add_action( 'admin_init', array( $this, 'setup_plugins_action_links' ) );
134
+
135
+ }
136
+
137
+ if ( $this->is_repositories_page() ) {
138
+ add_action( 'admin_init', array( $this, 'validate_repository_subscription' ) );
139
+ }
140
+
141
+ if ( defined( 'DOING_AJAX' ) ) {
142
+ add_action( 'wp_ajax_save_site_key', array( $this, 'save_site_key' ) );
143
+ add_action( 'wp_ajax_remove_site_key', array( $this, 'remove_site_key_ajax' ) );
144
+ add_action( 'wp_ajax_update_site_key', array( $this, 'update_site_key' ) );
145
+
146
+ add_action( 'wp_ajax_installer_download_plugin', array( $this, 'download_plugin_ajax_handler' ) );
147
+ add_action( 'wp_ajax_installer_activate_plugin', array( $this, 'activate_plugin' ) );
148
+
149
+ add_action( 'wp_ajax_installer_dismiss_nag', array( $this, 'dismiss_nag' ) );
150
+ }
151
+
152
+ if ( $pagenow == 'update.php' ) {
153
+ if ( isset( $_GET['action'] ) && $_GET['action'] == 'update-selected' ) {
154
+ add_action( 'admin_head', array( $this, 'plugin_upgrade_custom_errors' ) ); //iframe/bulk
155
+ } else {
156
+ add_action( 'all_admin_notices', array( $this, 'plugin_upgrade_custom_errors' ) ); //regular/singular
157
+ }
158
+ }
159
+
160
+ // WP 4.2
161
+ if ( defined( 'DOING_AJAX' ) ) {
162
+ add_action( 'wp_ajax_update-plugin', array(
163
+ $this,
164
+ 'plugin_upgrade_custom_errors'
165
+ ), 0 ); // high priority, before WP
166
+ }
167
+
168
+ //Include theme support
169
+ include_once $this->plugin_path() . '/includes/class-installer-theme.php';
170
+
171
+ // Extra information about the source of Installer
172
+ $package_source_file = $this->plugin_path() . '/installer-source.json';
173
+ if ( file_exists( $package_source_file ) ) {
174
+ WP_Filesystem();
175
+ global $wp_filesystem;
176
+ $this->package_source = json_decode( $wp_filesystem->get_contents( $package_source_file ) );
177
+ }
178
+ }
179
+
180
+ protected function log( $message ) {
181
+ require_once ABSPATH . 'wp-admin/includes/file.php';
182
+ WP_Filesystem();
183
+ global $wp_filesystem;
184
+ if ( defined( 'WPML_INSTALLER_LOGGING' ) && WPML_INSTALLER_LOGGING ) {
185
+ $wp_filesystem->put_contents( $this->plugin_path() . '/installer.log', current_time( 'mysql' ) . "\t" . $message . "\n" );
186
+ }
187
+ }
188
+
189
+ public function register_admin_message( $text, $type = 'updated' ) {
190
+ $this->admin_messages[] = array( 'text' => $text, 'type' => $type );
191
+ }
192
+
193
+ public function show_admin_messages() {
194
+ if ( ! empty( $this->admin_messages ) ) {
195
+ $types = array( 'error', 'updated', 'notice' );
196
+ foreach ( $this->admin_messages as $message ) {
197
+ $class = in_array( $message['type'], $types ) ? $message['type'] : 'updated';
198
+ ?>
199
+ <div class="<?php echo $class ?>">
200
+ <p>
201
+ <?php echo $message['text'] ?>
202
+ </p>
203
+ </div>
204
+ <?php
205
+ }
206
+ }
207
+ }
208
+
209
+ public function load_locale() {
210
+ if ( function_exists( 'get_user_locale' ) ) {
211
+ $locale = get_user_locale();
212
+ } else {
213
+ $locale = get_locale();
214
+ }
215
+ $locale = apply_filters( 'plugin_locale', $locale, 'installer' );
216
+ $mo_file = $this->plugin_path() . '/locale/installer-' . $locale . '.mo';
217
+ if ( file_exists( $mo_file ) ) {
218
+ load_textdomain( 'installer', $mo_file );
219
+ }
220
+ }
221
+
222
+ public function load_embedded_plugins() {
223
+ if ( file_exists( $this->plugin_path() . '/embedded-plugins' ) ) {
224
+ include_once $this->plugin_path() . '/embedded-plugins/embedded-plugins.class.php';
225
+ $this->installer_embedded_plugins = new Installer_Embedded_Plugins();
226
+ }
227
+ }
228
+
229
+ public function menu_setup() {
230
+ global $pagenow;
231
+
232
+ if ( is_multisite() && ! is_network_admin() ) {
233
+ $this->menu_multisite_redirect();
234
+ add_options_page( __( 'Installer', 'installer' ), __( 'Installer', 'installer' ), 'manage_options', 'installer', array(
235
+ $this,
236
+ 'show_products'
237
+ ) );
238
+ } else {
239
+ if ( $this->config['plugins_install_tab'] && is_admin() && $pagenow == 'plugin-install.php' ) {
240
+ // Default GUI, under Plugins -> Install
241
+ add_filter( 'install_plugins_tabs', array( $this, 'add_install_plugins_tab' ) );
242
+ add_action( 'install_plugins_commercial', array( $this, 'show_products' ) );
243
+ }
244
+ }
245
+
246
+ }
247
+
248
+ public function menu_url() {
249
+ if ( is_multisite() ) {
250
+ if ( is_network_admin() ) {
251
+ $url = network_admin_url( 'plugin-install.php?tab=commercial' );
252
+ } else {
253
+ $url = admin_url( 'options-general.php?page=installer' );
254
+ }
255
+ } else {
256
+ $url = admin_url( 'plugin-install.php?tab=commercial' );
257
+ }
258
+
259
+ return $url;
260
+ }
261
+
262
+ private function menu_multisite_redirect() {
263
+ global $pagenow;
264
+
265
+ if ( $pagenow == 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] == 'commercial' ) {
266
+ wp_redirect( $this->menu_url() );
267
+ exit;
268
+ }
269
+
270
+ }
271
+
272
+ private function _pre_1_0_clean_up() {
273
+ global $wpdb;
274
+
275
+ if ( ! defined( 'WPRC_VERSION' ) ) {
276
+ $old_tables = array(
277
+ $wpdb->prefix . 'wprc_cached_requests',
278
+ $wpdb->prefix . 'wprc_extension_types',
279
+ $wpdb->prefix . 'wprc_extensions',
280
+ $wpdb->prefix . 'wprc_repositories',
281
+ $wpdb->prefix . 'wprc_repositories_relationships',
282
+ );
283
+
284
+ foreach ( $old_tables as $table ) {
285
+ $wpdb->query( sprintf( "DROP TABLE IF EXISTS %s", $table ) );
286
+ }
287
+
288
+ }
289
+
290
+ $this->settings['_pre_1_0_clean_up'] = true;
291
+ $this->save_settings();
292
+ }
293
+
294
+ public function setup_plugins_action_links() {
295
+
296
+ $plugins = get_plugins();
297
+
298
+ $repositories_plugins = array();
299
+
300
+ if ( ! empty( $this->settings['repositories'] ) ) {
301
+
302
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
303
+
304
+ foreach ( $repository['data']['packages'] as $package ) {
305
+
306
+ foreach ( $package['products'] as $product ) {
307
+
308
+ foreach ( $product['plugins'] as $plugin_slug ) {
309
+
310
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
311
+
312
+ if ( ! isset( $repositories_plugins[ $repository_id ][ $download['slug'] ] ) ) {
313
+ $repositories_plugins[ $repository_id ][ $download['slug'] ] = array(
314
+ 'name' => $download['name'],
315
+ 'registered' => $this->plugin_is_registered( $repository_id, $download['slug'] ) ? 1 : 0
316
+ );
317
+ }
318
+
319
+ }
320
+
321
+ }
322
+
323
+ }
324
+
325
+ foreach ( $plugins as $plugin_id => $plugin ) {
326
+
327
+ $wp_plugin_slug = dirname( $plugin_id );
328
+ if ( empty( $wp_plugin_slug ) ) {
329
+ $wp_plugin_slug = basename( $plugin_id, '.php' );
330
+ }
331
+
332
+ foreach ( $repositories_plugins as $repository_id => $r_plugins ) {
333
+
334
+ foreach ( $r_plugins as $slug => $r_plugin ) {
335
+
336
+ if ( $wp_plugin_slug == $slug || $r_plugin['name'] == $plugin['Name'] || $r_plugin['name'] == $plugin['Title'] ) { //match order: slug, name, title
337
+
338
+ if ( $r_plugin['registered'] ) {
339
+ add_filter( 'plugin_action_links_' . $plugin_id, array(
340
+ $this,
341
+ 'plugins_action_links_registered'
342
+ ) );
343
+ } else {
344
+ add_filter( 'plugin_action_links_' . $plugin_id, array(
345
+ $this,
346
+ 'plugins_action_links_not_registered'
347
+ ) );
348
+ }
349
+
350
+ }
351
+
352
+ }
353
+
354
+ }
355
+
356
+
357
+ }
358
+
359
+ }
360
+ }
361
+
362
+ }
363
+
364
+ public function plugins_action_links_registered( $links ) {
365
+ $links[] = '<a href="' . $this->menu_url() . '">' . __( 'Registered', 'installer' ) . '</a>';
366
+
367
+ return $links;
368
+ }
369
+
370
+ public function plugins_action_links_not_registered( $links ) {
371
+ $links[] = '<a href="' . $this->menu_url() . '">' . __( 'Register', 'installer' ) . '</a>';
372
+
373
+ return $links;
374
+ }
375
+
376
+ public function plugin_is_registered( $repository_id, $slug ) {
377
+
378
+ $registered = false;
379
+
380
+ if ( $this->repository_has_valid_subscription( $repository_id ) ) {
381
+
382
+ $subscription_type = $this->get_subscription_type_for_repository( $repository_id );
383
+ $r_plugins = array();
384
+
385
+ foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
386
+
387
+ foreach ( $package['products'] as $product ) {
388
+
389
+ if ( $product['subscription_type'] == $subscription_type || $this->have_superior_subscription( $subscription_type, $product ) ) {
390
+
391
+ foreach ( $product['plugins'] as $plugin_slug ) {
392
+
393
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
394
+
395
+ if ( ! isset( $rep_plugins[ $download['slug'] ] ) ) {
396
+ $r_plugins[ $download['slug'] ] = $download['slug'];
397
+ }
398
+
399
+ }
400
+
401
+ }
402
+
403
+ }
404
+
405
+ }
406
+
407
+ $registered = isset( $r_plugins[ $slug ] );
408
+
409
+ }
410
+
411
+
412
+ return $registered;
413
+
414
+ }
415
+
416
+ public function version() {
417
+ return WP_INSTALLER_VERSION;
418
+ }
419
+
420
+ public function plugin_path() {
421
+ return untrailingslashit( plugin_dir_path( dirname( __FILE__ ) ) );
422
+ }
423
+
424
+ public function plugin_url() {
425
+ if ( isset( $this->config['in_theme_folder'] ) && ! empty( $this->config['in_theme_folder'] ) ) {
426
+ $url = untrailingslashit( get_template_directory_uri() . '/' . $this->config['in_theme_folder'] );
427
+ } else {
428
+ $url = untrailingslashit( plugins_url( '/', dirname( __FILE__ ) ) );
429
+ }
430
+
431
+ return $url;
432
+ }
433
+
434
+ public function is_repositories_page() {
435
+ global $pagenow;
436
+
437
+ return $pagenow == 'plugin-install.php' && isset( $_GET['tab'] ) && $_GET['tab'] == 'commercial';
438
+ }
439
+
440
+ public function res_url() {
441
+ if ( isset( $this->config['in_theme_folder'] ) && ! empty( $this->config['in_theme_folder'] ) ) {
442
+ $url = untrailingslashit( get_template_directory_uri() . '/' . $this->config['in_theme_folder'] );
443
+ } else {
444
+ $url = $this->plugin_url();
445
+ }
446
+
447
+ return $url;
448
+ }
449
+
450
+ public function save_settings() {
451
+
452
+ $_settings = serialize( $this->settings );
453
+ if ( $this->_gz_on ) {
454
+ $_settings = gzcompress( $_settings );
455
+ }
456
+ $_settings = base64_encode( $_settings );
457
+
458
+ update_option( 'wp_installer_settings', $_settings );
459
+
460
+ if ( is_multisite() && is_main_site() && isset( $this->settings['repositories'] ) ) {
461
+ $network_settings = array();
462
+
463
+ foreach ( $this->settings['repositories'] as $rep_id => $repository ) {
464
+ if ( isset( $repository['subscription'] ) ) {
465
+ $network_settings[ $rep_id ] = $repository['subscription'];
466
+ }
467
+ }
468
+
469
+ update_site_option( 'wp_installer_network', $network_settings );
470
+
471
+
472
+ }
473
+
474
+ }
475
+
476
+ public function get_settings( $refresh = false ) {
477
+
478
+ if ( $refresh || empty( $this->settings ) ) {
479
+
480
+ $_settings = get_option( 'wp_installer_settings' );
481
+
482
+
483
+ if ( is_array( $_settings ) || empty( $_settings ) ) { //backward compatibility 1.1
484
+ $this->settings = $_settings;
485
+
486
+ } else {
487
+ $_settings = base64_decode( $_settings );
488
+ if ( $this->_gz_on ) {
489
+ $_settings = gzuncompress( $_settings );
490
+ }
491
+ $this->settings = unserialize( $_settings );
492
+ }
493
+
494
+ // Initialize
495
+ if ( empty( $this->settings ) ) {
496
+ $this->settings = array(
497
+ 'repositories' => array()
498
+ );
499
+ }
500
+
501
+ if ( is_multisite() ) {
502
+ $network_settings = maybe_unserialize( get_site_option( 'wp_installer_network' ) );
503
+ if ( $network_settings ) {
504
+ foreach ( $this->settings['repositories'] as $rep_id => $repository ) {
505
+ if ( isset( $network_settings[ $rep_id ] ) ) {
506
+ $this->settings['repositories'][ $rep_id ]['subscription'] = $network_settings[ $rep_id ];
507
+ }
508
+ }
509
+ }
510
+ }
511
+
512
+ $this->load_hardcoded_site_keys();
513
+
514
+ $this->_pre_1_8_backwards_compatibility( $this->settings );
515
+
516
+ $this->settings = $this->_old_products_format_backwards_compatibility( $this->settings );
517
+
518
+ }
519
+
520
+ return $this->settings;
521
+ }
522
+
523
+ private function load_hardcoded_site_keys() {
524
+
525
+ if ( ! empty( $this->settings['repositories'] ) ) {
526
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
527
+
528
+ if ( $site_key = self::get_repository_hardcoded_site_key( $repository_id ) ) {
529
+
530
+ $site_key_missing = empty( $this->settings['repositories'][ $repository_id ]['subscription']['data'] );
531
+ $site_key_changed = ! $site_key_missing &&
532
+ $this->settings['repositories'][ $repository_id ]['subscription']['key'] != $site_key;
533
+
534
+ if ( $site_key_missing || $site_key_changed ) {
535
+
536
+ if ( ! function_exists( 'get_plugins' ) ) {
537
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
538
+ }
539
+ $this->load_repositories_list();
540
+ $response = $this->save_site_key(
541
+ array(
542
+ 'repository_id' => $repository_id,
543
+ 'site_key' => $site_key,
544
+ 'return' => true,
545
+ 'nonce' => wp_create_nonce( 'save_site_key_' . $repository_id )
546
+ )
547
+ );
548
+
549
+ if ( ! empty( $response['error'] ) ) {
550
+ $this->remove_site_key( $repository_id );
551
+
552
+ $this->admin_messages[] = array(
553
+ 'type' => 'error',
554
+ 'text' => sprintf( __( 'You are using an invalid site key defined as the constant %s (most likely in wp-config.php).
555
+ Please remove it or use the correct value in order to be able to register correctly.', 'installer' ), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper( $repository_id ) )
556
+ );
557
+
558
+ }
559
+
560
+ }
561
+
562
+ }
563
+
564
+ }
565
+ }
566
+
567
+ }
568
+
569
+ public static function get_repository_hardcoded_site_key( $repository_id ) {
570
+
571
+ $site_key = false;
572
+
573
+ $site_key_constant = 'OTGS_INSTALLER_SITE_KEY_' . strtoupper( $repository_id );
574
+ if ( defined( $site_key_constant ) ) {
575
+ $site_key = constant( $site_key_constant );
576
+ }
577
+
578
+ return $site_key;
579
+ }
580
+
581
+ //backward compatibility, add channel
582
+ private function _pre_1_8_backwards_compatibility( &$settings ) {
583
+ if ( empty( $settings['_pre_1_8_clean_up'] ) ) {
584
+ foreach ( $settings['repositories'] as $repository_id => $repository ) {
585
+ foreach ( $repository['data']['downloads']['plugins'] as $slug => $download ) {
586
+ if( !isset( $download['channel'] ) ){
587
+ $settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $slug ]['channel'] = '';
588
+ }
589
+ }
590
+ }
591
+ $this->save_settings();
592
+ }
593
+ }
594
+
595
+ //backward compatibility - support old products list format (downloads under products instead of global downloads list)
596
+ private function _old_products_format_backwards_compatibility( $settings ) {
597
+
598
+ if ( version_compare( $this->version(), '1.8', '<' ) && ! empty( $settings['repositories'] ) && empty( $this->_old_products_format_backwards_compatibility ) ) {
599
+
600
+ foreach ( $settings['repositories'] as $repository_id => $repository ) {
601
+ $populate_downloads = false;
602
+ if ( isset( $repository['data'] ) ) {
603
+
604
+ foreach ( $repository['data']['packages'] as $package_id => $package ) {
605
+ foreach ( $package['products'] as $product_id => $product ) {
606
+ if ( ! isset( $product['plugins'] ) ) {
607
+ $populate_downloads = true;
608
+ foreach ( $product['downloads'] as $download_id => $download ) {
609
+ $settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['plugins'][] = $download['slug'];
610
+ }
611
+ }
612
+ }
613
+ }
614
+
615
+ if ( $populate_downloads ) {
616
+ // Add downloads branch
617
+ foreach ( $repository['data']['packages'] as $package_id => $package ) {
618
+ foreach ( $package['products'] as $product_id => $product ) {
619
+ foreach ( $product['downloads'] as $download_id => $download ) {
620
+ if ( ! isset( $settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $download['slug'] ] ) ) {
621
+ $settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $download['slug'] ] = $download;
622
+ }
623
+ $settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['plugins'][] = $download['slug'];
624
+ }
625
+ unset( $settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['downloads'] );
626
+ }
627
+ }
628
+ }
629
+ }
630
+ }
631
+
632
+ $this->_old_products_format_backwards_compatibility = true;
633
+ }
634
+
635
+ return $settings;
636
+ }
637
+
638
+ public function get_installer_site_url( $repository_id = false ) {
639
+ global $current_site;
640
+
641
+ $site_url = get_site_url();
642
+
643
+ if ( $repository_id && is_multisite() && isset( $this->settings['repositories'] ) ) {
644
+ $network_settings = maybe_unserialize( get_site_option( 'wp_installer_network' ) );
645
+
646
+ if ( isset( $network_settings[ $repository_id ] ) ) {
647
+ $site_url = get_site_url( $current_site->blog_id );
648
+ }
649
+
650
+ }
651
+
652
+ return $site_url;
653
+ }
654
+
655
+ public function show_site_key_nags() {
656
+ $screen = get_current_screen();
657
+
658
+ if ( $screen->base == 'settings_page_installer' || ( $screen->base == 'plugin-install' && isset( $_GET['tab'] ) && $_GET['tab'] == 'commercial' ) ) {
659
+ return;
660
+ }
661
+
662
+ if ( ! empty( $this->config['site_key_nags'] ) ) {
663
+
664
+ foreach ( $this->config['site_key_nags'] as $nag ) {
665
+
666
+ if ( ! $this->repository_has_subscription( $nag['repository_id'] ) ) {
667
+ $show = true;
668
+ if ( ! empty( $nag['condition_cb'] ) ) {
669
+ $show = call_user_func( $nag['condition_cb'] );
670
+ }
671
+
672
+ if ( empty( $this->settings['dismissed_nags'][ $nag['repository_id'] ] ) && $show ) {
673
+ echo '<div class="updated error otgs-is-dismissible"><p>';
674
+ printf( __( "To get automatic updates, you need to register %s for this site. %sRegister %s%s", 'sitepress' ),
675
+ $nag['product_name'], '<a class="button-primary" href="' . $this->menu_url() . '">', $nag['product_name'], '</a>' );
676
+
677
+ echo '</p>';
678
+ echo '<span class="installer-dismiss-nag notice-dismiss" data-repository="' . $nag['repository_id'] . '"><span class="screen-reader-text">' . __( 'Dismiss', 'sitepress' ) . '</span></span>';
679
+ echo '</div>';
680
+ }
681
+ }
682
+
683
+ }
684
+
685
+ }
686
+
687
+ }
688
+
689
+ public function dismiss_nag() {
690
+ $this->settings['dismissed_nags'][ $_POST['repository'] ] = 1;
691
+
692
+ $this->save_settings();
693
+
694
+ echo json_encode( array() );
695
+ exit;
696
+ }
697
+
698
+ public function add_install_plugins_tab( $tabs ) {
699
+
700
+ $tabs['commercial'] = __( 'Commercial', 'installer' );
701
+
702
+ return $tabs;
703
+ }
704
+
705
+ public function load_repositories_list() {
706
+ global $wp_installer_instances;
707
+
708
+ foreach ( $wp_installer_instances as $instance ) {
709
+
710
+ if ( file_exists( dirname( $instance['bootfile'] ) . '/repositories.xml' ) ) {
711
+ $config_file = dirname( $instance['bootfile'] ) . '/repositories.xml';
712
+
713
+ if ( file_exists( dirname( $instance['bootfile'] ) . '/repositories.sandbox.xml' ) ) {
714
+ $config_file = dirname( $instance['bootfile'] ) . '/repositories.sandbox.xml';
715
+ add_filter( 'https_ssl_verify', '__return_false' );
716
+ }
717
+
718
+ $repos = simplexml_load_file( $config_file );
719
+
720
+ if ( $repos ) {
721
+ foreach ( $repos as $repo ) {
722
+ $id = strval( $repo->id );
723
+
724
+ $data['api-url'] = strval( $repo->apiurl );
725
+ $data['products'] = strval( $repo->products );
726
+
727
+ // excludes rule;
728
+ if ( isset( $this->config['repositories_exclude'] ) && in_array( $id, $this->config['repositories_exclude'] ) ) {
729
+ continue;
730
+ }
731
+
732
+ // includes rule;
733
+ if ( isset( $this->config['repositories_include'] ) && ! in_array( $id, $this->config['repositories_include'] ) ) {
734
+ continue;
735
+ }
736
+
737
+ $this->repositories[ $id ] = $data;
738
+
739
+ }
740
+ }
741
+
742
+ }
743
+ }
744
+
745
+ }
746
+
747
+ public function filter_repositories_list() {
748
+
749
+ if ( ! empty( $this->settings['repositories'] ) ) {
750
+ foreach ( $this->settings['repositories'] as $id => $repo_data ) {
751
+
752
+ // excludes rule;
753
+ if ( isset( $this->config['repositories_exclude'] ) && in_array( $id, $this->config['repositories_exclude'] ) ) {
754
+ unset( $this->settings['repositories'][ $id ] );
755
+ }
756
+
757
+ // includes rule;
758
+ if ( isset( $this->config['repositories_include'] ) && ! in_array( $id, $this->config['repositories_include'] ) ) {
759
+ unset( $this->settings['repositories'][ $id ] );
760
+ }
761
+
762
+
763
+ }
764
+ }
765
+
766
+
767
+ }
768
+
769
+ public function refresh_repositories_data() {
770
+ static $checked = false;
771
+
772
+ if ( defined( 'OTGS_DISABLE_AUTO_UPDATES' ) && OTGS_DISABLE_AUTO_UPDATES && empty( $_GET['force-check'] ) || $checked ) {
773
+
774
+ if ( empty( $this->settings['repositories'] ) && $this->is_repositories_page() ) {
775
+
776
+ foreach ( $this->repositories as $id => $data ) {
777
+ $repository_names[] = $id;
778
+
779
+ }
780
+
781
+ $error = sprintf( __( "Installer cannot display the products information because the automatic updating for %s was explicitly disabled with the configuration below (usually in wp-config.php):", 'installer' ), strtoupper( join( ', ', $repository_names ) ) );
782
+ $error .= '<br /><br /><code>define("OTGS_DISABLE_AUTO_UPDATES", true);</code><br /><br />';
783
+ $error .= sprintf( __( "In order to see the products information, please run the %smanual updates check%s to initialize the products list or (temporarily) remove the above code.", 'installer' ), '<a href="' . admin_url( 'update-core.php' ) . '">', '</a>' );
784
+
785
+ $this->register_admin_message( $error, 'error' );
786
+
787
+
788
+ }
789
+
790
+ return;
791
+ }
792
+
793
+ $checked = true;
794
+
795
+ foreach ( $this->repositories as $id => $data ) {
796
+
797
+ $response = wp_remote_get( $data['products'] );
798
+
799
+ if ( is_wp_error( $response ) ) {
800
+ // http fallback
801
+ $data['products'] = preg_replace( "@^https://@", 'http://', $data['products'] );
802
+ $response = wp_remote_get( $data['products'] );
803
+ }
804
+
805
+ if ( is_wp_error( $response ) ) {
806
+
807
+ $error = sprintf( __( "Installer cannot contact our updates server to get information about the available products and check for new versions. If you are seeing this message for the first time, you can ignore it, as it may be a temporary communication problem. If the problem persists and your WordPress admin is slowing down, you can disable automated version checks. Add the following line to your wp-config.php file:", 'installer' ), strtoupper( $id ) );
808
+ $error .= '<br /><br /><code>define("OTGS_DISABLE_AUTO_UPDATES", true);</code>';
809
+
810
+ $this->register_admin_message( $error, 'error' );
811
+
812
+ continue;
813
+ }
814
+
815
+ if ( $response && isset( $response['response']['code'] ) && $response['response']['code'] == 200 ) {
816
+ $body = wp_remote_retrieve_body( $response );
817
+ if ( $body ) {
818
+ $products = json_decode( $body, true );
819
+
820
+ if ( is_array( $products ) ) {
821
+ $products['downloads'] = WP_Installer_Channels()->filter_downloads_by_channel( $id, $products['downloads'] );
822
+ $this->set_release_notes( $products['downloads'] );
823
+
824
+ $this->settings['repositories'][ $id ]['data'] = $products;
825
+ $this->_pre_1_8_backwards_compatibility( $this->settings );
826
+ }
827
+ }
828
+
829
+ }
830
+
831
+ $this->log( sprintf( "Checked for %s updates: %s", $id, $data['products'] ) );
832
+
833
+
834
+ }
835
+
836
+ // cleanup
837
+ if ( empty( $this->settings['repositories'] ) ) {
838
+ $this->settings['repositories'] = array();
839
+ }
840
+ foreach ( $this->settings['repositories'] as $id => $data ) {
841
+ if ( ! in_array( $id, array_keys( $this->repositories ) ) ) {
842
+ unset( $this->settings['repositories'][ $id ] );
843
+ }
844
+ }
845
+
846
+ $this->settings['last_repositories_update'] = time();
847
+
848
+ $this->save_settings();
849
+
850
+ }
851
+
852
+ /**
853
+ * Gets the release notes for the available version from the changelog
854
+ *
855
+ * @param array $all_downloads
856
+ */
857
+ private function set_release_notes( &$all_downloads ) {
858
+ foreach ( $all_downloads as $kind => $downloads ) {
859
+ foreach ( $downloads as $slug => $download ) {
860
+ $start = strpos( $download['changelog'], '<h4>' . $download['version'] . '</h4>' );
861
+ if ( $start !== false ) {
862
+ $start += strlen( $download['version'] ) + 9;
863
+ $end = strpos( $download['changelog'], '<h4>', 4 );
864
+ if ( $end ) {
865
+ $release_notes = substr( $download['changelog'], $start, $end - $start );
866
+ } else {
867
+ $release_notes = substr( $download['changelog'], $start );
868
+ }
869
+ }
870
+ $all_downloads[ $kind ][ $slug ]['release-notes'] = ! empty( $release_notes ) ? $release_notes : '';
871
+ }
872
+ }
873
+ }
874
+
875
+ public function show_products( $args = array() ) {
876
+
877
+ $screen = get_current_screen();
878
+
879
+ if ( $screen->base == 'settings_page_installer' ) { // settings page
880
+ echo '<div class="wrap">';
881
+ echo '<h2>' . __( 'Installer', 'installer' ) . '</h2>';
882
+ echo '<br />';
883
+ }
884
+
885
+ if ( ! is_array( $args ) ) {
886
+ $args = array();
887
+ }
888
+ if ( empty( $args['template'] ) ) {
889
+ $args['template'] = 'default';
890
+ }
891
+
892
+ $this->filter_repositories_list();
893
+
894
+ if ( ! empty( $this->settings['repositories'] ) ) {
895
+
896
+ $this->localize_strings();
897
+ $this->set_filtered_prices( $args );
898
+ $this->set_hierarchy_and_order();
899
+
900
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
901
+
902
+ if ( $args['template'] == 'compact' ) {
903
+
904
+ if ( isset( $args['repository'] ) && $args['repository'] == $repository_id ) {
905
+ include $this->plugin_path() . '/templates/products-compact.php';
906
+ }
907
+
908
+ } else {
909
+
910
+ include $this->plugin_path() . '/templates/repository-listing.php';
911
+
912
+ }
913
+
914
+ unset( $site_key, $subscription_type, $expired, $upgrade_options, $products_avaliable );
915
+
916
+ }
917
+
918
+ } else {
919
+
920
+ echo '<center>' . __( 'No repositories defined.', 'installer' ) . '</center>';
921
+
922
+ }
923
+
924
+ if ( $screen->base == 'settings_page_installer' ) { // settings page
925
+ echo '</div>';
926
+ }
927
+
928
+
929
+ }
930
+
931
+ public function get_product_price( $repository_id, $package_id, $product_id, $incl_discount = false ) {
932
+
933
+ $price = false;
934
+
935
+ foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
936
+
937
+ if ( $package['id'] == $package_id ) {
938
+ if ( isset( $package['products'][ $product_id ] ) ) {
939
+ if ( $incl_discount && isset( $package['products'][ $product_id ]['price_disc'] ) ) {
940
+ $price = $package['products'][ $product_id ]['price_disc'];
941
+ } elseif ( isset( $package['products'][ $product_id ]['price'] ) ) {
942
+ $price = $package['products'][ $product_id ]['price'];
943
+ }
944
+ }
945
+ break;
946
+ }
947
+ }
948
+
949
+ return $price;
950
+ }
951
+
952
+ private function _render_product_packages( $packages, $subscription_type, $expired, $upgrade_options, $repository_id ) {
953
+
954
+ $data = array();
955
+
956
+ foreach ( $packages as $package_id => $package ) {
957
+
958
+ $row = array( 'products' => array(), 'downloads' => array() );
959
+ foreach ( $package['products'] as $product ) {
960
+
961
+ // filter out free subscriptions from being displayed as buying options
962
+ if ( empty( $product['price'] ) && ( empty( $subscription_type ) || $expired ) ) {
963
+ continue;
964
+ }
965
+
966
+ //consider equivalent subscriptions
967
+ if ( empty( $product['subscription_type_equivalent'] ) ) {
968
+ $product['subscription_type_equivalent'] = '';
969
+ }
970
+
971
+ // buy base
972
+ if ( empty( $subscription_type ) || $expired ) {
973
+
974
+ $p['url'] = $this->append_parameters_to_buy_url( $product['url'], $repository_id );
975
+ if ( ! empty( $product['price_disc'] ) ) {
976
+ $p['label'] = $product['call2action'] . ' - ' . sprintf( '$%s %s$%d%s (USD)', $product['price_disc'], '&nbsp;&nbsp;<del>', $product['price'], '</del>' );
977
+ } else {
978
+ $p['label'] = $product['call2action'] . ' - ' . sprintf( '$%d (USD)', $product['price'] );
979
+ }
980
+ $row['products'][] = $p;
981
+
982
+ // renew
983
+ } elseif ( isset( $subscription_type ) && ( $product['subscription_type'] == $subscription_type || $product['subscription_type_equivalent'] == $subscription_type ) ) {
984
+
985
+ if ( $product['renewals'] ) {
986
+ foreach ( $product['renewals'] as $renewal ) {
987
+ $p['url'] = $this->append_parameters_to_buy_url( $renewal['url'], $repository_id );
988
+ $p['label'] = $renewal['call2action'] . ' - ' . sprintf( '$%d (USD)', $renewal['price'] );
989
+ }
990
+
991
+ $row['products'][] = $p;
992
+ }
993
+
994
+ }
995
+
996
+ // upgrades
997
+ if ( ! empty( $upgrade_options[ $product['subscription_type'] ] ) ) {
998
+
999
+ foreach ( $upgrade_options[ $product['subscription_type'] ] as $stype => $upgrade ) {
1000
+ if ( $stype != $subscription_type ) {
1001
+ continue;
1002
+ }
1003
+
1004
+ $p['url'] = $this->append_parameters_to_buy_url( $upgrade['url'], $repository_id );
1005
+ if ( ! empty( $upgrade['price_disc'] ) ) {
1006
+ $p['label'] = $upgrade['call2action'] . ' - ' . sprintf( '$%s %s$%d%s (USD)', $upgrade['price_disc'], '&nbsp;&nbsp;<del>', $upgrade['price'], '</del>' );
1007
+ } else {
1008
+ $p['label'] = $upgrade['call2action'] . ' - ' . sprintf( '$%d (USD)', $upgrade['price'] );
1009
+ }
1010
+ $row['products'][] = $p;
1011
+
1012
+ }
1013
+
1014
+ }
1015
+
1016
+ // downloads
1017
+ if ( isset( $subscription_type ) && ! $expired && ( $product['subscription_type'] == $subscription_type || $product['subscription_type_equivalent'] == $subscription_type ) ) {
1018
+
1019
+ foreach ( $product['plugins'] as $plugin_slug ) {
1020
+ $row['downloads'][ $plugin_slug ] = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1021
+ }
1022
+
1023
+ }
1024
+
1025
+ //subpackages
1026
+ if ( ! empty( $package['sub-packages'] ) ) {
1027
+ $row['sub-packages'] = $package['sub-packages'];
1028
+ }
1029
+
1030
+ }
1031
+
1032
+ $row['id'] = $package['id'];
1033
+ $row['image_url'] = $package['image_url'];
1034
+ $row['name'] = $package['name'];
1035
+ $row['description'] = $package['description'];
1036
+
1037
+ if ( ! empty( $row['products'] ) || ! empty( $row['downloads'] ) || ! empty( $row['sub-packages'] ) ) {
1038
+ $data[] = $row;
1039
+ }
1040
+
1041
+
1042
+ }
1043
+
1044
+ return $data;
1045
+
1046
+ }
1047
+
1048
+ public function get_extra_url_parameters() {
1049
+
1050
+ $parameters = array();
1051
+
1052
+ if ( ! empty( $this->package_source ) ) {
1053
+ foreach ( $this->package_source as $key => $val ) {
1054
+ $parameters[ $key ] = $val;
1055
+ }
1056
+ }
1057
+
1058
+ $parameters['installer_version'] = WP_INSTALLER_VERSION;
1059
+ $parameters['theme'] = wp_get_theme()->get( 'Name' );
1060
+ $parameters['site_name'] = get_bloginfo( 'name' );
1061
+
1062
+ return $parameters;
1063
+ }
1064
+
1065
+ public function append_parameters_to_buy_url( $url, $repository_id, $args = array() ) {
1066
+
1067
+ $url = add_query_arg( array( 'icl_site_url' => $this->get_installer_site_url( $repository_id ) ), $url );
1068
+
1069
+ $affiliate_id = false;
1070
+ $affiliate_key = false;
1071
+
1072
+ // Add extra parameters for custom Installer packages
1073
+ if ( ! empty( $this->package_source ) ) {
1074
+ $extra = $this->get_extra_url_parameters();
1075
+
1076
+ if ( ! empty( $extra['repository'] ) && $extra['repository'] == $repository_id ) {
1077
+
1078
+ if ( ! empty( $extra['affiliate_key'] ) && ! empty( $extra['user_id'] ) ) {
1079
+ $this->config[ 'affiliate_id:' . $repository_id ] = $extra['user_id'];
1080
+ $this->config[ 'affiliate_key:' . $repository_id ] = $extra['affiliate_key'];
1081
+ unset( $extra['affiliate_key'], $extra['user_id'], $extra['repository'] ); // no need to include these ones
1082
+ }
1083
+
1084
+ $url = add_query_arg( $extra, $url );
1085
+ }
1086
+
1087
+ }
1088
+
1089
+ if ( isset( $this->config[ 'affiliate_id:' . $repository_id ] ) && isset( $this->config[ 'affiliate_key:' . $repository_id ] ) ) {
1090
+
1091
+ $affiliate_id = $this->config[ 'affiliate_id:' . $repository_id ];
1092
+ $affiliate_key = $this->config[ 'affiliate_key:' . $repository_id ];
1093
+
1094
+ } elseif ( isset( $args[ 'affiliate_id:' . $repository_id ] ) && isset( $args[ 'affiliate_key:' . $repository_id ] ) ) {
1095
+
1096
+ $affiliate_id = $args[ 'affiliate_id:' . $repository_id ];
1097
+ $affiliate_key = $args[ 'affiliate_key:' . $repository_id ];
1098
+
1099
+ } elseif ( defined( 'ICL_AFFILIATE_ID' ) && defined( 'ICL_AFFILIATE_KEY' ) ) { //support for 1 repo
1100
+
1101
+ $affiliate_id = ICL_AFFILIATE_ID;
1102
+ $affiliate_key = ICL_AFFILIATE_KEY;
1103
+
1104
+ } elseif ( isset( $this->config['affiliate_id'] ) && isset( $this->config['affiliate_key'] ) ) {
1105
+ // BACKWARDS COMPATIBILITY
1106
+ $affiliate_id = $this->config['affiliate_id'];
1107
+ $affiliate_key = $this->config['affiliate_key'];
1108
+ }
1109
+
1110
+ if ( $affiliate_id && $affiliate_key ) {
1111
+ $url = add_query_arg( array( 'aid' => $affiliate_id, 'affiliate_key' => $affiliate_key ), $url );
1112
+ }
1113
+
1114
+ if ( $repository_id == 'wpml' ) {
1115
+ $url = add_query_arg( array(
1116
+ 'using_icl' => $this->_using_icl,
1117
+ 'wpml_version' => $this->_wpml_version
1118
+ ), $url );
1119
+ }
1120
+
1121
+ $url = apply_filters( 'wp_installer_buy_url', $url );
1122
+
1123
+ $url = esc_url( $url );
1124
+
1125
+ return $url;
1126
+
1127
+ }
1128
+
1129
+ public function save_site_key( $args = array() ) {
1130
+
1131
+ $error = '';
1132
+
1133
+ if ( isset( $args['repository_id'] ) ) {
1134
+ $repository_id = $args['repository_id'];
1135
+ } elseif ( isset( $_POST['repository_id'] ) ) {
1136
+ $repository_id = sanitize_text_field( $_POST['repository_id'] );
1137
+ } else {
1138
+ $repository_id = false;
1139
+ }
1140
+
1141
+ if ( isset( $args['nonce'] ) ) {
1142
+ $nonce = $args['nonce'];
1143
+ } elseif ( isset( $_POST['nonce'] ) ) {
1144
+ $nonce = sanitize_text_field( $_POST['nonce'] );
1145
+ } else {
1146
+ $nonce = '';
1147
+ }
1148
+
1149
+ if ( isset( $args['site_key'] ) ) {
1150
+ $site_key = $args['site_key'];
1151
+ } else {
1152
+ $site_key = sanitize_text_field( $_POST[ 'site_key_' . $repository_id ] );
1153
+ }
1154
+ $site_key = preg_replace( "/[^A-Za-z0-9]/", '', $site_key );
1155
+
1156
+ if ( $repository_id && $nonce && wp_create_nonce( 'save_site_key_' . $repository_id ) == $nonce ) {
1157
+
1158
+ try {
1159
+ $subscription_data = $this->fetch_subscription_data( $repository_id, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REGISTRATION );
1160
+
1161
+ if ( $subscription_data ) {
1162
+ $this->settings['repositories'][ $repository_id ]['subscription'] = array(
1163
+ 'key' => $site_key,
1164
+ 'data' => $subscription_data,
1165
+ 'registered_by' => get_current_user_id()
1166
+ );
1167
+ $this->save_settings();
1168
+ } else {
1169
+ $error = __( 'Invalid site key for the current site.', 'installer' )
1170
+ . '<br /><div class="installer-footnote">' . __( 'Please note that the site key is case sensitive.', 'installer' ) . '</div>';
1171
+ }
1172
+
1173
+ } catch ( Exception $e ) {
1174
+ $error = $e->getMessage();
1175
+ if ( preg_match( '#Could not resolve host: (.*)#', $error, $matches ) || preg_match( '#Couldn\'t resolve host \'(.*)\'#', $error, $matches ) ) {
1176
+ $error = sprintf( __( "%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates.", 'installer' ),
1177
+ '<strong><i>' . $this->get_generic_product_name( $repository_id ) . '</i></strong>',
1178
+ '<strong><i>' . $matches[1] . '</i></strong>'
1179
+ );
1180
+ }
1181
+ }
1182
+
1183
+ }
1184
+
1185
+ $return = array( 'error' => $error );
1186
+
1187
+ if ( $this->api_debug ) {
1188
+ $return['debug'] = $this->api_debug;
1189
+ }
1190
+
1191
+ if ( ! empty( $args['return'] ) ) {
1192
+ return $return;
1193
+ } else {
1194
+ echo json_encode( $return );
1195
+ exit;
1196
+ }
1197
+
1198
+ }
1199
+
1200
+ /**
1201
+ * Alias for WP_Installer::get_repository_site_key
1202
+ * @see WP_Installer::get_repository_site_key()
1203
+ *
1204
+ * @param string $repository_id
1205
+ *
1206
+ * @return string (site key) or bool
1207
+ */
1208
+ public function get_site_key( $repository_id ) {
1209
+ return WP_Installer::get_repository_site_key( $repository_id );
1210
+ }
1211
+
1212
+ public function remove_site_key( $repository_id ) {
1213
+ if ( isset( $this->settings['repositories'][ $repository_id ] ) ) {
1214
+ unset( $this->settings['repositories'][ $repository_id ]['subscription'] );
1215
+ $this->save_settings();
1216
+ $this->refresh_repositories_data();
1217
+ }
1218
+ }
1219
+
1220
+ public function remove_site_key_ajax() {
1221
+ if ( $_POST['nonce'] == wp_create_nonce( 'remove_site_key_' . $_POST['repository_id'] ) ) {
1222
+ $this->remove_site_key( $_POST['repository_id'] );
1223
+ }
1224
+ exit;
1225
+ }
1226
+
1227
+ public function validate_repository_subscription() {
1228
+ $repository_id = isset( $_GET['validate_repository'] ) ? sanitize_text_field( $_GET['validate_repository'] ) : false;
1229
+ if ( $repository_id ) {
1230
+
1231
+ $site_key = $this->get_site_key( $repository_id );
1232
+ if ( $site_key ) {
1233
+ $subscription_data = $this->fetch_subscription_data( $repository_id, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION );
1234
+ if ( empty( $subscription_data ) ) {
1235
+ unset( $this->settings['repositories'][ $repository_id ]['subscription'] );
1236
+ delete_site_transient( 'update_plugins' );
1237
+ $this->save_settings();
1238
+ }
1239
+ }
1240
+
1241
+ wp_redirect( $this->menu_url() . '#repository-' . $repository_id );
1242
+ exit;
1243
+
1244
+ }
1245
+
1246
+ }
1247
+
1248
+ public function update_site_key() {
1249
+
1250
+ $error = '';
1251
+
1252
+ $repository_id = sanitize_text_field( $_POST['repository_id'] );
1253
+ if ( $_POST['nonce'] == wp_create_nonce( 'update_site_key_' . $repository_id ) ) {
1254
+
1255
+ $site_key = $this->get_site_key( $_POST['repository_id'] );
1256
+
1257
+ if ( $site_key ) {
1258
+ try {
1259
+ $subscription_data = $this->fetch_subscription_data( $repository_id, $site_key, self::SITE_KEY_VALIDATION_SOURCE_UPDATES_CHECK );
1260
+
1261
+ if ( $subscription_data ) {
1262
+ $this->settings['repositories'][ $repository_id ]['subscription'] = array(
1263
+ 'key' => $site_key,
1264
+ 'data' => $subscription_data,
1265
+ 'registered_by' => get_current_user_id()
1266
+ );
1267
+
1268
+ //also refresh products information
1269
+ $this->refresh_repositories_data();
1270
+
1271
+ $this->save_settings();
1272
+
1273
+ } else {
1274
+ unset( $this->settings['repositories'][ $repository_id ]['subscription'] );
1275
+ $error = __( 'Invalid site key for the current site. If the error persists, try to unregister first and then register again with the same site key.', 'installer' );
1276
+ }
1277
+
1278
+
1279
+ } catch ( Exception $e ) {
1280
+ $error = $e->getMessage();
1281
+ if ( preg_match( '#Could not resolve host: (.*)#', $error, $matches ) || preg_match( '#Couldn\'t resolve host \'(.*)\'#', $error, $matches ) ) {
1282
+ $error = sprintf( __( "%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates.", 'installer' ),
1283
+ '<strong><i>' . $this->get_generic_product_name( $repository_id ) . '</i></strong>',
1284
+ '<strong><i>' . $matches[1] . '</i></strong>'
1285
+ );
1286
+ }
1287
+ }
1288
+
1289
+ }
1290
+
1291
+ }
1292
+
1293
+ echo json_encode( array( 'error' => $error ) );
1294
+
1295
+ exit;
1296
+ }
1297
+
1298
+ public function api_debug_log( $text ) {
1299
+
1300
+ if ( defined( 'WPML_DEBUG_INSTALLER' ) && WPML_DEBUG_INSTALLER ) {
1301
+
1302
+ if ( ! is_scalar( $text ) ) {
1303
+ $text = print_r( $text, 1 );
1304
+ }
1305
+
1306
+ $this->api_debug .= $text . "\n";
1307
+
1308
+ }
1309
+
1310
+ }
1311
+
1312
+ public function fetch_subscription_data( $repository_id, $site_key, $source = self::SITE_KEY_VALIDATION_SOURCE_OTHER ) {
1313
+
1314
+ $subscription_data = false;
1315
+
1316
+ $args['body'] = array(
1317
+ 'action' => 'site_key_validation',
1318
+ 'site_key' => $site_key,
1319
+ 'site_url' => $this->get_installer_site_url( $repository_id ),
1320
+ 'source' => $source
1321
+ );
1322
+
1323
+ if ( $repository_id == 'wpml' ) {
1324
+ $args['body']['using_icl'] = $this->_using_icl;
1325
+ $args['body']['wpml_version'] = $this->_wpml_version;
1326
+ }
1327
+
1328
+ $args['body']['installer_version'] = WP_INSTALLER_VERSION;
1329
+ $args['body']['theme'] = wp_get_theme()->get( 'Name' );
1330
+ $args['body']['site_name'] = get_bloginfo( 'name' );
1331
+
1332
+ $args['body']['versions'] = $this->get_local_product_versions( $repository_id );
1333
+
1334
+ $args['timeout'] = 45;
1335
+
1336
+ // Add extra parameters for custom Installer packages
1337
+ if ( ! empty( $this->package_source ) ) {
1338
+ $extra = $this->get_extra_url_parameters();
1339
+ if ( ! empty( $extra['repository'] ) && $extra['repository'] == $repository_id ) {
1340
+ unset( $extra['repository'] );
1341
+ foreach ( $extra as $key => $val ) {
1342
+ $args['body'][ $key ] = $val;
1343
+ }
1344
+ }
1345
+ }
1346
+
1347
+ $response = wp_remote_post( $this->repositories[ $repository_id ]['api-url'], $args );
1348
+
1349
+ $this->api_debug_log( "POST {$this->repositories[$repository_id]['api-url']}" );
1350
+ $this->api_debug_log( $args );
1351
+
1352
+ $this->log( "POST {$this->repositories[$repository_id]['api-url']} - fetch subscription data" );
1353
+
1354
+ if ( ! is_wp_error( $response ) ) {
1355
+ $datas = wp_remote_retrieve_body( $response );
1356
+
1357
+ if ( is_serialized( $datas ) ) {
1358
+ $data = unserialize( $datas );
1359
+ $this->api_debug_log( $data );
1360
+
1361
+ if ( ! empty( $data->subscription_data ) ) {
1362
+ $subscription_data = $data->subscription_data;
1363
+ }
1364
+
1365
+ do_action( 'installer_fetched_subscription_data', $data, $repository_id );
1366
+
1367
+ } else {
1368
+ $this->api_debug_log( $datas );
1369
+ }
1370
+
1371
+ } else {
1372
+
1373
+ $this->api_debug_log( $response );
1374
+ throw new Exception( $response->get_error_message() );
1375
+ }
1376
+
1377
+ return $subscription_data;
1378
+
1379
+ }
1380
+
1381
+ function get_local_product_versions( $repository_id ) {
1382
+
1383
+ $versions = array();
1384
+
1385
+ foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package_id => $package ) {
1386
+
1387
+ foreach ( $package['products'] as $product_id => $product ) {
1388
+
1389
+ foreach ( $product['plugins'] as $plugin_slug ) {
1390
+
1391
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1392
+
1393
+ if ( empty( $versions[ $download['slug'] ] ) ) {
1394
+ $v = $this->get_plugin_installed_version( $download['name'], $download['slug'] );
1395
+ if ( $v ) {
1396
+ $versions[ $download['slug'] ] = $v;
1397
+ }
1398
+ }
1399
+
1400
+ }
1401
+
1402
+ }
1403
+
1404
+ }
1405
+
1406
+ return $versions;
1407
+ }
1408
+
1409
+ public function get_repository_site_key( $repository_id ) {
1410
+ $site_key = false;
1411
+
1412
+ if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription']['key'] ) ) {
1413
+ $site_key = $this->settings['repositories'][ $repository_id ]['subscription']['key'];
1414
+ }
1415
+
1416
+ return $site_key;
1417
+ }
1418
+
1419
+ public function repository_has_valid_subscription( $repository_id ) {
1420
+
1421
+ $valid = false;
1422
+
1423
+ if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription'] ) ) {
1424
+
1425
+ $subscription = $this->settings['repositories'][ $repository_id ]['subscription']['data'];
1426
+ $valid = ( $subscription->status == 1 && ( strtotime( $subscription->expires ) > time() || empty( $subscription->expires ) ) ) || $subscription->status == 4;
1427
+
1428
+ }
1429
+
1430
+ return $valid;
1431
+
1432
+ }
1433
+
1434
+ public function repository_has_subscription( $repository_id ) {
1435
+ $key = false;
1436
+ if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription']['key'] ) ) {
1437
+ $key = $this->settings['repositories'][ $repository_id ]['subscription']['key'];
1438
+ }
1439
+
1440
+ return $key;
1441
+
1442
+ }
1443
+
1444
+ public function repository_has_expired_subscription( $repository_id ) {
1445
+
1446
+ return $this->repository_has_subscription( $repository_id ) && ! $this->repository_has_valid_subscription( $repository_id );
1447
+
1448
+ }
1449
+
1450
+ public function get_generic_product_name( $repository_id ) {
1451
+
1452
+ return $this->settings['repositories'][ $repository_id ]['data']['product-name'];
1453
+
1454
+ }
1455
+
1456
+ public function show_subscription_renew_warning( $repository_id, $subscription_id ) {
1457
+
1458
+ $show = false;
1459
+
1460
+ $data = $this->settings['repositories'][ $repository_id ]['data'];
1461
+ if ( ! empty( $data['subscriptions_meta'] ) ) {
1462
+ if ( isset( $data['subscriptions_meta']['expiration'] ) ) {
1463
+
1464
+ if ( ! empty( $data['subscriptions_meta']['expiration'][ $subscription_id ] ) ) {
1465
+
1466
+ $days = $data['subscriptions_meta']['expiration'][ $subscription_id ]['days_warning'];
1467
+ $message = $data['subscriptions_meta']['expiration'][ $subscription_id ]['warning_message'];
1468
+
1469
+ } else {
1470
+
1471
+ //defaults
1472
+ $days = 30;
1473
+ $message = __( 'You will have to renew your subscription in order to continue getting the updates and support.', 'installer' );
1474
+
1475
+ }
1476
+
1477
+ if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription'] ) ) {
1478
+ $subscription = $this->settings['repositories'][ $repository_id ]['subscription'];
1479
+
1480
+ if ( $subscription['data']->subscription_type == $subscription_id && ! empty( $subscription['data']->expires ) ) {
1481
+
1482
+ if ( strtotime( $subscription['data']->expires ) < strtotime( sprintf( "+%d day", $days ) ) ) {
1483
+
1484
+ $days_to_expiration = ceil( ( strtotime( $subscription['data']->expires ) - time() ) / 86400 );
1485
+
1486
+ echo '<div><p class="installer-warn-box">' .
1487
+ sprintf( _n( 'Your subscription expires in %d day.', 'Your subscription expires in %d days.', $days_to_expiration, 'installer' ), $days_to_expiration ) .
1488
+ '<br />' . $message .
1489
+ '</p></div>';
1490
+
1491
+ $show = true;
1492
+
1493
+ }
1494
+
1495
+ }
1496
+
1497
+ }
1498
+
1499
+
1500
+ }
1501
+ }
1502
+
1503
+
1504
+ return $show;
1505
+
1506
+ }
1507
+
1508
+ public function setup_plugins_renew_warnings() {
1509
+
1510
+ $plugins = get_plugins();
1511
+
1512
+ $subscriptions_with_warnings = array();
1513
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
1514
+
1515
+ if ( $this->repository_has_valid_subscription( $repository_id ) ) {
1516
+ $subscription_type = $this->settings['repositories'][ $repository_id ]['subscription']['data']->subscription_type;
1517
+ $expires = $this->settings['repositories'][ $repository_id ]['subscription']['data']->expires;
1518
+
1519
+ $never_expires = isset( $this->settings['repositories'][ $repository_id ]['subscription'] )
1520
+ && empty( $this->settings['repositories'][ $repository_id ]['subscription']['data']->expires )
1521
+ && (
1522
+ $this->settings['repositories'][ $repository_id ]['subscription']['data']->status == 4 ||
1523
+ $this->settings['repositories'][ $repository_id ]['subscription']['data']->status == 1
1524
+ );
1525
+
1526
+ if ( ! $never_expires ) {
1527
+ if ( isset( $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_type ] ) ) {
1528
+
1529
+ $days_warning = $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_type ]['days_warning'];
1530
+ $custom_message = $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_type ]['warning_message'];
1531
+
1532
+ } else {
1533
+ //defaults
1534
+ $days_warning = 30;
1535
+ $custom_message = __( 'You will have to renew your subscription in order to continue getting the updates and support.', 'installer' );
1536
+ }
1537
+
1538
+ if ( strtotime( $expires ) < strtotime( sprintf( '+%d day', $days_warning ) ) ) {
1539
+
1540
+ $days_to_expiration = ceil( ( strtotime( $expires ) - time() ) / 86400 );
1541
+
1542
+ $message = sprintf( _n( 'Your subscription expires in %d day.', 'Your subscription expires in %d days.', $days_to_expiration, 'installer' ), $days_to_expiration );
1543
+ $subscriptions_with_warnings[ $subscription_type ] = $message . ' ' . $custom_message;
1544
+
1545
+ }
1546
+ }
1547
+
1548
+ }
1549
+
1550
+ }
1551
+
1552
+
1553
+ foreach ( $plugins as $plugin_id => $plugin ) {
1554
+
1555
+ $slug = dirname( $plugin_id );
1556
+ if ( empty( $slug ) ) {
1557
+ continue;
1558
+ }
1559
+
1560
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
1561
+
1562
+ if ( $this->repository_has_valid_subscription( $repository_id ) ) {
1563
+
1564
+ foreach ( $repository['data']['packages'] as $package ) {
1565
+
1566
+ foreach ( $package['products'] as $product ) {
1567
+
1568
+ foreach ( $product['plugins'] as $plugin_slug ) {
1569
+
1570
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1571
+
1572
+ if ( $download['slug'] == $slug || $download['name'] == $plugin['Name'] || $download['name'] == $plugin['Title'] ) { //match order: slug, name, title
1573
+
1574
+ if ( isset( $subscriptions_with_warnings[ $product['subscription_type'] ] ) ) {
1575
+
1576
+ $this->_plugins_renew_warnings[ $plugin_id ] = $subscriptions_with_warnings[ $product['subscription_type'] ];
1577
+
1578
+ }
1579
+
1580
+ }
1581
+
1582
+ }
1583
+
1584
+ }
1585
+
1586
+ }
1587
+
1588
+ }
1589
+
1590
+ }
1591
+
1592
+ }
1593
+
1594
+ }
1595
+
1596
+ public function queue_plugins_renew_warnings() {
1597
+
1598
+ if ( ! empty( $this->_plugins_renew_warnings ) ) {
1599
+
1600
+ foreach ( $this->_plugins_renew_warnings as $plugin_id => $message ) {
1601
+
1602
+ add_action( "after_plugin_row_" . $plugin_id, array( $this, 'plugins_renew_warning' ), 10, 3 );
1603
+ }
1604
+
1605
+ }
1606
+
1607
+ }
1608
+
1609
+ public function plugins_renew_warning( $plugin_file, $plugin_data, $status ) {
1610
+
1611
+ if ( empty( $this->_plugins_renew_warnings[ $plugin_file ] ) ) {
1612
+ return;
1613
+ }
1614
+
1615
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1616
+ ?>
1617
+
1618
+ <tr class="plugin-update-tr">
1619
+ <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-update colspanchange">
1620
+ <div class="update-message">
1621
+ <?php
1622
+ echo $this->_plugins_renew_warnings[ $plugin_file ] . ' ';
1623
+ printf( __( '%sRenew here%s.', 'installer' ),
1624
+ '<a href="' . $this->menu_url() . '">', '</a>' );
1625
+ ?>
1626
+ </div>
1627
+ </tr>
1628
+
1629
+ <?php
1630
+
1631
+ }
1632
+
1633
+ public function get_subscription_type_for_repository( $repository_id ) {
1634
+
1635
+ $subscription_type = false;
1636
+
1637
+ if ( ! empty( $this->settings['repositories'][ $repository_id ]['subscription'] ) ) {
1638
+ $subscription_type = $this->settings['repositories'][ $repository_id ]['subscription']['data']->subscription_type;
1639
+ }
1640
+
1641
+ return $subscription_type;
1642
+
1643
+ }
1644
+
1645
+ public function have_superior_subscription( $subscription_type, $product ) {
1646
+
1647
+ $have = false;
1648
+
1649
+ if ( is_array( $product['upgrades'] ) ) {
1650
+ foreach ( $product['upgrades'] as $u ) {
1651
+ if ( $u['subscription_type'] == $subscription_type ) {
1652
+ $have = true;
1653
+ break;
1654
+ }
1655
+ }
1656
+ }
1657
+
1658
+ return $have;
1659
+ }
1660
+
1661
+ public function is_product_available_for_download( $product_name, $repository_id ) {
1662
+
1663
+ $available = false;
1664
+
1665
+ $subscription_type = $this->get_subscription_type_for_repository( $repository_id );
1666
+ $expired = $this->repository_has_expired_subscription( $repository_id );
1667
+
1668
+ if ( $this->repository_has_subscription( $repository_id ) && ! $expired ) {
1669
+
1670
+ $this->set_hierarchy_and_order();
1671
+
1672
+ foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package_id => $package ) {
1673
+
1674
+ $has_top_package = false;
1675
+
1676
+ foreach ( $package['products'] as $product ) {
1677
+
1678
+ if ( $subscription_type == $product['subscription_type'] ) {
1679
+ $has_top_package = true;
1680
+ if ( $product['name'] == $product_name ) {
1681
+ return $available = true;
1682
+ }
1683
+ }
1684
+
1685
+ }
1686
+
1687
+ if ( ! empty( $package['sub-packages'] ) ) {
1688
+ foreach ( $package['sub-packages'] as $sub_package ) {
1689
+ foreach ( $sub_package['products'] as $product ) {
1690
+ if ( $product['name'] == $product_name && ( $subscription_type == $product['subscription_type'] || $has_top_package ) ) {
1691
+ return $available = true;
1692
+ }
1693
+ }
1694
+ }
1695
+ }
1696
+
1697
+ }
1698
+ }
1699
+
1700
+ return $available;
1701
+
1702
+ }
1703
+
1704
+ public function get_upgrade_options( $repository_id ) {
1705
+ $all_upgrades = array();
1706
+
1707
+
1708
+ //get all products: packages and subpackages
1709
+ $all_products = array();
1710
+ foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
1711
+ foreach ( $package['products'] as $product ) {
1712
+ $all_products[] = $product;
1713
+ }
1714
+ if ( ! empty( $package['sub-packages'] ) ) {
1715
+ foreach ( $package['sub-packages'] as $subpackage ) {
1716
+ foreach ( $subpackage['products'] as $product ) {
1717
+ $all_products[] = $product;
1718
+ }
1719
+
1720
+ }
1721
+
1722
+ }
1723
+
1724
+ }
1725
+
1726
+ foreach ( $all_products as $product ) {
1727
+ if ( $product['upgrades'] ) {
1728
+ foreach ( $product['upgrades'] as $upgrade ) {
1729
+ if ( $this->repository_has_valid_subscription( $repository_id ) || ( $this->repository_has_subscription( $repository_id ) && $upgrade['including_expired'] ) ) {
1730
+ $all_upgrades[ $upgrade['subscription_type'] ][ $product['subscription_type'] ] = $upgrade;
1731
+ }
1732
+ }
1733
+ }
1734
+ }
1735
+
1736
+ return $all_upgrades;
1737
+
1738
+ }
1739
+
1740
+ public function append_site_key_to_download_url( $url, $key, $repository_id ) {
1741
+
1742
+ $url_params['site_key'] = $key;
1743
+ $url_params['site_url'] = $this->get_installer_site_url( $repository_id );
1744
+
1745
+
1746
+ // Add extra parameters for custom Installer packages
1747
+ if ( ! empty( $this->package_source ) ) {
1748
+ $extra = $this->get_extra_url_parameters();
1749
+ if ( ! empty( $extra['repository'] ) && $extra['repository'] == $repository_id ) {
1750
+ unset( $extra['repository'] );
1751
+ foreach ( $extra as $key => $val ) {
1752
+ $url_params[ $key ] = $val;
1753
+ }
1754
+ }
1755
+ }
1756
+
1757
+ $url = add_query_arg( $url_params, $url );
1758
+
1759
+ if ( $repository_id == 'wpml' ) {
1760
+ $url = add_query_arg( array(
1761
+ 'using_icl' => $this->_using_icl,
1762
+ 'wpml_version' => $this->_wpml_version
1763
+ ), $url );
1764
+ }
1765
+
1766
+ return $url;
1767
+
1768
+ }
1769
+
1770
+ public function plugin_is_installed( $name, $slug, $version = null ) {
1771
+
1772
+ $is = false;
1773
+
1774
+ $plugins = get_plugins();
1775
+
1776
+ foreach ( $plugins as $plugin_id => $plugin ) {
1777
+
1778
+ $wp_plugin_slug = dirname( $plugin_id );
1779
+
1780
+ // Exception: embedded plugins
1781
+ if ( $wp_plugin_slug == $slug || $plugin['Name'] == $name || $plugin['Title'] == $name || ( $wp_plugin_slug == $slug . '-embedded' || $plugin['Name'] == $name . ' Embedded' ) ) {
1782
+ if ( $version ) {
1783
+ if ( version_compare( $plugin['Version'], $version, '>=' ) ) {
1784
+ $is = $plugin['Version'];
1785
+ }
1786
+ } else {
1787
+ $is = $plugin['Version'];
1788
+ }
1789
+
1790
+ break;
1791
+ }
1792
+
1793
+ }
1794
+
1795
+ //exception: Types name difference
1796
+ if ( ! $is && $name == 'Types' ) {
1797
+ return $this->plugin_is_installed( 'Types - Complete Solution for Custom Fields and Types', $slug, $version );
1798
+ }
1799
+
1800
+ return $is;
1801
+ }
1802
+
1803
+ public function plugin_is_embedded_version( $name, $slug ) {
1804
+ $is = false;
1805
+
1806
+ $plugins = get_plugins();
1807
+
1808
+ //false if teh full version is also installed
1809
+ $is_full_installed = false;
1810
+ foreach ( $plugins as $plugin_id => $plugin ) {
1811
+
1812
+ if ( ( $plugin['Name'] == $name && ! preg_match( "#-embedded$#", $slug ) ) ) {
1813
+ $is_full_installed = true;
1814
+ break;
1815
+ }
1816
+
1817
+ }
1818
+
1819
+ if ( $is_full_installed ) {
1820
+ return false;
1821
+ }
1822
+
1823
+ foreach ( $plugins as $plugin_id => $plugin ) {
1824
+
1825
+ // TBD
1826
+ $wp_plugin_slug = dirname( $plugin_id );
1827
+ if ( $wp_plugin_slug == $slug . '-embedded' && $plugin['Name'] == $name . ' Embedded' ) {
1828
+ $is = true;
1829
+ break;
1830
+ }
1831
+
1832
+ }
1833
+
1834
+ return $is;
1835
+
1836
+ }
1837
+
1838
+ //Alias for plugin_is_installed
1839
+ public function get_plugin_installed_version( $name, $slug ) {
1840
+
1841
+ return $this->plugin_is_installed( $name, $slug );
1842
+
1843
+ }
1844
+
1845
+ public function get_plugin_repository_version( $repository_id, $slug ) {
1846
+ $version = false;
1847
+
1848
+ if ( ! empty( $this->settings['repositories'][ $repository_id ]['data']['packages'] ) ) {
1849
+ foreach ( $this->settings['repositories'][ $repository_id ]['data']['packages'] as $package ) {
1850
+ foreach ( $package['products'] as $product ) {
1851
+
1852
+ foreach ( $product['plugins'] as $plugin_slug ) {
1853
+
1854
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
1855
+
1856
+ if ( $download['slug'] == $slug ) {
1857
+ $version = $download['version'];
1858
+ break ( 3 );
1859
+ }
1860
+
1861
+ }
1862
+
1863
+ }
1864
+ }
1865
+ }
1866
+
1867
+ return $version;
1868
+ }
1869
+
1870
+ public function is_uploading_allowed() {
1871
+
1872
+ //_deprecated_function ( __FUNCTION__, '1.7.3', 'Installer_Dependencies::' . __FUNCTION__ );
1873
+ return $this->dependencies->is_uploading_allowed();
1874
+
1875
+ }
1876
+
1877
+ public function download_plugin_ajax_handler() {
1878
+
1879
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1880
+ require_once $this->plugin_path() . '/includes/class-installer-upgrader-skins.php';
1881
+
1882
+ $data = json_decode( base64_decode( sanitize_text_field( $_POST['data'] ) ), true );
1883
+
1884
+ $ret = false;
1885
+ $plugin_id = false;
1886
+ $message = '';
1887
+
1888
+ //validate subscription
1889
+ $site_key = $this->get_repository_site_key( $data['repository_id'] );
1890
+ $subscription_data = $this->fetch_subscription_data( $data['repository_id'], $site_key, self::SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_REPORT );
1891
+
1892
+ if ( $subscription_data && ! is_wp_error( $subscription_data ) && $this->repository_has_valid_subscription( $data['repository_id'] ) ) {
1893
+
1894
+ if ( $data['nonce'] == wp_create_nonce( 'install_plugin_' . $data['url'] ) ) {
1895
+
1896
+ $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1897
+ $upgrader = new Plugin_Upgrader( $upgrader_skins );
1898
+
1899
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
1900
+
1901
+ $plugins = get_plugins();
1902
+
1903
+ //upgrade or install?
1904
+ foreach ( $plugins as $id => $plugin ) {
1905
+ $wp_plugin_slug = dirname( $id );
1906
+ $is_embedded = $this->plugin_is_embedded_version( preg_replace( '/ Embedded$/', '', $plugin['Name'] ), preg_replace( '/-embedded$/', '', $wp_plugin_slug ) );
1907
+
1908
+ if ( $wp_plugin_slug == $data['slug'] || $is_embedded && preg_replace( '/-embedded$/', '', $wp_plugin_slug ) == $data['slug'] ) {
1909
+ $plugin_id = $id;
1910
+ break;
1911
+ }
1912
+ }
1913
+
1914
+ if ( $plugin_id && empty( $is_embedded ) ) { //upgrade
1915
+ $response['upgrade'] = 1;
1916
+
1917
+ $plugin_is_active = is_plugin_active( $plugin_id );
1918
+
1919
+ $ret = $upgrader->upgrade( $plugin_id );
1920
+
1921
+ if ( ! $ret && ! empty( $upgrader->skin->installer_error ) ) {
1922
+ if ( is_wp_error( $upgrader->skin->installer_error ) ) {
1923
+ $message = $upgrader->skin->installer_error->get_error_message() .
1924
+ ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
1925
+ }
1926
+ $plugin_version = 0;
1927
+ }else{
1928
+ if ( $plugin_is_active ) {
1929
+ //prevent redirects
1930
+ add_filter( 'wp_redirect', '__return_false' );
1931
+ activate_plugin( $plugin_id );
1932
+ }
1933
+ $plugin_version = $this->get_plugin_repository_version( $data['repository_id'], $data['slug'] );
1934
+ }
1935
+
1936
+ } else { //install
1937
+
1938
+ if ( $is_embedded ) {
1939
+ delete_plugins( array( $plugin_id ) );
1940
+ }
1941
+
1942
+ $response['install'] = 1;
1943
+ $ret = $upgrader->install( $data['url'] );
1944
+ if ( ! $ret && ! empty( $upgrader->skin->installer_error ) ) {
1945
+ if ( is_wp_error( $upgrader->skin->installer_error ) ) {
1946
+ $message = $upgrader->skin->installer_error->get_error_message() .
1947
+ ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
1948
+ }
1949
+ }
1950
+ }
1951
+
1952
+ $plugins = get_plugins(); //read again
1953
+
1954
+ if ( $ret ) {
1955
+ foreach ( $plugins as $id => $plugin ) {
1956
+ $wp_plugin_slug = dirname( $id );
1957
+ if ( $wp_plugin_slug == $data['slug'] ) {
1958
+ $plugin_version = $plugin['Version'];
1959
+ $plugin_id = $id;
1960
+ break;
1961
+ }
1962
+ }
1963
+
1964
+ }
1965
+
1966
+ if( WP_Installer_Channels()->get_channel( $data['repository_id'] ) !== WP_Installer_Channels::CHANNEL_PRODUCTION ){
1967
+ $download = $this->settings['repositories'][$data['repository_id']]['data']['downloads']['plugins'][$data['slug']];
1968
+ $non_stable = WP_Installer_Channels()->get_download_source_channel( $plugin_version, $data['repository_id'], $download['slug'], 'plugins' );
1969
+ }
1970
+
1971
+ }
1972
+
1973
+ } else { //subscription not valid
1974
+
1975
+ $ret = false;
1976
+ $message = __( 'Your subscription appears to no longer be valid. Please try to register again using a valid site key.', 'installer' );
1977
+ }
1978
+
1979
+ $response['version'] = isset( $plugin_version ) ? $plugin_version : 0;
1980
+ $response['non_stable']= isset( $non_stable ) ? $non_stable : '';
1981
+ $response['plugin_id'] = $plugin_id;
1982
+ $response['nonce'] = wp_create_nonce( 'activate_' . $plugin_id );
1983
+ $response['success'] = $ret;
1984
+ $response['message'] = $message;
1985
+
1986
+ echo json_encode( $response );
1987
+ exit;
1988
+
1989
+ }
1990
+
1991
+ public function download_plugin( $slug, $url ) {
1992
+
1993
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1994
+ require_once $this->plugin_path() . '/includes/class-installer-upgrader-skins.php';
1995
+
1996
+ $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1997
+ $upgrader = new Plugin_Upgrader( $upgrader_skins );
1998
+
1999
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
2000
+
2001
+ $plugins = get_plugins();
2002
+
2003
+ $plugin_id = false;
2004
+
2005
+ //upgrade or install?
2006
+ foreach ( $plugins as $id => $plugin ) {
2007
+ $wp_plugin_slug = dirname( $id );
2008
+ if ( $wp_plugin_slug == $slug ) {
2009
+ $plugin_id = $id;
2010
+ break;
2011
+ }
2012
+ }
2013
+
2014
+ if ( $plugin_id ) { //upgrade
2015
+
2016
+ $plugin_is_active = is_plugin_active( $plugin_id );
2017
+
2018
+ $ret = $upgrader->upgrade( $plugin_id );
2019
+
2020
+ if ( $plugin_is_active ) {
2021
+ activate_plugin( $plugin_id );
2022
+ }
2023
+
2024
+ } else { //install
2025
+ $ret = $upgrader->install( $url );
2026
+ }
2027
+
2028
+ return $ret;
2029
+
2030
+ }
2031
+
2032
+ public function activate_plugin() {
2033
+
2034
+ $error = '';
2035
+
2036
+ $plugin_id = sanitize_text_field( $_POST['plugin_id'] );
2037
+ if ( isset( $_POST['nonce'] ) && $plugin_id && $_POST['nonce'] == wp_create_nonce( 'activate_' . $plugin_id ) ) {
2038
+
2039
+ // Deactivate any embedded version
2040
+ $plugin_slug = dirname( $plugin_id );
2041
+ $active_plugins = get_option( 'active_plugins' );
2042
+ foreach ( $active_plugins as $plugin ) {
2043
+ $wp_plugin_slug = dirname( $plugin );
2044
+ if ( $wp_plugin_slug == $plugin_slug . '-embedded' ) {
2045
+ deactivate_plugins( array( $plugin ) );
2046
+ break;
2047
+ }
2048
+ }
2049
+
2050
+ //prevent redirects
2051
+ add_filter( 'wp_redirect', '__return_false', 10000 );
2052
+
2053
+ $return = activate_plugin( $plugin_id );
2054
+
2055
+ if ( is_wp_error( $return ) ) {
2056
+ $error = $return->get_error_message();
2057
+ }
2058
+
2059
+ } else {
2060
+ $error = 'error';
2061
+ }
2062
+
2063
+ $ret = array( 'error' => $error );
2064
+
2065
+ echo json_encode( $ret );
2066
+ exit;
2067
+
2068
+ }
2069
+
2070
+ public function custom_plugins_api_call( $false, $action, $args ) {
2071
+
2072
+ if ( $action == 'plugin_information' ) {
2073
+
2074
+ $plugins = get_plugins();
2075
+ $plugin_names = array();
2076
+ foreach ( $plugins as $plugin_id => $plugin ) {
2077
+ // plugins by WP slug which (plugin folder) which can be different
2078
+ // will use this to compare by title
2079
+ $plugin_names[ dirname( $plugin_id ) ] = array(
2080
+ 'name' => $plugin['Name'],
2081
+ 'title' => $plugin['Title'],
2082
+ );
2083
+ }
2084
+
2085
+ $slug = $args->slug;
2086
+
2087
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2088
+
2089
+ if ( ! $this->repository_has_valid_subscription( $repository_id ) ) {
2090
+ $site_key = false;
2091
+ } else {
2092
+ $site_key = $repository['subscription']['key'];
2093
+ }
2094
+
2095
+ foreach ( $repository['data']['packages'] as $package ) {
2096
+
2097
+ foreach ( $package['products'] as $product ) {
2098
+
2099
+ foreach ( $product['plugins'] as $plugin_slug ) {
2100
+
2101
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2102
+
2103
+ if ( $download['slug'] == $slug ||
2104
+ isset( $plugin_names[ $slug ] ) && (
2105
+ $plugin_names[ $slug ]['name'] == $download['name'] ||
2106
+ $plugin_names[ $slug ]['title'] == $download['name']
2107
+ )
2108
+ ) {
2109
+
2110
+ if ( ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION ) {
2111
+ return false; // use data from wordpress.org
2112
+ }
2113
+
2114
+ $res = new stdClass();
2115
+ $res->external = true;
2116
+
2117
+ $res->name = $download['name'];
2118
+ $res->slug = $slug;
2119
+ $res->version = $download['version'];
2120
+ $res->author = '';
2121
+ $res->author_profile = '';
2122
+ $res->last_updated = $download['date'];
2123
+
2124
+ if ( $site_key ) {
2125
+ $res->download_link = $this->append_site_key_to_download_url( $download['url'], $site_key, $repository_id );
2126
+ }
2127
+
2128
+ $res->homepage = $repository['data']['url'];
2129
+ $res->sections = array(
2130
+ 'Description' => $download['description'],
2131
+ 'Changelog' => $download['changelog']
2132
+ );
2133
+
2134
+ return $res;
2135
+
2136
+ }
2137
+
2138
+ }
2139
+
2140
+ }
2141
+
2142
+ }
2143
+
2144
+ }
2145
+
2146
+ }
2147
+
2148
+ return $false;
2149
+
2150
+ }
2151
+
2152
+ public function plugins_upgrade_check( $update_plugins ) {
2153
+
2154
+ if ( ! empty( $this->settings['repositories'] ) ) {
2155
+
2156
+ $plugins = get_plugins();
2157
+
2158
+ foreach ( $plugins as $plugin_id => $plugin ) {
2159
+
2160
+ $slug = dirname( $plugin_id );
2161
+ if ( empty( $slug ) ) {
2162
+ continue;
2163
+ }
2164
+
2165
+ $version = $plugin['Version'];
2166
+ $name = $plugin['Name'];
2167
+
2168
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2169
+
2170
+
2171
+ if ( ! $this->repository_has_valid_subscription( $repository_id ) ) {
2172
+ $site_key = false;
2173
+ } else {
2174
+ $site_key = $repository['subscription']['key'];
2175
+ //$subscription_type = $this->get_subscription_type_for_repository($repository_id);
2176
+ }
2177
+
2178
+ foreach ( $repository['data']['packages'] as $package ) {
2179
+
2180
+ foreach ( $package['products'] as $product ) {
2181
+
2182
+ foreach ( $product['plugins'] as $plugin_slug ) {
2183
+
2184
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2185
+
2186
+ if ( ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION ) {
2187
+ continue;
2188
+ }
2189
+
2190
+ $needs_version_update = version_compare( $download['version'], $version, '>' ) ||
2191
+ ! empty( $_POST['reset_to_channel'] );
2192
+
2193
+ if (
2194
+ empty( $update_plugins->response[ $plugin_id ] ) &&
2195
+ ( $download['slug'] == $slug || $download['name'] == $name ) &&
2196
+ $needs_version_update
2197
+ ) {
2198
+
2199
+ $response = new stdClass();
2200
+ $response->id = 0;
2201
+ $response->slug = $slug;
2202
+ $response->plugin = $plugin_id;
2203
+ $response->new_version = $download['version'];
2204
+ $response->upgrade_notice = '';
2205
+ $response->url = $download['url'];
2206
+ if ( $site_key ) {
2207
+ $response->package = $this->append_site_key_to_download_url( $download['url'], $site_key, $repository_id );
2208
+ }
2209
+ $update_plugins->checked[ $plugin_id ] = $version;
2210
+ $update_plugins->response[ $plugin_id ] = $response;
2211
+
2212
+ }
2213
+
2214
+ }
2215
+
2216
+ }
2217
+
2218
+ }
2219
+
2220
+ }
2221
+
2222
+ }
2223
+
2224
+ }
2225
+
2226
+ return $update_plugins;
2227
+
2228
+ }
2229
+
2230
+ public function setup_plugins_page_notices() {
2231
+
2232
+ $plugins = get_plugins();
2233
+
2234
+ foreach ( $plugins as $plugin_id => $plugin ) {
2235
+
2236
+ $slug = dirname( $plugin_id );
2237
+ if ( empty( $slug ) ) {
2238
+ continue;
2239
+ }
2240
+
2241
+ $name = $plugin['Name'];
2242
+
2243
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2244
+
2245
+ if ( ! $this->repository_has_valid_subscription( $repository_id ) ) {
2246
+ $site_key = false;
2247
+ } else {
2248
+ $site_key = $repository['subscription']['key'];
2249
+ }
2250
+
2251
+ foreach ( $repository['data']['packages'] as $package ) {
2252
+
2253
+ foreach ( $package['products'] as $product ) {
2254
+
2255
+ foreach ( $product['plugins'] as $plugin_slug ) {
2256
+
2257
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2258
+ if ( ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION ) {
2259
+ continue;
2260
+ }
2261
+
2262
+ if ( $download['slug'] == $slug || $download['name'] == $name ) {
2263
+
2264
+ if ( ! $site_key || ! $this->plugin_is_registered( $repository_id, $download['slug'] ) ) {
2265
+ add_action( "after_plugin_row_" . $plugin_id, array(
2266
+ $this,
2267
+ 'show_purchase_notice_under_plugin'
2268
+ ), 10, 3 );
2269
+ }
2270
+
2271
+ }
2272
+
2273
+ }
2274
+
2275
+ }
2276
+
2277
+ }
2278
+
2279
+ }
2280
+
2281
+ }
2282
+
2283
+ }
2284
+
2285
+ public function show_purchase_notice_under_plugin( $plugin_file, $plugin_data, $status ) {
2286
+
2287
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
2288
+ $wp_version = preg_replace( '/-(.+)$/', '', $GLOBALS['wp_version'] );
2289
+
2290
+ if ( version_compare( $wp_version, '4.6', '>=' ) ) {
2291
+
2292
+ ?>
2293
+ <tr class="plugin-update-tr installer-plugin-update-tr">
2294
+ <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-update colspanchange">
2295
+ <div class="notice inline notice-warning notice-alt">
2296
+ <p class="installer-q-icon">
2297
+ <?php printf( __( 'You must have a valid subscription in order to get upgrades or support for this plugin. %sPurchase a subscription or enter an existing site key%s.', 'installer' ),
2298
+ '<a href="' . $this->menu_url() . '">', '</a>' ); ?>
2299
+ </p>
2300
+ </div>
2301
+ </td>
2302
+ </tr>
2303
+ <?php
2304
+
2305
+ } else {
2306
+
2307
+ ?>
2308
+ <tr class="plugin-update-tr">
2309
+ <td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-update colspanchange">
2310
+ <div class="update-message installer-q-icon">
2311
+ <?php printf( __( 'You must have a valid subscription in order to get upgrades or support for this plugin. %sPurchase a subscription or enter an existing site key%s.', 'installer' ),
2312
+ '<a href="' . $this->menu_url() . '">', '</a>' ); ?>
2313
+ </div>
2314
+ </td>
2315
+ </tr>
2316
+ <?php
2317
+
2318
+ }
2319
+
2320
+ }
2321
+
2322
+ public function localize_strings() {
2323
+
2324
+ if ( ! empty( $this->settings['repositories'] ) ) {
2325
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2326
+ //set name as call2action when don't have any
2327
+ //products
2328
+ foreach ( $repository['data']['packages'] as $package_id => $package ) {
2329
+ foreach ( $package['products'] as $product_id => $product ) {
2330
+ if ( empty( $product['call2action'] ) ) {
2331
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['call2action'] = $product['name'];
2332
+ }
2333
+
2334
+ foreach ( $product['upgrades'] as $idx => $upg ) {
2335
+ if ( empty( $upg['call2action'] ) ) {
2336
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $idx ]['call2action'] = $upg['name'];
2337
+ }
2338
+ }
2339
+
2340
+ foreach ( $product['renewals'] as $idx => $rnw ) {
2341
+ if ( empty( $rnw['call2action'] ) ) {
2342
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['renewals'][ $idx ]['call2action'] = $rnw['name'];
2343
+ }
2344
+
2345
+ }
2346
+
2347
+ }
2348
+ }
2349
+ }
2350
+ }
2351
+
2352
+ global $sitepress;
2353
+ if ( is_null( $sitepress ) ) {
2354
+ return;
2355
+ }
2356
+
2357
+ // default strings are always in English
2358
+ $user_admin_language = $sitepress->get_admin_language();
2359
+
2360
+ if ( $user_admin_language != 'en' ) {
2361
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2362
+
2363
+ $localization = $repository['data']['localization'];
2364
+
2365
+ //packages
2366
+ foreach ( $repository['data']['packages'] as $package_id => $package ) {
2367
+
2368
+ if ( isset( $localization['packages'][ $package_id ]['name'][ $user_admin_language ] ) ) {
2369
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['name'] = $localization['packages'][ $package_id ]['name'][ $user_admin_language ];
2370
+ }
2371
+ if ( isset( $localization['packages'][ $package_id ]['description'][ $user_admin_language ] ) ) {
2372
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['description'] = $localization['packages'][ $package_id ]['description'][ $user_admin_language ];
2373
+ }
2374
+
2375
+ }
2376
+
2377
+ //products
2378
+ foreach ( $repository['data']['packages'] as $package_id => $package ) {
2379
+ foreach ( $package['products'] as $product_id => $product ) {
2380
+
2381
+ if ( isset( $localization['products'][ $product_id ]['name'][ $user_admin_language ] ) ) {
2382
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['name']
2383
+ = $localization['products'][ $product_id ]['name'][ $user_admin_language ];
2384
+ }
2385
+ if ( isset( $localization['products'][ $product_id ]['description'][ $user_admin_language ] ) ) {
2386
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['description']
2387
+ = $localization['products'][ $product_id ]['description'][ $user_admin_language ];
2388
+ }
2389
+ if ( isset( $localization['products'][ $product_id ]['call2action'][ $user_admin_language ] ) ) {
2390
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['name']
2391
+ = $localization['products'][ $product_id ]['call2action'][ $user_admin_language ];
2392
+ }
2393
+
2394
+
2395
+ }
2396
+ }
2397
+
2398
+ //subscription info
2399
+ if ( isset( $repository['data']['subscriptions_meta']['expiration'] ) ) {
2400
+ foreach ( $repository['data']['subscriptions_meta']['expiration'] as $subscription_id => $note ) {
2401
+ if ( isset( $localization['subscriptions-notes'][ $subscription_id ]['expiration-warning'][ $user_admin_language ] ) ) {
2402
+ $this->settings['repositories'][ $repository_id ]['data']['subscriptions_meta']['expiration'][ $subscription_id ]['warning_message']
2403
+ = $localization['subscriptions-notes'][ $subscription_id ]['expiration-warning'][ $user_admin_language ];
2404
+ }
2405
+ }
2406
+ }
2407
+
2408
+ }
2409
+ }
2410
+
2411
+ }
2412
+
2413
+ public function get_matching_cp( $repository, $args = array() ) {
2414
+ $match = false;
2415
+
2416
+
2417
+ $cp_name = $cp_author = false;
2418
+
2419
+ if ( isset( $this->config['src_name'] ) && isset( $this->config['src_author'] ) ) {
2420
+
2421
+ $cp_name = $this->config['src_name'];
2422
+ $cp_author = $this->config['src_author'];
2423
+
2424
+ } elseif ( isset( $args['src_name'] ) && isset( $args['src_author'] ) ) {
2425
+
2426
+ $cp_name = $args['src_name'];
2427
+ $cp_author = $args['src_author'];
2428
+
2429
+ }
2430
+
2431
+ if ( isset( $repository['data']['marketing_cp'] ) ) {
2432
+
2433
+ foreach ( $repository['data']['marketing_cp'] as $cp ) {
2434
+
2435
+ if ( ! empty( $cp['exp'] ) && time() > $cp['exp'] ) {
2436
+ continue;
2437
+ }
2438
+
2439
+ //Use theme_name for plugins too
2440
+ if ( ! empty( $cp['theme_name'] ) ) {
2441
+ if ( $cp['author_name'] == $cp_author && $cp['theme_name'] == $cp_name ) {
2442
+ $match = $cp;
2443
+ continue;
2444
+ }
2445
+ } else {
2446
+ if ( $cp['author_name'] == $cp_author ) {
2447
+ $match = $cp;
2448
+ continue;
2449
+ }
2450
+ }
2451
+
2452
+ }
2453
+
2454
+ }
2455
+
2456
+ return $match;
2457
+ }
2458
+
2459
+ public function set_filtered_prices( $args = array() ) {
2460
+
2461
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2462
+
2463
+ $match = $this->get_matching_cp( $repository, $args );
2464
+
2465
+ if ( empty( $match ) ) {
2466
+ continue;
2467
+ }
2468
+
2469
+ foreach ( $repository['data']['packages'] as $package_id => $package ) {
2470
+
2471
+ foreach ( $package['products'] as $product_id => $product ) {
2472
+
2473
+ if ( $match['dtp'] == '%' ) {
2474
+ $fprice = round( $product['price'] * ( 1 - $match['amt'] / 100 ), 2 );
2475
+ $fprice = $fprice != round( $fprice ) ? sprintf( '%.2f', $fprice ) : round( $fprice, 0 );
2476
+ } elseif ( $match['dtp'] == '-' ) {
2477
+ $fprice = $product['price'] - $match['amt'];
2478
+ } else {
2479
+ $fprice = $product['price'];
2480
+ }
2481
+
2482
+ if ( $fprice ) {
2483
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['price_disc'] = $fprice;
2484
+
2485
+ $url_glue = false !== strpos( $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['url'], '?' ) ? '&' : '?';
2486
+ $cpndata = base64_encode( json_encode( array(
2487
+ 'theme_author' => $match['author_name'],
2488
+ 'theme_name' => $match['theme_name'],
2489
+ 'vlc' => $match['vlc']
2490
+ ) ) );
2491
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['url'] .= $url_glue . 'cpn=' . $cpndata;
2492
+
2493
+ foreach ( $product['upgrades'] as $upgrade_id => $upgrade ) {
2494
+
2495
+ $fprice = false;
2496
+ if ( $match['dtp'] == '%' ) {
2497
+ $fprice = round( $upgrade['price'] * ( 1 - $match['amt'] / 100 ), 2 );
2498
+ $fprice = $fprice != round( $fprice ) ? sprintf( '%.2f', $fprice ) : round( $fprice, 0 );
2499
+ } elseif ( $match['dtp'] == '-' ) {
2500
+ $fprice = $upgrade['price'] - $match['amt'];
2501
+ }
2502
+ if ( $fprice ) {
2503
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $upgrade_id ]['price_disc'] = $fprice;
2504
+ $this->settings['repositories'][ $repository_id ]['data']['packages'][ $package_id ]['products'][ $product_id ]['upgrades'][ $upgrade_id ]['url'] .= $url_glue . 'cpn=' . $cpndata;
2505
+ }
2506
+
2507
+
2508
+ }
2509
+
2510
+ }
2511
+
2512
+ }
2513
+
2514
+ }
2515
+
2516
+ }
2517
+
2518
+ }
2519
+
2520
+ public function set_hierarchy_and_order() {
2521
+
2522
+ //2 levels
2523
+ if ( ! empty( $this->settings['repositories'] ) ) {
2524
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2525
+
2526
+ if ( empty( $repository['data']['packages'] ) ) {
2527
+ continue;
2528
+ }
2529
+
2530
+ $all_packages = $repository['data']['packages'];
2531
+ $ordered_packages = array();
2532
+
2533
+ //backward compatibility - 'order'
2534
+ foreach ( $all_packages as $k => $v ) {
2535
+ if ( ! isset( $v['order'] ) ) {
2536
+ $all_packages[ $k ]['order'] = 0;
2537
+ }
2538
+ }
2539
+
2540
+ //select parents
2541
+ foreach ( $all_packages as $package_id => $package ) {
2542
+ if ( empty( $package['parent'] ) ) {
2543
+ $ordered_packages[ $package_id ] = $package;
2544
+ }
2545
+ }
2546
+
2547
+ //add sub-packages
2548
+ foreach ( $all_packages as $package_id => $package ) {
2549
+ if ( ! empty( $package['parent'] ) ) {
2550
+ if ( isset( $ordered_packages[ $package['parent'] ] ) ) {
2551
+ $ordered_packages[ $package['parent'] ]['sub-packages'][ $package_id ] = $package;
2552
+ }
2553
+ }
2554
+ }
2555
+
2556
+ // order parents
2557
+ usort( $ordered_packages, array( $this, '_order_packages_callback' ) );
2558
+ //order sub-packages
2559
+ foreach ( $ordered_packages as $package_id => $package ) {
2560
+ if ( ! empty( $package['sub-packages'] ) ) {
2561
+ usort( $ordered_packages[ $package_id ]['sub-packages'], create_function( '$a, $b', 'return $a[\'order\'] > $b[\'order\'];' ) );
2562
+ }
2563
+ }
2564
+
2565
+ $this->settings['repositories'][ $repository_id ]['data']['packages'] = $ordered_packages;
2566
+
2567
+
2568
+ }
2569
+ }
2570
+
2571
+
2572
+ }
2573
+
2574
+ public function _order_packages_callback( $a, $b ) {
2575
+ return $a['order'] > $b['order'];
2576
+ }
2577
+
2578
+ public function get_support_tag_by_name( $name, $repository ) {
2579
+
2580
+ if ( is_array( $this->settings['repositories'][ $repository ]['data']['support_tags'] ) ) {
2581
+ foreach ( $this->settings['repositories'][ $repository ]['data']['support_tags'] as $support_tag ) {
2582
+ if ( $support_tag['name'] == $name ) {
2583
+ return $support_tag['url'];
2584
+ }
2585
+ }
2586
+ }
2587
+
2588
+ return false;
2589
+ }
2590
+
2591
+ public function plugin_upgrade_custom_errors() {
2592
+
2593
+ if ( isset( $_REQUEST['action'] ) ) {
2594
+
2595
+ $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
2596
+
2597
+ //bulk mode
2598
+ if ( 'update-selected' == $action ) {
2599
+
2600
+ global $plugins;
2601
+
2602
+ if ( isset( $plugins ) && is_array( $plugins ) ) {
2603
+
2604
+ foreach ( $plugins as $k => $plugin ) {
2605
+ $plugin_repository = false;
2606
+
2607
+ $wp_plugin_slug = dirname( $plugin );
2608
+
2609
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2610
+
2611
+ foreach ( $repository['data']['packages'] as $package ) {
2612
+
2613
+ foreach ( $package['products'] as $product ) {
2614
+
2615
+ foreach ( $product['plugins'] as $plugin_slug ) {
2616
+
2617
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2618
+
2619
+ if ( $download['slug'] == $wp_plugin_slug ) {
2620
+ $plugin_repository = $repository_id;
2621
+ $product_name = $repository['data']['product-name'];
2622
+ $plugin_name = $download['name'];
2623
+ $free_on_wporg = ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION;
2624
+ break;
2625
+ }
2626
+
2627
+ }
2628
+
2629
+ }
2630
+
2631
+ }
2632
+
2633
+ }
2634
+
2635
+ if ( $plugin_repository ) {
2636
+
2637
+ //validate subscription
2638
+ static $sub_cache = array();
2639
+
2640
+ if ( empty( $sub_cache[ $plugin_repository ] ) ) {
2641
+ $site_key = $this->get_repository_site_key( $plugin_repository );
2642
+ if ( $site_key ) {
2643
+ $subscription_data = $this->fetch_subscription_data( $plugin_repository, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION );
2644
+ }
2645
+
2646
+ $sub_cache[ $plugin_repository ]['site_key'] = $site_key;
2647
+ $sub_cache[ $plugin_repository ]['subscription_data'] = isset( $subscription_data ) ? $subscription_data : false;
2648
+ } else {
2649
+
2650
+ $site_key = $sub_cache[ $plugin_repository ]['site_key'];
2651
+ $subscription_data = $sub_cache[ $plugin_repository ]['subscription_data'];
2652
+
2653
+ }
2654
+
2655
+ if ( ! $site_key && ! empty( $free_on_wporg ) ) { // allow the download from wp.org
2656
+ continue;
2657
+ }
2658
+
2659
+ if ( empty( $site_key ) || empty( $subscription_data ) ) {
2660
+
2661
+
2662
+ $error_message = sprintf( __( "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer' ),
2663
+ '<strong>' . $plugin_name . '</strong>', '<a target="_top" href="' . $this->menu_url() . '&validate_repository=' . $plugin_repository .
2664
+ '#repository-' . $plugin_repository . '">', $product_name, '</a>' );
2665
+
2666
+ echo '<div class="updated error"><p>' . $error_message . '</p></div>';
2667
+
2668
+ unset( $plugins[ $k ] );
2669
+
2670
+
2671
+ }
2672
+
2673
+ }
2674
+
2675
+ }
2676
+
2677
+ }
2678
+
2679
+ }
2680
+
2681
+
2682
+ if ( 'upgrade-plugin' == $action || 'update-plugin' == $action ) {
2683
+
2684
+ $plugin = isset( $_REQUEST['plugin'] ) ? trim( sanitize_text_field( $_REQUEST['plugin'] ) ) : '';
2685
+
2686
+ $wp_plugin_slug = dirname( $plugin );
2687
+
2688
+ $plugin_repository = false;
2689
+
2690
+ foreach ( $this->settings['repositories'] as $repository_id => $repository ) {
2691
+
2692
+ foreach ( $repository['data']['packages'] as $package ) {
2693
+
2694
+ foreach ( $package['products'] as $product ) {
2695
+
2696
+ foreach ( $product['plugins'] as $plugin_slug ) {
2697
+ $download = $this->settings['repositories'][ $repository_id ]['data']['downloads']['plugins'][ $plugin_slug ];
2698
+
2699
+ //match by folder, will change to match by name and folder
2700
+ if ( $download['slug'] == $wp_plugin_slug ) {
2701
+ $plugin_repository = $repository_id;
2702
+ $product_name = $repository['data']['product-name'];
2703
+ $plugin_name = $download['name'];
2704
+ $free_on_wporg = ! empty( $download['free-on-wporg'] ) && $download['channel'] == WP_Installer_Channels::CHANNEL_PRODUCTION;
2705
+ break;
2706
+ }
2707
+
2708
+ }
2709
+
2710
+ }
2711
+
2712
+ }
2713
+
2714
+ }
2715
+
2716
+ if ( $plugin_repository ) {
2717
+
2718
+ //validate subscription
2719
+ $site_key = $this->get_repository_site_key( $plugin_repository );
2720
+ if ( $site_key ) {
2721
+ $subscription_data = $this->fetch_subscription_data( $plugin_repository, $site_key, self::SITE_KEY_VALIDATION_SOURCE_REVALIDATION );
2722
+ }
2723
+
2724
+ if ( ( empty( $site_key ) || empty( $subscription_data ) ) && empty( $free_on_wporg ) ) {
2725
+
2726
+ $error_message = sprintf( __( "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer' ),
2727
+ '<strong>' . $plugin_name . '</strong>', '<a href="' . $this->menu_url() . '&validate_repository=' . $plugin_repository .
2728
+ '#repository-' . $plugin_repository . '">', $product_name, '</a>' );
2729
+
2730
+ if ( defined( 'DOING_AJAX' ) ) { //WP 4.2
2731
+
2732
+ $status = array(
2733
+ 'update' => 'plugin',
2734
+ 'plugin' => $plugin,
2735
+ 'slug' => sanitize_key( $_POST['slug'] ),
2736
+ 'oldVersion' => '',
2737
+ 'newVersion' => '',
2738
+ );
2739
+
2740
+ $status['errorCode'] = 'wp_installer_invalid_subscription';
2741
+ $status['error'] = $error_message;
2742
+
2743
+ wp_send_json_error( $status );
2744
+
2745
+ } else { // WP 4.1.1
2746
+ echo '<div class="updated error"><p>' . $error_message . '</p></div>';
2747
+
2748
+
2749
+ echo '<div class="wrap">';
2750
+ echo '<h2>' . __( 'Update Plugin', 'installer' ) . '</h2>';
2751
+ echo '<a href="' . admin_url( 'plugins.php' ) . '">' . __( 'Return to the plugins page', 'installer' ) . '</a>';
2752
+ echo '</div>';
2753
+ require_once( ABSPATH . 'wp-admin/admin-footer.php' );
2754
+ exit;
2755
+
2756
+ }
2757
+
2758
+ }
2759
+
2760
+
2761
+ }
2762
+
2763
+ }
2764
+ }
2765
+
2766
+ }
2767
+
2768
+ }
vendor/otgs/installer/includes/functions-core.php CHANGED
@@ -1,9 +1,9 @@
1
- <?php
2
-
3
- function WP_Installer(){
4
- return WP_Installer::instance();
5
- }
6
-
7
- function WP_Installer_Channels(){
8
- return WP_Installer_Channels::instance();
9
- }
1
+ <?php
2
+
3
+ function WP_Installer(){
4
+ return WP_Installer::instance();
5
+ }
6
+
7
+ function WP_Installer_Channels(){
8
+ return WP_Installer_Channels::instance();
9
+ }
vendor/otgs/installer/includes/functions-templates.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- // Ext function
4
- function WP_Installer_Show_Products($args = array()){
5
- WP_Installer()->show_products($args);
6
- }
1
+ <?php
2
+
3
+ // Ext function
4
+ function WP_Installer_Show_Products($args = array()){
5
+ WP_Installer()->show_products($args);
6
+ }
vendor/otgs/installer/installer.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
- define( 'WP_INSTALLER_VERSION', '1.8.2' );
3
-
4
- include_once dirname( __FILE__ ) . '/includes/functions-core.php';
5
- include_once dirname( __FILE__ ) . '/includes/class-wp-installer.php';
6
-
7
- include_once WP_Installer()->plugin_path() . '/includes/class-wp-installer-api.php';
8
- include_once WP_Installer()->plugin_path() . '/includes/class-translation-service-info.php';
9
- include_once WP_Installer()->plugin_path() . '/includes/class-installer-dependencies.php';
10
- include_once WP_Installer()->plugin_path() . '/includes/class-wp-installer-channels.php';
11
-
12
- include_once WP_Installer()->plugin_path() . '/includes/functions-templates.php';
13
-
14
- // Initialization
15
- WP_Installer();
16
- WP_Installer_Channels();
17
-
18
-
1
+ <?php
2
+ define( 'WP_INSTALLER_VERSION', '1.8.2' );
3
+
4
+ include_once dirname( __FILE__ ) . '/includes/functions-core.php';
5
+ include_once dirname( __FILE__ ) . '/includes/class-wp-installer.php';
6
+
7
+ include_once WP_Installer()->plugin_path() . '/includes/class-wp-installer-api.php';
8
+ include_once WP_Installer()->plugin_path() . '/includes/class-translation-service-info.php';
9
+ include_once WP_Installer()->plugin_path() . '/includes/class-installer-dependencies.php';
10
+ include_once WP_Installer()->plugin_path() . '/includes/class-wp-installer-channels.php';
11
+
12
+ include_once WP_Installer()->plugin_path() . '/includes/functions-templates.php';
13
+
14
+ // Initialization
15
+ WP_Installer();
16
+ WP_Installer_Channels();
17
+
18
+
vendor/otgs/installer/loader.php CHANGED
@@ -1,151 +1,151 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit; // Exit if accessed directly
5
- }
6
-
7
- //It should only be loaded on the admin side
8
- if( !is_admin() ){
9
- if(!function_exists('WP_Installer_Setup')){ function WP_Installer_Setup(){} }
10
- $wp_installer_instance = null;
11
- return;
12
- }
13
-
14
-
15
- $wp_installer_instance = dirname(__FILE__) . '/installer.php';
16
-
17
-
18
- // Global stack of instances
19
- global $wp_installer_instances;
20
- $wp_installer_instances[$wp_installer_instance] = array(
21
- 'bootfile' => $wp_installer_instance,
22
- 'version' => '1.8.2'
23
- );
24
-
25
-
26
- /* EXCEPTIONS ********************************************************************************************/
27
- // Exception: When WPML prior 3.2 is used, that instance must be used regardless of another newer instance
28
- // Case 1: WPML loaded before Types - eliminate other instances
29
- if( defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '<') ) {
30
- foreach($wp_installer_instances as $key => $instance) {
31
- if(isset($instance['args']['site_key_nags'])){
32
- $wp_installer_instances[$key]['version'] = '9.9';
33
- }else{
34
- $wp_installer_instances[$key]['version'] = '0';
35
- }
36
- }
37
- }
38
-
39
- // Exception: Types 1.8.9 (Installer 1.7.0) with WPML before 3.3 (Installer before 1.7.0)
40
- // New products file http://d2salfytceyqoe.cloudfront.net/wpml-products33.json overrides the old one
41
- // while the WPML's instance is being used
42
- // => Force using the new Installer Instance
43
- if( defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.3.1', '<') ) {
44
-
45
- // if Installer 1.7.0+ is present, unregister Installer from old WPML
46
- // Force Installer 1.7.0+ being used over older Installer versions
47
- $installer_171_plus_on = false;
48
- foreach($wp_installer_instances as $key => $instance) {
49
- if( version_compare( $instance['version'], '1.7.1', '>=' ) ){
50
- $installer_171_plus_on = true;
51
- break;
52
- }
53
- }
54
-
55
- if( $installer_171_plus_on ){
56
- foreach($wp_installer_instances as $key => $instance) {
57
-
58
- if( version_compare( $instance['version'], '1.7.0', '<' ) ){
59
- unset( $wp_installer_instances[$key] );
60
- }
61
-
62
- }
63
- }
64
-
65
- }
66
-
67
- // Exception: When using the embedded plugins module allow the set up to run completely with the
68
- // Installer instance that triggers it
69
- if( isset( $_POST['installer_instance'] ) && isset( $wp_installer_instances[$_POST['installer_instance']] ) ){
70
- $wp_installer_instances[$_POST['installer_instance']]['version'] = '999';
71
- }
72
- /* EXCEPTIONS ********************************************************************************************/
73
-
74
-
75
- // Only one of these in the end
76
- remove_action('after_setup_theme', 'wpml_installer_instance_delegator', 1);
77
- add_action('after_setup_theme', 'wpml_installer_instance_delegator', 1);
78
-
79
- // When all plugins load pick the newest version
80
- if(!function_exists('wpml_installer_instance_delegator')){
81
- function wpml_installer_instance_delegator(){
82
- global $wp_installer_instances;
83
-
84
- // version based election
85
- foreach($wp_installer_instances as $instance){
86
-
87
- if(!isset($delegate)){
88
- $delegate = $instance;
89
- continue;
90
- }
91
-
92
- if(version_compare($instance['version'], $delegate['version'], '>')){
93
- $delegate = $instance;
94
- }
95
- }
96
-
97
- // priority based election
98
- $highest_priority = null;
99
- foreach($wp_installer_instances as $instance) {
100
- if(isset($instance['args']['high_priority'])){
101
- if(is_null($highest_priority) || $instance['args']['high_priority'] <= $highest_priority){
102
- $highest_priority = $instance['args']['high_priority'];
103
- $delegate = $instance;
104
- }
105
- }
106
- }
107
-
108
- // Exception: When WPML prior 3.2 is used, that instance must be used regardless of another newer instance
109
- // Case 2: WPML loaded after Types
110
- if( defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '<') ) {
111
- foreach($wp_installer_instances as $key => $instance) {
112
- if(isset($instance['args']['site_key_nags'])){
113
- $delegate = $instance;
114
- $wp_installer_instances = array($key => $delegate); //Eliminate other instances
115
- break;
116
- }
117
- }
118
- }
119
-
120
- include_once $delegate['bootfile'];
121
-
122
- // set configuration
123
- if(strpos(realpath($delegate['bootfile']), realpath(TEMPLATEPATH)) === 0){
124
- $delegate['args']['in_theme_folder'] = dirname(ltrim(str_replace(realpath(TEMPLATEPATH), '', realpath($delegate['bootfile'])), '\\/'));
125
- }
126
- if(isset($delegate['args']) && is_array($delegate['args'])){
127
- foreach($delegate['args'] as $key => $value){
128
- WP_Installer()->set_config($key, $value);
129
- }
130
- }
131
-
132
- }
133
- }
134
-
135
- if(!function_exists('WP_Installer_Setup')){
136
-
137
- // $args:
138
- // plugins_install_tab = true|false (default: true)
139
- // repositories_include = array() (default: all)
140
- // repositories_exclude = array() (default: none)
141
- // template = name (default: default)
142
- //
143
- // Ext function
144
- function WP_Installer_Setup($wp_installer_instance, $args = array()){
145
- global $wp_installer_instances;
146
-
147
- $wp_installer_instances[$wp_installer_instance]['args'] = $args;
148
-
149
- }
150
-
151
  }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
+
7
+ //It should only be loaded on the admin side
8
+ if( !is_admin() ){
9
+ if(!function_exists('WP_Installer_Setup')){ function WP_Installer_Setup(){} }
10
+ $wp_installer_instance = null;
11
+ return;
12
+ }
13
+
14
+
15
+ $wp_installer_instance = dirname(__FILE__) . '/installer.php';
16
+
17
+
18
+ // Global stack of instances
19
+ global $wp_installer_instances;
20
+ $wp_installer_instances[$wp_installer_instance] = array(
21
+ 'bootfile' => $wp_installer_instance,
22
+ 'version' => '1.8.2'
23
+ );
24
+
25
+
26
+ /* EXCEPTIONS ********************************************************************************************/
27
+ // Exception: When WPML prior 3.2 is used, that instance must be used regardless of another newer instance
28
+ // Case 1: WPML loaded before Types - eliminate other instances
29
+ if( defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '<') ) {
30
+ foreach($wp_installer_instances as $key => $instance) {
31
+ if(isset($instance['args']['site_key_nags'])){
32
+ $wp_installer_instances[$key]['version'] = '9.9';
33
+ }else{
34
+ $wp_installer_instances[$key]['version'] = '0';
35
+ }
36
+ }
37
+ }
38
+
39
+ // Exception: Types 1.8.9 (Installer 1.7.0) with WPML before 3.3 (Installer before 1.7.0)
40
+ // New products file http://d2salfytceyqoe.cloudfront.net/wpml-products33.json overrides the old one
41
+ // while the WPML's instance is being used
42
+ // => Force using the new Installer Instance
43
+ if( defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.3.1', '<') ) {
44
+
45
+ // if Installer 1.7.0+ is present, unregister Installer from old WPML
46
+ // Force Installer 1.7.0+ being used over older Installer versions
47
+ $installer_171_plus_on = false;
48
+ foreach($wp_installer_instances as $key => $instance) {
49
+ if( version_compare( $instance['version'], '1.7.1', '>=' ) ){
50
+ $installer_171_plus_on = true;
51
+ break;
52
+ }
53
+ }
54
+
55
+ if( $installer_171_plus_on ){
56
+ foreach($wp_installer_instances as $key => $instance) {
57
+
58
+ if( version_compare( $instance['version'], '1.7.0', '<' ) ){
59
+ unset( $wp_installer_instances[$key] );
60
+ }
61
+
62
+ }
63
+ }
64
+
65
+ }
66
+
67
+ // Exception: When using the embedded plugins module allow the set up to run completely with the
68
+ // Installer instance that triggers it
69
+ if( isset( $_POST['installer_instance'] ) && isset( $wp_installer_instances[$_POST['installer_instance']] ) ){
70
+ $wp_installer_instances[$_POST['installer_instance']]['version'] = '999';
71
+ }
72
+ /* EXCEPTIONS ********************************************************************************************/
73
+
74
+
75
+ // Only one of these in the end
76
+ remove_action('after_setup_theme', 'wpml_installer_instance_delegator', 1);
77
+ add_action('after_setup_theme', 'wpml_installer_instance_delegator', 1);
78
+
79
+ // When all plugins load pick the newest version
80
+ if(!function_exists('wpml_installer_instance_delegator')){
81
+ function wpml_installer_instance_delegator(){
82
+ global $wp_installer_instances;
83
+
84
+ // version based election
85
+ foreach($wp_installer_instances as $instance){
86
+
87
+ if(!isset($delegate)){
88
+ $delegate = $instance;
89
+ continue;
90
+ }
91
+
92
+ if(version_compare($instance['version'], $delegate['version'], '>')){
93
+ $delegate = $instance;
94
+ }
95
+ }
96
+
97
+ // priority based election
98
+ $highest_priority = null;
99
+ foreach($wp_installer_instances as $instance) {
100
+ if(isset($instance['args']['high_priority'])){
101
+ if(is_null($highest_priority) || $instance['args']['high_priority'] <= $highest_priority){
102
+ $highest_priority = $instance['args']['high_priority'];
103
+ $delegate = $instance;
104
+ }
105
+ }
106
+ }
107
+
108
+ // Exception: When WPML prior 3.2 is used, that instance must be used regardless of another newer instance
109
+ // Case 2: WPML loaded after Types
110
+ if( defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '<') ) {
111
+ foreach($wp_installer_instances as $key => $instance) {
112
+ if(isset($instance['args']['site_key_nags'])){
113
+ $delegate = $instance;
114
+ $wp_installer_instances = array($key => $delegate); //Eliminate other instances
115
+ break;
116
+ }
117
+ }
118
+ }
119
+
120
+ include_once $delegate['bootfile'];
121
+
122
+ // set configuration
123
+ if(strpos(realpath($delegate['bootfile']), realpath(TEMPLATEPATH)) === 0){
124
+ $delegate['args']['in_theme_folder'] = dirname(ltrim(str_replace(realpath(TEMPLATEPATH), '', realpath($delegate['bootfile'])), '\\/'));
125
+ }
126
+ if(isset($delegate['args']) && is_array($delegate['args'])){
127
+ foreach($delegate['args'] as $key => $value){
128
+ WP_Installer()->set_config($key, $value);
129
+ }
130
+ }
131
+
132
+ }
133
+ }
134
+
135
+ if(!function_exists('WP_Installer_Setup')){
136
+
137
+ // $args:
138
+ // plugins_install_tab = true|false (default: true)
139
+ // repositories_include = array() (default: all)
140
+ // repositories_exclude = array() (default: none)
141
+ // template = name (default: default)
142
+ //
143
+ // Ext function
144
+ function WP_Installer_Setup($wp_installer_instance, $args = array()){
145
+ global $wp_installer_instances;
146
+
147
+ $wp_installer_instances[$wp_installer_instance]['args'] = $args;
148
+
149
+ }
150
+
151
  }
vendor/otgs/installer/locale/orig/installer.po CHANGED
@@ -1,230 +1,230 @@
1
- # This file was generated by WPML
2
- # WPML is a WordPress plugin that can turn any WordPress site into a full featured multilingual content management system.
3
- # https://wpml.org
4
- msgid ""
5
- msgstr ""
6
- "Content-Type: text/plain; charset=utf-8\n"
7
- "Content-Transfer-Encoding: 8bit\n"
8
- "Project-Id-Version:WPML_EXPORT\n"
9
- "POT-Creation-Date: \n"
10
- "PO-Revision-Date: \n"
11
- "Last-Translator: \n"
12
- "Language-Team: \n"
13
- "Language:en\n"
14
- "MIME-Version: 1.0\n"
15
-
16
- msgid "Installer"
17
- msgstr ""
18
-
19
- msgid "Registered"
20
- msgstr ""
21
-
22
- msgid "Register"
23
- msgstr ""
24
-
25
- msgid "To get automatic updates, you need to register %s for this site. %sRegister %s%s"
26
- msgstr ""
27
-
28
- msgid "Dismiss"
29
- msgstr ""
30
-
31
- msgid "Commercial"
32
- msgstr ""
33
-
34
- msgid "Installer cannot contact our updates server to get information about the available products and check for new versions. If you are seeing this message for the first time, you can ignore it, as it may be a temporary communication problem. If the problem persists and your WordPress admin is slowing down, you can disable automated version checks. Add the following line to your wp-config.php file:"
35
- msgstr ""
36
-
37
- msgid "No repositories defined."
38
- msgstr ""
39
-
40
- msgid "%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates."
41
- msgstr ""
42
-
43
- msgid "Invalid site key for the current site."
44
- msgstr ""
45
-
46
- msgid "You will have to renew your subscription in order to continue getting the updates and support."
47
- msgstr ""
48
-
49
- msgid "%sRenew here%s."
50
- msgstr ""
51
-
52
- msgid "Your subscription appears to no longer be valid. Please try to register again using a valid site key."
53
- msgstr ""
54
-
55
- msgid "You need to have a valid subscription in order to get upgrades or support for this plugin. %sPurchase a subscription or enter an existing site key%s."
56
- msgstr ""
57
-
58
- msgid "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first."
59
- msgstr ""
60
-
61
- msgid "Update Plugin"
62
- msgstr ""
63
-
64
- msgid "Return to the plugins page"
65
- msgstr ""
66
-
67
- msgid "Your subscription expires in %d day."
68
- msgstr ""
69
-
70
- msgid "Your subscription expires in %d days."
71
- msgstr ""
72
-
73
- msgid "Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s."
74
- msgstr ""
75
-
76
- msgid "Plugin"
77
- msgstr ""
78
-
79
- msgid "downloading..."
80
- msgstr ""
81
-
82
- msgid "failed!"
83
- msgstr ""
84
-
85
- msgid "downloaded"
86
- msgstr ""
87
-
88
- msgid "activating"
89
- msgstr ""
90
-
91
- msgid "activated"
92
- msgstr ""
93
-
94
- msgid "Activate after download"
95
- msgstr ""
96
-
97
- msgid "Operation complete!"
98
- msgstr ""
99
-
100
- msgid "Download failed!\n\nClick OK to revalidate your subscription or CANCEL to try again."
101
- msgstr ""
102
-
103
- msgid "Available"
104
- msgstr ""
105
-
106
- msgid "Installed"
107
- msgstr ""
108
-
109
- msgid "Downloading"
110
- msgstr ""
111
-
112
- msgid "Activate"
113
- msgstr ""
114
-
115
- msgid "Download"
116
- msgstr ""
117
-
118
- msgid "Downloads:"
119
- msgstr ""
120
-
121
- msgid "Current version"
122
- msgstr ""
123
-
124
- msgid "Released"
125
- msgstr ""
126
-
127
- msgid "Installed version"
128
- msgstr ""
129
-
130
- msgid "(embedded)"
131
- msgstr ""
132
-
133
- msgid "installing..."
134
- msgstr ""
135
-
136
- msgid "updating..."
137
- msgstr ""
138
-
139
- msgid "installed"
140
- msgstr ""
141
-
142
- msgid "updated"
143
- msgstr ""
144
-
145
- msgid "Download failed!\n\nPlease refresh the page and try again."
146
- msgstr ""
147
-
148
- msgid "Incorrect setup"
149
- msgstr ""
150
-
151
- msgid "Invalid product"
152
- msgstr ""
153
-
154
- msgid "Unknown repository"
155
- msgstr ""
156
-
157
- msgid " Your current site key (%s) does not match the selected product (%s)."
158
- msgstr ""
159
-
160
- msgid "Buy %s"
161
- msgstr ""
162
-
163
- msgid "Already bought %s?"
164
- msgstr ""
165
-
166
- msgid "Renew %s"
167
- msgstr ""
168
-
169
- msgid "Remove current site key (%s)"
170
- msgstr ""
171
-
172
- msgid "%s support on wpml.org"
173
- msgstr ""
174
-
175
- msgid "Enter site key"
176
- msgstr ""
177
-
178
- msgid "Subscription is expired."
179
- msgstr ""
180
-
181
- msgid "Add"
182
- msgstr ""
183
-
184
- msgid "Are you sure you want to remove this site key?"
185
- msgstr ""
186
-
187
- msgid "Register %s"
188
- msgstr ""
189
-
190
- msgid "1. Go to your %s%s account%s and add this site URL: %s"
191
- msgstr ""
192
-
193
- msgid "Unregister %s from this site"
194
- msgstr ""
195
-
196
- msgid "%s is registered on this site. You will receive automatic updates until %s"
197
- msgstr ""
198
-
199
- msgid "%s is registered on this site. Your Lifetime account gives you updates for life."
200
- msgstr ""
201
-
202
- msgid "This page lets you install plugins and update existing plugins. To remove any of these plugins, go to the %splugins%s page and if you have the permission to remove plugins you should be able to do this."
203
- msgstr ""
204
-
205
- msgid "Already bought?"
206
- msgstr ""
207
-
208
- msgid "2. Enter your site key"
209
- msgstr ""
210
-
211
- msgid "Subscription is expired. You need to either purchase a new subscription or upgrade if available."
212
- msgstr ""
213
-
214
- msgid "Check for updates"
215
- msgstr ""
216
-
217
- msgid "Individual components"
218
- msgstr ""
219
-
220
- msgid "OK"
221
- msgstr ""
222
-
223
- msgid "Cancel"
224
- msgstr ""
225
-
226
- msgid "Are you sure you want to unregister?"
227
- msgstr ""
228
-
229
- msgid "Click to see individual components options."
230
- msgstr ""
1
+ # This file was generated by WPML
2
+ # WPML is a WordPress plugin that can turn any WordPress site into a full featured multilingual content management system.
3
+ # https://wpml.org
4
+ msgid ""
5
+ msgstr ""
6
+ "Content-Type: text/plain; charset=utf-8\n"
7
+ "Content-Transfer-Encoding: 8bit\n"
8
+ "Project-Id-Version:WPML_EXPORT\n"
9
+ "POT-Creation-Date: \n"
10
+ "PO-Revision-Date: \n"
11
+ "Last-Translator: \n"
12
+ "Language-Team: \n"
13
+ "Language:en\n"
14
+ "MIME-Version: 1.0\n"
15
+
16
+ msgid "Installer"
17
+ msgstr ""
18
+
19
+ msgid "Registered"
20
+ msgstr ""
21
+
22
+ msgid "Register"
23
+ msgstr ""
24
+
25
+ msgid "To get automatic updates, you need to register %s for this site. %sRegister %s%s"
26
+ msgstr ""
27
+
28
+ msgid "Dismiss"
29
+ msgstr ""
30
+
31
+ msgid "Commercial"
32
+ msgstr ""
33
+
34
+ msgid "Installer cannot contact our updates server to get information about the available products and check for new versions. If you are seeing this message for the first time, you can ignore it, as it may be a temporary communication problem. If the problem persists and your WordPress admin is slowing down, you can disable automated version checks. Add the following line to your wp-config.php file:"
35
+ msgstr ""
36
+
37
+ msgid "No repositories defined."
38
+ msgstr ""
39
+
40
+ msgid "%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates."
41
+ msgstr ""
42
+
43
+ msgid "Invalid site key for the current site."
44
+ msgstr ""
45
+
46
+ msgid "You will have to renew your subscription in order to continue getting the updates and support."
47
+ msgstr ""
48
+
49
+ msgid "%sRenew here%s."
50
+ msgstr ""
51
+
52
+ msgid "Your subscription appears to no longer be valid. Please try to register again using a valid site key."
53
+ msgstr ""
54
+
55
+ msgid "You need to have a valid subscription in order to get upgrades or support for this plugin. %sPurchase a subscription or enter an existing site key%s."
56
+ msgstr ""
57
+
58
+ msgid "%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first."
59
+ msgstr ""
60
+
61
+ msgid "Update Plugin"
62
+ msgstr ""
63
+
64
+ msgid "Return to the plugins page"
65
+ msgstr ""
66
+
67
+ msgid "Your subscription expires in %d day."
68
+ msgstr ""
69
+
70
+ msgid "Your subscription expires in %d days."
71
+ msgstr ""
72
+
73
+ msgid "Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s."
74
+ msgstr ""
75
+
76
+ msgid "Plugin"
77
+ msgstr ""
78
+
79
+ msgid "downloading..."
80
+ msgstr ""
81
+
82
+ msgid "failed!"
83
+ msgstr ""
84
+
85
+ msgid "downloaded"
86
+ msgstr ""
87
+
88
+ msgid "activating"
89
+ msgstr ""
90
+
91
+ msgid "activated"
92
+ msgstr ""
93
+
94
+ msgid "Activate after download"
95
+ msgstr ""
96
+
97
+ msgid "Operation complete!"
98
+ msgstr ""
99
+
100
+ msgid "Download failed!\n\nClick OK to revalidate your subscription or CANCEL to try again."
101
+ msgstr ""
102
+
103
+ msgid "Available"
104
+ msgstr ""
105
+
106
+ msgid "Installed"
107
+ msgstr ""
108
+
109
+ msgid "Downloading"
110
+ msgstr ""
111
+
112
+ msgid "Activate"
113
+ msgstr ""
114
+
115
+ msgid "Download"
116
+ msgstr ""
117
+
118
+ msgid "Downloads:"
119
+ msgstr ""
120
+
121
+ msgid "Current version"
122
+ msgstr ""
123
+
124
+ msgid "Released"
125
+ msgstr ""
126
+
127
+ msgid "Installed version"
128
+ msgstr ""
129
+
130
+ msgid "(embedded)"
131
+ msgstr ""
132
+
133
+ msgid "installing..."
134
+ msgstr ""
135
+
136
+ msgid "updating..."
137
+ msgstr ""
138
+
139
+ msgid "installed"
140
+ msgstr ""
141
+
142
+ msgid "updated"
143
+ msgstr ""
144
+
145
+ msgid "Download failed!\n\nPlease refresh the page and try again."
146
+ msgstr ""
147
+
148
+ msgid "Incorrect setup"
149
+ msgstr ""
150
+
151
+ msgid "Invalid product"
152
+ msgstr ""
153
+
154
+ msgid "Unknown repository"
155
+ msgstr ""
156
+
157
+ msgid " Your current site key (%s) does not match the selected product (%s)."
158
+ msgstr ""
159
+
160
+ msgid "Buy %s"
161
+ msgstr ""
162
+
163
+ msgid "Already bought %s?"
164
+ msgstr ""
165
+
166
+ msgid "Renew %s"
167
+ msgstr ""
168
+
169
+ msgid "Remove current site key (%s)"
170
+ msgstr ""
171
+
172
+ msgid "%s support on wpml.org"
173
+ msgstr ""
174
+
175
+ msgid "Enter site key"
176
+ msgstr ""
177
+
178
+ msgid "Subscription is expired."
179
+ msgstr ""
180
+
181
+ msgid "Add"
182
+ msgstr ""
183
+
184
+ msgid "Are you sure you want to remove this site key?"
185
+ msgstr ""
186
+
187
+ msgid "Register %s"
188
+ msgstr ""
189
+
190
+ msgid "1. Go to your %s%s account%s and add this site URL: %s"
191
+ msgstr ""
192
+
193
+ msgid "Unregister %s from this site"
194
+ msgstr ""
195
+
196
+ msgid "%s is registered on this site. You will receive automatic updates until %s"
197
+ msgstr ""
198
+
199
+ msgid "%s is registered on this site. Your Lifetime account gives you updates for life."
200
+ msgstr ""
201
+
202
+ msgid "This page lets you install plugins and update existing plugins. To remove any of these plugins, go to the %splugins%s page and if you have the permission to remove plugins you should be able to do this."
203
+ msgstr ""
204
+
205
+ msgid "Already bought?"
206
+ msgstr ""
207
+
208
+ msgid "2. Enter your site key"
209
+ msgstr ""
210
+
211
+ msgid "Subscription is expired. You need to either purchase a new subscription or upgrade if available."
212
+ msgstr ""
213
+
214
+ msgid "Check for updates"
215
+ msgstr ""
216
+
217
+ msgid "Individual components"
218
+ msgstr ""
219
+
220
+ msgid "OK"
221
+ msgstr ""
222
+
223
+ msgid "Cancel"
224
+ msgstr ""
225
+
226
+ msgid "Are you sure you want to unregister?"
227
+ msgstr ""
228
+
229
+ msgid "Click to see individual components options."
230
+ msgstr ""
vendor/otgs/installer/res/css/admin.css CHANGED
@@ -1,293 +1,293 @@
1
- .otgsi_site_key_form{
2
- display:none;
3
- /*display:inline;*/
4
- }
5
-
6
- .installer-status-installing, .installer-status-installed, .installer-status-updating, .installer-status-updated, .installer-status-activating, .installer-status-activated, .installer-status-success{
7
- display: none;
8
- }
9
- .installer-status-installing{color: #FF9900; }
10
- .installer-status-installed{color: #003300; font-weight: bold; }
11
- .installer-status-updating{color: #FF9900; }
12
- .installer-status-updated{color: #003300; font-weight: bold; }
13
-
14
- .installer-status-installed .error-details:before,
15
- .installer-status-updated .error-details:before{
16
- content: "\f534";
17
- font: 200 16px/1 dashicons;
18
- vertical-align: text-bottom;
19
- margin-left: 5px;
20
- color: red;
21
- cursor: help;
22
- }
23
-
24
- .installer-status-activating{color: #996666 }
25
- .installer-status-activated{color: #333366; font-weight: bold; }
26
-
27
- .js-status-success p{
28
- color: #FF9900;
29
- padding: 4px;
30
- }
31
-
32
- .installer-green-text{
33
- color:#006600;
34
- font-weight:bold;
35
- }
36
-
37
- .installer-red-text{
38
- color:#b22121;
39
- font-weight:bold;
40
- }
41
-
42
- .installer-footnote{
43
- color:#3d5e69;
44
- display:block;
45
- float: left;
46
- font-style: italic;
47
- font-size: 90%;
48
- }
49
-
50
- .installer-products-list li{
51
- display: inline;
52
- margin-right: 20px;
53
- }
54
-
55
- .otgs_wp_installer_table a.disabled{
56
- color:#888;
57
- }
58
-
59
- .otgs_wp_installer_subtable{
60
- clear: both;
61
- margin-left:-20px;
62
- }
63
- .otgs_wp_installer_subtable td p{
64
- font-size: 92%;
65
- }
66
-
67
- .installer-status-error{
68
- color: #f00;
69
- }
70
-
71
- .installer-status-note{
72
- color: #6F6E6D;
73
- font-style: italic;
74
- }
75
-
76
- .installer-warn-text{
77
- color: #FF6400;
78
- }
79
-
80
- .installer-warn-box{
81
- -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #FF6400;background-color:#df8a48;
82
- color: #333;
83
- padding: 5px;
84
- }
85
- .installer-warn-box span.details{
86
- font-style: italic;
87
- color:#777;
88
- }
89
-
90
- .installer-error-box{
91
- color:#962722;
92
- margin-top: 10px;
93
- }
94
- .installer-error-box p{
95
- margin: 10px 0 10px 0;
96
- -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #962722;background-color:#F5C8C6;
97
- color: #333;
98
- padding: 5px;
99
- text-align: center;
100
- }
101
-
102
- .spinner-inline{
103
- float: none;
104
- display: inline-block;
105
- visibility: visible;
106
- }
107
-
108
- .installer-q-icon:before{
109
- content: '\f223' !important;
110
- font-family: dashicons !important;
111
- color: #f56e28;
112
- font: 20px/1 "dashicons";
113
- }
114
-
115
- .installer-plugin-update-tr td{
116
- padding-left:3px !important;
117
- }
118
-
119
- .otgsi_yellow_bg{
120
- background-color: #f2f46b;
121
- }
122
-
123
- .otgs_wp_installer_table_compact{
124
- width:480px;
125
- border: solid 1px #999;
126
- padding:10px;
127
- border-radius: 5px;
128
- }
129
-
130
- .installer-plugins-list-compact{
131
- background-color: #fff;
132
- border-collapse: collapse;
133
- border:solid 1px #C1DAD7;
134
- width:100%;
135
- }
136
-
137
- .installer-plugins-list-compact tr th{
138
- padding-top:3px;
139
- background-color: #ccc;
140
- }
141
-
142
- .installer-plugins-list-compact tr{
143
- background-color: #ddd;
144
- }
145
-
146
- .installer-plugins-list-compact tr.even{
147
- background-color: #eee;
148
- }
149
-
150
- .installer-plugins-list-compact td{
151
- padding:2px 5px 2px 5px;
152
- border-right: 1px solid #C1DAD7;
153
- border-bottom: 1px solid #C1DAD7;
154
- }
155
-
156
- .installer-plugins-list-compact td.twelve{
157
- width:16px;
158
- }
159
-
160
- .otgs_wp_installer_table_compact .installer-status-downloading,
161
- .otgs_wp_installer_table_compact .installer-status-downloaded,
162
- .otgs_wp_installer_table_compact .installer-status-activating,
163
- .otgs_wp_installer_table_compact .installer-status-activated{
164
- display: none;
165
- color:transparent; width: 12px; padding:2px;
166
- }
167
-
168
- .otgs_wp_installer_table_compact .installer-status-success,
169
- .otgs_wp_installer_table_compact .installer-status-fail{
170
- display: none;
171
- }
172
-
173
- .installer-status-success{
174
- float: right;
175
- color: #006600;
176
- }
177
-
178
- .otgs_wp_installer_table_compact .installer-status-downloading{background: url(../img/dn.gif) no-repeat center; }
179
- .otgs_wp_installer_table_compact .installer-status-downloaded{background: url(../img/complete.png) no-repeat center;}
180
- .otgs_wp_installer_table_compact .installer-status-activating{background: url(../img/dn.gif) no-repeat center; }
181
- .otgs_wp_installer_table_compact .installer-status-activated{background: url(../img/complete.png) no-repeat center; }
182
- .otgs_wp_installer_table_compact .installer-status-error{background: url(../img/icon_error.gif) no-repeat center; }
183
-
184
- .installer_highlight{
185
- color:#c5510b;
186
- }
187
-
188
- .installer_highlight_package{
189
- background-color: #fff9c0;
190
- }
191
-
192
- .plugin_progress{
193
- font-style: italic;
194
- color: #777
195
- }
196
-
197
- .installer-download-progress-status{
198
- display: none;
199
- float:right;
200
- color: #006600;
201
- font-style: italic;
202
- background: url('../img/spinner.gif') no-repeat;
203
- padding-left:24px;
204
- }
205
-
206
- .installer-release-notes{
207
- display: none;
208
- }
209
-
210
- .handle.extended:after{
211
- content: "▾";
212
- font-size: 24px;
213
- vertical-align:bottom;
214
- }
215
- .installer-table-wrap a.handle:active,
216
- .installer-table-wrap a.handle:focus{
217
- outline:0;
218
- border:none;
219
- -moz-outline-style: none;
220
- -webkit-box-shadow: none;
221
- box-shadow: none;
222
- }
223
-
224
- .installer-release-notes .arrow_box {
225
- position: relative;
226
- background: #eee;
227
- border: 1px solid #ccc;
228
- }
229
- .installer-release-notes .arrow_box:after, .installer-release-notes .arrow_box:before {
230
- bottom: 100%;
231
- left: 50%;
232
- border: solid transparent;
233
- content: " ";
234
- height: 0;
235
- width: 0;
236
- position: absolute;
237
- pointer-events: none;
238
- }
239
-
240
- .installer-release-notes .arrow_box:after {
241
- border-color: rgba(238, 238, 238, 0);
242
- border-bottom-color: #eee;
243
- border-width: 16px;
244
- margin-left: -16px;
245
- }
246
- .installer-release-notes .arrow_box:before {
247
- border-color: rgba(204, 204, 204, 0);
248
- border-bottom-color: #ccc;
249
- border-width: 17px;
250
- margin-left: -17px;
251
- }
252
-
253
- .installer-release-notes .arrow_box div{
254
- margin-top:5px;
255
- padding: 10px;
256
- overflow-y: auto;
257
- max-height: 400px;
258
- }
259
-
260
- .otgs-is-dismissible {
261
- position: relative;
262
- padding-right: 38px;
263
- }
264
- .otgs-is-dismissible .notice-dismiss {
265
- text-decoration: none;
266
- }
267
- .otgs-is-dismissible p [class*="button-"] {
268
- margin: -5px 5px;
269
- }
270
-
271
- .otgsi_downloads_form{
272
- margin-top: 15px;
273
- }
274
-
275
- .spinner-with-text{
276
- padding-left: 25px;
277
- float:none;
278
- width: auto;
279
- }
280
- .installer-channel-update-ok{
281
- padding-left: 10px;
282
- display: none;
283
- color: #006600;
284
- }
285
- .installer-channel-update-fail{
286
- padding-left: 10px;
287
- display: none;
288
- color: #962722;
289
- }
290
-
291
- .otgs_wp_installer_table .installer-repository-image {
292
- padding: 8px 20px;
293
- }
1
+ .otgsi_site_key_form{
2
+ display:none;
3
+ /*display:inline;*/
4
+ }
5
+
6
+ .installer-status-installing, .installer-status-installed, .installer-status-updating, .installer-status-updated, .installer-status-activating, .installer-status-activated, .installer-status-success{
7
+ display: none;
8
+ }
9
+ .installer-status-installing{color: #FF9900; }
10
+ .installer-status-installed{color: #003300; font-weight: bold; }
11
+ .installer-status-updating{color: #FF9900; }
12
+ .installer-status-updated{color: #003300; font-weight: bold; }
13
+
14
+ .installer-status-installed .error-details:before,
15
+ .installer-status-updated .error-details:before{
16
+ content: "\f534";
17
+ font: 200 16px/1 dashicons;
18
+ vertical-align: text-bottom;
19
+ margin-left: 5px;
20
+ color: red;
21
+ cursor: help;
22
+ }
23
+
24
+ .installer-status-activating{color: #996666 }
25
+ .installer-status-activated{color: #333366; font-weight: bold; }
26
+
27
+ .js-status-success p{
28
+ color: #FF9900;
29
+ padding: 4px;
30
+ }
31
+
32
+ .installer-green-text{
33
+ color:#006600;
34
+ font-weight:bold;
35
+ }
36
+
37
+ .installer-red-text{
38
+ color:#b22121;
39
+ font-weight:bold;
40
+ }
41
+
42
+ .installer-footnote{
43
+ color:#3d5e69;
44
+ display:block;
45
+ float: left;
46
+ font-style: italic;
47
+ font-size: 90%;
48
+ }
49
+
50
+ .installer-products-list li{
51
+ display: inline;
52
+ margin-right: 20px;
53
+ }
54
+
55
+ .otgs_wp_installer_table a.disabled{
56
+ color:#888;
57
+ }
58
+
59
+ .otgs_wp_installer_subtable{
60
+ clear: both;
61
+ margin-left:-20px;
62
+ }
63
+ .otgs_wp_installer_subtable td p{
64
+ font-size: 92%;
65
+ }
66
+
67
+ .installer-status-error{
68
+ color: #f00;
69
+ }
70
+
71
+ .installer-status-note{
72
+ color: #6F6E6D;
73
+ font-style: italic;
74
+ }
75
+
76
+ .installer-warn-text{
77
+ color: #FF6400;
78
+ }
79
+
80
+ .installer-warn-box{
81
+ -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #FF6400;background-color:#df8a48;
82
+ color: #333;
83
+ padding: 5px;
84
+ }
85
+ .installer-warn-box span.details{
86
+ font-style: italic;
87
+ color:#777;
88
+ }
89
+
90
+ .installer-error-box{
91
+ color:#962722;
92
+ margin-top: 10px;
93
+ }
94
+ .installer-error-box p{
95
+ margin: 10px 0 10px 0;
96
+ -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #962722;background-color:#F5C8C6;
97
+ color: #333;
98
+ padding: 5px;
99
+ text-align: center;
100
+ }
101
+
102
+ .spinner-inline{
103
+ float: none;
104
+ display: inline-block;
105
+ visibility: visible;
106
+ }
107
+
108
+ .installer-q-icon:before{
109
+ content: '\f223' !important;
110
+ font-family: dashicons !important;
111
+ color: #f56e28;
112
+ font: 20px/1 "dashicons";
113
+ }
114
+
115
+ .installer-plugin-update-tr td{
116
+ padding-left:3px !important;
117
+ }
118
+
119
+ .otgsi_yellow_bg{
120
+ background-color: #f2f46b;
121
+ }
122
+
123
+ .otgs_wp_installer_table_compact{
124
+ width:480px;
125
+ border: solid 1px #999;
126
+ padding:10px;
127
+ border-radius: 5px;
128
+ }
129
+
130
+ .installer-plugins-list-compact{
131
+ background-color: #fff;
132
+ border-collapse: collapse;
133
+ border:solid 1px #C1DAD7;
134
+ width:100%;
135
+ }
136
+
137
+ .installer-plugins-list-compact tr th{
138
+ padding-top:3px;
139
+ background-color: #ccc;
140
+ }
141
+
142
+ .installer-plugins-list-compact tr{
143
+ background-color: #ddd;
144
+ }
145
+
146
+ .installer-plugins-list-compact tr.even{
147
+ background-color: #eee;
148
+ }
149
+
150
+ .installer-plugins-list-compact td{
151
+ padding:2px 5px 2px 5px;
152
+ border-right: 1px solid #C1DAD7;
153
+ border-bottom: 1px solid #C1DAD7;
154
+ }
155
+
156
+ .installer-plugins-list-compact td.twelve{
157
+ width:16px;
158
+ }
159
+
160
+ .otgs_wp_installer_table_compact .installer-status-downloading,
161
+ .otgs_wp_installer_table_compact .installer-status-downloaded,
162
+ .otgs_wp_installer_table_compact .installer-status-activating,
163
+ .otgs_wp_installer_table_compact .installer-status-activated{
164
+ display: none;
165
+ color:transparent; width: 12px; padding:2px;
166
+ }
167
+
168
+ .otgs_wp_installer_table_compact .installer-status-success,
169
+ .otgs_wp_installer_table_compact .installer-status-fail{
170
+ display: none;
171
+ }
172
+
173
+ .installer-status-success{
174
+ float: right;
175
+ color: #006600;
176
+ }
177
+
178
+ .otgs_wp_installer_table_compact .installer-status-downloading{background: url(../img/dn.gif) no-repeat center; }
179
+ .otgs_wp_installer_table_compact .installer-status-downloaded{background: url(../img/complete.png) no-repeat center;}
180
+ .otgs_wp_installer_table_compact .installer-status-activating{background: url(../img/dn.gif) no-repeat center; }
181
+ .otgs_wp_installer_table_compact .installer-status-activated{background: url(../img/complete.png) no-repeat center; }
182
+ .otgs_wp_installer_table_compact .installer-status-error{background: url(../img/icon_error.gif) no-repeat center; }
183
+
184
+ .installer_highlight{
185
+ color:#c5510b;
186
+ }
187
+
188
+ .installer_highlight_package{
189
+ background-color: #fff9c0;
190
+ }
191
+
192
+ .plugin_progress{
193
+ font-style: italic;
194
+ color: #777
195
+ }
196
+
197
+ .installer-download-progress-status{
198
+ display: none;
199
+ float:right;
200
+ color: #006600;
201
+ font-style: italic;
202
+ background: url('../img/spinner.gif') no-repeat;
203
+ padding-left:24px;
204
+ }
205
+
206
+ .installer-release-notes{
207
+ display: none;
208
+ }
209
+
210
+ .handle.extended:after{
211
+ content: "▾";
212
+ font-size: 24px;
213
+ vertical-align:bottom;
214
+ }
215
+ .installer-table-wrap a.handle:active,
216
+ .installer-table-wrap a.handle:focus{
217
+ outline:0;
218
+ border:none;
219
+ -moz-outline-style: none;
220
+ -webkit-box-shadow: none;
221
+ box-shadow: none;
222
+ }
223
+
224
+ .installer-release-notes .arrow_box {
225
+ position: relative;
226
+ background: #eee;
227
+ border: 1px solid #ccc;
228
+ }
229
+ .installer-release-notes .arrow_box:after, .installer-release-notes .arrow_box:before {
230
+ bottom: 100%;
231
+ left: 50%;
232
+ border: solid transparent;
233
+ content: " ";
234
+ height: 0;
235
+ width: 0;
236
+ position: absolute;
237
+ pointer-events: none;
238
+ }
239
+
240
+ .installer-release-notes .arrow_box:after {
241
+ border-color: rgba(238, 238, 238, 0);
242
+ border-bottom-color: #eee;
243
+ border-width: 16px;
244
+ margin-left: -16px;
245
+ }
246
+ .installer-release-notes .arrow_box:before {
247
+ border-color: rgba(204, 204, 204, 0);
248
+ border-bottom-color: #ccc;
249
+ border-width: 17px;
250
+ margin-left: -17px;
251
+ }
252
+
253
+ .installer-release-notes .arrow_box div{
254
+ margin-top:5px;
255
+ padding: 10px;
256
+ overflow-y: auto;
257
+ max-height: 400px;
258
+ }
259
+
260
+ .otgs-is-dismissible {
261
+ position: relative;
262
+ padding-right: 38px;
263
+ }
264
+ .otgs-is-dismissible .notice-dismiss {
265
+ text-decoration: none;
266
+ }
267
+ .otgs-is-dismissible p [class*="button-"] {
268
+ margin: -5px 5px;
269
+ }
270
+
271
+ .otgsi_downloads_form{
272
+ margin-top: 15px;
273
+ }
274
+
275
+ .spinner-with-text{
276
+ padding-left: 25px;
277
+ float:none;
278
+ width: auto;
279
+ }
280
+ .installer-channel-update-ok{
281
+ padding-left: 10px;
282
+ display: none;
283
+ color: #006600;
284
+ }
285
+ .installer-channel-update-fail{
286
+ padding-left: 10px;
287
+ display: none;
288
+ color: #962722;
289
+ }
290
+
291
+ .otgs_wp_installer_table .installer-repository-image {
292
+ padding: 8px 20px;
293
+ }
vendor/otgs/installer/res/js/admin.js CHANGED
@@ -1,461 +1,461 @@
1
-
2
-
3
- var otgs_wp_installer = {
4
-
5
- plugins_update_XHR :{},
6
-
7
- init: function(){
8
-
9
- jQuery('.otgs_wp_installer_table').on('click', '.enter_site_key_js', otgs_wp_installer.show_site_key_form);
10
- jQuery('.otgs_wp_installer_table').on('click', '.cancel_site_key_js', otgs_wp_installer.hide_site_key_form);
11
-
12
- jQuery('.otgs_wp_installer_table').on('click', '.remove_site_key_js', otgs_wp_installer.remove_site_key);
13
- jQuery('.otgs_wp_installer_table').on('click', '.update_site_key_js', otgs_wp_installer.update_site_key);
14
-
15
- jQuery('.otgs_wp_installer_table').on('submit', '.otgsi_site_key_form', otgs_wp_installer.save_site_key);
16
- jQuery('.otgs_wp_installer_table').on('submit', '.otgsi_downloads_form', otgs_wp_installer.download_downloads);
17
- jQuery('.otgs_wp_installer_table').on('change', '.otgsi_downloads_form :checkbox[name="downloads[]"]', otgs_wp_installer.update_downloads_form);
18
-
19
- jQuery('.installer-dismiss-nag').click(otgs_wp_installer.dismiss_nag);
20
-
21
- jQuery('.otgs_wp_installer_table').on('click', '.installer_expand_button', otgs_wp_installer.toggle_subpackages);
22
-
23
- otgs_wp_installer.scroll_to_repository();
24
-
25
- if( typeof pagenow != 'undefined' && pagenow == 'plugins'){
26
-
27
- jQuery(document).ajaxSuccess(function(event, xhr, settings) {
28
- var data = otgs_wp_installer.getQueryParameters(settings.data);
29
- if(typeof data.action != 'undefined' && data.action == 'update-plugin'){
30
- response = xhr.responseJSON.data;
31
- if(typeof response.error != 'undefined'){
32
- var default_error = jQuery('#' + response.slug + '-update .update-message').html();
33
- jQuery('#' + response.slug + '-update .update-message').html(default_error + ' &raquo;<span class="installer-red-text"> ' + response.error + '</span>');
34
- }
35
- }
36
- return false;
37
- });
38
-
39
- }
40
-
41
- if( typeof pagenow != 'undefined' && pagenow == 'plugin-install' ){
42
- jQuery( '.plugin-install-tab-commercial .search-plugins' ).remove();
43
- }
44
-
45
- jQuery('.installer-table-wrap').on('click', '.js-release-notes', otgs_wp_installer.toggle_release_notes);
46
- },
47
-
48
- getQueryParameters : function(str) {
49
- return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
50
- },
51
-
52
- reset_errors: function(){
53
- jQuery('.installer-error-box').html('').hide();
54
- },
55
-
56
- show_error: function(repo, text){
57
- jQuery('#installer_repo_' + repo).find('.installer-error-box').html(text).show();
58
- },
59
-
60
- show_site_key_form: function(){
61
-
62
- if( jQuery(this).hasClass('disabled') ) {
63
- alert( jQuery(this).attr('title') );
64
- return false;
65
- }
66
-
67
- otgs_wp_installer.reset_errors();
68
-
69
- var form = jQuery(this).parent().find('form.otgsi_site_key_form');
70
- jQuery(this).prev().hide();
71
- jQuery(this).hide();
72
- form.css('display', 'inline');
73
- form.find('input[name^=site_key_]').focus().val('');
74
- form.find('input').removeAttr('disabled');
75
-
76
- form.closest('.otgsi_register_product_wrap').addClass('otgsi_yellow_bg');
77
-
78
- return false;
79
- },
80
-
81
- hide_site_key_form: function(){
82
- var form = jQuery(this).closest('form');
83
- form.hide();
84
- form.parent().find('.enter_site_key_js').show();
85
- form.parent().find('.enter_site_key_js').prev().show();
86
-
87
- form.closest('.otgsi_register_product_wrap').removeClass('otgsi_yellow_bg');
88
- otgs_wp_installer.reset_errors();
89
- return false;
90
- },
91
-
92
- save_site_key: function(){
93
-
94
- var thisf = jQuery(this);
95
- var data = jQuery(this).serialize();
96
- jQuery(this).find('input').attr('disabled', 'disabled');
97
-
98
- var spinner = jQuery('<span class="spinner"></span>');
99
- spinner.css({display: 'inline-block', float: 'none'}).prependTo(jQuery(this));
100
-
101
- otgs_wp_installer.reset_errors();
102
-
103
- jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
104
- function(ret){
105
- if(!ret.error){
106
- otgs_wp_installer.saved_site_key();
107
- }else{
108
- otgs_wp_installer.show_error(thisf.find('[name=repository_id]').val(), ret.error);
109
- thisf.find('input').removeAttr('disabled');
110
- }
111
-
112
- if(typeof ret.debug != 'undefined'){
113
- thisf.append('<textarea style="width:100%" rows="20">' + ret.debug + '</textarea>');
114
- }
115
-
116
- spinner.remove();
117
- }
118
- });
119
-
120
- return false;
121
-
122
- },
123
-
124
- saved_site_key: function(){
125
- location.reload();
126
- },
127
-
128
- remove_site_key: function(){
129
-
130
- if( jQuery(this).attr('disabled') == 'disabled' ){
131
-
132
- alert( jQuery(this).attr('title') );
133
- return false;
134
-
135
- } else {
136
-
137
- if(confirm(jQuery(this).data('confirmation'))){
138
-
139
- jQuery('<span class="spinner"></span>').css({visibility: 'visible', float: 'none'}).prependTo(jQuery(this).parent());
140
- data = {action: 'remove_site_key', repository_id: jQuery(this).data('repository'), nonce: jQuery(this).data('nonce')}
141
- jQuery.ajax({url: ajaxurl, type: 'POST', data: data, success: otgs_wp_installer.removed_site_key});
142
- }
143
-
144
- }
145
-
146
- return false;
147
- },
148
-
149
- removed_site_key: function(){
150
- location.reload();
151
- },
152
-
153
- update_site_key: function(){
154
- var error_wrap = jQuery(this).closest('.otgsi_register_product_wrap').find('.installer-error-box');
155
- error_wrap.html('');
156
-
157
- var spinner = jQuery('<span class="spinner"></span>');
158
-
159
- spinner.css({visibility: 'visible', float: 'none'}).prependTo(jQuery(this).parent());
160
- data = {action: 'update_site_key', repository_id: jQuery(this).data('repository'), nonce: jQuery(this).data('nonce')}
161
- jQuery.ajax({
162
- url: ajaxurl,
163
- type: 'POST',
164
- data: data,
165
- dataType: 'json',
166
- complete: function( event, xhr, settings ){
167
- var error = '';
168
- if(xhr == 'success') {
169
- var ret = event.responseJSON;
170
- if(ret.error){
171
- error = ret.error;
172
- }else{
173
- otgs_wp_installer.updated_site_key(ret);
174
- }
175
- }else{
176
- error = 'Error processing request (' + xhr + '). Please try again!';
177
- }
178
-
179
- if( error ){
180
- error_wrap.html('<p>' + error + '</p>').show();
181
- spinner.remove();
182
- }
183
-
184
- }
185
- });
186
-
187
- return false;
188
-
189
- },
190
-
191
- updated_site_key: function(ret){
192
- location.reload();
193
- },
194
-
195
- update_downloads_form: function(){
196
-
197
- var checked = jQuery('.otgsi_downloads_form :checkbox:checked[name="downloads[]"]').length;
198
-
199
- if(checked){
200
- jQuery(this).closest('form').find(':submit, :checkbox[name=activate]').removeAttr('disabled');
201
- }else{
202
- jQuery(this).closest('form').find(':submit, :checkbox[name=activate]').attr('disabled', 'disabled');
203
- }
204
-
205
-
206
- },
207
-
208
- download_downloads: function(){
209
-
210
- var activate = jQuery(this).find(":checkbox:checked[name=activate]").val(),
211
- action_button = jQuery(this).find('input[type="submit"]');
212
- downloads_form = jQuery(this),
213
- idx = 0,
214
- checkboxes = [];
215
-
216
- jQuery(this).find(':checkbox:checked[name="downloads[]"]').each(function(){
217
- if(jQuery(this).attr('disabled')) return;
218
- checkboxes[idx] = jQuery(this);
219
- idx++;
220
- jQuery(this).attr('disabled', 'disabled');
221
- });
222
-
223
- idx = 0;
224
-
225
- if( typeof checkboxes[idx] != 'undefined' ){
226
- download_and_activate( checkboxes[idx] );
227
- action_button.attr('disabled', 'disabled');
228
- }
229
-
230
- function download_and_activate( elem ){
231
-
232
- var this_tr = elem.closest('tr');
233
- var is_update = this_tr.find('.installer-red-text').length;
234
- if(is_update){
235
- var installing = this_tr.find('.installer-status-updating');
236
- var installed = this_tr.find('.installer-status-updated');
237
- }else{
238
- var installing = this_tr.find('.installer-status-installing');
239
- var installed = this_tr.find('.installer-status-installed');
240
-
241
- }
242
- if(activate){
243
- var activating = this_tr.find('.installer-status-activating');
244
- var activated = this_tr.find('.installer-status-activated');
245
- }
246
-
247
- if( this_tr.find('.for_spinner_js .spinner').length > 0 ){
248
- var spinner = this_tr.find('.for_spinner_js .spinner');
249
- }else{
250
- var spinner = this_tr.find('.installer-status-downloading');
251
- }
252
-
253
- otgs_wp_installer.reset_errors();
254
- downloads_form.find('div.installer-status-success').hide();
255
- spinner.css('visibility', 'visible');
256
- installing.show();
257
-
258
- var plugin_name = this_tr.find('.installer_plugin_name').html();
259
- if(is_update){
260
- otgs_wp_installer.show_download_progress_status(downloads_form, installer_strings.updating.replace('%s', plugin_name));
261
- }else{
262
- otgs_wp_installer.show_download_progress_status(downloads_form, installer_strings.installing.replace('%s', plugin_name));
263
- }
264
-
265
-
266
- data = {
267
- action: 'installer_download_plugin',
268
- data: elem.val(),
269
- activate: activate,
270
- reset_to_channel: downloads_form.find('input[name="reset-to-channel"]').val()
271
- }
272
-
273
- otgs_wp_installer.plugins_update_XHR = jQuery.ajax({
274
- url: ajaxurl,
275
- type: 'POST',
276
- dataType: 'json',
277
- data: data,
278
- success: function(ret){
279
- installing.hide();
280
-
281
- if(!ret.success){
282
- installed.addClass('installer-status-error');
283
- installed.html(
284
- installed.data('fail') +
285
- '<a class="error-details" href="#" title="' + ret.message + '"></a>'
286
- );
287
-
288
- if(ret.message){
289
- installed.closest('.otgs_wp_installer_table')
290
- .find('.installer-error-box')
291
- .html('<p>' + ret.message + '</p>')
292
- .show();
293
- }else{
294
- installed.closest('.otgs_wp_installer_table')
295
- .find('.installer-error-box')
296
- .html('<p>' + downloads_form.find('.installer-revalidate-message').html() + '</p>')
297
- .show();
298
- }
299
-
300
- downloads_form.trigger('installer-update-fail');
301
- }
302
-
303
- installed.show();
304
- spinner.fadeOut();
305
-
306
- if(ret.version){
307
- var updated_version = '<span class="installer-green-text">' + ret.version + '</span>';
308
- if( ret.non_stable ){
309
- updated_version += ' (' + ret.non_stable + ')';
310
- }
311
- this_tr.find('.installer_version_installed').html(updated_version);
312
- }
313
-
314
- if(ret.success && activate){
315
-
316
- otgs_wp_installer.show_download_progress_status(downloads_form, installer_strings.activating.replace('%s', plugin_name));
317
- activating.show();
318
- spinner.show();
319
- this_tr.find('.installer-red-text').removeClass('installer-red-text').addClass('installer-green-text').html(ret.version);
320
-
321
- jQuery.ajax({
322
- url: ajaxurl,
323
- type: 'POST',
324
- dataType: 'json',
325
- data: {action: 'installer_activate_plugin', plugin_id: ret.plugin_id, nonce: ret.nonce},
326
- success: function(ret){
327
- activating.hide();
328
- if(!ret.error ){
329
- activated.show();
330
- }
331
-
332
- spinner.fadeOut();
333
-
334
- idx++;
335
- if( typeof checkboxes[idx] != 'undefined' ){
336
- download_and_activate( checkboxes[idx] );
337
- }else{
338
- otgs_wp_installer.hide_download_progress_status(downloads_form);
339
- downloads_form.find('div.installer-status-success').show();
340
- action_button.removeAttr('disabled');
341
-
342
- downloads_form.trigger('installer-update-complete');
343
- }
344
- }
345
- });
346
- }else{
347
- idx++;
348
- if( typeof checkboxes[idx] != 'undefined' ){
349
- download_and_activate( checkboxes[idx] );
350
- }else{
351
- otgs_wp_installer.hide_download_progress_status(downloads_form);
352
- downloads_form.find('div.installer-status-success').show();
353
- action_button.removeAttr('disabled');
354
-
355
- downloads_form.trigger('installer-update-complete');
356
-
357
- }
358
- }
359
- }
360
-
361
- });
362
-
363
- };
364
-
365
- return false;
366
- },
367
-
368
- show_download_progress_status: function(downloads_form, text){
369
-
370
- downloads_form.find('.installer-download-progress-status').html(text).fadeIn();
371
-
372
- },
373
-
374
- hide_download_progress_status: function(downloads_form){
375
-
376
- downloads_form.find('.installer-download-progress-status').html('').fadeOut();
377
-
378
- },
379
-
380
- dismiss_nag: function(){
381
-
382
- var thisa = jQuery(this);
383
-
384
- data = {action: 'installer_dismiss_nag', repository: jQuery(this).data('repository')}
385
-
386
- jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
387
- function(ret){
388
- thisa.closest('.otgs-is-dismissible').remove();
389
- }
390
- });
391
-
392
- return false;
393
- },
394
-
395
- toggle_subpackages: function(){
396
- var list = jQuery(this).closest('td').find('.otgs_wp_installer_subtable');
397
-
398
- if(list.is(':visible')){
399
- list.slideUp('fast');
400
- }else{
401
- list.slideDown('fast');
402
- }
403
-
404
-
405
- return false;
406
-
407
- },
408
-
409
- scroll_to_repository: function(){
410
-
411
- var ref = window.location.hash.replace('#', '');
412
-
413
- if(ref) {
414
- var split = ref.split('/');
415
- var repo = split[0];
416
-
417
- if(typeof split[1] != 'undefined'){
418
- var package = split[1];
419
- var repo_element = jQuery('#repository-' + repo);
420
-
421
-
422
-
423
- if(repo_element.length){
424
-
425
- jQuery('html, body').animate({
426
- scrollTop: repo_element.offset().top
427
- }, 1000);
428
-
429
- var package_element = jQuery('#repository-' + repo +'_' + package);
430
-
431
- if(package_element.length && !package_element.is(':visible')){
432
- package_element.parents('.otgs_wp_installer_subtable').slideDown();
433
- package_element.addClass('installer_highlight_package');
434
- }
435
-
436
- package_element.find('.button-secondary').removeClass('button-secondary').addClass('button-primary');
437
- }
438
- }
439
-
440
- }
441
-
442
- },
443
-
444
- toggle_release_notes: function(){
445
- var handle = jQuery(this);
446
- var tr = handle.closest('tr');
447
- if( tr.next('.installer-release-notes').is(':visible') ){
448
- handle.removeClass('extended');
449
- }else{
450
- handle.addClass('extended');
451
- }
452
- tr.next('.installer-release-notes').fadeToggle();
453
-
454
- return false;
455
- }
456
-
457
-
458
- }
459
-
460
-
461
  jQuery(document).ready(otgs_wp_installer.init);
1
+
2
+
3
+ var otgs_wp_installer = {
4
+
5
+ plugins_update_XHR :{},
6
+
7
+ init: function(){
8
+
9
+ jQuery('.otgs_wp_installer_table').on('click', '.enter_site_key_js', otgs_wp_installer.show_site_key_form);
10
+ jQuery('.otgs_wp_installer_table').on('click', '.cancel_site_key_js', otgs_wp_installer.hide_site_key_form);
11
+
12
+ jQuery('.otgs_wp_installer_table').on('click', '.remove_site_key_js', otgs_wp_installer.remove_site_key);
13
+ jQuery('.otgs_wp_installer_table').on('click', '.update_site_key_js', otgs_wp_installer.update_site_key);
14
+
15
+ jQuery('.otgs_wp_installer_table').on('submit', '.otgsi_site_key_form', otgs_wp_installer.save_site_key);
16
+ jQuery('.otgs_wp_installer_table').on('submit', '.otgsi_downloads_form', otgs_wp_installer.download_downloads);
17
+ jQuery('.otgs_wp_installer_table').on('change', '.otgsi_downloads_form :checkbox[name="downloads[]"]', otgs_wp_installer.update_downloads_form);
18
+
19
+ jQuery('.installer-dismiss-nag').click(otgs_wp_installer.dismiss_nag);
20
+
21
+ jQuery('.otgs_wp_installer_table').on('click', '.installer_expand_button', otgs_wp_installer.toggle_subpackages);
22
+
23
+ otgs_wp_installer.scroll_to_repository();
24
+
25
+ if( typeof pagenow != 'undefined' && pagenow == 'plugins'){
26
+
27
+ jQuery(document).ajaxSuccess(function(event, xhr, settings) {
28
+ var data = otgs_wp_installer.getQueryParameters(settings.data);
29
+ if(typeof data.action != 'undefined' && data.action == 'update-plugin'){
30
+ response = xhr.responseJSON.data;
31
+ if(typeof response.error != 'undefined'){
32
+ var default_error = jQuery('#' + response.slug + '-update .update-message').html();
33
+ jQuery('#' + response.slug + '-update .update-message').html(default_error + ' &raquo;<span class="installer-red-text"> ' + response.error + '</span>');
34
+ }
35
+ }
36
+ return false;
37
+ });
38
+
39
+ }
40
+
41
+ if( typeof pagenow != 'undefined' && pagenow == 'plugin-install' ){
42
+ jQuery( '.plugin-install-tab-commercial .search-plugins' ).remove();
43
+ }
44
+
45
+ jQuery('.installer-table-wrap').on('click', '.js-release-notes', otgs_wp_installer.toggle_release_notes);
46
+ },
47
+
48
+ getQueryParameters : function(str) {
49
+ return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
50
+ },
51
+
52
+ reset_errors: function(){
53
+ jQuery('.installer-error-box').html('').hide();
54
+ },
55
+
56
+ show_error: function(repo, text){
57
+ jQuery('#installer_repo_' + repo).find('.installer-error-box').html(text).show();
58
+ },
59
+
60
+ show_site_key_form: function(){
61
+
62
+ if( jQuery(this).hasClass('disabled') ) {
63
+ alert( jQuery(this).attr('title') );
64
+ return false;
65
+ }
66
+
67
+ otgs_wp_installer.reset_errors();
68
+
69
+ var form = jQuery(this).parent().find('form.otgsi_site_key_form');
70
+ jQuery(this).prev().hide();
71
+ jQuery(this).hide();
72
+ form.css('display', 'inline');
73
+ form.find('input[name^=site_key_]').focus().val('');
74
+ form.find('input').removeAttr('disabled');
75
+
76
+ form.closest('.otgsi_register_product_wrap').addClass('otgsi_yellow_bg');
77
+
78
+ return false;
79
+ },
80
+
81
+ hide_site_key_form: function(){
82
+ var form = jQuery(this).closest('form');
83
+ form.hide();
84
+ form.parent().find('.enter_site_key_js').show();
85
+ form.parent().find('.enter_site_key_js').prev().show();
86
+
87
+ form.closest('.otgsi_register_product_wrap').removeClass('otgsi_yellow_bg');
88
+ otgs_wp_installer.reset_errors();
89
+ return false;
90
+ },
91
+
92
+ save_site_key: function(){
93
+
94
+ var thisf = jQuery(this);
95
+ var data = jQuery(this).serialize();
96
+ jQuery(this).find('input').attr('disabled', 'disabled');
97
+
98
+ var spinner = jQuery('<span class="spinner"></span>');
99
+ spinner.css({display: 'inline-block', float: 'none'}).prependTo(jQuery(this));
100
+
101
+ otgs_wp_installer.reset_errors();
102
+
103
+ jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
104
+ function(ret){
105
+ if(!ret.error){
106
+ otgs_wp_installer.saved_site_key();
107
+ }else{
108
+ otgs_wp_installer.show_error(thisf.find('[name=repository_id]').val(), ret.error);
109
+ thisf.find('input').removeAttr('disabled');
110
+ }
111
+
112
+ if(typeof ret.debug != 'undefined'){
113
+ thisf.append('<textarea style="width:100%" rows="20">' + ret.debug + '</textarea>');
114
+ }
115
+
116
+ spinner.remove();
117
+ }
118
+ });
119
+
120
+ return false;
121
+
122
+ },
123
+
124
+ saved_site_key: function(){
125
+ location.reload();
126
+ },
127
+
128
+ remove_site_key: function(){
129
+
130
+ if( jQuery(this).attr('disabled') == 'disabled' ){
131
+
132
+ alert( jQuery(this).attr('title') );
133
+ return false;
134
+
135
+ } else {
136
+
137
+ if(confirm(jQuery(this).data('confirmation'))){
138
+
139
+ jQuery('<span class="spinner"></span>').css({visibility: 'visible', float: 'none'}).prependTo(jQuery(this).parent());
140
+ data = {action: 'remove_site_key', repository_id: jQuery(this).data('repository'), nonce: jQuery(this).data('nonce')}
141
+ jQuery.ajax({url: ajaxurl, type: 'POST', data: data, success: otgs_wp_installer.removed_site_key});
142
+ }
143
+
144
+ }
145
+
146
+ return false;
147
+ },
148
+
149
+ removed_site_key: function(){
150
+ location.reload();
151
+ },
152
+
153
+ update_site_key: function(){
154
+ var error_wrap = jQuery(this).closest('.otgsi_register_product_wrap').find('.installer-error-box');
155
+ error_wrap.html('');
156
+
157
+ var spinner = jQuery('<span class="spinner"></span>');
158
+
159
+ spinner.css({visibility: 'visible', float: 'none'}).prependTo(jQuery(this).parent());
160
+ data = {action: 'update_site_key', repository_id: jQuery(this).data('repository'), nonce: jQuery(this).data('nonce')}
161
+ jQuery.ajax({
162
+ url: ajaxurl,
163
+ type: 'POST',
164
+ data: data,
165
+ dataType: 'json',
166
+ complete: function( event, xhr, settings ){
167
+ var error = '';
168
+ if(xhr == 'success') {
169
+ var ret = event.responseJSON;
170
+ if(ret.error){
171
+ error = ret.error;
172
+ }else{
173
+ otgs_wp_installer.updated_site_key(ret);
174
+ }
175
+ }else{
176
+ error = 'Error processing request (' + xhr + '). Please try again!';
177
+ }
178
+
179
+ if( error ){
180
+ error_wrap.html('<p>' + error + '</p>').show();
181
+ spinner.remove();
182
+ }
183
+
184
+ }
185
+ });
186
+
187
+ return false;
188
+
189
+ },
190
+
191
+ updated_site_key: function(ret){
192
+ location.reload();
193
+ },
194
+
195
+ update_downloads_form: function(){
196
+
197
+ var checked = jQuery('.otgsi_downloads_form :checkbox:checked[name="downloads[]"]').length;
198
+
199
+ if(checked){
200
+ jQuery(this).closest('form').find(':submit, :checkbox[name=activate]').removeAttr('disabled');
201
+ }else{
202
+ jQuery(this).closest('form').find(':submit, :checkbox[name=activate]').attr('disabled', 'disabled');
203
+ }
204
+
205
+
206
+ },
207
+
208
+ download_downloads: function(){
209
+
210
+ var activate = jQuery(this).find(":checkbox:checked[name=activate]").val(),
211
+ action_button = jQuery(this).find('input[type="submit"]');
212
+ downloads_form = jQuery(this),
213
+ idx = 0,
214
+ checkboxes = [];
215
+
216
+ jQuery(this).find(':checkbox:checked[name="downloads[]"]').each(function(){
217
+ if(jQuery(this).attr('disabled')) return;
218
+ checkboxes[idx] = jQuery(this);
219
+ idx++;
220
+ jQuery(this).attr('disabled', 'disabled');
221
+ });
222
+
223
+ idx = 0;
224
+
225
+ if( typeof checkboxes[idx] != 'undefined' ){
226
+ download_and_activate( checkboxes[idx] );
227
+ action_button.attr('disabled', 'disabled');
228
+ }
229
+
230
+ function download_and_activate( elem ){
231
+
232
+ var this_tr = elem.closest('tr');
233
+ var is_update = this_tr.find('.installer-red-text').length;
234
+ if(is_update){
235
+ var installing = this_tr.find('.installer-status-updating');
236
+ var installed = this_tr.find('.installer-status-updated');
237
+ }else{
238
+ var installing = this_tr.find('.installer-status-installing');
239
+ var installed = this_tr.find('.installer-status-installed');
240
+
241
+ }
242
+ if(activate){
243
+ var activating = this_tr.find('.installer-status-activating');
244
+ var activated = this_tr.find('.installer-status-activated');
245
+ }
246
+
247
+ if( this_tr.find('.for_spinner_js .spinner').length > 0 ){
248
+ var spinner = this_tr.find('.for_spinner_js .spinner');
249
+ }else{
250
+ var spinner = this_tr.find('.installer-status-downloading');
251
+ }
252
+
253
+ otgs_wp_installer.reset_errors();
254
+ downloads_form.find('div.installer-status-success').hide();
255
+ spinner.css('visibility', 'visible');
256
+ installing.show();
257
+
258
+ var plugin_name = this_tr.find('.installer_plugin_name').html();
259
+ if(is_update){
260
+ otgs_wp_installer.show_download_progress_status(downloads_form, installer_strings.updating.replace('%s', plugin_name));
261
+ }else{
262
+ otgs_wp_installer.show_download_progress_status(downloads_form, installer_strings.installing.replace('%s', plugin_name));
263
+ }
264
+
265
+
266
+ data = {
267
+ action: 'installer_download_plugin',
268
+ data: elem.val(),
269
+ activate: activate,
270
+ reset_to_channel: downloads_form.find('input[name="reset-to-channel"]').val()
271
+ }
272
+
273
+ otgs_wp_installer.plugins_update_XHR = jQuery.ajax({
274
+ url: ajaxurl,
275
+ type: 'POST',
276
+ dataType: 'json',
277
+ data: data,
278
+ success: function(ret){
279
+ installing.hide();
280
+
281
+ if(!ret.success){
282
+ installed.addClass('installer-status-error');
283
+ installed.html(
284
+ installed.data('fail') +
285
+ '<a class="error-details" href="#" title="' + ret.message + '"></a>'
286
+ );
287
+
288
+ if(ret.message){
289
+ installed.closest('.otgs_wp_installer_table')
290
+ .find('.installer-error-box')
291
+ .html('<p>' + ret.message + '</p>')
292
+ .show();
293
+ }else{
294
+ installed.closest('.otgs_wp_installer_table')
295
+ .find('.installer-error-box')
296
+ .html('<p>' + downloads_form.find('.installer-revalidate-message').html() + '</p>')
297
+ .show();
298
+ }
299
+
300
+ downloads_form.trigger('installer-update-fail');
301
+ }
302
+
303
+ installed.show();
304
+ spinner.fadeOut();
305
+
306
+ if(ret.version){
307
+ var updated_version = '<span class="installer-green-text">' + ret.version + '</span>';
308
+ if( ret.non_stable ){
309
+ updated_version += ' (' + ret.non_stable + ')';
310
+ }
311
+ this_tr.find('.installer_version_installed').html(updated_version);
312
+ }
313
+
314
+ if(ret.success && activate){
315
+
316
+ otgs_wp_installer.show_download_progress_status(downloads_form, installer_strings.activating.replace('%s', plugin_name));
317
+ activating.show();
318
+ spinner.show();
319
+ this_tr.find('.installer-red-text').removeClass('installer-red-text').addClass('installer-green-text').html(ret.version);
320
+
321
+ jQuery.ajax({
322
+ url: ajaxurl,
323
+ type: 'POST',
324
+ dataType: 'json',
325
+ data: {action: 'installer_activate_plugin', plugin_id: ret.plugin_id, nonce: ret.nonce},
326
+ success: function(ret){
327
+ activating.hide();
328
+ if(!ret.error ){
329
+ activated.show();
330
+ }
331
+
332
+ spinner.fadeOut();
333
+
334
+ idx++;
335
+ if( typeof checkboxes[idx] != 'undefined' ){
336
+ download_and_activate( checkboxes[idx] );
337
+ }else{
338
+ otgs_wp_installer.hide_download_progress_status(downloads_form);
339
+ downloads_form.find('div.installer-status-success').show();
340
+ action_button.removeAttr('disabled');
341
+
342
+ downloads_form.trigger('installer-update-complete');
343
+ }
344
+ }
345
+ });
346
+ }else{
347
+ idx++;
348
+ if( typeof checkboxes[idx] != 'undefined' ){
349
+ download_and_activate( checkboxes[idx] );
350
+ }else{
351
+ otgs_wp_installer.hide_download_progress_status(downloads_form);
352
+ downloads_form.find('div.installer-status-success').show();
353
+ action_button.removeAttr('disabled');
354
+
355
+ downloads_form.trigger('installer-update-complete');
356
+
357
+ }
358
+ }
359
+ }
360
+
361
+ });
362
+
363
+ };
364
+
365
+ return false;
366
+ },
367
+
368
+ show_download_progress_status: function(downloads_form, text){
369
+
370
+ downloads_form.find('.installer-download-progress-status').html(text).fadeIn();
371
+
372
+ },
373
+
374
+ hide_download_progress_status: function(downloads_form){
375
+
376
+ downloads_form.find('.installer-download-progress-status').html('').fadeOut();
377
+
378
+ },
379
+
380
+ dismiss_nag: function(){
381
+
382
+ var thisa = jQuery(this);
383
+
384
+ data = {action: 'installer_dismiss_nag', repository: jQuery(this).data('repository')}
385
+
386
+ jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
387
+ function(ret){
388
+ thisa.closest('.otgs-is-dismissible').remove();
389
+ }
390
+ });
391
+
392
+ return false;
393
+ },
394
+
395
+ toggle_subpackages: function(){
396
+ var list = jQuery(this).closest('td').find('.otgs_wp_installer_subtable');
397
+
398
+ if(list.is(':visible')){
399
+ list.slideUp('fast');
400
+ }else{
401
+ list.slideDown('fast');
402
+ }
403
+
404
+
405
+ return false;
406
+
407
+ },
408
+
409
+ scroll_to_repository: function(){
410
+
411
+ var ref = window.location.hash.replace('#', '');
412
+
413
+ if(ref) {
414
+ var split = ref.split('/');
415
+ var repo = split[0];
416
+
417
+ if(typeof split[1] != 'undefined'){
418
+ var package = split[1];
419
+ var repo_element = jQuery('#repository-' + repo);
420
+
421
+
422
+
423
+ if(repo_element.length){
424
+
425
+ jQuery('html, body').animate({
426
+ scrollTop: repo_element.offset().top
427
+ }, 1000);
428
+
429
+ var package_element = jQuery('#repository-' + repo +'_' + package);
430
+
431
+ if(package_element.length && !package_element.is(':visible')){
432
+ package_element.parents('.otgs_wp_installer_subtable').slideDown();
433
+ package_element.addClass('installer_highlight_package');
434
+ }
435
+
436
+ package_element.find('.button-secondary').removeClass('button-secondary').addClass('button-primary');
437
+ }
438
+ }
439
+
440
+ }
441
+
442
+ },
443
+
444
+ toggle_release_notes: function(){
445
+ var handle = jQuery(this);
446
+ var tr = handle.closest('tr');
447
+ if( tr.next('.installer-release-notes').is(':visible') ){
448
+ handle.removeClass('extended');
449
+ }else{
450
+ handle.addClass('extended');
451
+ }
452
+ tr.next('.installer-release-notes').fadeToggle();
453
+
454
+ return false;
455
+ }
456
+
457
+
458
+ }
459
+
460
+
461
  jQuery(document).ready(otgs_wp_installer.init);
vendor/otgs/installer/res/js/channels.js CHANGED
@@ -1,261 +1,261 @@
1
- (function($){
2
-
3
- var updateErrors = [];
4
- var channelUpdateInProgress = false;
5
-
6
- function channelSelectorInit(){
7
-
8
- $('.otgs_wp_installer_table')
9
- .on('focus', '.installer-channel-selector', saveCurrentValue)
10
- .on('change', '.installer-channel-selector', maybeShowPrompt);
11
-
12
- $('.otgs_wp_installer_table')
13
- .on('click', '.installer-channel-retry', retryChannelSwitch)
14
-
15
- $('.installer-switch-confirmation')
16
- .on('click', '.js-cancel', cancelSwitch)
17
- .on('click', '.js-proceed', changeChannel);
18
-
19
- $('.otgsi_downloads_form').on('installer-update-complete', maybeShowWarn);
20
- $('.otgsi_downloads_form').on('installer-update-complete', hideUpdateProgress);
21
-
22
- $('.otgsi_downloads_form').on('installer-update-complete', showConfirmationMessage);
23
-
24
- $('.otgsi_downloads_form').on('installer-update-fail', logUpdateError);
25
-
26
- }
27
-
28
- function saveCurrentValue(){
29
- $(this).data('previous-value', $(this).val());
30
- }
31
-
32
- function maybeShowPrompt(){
33
- var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
34
- var prompt = selectorContainer.find('.installer-switch-confirmation:hidden');
35
-
36
- if(prompt.length){
37
- prompt.show();
38
- selectorContainer.find('select').prop('disabled', true);
39
- var warnText = selectorContainer.find('.installer-warn-text');
40
- warnText.hide();
41
- }else{
42
- changeChannel(selectorContainer);
43
- }
44
-
45
- }
46
-
47
- function changeChannel(selectorContainer){
48
-
49
- if(selectorContainer.type == 'click'){
50
- var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
51
- }
52
-
53
- var select = selectorContainer.find('select');
54
- select.prop('disabled', true);
55
-
56
- hideConfirmationMessage(select);
57
- showUpdateProgress(select);
58
-
59
- selectorContainer.find('.installer-switch-confirmation').hide();
60
-
61
- var data = {
62
- action: 'installer_set_channel',
63
- repository_id: select.data('repository-id'),
64
- channel: select.val(),
65
- nonce: select.parent().find('.nonce').val(),
66
- noprompt: selectorContainer.find('.js-remember').length ?
67
- selectorContainer.find('.js-remember').attr('checked') == 'checked' : 0
68
- }
69
-
70
- resetUpdateErrors();
71
- otgs_wp_installer.reset_errors();
72
- channelUpdateInProgress = true;
73
-
74
- // save selection
75
- jQuery.ajax({
76
- url: ajaxurl,
77
- type: 'POST',
78
- dataType: 'json',
79
- data: data,
80
- success: function (ret) {
81
- if( ret.status == 'OK'){
82
- var tableSelector = '#installer_repo_' + select.data('repository-id') + ' .installer-table-wrap';
83
- $(tableSelector).load( location.href + ' ' + tableSelector + ' table.widefat', function(){
84
-
85
- var upgradesCount = $(tableSelector).find('tr .installer-red-text').length
86
- || select.val() == 1 && $(tableSelector).find('td.installer_version_installed .unstable').length;
87
- if( upgradesCount > 0){
88
- automaticUpgrade(tableSelector);
89
- }else{
90
- $('#installer_repo_' + select.data('repository-id') + ' .otgsi_downloads_form')
91
- .trigger('installer-update-complete');
92
- }
93
-
94
- select.prop('disabled', false);
95
- } );
96
- }
97
-
98
- }
99
-
100
- });
101
-
102
- }
103
-
104
- function retryChannelSwitch(){
105
- var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
106
- changeChannel(selectorContainer);
107
- return false;
108
- }
109
-
110
- function cancelSwitch(){
111
- $(this).closest('.installer-switch-confirmation').hide();
112
- var select = $(this).closest('.installer-switch-confirmation').prev().find('.installer-channel-selector');
113
- var previousValue = select.data('previous-value');
114
-
115
- select.val(previousValue).prop('disabled', false);
116
-
117
- if( select.val() > 1){
118
- var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
119
- var warnText = selectorContainer.find('.installer-warn-text');
120
- warnText.show();
121
- }
122
-
123
- }
124
-
125
- function automaticUpgrade(downloadsTable){
126
- $(downloadsTable + ' tr').each(
127
- function () {
128
- var needsUpgrade = $(this).find(
129
- 'td.installer_version_installed .installer-red-text, ' +
130
- 'td.installer_version_installed .unstable'
131
- ).length > 0;
132
- if (needsUpgrade) {
133
- $(this).find('td :checkbox').prop('disabled', false).prop('checked', true);
134
- }
135
- }
136
- );
137
-
138
- $(downloadsTable)
139
- .closest('form')
140
- .append('<input type="hidden" name="reset-to-channel" value="1">')
141
- .submit();
142
-
143
- }
144
-
145
- function maybeShowWarn(){
146
-
147
- var select = $(this)
148
- .closest('.otgs_wp_installer_table')
149
- .find('.installer-channel-selector')
150
-
151
- if(select.val() > 1 && !hasUpdateErrors()){
152
-
153
- var warnText = select
154
- .closest('.installer-channel-selector-wrap')
155
- .find('.installer-warn-text');
156
- warnText.show();
157
-
158
- }
159
-
160
-
161
- }
162
-
163
- function showUpdateProgress(select){
164
-
165
- var spinner = select
166
- .closest('.installer-channel-selector-wrap')
167
- .find('.spinner-with-text');
168
-
169
- spinner.addClass('is-active').show();
170
-
171
- }
172
-
173
- function hideUpdateProgress(){
174
-
175
- var spinner = $(this)
176
- .closest('.otgs_wp_installer_table')
177
- .find('.installer-channel-selector-wrap')
178
- .find('.spinner-with-text');
179
-
180
- spinner.removeClass('is-active').hide();
181
-
182
- }
183
-
184
- function showConfirmationMessage(){
185
-
186
- if( ! channelUpdateInProgress ) return false;
187
-
188
- var selectWrap = $(this)
189
- .closest('.otgs_wp_installer_table')
190
- .find('.installer-channel-selector-wrap');
191
-
192
- var select = $(this)
193
- .closest('.otgs_wp_installer_table')
194
- .find('.installer-channel-selector');
195
-
196
- var channelName = select.find('option:selected').text();
197
-
198
- if( hasUpdateErrors() ) {
199
-
200
- var message = selectWrap.find('.installer-channel-update-fail');
201
- // suppress default errors
202
- $(this).closest('.otgs_wp_installer_table').find('.installer-error-box').hide();
203
-
204
- var channelType = select.val() == 1 ? 'stable' : 'unstable';
205
- message.html(message.data('text-' + channelType).replace(/%CHANNEL%/, channelName));
206
-
207
- }else{
208
-
209
- var message = selectWrap.find('.installer-channel-update-ok');
210
- message.html(message.data('text').replace(/%CHANNEL%/, channelName));
211
- }
212
-
213
- message.show();
214
-
215
- channelUpdateInProgress = false;
216
- }
217
-
218
- function hideConfirmationMessage(select){
219
-
220
- var selectWrap = select.closest('.installer-channel-selector-wrap');
221
- if( hasUpdateErrors() ){
222
- var message = selectWrap.find('.installer-channel-update-fail');
223
- }else{
224
- var message = selectWrap.find('.installer-channel-update-ok');
225
- }
226
-
227
- message.hide();
228
- }
229
-
230
- /*
231
- function showFailureMessage(download_form){
232
- var message = download_form
233
- .closest('.otgs_wp_installer_table')
234
- .find('.installer-channel-selector-wrap')
235
- .find('.installer-channel-update-fail');
236
-
237
- var channelName = $(this)
238
- .closest('.otgs_wp_installer_table')
239
- .find('.installer-channel-selector option:selected')
240
- .text();
241
-
242
- message.html( message.data('text').replace(/%CHANNEL%/, channelName) );
243
- message.show();
244
- }
245
- */
246
-
247
- function logUpdateError(){
248
- updateErrors.push(1);
249
- }
250
-
251
- function resetUpdateErrors(){
252
- updateErrors = [];
253
- }
254
-
255
- function hasUpdateErrors() {
256
- return updateErrors.length;
257
- }
258
-
259
- $(document).ready( channelSelectorInit );
260
-
261
  })(jQuery)
1
+ (function($){
2
+
3
+ var updateErrors = [];
4
+ var channelUpdateInProgress = false;
5
+
6
+ function channelSelectorInit(){
7
+
8
+ $('.otgs_wp_installer_table')
9
+ .on('focus', '.installer-channel-selector', saveCurrentValue)
10
+ .on('change', '.installer-channel-selector', maybeShowPrompt);
11
+
12
+ $('.otgs_wp_installer_table')
13
+ .on('click', '.installer-channel-retry', retryChannelSwitch)
14
+
15
+ $('.installer-switch-confirmation')
16
+ .on('click', '.js-cancel', cancelSwitch)
17
+ .on('click', '.js-proceed', changeChannel);
18
+
19
+ $('.otgsi_downloads_form').on('installer-update-complete', maybeShowWarn);
20
+ $('.otgsi_downloads_form').on('installer-update-complete', hideUpdateProgress);
21
+
22
+ $('.otgsi_downloads_form').on('installer-update-complete', showConfirmationMessage);
23
+
24
+ $('.otgsi_downloads_form').on('installer-update-fail', logUpdateError);
25
+
26
+ }
27
+
28
+ function saveCurrentValue(){
29
+ $(this).data('previous-value', $(this).val());
30
+ }
31
+
32
+ function maybeShowPrompt(){
33
+ var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
34
+ var prompt = selectorContainer.find('.installer-switch-confirmation:hidden');
35
+
36
+ if(prompt.length){
37
+ prompt.show();
38
+ selectorContainer.find('select').prop('disabled', true);
39
+ var warnText = selectorContainer.find('.installer-warn-text');
40
+ warnText.hide();
41
+ }else{
42
+ changeChannel(selectorContainer);
43
+ }
44
+
45
+ }
46
+
47
+ function changeChannel(selectorContainer){
48
+
49
+ if(selectorContainer.type == 'click'){
50
+ var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
51
+ }
52
+
53
+ var select = selectorContainer.find('select');
54
+ select.prop('disabled', true);
55
+
56
+ hideConfirmationMessage(select);
57
+ showUpdateProgress(select);
58
+
59
+ selectorContainer.find('.installer-switch-confirmation').hide();
60
+
61
+ var data = {
62
+ action: 'installer_set_channel',
63
+ repository_id: select.data('repository-id'),
64
+ channel: select.val(),
65
+ nonce: select.parent().find('.nonce').val(),
66
+ noprompt: selectorContainer.find('.js-remember').length ?
67
+ selectorContainer.find('.js-remember').attr('checked') == 'checked' : 0
68
+ }
69
+
70
+ resetUpdateErrors();
71
+ otgs_wp_installer.reset_errors();
72
+ channelUpdateInProgress = true;
73
+
74
+ // save selection
75
+ jQuery.ajax({
76
+ url: ajaxurl,
77
+ type: 'POST',
78
+ dataType: 'json',
79
+ data: data,
80
+ success: function (ret) {
81
+ if( ret.status == 'OK'){
82
+ var tableSelector = '#installer_repo_' + select.data('repository-id') + ' .installer-table-wrap';
83
+ $(tableSelector).load( location.href + ' ' + tableSelector + ' table.widefat', function(){
84
+
85
+ var upgradesCount = $(tableSelector).find('tr .installer-red-text').length
86
+ || select.val() == 1 && $(tableSelector).find('td.installer_version_installed .unstable').length;
87
+ if( upgradesCount > 0){
88
+ automaticUpgrade(tableSelector);
89
+ }else{
90
+ $('#installer_repo_' + select.data('repository-id') + ' .otgsi_downloads_form')
91
+ .trigger('installer-update-complete');
92
+ }
93
+
94
+ select.prop('disabled', false);
95
+ } );
96
+ }
97
+
98
+ }
99
+
100
+ });
101
+
102
+ }
103
+
104
+ function retryChannelSwitch(){
105
+ var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
106
+ changeChannel(selectorContainer);
107
+ return false;
108
+ }
109
+
110
+ function cancelSwitch(){
111
+ $(this).closest('.installer-switch-confirmation').hide();
112
+ var select = $(this).closest('.installer-switch-confirmation').prev().find('.installer-channel-selector');
113
+ var previousValue = select.data('previous-value');
114
+
115
+ select.val(previousValue).prop('disabled', false);
116
+
117
+ if( select.val() > 1){
118
+ var selectorContainer = $(this).closest('.installer-channel-selector-wrap');
119
+ var warnText = selectorContainer.find('.installer-warn-text');
120
+ warnText.show();
121
+ }
122
+
123
+ }
124
+
125
+ function automaticUpgrade(downloadsTable){
126
+ $(downloadsTable + ' tr').each(
127
+ function () {
128
+ var needsUpgrade = $(this).find(
129
+ 'td.installer_version_installed .installer-red-text, ' +
130
+ 'td.installer_version_installed .unstable'
131
+ ).length > 0;
132
+ if (needsUpgrade) {
133
+ $(this).find('td :checkbox').prop('disabled', false).prop('checked', true);
134
+ }
135
+ }
136
+ );
137
+
138
+ $(downloadsTable)
139
+ .closest('form')
140
+ .append('<input type="hidden" name="reset-to-channel" value="1">')
141
+ .submit();
142
+
143
+ }
144
+
145
+ function maybeShowWarn(){
146
+
147
+ var select = $(this)
148
+ .closest('.otgs_wp_installer_table')
149
+ .find('.installer-channel-selector')
150
+
151
+ if(select.val() > 1 && !hasUpdateErrors()){
152
+
153
+ var warnText = select
154
+ .closest('.installer-channel-selector-wrap')
155
+ .find('.installer-warn-text');
156
+ warnText.show();
157
+
158
+ }
159
+
160
+
161
+ }
162
+
163
+ function showUpdateProgress(select){
164
+
165
+ var spinner = select
166
+ .closest('.installer-channel-selector-wrap')
167
+ .find('.spinner-with-text');
168
+
169
+ spinner.addClass('is-active').show();
170
+
171
+ }
172
+
173
+ function hideUpdateProgress(){
174
+
175
+ var spinner = $(this)
176
+ .closest('.otgs_wp_installer_table')
177
+ .find('.installer-channel-selector-wrap')
178
+ .find('.spinner-with-text');
179
+
180
+ spinner.removeClass('is-active').hide();
181
+
182
+ }
183
+
184
+ function showConfirmationMessage(){
185
+
186
+ if( ! channelUpdateInProgress ) return false;
187
+
188
+ var selectWrap = $(this)
189
+ .closest('.otgs_wp_installer_table')
190
+ .find('.installer-channel-selector-wrap');
191
+
192
+ var select = $(this)
193
+ .closest('.otgs_wp_installer_table')
194
+ .find('.installer-channel-selector');
195
+
196
+ var channelName = select.find('option:selected').text();
197
+
198
+ if( hasUpdateErrors() ) {
199
+
200
+ var message = selectWrap.find('.installer-channel-update-fail');
201
+ // suppress default errors
202
+ $(this).closest('.otgs_wp_installer_table').find('.installer-error-box').hide();
203
+
204
+ var channelType = select.val() == 1 ? 'stable' : 'unstable';
205
+ message.html(message.data('text-' + channelType).replace(/%CHANNEL%/, channelName));
206
+
207
+ }else{
208
+
209
+ var message = selectWrap.find('.installer-channel-update-ok');
210
+ message.html(message.data('text').replace(/%CHANNEL%/, channelName));
211
+ }
212
+
213
+ message.show();
214
+
215
+ channelUpdateInProgress = false;
216
+ }
217
+
218
+ function hideConfirmationMessage(select){
219
+
220
+ var selectWrap = select.closest('.installer-channel-selector-wrap');
221
+ if( hasUpdateErrors() ){
222
+ var message = selectWrap.find('.installer-channel-update-fail');
223
+ }else{
224
+ var message = selectWrap.find('.installer-channel-update-ok');
225
+ }
226
+
227
+ message.hide();
228
+ }
229
+
230
+ /*
231
+ function showFailureMessage(download_form){
232
+ var message = download_form
233
+ .closest('.otgs_wp_installer_table')
234
+ .find('.installer-channel-selector-wrap')
235
+ .find('.installer-channel-update-fail');
236
+
237
+ var channelName = $(this)
238
+ .closest('.otgs_wp_installer_table')
239
+ .find('.installer-channel-selector option:selected')
240
+ .text();
241
+
242
+ message.html( message.data('text').replace(/%CHANNEL%/, channelName) );
243
+ message.show();
244
+ }
245
+ */
246
+
247
+ function logUpdateError(){
248
+ updateErrors.push(1);
249
+ }
250
+
251
+ function resetUpdateErrors(){
252
+ updateErrors = [];
253
+ }
254
+
255
+ function hasUpdateErrors() {
256
+ return updateErrors.length;
257
+ }
258
+
259
+ $(document).ready( channelSelectorInit );
260
+
261
  })(jQuery)
vendor/otgs/installer/res/js/iframeResizer.min.js CHANGED
@@ -1,10 +1,10 @@
1
- /*! iFrame Resizer (iframeSizer.min.js ) - v2.6.1 - 2014-09-03
2
- * Desc: Force cross domain iframes to size to content.
3
- * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
4
- * Copyright: (c) 2014 David J. Bradshaw - dave@bradshaw.net
5
- * License: MIT
6
- */
7
-
8
- !function(){"use strict";function a(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function b(){var a,b=["moz","webkit","o","ms"];for(a=0;a<b.length&&!w;a+=1)w=window[b[a]+"RequestAnimationFrame"];w||c(" RequestAnimationFrame not supported")}function c(a){y.log&&"object"==typeof console&&console.log(s+"[Host page"+u+"]"+a)}function d(a){function b(){function a(){h(z),f(),y.resizedCallback(z)}i(a,z,"resetPage")}function d(a){var b=a.id;c(" Removing iFrame: "+b),a.parentNode.removeChild(a),y.closedCallback(b),c(" --")}function e(){var a=x.substr(t).split(":");return{iframe:document.getElementById(a[0]),id:a[0],height:a[1],width:a[2],type:a[3]}}function j(a){var b=Number(y["max"+a]),d=Number(y["min"+a]),e=a.toLowerCase(),f=Number(z[e]);if(d>b)throw new Error("Value for min"+a+" can not be greater than max"+a);c(" Checking "+e+" is in range "+d+"-"+b),d>f&&(f=d,c(" Set "+e+" to min value")),f>b&&(f=b,c(" Set "+e+" to max value")),z[e]=""+f}function k(){var b=a.origin,d=z.iframe.src.split("/").slice(0,3).join("/");if(y.checkOrigin&&(c(" Checking connection is from: "+d),""+b!="null"&&b!==d))throw new Error("Unexpected message received from: "+b+" for "+z.iframe.id+". Message was: "+a.data+". This error can be disabled by adding the checkOrigin: false option.");return!0}function l(){return s===(""+x).substr(0,t)}function m(){var a=z.type in{"true":1,"false":1};return a&&c(" Ignoring init message from meta parent page"),a}function n(){var a=x.substr(x.indexOf(":")+r+6);c(" MessageCallback passed: {iframe: "+z.iframe.id+", message: "+a+"}"),y.messageCallback({iframe:z.iframe,message:a}),c(" --")}function o(){if(null===z.iframe)throw new Error("iFrame ("+z.id+") does not exist on "+u);return!0}function q(){c(" Reposition requested from iFrame"),v={x:z.width,y:z.height},f()}function w(){switch(z.type){case"close":d(z.iframe),y.resizedCallback(z);break;case"message":n();break;case"scrollTo":q();break;case"reset":g(z);break;case"init":b(),y.initCallback(z.iframe);break;default:b()}}var x=a.data,z={};l()&&(c(" Received: "+x),z=e(),j("Height"),j("Width"),!m()&&o()&&k()&&(w(),p=!1))}function e(){null===v&&(v={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},c(" Get position: "+v.x+","+v.y))}function f(){null!==v&&(window.scrollTo(v.x,v.y),c(" Set position: "+v.x+","+v.y),v=null)}function g(a){function b(){h(a),j("reset","reset",a.iframe)}c(" Size reset requested by "+("init"===a.type?"host page":"iFrame")),e(),i(b,a,"init")}function h(a){function b(b){a.iframe.style[b]=a[b]+"px",c(" IFrame ("+a.iframe.id+") "+b+" set to "+a[b]+"px")}y.sizeHeight&&b("height"),y.sizeWidth&&b("width")}function i(a,b,d){d!==b.type&&w?(c(" Requesting animation frame"),w(a)):a()}function j(a,b,d){c("["+a+"] Sending msg to iframe ("+b+")"),d.contentWindow.postMessage(s+b,"*")}function k(){function b(){function a(a){1/0!==y[a]&&0!==y[a]&&(k.style[a]=y[a]+"px",c(" Set "+a+" = "+y[a]+"px"))}a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function d(a){return""===a&&(k.id=a="iFrameResizer"+o++,c(" Added missing iframe ID: "+a+" ("+k.src+")")),a}function e(){c(" IFrame scrolling "+(y.scrolling?"enabled":"disabled")+" for "+l),k.style.overflow=!1===y.scrolling?"hidden":"auto",k.scrolling=!1===y.scrolling?"no":"yes"}function f(){("number"==typeof y.bodyMargin||"0"===y.bodyMargin)&&(y.bodyMarginV1=y.bodyMargin,y.bodyMargin=""+y.bodyMargin+"px")}function h(){return l+":"+y.bodyMarginV1+":"+y.sizeWidth+":"+y.log+":"+y.interval+":"+y.enablePublicMethods+":"+y.autoResize+":"+y.bodyMargin+":"+y.heightCalculationMethod+":"+y.bodyBackground+":"+y.bodyPadding+":"+y.tolerance}function i(b){a(k,"load",function(){var a=p;j("iFrame.onload",b,k),!a&&y.heightCalculationMethod in x&&g({iframe:k,height:0,width:0,type:"init"})}),j("init",b,k)}var k=this,l=d(k.id);e(),b(),f(),i(h())}function l(a){if("object"!=typeof a)throw new TypeError("Options is not an object.")}function m(){function a(a){if("IFRAME"!==a.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+a.tagName+">.");k.call(a)}function b(a){a=a||{},l(a);for(var b in z)z.hasOwnProperty(b)&&(y[b]=a.hasOwnProperty(b)?a[b]:z[b])}return function(c,d){b(c),Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a)}}function n(a){a.fn.iFrameResize=function(b){return b=b||{},l(b),y=a.extend({},z,b),this.filter("iframe").each(k).end()}}var o=0,p=!0,q="message",r=q.length,s="[iFrameSizer]",t=s.length,u="",v=null,w=window.requestAnimationFrame,x={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},y={},z={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,enablePublicMethods:!1,heightCalculationMethod:"offset",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,closedCallback:function(){},initCallback:function(){},messageCallback:function(){},resizedCallback:function(){}};b(),a(window,"message",d),"jQuery"in window&&n(jQuery),"function"==typeof define&&define.amd?define(function(){return m()}):window.iFrameResize=m()}();
9
- //# sourceMappingURL=../src/iframeResizer.map
10
-
1
+ /*! iFrame Resizer (iframeSizer.min.js ) - v2.6.1 - 2014-09-03
2
+ * Desc: Force cross domain iframes to size to content.
3
+ * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
4
+ * Copyright: (c) 2014 David J. Bradshaw - dave@bradshaw.net
5
+ * License: MIT
6
+ */
7
+
8
+ !function(){"use strict";function a(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function b(){var a,b=["moz","webkit","o","ms"];for(a=0;a<b.length&&!w;a+=1)w=window[b[a]+"RequestAnimationFrame"];w||c(" RequestAnimationFrame not supported")}function c(a){y.log&&"object"==typeof console&&console.log(s+"[Host page"+u+"]"+a)}function d(a){function b(){function a(){h(z),f(),y.resizedCallback(z)}i(a,z,"resetPage")}function d(a){var b=a.id;c(" Removing iFrame: "+b),a.parentNode.removeChild(a),y.closedCallback(b),c(" --")}function e(){var a=x.substr(t).split(":");return{iframe:document.getElementById(a[0]),id:a[0],height:a[1],width:a[2],type:a[3]}}function j(a){var b=Number(y["max"+a]),d=Number(y["min"+a]),e=a.toLowerCase(),f=Number(z[e]);if(d>b)throw new Error("Value for min"+a+" can not be greater than max"+a);c(" Checking "+e+" is in range "+d+"-"+b),d>f&&(f=d,c(" Set "+e+" to min value")),f>b&&(f=b,c(" Set "+e+" to max value")),z[e]=""+f}function k(){var b=a.origin,d=z.iframe.src.split("/").slice(0,3).join("/");if(y.checkOrigin&&(c(" Checking connection is from: "+d),""+b!="null"&&b!==d))throw new Error("Unexpected message received from: "+b+" for "+z.iframe.id+". Message was: "+a.data+". This error can be disabled by adding the checkOrigin: false option.");return!0}function l(){return s===(""+x).substr(0,t)}function m(){var a=z.type in{"true":1,"false":1};return a&&c(" Ignoring init message from meta parent page"),a}function n(){var a=x.substr(x.indexOf(":")+r+6);c(" MessageCallback passed: {iframe: "+z.iframe.id+", message: "+a+"}"),y.messageCallback({iframe:z.iframe,message:a}),c(" --")}function o(){if(null===z.iframe)throw new Error("iFrame ("+z.id+") does not exist on "+u);return!0}function q(){c(" Reposition requested from iFrame"),v={x:z.width,y:z.height},f()}function w(){switch(z.type){case"close":d(z.iframe),y.resizedCallback(z);break;case"message":n();break;case"scrollTo":q();break;case"reset":g(z);break;case"init":b(),y.initCallback(z.iframe);break;default:b()}}var x=a.data,z={};l()&&(c(" Received: "+x),z=e(),j("Height"),j("Width"),!m()&&o()&&k()&&(w(),p=!1))}function e(){null===v&&(v={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},c(" Get position: "+v.x+","+v.y))}function f(){null!==v&&(window.scrollTo(v.x,v.y),c(" Set position: "+v.x+","+v.y),v=null)}function g(a){function b(){h(a),j("reset","reset",a.iframe)}c(" Size reset requested by "+("init"===a.type?"host page":"iFrame")),e(),i(b,a,"init")}function h(a){function b(b){a.iframe.style[b]=a[b]+"px",c(" IFrame ("+a.iframe.id+") "+b+" set to "+a[b]+"px")}y.sizeHeight&&b("height"),y.sizeWidth&&b("width")}function i(a,b,d){d!==b.type&&w?(c(" Requesting animation frame"),w(a)):a()}function j(a,b,d){c("["+a+"] Sending msg to iframe ("+b+")"),d.contentWindow.postMessage(s+b,"*")}function k(){function b(){function a(a){1/0!==y[a]&&0!==y[a]&&(k.style[a]=y[a]+"px",c(" Set "+a+" = "+y[a]+"px"))}a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function d(a){return""===a&&(k.id=a="iFrameResizer"+o++,c(" Added missing iframe ID: "+a+" ("+k.src+")")),a}function e(){c(" IFrame scrolling "+(y.scrolling?"enabled":"disabled")+" for "+l),k.style.overflow=!1===y.scrolling?"hidden":"auto",k.scrolling=!1===y.scrolling?"no":"yes"}function f(){("number"==typeof y.bodyMargin||"0"===y.bodyMargin)&&(y.bodyMarginV1=y.bodyMargin,y.bodyMargin=""+y.bodyMargin+"px")}function h(){return l+":"+y.bodyMarginV1+":"+y.sizeWidth+":"+y.log+":"+y.interval+":"+y.enablePublicMethods+":"+y.autoResize+":"+y.bodyMargin+":"+y.heightCalculationMethod+":"+y.bodyBackground+":"+y.bodyPadding+":"+y.tolerance}function i(b){a(k,"load",function(){var a=p;j("iFrame.onload",b,k),!a&&y.heightCalculationMethod in x&&g({iframe:k,height:0,width:0,type:"init"})}),j("init",b,k)}var k=this,l=d(k.id);e(),b(),f(),i(h())}function l(a){if("object"!=typeof a)throw new TypeError("Options is not an object.")}function m(){function a(a){if("IFRAME"!==a.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+a.tagName+">.");k.call(a)}function b(a){a=a||{},l(a);for(var b in z)z.hasOwnProperty(b)&&(y[b]=a.hasOwnProperty(b)?a[b]:z[b])}return function(c,d){b(c),Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a)}}function n(a){a.fn.iFrameResize=function(b){return b=b||{},l(b),y=a.extend({},z,b),this.filter("iframe").each(k).end()}}var o=0,p=!0,q="message",r=q.length,s="[iFrameSizer]",t=s.length,u="",v=null,w=window.requestAnimationFrame,x={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},y={},z={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,enablePublicMethods:!1,heightCalculationMethod:"offset",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,closedCallback:function(){},initCallback:function(){},messageCallback:function(){},resizedCallback:function(){}};b(),a(window,"message",d),"jQuery"in window&&n(jQuery),"function"==typeof define&&define.amd?define(function(){return m()}):window.iFrameResize=m()}();
9
+ //# sourceMappingURL=../src/iframeResizer.map
10
+
vendor/otgs/installer/res/js/installer_theme_install.js CHANGED
@@ -1,97 +1,97 @@
1
- jQuery( document ).ready( function( $ ) {
2
-
3
- /** Append OTGS Theme tab */
4
- var js_array= installer_theme_install_localize.js_array_installer;
5
-
6
- if (!($.isEmptyObject(js_array))) {
7
- //Unempty
8
- for(var key in js_array) {
9
- //Dont append if we are on commercial plugins tab page and if there are no themes
10
- if ((!(js_array[key]['is_commercial_plugin_tab'])) && (!(installer_theme_install_localize.no_associated_themes))) {
11
- $('div.wp-filter ul.filter-links').append('<li><a data-sort="'+key+'" href="#">'+ js_array[key]['the_hyperlink_text'] +'</a></li>');
12
- }
13
- }
14
- }
15
-
16
- /** Page load event tab selected identifier */
17
- var loaded_browsing_tab=installer_theme_extended_object.getParameterByName('browse');
18
- if (loaded_browsing_tab.length > 0) {
19
-
20
- var frontend_tab_selected_tab = loaded_browsing_tab;
21
-
22
- } else if (0 == loaded_browsing_tab.length){
23
-
24
- //WordPress defaults to 'Featured' when theme install is loaded without the browse parameter
25
- var frontend_tab_selected_tab = 'featured';
26
- }
27
-
28
- /** Prepare data on page load event for AJAX */
29
- var data = {
30
- action: 'installer_theme_frontend_selected_tab',
31
- installer_theme_frontend_selected_tab_nonce: installer_theme_install_localize.installer_theme_frontend_selected_tab_nonce,
32
- frontend_tab_selected :frontend_tab_selected_tab
33
- };
34
-
35
- //Call AJAX
36
- installer_theme_extended_object.doAJAX(data,frontend_tab_selected_tab,js_array);
37
-
38
- /** When user clicks on any tab */
39
- $(document).on('click','.filter-links li > a',function () {
40
-
41
- //Get data_sort
42
- var data_sort =$(this).attr('data-sort');
43
-
44
- if (data_sort) {
45
- //data_sort is set, prepare data
46
- var data = {
47
- action: 'installer_theme_frontend_selected_tab',
48
- installer_theme_frontend_selected_tab_nonce: installer_theme_install_localize.installer_theme_frontend_selected_tab_nonce,
49
- frontend_tab_selected : data_sort
50
- };
51
-
52
- //Call AJAX
53
- installer_theme_extended_object.doAJAX(data,data_sort,js_array);
54
-
55
- }
56
- });
57
-
58
- var fullhash = window.location.hash;
59
- if (fullhash.length > 0) {
60
- var product_selector=fullhash+' '+'.enter_site_key_js';
61
- if ($(product_selector).length ) {
62
- $(product_selector).click();
63
- }
64
- }
65
- });
66
-
67
- //Installer theme extended JS object for methods
68
- var installer_theme_extended_object = {
69
-
70
- getParameterByName: function(name) {
71
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
72
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
73
- results = regex.exec(location.search);
74
- return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
75
- },
76
-
77
- doAJAX: function(data,data_sort,js_array) {
78
-
79
- //We only want to post to AJAX if its an OTGS tab
80
- jQuery.post(installer_theme_install_localize.ajaxurl, data, function(response) {
81
- //AJAX response
82
- var myObject = jQuery.parseJSON(response);
83
- if (typeof myObject != "undefined") {
84
- if(myObject.hasOwnProperty("output")){
85
- var tab_selected= myObject.output;
86
- if (data_sort in js_array) {
87
- if (!(installer_theme_install_localize.js_array_installer[tab_selected]['registration_status'])) {
88
- //Not registered, no theme response
89
- var unregistered_message= myObject.unregistered_messages;
90
- jQuery('.no-themes').html(unregistered_message);
91
- }
92
- }
93
- }
94
- }
95
- });
96
- }
97
  };
1
+ jQuery( document ).ready( function( $ ) {
2
+
3
+ /** Append OTGS Theme tab */
4
+ var js_array= installer_theme_install_localize.js_array_installer;
5
+
6
+ if (!($.isEmptyObject(js_array))) {
7
+ //Unempty
8
+ for(var key in js_array) {
9
+ //Dont append if we are on commercial plugins tab page and if there are no themes
10
+ if ((!(js_array[key]['is_commercial_plugin_tab'])) && (!(installer_theme_install_localize.no_associated_themes))) {
11
+ $('div.wp-filter ul.filter-links').append('<li><a data-sort="'+key+'" href="#">'+ js_array[key]['the_hyperlink_text'] +'</a></li>');
12
+ }
13
+ }
14
+ }
15
+
16
+ /** Page load event tab selected identifier */
17
+ var loaded_browsing_tab=installer_theme_extended_object.getParameterByName('browse');
18
+ if (loaded_browsing_tab.length > 0) {
19
+
20
+ var frontend_tab_selected_tab = loaded_browsing_tab;
21
+
22
+ } else if (0 == loaded_browsing_tab.length){
23
+
24
+ //WordPress defaults to 'Featured' when theme install is loaded without the browse parameter
25
+ var frontend_tab_selected_tab = 'featured';
26
+ }
27
+
28
+ /** Prepare data on page load event for AJAX */
29
+ var data = {
30
+ action: 'installer_theme_frontend_selected_tab',
31
+ installer_theme_frontend_selected_tab_nonce: installer_theme_install_localize.installer_theme_frontend_selected_tab_nonce,
32
+ frontend_tab_selected :frontend_tab_selected_tab
33
+ };
34
+
35
+ //Call AJAX
36
+ installer_theme_extended_object.doAJAX(data,frontend_tab_selected_tab,js_array);
37
+
38
+ /** When user clicks on any tab */
39
+ $(document).on('click','.filter-links li > a',function () {
40
+
41
+ //Get data_sort
42
+ var data_sort =$(this).attr('data-sort');
43
+
44
+ if (data_sort) {
45
+ //data_sort is set, prepare data
46
+ var data = {
47
+ action: 'installer_theme_frontend_selected_tab',
48
+ installer_theme_frontend_selected_tab_nonce: installer_theme_install_localize.installer_theme_frontend_selected_tab_nonce,
49
+ frontend_tab_selected : data_sort
50
+ };
51
+
52
+ //Call AJAX
53
+ installer_theme_extended_object.doAJAX(data,data_sort,js_array);
54
+
55
+ }
56
+ });
57
+
58
+ var fullhash = window.location.hash;
59
+ if (fullhash.length > 0) {
60
+ var product_selector=fullhash+' '+'.enter_site_key_js';
61
+ if ($(product_selector).length ) {
62
+ $(product_selector).click();
63
+ }
64
+ }
65
+ });
66
+
67
+ //Installer theme extended JS object for methods
68
+ var installer_theme_extended_object = {
69
+
70
+ getParameterByName: function(name) {
71
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
72
+ var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
73
+ results = regex.exec(location.search);
74
+ return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
75
+ },
76
+
77
+ doAJAX: function(data,data_sort,js_array) {
78
+
79
+ //We only want to post to AJAX if its an OTGS tab
80
+ jQuery.post(installer_theme_install_localize.ajaxurl, data, function(response) {
81
+ //AJAX response
82
+ var myObject = jQuery.parseJSON(response);
83
+ if (typeof myObject != "undefined") {
84
+ if(myObject.hasOwnProperty("output")){
85
+ var tab_selected= myObject.output;
86
+ if (data_sort in js_array) {
87
+ if (!(installer_theme_install_localize.js_array_installer[tab_selected]['registration_status'])) {
88
+ //Not registered, no theme response
89
+ var unregistered_message= myObject.unregistered_messages;
90
+ jQuery('.no-themes').html(unregistered_message);
91
+ }
92
+ }
93
+ }
94
+ }
95
+ });
96
+ }
97
  };
vendor/otgs/installer/templates/channel-selector.php CHANGED
@@ -1,68 +1,68 @@
1
- <div class="installer-channel-selector-wrap">
2
- <label>
3
- <?php esc_html_e('Updates channel:', 'installer'); ?>
4
- <select class="installer-channel-selector" data-repository-id="<?php echo $repository_id ?>"<?php if( !$can_switch ): ?> disabled<?php endif ?>>
5
- <?php foreach( $channels as $channel_id => $channel_name ): ?>
6
- <option value="<?php echo $channel_id ?>" <?php
7
- if( $channel_id == $current_channel ): ?>selected="selected"<?php
8
- endif; ?>><?php echo $channel_name ?></option>
9
- <?php endforeach ?>
10
- </select>
11
- <span class="installer-status-note" <?php if( $can_switch ): ?>style="display:none" <?php endif; ?>>
12
- <?php _e("To select different update channels (beta, development) you must update your existing products to their most recent stable versions.", 'installer') ?>
13
- </span>
14
- <span class="spinner spinner-with-text">
15
- <?php _e( "Updating the plugins on your site. Please don't close this page or navigate away.", 'installer' ); ?>
16
- </span>
17
- <span class="installer-channel-update-ok" data-text="<?php
18
- esc_attr_e( sprintf("Update completed. You are now using the %s channel of %s.",
19
- '%CHANNEL%', WP_Installer()->get_generic_product_name( $repository_id ) ) ) ?>">
20
- </span>
21
- <span class="installer-channel-update-fail" data-text-unstable="<?php
22
- $support_url = $repository_id ==='toolset' ? 'https://wp-types.com/forums/forum/support-2/' : 'https://wpml.org/forums/forum/english-support/';
23
- $download_url = $repository_id ==='toolset' ? 'https://wp-types.com/account/downloads/' : 'https://wpml.org/account/downloads/';
24
- echo esc_attr( sprintf(
25
- __( "Something went wrong and we could not install all updates from the %s channel. Click here to %stry again%s. If the errors persist, please switch back to the Production channel and contact the %s%s support%s.", 'installer' ),
26
- '%CHANNEL%',
27
- '<a href="#" class="installer-channel-retry"><strong>',
28
- '</strong></a>',
29
- '<a href="' . $support_url . '">', WP_Installer()->get_generic_product_name( $repository_id ), '</a>'
30
- ) );
31
- ?>" data-text-stable="<?php
32
- echo esc_attr( sprintf(
33
- esc_attr__( "There was a problem switching to the %s channel. You can %sretry%s. If the problem continues, please %sdownload %s%s and install again manually", 'installer' ),
34
- '%CHANNEL%',
35
- '<a href="#" class="installer-channel-retry"><strong>',
36
- '</strong></a>',
37
- '<a href="' . $download_url . '">', WP_Installer()->get_generic_product_name( $repository_id ), '</a>'
38
- ) );
39
- ?>">
40
- </span>
41
- <input type="hidden" class="nonce" value="<?php echo $nonce ?>" />
42
- </label>
43
-
44
- <?php if( !$no_prompt ): ?>
45
- <div class="installer-warn-box installer-switch-confirmation" style="margin-top: 10px; display: none">
46
- <p class="alignright">
47
- <button class="button-secondary js-cancel"><?php _e("Cancel", 'installer') ?></button>
48
- <button class="button-primary js-proceed"><?php _e("Switch", 'installer') ?></button>
49
- </p>
50
- <p>
51
- <?php _e("Plugins will be updated to their most advanced version in the channel that you selected.", 'installer') ?>
52
- </p>
53
- <label>
54
- <input type="checkbox" value="1" class="js-remember"/>
55
- &nbsp;<?php _e("Remember my preference.", 'installer') ?><br />
56
- </label>
57
- </div>
58
- <?php endif; ?>
59
-
60
- <div class="installer-warn-text" <?php if( WP_Installer_Channels()->get_channel( $repository_id ) <= 1 ): ?>style="display:none" <?php endif; ?>>
61
- <?php printf(
62
- __("You are using a potentially less stable channel for %s. If you didn't enable this on purpose, you should switch to the 'Production' channel.", 'installer'),
63
- WP_Installer()->get_generic_product_name( $repository_id )
64
- );
65
- ?>
66
- </div>
67
-
68
  </div>
1
+ <div class="installer-channel-selector-wrap">
2
+ <label>
3
+ <?php esc_html_e('Updates channel:', 'installer'); ?>
4
+ <select class="installer-channel-selector" data-repository-id="<?php echo $repository_id ?>"<?php if( !$can_switch ): ?> disabled<?php endif ?>>
5
+ <?php foreach( $channels as $channel_id => $channel_name ): ?>
6
+ <option value="<?php echo $channel_id ?>" <?php
7
+ if( $channel_id == $current_channel ): ?>selected="selected"<?php
8
+ endif; ?>><?php echo $channel_name ?></option>
9
+ <?php endforeach ?>
10
+ </select>
11
+ <span class="installer-status-note" <?php if( $can_switch ): ?>style="display:none" <?php endif; ?>>
12
+ <?php _e("To select different update channels (beta, development) you must update your existing products to their most recent stable versions.", 'installer') ?>
13
+ </span>
14
+ <span class="spinner spinner-with-text">
15
+ <?php _e( "Updating the plugins on your site. Please don't close this page or navigate away.", 'installer' ); ?>
16
+ </span>
17
+ <span class="installer-channel-update-ok" data-text="<?php
18
+ esc_attr_e( sprintf("Update completed. You are now using the %s channel of %s.",
19
+ '%CHANNEL%', WP_Installer()->get_generic_product_name( $repository_id ) ) ) ?>">
20
+ </span>
21
+ <span class="installer-channel-update-fail" data-text-unstable="<?php
22
+ $support_url = $repository_id ==='toolset' ? 'https://wp-types.com/forums/forum/support-2/' : 'https://wpml.org/forums/forum/english-support/';
23
+ $download_url = $repository_id ==='toolset' ? 'https://wp-types.com/account/downloads/' : 'https://wpml.org/account/downloads/';
24
+ echo esc_attr( sprintf(
25
+ __( "Something went wrong and we could not install all updates from the %s channel. Click here to %stry again%s. If the errors persist, please switch back to the Production channel and contact the %s%s support%s.", 'installer' ),
26
+ '%CHANNEL%',
27
+ '<a href="#" class="installer-channel-retry"><strong>',
28
+ '</strong></a>',
29
+ '<a href="' . $support_url . '">', WP_Installer()->get_generic_product_name( $repository_id ), '</a>'
30
+ ) );
31
+ ?>" data-text-stable="<?php
32
+ echo esc_attr( sprintf(
33
+ esc_attr__( "There was a problem switching to the %s channel. You can %sretry%s. If the problem continues, please %sdownload %s%s and install again manually", 'installer' ),
34
+ '%CHANNEL%',
35
+ '<a href="#" class="installer-channel-retry"><strong>',
36
+ '</strong></a>',
37
+ '<a href="' . $download_url . '">', WP_Installer()->get_generic_product_name( $repository_id ), '</a>'
38
+ ) );
39
+ ?>">
40
+ </span>
41
+ <input type="hidden" class="nonce" value="<?php echo $nonce ?>" />
42
+ </label>
43
+
44
+ <?php if( !$no_prompt ): ?>
45
+ <div class="installer-warn-box installer-switch-confirmation" style="margin-top: 10px; display: none">
46
+ <p class="alignright">
47
+ <button class="button-secondary js-cancel"><?php _e("Cancel", 'installer') ?></button>
48
+ <button class="button-primary js-proceed"><?php _e("Switch", 'installer') ?></button>
49
+ </p>
50
+ <p>
51
+ <?php _e("Plugins will be updated to their most advanced version in the channel that you selected.", 'installer') ?>
52
+ </p>
53
+ <label>
54
+ <input type="checkbox" value="1" class="js-remember"/>
55
+ &nbsp;<?php _e("Remember my preference.", 'installer') ?><br />
56
+ </label>
57
+ </div>
58
+ <?php endif; ?>
59
+
60
+ <div class="installer-warn-text" <?php if( WP_Installer_Channels()->get_channel( $repository_id ) <= 1 ): ?>style="display:none" <?php endif; ?>>
61
+ <?php printf(
62
+ __("You are using a potentially less stable channel for %s. If you didn't enable this on purpose, you should switch to the 'Production' channel.", 'installer'),
63
+ WP_Installer()->get_generic_product_name( $repository_id )
64
+ );
65
+ ?>
66
+ </div>
67
+
68
  </div>
vendor/otgs/installer/templates/downloads-list-compact.php CHANGED
@@ -1,80 +1,80 @@
1
-
2
- <form method="post" class="otgsi_downloads_form">
3
-
4
- <table class="installer-plugins-list-compact">
5
- <thead>
6
- <tr>
7
- <th>&nbsp;</th>
8
- <th><?php _e('Plugin', 'installer') ?></th>
9
- <th><img src="<?php echo $this->plugin_url() ?>/res/img/globe.png" alt="<?php esc_attr_e('Available', 'installer') ?>" width="16" height="16"></th>
10
- <th><img src="<?php echo $this->plugin_url() ?>/res/img/computer.png" alt="<?php esc_attr_e('Installed', 'installer') ?>" width="16" height="16"></th>
11
- <th><img src="<?php echo $this->plugin_url() ?>/res/img/dn2.gif" alt="<?php esc_attr_e('Downloading', 'installer') ?>" width="16" height="16"></th>
12
- <th><img src="<?php echo $this->plugin_url() ?>/res/img/on.png" alt="<?php esc_attr_e('Activate', 'installer') ?>" width="16" height="16"></th>
13
- </tr>
14
- </thead>
15
- <tbody>
16
- <?php foreach($product['downloads'] as $download): ?>
17
- <?php if(empty($tr_oddeven) || $tr_oddeven == 'even') $tr_oddeven = 'odd'; else $tr_oddeven = 'even'; ?>
18
- <tr class="<?php echo $tr_oddeven ?>">
19
- <td>
20
- <label>
21
- <?php
22
- $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id );
23
-
24
- $download_data = array(
25
- 'url' => $url,
26
- 'slug' => $download['slug'],
27
- 'nonce' => wp_create_nonce('install_plugin_' . $url),
28
- 'repository_id' => $repository_id
29
- );
30
-
31
- $disabled = $expired ||
32
- (
33
- $this->plugin_is_installed($download['name'], $download['slug'], $download['version']) &&
34
- !$this->plugin_is_embedded_version($download['name'], $download['slug'])
35
- ) || WP_Installer()->dependencies->cant_download( $repository_id );
36
-
37
- ?>
38
- <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode($download_data)); ?>" <?php
39
- if($disabled): ?>disabled="disabled"<?php endif; ?> />&nbsp;
40
-
41
- </label>
42
- </td>
43
- <td class="installer_plugin_name"><?php echo $download['name'] ?></td>
44
- <td><?php echo $download['version'] ?></td>
45
- <td class="installer_version_installed">
46
- <?php if($v = $this->plugin_is_installed($download['name'], $download['slug'])):
47
- $class = version_compare($v, $download['version'], '>=') ? 'installer-green-text' : 'installer-red-text'; ?>
48
- <span class="<?php echo $class ?>"><?php echo $v; ?></span>
49
- <?php endif; ?>
50
- </td>
51
- <td class="twelve">
52
- <div class="installer-status-downloading"><?php _e('downloading...', 'installer') ?></div>
53
- <div class="installer-status-downloaded" data-fail="<?php _e('failed!', 'installer') ?>"><?php _e('downloaded', 'installer') ?></div>
54
- </td>
55
- <td class="twelve">
56
- <div class="installer-status-activating"><?php _e('activating', 'installer') ?></div>
57
- <div class="installer-status-activated"><?php _e('activated', 'installer') ?></div>
58
- </td>
59
- </tr>
60
- <?php endforeach; ?>
61
- </tbody>
62
- </table>
63
-
64
- <?php if( !WP_Installer()->dependencies->is_uploading_allowed() ): ?>
65
- <p class="installer-error-box"><?php printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'),
66
- '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>') ?></p>
67
- <?php elseif( WP_Installer()->dependencies->is_win_paths_exception($repository_id) ): ?>
68
- <p><?php echo WP_Installer()->dependencies->win_paths_exception_message() ?></p>
69
- <?php endif;?>
70
-
71
- <br />
72
- <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
73
- &nbsp;
74
- <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php _e('Activate after download', 'installer') ?></label>
75
-
76
- <div class="installer-download-progress-status"></div>
77
- <div class="installer-status-success"><?php _e('Operation complete!', 'installer') ?></div>
78
-
79
- <span class="installer-revalidate-message hidden"><?php _e("Download failed!\n\nClick OK to revalidate your subscription or CANCEL to try again.", 'installer') ?></span>
80
- </form>
1
+
2
+ <form method="post" class="otgsi_downloads_form">
3
+
4
+ <table class="installer-plugins-list-compact">
5
+ <thead>
6
+ <tr>
7
+ <th>&nbsp;</th>
8
+ <th><?php _e('Plugin', 'installer') ?></th>
9
+ <th><img src="<?php echo $this->plugin_url() ?>/res/img/globe.png" alt="<?php esc_attr_e('Available', 'installer') ?>" width="16" height="16"></th>
10
+ <th><img src="<?php echo $this->plugin_url() ?>/res/img/computer.png" alt="<?php esc_attr_e('Installed', 'installer') ?>" width="16" height="16"></th>
11
+ <th><img src="<?php echo $this->plugin_url() ?>/res/img/dn2.gif" alt="<?php esc_attr_e('Downloading', 'installer') ?>" width="16" height="16"></th>
12
+ <th><img src="<?php echo $this->plugin_url() ?>/res/img/on.png" alt="<?php esc_attr_e('Activate', 'installer') ?>" width="16" height="16"></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <?php foreach($product['downloads'] as $download): ?>
17
+ <?php if(empty($tr_oddeven) || $tr_oddeven == 'even') $tr_oddeven = 'odd'; else $tr_oddeven = 'even'; ?>
18
+ <tr class="<?php echo $tr_oddeven ?>">
19
+ <td>
20
+ <label>
21
+ <?php
22
+ $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id );
23
+
24
+ $download_data = array(
25
+ 'url' => $url,
26
+ 'slug' => $download['slug'],
27
+ 'nonce' => wp_create_nonce('install_plugin_' . $url),
28
+ 'repository_id' => $repository_id
29
+ );
30
+
31
+ $disabled = $expired ||
32
+ (
33
+ $this->plugin_is_installed($download['name'], $download['slug'], $download['version']) &&
34
+ !$this->plugin_is_embedded_version($download['name'], $download['slug'])
35
+ ) || WP_Installer()->dependencies->cant_download( $repository_id );
36
+
37
+ ?>
38
+ <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode($download_data)); ?>" <?php
39
+ if($disabled): ?>disabled="disabled"<?php endif; ?> />&nbsp;
40
+
41
+ </label>
42
+ </td>
43
+ <td class="installer_plugin_name"><?php echo $download['name'] ?></td>
44
+ <td><?php echo $download['version'] ?></td>
45
+ <td class="installer_version_installed">
46
+ <?php if($v = $this->plugin_is_installed($download['name'], $download['slug'])):
47
+ $class = version_compare($v, $download['version'], '>=') ? 'installer-green-text' : 'installer-red-text'; ?>
48
+ <span class="<?php echo $class ?>"><?php echo $v; ?></span>
49
+ <?php endif; ?>
50
+ </td>
51
+ <td class="twelve">
52
+ <div class="installer-status-downloading"><?php _e('downloading...', 'installer') ?></div>
53
+ <div class="installer-status-downloaded" data-fail="<?php _e('failed!', 'installer') ?>"><?php _e('downloaded', 'installer') ?></div>
54
+ </td>
55
+ <td class="twelve">
56
+ <div class="installer-status-activating"><?php _e('activating', 'installer') ?></div>
57
+ <div class="installer-status-activated"><?php _e('activated', 'installer') ?></div>
58
+ </td>
59
+ </tr>
60
+ <?php endforeach; ?>
61
+ </tbody>
62
+ </table>
63
+
64
+ <?php if( !WP_Installer()->dependencies->is_uploading_allowed() ): ?>
65
+ <p class="installer-error-box"><?php printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'),
66
+ '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>') ?></p>
67
+ <?php elseif( WP_Installer()->dependencies->is_win_paths_exception($repository_id) ): ?>
68
+ <p><?php echo WP_Installer()->dependencies->win_paths_exception_message() ?></p>
69
+ <?php endif;?>
70
+
71
+ <br />
72
+ <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
73
+ &nbsp;
74
+ <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php _e('Activate after download', 'installer') ?></label>
75
+
76
+ <div class="installer-download-progress-status"></div>
77
+ <div class="installer-status-success"><?php _e('Operation complete!', 'installer') ?></div>
78
+
79
+ <span class="installer-revalidate-message hidden"><?php _e("Download failed!\n\nClick OK to revalidate your subscription or CANCEL to try again.", 'installer') ?></span>
80
+ </form>
vendor/otgs/installer/templates/downloads-list.php CHANGED
@@ -1,109 +1,109 @@
1
-
2
- <form method="post" class="otgsi_downloads_form">
3
-
4
- <div class="installer-table-wrap">
5
- <table class="widefat">
6
- <thead>
7
- <tr>
8
- <th>&nbsp;</th>
9
- <th><?php _e('Plugin', 'installer') ?></th>
10
- <th><?php _e('Installed', 'installer') ?></th>
11
- <th><?php _e('Current', 'installer') ?></th>
12
- <th><?php _e('Released', 'installer') ?></th>
13
- <th>&nbsp;</th>
14
- <th>&nbsp;</th>
15
- <th>&nbsp;</th>
16
- <th>&nbsp;</th>
17
- </tr>
18
- </thead>
19
- <tbody>
20
- <?php
21
- foreach($package['downloads'] as $download_id => $download): ?>
22
- <tr>
23
- <td>
24
- <label>
25
- <?php
26
- $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id);
27
-
28
- $download_data = array(
29
- 'url' => $url,
30
- 'slug' => $download['slug'],
31
- 'nonce' => wp_create_nonce('install_plugin_' . $url),
32
- 'repository_id' => $repository_id
33
- );
34
- ?>
35
- <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode($download_data)); ?>" <?php
36
- if( $this->plugin_is_installed($download['name'], $download['slug'], $download['version'] )
37
- && ! $this->plugin_is_embedded_version( $download['name'], $download['slug'] )
38
- || WP_Installer()->dependencies->cant_download( $repository_id ) ): ?>disabled="disabled"<?php endif; ?> />&nbsp;
39
- </label>
40
- </td>
41
- <td class="installer_plugin_name"><?php echo $download['name'] ?></td>
42
- <td class="installer_version_installed">
43
- <?php if ( $v = $this->plugin_is_installed( $download['name'], $download['slug'] ) ): ?>
44
- <?php
45
- $class = version_compare( $v, $download['version'], '>=' ) ? 'installer-green-text' : 'installer-red-text';
46
- $class .= version_compare( $v, $download['version'], '>' ) ? ' unstable' : '';
47
- ?>
48
- <span class="<?php echo $class ?>"><?php echo $v; ?></span>
49
- <?php if ( $this->plugin_is_embedded_version( $download['name'], $download['slug'] ) ): ?>&nbsp;<?php _e( '(embedded)', 'installer' ); ?><?php endif; ?>
50
- <?php if(
51
- WP_Installer_Channels()->get_channel( $repository_id ) !== WP_Installer_Channels::CHANNEL_PRODUCTION &&
52
- $non_stable = WP_Installer_Channels()->get_download_source_channel( $v, $repository_id, $download_id, 'plugins')
53
- ) : ?>
54
- (<?php echo $non_stable ?>)
55
- <?php endif; ?>
56
- <?php endif; ?>
57
- </td>
58
- <td><?php echo $download['version'] ?></td>
59
- <td><?php echo date_i18n('F j, Y', strtotime($download['date'])) ?></td>
60
- <td>
61
- <?php if ( !empty( $download['release-notes'] ) ): ?>
62
- <a class="js-release-notes handle" href="#"><?php esc_html_e( 'Release notes', 'installer' ) ?></a></td>
63
- <?php endif; ?>
64
- <td>
65
- <span class="installer-status-installing"><?php _e('installing...', 'installer') ?></span>
66
- <span class="installer-status-updating"><?php _e('updating...', 'installer') ?></span>
67
- <span class="installer-status-installed" data-fail="<?php _e('failed!', 'installer') ?>"><?php _e('installed', 'installer') ?></span>
68
- <span class="installer-status-updated" data-fail="<?php _e('failed!', 'installer') ?>"><?php _e('updated', 'installer') ?></span>
69
- </td>
70
- <td>
71
- <span class="installer-status-activating"><?php _e('activating', 'installer') ?></span>
72
- <span class="installer-status-activated"><?php _e('activated', 'installer') ?></span>
73
- </td>
74
- <td class="for_spinner_js"><span class="spinner"></span></td>
75
- </tr>
76
- <?php if ( !empty( $download['release-notes'] ) ): ?>
77
- <tr class="installer-release-notes">
78
- <td colspan="9">
79
- <div class="arrow_box">
80
- <div><?php echo force_balance_tags( $download['release-notes'] ) ?></div>
81
- </div>
82
- </td>
83
- </tr>
84
- <?php endif; ?>
85
- <?php endforeach; ?>
86
- </tbody>
87
- </table>
88
- </div>
89
- <br />
90
-
91
- <div class="installer-error-box">
92
- <?php if( !WP_Installer()->dependencies->is_uploading_allowed() ): ?>
93
- <p><?php printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'),
94
- '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>') ?></p>
95
- <?php elseif( WP_Installer()->dependencies->is_win_paths_exception($repository_id) ): ?>
96
- <p><?php echo WP_Installer()->dependencies->win_paths_exception_message() ?></p>
97
- <?php endif; ?>
98
- </div>
99
-
100
- <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
101
- &nbsp;
102
- <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php _e('Activate after download', 'installer') ?></label>
103
-
104
- <div class="installer-download-progress-status"></div>
105
-
106
- <div class="installer-status-success"><?php _e('Operation complete!', 'installer') ?></div>
107
-
108
- <span class="installer-revalidate-message hidden"><?php _e("Download failed!\n\nPlease refresh the page and try again.", 'installer') ?></span>
109
- </form>
1
+
2
+ <form method="post" class="otgsi_downloads_form">
3
+
4
+ <div class="installer-table-wrap">
5
+ <table class="widefat">
6
+ <thead>
7
+ <tr>
8
+ <th>&nbsp;</th>
9
+ <th><?php _e('Plugin', 'installer') ?></th>
10
+ <th><?php _e('Installed', 'installer') ?></th>
11
+ <th><?php _e('Current', 'installer') ?></th>
12
+ <th><?php _e('Released', 'installer') ?></th>
13
+ <th>&nbsp;</th>
14
+ <th>&nbsp;</th>
15
+ <th>&nbsp;</th>
16
+ <th>&nbsp;</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <?php
21
+ foreach($package['downloads'] as $download_id => $download): ?>
22
+ <tr>
23
+ <td>
24
+ <label>
25
+ <?php
26
+ $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id);
27
+
28
+ $download_data = array(
29
+ 'url' => $url,
30
+ 'slug' => $download['slug'],
31
+ 'nonce' => wp_create_nonce('install_plugin_' . $url),
32
+ 'repository_id' => $repository_id
33
+ );
34
+ ?>
35
+ <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode($download_data)); ?>" <?php
36
+ if( $this->plugin_is_installed($download['name'], $download['slug'], $download['version'] )
37
+ && ! $this->plugin_is_embedded_version( $download['name'], $download['slug'] )
38
+ || WP_Installer()->dependencies->cant_download( $repository_id ) ): ?>disabled="disabled"<?php endif; ?> />&nbsp;
39
+ </label>
40
+ </td>
41
+ <td class="installer_plugin_name"><?php echo $download['name'] ?></td>
42
+ <td class="installer_version_installed">
43
+ <?php if ( $v = $this->plugin_is_installed( $download['name'], $download['slug'] ) ): ?>
44
+ <?php
45
+ $class = version_compare( $v, $download['version'], '>=' ) ? 'installer-green-text' : 'installer-red-text';
46
+ $class .= version_compare( $v, $download['version'], '>' ) ? ' unstable' : '';
47
+ ?>
48
+ <span class="<?php echo $class ?>"><?php echo $v; ?></span>
49
+ <?php if ( $this->plugin_is_embedded_version( $download['name'], $download['slug'] ) ): ?>&nbsp;<?php _e( '(embedded)', 'installer' ); ?><?php endif; ?>
50
+ <?php if(
51
+ WP_Installer_Channels()->get_channel( $repository_id ) !== WP_Installer_Channels::CHANNEL_PRODUCTION &&
52
+ $non_stable = WP_Installer_Channels()->get_download_source_channel( $v, $repository_id, $download_id, 'plugins')
53
+ ) : ?>
54
+ (<?php echo $non_stable ?>)
55
+ <?php endif; ?>
56
+ <?php endif; ?>
57
+ </td>
58
+ <td><?php echo $download['version'] ?></td>
59
+ <td><?php echo date_i18n('F j, Y', strtotime($download['date'])) ?></td>
60
+ <td>
61
+ <?php if ( !empty( $download['release-notes'] ) ): ?>
62
+ <a class="js-release-notes handle" href="#"><?php esc_html_e( 'Release notes', 'installer' ) ?></a></td>
63
+ <?php endif; ?>
64
+ <td>
65
+ <span class="installer-status-installing"><?php _e('installing...', 'installer') ?></span>
66
+ <span class="installer-status-updating"><?php _e('updating...', 'installer') ?></span>
67
+ <span class="installer-status-installed" data-fail="<?php _e('failed!', 'installer') ?>"><?php _e('installed', 'installer') ?></span>
68
+ <span class="installer-status-updated" data-fail="<?php _e('failed!', 'installer') ?>"><?php _e('updated', 'installer') ?></span>
69
+ </td>
70
+ <td>
71
+ <span class="installer-status-activating"><?php _e('activating', 'installer') ?></span>
72
+ <span class="installer-status-activated"><?php _e('activated', 'installer') ?></span>
73
+ </td>
74
+ <td class="for_spinner_js"><span class="spinner"></span></td>
75
+ </tr>
76
+ <?php if ( !empty( $download['release-notes'] ) ): ?>
77
+ <tr class="installer-release-notes">
78
+ <td colspan="9">
79
+ <div class="arrow_box">
80
+ <div><?php echo force_balance_tags( $download['release-notes'] ) ?></div>
81
+ </div>
82
+ </td>
83
+ </tr>
84
+ <?php endif; ?>
85
+ <?php endforeach; ?>
86
+ </tbody>
87
+ </table>
88
+ </div>
89
+ <br />
90
+
91
+ <div class="installer-error-box">
92
+ <?php if( !WP_Installer()->dependencies->is_uploading_allowed() ): ?>
93
+ <p><?php printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'),
94
+ '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>') ?></p>
95
+ <?php elseif( WP_Installer()->dependencies->is_win_paths_exception($repository_id) ): ?>
96
+ <p><?php echo WP_Installer()->dependencies->win_paths_exception_message() ?></p>
97
+ <?php endif; ?>
98
+ </div>
99
+
100
+ <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
101
+ &nbsp;
102
+ <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php _e('Activate after download', 'installer') ?></label>
103
+
104
+ <div class="installer-download-progress-status"></div>
105
+
106
+ <div class="installer-status-success"><?php _e('Operation complete!', 'installer') ?></div>
107
+
108
+ <span class="installer-revalidate-message hidden"><?php _e("Download failed!\n\nPlease refresh the page and try again.", 'installer') ?></span>
109
+ </form>
vendor/otgs/installer/templates/products-compact.php CHANGED
@@ -1,147 +1,147 @@
1
- <h3><?php echo $args['box_title'] ?></h3>
2
-
3
- <?php
4
- if(empty($args['repository']) || empty($args['package']) || empty($args['product'])){
5
- echo __('Incorrect setup', 'installer');
6
- return;
7
- }
8
-
9
- $product = false;
10
- foreach($this->settings['repositories'][$repository_id]['data']['packages'] as $package_idx => $package){
11
-
12
- //pre 1.3 backwardds compatibility
13
- if(!isset($package['id'])){
14
- $package['id'] = sanitize_title_with_dashes($package['name']);
15
- }
16
-
17
- if($package['id'] == $args['package']){
18
- $product = $this->settings['repositories'][$repository_id]['data']['packages'][$package_idx]['products'][$args['product']];
19
- break;
20
- }
21
- }
22
-
23
-
24
- if(!$product){
25
- echo __('Invalid product', 'installer');
26
- return;
27
- }
28
-
29
- if(isset($this->settings['repositories'][$repository_id])){
30
- if(isset($this->settings['repositories'][$repository_id]['subscription']['key'])){
31
- $site_key = $this->settings['repositories'][$repository_id]['subscription']['key'];
32
- }else{
33
- $site_key = false;
34
- }
35
- }else{
36
- echo __('Unknown repository', 'installer');
37
- return;
38
- }
39
-
40
- $subscription_type = $this->get_subscription_type_for_repository($repository_id);
41
- $expired = false;
42
-
43
- if($subscription_type != $product['subscription_type'] && !$this->have_superior_subscription($subscription_type, $product) && $site_key){
44
- $subscription_no_match = sprintf(__(' Your current site key (%s) does not match the selected product (%s).', 'installer'), $site_key, $product['name']);
45
- }
46
-
47
- if(!isset($args['product_name'])) $args['product_name'] = $product['name'];
48
-
49
- ?>
50
-
51
- <div class="otgs_wp_installer_table otgs_wp_installer_table_compact">
52
-
53
- <p><?php echo $args['box_description'] ?></p>
54
-
55
-
56
- <?php if(!$this->repository_has_subscription($repository_id) || !empty($subscription_no_match)): ?>
57
-
58
- <?php if(!empty($subscription_no_match)): ?>
59
- <div class="installer-warn-box">
60
- <?php echo $subscription_no_match; ?>
61
- </div>
62
- <br />
63
- <?php endif; ?>
64
-
65
- <a class="button-primary" href="<?php echo $this->append_parameters_to_buy_url($product['url'], $repository_id, $args) ?>"><?php printf(__('Buy %s', 'installer'), $args['product_name']) ?></a>
66
-
67
- <div>
68
- <br />
69
- <?php printf(__('Already bought %s?', 'installer'), $args['product_name']) ?>
70
- <a class="enter_site_key_js<?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?> disabled<?php endif ?>" href="#"
71
- <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
72
- style="cursor: help"
73
- disabled="disabled"
74
- title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to register.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
75
- <?php endif; ?>
76
- >
77
- <?php _e('Enter site key', 'installer') ?>
78
- </a>&nbsp;&nbsp;
79
-
80
- <form class="otgsi_site_key_form" method="post">
81
- <input type="hidden" name="action" value="save_site_key" />
82
- <input type="hidden" name="nonce" value="<?php echo wp_create_nonce('save_site_key_' . $repository_id) ?>" />
83
- <input type="hidden" name="repository_id" value="<?php echo $repository_id ?>">
84
- <input type="text" size="10" name="site_key_<?php echo $repository_id ?>" />
85
- <input class="button-secondary" type="submit" value="<?php esc_attr_e('Add', 'installer') ?>" />
86
- </form>
87
- <div class="installer-error-box hidden" style="margin-top:10px;"></div>
88
- </div>
89
-
90
- <?php else: ?>
91
-
92
- <?php if($this->repository_has_expired_subscription($repository_id)): $expired = true; ?>
93
-
94
- <div><p class="installer-warn-box"><?php _e('Subscription is expired.', 'installer') ?></p></div>
95
-
96
- <?php else: ?>
97
-
98
- <?php if($this->show_subscription_renew_warning($repository_id, $subscription_type)): ?>
99
-
100
- <ul class="installer-products-list">
101
- <?php foreach($product['renewals'] as $renewal): ?>
102
- <li>
103
- <a href="<?php echo $this->append_parameters_to_buy_url($renewal['url'], $repository_id, $args) ?>"><?php printf(__('Renew %s', 'installer'), $args['product_name']) ?></a>
104
- </li>
105
- <?php endforeach; ?>
106
- </ul>
107
-
108
- <?php endif; ?>
109
-
110
- <?php endif; ?>
111
-
112
- <center>
113
- <a class="remove_site_key_js" href="#" data-repository=<?php echo $repository_id ?>
114
- data-confirmation="<?php esc_attr_e('Are you sure you want to remove this site key?', 'installer') ?>"
115
- data-nonce="<?php echo wp_create_nonce('remove_site_key_' . $repository_id) ?>"
116
- <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
117
- style="cursor: help;color:#999999"
118
- disabled="disabled"
119
- title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to unregister.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
120
- <?php endif; ?>
121
- >
122
- <?php printf(__("Remove current site key (%s)", 'installer'), $site_key) ?>
123
- </a>
124
- </center>
125
- <br />
126
-
127
- <?php include $this->plugin_path() . '/templates/downloads-list-compact.php'; ?>
128
-
129
-
130
-
131
- <?php endif; ?>
132
-
133
- <?php
134
- if( isset( $args[ 'name' ] ) ):
135
- $support_link = $this->get_support_tag_by_name($args['name'], $args['repository']); ?>
136
-
137
- <?php if($support_link): ?>
138
- <p><a href="<?php echo $support_link ?>" target="_blank"><?php printf(__('%s support on wpml.org', 'installer'), $args['name'] ) ?></a></p>
139
-
140
- <?php endif; ?>
141
- <?php
142
- // compatibility for installer 1.1
143
- elseif( isset( $args[ 'support_link' ] ) ): ?>
144
- <p><?php echo $args[ 'support_link' ]; ?></p>
145
- <?php endif; ?>
146
-
147
- </div>
1
+ <h3><?php echo $args['box_title'] ?></h3>
2
+
3
+ <?php
4
+ if(empty($args['repository']) || empty($args['package']) || empty($args['product'])){
5
+ echo __('Incorrect setup', 'installer');
6
+ return;
7
+ }
8
+
9
+ $product = false;
10
+ foreach($this->settings['repositories'][$repository_id]['data']['packages'] as $package_idx => $package){
11
+
12
+ //pre 1.3 backwardds compatibility
13
+ if(!isset($package['id'])){
14
+ $package['id'] = sanitize_title_with_dashes($package['name']);
15
+ }
16
+
17
+ if($package['id'] == $args['package']){
18
+ $product = $this->settings['repositories'][$repository_id]['data']['packages'][$package_idx]['products'][$args['product']];
19
+ break;
20
+ }
21
+ }
22
+
23
+
24
+ if(!$product){
25
+ echo __('Invalid product', 'installer');
26
+ return;
27
+ }
28
+
29
+ if(isset($this->settings['repositories'][$repository_id])){
30
+ if(isset($this->settings['repositories'][$repository_id]['subscription']['key'])){
31
+ $site_key = $this->settings['repositories'][$repository_id]['subscription']['key'];
32
+ }else{
33
+ $site_key = false;
34
+ }
35
+ }else{
36
+ echo __('Unknown repository', 'installer');
37
+ return;
38
+ }
39
+
40
+ $subscription_type = $this->get_subscription_type_for_repository($repository_id);
41
+ $expired = false;
42
+
43
+ if($subscription_type != $product['subscription_type'] && !$this->have_superior_subscription($subscription_type, $product) && $site_key){
44
+ $subscription_no_match = sprintf(__(' Your current site key (%s) does not match the selected product (%s).', 'installer'), $site_key, $product['name']);
45
+ }
46
+
47
+ if(!isset($args['product_name'])) $args['product_name'] = $product['name'];
48
+
49
+ ?>
50
+
51
+ <div class="otgs_wp_installer_table otgs_wp_installer_table_compact">
52
+
53
+ <p><?php echo $args['box_description'] ?></p>
54
+
55
+
56
+ <?php if(!$this->repository_has_subscription($repository_id) || !empty($subscription_no_match)): ?>
57
+
58
+ <?php if(!empty($subscription_no_match)): ?>
59
+ <div class="installer-warn-box">
60
+ <?php echo $subscription_no_match; ?>
61
+ </div>
62
+ <br />
63
+ <?php endif; ?>
64
+
65
+ <a class="button-primary" href="<?php echo $this->append_parameters_to_buy_url($product['url'], $repository_id, $args) ?>"><?php printf(__('Buy %s', 'installer'), $args['product_name']) ?></a>
66
+
67
+ <div>
68
+ <br />
69
+ <?php printf(__('Already bought %s?', 'installer'), $args['product_name']) ?>
70
+ <a class="enter_site_key_js<?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?> disabled<?php endif ?>" href="#"
71
+ <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
72
+ style="cursor: help"
73
+ disabled="disabled"
74
+ title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to register.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
75
+ <?php endif; ?>
76
+ >
77
+ <?php _e('Enter site key', 'installer') ?>
78
+ </a>&nbsp;&nbsp;
79
+
80
+ <form class="otgsi_site_key_form" method="post">
81
+ <input type="hidden" name="action" value="save_site_key" />
82
+ <input type="hidden" name="nonce" value="<?php echo wp_create_nonce('save_site_key_' . $repository_id) ?>" />
83
+ <input type="hidden" name="repository_id" value="<?php echo $repository_id ?>">
84
+ <input type="text" size="10" name="site_key_<?php echo $repository_id ?>" />
85
+ <input class="button-secondary" type="submit" value="<?php esc_attr_e('Add', 'installer') ?>" />
86
+ </form>
87
+ <div class="installer-error-box hidden" style="margin-top:10px;"></div>
88
+ </div>
89
+
90
+ <?php else: ?>
91
+
92
+ <?php if($this->repository_has_expired_subscription($repository_id)): $expired = true; ?>
93
+
94
+ <div><p class="installer-warn-box"><?php _e('Subscription is expired.', 'installer') ?></p></div>
95
+
96
+ <?php else: ?>
97
+
98
+ <?php if($this->show_subscription_renew_warning($repository_id, $subscription_type)): ?>
99
+
100
+ <ul class="installer-products-list">
101
+ <?php foreach($product['renewals'] as $renewal): ?>
102
+ <li>
103
+ <a href="<?php echo $this->append_parameters_to_buy_url($renewal['url'], $repository_id, $args) ?>"><?php printf(__('Renew %s', 'installer'), $args['product_name']) ?></a>
104
+ </li>
105
+ <?php endforeach; ?>
106
+ </ul>
107
+
108
+ <?php endif; ?>
109
+
110
+ <?php endif; ?>
111
+
112
+ <center>
113
+ <a class="remove_site_key_js" href="#" data-repository=<?php echo $repository_id ?>
114
+ data-confirmation="<?php esc_attr_e('Are you sure you want to remove this site key?', 'installer') ?>"
115
+ data-nonce="<?php echo wp_create_nonce('remove_site_key_' . $repository_id) ?>"
116
+ <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
117
+ style="cursor: help;color:#999999"
118
+ disabled="disabled"
119
+ title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to unregister.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
120
+ <?php endif; ?>
121
+ >
122
+ <?php printf(__("Remove current site key (%s)", 'installer'), $site_key) ?>
123
+ </a>
124
+ </center>
125
+ <br />
126
+
127
+ <?php include $this->plugin_path() . '/templates/downloads-list-compact.php'; ?>
128
+
129
+
130
+
131
+ <?php endif; ?>
132
+
133
+ <?php
134
+ if( isset( $args[ 'name' ] ) ):
135
+ $support_link = $this->get_support_tag_by_name($args['name'], $args['repository']); ?>
136
+
137
+ <?php if($support_link): ?>
138
+ <p><a href="<?php echo $support_link ?>" target="_blank"><?php printf(__('%s support on wpml.org', 'installer'), $args['name'] ) ?></a></p>
139
+
140
+ <?php endif; ?>
141
+ <?php
142
+ // compatibility for installer 1.1
143
+ elseif( isset( $args[ 'support_link' ] ) ): ?>
144
+ <p><?php echo $args[ 'support_link' ]; ?></p>
145
+ <?php endif; ?>
146
+
147
+ </div>
vendor/otgs/installer/templates/repository-listing.php CHANGED
@@ -1,199 +1,199 @@
1
- <?php if((!$this->repository_has_subscription($repository_id) && $match = $this->get_matching_cp($repository)) && $match['exp']): ?>
2
- <p class="alignright installer_highlight"><strong><?php printf('Price offers available until %s', date_i18n(get_option( 'date_format' ), $match['exp'])) ?></strong></p>
3
- <?php endif; ?>
4
-
5
- <h3 id="repository-<?php echo $repository_id ?>"><?php echo $repository['data']['name'] ?></h3>
6
- <?php
7
- $generic_product_name = $this->settings['repositories'][$repository_id]['data']['product-name'];
8
- ?>
9
- <table class="widefat otgs_wp_installer_table" id="installer_repo_<?php echo $repository_id ?>">
10
-
11
- <tr>
12
- <td>&nbsp;</td>
13
- <td class="otgsi_register_product_wrap" align="center" valign="top">
14
- <?php // IF NO SUBSCRIPTION ?>
15
- <?php if(!$this->repository_has_subscription($repository_id)): ?>
16
-
17
- <div style="text-align: right;">
18
- <span><?php _e('Already bought?', 'installer'); ?>&nbsp;</span>
19
- <a class="enter_site_key_js button-primary<?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?> disabled<?php endif ?>" href="#"
20
- <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
21
- style="cursor: help"
22
- disabled="disabled"
23
- title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to register.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
24
- <?php endif; ?>
25
- >
26
- <?php printf(__('Register %s', 'installer'), $generic_product_name); ?>
27
- </a>&nbsp;&nbsp;
28
- <form class="otgsi_site_key_form" method="post">
29
- <input type="hidden" name="action" value="save_site_key" />
30
- <input type="hidden" name="nonce" value="<?php echo wp_create_nonce('save_site_key_' . $repository_id) ?>" />
31
- <input type="hidden" name="repository_id" value="<?php echo $repository_id ?>">
32
- <?php _e('2. Enter your site key', 'installer'); ?>
33
- <input type="text" size="10" name="site_key_<?php echo $repository_id ?>" placeholder="<?php echo esc_attr('site key') ?>" />
34
- <input class="button-primary" type="submit" value="<?php esc_attr_e('OK', 'installer') ?>" />
35
- <input class="button-secondary cancel_site_key_js" type="button" value="<?php esc_attr_e('Cancel', 'installer') ?>" />
36
-
37
- <div class="alignleft" style="margin-top:6px;"><?php printf(__('1. Go to your %s%s account%s and add this site URL: %s', 'installer'),
38
- '<a href="' . $this->settings['repositories'][$repository_id]['data']['site_keys_management_url'] . '?add='.urlencode($this->get_installer_site_url( $repository_id )).'">',
39
- $generic_product_name, '</a>', $this->get_installer_site_url( $repository_id )); ?></div>
40
- </form>
41
-
42
-
43
- </div>
44
-
45
- <?php
46
- $site_key = false;
47
-
48
- // IF SUBSCRIPTION
49
- else:
50
-
51
- $site_key = $this->settings['repositories'][$repository_id]['subscription']['key'];
52
- $subscription_type = $this->get_subscription_type_for_repository($repository_id);
53
- $upgrade_options = $this->get_upgrade_options($repository_id);
54
- $expired = false;
55
-
56
- ?>
57
-
58
- <?php if($this->repository_has_expired_subscription($repository_id)): $expired = true; ?>
59
- <div>
60
- <p class="installer-warn-box">
61
- <?php _e('Subscription expired. You need to either purchase a new subscription or upgrade if available.', 'installer') ?>
62
- <span class="alignright">
63
- <a class="update_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?> data-nonce="<?php echo wp_create_nonce('update_site_key_' . $repository_id) ?>">
64
- <?php _e('Revalidate subscription', 'installer'); ?>
65
- </a>
66
- </span>
67
- <br />
68
- <span class="details"><?php _e("If you have already purchased or renewed your subscription and you can still see this message, please revalidate your subscription", 'installer') ?></span>
69
- </p>
70
- </div>
71
- <?php else: ?>
72
- <?php $this->show_subscription_renew_warning($repository_id, $subscription_type); ?>
73
- <?php endif; ?>
74
-
75
- <div class="alignright">
76
- <a class="remove_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?>
77
- data-confirmation="<?php esc_attr_e('Are you sure you want to unregister?', 'installer') ?>"
78
- data-nonce="<?php echo wp_create_nonce('remove_site_key_' . $repository_id) ?>"
79
- <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
80
- style="cursor: help"
81
- disabled="disabled"
82
- title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to unregister.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
83
- <?php endif; ?>
84
- >
85
- <?php printf(__("Unregister %s from this site", 'installer'), $generic_product_name) ?></a>&nbsp;
86
- <a class="update_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?>
87
- data-nonce="<?php echo wp_create_nonce('update_site_key_' . $repository_id) ?>">
88
- <?php _e('Check for updates', 'installer'); ?>
89
- </a>
90
- </div>
91
-
92
- <?php if(empty($expired)): ?>
93
- <div class="alignleft">
94
- <?php if($expires = $this->settings['repositories'][$repository_id]['subscription']['data']->expires): ?>
95
- <?php printf(__('%s is registered on this site. You will receive automatic updates until %s', 'installer'), $generic_product_name, date_i18n('F j, Y', strtotime($expires))); ?>
96
- <?php else: ?>
97
- <?php printf(__('%s is registered on this site. Your Lifetime account gives you updates for life.', 'installer'), $generic_product_name); ?>
98
- <?php endif; ?>
99
- </div>
100
- <?php endif; //if(empty($expired)) ?>
101
-
102
- <?php endif; // if(!repository_has_subscription) ?>
103
- <br clear="all" />
104
- <div class="installer-error-box hidden"></div>
105
-
106
- </td>
107
- </tr>
108
-
109
- <?php
110
-
111
- $subscription_type = isset($subscription_type) ? $subscription_type : null;
112
- $expired = isset($expired) ? $expired : null;
113
- $upgrade_options = isset($upgrade_options) ? $upgrade_options : null;
114
- $packages = $this->_render_product_packages($repository['data']['packages'], $subscription_type, $expired, $upgrade_options, $repository_id);
115
- if(empty($subscription_type) || $expired){
116
- $subpackages_expandable = true;
117
- }else{
118
- $subpackages_expandable = false;
119
- }
120
-
121
- ?>
122
-
123
- <?php foreach($packages as $package): ?>
124
- <tr id="repository-<?php echo $repository_id ?>_<?php echo $package['id'] ?>">
125
- <td class="installer-repository-image"><img width="140" src="<?php echo $package['image_url'] ?>" /></td>
126
- <td>
127
- <p><strong><?php echo $package['name'] ?></strong></p>
128
- <p><?php echo $package['description'] ?></p>
129
-
130
- <?php if($package['products']): ?>
131
- <?php foreach($package['products'] as $product): ?>
132
- <ul class="installer-products-list" style="display:inline">
133
- <li>
134
- <a class="button-secondary" href="<?php echo $product['url'] ?>"><?php echo $product['label'] ?></a>
135
- </li>
136
- </ul>
137
- <?php endforeach; ?>
138
- <?php endif; ?>
139
-
140
- <?php
141
- if ( $package['downloads'] ) {
142
- WP_Installer_Channels()->load_channel_selector( $repository_id, $package['downloads'] );
143
- include $this->plugin_path() . '/templates/downloads-list.php';
144
- }
145
- ?>
146
-
147
- <?php if(!empty($package['sub-packages'])): ?>
148
-
149
- <?php $subpackages = $this->_render_product_packages($package['sub-packages'], $subscription_type, $expired, $upgrade_options, $repository_id); ?>
150
-
151
- <?php if($subpackages): ?>
152
-
153
- <?php if($subpackages_expandable): ?>
154
- <h5><a class="installer_expand_button" href="#" title="<?php esc_attr_e('Click to see individual components options.', 'installer') ?>"><?php _e('Individual components', 'installer') ?></a></h5>
155
- <?php endif; ?>
156
-
157
- <table class="otgs_wp_installer_subtable" style="<?php if($subpackages_expandable) echo 'display:none' ?>">
158
- <?php foreach($subpackages as $package): ?>
159
- <tr id="repository-<?php echo $repository_id ?>_<?php echo $package['id'] ?>">
160
- <td><img width="70" height="70" src="<?php echo $package['image_url'] ?>" /></td>
161
- <td>
162
- <p><strong><?php echo $package['name'] ?></strong></p>
163
- <p><?php echo $package['description'] ?></p>
164
-
165
- <?php if($package['products']): ?>
166
- <?php foreach($package['products'] as $product): ?>
167
- <ul class="installer-products-list" style="display:inline">
168
- <li>
169
- <a class="button-secondary" href="<?php echo $product['url'] ?>"><?php echo $product['label'] ?></a>
170
- </li>
171
- </ul>
172
- <?php endforeach; ?>
173
- <?php endif; ?>
174
-
175
- <?php if($package['downloads']): ?>
176
- <?php include $this->plugin_path() . '/templates/downloads-list.php'; ?>
177
- <?php endif; ?>
178
- </td>
179
- </tr>
180
- <?php endforeach; ?>
181
- </table>
182
- <?php endif; ?>
183
-
184
- <?php endif; ?>
185
-
186
-
187
- </td>
188
- </tr>
189
-
190
- <?php endforeach; ?>
191
-
192
- </table>
193
-
194
-
195
- <p><i><?php printf(__('This page lets you install plugins and update existing plugins. To remove any of these plugins, go to the %splugins%s page and if you have the permission to remove plugins you should be able to do this.', 'installer'), '<a href="' . admin_url('plugins.php') . '">' , '</a>'); ?></i></p>
196
-
197
-
198
-
199
- <br />
1
+ <?php if((!$this->repository_has_subscription($repository_id) && $match = $this->get_matching_cp($repository)) && $match['exp']): ?>
2
+ <p class="alignright installer_highlight"><strong><?php printf('Price offers available until %s', date_i18n(get_option( 'date_format' ), $match['exp'])) ?></strong></p>
3
+ <?php endif; ?>
4
+
5
+ <h3 id="repository-<?php echo $repository_id ?>"><?php echo $repository['data']['name'] ?></h3>
6
+ <?php
7
+ $generic_product_name = $this->settings['repositories'][$repository_id]['data']['product-name'];
8
+ ?>
9
+ <table class="widefat otgs_wp_installer_table" id="installer_repo_<?php echo $repository_id ?>">
10
+
11
+ <tr>
12
+ <td>&nbsp;</td>
13
+ <td class="otgsi_register_product_wrap" align="center" valign="top">
14
+ <?php // IF NO SUBSCRIPTION ?>
15
+ <?php if(!$this->repository_has_subscription($repository_id)): ?>
16
+
17
+ <div style="text-align: right;">
18
+ <span><?php _e('Already bought?', 'installer'); ?>&nbsp;</span>
19
+ <a class="enter_site_key_js button-primary<?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?> disabled<?php endif ?>" href="#"
20
+ <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
21
+ style="cursor: help"
22
+ disabled="disabled"
23
+ title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to register.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
24
+ <?php endif; ?>
25
+ >
26
+ <?php printf(__('Register %s', 'installer'), $generic_product_name); ?>
27
+ </a>&nbsp;&nbsp;
28
+ <form class="otgsi_site_key_form" method="post">
29
+ <input type="hidden" name="action" value="save_site_key" />
30
+ <input type="hidden" name="nonce" value="<?php echo wp_create_nonce('save_site_key_' . $repository_id) ?>" />
31
+ <input type="hidden" name="repository_id" value="<?php echo $repository_id ?>">
32
+ <?php _e('2. Enter your site key', 'installer'); ?>
33
+ <input type="text" size="10" name="site_key_<?php echo $repository_id ?>" placeholder="<?php echo esc_attr('site key') ?>" />
34
+ <input class="button-primary" type="submit" value="<?php esc_attr_e('OK', 'installer') ?>" />
35
+ <input class="button-secondary cancel_site_key_js" type="button" value="<?php esc_attr_e('Cancel', 'installer') ?>" />
36
+
37
+ <div class="alignleft" style="margin-top:6px;"><?php printf(__('1. Go to your %s%s account%s and add this site URL: %s', 'installer'),
38
+ '<a href="' . $this->settings['repositories'][$repository_id]['data']['site_keys_management_url'] . '?add='.urlencode($this->get_installer_site_url( $repository_id )).'">',
39
+ $generic_product_name, '</a>', $this->get_installer_site_url( $repository_id )); ?></div>
40
+ </form>
41
+
42
+
43
+ </div>
44
+
45
+ <?php
46
+ $site_key = false;
47
+
48
+ // IF SUBSCRIPTION
49
+ else:
50
+
51
+ $site_key = $this->settings['repositories'][$repository_id]['subscription']['key'];
52
+ $subscription_type = $this->get_subscription_type_for_repository($repository_id);
53
+ $upgrade_options = $this->get_upgrade_options($repository_id);
54
+ $expired = false;
55
+
56
+ ?>
57
+
58
+ <?php if($this->repository_has_expired_subscription($repository_id)): $expired = true; ?>
59
+ <div>
60
+ <p class="installer-warn-box">
61
+ <?php _e('Subscription expired. You need to either purchase a new subscription or upgrade if available.', 'installer') ?>
62
+ <span class="alignright">
63
+ <a class="update_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?> data-nonce="<?php echo wp_create_nonce('update_site_key_' . $repository_id) ?>">
64
+ <?php _e('Revalidate subscription', 'installer'); ?>
65
+ </a>
66
+ </span>
67
+ <br />
68
+ <span class="details"><?php _e("If you have already purchased or renewed your subscription and you can still see this message, please revalidate your subscription", 'installer') ?></span>
69
+ </p>
70
+ </div>
71
+ <?php else: ?>
72
+ <?php $this->show_subscription_renew_warning($repository_id, $subscription_type); ?>
73
+ <?php endif; ?>
74
+
75
+ <div class="alignright">
76
+ <a class="remove_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?>
77
+ data-confirmation="<?php esc_attr_e('Are you sure you want to unregister?', 'installer') ?>"
78
+ data-nonce="<?php echo wp_create_nonce('remove_site_key_' . $repository_id) ?>"
79
+ <?php if( WP_Installer::get_repository_hardcoded_site_key( $repository_id ) ): ?>
80
+ style="cursor: help"
81
+ disabled="disabled"
82
+ title="<?php printf( esc_attr__("Site-key was set by %s, most likely in wp-config.php. Please remove the constant before attempting to unregister.", 'installer'), 'OTGS_INSTALLER_SITE_KEY_' . strtoupper($repository_id) ) ?>"
83
+ <?php endif; ?>
84
+ >
85
+ <?php printf(__("Unregister %s from this site", 'installer'), $generic_product_name) ?></a>&nbsp;
86
+ <a class="update_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?>
87
+ data-nonce="<?php echo wp_create_nonce('update_site_key_' . $repository_id) ?>">
88
+ <?php _e('Check for updates', 'installer'); ?>
89
+ </a>
90
+ </div>
91
+
92
+ <?php if(empty($expired)): ?>
93
+ <div class="alignleft">
94
+ <?php if($expires = $this->settings['repositories'][$repository_id]['subscription']['data']->expires): ?>
95
+ <?php printf(__('%s is registered on this site. You will receive automatic updates until %s', 'installer'), $generic_product_name, date_i18n('F j, Y', strtotime($expires))); ?>
96
+ <?php else: ?>
97
+ <?php printf(__('%s is registered on this site. Your Lifetime account gives you updates for life.', 'installer'), $generic_product_name); ?>
98
+ <?php endif; ?>
99
+ </div>
100
+ <?php endif; //if(empty($expired)) ?>
101
+
102
+ <?php endif; // if(!repository_has_subscription) ?>
103
+ <br clear="all" />
104
+ <div class="installer-error-box hidden"></div>
105
+
106
+ </td>
107
+ </tr>
108
+
109
+ <?php
110
+
111
+ $subscription_type = isset($subscription_type) ? $subscription_type : null;
112
+ $expired = isset($expired) ? $expired : null;
113
+ $upgrade_options = isset($upgrade_options) ? $upgrade_options : null;
114
+ $packages = $this->_render_product_packages($repository['data']['packages'], $subscription_type, $expired, $upgrade_options, $repository_id);
115
+ if(empty($subscription_type) || $expired){
116
+ $subpackages_expandable = true;
117
+ }else{
118
+ $subpackages_expandable = false;
119
+ }
120
+
121
+ ?>
122
+
123
+ <?php foreach($packages as $package): ?>
124
+ <tr id="repository-<?php echo $repository_id ?>_<?php echo $package['id'] ?>">
125
+ <td class="installer-repository-image"><img width="140" src="<?php echo $package['image_url'] ?>" /></td>
126
+ <td>
127
+ <p><strong><?php echo $package['name'] ?></strong></p>
128
+ <p><?php echo $package['description'] ?></p>
129
+
130
+ <?php if($package['products']): ?>
131
+ <?php foreach($package['products'] as $product): ?>
132
+ <ul class="installer-products-list" style="display:inline">
133
+ <li>
134
+ <a class="button-secondary" href="<?php echo $product['url'] ?>"><?php echo $product['label'] ?></a>
135
+ </li>
136
+ </ul>
137
+ <?php endforeach; ?>
138
+ <?php endif; ?>
139
+
140
+ <?php
141
+ if ( $package['downloads'] ) {
142
+ WP_Installer_Channels()->load_channel_selector( $repository_id, $package['downloads'] );
143
+ include $this->plugin_path() . '/templates/downloads-list.php';
144
+ }
145
+ ?>
146
+
147
+ <?php if(!empty($package['sub-packages'])): ?>
148
+
149
+ <?php $subpackages = $this->_render_product_packages($package['sub-packages'], $subscription_type, $expired, $upgrade_options, $repository_id); ?>
150
+
151
+ <?php if($subpackages): ?>
152
+
153
+ <?php if($subpackages_expandable): ?>
154
+ <h5><a class="installer_expand_button" href="#" title="<?php esc_attr_e('Click to see individual components options.', 'installer') ?>"><?php _e('Individual components', 'installer') ?></a></h5>
155
+ <?php endif; ?>
156
+
157
+ <table class="otgs_wp_installer_subtable" style="<?php if($subpackages_expandable) echo 'display:none' ?>">
158
+ <?php foreach($subpackages as $package): ?>
159
+ <tr id="repository-<?php echo $repository_id ?>_<?php echo $package['id'] ?>">
160
+ <td><img width="70" height="70" src="<?php echo $package['image_url'] ?>" /></td>
161
+ <td>
162
+ <p><strong><?php echo $package['name'] ?></strong></p>
163
+ <p><?php echo $package['description'] ?></p>
164
+
165
+ <?php if($package['products']): ?>
166
+ <?php foreach($package['products'] as $product): ?>
167
+ <ul class="installer-products-list" style="display:inline">
168
+ <li>
169
+ <a class="button-secondary" href="<?php echo $product['url'] ?>"><?php echo $product['label'] ?></a>
170
+ </li>
171
+ </ul>
172
+ <?php endforeach; ?>
173
+ <?php endif; ?>
174
+
175
+ <?php if($package['downloads']): ?>
176
+ <?php include $this->plugin_path() . '/templates/downloads-list.php'; ?>
177
+ <?php endif; ?>
178
+ </td>
179
+ </tr>
180
+ <?php endforeach; ?>
181
+ </table>
182
+ <?php endif; ?>
183
+
184
+ <?php endif; ?>
185
+
186
+
187
+ </td>
188
+ </tr>
189
+
190
+ <?php endforeach; ?>
191
+
192
+ </table>
193
+
194
+
195
+ <p><i><?php printf(__('This page lets you install plugins and update existing plugins. To remove any of these plugins, go to the %splugins%s page and if you have the permission to remove plugins you should be able to do this.', 'installer'), '<a href="' . admin_url('plugins.php') . '">' , '</a>'); ?></i></p>
196
+
197
+
198
+
199
+ <br />
vendor/twig/twig/CHANGELOG CHANGED
@@ -1,46 +1,3 @@
1
- * 1.34.4 (2017-XX-XX)
2
-
3
- * fixed deprecation when using Twig_Profiler_Dumper_Html
4
-
5
- * 1.34.3 (2017-06-07)
6
-
7
- * fixed namespaces introduction
8
-
9
- * 1.34.2 (2017-06-05)
10
-
11
- * fixed namespaces introduction
12
-
13
- * 1.34.1 (2017-06-05)
14
-
15
- * fixed namespaces introduction
16
-
17
- * 1.34.0 (2017-06-05)
18
-
19
- * added support for PHPUnit 6 when testing extensions
20
- * fixed PHP 7.2 compatibility
21
- * fixed template name generation in Twig_Environment::createTemplate()
22
- * removed final tag on Twig_TokenParser_Include
23
- * added namespaced aliases for all (non-deprecated) classes and interfaces
24
- * dropped HHVM support
25
- * dropped PHP 5.2 support
26
-
27
- * 1.33.2 (2017-04-20)
28
-
29
- * fixed edge case in the method cache for Twig attributes
30
-
31
- * 1.33.1 (2017-04-18)
32
-
33
- * fixed the empty() test
34
-
35
- * 1.33.0 (2017-03-22)
36
-
37
- * fixed a race condition handling when writing cache files
38
- * "length" filter now returns string length when applied to an object that does
39
- not implement \Countable but provides __toString()
40
- * "empty" test will now consider the return value of the __toString() method for
41
- objects implement __toString() but not \Countable
42
- * fixed JS escaping for unicode characters with higher code points
43
-
44
  * 1.32.0 (2017-02-26)
45
 
46
  * fixed deprecation notice in Twig_Util_DeprecationCollector
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  * 1.32.0 (2017-02-26)
2
 
3
  * fixed deprecation notice in Twig_Util_DeprecationCollector
vendor/twig/twig/ext/twig/php_twig.h CHANGED
@@ -15,7 +15,7 @@
15
  #ifndef PHP_TWIG_H
16
  #define PHP_TWIG_H
17
 
18
- #define PHP_TWIG_VERSION "1.34.4-DEV"
19
 
20
  #include "php.h"
21
 
15
  #ifndef PHP_TWIG_H
16
  #define PHP_TWIG_H
17
 
18
+ #define PHP_TWIG_VERSION "1.32.0"
19
 
20
  #include "php.h"
21
 
vendor/twig/twig/lib/Twig/BaseNodeVisitor.php CHANGED
@@ -48,7 +48,3 @@ abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
48
  */
49
  abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env);
50
  }
51
-
52
- class_alias('Twig_BaseNodeVisitor', 'Twig\NodeVisitor\AbstractNodeVisitor', false);
53
- class_exists('Twig_Environment');
54
- class_exists('Twig_Node');
48
  */
49
  abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env);
50
  }
 
 
 
 
vendor/twig/twig/lib/Twig/Cache/Filesystem.php CHANGED
@@ -49,13 +49,8 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
49
  {
50
  $dir = dirname($key);
51
  if (!is_dir($dir)) {
52
- if (false === @mkdir($dir, 0777, true)) {
53
- if (PHP_VERSION_ID >= 50300) {
54
- clearstatcache(true, $dir);
55
- }
56
- if (!is_dir($dir)) {
57
- throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
58
- }
59
  }
60
  } elseif (!is_writable($dir)) {
61
  throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
@@ -89,5 +84,3 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
89
  return (int) @filemtime($key);
90
  }
91
  }
92
-
93
- class_alias('Twig_Cache_Filesystem', 'Twig\Cache\FilesystemCache', false);
49
  {
50
  $dir = dirname($key);
51
  if (!is_dir($dir)) {
52
+ if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
53
+ throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
 
 
 
 
 
54
  }
55
  } elseif (!is_writable($dir)) {
56
  throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
84
  return (int) @filemtime($key);
85
  }
86
  }
 
 
vendor/twig/twig/lib/Twig/Cache/Null.php CHANGED
@@ -36,5 +36,3 @@ class Twig_Cache_Null implements Twig_CacheInterface
36
  return 0;
37
  }
38
  }
39
-
40
- class_alias('Twig_Cache_Null', 'Twig\Cache\NullCache', false);
36
  return 0;
37
  }
38
  }
 
 
vendor/twig/twig/lib/Twig/CacheInterface.php CHANGED
@@ -54,5 +54,3 @@ interface Twig_CacheInterface
54
  */
55
  public function getTimestamp($key);
56
  }
57
-
58
- class_alias('Twig_CacheInterface', 'Twig\Cache\CacheInterface', false);
54
  */
55
  public function getTimestamp($key);
56
  }
 
 
vendor/twig/twig/lib/Twig/Compiler.php CHANGED
@@ -169,7 +169,7 @@ class Twig_Compiler implements Twig_CompilerInterface
169
  public function repr($value)
170
  {
171
  if (is_int($value) || is_float($value)) {
172
- if (false !== $locale = setlocale(LC_NUMERIC, '0')) {
173
  setlocale(LC_NUMERIC, 'C');
174
  }
175
 
@@ -279,6 +279,3 @@ class Twig_Compiler implements Twig_CompilerInterface
279
  return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
280
  }
281
  }
282
-
283
- class_alias('Twig_Compiler', 'Twig\Compiler', false);
284
- class_exists('Twig_Node');
169
  public function repr($value)
170
  {
171
  if (is_int($value) || is_float($value)) {
172
+ if (false !== $locale = setlocale(LC_NUMERIC, 0)) {
173
  setlocale(LC_NUMERIC, 'C');
174
  }
175
 
279
  return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
280
  }
281
  }
 
 
 
vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php CHANGED
@@ -35,5 +35,3 @@ class Twig_ContainerRuntimeLoader implements Twig_RuntimeLoaderInterface
35
  }
36
  }
37
  }
38
-
39
- class_alias('Twig_ContainerRuntimeLoader', 'Twig\RuntimeLoader\ContainerRuntimeLoader', false);
35
  }
36
  }
37
  }
 
 
vendor/twig/twig/lib/Twig/Environment.php CHANGED
@@ -16,12 +16,12 @@
16
  */
17
  class Twig_Environment
18
  {
19
- const VERSION = '1.34.4-DEV';
20
- const VERSION_ID = 13404;
21
  const MAJOR_VERSION = 1;
22
- const MINOR_VERSION = 34;
23
- const RELEASE_VERSION = 4;
24
- const EXTRA_VERSION = 'DEV';
25
 
26
  protected $charset;
27
  protected $loader;
@@ -489,7 +489,7 @@ class Twig_Environment
489
  */
490
  public function createTemplate($template)
491
  {
492
- $name = sprintf('__string_template__%s', hash('sha256', $template, false));
493
 
494
  $loader = new Twig_Loader_Chain(array(
495
  new Twig_Loader_Array(array($name => $template)),
@@ -758,7 +758,7 @@ class Twig_Environment
758
 
759
  public function setLoader(Twig_LoaderInterface $loader)
760
  {
761
- if (!$loader instanceof Twig_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_')) {
762
  @trigger_error(sprintf('Twig loader "%s" should implement Twig_SourceContextLoaderInterface since version 1.27.', get_class($loader)), E_USER_DEPRECATED);
763
  }
764
 
@@ -831,12 +831,6 @@ class Twig_Environment
831
  public function hasExtension($class)
832
  {
833
  $class = ltrim($class, '\\');
834
- if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
835
- // For BC/FC with namespaced aliases
836
- $class = new ReflectionClass($class);
837
- $class = $class->name;
838
- }
839
-
840
  if (isset($this->extensions[$class])) {
841
  if ($class !== get_class($this->extensions[$class])) {
842
  @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
@@ -866,11 +860,6 @@ class Twig_Environment
866
  public function getExtension($class)
867
  {
868
  $class = ltrim($class, '\\');
869
- if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
870
- // For BC/FC with namespaced aliases
871
- $class = new ReflectionClass($class);
872
- $class = $class->name;
873
- }
874
 
875
  if (isset($this->extensions[$class])) {
876
  if ($class !== get_class($this->extensions[$class])) {
@@ -949,12 +938,6 @@ class Twig_Environment
949
  }
950
 
951
  $class = ltrim($name, '\\');
952
- if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
953
- // For BC/FC with namespaced aliases
954
- $class = new ReflectionClass($class);
955
- $class = $class->name;
956
- }
957
-
958
  if (isset($this->extensions[$class])) {
959
  if ($class !== get_class($this->extensions[$class])) {
960
  @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
@@ -1576,5 +1559,3 @@ class Twig_Environment
1576
  $this->optionsHash = implode(':', $hashParts);
1577
  }
1578
  }
1579
-
1580
- class_alias('Twig_Environment', 'Twig\Environment', false);
16
  */
17
  class Twig_Environment
18
  {
19
+ const VERSION = '1.32.0';
20
+ const VERSION_ID = 13200;
21
  const MAJOR_VERSION = 1;
22
+ const MINOR_VERSION = 32;
23
+ const RELEASE_VERSION = 0;
24
+ const EXTRA_VERSION = '';
25
 
26
  protected $charset;
27
  protected $loader;
489
  */
490
  public function createTemplate($template)
491
  {
492
+ $name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
493
 
494
  $loader = new Twig_Loader_Chain(array(
495
  new Twig_Loader_Array(array($name => $template)),
758
 
759
  public function setLoader(Twig_LoaderInterface $loader)
760
  {
761
+ if (!$loader instanceof Twig_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_Twig_LoaderInterface')) {
762
  @trigger_error(sprintf('Twig loader "%s" should implement Twig_SourceContextLoaderInterface since version 1.27.', get_class($loader)), E_USER_DEPRECATED);
763
  }
764
 
831
  public function hasExtension($class)
832
  {
833
  $class = ltrim($class, '\\');
 
 
 
 
 
 
834
  if (isset($this->extensions[$class])) {
835
  if ($class !== get_class($this->extensions[$class])) {
836
  @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
860
  public function getExtension($class)
861
  {
862
  $class = ltrim($class, '\\');
 
 
 
 
 
863
 
864
  if (isset($this->extensions[$class])) {
865
  if ($class !== get_class($this->extensions[$class])) {
938
  }
939
 
940
  $class = ltrim($name, '\\');
 
 
 
 
 
 
941
  if (isset($this->extensions[$class])) {
942
  if ($class !== get_class($this->extensions[$class])) {
943
  @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
1559
  $this->optionsHash = implode(':', $hashParts);
1560
  }
1561
  }
 
 
vendor/twig/twig/lib/Twig/Error.php CHANGED
@@ -332,6 +332,11 @@ class Twig_Error extends Exception
332
  $r = new ReflectionObject($template);
333
  $file = $r->getFileName();
334
 
 
 
 
 
 
335
  $exceptions = array($e = $this);
336
  while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) {
337
  $exceptions[] = $e;
@@ -358,6 +363,3 @@ class Twig_Error extends Exception
358
  }
359
  }
360
  }
361
-
362
- class_alias('Twig_Error', 'Twig\Error\Error', false);
363
- class_exists('Twig_Source');
332
  $r = new ReflectionObject($template);
333
  $file = $r->getFileName();
334
 
335
+ // hhvm has a bug where eval'ed files comes out as the current directory
336
+ if (is_dir($file)) {
337
+ $file = '';
338
+ }
339
+
340
  $exceptions = array($e = $this);
341
  while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) {
342
  $exceptions[] = $e;
363
  }
364
  }
365
  }
 
 
 
vendor/twig/twig/lib/Twig/Error/Loader.php CHANGED
@@ -36,5 +36,3 @@ class Twig_Error_Loader extends Twig_Error
36
  $this->setTemplateLine(false);
37
  }
38
  }
39
-
40
- class_alias('Twig_Error_Loader', 'Twig\Error\LoaderError', false);
36
  $this->setTemplateLine(false);
37
  }
38
  }
 
 
vendor/twig/twig/lib/Twig/Error/Runtime.php CHANGED
@@ -18,5 +18,3 @@
18
  class Twig_Error_Runtime extends Twig_Error
19
  {
20
  }
21
-
22
- class_alias('Twig_Error_Runtime', 'Twig\Error\RuntimeError', false);
18
  class Twig_Error_Runtime extends Twig_Error
19
  {
20
  }
 
 
vendor/twig/twig/lib/Twig/Error/Syntax.php CHANGED
@@ -51,5 +51,3 @@ class Twig_Error_Syntax extends Twig_Error
51
  return array_keys($alternatives);
52
  }
53
  }
54
-
55
- class_alias('Twig_Error_Syntax', 'Twig\Error\SyntaxError', false);
51
  return array_keys($alternatives);
52
  }
53
  }
 
 
vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php CHANGED
@@ -27,5 +27,3 @@ interface Twig_ExistsLoaderInterface
27
  */
28
  public function exists($name);
29
  }
30
-
31
- class_alias('Twig_ExistsLoaderInterface', 'Twig\Loader\ExistsLoaderInterface', false);
27
  */
28
  public function exists($name);
29
  }
 
 
vendor/twig/twig/lib/Twig/ExpressionParser.php CHANGED
@@ -737,5 +737,3 @@ class Twig_ExpressionParser
737
  return true;
738
  }
739
  }
740
-
741
- class_alias('Twig_ExpressionParser', 'Twig\ExpressionParser', false);
737
  return true;
738
  }
739
  }
 
 
vendor/twig/twig/lib/Twig/Extension.php CHANGED
@@ -8,7 +8,6 @@
8
  * For the full copyright and license information, please view the LICENSE
9
  * file that was distributed with this source code.
10
  */
11
-
12
  abstract class Twig_Extension implements Twig_ExtensionInterface
13
  {
14
  /**
@@ -64,6 +63,3 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
64
  return get_class($this);
65
  }
66
  }
67
-
68
- class_alias('Twig_Extension', 'Twig\Extension\AbstractExtension', false);
69
- class_exists('Twig_Environment');
8
  * For the full copyright and license information, please view the LICENSE
9
  * file that was distributed with this source code.
10
  */
 
11
  abstract class Twig_Extension implements Twig_ExtensionInterface
12
  {
13
  /**
63
  return get_class($this);
64
  }
65
  }
 
 
 
vendor/twig/twig/lib/Twig/Extension/Core.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
 
3
  if (!defined('ENT_SUBSTITUTE')) {
4
- define('ENT_SUBSTITUTE', 8);
 
5
  }
6
 
7
  /*
@@ -1005,22 +1006,30 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
1005
  // Using a static variable to avoid initializing the array
1006
  // each time the function is called. Moving the declaration on the
1007
  // top of the function slow downs other escaping strategies.
1008
- static $htmlspecialcharsCharsets = array(
1009
- 'ISO-8859-1' => true, 'ISO8859-1' => true,
1010
- 'ISO-8859-15' => true, 'ISO8859-15' => true,
1011
- 'utf-8' => true, 'UTF-8' => true,
1012
- 'CP866' => true, 'IBM866' => true, '866' => true,
1013
- 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
1014
- '1251' => true,
1015
- 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
1016
- 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
1017
- 'BIG5' => true, '950' => true,
1018
- 'GB2312' => true, '936' => true,
1019
- 'BIG5-HKSCS' => true,
1020
- 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
1021
- 'EUC-JP' => true, 'EUCJP' => true,
1022
- 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
1023
- );
 
 
 
 
 
 
 
 
1024
 
1025
  if (isset($htmlspecialcharsCharsets[$charset])) {
1026
  return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
@@ -1159,13 +1168,8 @@ function _twig_escape_js_callback($matches)
1159
 
1160
  // \uHHHH
1161
  $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
1162
- $char = strtoupper(bin2hex($char));
1163
 
1164
- if (4 >= strlen($char)) {
1165
- return sprintf('\u%04s', $char);
1166
- }
1167
-
1168
- return sprintf('\u%04s\u%04s', substr($char, 0, -4), substr($char, -4));
1169
  }
1170
 
1171
  function _twig_escape_css_callback($matches)
@@ -1255,23 +1259,7 @@ if (function_exists('mb_get_info')) {
1255
  */
1256
  function twig_length_filter(Twig_Environment $env, $thing)
1257
  {
1258
- if (null === $thing) {
1259
- return 0;
1260
- }
1261
-
1262
- if (is_scalar($thing)) {
1263
- return mb_strlen($thing, $env->getCharset());
1264
- }
1265
-
1266
- if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
1267
- return mb_strlen((string) $thing, $env->getCharset());
1268
- }
1269
-
1270
- if ($thing instanceof \Countable || is_array($thing)) {
1271
- return count($thing);
1272
- }
1273
-
1274
- return 1;
1275
  }
1276
 
1277
  /**
@@ -1354,23 +1342,7 @@ else {
1354
  */
1355
  function twig_length_filter(Twig_Environment $env, $thing)
1356
  {
1357
- if (null === $thing) {
1358
- return 0;
1359
- }
1360
-
1361
- if (is_scalar($thing)) {
1362
- return strlen($thing);
1363
- }
1364
-
1365
- if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
1366
- return strlen((string) $thing);
1367
- }
1368
-
1369
- if ($thing instanceof \Countable || is_array($thing)) {
1370
- return count($thing);
1371
- }
1372
-
1373
- return 1;
1374
  }
1375
 
1376
  /**
@@ -1432,10 +1404,6 @@ function twig_test_empty($value)
1432
  return 0 == count($value);
1433
  }
1434
 
1435
- if (is_object($value) && method_exists($value, '__toString')) {
1436
- return '' === (string) $value;
1437
- }
1438
-
1439
  return '' === $value || false === $value || null === $value || array() === $value;
1440
  }
1441
 
@@ -1608,5 +1576,3 @@ function twig_array_batch($items, $size, $fill = null)
1608
 
1609
  return $result;
1610
  }
1611
-
1612
- class_alias('Twig_Extension_Core', 'Twig\Extension\CoreExtension', false);
1
  <?php
2
 
3
  if (!defined('ENT_SUBSTITUTE')) {
4
+ // use 0 as hhvm does not support several flags yet
5
+ define('ENT_SUBSTITUTE', 0);
6
  }
7
 
8
  /*
1006
  // Using a static variable to avoid initializing the array
1007
  // each time the function is called. Moving the declaration on the
1008
  // top of the function slow downs other escaping strategies.
1009
+ static $htmlspecialcharsCharsets;
1010
+
1011
+ if (null === $htmlspecialcharsCharsets) {
1012
+ if (defined('HHVM_VERSION')) {
1013
+ $htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
1014
+ } else {
1015
+ $htmlspecialcharsCharsets = array(
1016
+ 'ISO-8859-1' => true, 'ISO8859-1' => true,
1017
+ 'ISO-8859-15' => true, 'ISO8859-15' => true,
1018
+ 'utf-8' => true, 'UTF-8' => true,
1019
+ 'CP866' => true, 'IBM866' => true, '866' => true,
1020
+ 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
1021
+ '1251' => true,
1022
+ 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
1023
+ 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
1024
+ 'BIG5' => true, '950' => true,
1025
+ 'GB2312' => true, '936' => true,
1026
+ 'BIG5-HKSCS' => true,
1027
+ 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
1028
+ 'EUC-JP' => true, 'EUCJP' => true,
1029
+ 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
1030
+ );
1031
+ }
1032
+ }
1033
 
1034
  if (isset($htmlspecialcharsCharsets[$charset])) {
1035
  return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
1168
 
1169
  // \uHHHH
1170
  $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
 
1171
 
1172
+ return '\\u'.strtoupper(substr('0000'.bin2hex($char), -4));
 
 
 
 
1173
  }
1174
 
1175
  function _twig_escape_css_callback($matches)
1259
  */
1260
  function twig_length_filter(Twig_Environment $env, $thing)
1261
  {
1262
+ return is_scalar($thing) ? mb_strlen($thing, $env->getCharset()) : count($thing);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
  }
1264
 
1265
  /**
1342
  */
1343
  function twig_length_filter(Twig_Environment $env, $thing)
1344
  {
1345
+ return is_scalar($thing) ? strlen($thing) : count($thing);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1346
  }
1347
 
1348
  /**
1404
  return 0 == count($value);
1405
  }
1406
 
 
 
 
 
1407
  return '' === $value || false === $value || null === $value || array() === $value;
1408
  }
1409
 
1576
 
1577
  return $result;
1578
  }
 
 
vendor/twig/twig/lib/Twig/Extension/Debug.php CHANGED
@@ -23,7 +23,7 @@ class Twig_Extension_Debug extends Twig_Extension
23
  // false means that it was not set (and the default is on) or it explicitly enabled
24
  // xdebug.overload_var_dump produces HTML only when html_errors is also enabled
25
  && (false === ini_get('html_errors') || ini_get('html_errors'))
26
- || 'cli' === PHP_SAPI
27
  ;
28
 
29
  return array(
@@ -63,5 +63,3 @@ function twig_var_dump(Twig_Environment $env, $context)
63
 
64
  return ob_get_clean();
65
  }
66
-
67
- class_alias('Twig_Extension_Debug', 'Twig\Extension\DebugExtension', false);
23
  // false means that it was not set (and the default is on) or it explicitly enabled
24
  // xdebug.overload_var_dump produces HTML only when html_errors is also enabled
25
  && (false === ini_get('html_errors') || ini_get('html_errors'))
26
+ || 'cli' === php_sapi_name()
27
  ;
28
 
29
  return array(
63
 
64
  return ob_get_clean();
65
  }
 
 
vendor/twig/twig/lib/Twig/Extension/Escaper.php CHANGED
@@ -108,5 +108,3 @@ function twig_raw_filter($string)
108
  {
109
  return $string;
110
  }
111
-
112
- class_alias('Twig_Extension_Escaper', 'Twig\Extension\EscaperExtension', false);
108
  {
109
  return $string;
110
  }
 
 
vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php CHANGED
@@ -20,5 +20,3 @@
20
  interface Twig_Extension_GlobalsInterface
21
  {
22
  }
23
-
24
- class_alias('Twig_Extension_GlobalsInterface', 'Twig\Extension\GlobalsInterface', false);
20
  interface Twig_Extension_GlobalsInterface
21
  {
22
  }
 
 
vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php CHANGED
@@ -20,5 +20,3 @@
20
  interface Twig_Extension_InitRuntimeInterface
21
  {
22
  }
23
-
24
- class_alias('Twig_Extension_InitRuntimeInterface', 'Twig\Extension\InitRuntimeInterface', false);
20
  interface Twig_Extension_InitRuntimeInterface
21
  {
22
  }
 
 
vendor/twig/twig/lib/Twig/Extension/Optimizer.php CHANGED
@@ -31,5 +31,3 @@ class Twig_Extension_Optimizer extends Twig_Extension
31
  return 'optimizer';
32
  }
33
  }
34
-
35
- class_alias('Twig_Extension_Optimizer', 'Twig\Extension\OptimizerExtension', false);
31
  return 'optimizer';
32
  }
33
  }
 
 
vendor/twig/twig/lib/Twig/Extension/Profiler.php CHANGED
@@ -44,6 +44,3 @@ class Twig_Extension_Profiler extends Twig_Extension
44
  return 'profiler';
45
  }
46
  }
47
-
48
- class_alias('Twig_Extension_Profiler', 'Twig\Extension\ProfilerExtension', false);
49
- class_exists('Twig_Profiler_Profile');
44
  return 'profiler';
45
  }
46
  }
 
 
 
vendor/twig/twig/lib/Twig/Extension/Sandbox.php CHANGED
@@ -99,5 +99,3 @@ class Twig_Extension_Sandbox extends Twig_Extension
99
  return 'sandbox';
100
  }
101
  }
102
-
103
- class_alias('Twig_Extension_Sandbox', 'Twig\Extension\SandboxExtension', false);
99
  return 'sandbox';
100
  }
101
  }
 
 
vendor/twig/twig/lib/Twig/Extension/Staging.php CHANGED
@@ -108,5 +108,3 @@ class Twig_Extension_Staging extends Twig_Extension
108
  return 'staging';
109
  }
110
  }
111
-
112
- class_alias('Twig_Extension_Staging', 'Twig\Extension\StagingExtension', false);
108
  return 'staging';
109
  }
110
  }
 
 
vendor/twig/twig/lib/Twig/Extension/StringLoader.php CHANGED
@@ -43,5 +43,3 @@ function twig_template_from_string(Twig_Environment $env, $template)
43
  {
44
  return $env->createTemplate((string) $template);
45
  }
46
-
47
- class_alias('Twig_Extension_StringLoader', 'Twig\Extension\StringLoaderExtension', false);
43
  {
44
  return $env->createTemplate((string) $template);
45
  }
 
 
vendor/twig/twig/lib/Twig/ExtensionInterface.php CHANGED
@@ -85,6 +85,3 @@ interface Twig_ExtensionInterface
85
  */
86
  public function getName();
87
  }
88
-
89
- class_alias('Twig_ExtensionInterface', 'Twig\Extension\ExtensionInterface', false);
90
- class_exists('Twig_Environment');
85
  */
86
  public function getName();
87
  }
 
 
 
vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php CHANGED
@@ -35,5 +35,3 @@ class Twig_FactoryRuntimeLoader implements Twig_RuntimeLoaderInterface
35
  }
36
  }
37
  }
38
-
39
- class_alias('Twig_FactoryRuntimeLoader', 'Twig\RuntimeLoader\FactoryRuntimeLoader', false);
35
  }
36
  }
37
  }
 
 
vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php CHANGED
@@ -56,5 +56,3 @@ class Twig_FileExtensionEscapingStrategy
56
  }
57
  }
58
  }
59
-
60
- class_alias('Twig_FileExtensionEscapingStrategy', 'Twig\FileExtensionEscapingStrategy', false);
56
  }
57
  }
58
  }
 
 
vendor/twig/twig/lib/Twig/Lexer.php CHANGED
@@ -420,5 +420,3 @@ class Twig_Lexer implements Twig_LexerInterface
420
  $this->state = array_pop($this->states);
421
  }
422
  }
423
-
424
- class_alias('Twig_Lexer', 'Twig\Lexer', false);
420
  $this->state = array_pop($this->states);
421
  }
422
  }
 
 
vendor/twig/twig/lib/Twig/Loader/Array.php CHANGED
@@ -80,7 +80,7 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
80
  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
81
  }
82
 
83
- return $name.':'.$this->templates[$name];
84
  }
85
 
86
  public function isFresh($name, $time)
@@ -93,5 +93,3 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
93
  return true;
94
  }
95
  }
96
-
97
- class_alias('Twig_Loader_Array', 'Twig\Loader\ArrayLoader', false);
80
  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
81
  }
82
 
83
+ return $this->templates[$name];
84
  }
85
 
86
  public function isFresh($name, $time)
93
  return true;
94
  }
95
  }
 
 
vendor/twig/twig/lib/Twig/Loader/Chain.php CHANGED
@@ -147,5 +147,3 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
147
  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
148
  }
149
  }
150
-
151
- class_alias('Twig_Loader_Chain', 'Twig\Loader\ChainLoader', false);
147
  throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
148
  }
149
  }
 
 
vendor/twig/twig/lib/Twig/Loader/Filesystem.php CHANGED
@@ -286,5 +286,3 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
286
  ;
287
  }
288
  }
289
-
290
- class_alias('Twig_Loader_Filesystem', 'Twig\Loader\FilesystemLoader', false);
286
  ;
287
  }
288
  }
 
 
vendor/twig/twig/lib/Twig/LoaderInterface.php CHANGED
@@ -53,5 +53,3 @@ interface Twig_LoaderInterface
53
  */
54
  public function isFresh($name, $time);
55
  }
56
-
57
- class_alias('Twig_LoaderInterface', 'Twig\Loader\LoaderInterface', false);
53
  */
54
  public function isFresh($name, $time);
55
  }
 
 
vendor/twig/twig/lib/Twig/Markup.php CHANGED
@@ -35,5 +35,3 @@ class Twig_Markup implements Countable
35
  return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
36
  }
37
  }
38
-
39
- class_alias('Twig_Markup', 'Twig\Markup', false);
35
  return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
36
  }
37
  }
 
 
vendor/twig/twig/lib/Twig/Node.php CHANGED
@@ -251,6 +251,3 @@ class Twig_Node implements Twig_NodeInterface
251
  return $this->name;
252
  }
253
  }
254
-
255
- class_alias('Twig_Node', 'Twig\Node\Node', false);
256
- class_exists('Twig_Compiler');
251
  return $this->name;
252
  }
253
  }
 
 
 
vendor/twig/twig/lib/Twig/Node/AutoEscape.php CHANGED
@@ -32,5 +32,3 @@ class Twig_Node_AutoEscape extends Twig_Node
32
  $compiler->subcompile($this->getNode('body'));
33
  }
34
  }
35
-
36
- class_alias('Twig_Node_AutoEscape', 'Twig\Node\AutoEscapeNode', false);
32
  $compiler->subcompile($this->getNode('body'));
33
  }
34
  }
 
 
vendor/twig/twig/lib/Twig/Node/Block.php CHANGED
@@ -37,5 +37,3 @@ class Twig_Node_Block extends Twig_Node
37
  ;
38
  }
39
  }
40
-
41
- class_alias('Twig_Node_Block', 'Twig\Node\BlockNode', false);
37
  ;
38
  }
39
  }
 
 
vendor/twig/twig/lib/Twig/Node/BlockReference.php CHANGED
@@ -30,5 +30,3 @@ class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInter
30
  ;
31
  }
32
  }
33
-
34
- class_alias('Twig_Node_BlockReference', 'Twig\Node\BlockReferenceNode', false);
30
  ;
31
  }
32
  }
 
 
vendor/twig/twig/lib/Twig/Node/Body.php CHANGED
@@ -17,5 +17,3 @@
17
  class Twig_Node_Body extends Twig_Node
18
  {
19
  }
20
-
21
- class_alias('Twig_Node_Body', 'Twig\Node\BodyNode', false);
17
  class Twig_Node_Body extends Twig_Node
18
  {
19
  }
 
 
vendor/twig/twig/lib/Twig/Node/CheckSecurity.php CHANGED
@@ -76,5 +76,3 @@ class Twig_Node_CheckSecurity extends Twig_Node
76
  ;
77
  }
78
  }
79
-
80
- class_alias('Twig_Node_CheckSecurity', 'Twig\Node\CheckSecurityNode', false);
76
  ;
77
  }
78
  }
 
 
vendor/twig/twig/lib/Twig/Node/Do.php CHANGED
@@ -31,5 +31,3 @@ class Twig_Node_Do extends Twig_Node
31
  ;
32
  }
33
  }
34
-
35
- class_alias('Twig_Node_Do', 'Twig\Node\DoNode', false);
31
  ;
32
  }
33
  }
 
 
vendor/twig/twig/lib/Twig/Node/Embed.php CHANGED
@@ -42,5 +42,3 @@ class Twig_Node_Embed extends Twig_Node_Include
42
  ;
43
  }
44
  }
45
-
46
- class_alias('Twig_Node_Embed', 'Twig\Node\EmbedNode', false);
42
  ;
43
  }
44
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression.php CHANGED
@@ -18,5 +18,3 @@
18
  abstract class Twig_Node_Expression extends Twig_Node
19
  {
20
  }
21
-
22
- class_alias('Twig_Node_Expression', 'Twig\Node\Expression\AbstractExpression', false);
18
  abstract class Twig_Node_Expression extends Twig_Node
19
  {
20
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Array.php CHANGED
@@ -79,5 +79,3 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
79
  $compiler->raw(')');
80
  }
81
  }
82
-
83
- class_alias('Twig_Node_Expression_Array', 'Twig\Node\Expression\ArrayExpression', false);
79
  $compiler->raw(')');
80
  }
81
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php CHANGED
@@ -21,5 +21,3 @@ class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
21
  ;
22
  }
23
  }
24
-
25
- class_alias('Twig_Node_Expression_AssignName', 'Twig\Node\Expression\AssignNameExpression', false);
21
  ;
22
  }
23
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary.php CHANGED
@@ -33,5 +33,3 @@ abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
33
 
34
  abstract public function operator(Twig_Compiler $compiler);
35
  }
36
-
37
- class_alias('Twig_Node_Expression_Binary', 'Twig\Node\Expression\Binary\AbstractBinary', false);
33
 
34
  abstract public function operator(Twig_Compiler $compiler);
35
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary
16
  return $compiler->raw('+');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Add', 'Twig\Node\Expression\Binary\AddBinary', false);
16
  return $compiler->raw('+');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary
16
  return $compiler->raw('&&');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_And', 'Twig\Node\Expression\Binary\AndBinary', false);
16
  return $compiler->raw('&&');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary
16
  return $compiler->raw('&');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_BitwiseAnd', 'Twig\Node\Expression\Binary\BitwiseAndBinary', false);
16
  return $compiler->raw('&');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary
16
  return $compiler->raw('|');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_BitwiseOr', 'Twig\Node\Expression\Binary\BitwiseOrBinary', false);
16
  return $compiler->raw('|');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary
16
  return $compiler->raw('^');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_BitwiseXor', 'Twig\Node\Expression\Binary\BitwiseXorBinary', false);
16
  return $compiler->raw('^');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary
16
  return $compiler->raw('.');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Concat', 'Twig\Node\Expression\Binary\ConcatBinary', false);
16
  return $compiler->raw('.');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary
16
  return $compiler->raw('/');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Div', 'Twig\Node\Expression\Binary\DivBinary', false);
16
  return $compiler->raw('/');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php CHANGED
@@ -28,5 +28,3 @@ class Twig_Node_Expression_Binary_EndsWith extends Twig_Node_Expression_Binary
28
  return $compiler->raw('');
29
  }
30
  }
31
-
32
- class_alias('Twig_Node_Expression_Binary_EndsWith', 'Twig\Node\Expression\Binary\EndsWithBinary', false);
28
  return $compiler->raw('');
29
  }
30
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php CHANGED
@@ -15,5 +15,3 @@ class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary
15
  return $compiler->raw('==');
16
  }
17
  }
18
-
19
- class_alias('Twig_Node_Expression_Binary_Equal', 'Twig\Node\Expression\Binary\EqualBinary', false);
15
  return $compiler->raw('==');
16
  }
17
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php CHANGED
@@ -22,5 +22,3 @@ class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
22
  return $compiler->raw('/');
23
  }
24
  }
25
-
26
- class_alias('Twig_Node_Expression_Binary_FloorDiv', 'Twig\Node\Expression\Binary\FloorDivBinary', false);
22
  return $compiler->raw('/');
23
  }
24
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php CHANGED
@@ -15,5 +15,3 @@ class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary
15
  return $compiler->raw('>');
16
  }
17
  }
18
-
19
- class_alias('Twig_Node_Expression_Binary_Greater', 'Twig\Node\Expression\Binary\GreaterBinary', false);
15
  return $compiler->raw('>');
16
  }
17
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php CHANGED
@@ -15,5 +15,3 @@ class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Bina
15
  return $compiler->raw('>=');
16
  }
17
  }
18
-
19
- class_alias('Twig_Node_Expression_Binary_GreaterEqual', 'Twig\Node\Expression\Binary\GreaterEqualBinary', false);
15
  return $compiler->raw('>=');
16
  }
17
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php CHANGED
@@ -26,5 +26,3 @@ class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
26
  return $compiler->raw('in');
27
  }
28
  }
29
-
30
- class_alias('Twig_Node_Expression_Binary_In', 'Twig\Node\Expression\Binary\InBinary', false);
26
  return $compiler->raw('in');
27
  }
28
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php CHANGED
@@ -15,5 +15,3 @@ class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary
15
  return $compiler->raw('<');
16
  }
17
  }
18
-
19
- class_alias('Twig_Node_Expression_Binary_Less', 'Twig\Node\Expression\Binary\LessBinary', false);
15
  return $compiler->raw('<');
16
  }
17
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php CHANGED
@@ -15,5 +15,3 @@ class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary
15
  return $compiler->raw('<=');
16
  }
17
  }
18
-
19
- class_alias('Twig_Node_Expression_Binary_LessEqual', 'Twig\Node\Expression\Binary\LessEqualBinary', false);
15
  return $compiler->raw('<=');
16
  }
17
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php CHANGED
@@ -26,5 +26,3 @@ class Twig_Node_Expression_Binary_Matches extends Twig_Node_Expression_Binary
26
  return $compiler->raw('');
27
  }
28
  }
29
-
30
- class_alias('Twig_Node_Expression_Binary_Matches', 'Twig\Node\Expression\Binary\MatchesBinary', false);
26
  return $compiler->raw('');
27
  }
28
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary
16
  return $compiler->raw('%');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Mod', 'Twig\Node\Expression\Binary\ModBinary', false);
16
  return $compiler->raw('%');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary
16
  return $compiler->raw('*');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Mul', 'Twig\Node\Expression\Binary\MulBinary', false);
16
  return $compiler->raw('*');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php CHANGED
@@ -15,5 +15,3 @@ class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary
15
  return $compiler->raw('!=');
16
  }
17
  }
18
-
19
- class_alias('Twig_Node_Expression_Binary_NotEqual', 'Twig\Node\Expression\Binary\NotEqualBinary', false);
15
  return $compiler->raw('!=');
16
  }
17
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php CHANGED
@@ -26,5 +26,3 @@ class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
26
  return $compiler->raw('not in');
27
  }
28
  }
29
-
30
- class_alias('Twig_Node_Expression_Binary_NotIn', 'Twig\Node\Expression\Binary\NotInBinary', false);
26
  return $compiler->raw('not in');
27
  }
28
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary
16
  return $compiler->raw('||');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Or', 'Twig\Node\Expression\Binary\OrBinary', false);
16
  return $compiler->raw('||');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php CHANGED
@@ -30,5 +30,3 @@ class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
30
  return $compiler->raw('**');
31
  }
32
  }
33
-
34
- class_alias('Twig_Node_Expression_Binary_Power', 'Twig\Node\Expression\Binary\PowerBinary', false);
30
  return $compiler->raw('**');
31
  }
32
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php CHANGED
@@ -26,5 +26,3 @@ class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
26
  return $compiler->raw('..');
27
  }
28
  }
29
-
30
- class_alias('Twig_Node_Expression_Binary_Range', 'Twig\Node\Expression\Binary\RangeBinary', false);
26
  return $compiler->raw('..');
27
  }
28
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php CHANGED
@@ -28,5 +28,3 @@ class Twig_Node_Expression_Binary_StartsWith extends Twig_Node_Expression_Binary
28
  return $compiler->raw('');
29
  }
30
  }
31
-
32
- class_alias('Twig_Node_Expression_Binary_StartsWith', 'Twig\Node\Expression\Binary\StartsWithBinary', false);
28
  return $compiler->raw('');
29
  }
30
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary
16
  return $compiler->raw('-');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Binary_Sub', 'Twig\Node\Expression\Binary\SubBinary', false);
16
  return $compiler->raw('-');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php CHANGED
@@ -89,5 +89,3 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
89
  return $compiler->raw(')');
90
  }
91
  }
92
-
93
- class_alias('Twig_Node_Expression_BlockReference', 'Twig\Node\Expression\BlockReferenceExpression', false);
89
  return $compiler->raw(')');
90
  }
91
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Call.php CHANGED
@@ -287,5 +287,3 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
287
  return $this->reflector = array($r, $callable);
288
  }
289
  }
290
-
291
- class_alias('Twig_Node_Expression_Call', 'Twig\Node\Expression\CallExpression', false);
287
  return $this->reflector = array($r, $callable);
288
  }
289
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Node_Expression_Conditional extends Twig_Node_Expression
29
  ;
30
  }
31
  }
32
-
33
- class_alias('Twig_Node_Expression_Conditional', 'Twig\Node\Expression\ConditionalExpression', false);
29
  ;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Constant.php CHANGED
@@ -21,5 +21,3 @@ class Twig_Node_Expression_Constant extends Twig_Node_Expression
21
  $compiler->repr($this->getAttribute('value'));
22
  }
23
  }
24
-
25
- class_alias('Twig_Node_Expression_Constant', 'Twig\Node\Expression\ConstantExpression', false);
21
  $compiler->repr($this->getAttribute('value'));
22
  }
23
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Filter.php CHANGED
@@ -37,5 +37,3 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call
37
  $this->compileCallable($compiler);
38
  }
39
  }
40
-
41
- class_alias('Twig_Node_Expression_Filter', 'Twig\Node\Expression\FilterExpression', false);
37
  $this->compileCallable($compiler);
38
  }
39
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php CHANGED
@@ -41,5 +41,3 @@ class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter
41
  $compiler->subcompile($this->getNode('node'));
42
  }
43
  }
44
-
45
- class_alias('Twig_Node_Expression_Filter_Default', 'Twig\Node\Expression\Filter\DefaultFilter', false);
41
  $compiler->subcompile($this->getNode('node'));
42
  }
43
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Function.php CHANGED
@@ -41,5 +41,3 @@ class Twig_Node_Expression_Function extends Twig_Node_Expression_Call
41
  $this->compileCallable($compiler);
42
  }
43
  }
44
-
45
- class_alias('Twig_Node_Expression_Function', 'Twig\Node\Expression\FunctionExpression', false);
41
  $this->compileCallable($compiler);
42
  }
43
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php CHANGED
@@ -70,5 +70,3 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
70
  $compiler->raw(')');
71
  }
72
  }
73
-
74
- class_alias('Twig_Node_Expression_GetAttr', 'Twig\Node\Expression\GetAttrExpression', false);
70
  $compiler->raw(')');
71
  }
72
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php CHANGED
@@ -39,5 +39,3 @@ class Twig_Node_Expression_MethodCall extends Twig_Node_Expression
39
  $compiler->raw(')');
40
  }
41
  }
42
-
43
- class_alias('Twig_Node_Expression_MethodCall', 'Twig\Node\Expression\MethodCallExpression', false);
39
  $compiler->raw(')');
40
  }
41
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Name.php CHANGED
@@ -98,5 +98,3 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
98
  return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
99
  }
100
  }
101
-
102
- class_alias('Twig_Node_Expression_Name', 'Twig\Node\Expression\NameExpression', false);
98
  return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
99
  }
100
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php CHANGED
@@ -44,5 +44,3 @@ class Twig_Node_Expression_NullCoalesce extends Twig_Node_Expression_Conditional
44
  }
45
  }
46
  }
47
-
48
- class_alias('Twig_Node_Expression_NullCoalesce', 'Twig\Node\Expression\NullCoalesceExpression', false);
44
  }
45
  }
46
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Parent.php CHANGED
@@ -40,5 +40,3 @@ class Twig_Node_Expression_Parent extends Twig_Node_Expression
40
  }
41
  }
42
  }
43
-
44
- class_alias('Twig_Node_Expression_Parent', 'Twig\Node\Expression\ParentExpression', false);
40
  }
41
  }
42
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/TempName.php CHANGED
@@ -24,5 +24,3 @@ class Twig_Node_Expression_TempName extends Twig_Node_Expression
24
  ;
25
  }
26
  }
27
-
28
- class_alias('Twig_Node_Expression_TempName', 'Twig\Node\Expression\TempNameExpression', false);
24
  ;
25
  }
26
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test.php CHANGED
@@ -38,5 +38,3 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
38
  $this->compileCallable($compiler);
39
  }
40
  }
41
-
42
- class_alias('Twig_Node_Expression_Test', 'Twig\Node\Expression\TestExpression', false);
38
  $this->compileCallable($compiler);
39
  }
40
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php CHANGED
@@ -44,5 +44,3 @@ class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
44
  ;
45
  }
46
  }
47
-
48
- class_alias('Twig_Node_Expression_Test_Constant', 'Twig\Node\Expression\Test\ConstantTest', false);
44
  ;
45
  }
46
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php CHANGED
@@ -57,5 +57,3 @@ class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
57
  $compiler->subcompile($this->getNode('node'));
58
  }
59
  }
60
-
61
- class_alias('Twig_Node_Expression_Test_Defined', 'Twig\Node\Expression\Test\DefinedTest', false);
57
  $compiler->subcompile($this->getNode('node'));
58
  }
59
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php CHANGED
@@ -31,5 +31,3 @@ class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test
31
  ;
32
  }
33
  }
34
-
35
- class_alias('Twig_Node_Expression_Test_Divisibleby', 'Twig\Node\Expression\Test\DivisiblebyTest', false);
31
  ;
32
  }
33
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php CHANGED
@@ -30,5 +30,3 @@ class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test
30
  ;
31
  }
32
  }
33
-
34
- class_alias('Twig_Node_Expression_Test_Even', 'Twig\Node\Expression\Test\EvenTest', false);
30
  ;
31
  }
32
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test
29
  ;
30
  }
31
  }
32
-
33
- class_alias('Twig_Node_Expression_Test_Null', 'Twig\Node\Expression\Test\NullTest', false);
29
  ;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php CHANGED
@@ -30,5 +30,3 @@ class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
30
  ;
31
  }
32
  }
33
-
34
- class_alias('Twig_Node_Expression_Test_Odd', 'Twig\Node\Expression\Test\OddTest', false);
30
  ;
31
  }
32
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php CHANGED
@@ -27,5 +27,3 @@ class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test
27
  ;
28
  }
29
  }
30
-
31
- class_alias('Twig_Node_Expression_Test_Sameas', 'Twig\Node\Expression\Test\SameasTest', false);
27
  ;
28
  }
29
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Unary.php CHANGED
@@ -25,5 +25,3 @@ abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression
25
 
26
  abstract public function operator(Twig_Compiler $compiler);
27
  }
28
-
29
- class_alias('Twig_Node_Expression_Unary', 'Twig\Node\Expression\Unary\AbstractUnary', false);
25
 
26
  abstract public function operator(Twig_Compiler $compiler);
27
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Unary_Neg extends Twig_Node_Expression_Unary
16
  $compiler->raw('-');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Unary_Neg', 'Twig\Node\Expression\Unary\NegUnary', false);
16
  $compiler->raw('-');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Unary_Not extends Twig_Node_Expression_Unary
16
  $compiler->raw('!');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Unary_Not', 'Twig\Node\Expression\Unary\NotUnary', false);
16
  $compiler->raw('!');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php CHANGED
@@ -16,5 +16,3 @@ class Twig_Node_Expression_Unary_Pos extends Twig_Node_Expression_Unary
16
  $compiler->raw('+');
17
  }
18
  }
19
-
20
- class_alias('Twig_Node_Expression_Unary_Pos', 'Twig\Node\Expression\Unary\PosUnary', false);
16
  $compiler->raw('+');
17
  }
18
  }
 
 
vendor/twig/twig/lib/Twig/Node/Flush.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Node_Flush extends Twig_Node
29
  ;
30
  }
31
  }
32
-
33
- class_alias('Twig_Node_Flush', 'Twig\Node\FlushNode', false);
29
  ;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Node/For.php CHANGED
@@ -109,5 +109,3 @@ class Twig_Node_For extends Twig_Node
109
  $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
110
  }
111
  }
112
-
113
- class_alias('Twig_Node_For', 'Twig\Node\ForNode', false);
109
  $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
110
  }
111
  }
 
 
vendor/twig/twig/lib/Twig/Node/ForLoop.php CHANGED
@@ -48,5 +48,3 @@ class Twig_Node_ForLoop extends Twig_Node
48
  }
49
  }
50
  }
51
-
52
- class_alias('Twig_Node_ForLoop', 'Twig\Node\ForLoopNode', false);
48
  }
49
  }
50
  }
 
 
vendor/twig/twig/lib/Twig/Node/If.php CHANGED
@@ -64,5 +64,3 @@ class Twig_Node_If extends Twig_Node
64
  ->write("}\n");
65
  }
66
  }
67
-
68
- class_alias('Twig_Node_If', 'Twig\Node\IfNode', false);
64
  ->write("}\n");
65
  }
66
  }
 
 
vendor/twig/twig/lib/Twig/Node/Import.php CHANGED
@@ -47,5 +47,3 @@ class Twig_Node_Import extends Twig_Node
47
  $compiler->raw(";\n");
48
  }
49
  }
50
-
51
- class_alias('Twig_Node_Import', 'Twig\Node\ImportNode', false);
47
  $compiler->raw(";\n");
48
  }
49
  }
 
 
vendor/twig/twig/lib/Twig/Node/Include.php CHANGED
@@ -86,5 +86,3 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
86
  }
87
  }
88
  }
89
-
90
- class_alias('Twig_Node_Include', 'Twig\Node\IncludeNode', false);
86
  }
87
  }
88
  }
 
 
vendor/twig/twig/lib/Twig/Node/Macro.php CHANGED
@@ -121,5 +121,3 @@ class Twig_Node_Macro extends Twig_Node
121
  ;
122
  }
123
  }
124
-
125
- class_alias('Twig_Node_Macro', 'Twig\Node\MacroNode', false);
121
  ;
122
  }
123
  }
 
 
vendor/twig/twig/lib/Twig/Node/Module.php CHANGED
@@ -457,5 +457,3 @@ class Twig_Node_Module extends Twig_Node
457
  }
458
  }
459
  }
460
-
461
- class_alias('Twig_Node_Module', 'Twig\Node\ModuleNode', false);
457
  }
458
  }
459
  }
 
 
vendor/twig/twig/lib/Twig/Node/Print.php CHANGED
@@ -32,5 +32,3 @@ class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
32
  ;
33
  }
34
  }
35
-
36
- class_alias('Twig_Node_Print', 'Twig\Node\PrintNode', false);
32
  ;
33
  }
34
  }
 
 
vendor/twig/twig/lib/Twig/Node/Sandbox.php CHANGED
@@ -40,5 +40,3 @@ class Twig_Node_Sandbox extends Twig_Node
40
  ;
41
  }
42
  }
43
-
44
- class_alias('Twig_Node_Sandbox', 'Twig\Node\SandboxNode', false);
40
  ;
41
  }
42
  }
 
 
vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php CHANGED
@@ -47,5 +47,3 @@ class Twig_Node_SandboxedPrint extends Twig_Node_Print
47
  return $node;
48
  }
49
  }
50
-
51
- class_alias('Twig_Node_SandboxedPrint', 'Twig\Node\SandboxedPrintNode', false);
47
  return $node;
48
  }
49
  }
 
 
vendor/twig/twig/lib/Twig/Node/Set.php CHANGED
@@ -94,5 +94,3 @@ class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
94
  $compiler->raw(";\n");
95
  }
96
  }
97
-
98
- class_alias('Twig_Node_Set', 'Twig\Node\SetNode', false);
94
  $compiler->raw(";\n");
95
  }
96
  }
 
 
vendor/twig/twig/lib/Twig/Node/SetTemp.php CHANGED
@@ -9,9 +9,6 @@
9
  * file that was distributed with this source code.
10
  */
11
 
12
- /**
13
- * @internal
14
- */
15
  class Twig_Node_SetTemp extends Twig_Node
16
  {
17
  public function __construct($name, $lineno)
@@ -36,5 +33,3 @@ class Twig_Node_SetTemp extends Twig_Node
36
  ;
37
  }
38
  }
39
-
40
- class_alias('Twig_Node_SetTemp', 'Twig\Node\SetTempNode', false);
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
 
12
  class Twig_Node_SetTemp extends Twig_Node
13
  {
14
  public function __construct($name, $lineno)
33
  ;
34
  }
35
  }
 
 
vendor/twig/twig/lib/Twig/Node/Spaceless.php CHANGED
@@ -33,5 +33,3 @@ class Twig_Node_Spaceless extends Twig_Node
33
  ;
34
  }
35
  }
36
-
37
- class_alias('Twig_Node_Spaceless', 'Twig\Node\SpacelessNode', false);
33
  ;
34
  }
35
  }
 
 
vendor/twig/twig/lib/Twig/Node/Text.php CHANGED
@@ -32,5 +32,3 @@ class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
32
  ;
33
  }
34
  }
35
-
36
- class_alias('Twig_Node_Text', 'Twig\Node\TextNode', false);
32
  ;
33
  }
34
  }
 
 
vendor/twig/twig/lib/Twig/Node/With.php CHANGED
@@ -60,5 +60,3 @@ class Twig_Node_With extends Twig_Node
60
  ;
61
  }
62
  }
63
-
64
- class_alias('Twig_Node_With', 'Twig\Node\WithNode', false);
60
  ;
61
  }
62
  }
 
 
vendor/twig/twig/lib/Twig/NodeCaptureInterface.php CHANGED
@@ -17,5 +17,3 @@
17
  interface Twig_NodeCaptureInterface
18
  {
19
  }
20
-
21
- class_alias('Twig_NodeCaptureInterface', 'Twig\Node\NodeCaptureInterface', false);
17
  interface Twig_NodeCaptureInterface
18
  {
19
  }
 
 
vendor/twig/twig/lib/Twig/NodeOutputInterface.php CHANGED
@@ -17,5 +17,3 @@
17
  interface Twig_NodeOutputInterface
18
  {
19
  }
20
-
21
- class_alias('Twig_NodeOutputInterface', 'Twig\Node\NodeOutputInterface', false);
17
  interface Twig_NodeOutputInterface
18
  {
19
  }
 
 
vendor/twig/twig/lib/Twig/NodeTraverser.php CHANGED
@@ -80,5 +80,3 @@ class Twig_NodeTraverser
80
  return $visitor->leaveNode($node, $this->env);
81
  }
82
  }
83
-
84
- class_alias('Twig_NodeTraverser', 'Twig\NodeTraverser', false);
80
  return $visitor->leaveNode($node, $this->env);
81
  }
82
  }
 
 
vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php CHANGED
@@ -150,5 +150,3 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
150
  return 0;
151
  }
152
  }
153
-
154
- class_alias('Twig_NodeVisitor_Escaper', 'Twig\NodeVisitor\EscaperNodeVisitor', false);
150
  return 0;
151
  }
152
  }
 
 
vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php CHANGED
@@ -249,5 +249,3 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
249
  return 255;
250
  }
251
  }
252
-
253
- class_alias('Twig_NodeVisitor_Optimizer', 'Twig\NodeVisitor\OptimizerNodeVisitor', false);
249
  return 255;
250
  }
251
  }
 
 
vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php CHANGED
@@ -146,5 +146,3 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
146
  return 0;
147
  }
148
  }
149
-
150
- class_alias('Twig_NodeVisitor_SafeAnalysis', 'Twig\NodeVisitor\SafeAnalysisNodeVisitor', false);
146
  return 0;
147
  }
148
  }
 
 
vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php CHANGED
@@ -73,5 +73,3 @@ class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
73
  return 0;
74
  }
75
  }
76
-
77
- class_alias('Twig_NodeVisitor_Sandbox', 'Twig\NodeVisitor\SandboxNodeVisitor', false);
73
  return 0;
74
  }
75
  }
 
 
vendor/twig/twig/lib/Twig/NodeVisitorInterface.php CHANGED
@@ -39,7 +39,3 @@ interface Twig_NodeVisitorInterface
39
  */
40
  public function getPriority();
41
  }
42
-
43
- class_alias('Twig_NodeVisitorInterface', 'Twig\NodeVisitor\NodeVisitorInterface', false);
44
- class_exists('Twig_Environment');
45
- class_exists('Twig_Node');
39
  */
40
  public function getPriority();
41
  }
 
 
 
 
vendor/twig/twig/lib/Twig/Parser.php CHANGED
@@ -404,7 +404,3 @@ class Twig_Parser implements Twig_ParserInterface
404
  return $node;
405
  }
406
  }
407
-
408
- class_alias('Twig_Parser', 'Twig\Parser', false);
409
- class_exists('Twig_Node');
410
- class_exists('Twig_TokenStream');
404
  return $node;
405
  }
406
  }
 
 
 
 
vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php CHANGED
@@ -22,7 +22,7 @@ class Twig_Profiler_Dumper_Blackfire
22
  $this->dumpProfile('main()', $profile, $data);
23
  $this->dumpChildren('main()', $profile, $data);
24
 
25
- $start = sprintf('%f', microtime(true));
26
  $str = <<<EOF
27
  file-format: BlackfireProbe
28
  cost-dimensions: wt mu pmu
@@ -68,5 +68,3 @@ EOF;
68
  }
69
  }
70
  }
71
-
72
- class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false);
22
  $this->dumpProfile('main()', $profile, $data);
23
  $this->dumpChildren('main()', $profile, $data);
24
 
25
+ $start = microtime(true);
26
  $str = <<<EOF
27
  file-format: BlackfireProbe
28
  cost-dimensions: wt mu pmu
68
  }
69
  }
70
  }
 
 
vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php CHANGED
@@ -14,7 +14,7 @@
14
  *
15
  * @final
16
  */
17
- class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base
18
  {
19
  private static $colors = array(
20
  'block' => '#dfd',
@@ -43,5 +43,3 @@ class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base
43
  return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
44
  }
45
  }
46
-
47
- class_alias('Twig_Profiler_Dumper_Html', 'Twig\Profiler\Dumper\HtmlDumper', false);
14
  *
15
  * @final
16
  */
17
+ class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text
18
  {
19
  private static $colors = array(
20
  'block' => '#dfd',
43
  return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
44
  }
45
  }
 
 
vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php CHANGED
@@ -14,8 +14,15 @@
14
  *
15
  * @final
16
  */
17
- class Twig_Profiler_Dumper_Text extends Twig_Profiler_Dumper_Base
18
  {
 
 
 
 
 
 
 
19
  protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
20
  {
21
  return sprintf('%s└ %s', $prefix, $profile->getTemplate());
@@ -30,6 +37,34 @@ class Twig_Profiler_Dumper_Text extends Twig_Profiler_Dumper_Base
30
  {
31
  return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
32
  }
33
- }
34
 
35
- class_alias('Twig_Profiler_Dumper_Text', 'Twig\Profiler\Dumper\TextDumper', false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  *
15
  * @final
16
  */
17
+ class Twig_Profiler_Dumper_Text
18
  {
19
+ private $root;
20
+
21
+ public function dump(Twig_Profiler_Profile $profile)
22
+ {
23
+ return $this->dumpProfile($profile);
24
+ }
25
+
26
  protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
27
  {
28
  return sprintf('%s└ %s', $prefix, $profile->getTemplate());
37
  {
38
  return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
39
  }
 
40
 
41
+ private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
42
+ {
43
+ if ($profile->isRoot()) {
44
+ $this->root = $profile->getDuration();
45
+ $start = $profile->getName();
46
+ } else {
47
+ if ($profile->isTemplate()) {
48
+ $start = $this->formatTemplate($profile, $prefix);
49
+ } else {
50
+ $start = $this->formatNonTemplate($profile, $prefix);
51
+ }
52
+ $prefix .= $sibling ? '│ ' : ' ';
53
+ }
54
+
55
+ $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
56
+
57
+ if ($profile->getDuration() * 1000 < 1) {
58
+ $str = $start."\n";
59
+ } else {
60
+ $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
61
+ }
62
+
63
+ $nCount = count($profile->getProfiles());
64
+ foreach ($profile as $i => $p) {
65
+ $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
66
+ }
67
+
68
+ return $str;
69
+ }
70
+ }
vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php CHANGED
@@ -35,5 +35,3 @@ class Twig_Profiler_Node_EnterProfile extends Twig_Node
35
  ;
36
  }
37
  }
38
-
39
- class_alias('Twig_Profiler_Node_EnterProfile', 'Twig\Profiler\Node\EnterProfileNode', false);
35
  ;
36
  }
37
  }
 
 
vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Profiler_Node_LeaveProfile extends Twig_Node
29
  ;
30
  }
31
  }
32
-
33
- class_alias('Twig_Profiler_Node_LeaveProfile', 'Twig\Profiler\Node\LeaveProfileNode', false);
29
  ;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php CHANGED
@@ -63,5 +63,3 @@ class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
63
  return 0;
64
  }
65
  }
66
-
67
- class_alias('Twig_Profiler_NodeVisitor_Profiler', 'Twig\Profiler\NodeVisitor\ProfilerNodeVisitor', false);
63
  return 0;
64
  }
65
  }
 
 
vendor/twig/twig/lib/Twig/Profiler/Profile.php CHANGED
@@ -160,5 +160,3 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
160
  list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
161
  }
162
  }
163
-
164
- class_alias('Twig_Profiler_Profile', 'Twig\Profiler\Profile', false);
160
  list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
161
  }
162
  }
 
 
vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php CHANGED
@@ -25,5 +25,3 @@ interface Twig_RuntimeLoaderInterface
25
  */
26
  public function load($class);
27
  }
28
-
29
- class_alias('Twig_RuntimeLoaderInterface', 'Twig\RuntimeLoader\RuntimeLoaderInterface', false);
25
  */
26
  public function load($class);
27
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php CHANGED
@@ -17,5 +17,3 @@
17
  class Twig_Sandbox_SecurityError extends Twig_Error
18
  {
19
  }
20
-
21
- class_alias('Twig_Sandbox_SecurityError', 'Twig\Sandbox\SecurityError', false);
17
  class Twig_Sandbox_SecurityError extends Twig_Error
18
  {
19
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityEr
29
  return $this->filterName;
30
  }
31
  }
32
-
33
- class_alias('Twig_Sandbox_SecurityNotAllowedFilterError', 'Twig\Sandbox\SecurityNotAllowedFilterError', false);
29
  return $this->filterName;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_Security
29
  return $this->functionName;
30
  }
31
  }
32
-
33
- class_alias('Twig_Sandbox_SecurityNotAllowedFunctionError', 'Twig\Sandbox\SecurityNotAllowedFunctionError', false);
29
  return $this->functionName;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php CHANGED
@@ -36,5 +36,3 @@ class Twig_Sandbox_SecurityNotAllowedMethodError extends Twig_Sandbox_SecurityEr
36
  return $this->methodName;
37
  }
38
  }
39
-
40
- class_alias('Twig_Sandbox_SecurityNotAllowedMethodError', 'Twig\Sandbox\SecurityNotAllowedMethodError', false);
36
  return $this->methodName;
37
  }
38
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php CHANGED
@@ -36,5 +36,3 @@ class Twig_Sandbox_SecurityNotAllowedPropertyError extends Twig_Sandbox_Security
36
  return $this->propertyName;
37
  }
38
  }
39
-
40
- class_alias('Twig_Sandbox_SecurityNotAllowedPropertyError', 'Twig\Sandbox\SecurityNotAllowedPropertyError', false);
36
  return $this->propertyName;
37
  }
38
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php CHANGED
@@ -29,5 +29,3 @@ class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError
29
  return $this->tagName;
30
  }
31
  }
32
-
33
- class_alias('Twig_Sandbox_SecurityNotAllowedTagError', 'Twig\Sandbox\SecurityNotAllowedTagError', false);
29
  return $this->tagName;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php CHANGED
@@ -121,5 +121,3 @@ class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterfac
121
  }
122
  }
123
  }
124
-
125
- class_alias('Twig_Sandbox_SecurityPolicy', 'Twig\Sandbox\SecurityPolicy', false);
121
  }
122
  }
123
  }
 
 
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php CHANGED
@@ -22,5 +22,3 @@ interface Twig_Sandbox_SecurityPolicyInterface
22
 
23
  public function checkPropertyAllowed($obj, $method);
24
  }
25
-
26
- class_alias('Twig_Sandbox_SecurityPolicyInterface', 'Twig\Sandbox\SecurityPolicyInterface', false);
22
 
23
  public function checkPropertyAllowed($obj, $method);
24
  }
 
 
vendor/twig/twig/lib/Twig/SimpleFilter.php CHANGED
@@ -117,5 +117,3 @@ class Twig_SimpleFilter
117
  return $this->options['alternative'];
118
  }
119
  }
120
-
121
- class_alias('Twig_SimpleFilter', 'Twig\TwigFilter', false);
117
  return $this->options['alternative'];
118
  }
119
  }
 
 
vendor/twig/twig/lib/Twig/SimpleFunction.php CHANGED
@@ -107,5 +107,3 @@ class Twig_SimpleFunction
107
  return $this->options['alternative'];
108
  }
109
  }
110
-
111
- class_alias('Twig_SimpleFunction', 'Twig\TwigFunction', false);
107
  return $this->options['alternative'];
108
  }
109
  }
 
 
vendor/twig/twig/lib/Twig/SimpleTest.php CHANGED
@@ -69,5 +69,3 @@ class Twig_SimpleTest
69
  return $this->options['alternative'];
70
  }
71
  }
72
-
73
- class_alias('Twig_SimpleTest', 'Twig\TwigTest', false);
69
  return $this->options['alternative'];
70
  }
71
  }
 
 
vendor/twig/twig/lib/Twig/Source.php CHANGED
@@ -49,5 +49,3 @@ class Twig_Source
49
  return $this->path;
50
  }
51
  }
52
-
53
- class_alias('Twig_Source', 'Twig\Source', false);
49
  return $this->path;
50
  }
51
  }
 
 
vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php CHANGED
@@ -29,5 +29,3 @@ interface Twig_SourceContextLoaderInterface
29
  */
30
  public function getSourceContext($name);
31
  }
32
-
33
- class_alias('Twig_SourceContextLoaderInterface', 'Twig\Loader\SourceContextLoaderInterface', false);
29
  */
30
  public function getSourceContext($name);
31
  }
 
 
vendor/twig/twig/lib/Twig/Template.php CHANGED
@@ -627,14 +627,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
627
  continue;
628
  }
629
 
630
- // skip get() and is() methods (in which case, $name is empty)
631
- if ($name) {
632
- if (!isset($cache[$name])) {
633
- $cache[$name] = $method;
634
- }
635
- if (!isset($cache[$lcName])) {
636
- $cache[$lcName] = $method;
637
- }
638
  }
639
  }
640
  self::$cache[$class] = $cache;
@@ -702,5 +699,3 @@ abstract class Twig_Template implements Twig_TemplateInterface
702
  return $ret;
703
  }
704
  }
705
-
706
- class_alias('Twig_Template', 'Twig\Template', false);
627
  continue;
628
  }
629
 
630
+ if (!isset($cache[$name])) {
631
+ $cache[$name] = $method;
632
+ }
633
+ if (!isset($cache[$lcName])) {
634
+ $cache[$lcName] = $method;
 
 
 
635
  }
636
  }
637
  self::$cache[$class] = $cache;
699
  return $ret;
700
  }
701
  }
 
 
vendor/twig/twig/lib/Twig/TemplateWrapper.php CHANGED
@@ -129,5 +129,3 @@ final class Twig_TemplateWrapper
129
  return $this->template->getSourceContext();
130
  }
131
  }
132
-
133
- class_alias('Twig_TemplateWrapper', 'Twig\TemplateWrapper', false);
129
  return $this->template->getSourceContext();
130
  }
131
  }
 
 
vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php CHANGED
@@ -9,29 +9,19 @@
9
  * file that was distributed with this source code.
10
  */
11
 
12
- use PHPUnit\Framework\TestCase;
13
-
14
  /**
15
  * Integration test helper.
16
  *
17
  * @author Fabien Potencier <fabien@symfony.com>
18
  * @author Karma Dordrak <drak@zikula.org>
19
  */
20
- abstract class Twig_Test_IntegrationTestCase extends TestCase
21
  {
22
  /**
23
  * @return string
24
  */
25
  abstract protected function getFixturesDir();
26
 
27
- /**
28
- * @return Twig_RuntimeLoaderInterface[]
29
- */
30
- protected function getRuntimeLoaders()
31
- {
32
- return array();
33
- }
34
-
35
  /**
36
  * @return Twig_ExtensionInterface[]
37
  */
@@ -131,10 +121,6 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
131
 
132
  protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
133
  {
134
- if (!$outputs) {
135
- $this->markTestSkipped('no legacy tests to run');
136
- }
137
-
138
  if ($condition) {
139
  eval('$ret = '.$condition.';');
140
  if (!$ret) {
@@ -151,10 +137,6 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
151
  ), $match[2] ? eval($match[2].';') : array());
152
  $twig = new Twig_Environment($loader, $config);
153
  $twig->addGlobal('global', 'global');
154
- foreach ($this->getRuntimeLoaders() as $runtimeLoader) {
155
- $twig->addRuntimeLoader($runtimeLoader);
156
- }
157
-
158
  foreach ($this->getExtensions() as $extension) {
159
  $twig->addExtension($extension);
160
  }
@@ -210,8 +192,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
210
 
211
  if (false !== $exception) {
212
  list($class) = explode(':', $exception);
213
- $constraintClass = class_exists('PHPUnit\Framework\Constraint\Exception') ? 'PHPUnit\Framework\Constraint\Exception' : 'PHPUnit_Framework_Constraint_Exception';
214
- $this->assertThat(null, new $constraintClass($class));
215
  }
216
 
217
  $expected = trim($match[3], "\n ");
@@ -245,5 +226,3 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
245
  return $templates;
246
  }
247
  }
248
-
249
- class_alias('Twig_Test_IntegrationTestCase', 'Twig\Test\IntegrationTestCase', false);
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Integration test helper.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
  * @author Karma Dordrak <drak@zikula.org>
17
  */
18
+ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
19
  {
20
  /**
21
  * @return string
22
  */
23
  abstract protected function getFixturesDir();
24
 
 
 
 
 
 
 
 
 
25
  /**
26
  * @return Twig_ExtensionInterface[]
27
  */
121
 
122
  protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
123
  {
 
 
 
 
124
  if ($condition) {
125
  eval('$ret = '.$condition.';');
126
  if (!$ret) {
137
  ), $match[2] ? eval($match[2].';') : array());
138
  $twig = new Twig_Environment($loader, $config);
139
  $twig->addGlobal('global', 'global');
 
 
 
 
140
  foreach ($this->getExtensions() as $extension) {
141
  $twig->addExtension($extension);
142
  }
192
 
193
  if (false !== $exception) {
194
  list($class) = explode(':', $exception);
195
+ $this->assertThat(null, new PHPUnit_Framework_Constraint_Exception($class));
 
196
  }
197
 
198
  $expected = trim($match[3], "\n ");
226
  return $templates;
227
  }
228
  }
 
 
vendor/twig/twig/lib/Twig/Test/NodeTestCase.php CHANGED
@@ -8,10 +8,7 @@
8
  * For the full copyright and license information, please view the LICENSE
9
  * file that was distributed with this source code.
10
  */
11
-
12
- use PHPUnit\Framework\TestCase;
13
-
14
- abstract class Twig_Test_NodeTestCase extends TestCase
15
  {
16
  abstract public function getTests();
17
 
@@ -69,7 +66,3 @@ abstract class Twig_Test_NodeTestCase extends TestCase
69
  return '$this->getAttribute(';
70
  }
71
  }
72
-
73
- class_alias('Twig_Test_NodeTestCase', 'Twig\Test\NodeTestCase', false);
74
- class_exists('Twig_Environment');
75
- class_exists('Twig_Node');
8
  * For the full copyright and license information, please view the LICENSE
9
  * file that was distributed with this source code.
10
  */
11
+ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
 
 
 
12
  {
13
  abstract public function getTests();
14
 
66
  return '$this->getAttribute(';
67
  }
68
  }
 
 
 
 
vendor/twig/twig/lib/Twig/Token.php CHANGED
@@ -203,5 +203,3 @@ class Twig_Token
203
  }
204
  }
205
  }
206
-
207
- class_alias('Twig_Token', 'Twig\Token', false);
203
  }
204
  }
205
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser.php CHANGED
@@ -29,5 +29,3 @@ abstract class Twig_TokenParser implements Twig_TokenParserInterface
29
  $this->parser = $parser;
30
  }
31
  }
32
-
33
- class_alias('Twig_TokenParser', 'Twig\TokenParser\AbstractTokenParser', false);
29
  $this->parser = $parser;
30
  }
31
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php CHANGED
@@ -79,5 +79,3 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
79
  return 'autoescape';
80
  }
81
  }
82
-
83
- class_alias('Twig_TokenParser_AutoEscape', 'Twig\TokenParser\AutoEscapeTokenParser', false);
79
  return 'autoescape';
80
  }
81
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Block.php CHANGED
@@ -69,5 +69,3 @@ class Twig_TokenParser_Block extends Twig_TokenParser
69
  return 'block';
70
  }
71
  }
72
-
73
- class_alias('Twig_TokenParser_Block', 'Twig\TokenParser\BlockTokenParser', false);
69
  return 'block';
70
  }
71
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Do.php CHANGED
@@ -30,5 +30,3 @@ class Twig_TokenParser_Do extends Twig_TokenParser
30
  return 'do';
31
  }
32
  }
33
-
34
- class_alias('Twig_TokenParser_Do', 'Twig\TokenParser\DoTokenParser', false);
30
  return 'do';
31
  }
32
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Embed.php CHANGED
@@ -63,5 +63,3 @@ class Twig_TokenParser_Embed extends Twig_TokenParser_Include
63
  return 'embed';
64
  }
65
  }
66
-
67
- class_alias('Twig_TokenParser_Embed', 'Twig\TokenParser\EmbedTokenParser', false);
63
  return 'embed';
64
  }
65
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Extends.php CHANGED
@@ -42,5 +42,3 @@ class Twig_TokenParser_Extends extends Twig_TokenParser
42
  return 'extends';
43
  }
44
  }
45
-
46
- class_alias('Twig_TokenParser_Extends', 'Twig\TokenParser\ExtendsTokenParser', false);
42
  return 'extends';
43
  }
44
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Filter.php CHANGED
@@ -49,5 +49,3 @@ class Twig_TokenParser_Filter extends Twig_TokenParser
49
  return 'filter';
50
  }
51
  }
52
-
53
- class_alias('Twig_TokenParser_Filter', 'Twig\TokenParser\FilterTokenParser', false);
49
  return 'filter';
50
  }
51
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Flush.php CHANGED
@@ -30,5 +30,3 @@ class Twig_TokenParser_Flush extends Twig_TokenParser
30
  return 'flush';
31
  }
32
  }
33
-
34
- class_alias('Twig_TokenParser_Flush', 'Twig\TokenParser\FlushTokenParser', false);
30
  return 'flush';
31
  }
32
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/For.php CHANGED
@@ -123,5 +123,3 @@ class Twig_TokenParser_For extends Twig_TokenParser
123
  return 'for';
124
  }
125
  }
126
-
127
- class_alias('Twig_TokenParser_For', 'Twig\TokenParser\ForTokenParser', false);
123
  return 'for';
124
  }
125
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/From.php CHANGED
@@ -62,5 +62,3 @@ class Twig_TokenParser_From extends Twig_TokenParser
62
  return 'from';
63
  }
64
  }
65
-
66
- class_alias('Twig_TokenParser_From', 'Twig\TokenParser\FromTokenParser', false);
62
  return 'from';
63
  }
64
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/If.php CHANGED
@@ -82,5 +82,3 @@ class Twig_TokenParser_If extends Twig_TokenParser
82
  return 'if';
83
  }
84
  }
85
-
86
- class_alias('Twig_TokenParser_If', 'Twig\TokenParser\IfTokenParser', false);
82
  return 'if';
83
  }
84
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Import.php CHANGED
@@ -37,5 +37,3 @@ class Twig_TokenParser_Import extends Twig_TokenParser
37
  return 'import';
38
  }
39
  }
40
-
41
- class_alias('Twig_TokenParser_Import', 'Twig\TokenParser\ImportTokenParser', false);
37
  return 'import';
38
  }
39
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Include.php CHANGED
@@ -18,6 +18,8 @@
18
  * Body
19
  * {% include 'footer.html' %}
20
  * </pre>
 
 
21
  */
22
  class Twig_TokenParser_Include extends Twig_TokenParser
23
  {
@@ -61,5 +63,3 @@ class Twig_TokenParser_Include extends Twig_TokenParser
61
  return 'include';
62
  }
63
  }
64
-
65
- class_alias('Twig_TokenParser_Include', 'Twig\TokenParser\IncludeTokenParser', false);
18
  * Body
19
  * {% include 'footer.html' %}
20
  * </pre>
21
+ *
22
+ * @final
23
  */
24
  class Twig_TokenParser_Include extends Twig_TokenParser
25
  {
63
  return 'include';
64
  }
65
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Macro.php CHANGED
@@ -56,5 +56,3 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
56
  return 'macro';
57
  }
58
  }
59
-
60
- class_alias('Twig_TokenParser_Macro', 'Twig\TokenParser\MacroTokenParser', false);
56
  return 'macro';
57
  }
58
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php CHANGED
@@ -57,5 +57,3 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser
57
  return 'sandbox';
58
  }
59
  }
60
-
61
- class_alias('Twig_TokenParser_Sandbox', 'Twig\TokenParser\SandboxTokenParser', false);
57
  return 'sandbox';
58
  }
59
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Set.php CHANGED
@@ -71,5 +71,3 @@ class Twig_TokenParser_Set extends Twig_TokenParser
71
  return 'set';
72
  }
73
  }
74
-
75
- class_alias('Twig_TokenParser_Set', 'Twig\TokenParser\SetTokenParser', false);
71
  return 'set';
72
  }
73
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php CHANGED
@@ -47,5 +47,3 @@ class Twig_TokenParser_Spaceless extends Twig_TokenParser
47
  return 'spaceless';
48
  }
49
  }
50
-
51
- class_alias('Twig_TokenParser_Spaceless', 'Twig\TokenParser\SpacelessTokenParser', false);
47
  return 'spaceless';
48
  }
49
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/Use.php CHANGED
@@ -64,5 +64,3 @@ class Twig_TokenParser_Use extends Twig_TokenParser
64
  return 'use';
65
  }
66
  }
67
-
68
- class_alias('Twig_TokenParser_Use', 'Twig\TokenParser\UseTokenParser', false);
64
  return 'use';
65
  }
66
  }
 
 
vendor/twig/twig/lib/Twig/TokenParser/With.php CHANGED
@@ -48,5 +48,3 @@ class Twig_TokenParser_With extends Twig_TokenParser
48
  return 'with';
49
  }
50
  }
51
-
52
- class_alias('Twig_TokenParser_With', 'Twig\TokenParser\WithTokenParser', false);
48
  return 'with';
49
  }
50
  }
 
 
vendor/twig/twig/lib/Twig/TokenParserInterface.php CHANGED
@@ -37,7 +37,3 @@ interface Twig_TokenParserInterface
37
  */
38
  public function getTag();
39
  }
40
-
41
- class_alias('Twig_TokenParserInterface', 'Twig\TokenParser\TokenParserInterface', false);
42
- class_exists('Twig_Parser');
43
- class_exists('Twig_Token');
37
  */
38
  public function getTag();
39
  }
 
 
 
 
vendor/twig/twig/lib/Twig/TokenStream.php CHANGED
@@ -192,5 +192,3 @@ class Twig_TokenStream
192
  return $this->source;
193
  }
194
  }
195
-
196
- class_alias('Twig_TokenStream', 'Twig\TokenStream', false);
192
  return $this->source;
193
  }
194
  }
 
 
vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php CHANGED
@@ -82,5 +82,3 @@ class Twig_Util_DeprecationCollector
82
  }
83
  }
84
  }
85
-
86
- class_alias('Twig_Util_DeprecationCollector', 'Twig\Util\DeprecationCollector', false);
82
  }
83
  }
84
  }
 
 
vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php CHANGED
@@ -24,5 +24,3 @@ class Twig_Util_TemplateDirIterator extends IteratorIterator
24
  return (string) parent::key();
25
  }
26
  }
27
-
28
- class_alias('Twig_Util_TemplateDirIterator', 'Twig\Util\TemplateDirIterator', false);
24
  return (string) parent::key();
25
  }
26
  }
 
 
wpml-config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <custom-fields>
3
  <custom-field action="copy">_backorders</custom-field>
4
  <custom-field action="translate">_crosssell_ids</custom-field>
5
- <custom-field action="copy">_default_attributes</custom-field>
6
  <custom-field action="copy">_download_limit</custom-field>
7
  <custom-field action="copy">_download_expiry</custom-field>
8
  <custom-field action="copy">_download_type</custom-field>
@@ -62,6 +62,7 @@
62
  <custom-field action="ignore">wcml_sync_hash</custom-field>
63
  <custom-field action="ignore">wpml_language</custom-field>
64
  <custom-field action="ignore">_product_attributes</custom-field>
 
65
  </custom-fields>
66
  <custom-types>
67
  <custom-type translate="1">product</custom-type>
2
  <custom-fields>
3
  <custom-field action="copy">_backorders</custom-field>
4
  <custom-field action="translate">_crosssell_ids</custom-field>
5
+ <custom-field action="ignore">_default_attributes</custom-field>
6
  <custom-field action="copy">_download_limit</custom-field>
7
  <custom-field action="copy">_download_expiry</custom-field>
8
  <custom-field action="copy">_download_type</custom-field>
62
  <custom-field action="ignore">wcml_sync_hash</custom-field>
63
  <custom-field action="ignore">wpml_language</custom-field>
64
  <custom-field action="ignore">_product_attributes</custom-field>
65
+ <custom-field action="translate">_children</custom-field>
66
  </custom-fields>
67
  <custom-types>
68
  <custom-type translate="1">product</custom-type>
wpml-woocommerce.php CHANGED
@@ -8,14 +8,14 @@
8
  Text Domain: woocommerce-multilingual
9
  Requires at least: 3.9
10
  Tested up to: 4.8.1
11
- Version: 4.2.0.1
12
  */
13
 
14
  if ( defined( 'WCML_VERSION' ) ) {
15
  return;
16
  }
17
 
18
- define( 'WCML_VERSION', '4.2.0.1' );
19
  define( 'WCML_PLUGIN_PATH', dirname( __FILE__ ) );
20
  define( 'WCML_PLUGIN_FOLDER', basename( WCML_PLUGIN_PATH ) );
21
  define( 'WCML_LOCALE_PATH', WCML_PLUGIN_PATH . '/locale' );
@@ -28,7 +28,12 @@ require WCML_PLUGIN_PATH . '/inc/woocommerce-functions-wrapper.php';
28
  include WCML_PLUGIN_PATH . '/inc/installer-loader.php';
29
  include WCML_PLUGIN_PATH . '/inc/wcml-core-functions.php';
30
  include WCML_PLUGIN_PATH . '/inc/wcml-switch-lang-request.php';
31
- include WCML_PLUGIN_PATH . '/inc/wcml-cart-switch-lang-functions.php';
 
 
 
 
 
32
 
33
  if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress' ) ) {
34
  global $sitepress;
@@ -38,12 +43,7 @@ if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists
38
 
39
  //cart related language switching functions
40
  $wcml_cart_switch_lang_functions = new WCML_Cart_Switch_Lang_Functions();
41
- }
42
-
43
- if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {
44
- require WCML_PLUGIN_PATH . '/vendor/autoload.php';
45
- } else {
46
- require WCML_PLUGIN_PATH . '/vendor/autoload_52.php';
47
  }
48
 
49
  // Load WooCommerce Multilingual when WPML is active
8
  Text Domain: woocommerce-multilingual
9
  Requires at least: 3.9
10
  Tested up to: 4.8.1
11
+ Version: 4.2.1
12
  */
13
 
14
  if ( defined( 'WCML_VERSION' ) ) {
15
  return;
16
  }
17
 
18
+ define( 'WCML_VERSION', '4.2.1' );
19
  define( 'WCML_PLUGIN_PATH', dirname( __FILE__ ) );
20
  define( 'WCML_PLUGIN_FOLDER', basename( WCML_PLUGIN_PATH ) );
21
  define( 'WCML_LOCALE_PATH', WCML_PLUGIN_PATH . '/locale' );
28
  include WCML_PLUGIN_PATH . '/inc/installer-loader.php';
29
  include WCML_PLUGIN_PATH . '/inc/wcml-core-functions.php';
30
  include WCML_PLUGIN_PATH . '/inc/wcml-switch-lang-request.php';
31
+
32
+ if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {
33
+ require WCML_PLUGIN_PATH . '/vendor/autoload.php';
34
+ } else {
35
+ require WCML_PLUGIN_PATH . '/vendor/autoload_52.php';
36
+ }
37
 
38
  if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress' ) ) {
39
  global $sitepress;
43
 
44
  //cart related language switching functions
45
  $wcml_cart_switch_lang_functions = new WCML_Cart_Switch_Lang_Functions();
46
+ $wcml_cart_switch_lang_functions->add_actions();
 
 
 
 
 
47
  }
48
 
49
  // Load WooCommerce Multilingual when WPML is active