WPML
สถานะ
แก้ไขแล้ว
แก้ไขใน
4.4.12

ภาพรวมของปัญหา

ในบางกรณี การแปลวิดเจ็ตอาจไม่แสดงบนส่วนหน้าเว็บไซต์ และคุณจะเห็นข้อผิดพลาดต่อไปนี้:

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

วิธีแก้ปัญหาชั่วคราว

ปัญหานี้จะได้รับการแก้ไขใน WPML เวอร์ชันที่เผยแพร่ถัดไป อย่างไรก็ตาม ในระหว่างนี้คุณสามารถใช้วิธีแก้ปัญหาชั่วคราวต่อไปนี้:


  1. ก่อนดำเนินการต่อ ให้สำรองข้อมูลเว็บไซต์ของคุณทั้งหมด

  2. ไปที่โฟลเดอร์ /plugins/sitepress-multilingual-cms/classes/widgets/

  3. เปิดไฟล์ class-wpml-widgets-support-frontend.php และแทนที่บรรทัดที่ 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. ด้วย:
        private function it_must_display( $instance ) {
            return ! array_key_exists( 'wpml_language', $instance )
                   || $instance['wpml_language'] === $this->current_language
                   || 'all' === $instance['wpml_language'];
        }
    }

ปัญหาที่ทราบแล้วทั้งหมด →