Errors with PHP 8.3: translation too early
-
Hello,
PHP 8.3 is logging errors :
The bug in woosidebars – class-woo-conditions.php:57:
public function __construct () {
$this->meta_box_settings['title'] = __( 'Conditions', 'woosidebars' ); // ❌ Line 57
// ...
}Problem: The constructor calls
__()immediately when the class is instantiated. This happens during plugin loading (beforeinithook) becauseWoo_Sidebars->__construct()creates a newWoo_Conditionsobject.Fix: Delay the translation until it’s actually needed:
public function __construct () { /* DDB - 20251212 - WP 6.7+ fix: delay translation */ // $this->meta_box_settings['title'] = __( 'Conditions', 'woosidebars' ); $this->meta_box_settings['title'] = 'Conditions'; // Set untranslated add_action( 'init', array( $this, 'init_translations' ) ); // ... } public function init_translations() { $this->meta_box_settings['title'] = __( 'Conditions', 'woosidebars' ); }
You must be logged in to reply to this topic.