- Trạng thái
- Đang chờ nhà phát triển
- Plugin/giao diện liên quan
- Visual Composer
- Thẻ chủ đề
- Bug, Compatibility
Tổng quan về lỗi
Khi sử dụng Visual Composer Pro với WPML, bạn có thể gặp phải lỗi nghiêm trọng sau đây khi truy cập trang Quản lý dịch thuật:
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
Giải pháp tạm thời
Vui lòng đảm bảo bạn có bản sao lưu đầy đủ cho trang web trước khi tiếp tục.
Giải pháp tạm thời 1 (Được khuyến nghị)
Thêm mã sau vào tệp functions.php trong giao diện của bạn:
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;
} );
Giải pháp tạm thời 2 (Thay thế)
Giải pháp tạm thời này liên quan đến việc sửa đổi trực tiếp mã plugin, điều này có thể bị mất khi cập nhật.
- Mở: /wp-content/uploads/visualcomposer-assets/addons/themeEditor/themeEditor/PostTypeController.php
- Tìm:
protected function registerPostType() { register_post_type( - Và thay thế bằng:
protected function registerPostType() { if (!isset($this->postNamePlural)){ $this->postNamePlural = $this->postNameSlug; } register_post_type(