- الحالة
- محلولة
- أُبلغ عنها لـ
- Advanced Custom Fields Multilingual 2.0.3
- تم حلها في
- 2.0.4
- الإضافة/القالب ذو الصلة
- Advanced Custom Fields (ACF)
- وسوم الموضوع
- Bug
نظرة عامة على المشكلة
عند استخدام Advanced Custom Fields Pro وحفظ خيار قالب بحقل تصنيف، يحدث الخطأ الفادح التالي:
PHP Fatal error: Uncaught Error: Cannot use object of type WP_Term as array in …\wp-content\plugins\acfml\classes\strategy\repeater-shuffle\OptionsPage.php:89Stack trace:
#0 …\wp-content\plugins\acfml\classes\strategy\repeater-shuffle\OptionsPage.php(75): ACFML\Repeater\Shuffle\OptionsPage->addNormalizedValuesForFieldState(Array, '', ‘my_taxo_term’, Object(WP_Term))
…\plugins\acfml\classes\class-wpml-acf-field-state.php(57): ACFML\Repeater\Shuffle\OptionsPage->getAllMeta('options’)
…\plugins\acfml\classes\class-wpml-acf-field-state.php(41): ACFML\FieldState->getCurrentMetadata('options’)
…\class-wp-hook.php(308): ACFML\FieldState->storeStateBefore('options’)
…\class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
…\plugin.php(517): WP_Hook->do_action(Array)…
حل بديل مؤقت
يُرجى إنشاء نسخة احتياطية كاملة لموقعك قبل المتابعة.
- افتح الملف …/wp-content/plugins/acfml/classes/strategy/repeater-shuffle/OptionsPage.php.
- ابحث عن السطر 88.
- استبدل:
private function addNormalizedValuesForFieldState( $options, $prefix, $key, $value ) { if ( $value instanceof WP_Post || isset( $value['ID'] ) ) { return array_merge( $options, [ "${prefix}${key}" => Obj::prop( 'ID', $value ) ] ); } elseif ( $this->isArrayOfStrings( $value ) ) { return array_merge( $options, [ "${prefix}${key}" => $value ] ); } elseif ( is_array( $value ) ) { foreach ( $value as $index => $item ) { if ( is_numeric( $index ) ) { foreach ( $item as $field => $field_value ) { $options = array_merge( $options, $this->addNormalizedValuesForFieldState( $options, "${prefix}${key}_${index}_", $field, $field_value ) ); } } else { $options = $this->addNormalizedValuesForFieldState( $options, "${prefix}${key}_", $index, $item ); } } return $options; } else { return array_merge( $options, [ "${prefix}${key}" => $value ] ); } }بـ:
private function addNormalizedValuesForFieldState( $options, $prefix, $key, $value ) { if ( $value instanceof WP_Post || is_array($value) && isset( $value['ID'] ) ) { return array_merge( $options, [ "${prefix}${key}" => Obj::prop( 'ID', $value ) ] ); } elseif ( $value instanceof WP_Term || isset( $value->term_id ) ) { return array_merge( $options, [ "${prefix}${key}" => Obj::prop( 'term_id', $value ) ] ); } elseif ( $this->isArrayOfStrings( $value ) ) { return array_merge( $options, [ "${prefix}${key}" => $value ] ); } elseif ( is_array( $value ) ) { foreach ( $value as $index => $item ) { if ( is_numeric( $index ) ) { foreach ( $item as $field => $field_value ) { $options = array_merge( $options, $this->addNormalizedValuesForFieldState( $options, "${prefix}${key}_${index}_", $field, $field_value ) ); } } else { $options = $this->addNormalizedValuesForFieldState( $options, "${prefix}${key}_", $index, $item ); } } return $options; } else { return array_merge( $options, [ "${prefix}${key}" => $value ] ); } }