Home > Software design >  Member variable does not accept array with elements
Member variable does not accept array with elements

Time:09-16

After updating WordPress to 6.0.2, I get the "white screen of death" - just stating that

there is a critical error

with no further explanation.

After some debugging I located the line, that produces the error:
/wp-content/plugins/jet-theme-core/includes/locations.php line 53

It's a function of the class Jet_Theme_Core_Locations that assigns an array to $this->_locations[ $id ]

With these declarations

private $_locations     = array();
public $test = array();
private $_test = array();

I tested some statements and found out that

$this->_locations = true;    // works
$this->_locations = "test";  // works
$this->_locations = array(); // works
$this->_locations = array("test");           // produces a critical error
$this->_locations = array("test" => "test"); // produces a critical error
$this->_locations[] = "test";                // produces a critical error
$this->_locations["test"] = "test";          // produces a critical error
$test = array("test" => "test"); // works
$this->test = array();           // works
$this->test = array("test");     // works
$this->_test = array();          // works
$this->_test = array("test");    // works

I must be missing something. Probably something really obvious. But I can't figure out, what it is.

[Edit:] The PHP log file says:

PHP Fatal error:  Uncaught Error: Class 'Elementor\\Post_CSS_File' not found in /wp-content/plugins/jet-theme-core/includes/locations.php:106

CodePudding user response:

The function enqueue_styles() loops over $this->_locations and calls Elementor\Post_CSS_File but doesn't find it. If $this->_locations is empty or not an array at all, it doesn't touch Elementor\Post_CSS_File and the error doesn't occur.

As suggested here, I replaced

$css_file = new Elementor\Post_CSS_File( $template_id );

with

$css_file = new Elementor\Core\Files\CSS\Post( $template_id );

Now everything works fine.

  • Related