WPML
Stato
Risolto
Risolto in
4.4.12

Panoramica del problema

In alcuni casi, le traduzioni dei widget potrebbero non essere visualizzate sul front-end del sito e vedrai il seguente errore:

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

Soluzione alternativa

Questo problema verrà risolto nella nostra prossima versione di WPML, tuttavia nel frattempo puoi utilizzare la seguente soluzione alternativa:


  1. Prima di procedere, esegui un backup completo del tuo sito.

  2. Vai alla cartella /plugins/sitepress-multilingual-cms/classes/widgets/.

  3. Apri il file class-wpml-widgets-support-frontend.php e sostituisci le righe 56-67:
        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' ] );
        }
    }


  4. Con:
        private function it_must_display( $instance ) {
            return ! array_key_exists( 'wpml_language', $instance )
                   || $instance['wpml_language'] === $this->current_language
                   || 'all' === $instance['wpml_language'];
        }
    }

Tutti i problemi noti →