WPML

问题概述

使用 Advanced Custom Fields 插件时可能会出现以下致命错误。该错误特别在使用 PHP 8 或更高版本时出现:

Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in .../wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-element-translation.php:259

临时解决方法

此问题已在 Advanced Custom Fields Multilingual 2.1.0 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。

在继续操作之前,请确保对您的站点进行完整备份。

  • 打开 …/wp-content/plugins/acfml/classes/class-wpml-acf-attachments.php 文件。
  • 找到第 28 行。
  • 替换:
    foreach ( $attachments as $key => $attachment_id ) {
    		$translated_attachments[ $key ] = apply_filters( 'wpml_object_id', $attachment_id, 'attachment', true );
  • 替换为:
    foreach ( $attachments as $key => $attachment_id ) {
    	if (is_int($attachment_id)) {
    		$translated_attachments[ $key ] = apply_filters( 'wpml_object_id', $attachment_id, 'attachment', true );
    	}

所有已知问题

仍然遇到此问题?

如果更新无法解决问题,请提出支持问题,我们将与您一起排查。