- الحالة
- في انتظار المطور
- الإضافة/القالب ذو الصلة
- 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(