proteusbr
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce Parcelas] Erro no LogPor que o aviso aparece
- Quando o plugin é carregado,
woocommerce-parcelas.phpinstancia o objetoMainimediatamente:wcParcelas(); // executa já no “plugin load” - Em cadeia, o container resolve a classe
WcParcelas\App\Common\Settings; no construtor deSettingsainda durante o carregamento do plugin ocorre:__( 'Cor: ', 'wc-parcelas' ); // vários __() parecidos - Como o text-domain ainda não foi carregado e o hook
inittampouco ocorreu, o WordPress tenta carregá-lo “just-in-time”, gerando o doing_it_wrong: Translation loading for the wc-parcelas domain was triggered too early…
Passo-a-passo para corrigir
Há dois ajustes complementares (ambos simples e retro-compatíveis): Onde O que fazer Por quê
woocommerce-parcelas.phpCarregar o arquivo de tradução só noinit(ou mais tarde). Garante que o domínio esteja disponível antes de você chamar__(), mas depois do ponto permitido pelo core.app/Common/Settings.phpAdiar as chamadas a__()para o próprioinit(ou para qualquer callback que rode depois). Impede que o JIT seja acionado durante o carregamento do plugin. 1. Carregar o texto do plugin na hora certa// woocommerce-parcelas/woocommerce-parcelas.php add_action( 'init', function () { load_plugin_textdomain( 'wc-parcelas', false, dirname( WC_PARCELAS_BASENAME ) . '/languages' ); }, 0 ); // prioridade 0 para ser o primeiro no init2. Mover as traduções do construtor para um callback em
init// woocommerce-parcelas/app/Common/Settings.php class Settings { public function __construct() { add_action( 'admin_menu', [ $this, 'fswp_admin_menu' ], 100 ); add_action( 'admin_init', [ $this, 'fswp_page_settings' ] ); // ← Antes as traduções estavam aqui: gerava o aviso add_action( 'init', [ $this, 'init_style_labels' ] ); } /** * Só é chamado depois do init, quando o domínio de tradução já está carregado. */ public function init_style_labels() : void { $this->style = [ 'color' => [ 'title' => __( 'Cor: ', 'wc-parcelas' ), 'function' => 'fswp_text_callback', 'class' => 'color-field', ], 'font-weight' => [ 'title' => __( 'Peso: ', 'wc-parcelas' ), 'function' => 'fswp_select_callback', 'options' => [ 'inherit' => '-', 100 => 100, 200 => 200, 300 => 300, 400 => 400, 500 => 500, 600 => 600, 700 => 700, 800 => 800, 900 => 900, ], ], 'font-size' => [ 'title' => __( 'Tamanho: ', 'wc-parcelas' ), 'function' => 'fswp_text_callback', 'placeholder' => __( 'Ex.: 18px ou 1.2em', 'wc-parcelas' ), ], ]; }Observação: caso outra classe faça chamadas a
__()no construtor, repita a mesma estratégia:
– ou mova as strings para um método chamado eminit,
– ou adie a própria criação do objeto (ex.: instantiate-o também viainit).Resultado esperado
- O hook
initcarrega o arquivo de tradução. - Os métodos que usam
__()agora são executados apósinit. - O aviso “load_textdomain_just_in_time foi chamado incorretamente” desaparece do log.
Isso resolve o problema sem impactar outras funcionalidades do plugin.
Forum: Plugins
In reply to: [Pagar.me para WooCommerce] Warning: Attempt to read property “total” on null(duplicate)
- This reply was modified 1 year, 3 months ago by proteusbr.
Forum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Apple Pay And CSSForum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Apple Pay And CSSForum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Apple Pay And CSSin the strip I added the following domains: store.pericialmed.com and pericialmed.com
Forum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Custom Title is not workingSame here
https://loja.pericialmed.com/Forum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Apple Pay And CSSJust fix the CSS changing the Theme to storefront, but Apple Pay is not working.
- Quando o plugin é carregado,