WPML
סטטוס
ממתין למפתח
תוסף/ערכת עיצוב קשורים
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(
      

כל התקלות הידועות →