WPML
상태
개발자 대기 중
관련 플러그인/테마
Visual Composer
주제 태그
Bug, Compatibility

문제 개요

WPML과 함께 Visual Composer Pro를 사용할 때 번역 관리 페이지에 접속하면 다음과 같은 치명적인 오류가 발생할 수 있습니다:

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(
      

알려진 모든 문제 →