|
|
@@ -3,7 +3,7 @@
|
|
|
* Plugin Name: QDR - Studiou WC Free Photo Product
|
|
|
* Plugin URI: https://www.quadarax.com/plugins/studiou-wc-free-photo-product
|
|
|
* Description: Allows publishing special WooCommerce products with variants and custom raw image upload for photo printing
|
|
|
- * Version: 1.5.13
|
|
|
+ * Version: 1.5.14
|
|
|
* Requires at least: 6.9.4
|
|
|
* Requires PHP: 8.2
|
|
|
* Requires Plugins: woocommerce, product-variant-table-for-woocommerce
|
|
|
@@ -22,7 +22,7 @@ if (!defined('WPINC')) {
|
|
|
die;
|
|
|
}
|
|
|
|
|
|
-if (!defined('STUDIOU_WCFPP_VERSION')) define('STUDIOU_WCFPP_VERSION', '1.5.13');
|
|
|
+if (!defined('STUDIOU_WCFPP_VERSION')) define('STUDIOU_WCFPP_VERSION', '1.5.14');
|
|
|
if (!defined('STUDIOU_WCFPP_PLUGIN_DIR')) define('STUDIOU_WCFPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
|
if (!defined('STUDIOU_WCFPP_PLUGIN_URL')) define('STUDIOU_WCFPP_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
|
if (!defined('STUDIOU_WCFPP_PLUGIN_BASENAME')) define('STUDIOU_WCFPP_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
|
|
@@ -248,18 +248,40 @@ class Studiou_WC_Free_Photo_Product {
|
|
|
public function register_frontend_assets() {
|
|
|
// WC block cart ("Estimated total" etc.) is React-rendered and pulls its strings
|
|
|
// from wp.i18n in the browser — the PHP gettext_woocommerce filter never fires for
|
|
|
- // those strings. Patch the translation on the JS side: after wp-i18n loads, and
|
|
|
- // before the cart block renders, replace the 'Estimated total' → 'woocommerce'
|
|
|
- // domain entry with our own wording. Translation source of truth stays in our .po.
|
|
|
- $override_js = "( function() {";
|
|
|
+ // those strings. Patch the translation on the JS side.
|
|
|
+ //
|
|
|
+ // IMPORTANT: WC's wc-cart-checkout-base-js-translations inline bundle calls
|
|
|
+ // wp.i18n.setLocaleData(cartLocaleData, 'woocommerce') AFTER our override, which
|
|
|
+ // merges the WC-bundled "Estimated total": ["Odhadovaný součet"] back on top of
|
|
|
+ // ours. So a single one-shot override on wp-i18n is clobbered.
|
|
|
+ //
|
|
|
+ // We install a permanent override by:
|
|
|
+ // 1) re-applying after every future setLocaleData call via wp.hooks (if available), and
|
|
|
+ // 2) attaching another override as a `before` inline script on wc-cart-checkout-base,
|
|
|
+ // which runs AFTER the translations bundle has merged its own data in.
|
|
|
+ $total_txt = wp_json_encode(__('Total', 'studiou-wc-free-photo-product'));
|
|
|
+ $override_js = "( function() {";
|
|
|
$override_js .= " if ( ! window.wp || ! wp.i18n ) return;";
|
|
|
$override_js .= " var domain = 'woocommerce';";
|
|
|
- $override_js .= " var txt = " . wp_json_encode(__('Total', 'studiou-wc-free-photo-product')) . ";";
|
|
|
- $override_js .= " wp.i18n.setLocaleData( { 'Estimated total': [ txt ] }, domain );";
|
|
|
- // Also remap other cart-page terminology variants so UI stays consistent.
|
|
|
- $override_js .= " wp.i18n.setLocaleData( { 'Cart totals': [ txt ] }, domain );";
|
|
|
+ $override_js .= " var txt = " . $total_txt . ";";
|
|
|
+ $override_js .= " function apply() { try {";
|
|
|
+ $override_js .= " wp.i18n.setLocaleData( { 'Estimated total': [ txt ], 'Cart totals': [ txt ] }, domain );";
|
|
|
+ $override_js .= " } catch (e) {} }";
|
|
|
+ $override_js .= " apply();";
|
|
|
+ // Re-apply on every subsequent wp.i18n data change (covers WC's late bundle load).
|
|
|
+ $override_js .= " if ( wp.hooks && wp.hooks.addAction ) {";
|
|
|
+ $override_js .= " wp.hooks.addAction( 'i18n.gettext_with_context_woocommerce', 'studiou-fpp/total-override', apply );";
|
|
|
+ $override_js .= " wp.hooks.addAction( 'i18n.gettext_woocommerce', 'studiou-fpp/total-override', apply );";
|
|
|
+ $override_js .= " }";
|
|
|
+ // Also re-apply after DOMContentLoaded as a last-line safety net.
|
|
|
+ $override_js .= " if ( document.readyState === 'loading' ) {";
|
|
|
+ $override_js .= " document.addEventListener( 'DOMContentLoaded', apply );";
|
|
|
+ $override_js .= " }";
|
|
|
$override_js .= " } )();";
|
|
|
wp_add_inline_script('wp-i18n', $override_js, 'after');
|
|
|
+ // The critical bit: override AFTER WC's cart-checkout-base translations bundle runs.
|
|
|
+ wp_add_inline_script('wc-cart-checkout-base', $override_js, 'after');
|
|
|
+ wp_add_inline_script('wc-cart-block-frontend', $override_js, 'after');
|
|
|
|
|
|
wp_register_style(
|
|
|
'studiou-wcfpp-frontend',
|