Resumen del problema
En algunos casos, el plugin Advanced Custom Fields Multilingual (ACFML) puede generar una advertencia de PHP al utilizar campos de ACF:
Attempt to read property "post_content" on null in plugins .../acfml/classes/class-wpml-acf-repeater-shuffle.php on line 249
Solución alternativa
Este problema se ha solucionado en Advanced Custom Fields Multilingual 2.2.0. Actualizar lo soluciona en su sitio, por lo que solo necesita esta solución alternativa si aún no puede actualizar.
Por favor, asegúrese de tener una copia de seguridad completa de su sitio antes de continuar.
- Abra el archivo …/acfml/classes/class-wpml-acf-repeater-shuffle.php.
- Busque la línea 244.
- Reemplace:
private function isChildOfRepeaterField( $key, $postId ) { $acfFieldObject = get_field_object( $key, $postId ); if ( isset( $acfFieldObject['parent'] ) && $acfFieldObject['parent'] > 0 ) { $fieldParent = get_post( $acfFieldObject['parent'] ); $fieldParentContent = maybe_unserialize( $fieldParent->post_content ); if ( isset( $fieldParentContent['type'] ) && 'repeater' === $fieldParentContent['type'] ) { return true; } } return false; } - Por:
private function isChildOfRepeaterField( $key, $postId ) { $acfFieldObject = get_field_object( $key, $postId ); if ( isset( $acfFieldObject['parent'] ) ) { if ( is_numeric( $acfFieldObject['parent'] ) && $acfFieldObject['parent'] > 0 ) { $fieldParent = get_post( $acfFieldObject['parent'], $postId ); if ( $fieldParent ) { $fieldParentContent = maybe_unserialize( $fieldParent->post_content ); if ( isset( $fieldParentContent['type'] ) && 'repeater' === $fieldParentContent['type'] ) { return true; } } } elseif ( is_string( $acfFieldObject['parent'] ) ) { $fieldParent = get_field_object( $acfFieldObject['parent'], $postId ); if ( isset( $fieldParent['type'] ) && 'repeater' === $fieldParent['type'] ) { return true; } } } return false; }