- สถานะ
- รอผู้พัฒนา
- ปลั๊กอิน/ธีมที่เกี่ยวข้อง
- Visual Composer
- แท็กหัวข้อ
- Bug, Compatibility
ภาพรวมของปัญหา
เมื่อใช้ Visual Composer Pro ร่วมกับ WPML คุณอาจพบข้อผิดพลาดร้ายแรงต่อไปนี้เมื่อเข้าถึงหน้าการจัดการการแปล:
PHP Fatal error: Uncaught TypeError: Argument 2 passed to WPML\Core\SharedKernel\Component\Post\Application\Query\Dto\PostTypeDto::__construct() must be of the type string, null given, called in ../public_html/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Core/SharedKernel/Component/Post/Application/Query/Dto/PostTypeDto.php:26
วิธีแก้ปัญหาชั่วคราว
โปรดตรวจสอบให้แน่ใจว่าคุณได้สำรองข้อมูลไซต์ของคุณอย่างครบถ้วนก่อนดำเนินการต่อ
วิธีแก้ปัญหาชั่วคราว 1 (แนะนำ)
เพิ่มโค้ดต่อไปนี้ลงในไฟล์ functions.php ของธีมของคุณ:
add_filter( 'wpml_post_type_dto_filter', function ( $postTypeObject ) {
if ( is_object( $postTypeObject ) ) {
$default = $postTypeObject->name ?? '';
if ( ! isset( $postTypeObject->labels ) || ! is_object( $postTypeObject->labels ) ) {
$postTypeObject->labels = new stdClass();
}
if ( empty( $postTypeObject->name ) ) {
$postTypeObject->name = $default;
}
if ( empty( $postTypeObject->labels->name ) ) {
$postTypeObject->labels->name = $default;
}
if ( empty( $postTypeObject->labels->singular_name ) ) {
$postTypeObject->labels->singular_name = $default;
}
}
return $postTypeObject;
} );
วิธีแก้ปัญหาชั่วคราว 2 (ทางเลือก)
วิธีแก้ปัญหาชั่วคราวนี้เกี่ยวข้องกับการแก้ไขโค้ดของปลั๊กอินโดยตรง ซึ่งอาจสูญหายได้เมื่อมีการอัปเดต
- เปิด: /wp-content/uploads/visualcomposer-assets/addons/themeEditor/themeEditor/PostTypeController.php
- ค้นหา:
protected function registerPostType() { register_post_type( - และแทนที่ด้วย:
protected function registerPostType() { if (!isset($this->postNamePlural)){ $this->postNamePlural = $this->postNameSlug; } register_post_type(