- Status
- Resolved
- Resolved in
- 4.4.12
Overview of the issue
In some cases, widget translations may not display on the site’s front-end, and you will see the following error:
PHP Warning: array_merge(): Expected parameter 1 to be an array, null given in …\wp-content\plugins\sitepress-multilingual-cms\classes\widgets\class-wpml-widgets-support-frontend.php on line 61
Workaround
This issue will be fixed in our next WPML release, however you can use the following workaround in the meantime:
- Before proceeding make a full backup of your site.
- Go to your folder /plugins/sitepress-multilingual-cms/classes/widgets/.
- Open the class-wpml-widgets-support-frontend.php file and replace 56-67 lines:
private function it_must_display( $instance ) { if ( isset ( $instance['content'] ) ) { $matches = Str::matchAll( self::TERM_REGEX, $instance['content'] ); $matches = Fns::map( pipe( Lst::nth( 0 ), Json::toArray() ), $matches ); if ( count( $matches ) > 0 ) { $instance = array_merge(...$matches); } } return Lst::includes( Obj::propOr( null, 'wpml_language', $instance ), [ null, $this->current_language, 'all' ] ); } } - With:
private function it_must_display( $instance ) { return ! array_key_exists( 'wpml_language', $instance ) || $instance['wpml_language'] === $this->current_language || 'all' === $instance['wpml_language']; } }