WPML
Trạng thái
Đã giải quyết
Đã giải quyết trong
4.4.12

Tổng quan về lỗi

Trong một số trường hợp, các bản dịch widget có thể không hiển thị trên giao diện người dùng của trang web, và bạn sẽ thấy lỗi sau:

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

Giải pháp tạm thời

Vấn đề này sẽ được khắc phục trong phiên bản phát hành WPML tiếp theo của chúng tôi, tuy nhiên bạn có thể sử dụng giải pháp tạm thời sau trong thời gian chờ đợi:


  1. Trước khi tiếp tục, hãy tạo một bản sao lưu đầy đủ cho trang web của bạn.

  2. Đi tới thư mục /plugins/sitepress-multilingual-cms/classes/widgets/ của bạn.

  3. Mở tệp class-wpml-widgets-support-frontend.php và thay thế các dòng 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. Bằng:
        private function it_must_display( $instance ) {
            return ! array_key_exists( 'wpml_language', $instance )
                   || $instance['wpml_language'] === $this->current_language
                   || 'all' === $instance['wpml_language'];
        }
    }

Tất cả các lỗi đã ghi nhận →