This thread is resolved. Here is a description of the problem and solution.
Problem:
You are experiencing a significant slowdown when saving content in French on your WordPress site using WPML with French as the secondary language and ACFML for managing custom fields translations. The issue disappears when the ACF Multilingual plugin is deactivated.
Solution:
We recommend modifying specific methods in the WPML plugin files to potentially resolve the performance issue. Here are the steps:
1. Navigate to
\wp-content\plugins\sitepress-multilingual-cms\sitepress.class.php
and modify the
copy_custom_fields
method as follows:
function copy_custom_fields( $post_id_from, $post_id_to ) {<br /> $custom_fields_to_copy = $this->get_custom_fields_translation_settings( WPML_COPY_CUSTOM_FIELD );<br /> $custom_fields_from = get_post_meta( $post_id_from );<br /> $custom_fields_to = get_post_meta( $post_id_to );<br /><br /> foreach ( $custom_fields_to_copy as $meta_key ) {<br /> if ( array_key_exists( $meta_key, $custom_fields_from ) ) {<br /> $meta_from = isset( $custom_fields_from[ $meta_key ] ) ? $custom_fields_from[ $meta_key ] : [];<br /> $meta_to = isset( $custom_fields_to[ $meta_key ] ) ? $custom_fields_to[ $meta_key ] : [];<br /><br /> if ( $meta_from || $meta_to ) {<br /> $this->sync_custom_field( $post_id_from, $post_id_to, $meta_key );<br /> }<br /> }<br /> }<br /><br /> $sync_deleted_fields = false;<br /> if ( apply_filters( 'wpml_sync_deleted_custom_fields', $sync_deleted_fields ) && $custom_fields_from && $custom_fields_to ) {<br /> $if_deleted_in_source_and_still_in_target = Logic::allPass([<br /> Obj::prop( Fns::__, $custom_fields_to ),<br /> pipe( Obj::prop( Fns::__, $custom_fields_from ), Logic::not() ),<br /> ]);<br /><br /> wpml_collect( $this->get_custom_fields_translation_settings( WPML_TRANSLATE_CUSTOM_FIELD ) )<br /> ->filter( $if_deleted_in_source_and_still_in_target )<br /> ->map(function ( $meta_key ) use ( $post_id_from, $post_id_to ) {<br /> $this->sync_custom_field( $post_id_from, $post_id_to, $meta_key );<br /> });<br /> }<br />}
2. Navigate to
\wp-content\plugins\sitepress-multilingual-cms\classes\custom-field-translation\class-wpml-copy-once-custom-field.php
and modify the
copy
method as follows:
public function copy( $post_id ) {<br /> $custom_fields_to_copy = $this->sitepress->get_custom_fields_translation_settings( WPML_COPY_ONCE_CUSTOM_FIELD );<br /> if ( empty( $custom_fields_to_copy ) ) {<br /> return;<br /> }<br /><br /> $source_element_id = $this->wpml_post_translation->get_original_element( $post_id );<br /> $custom_fields = get_post_meta( $post_id );<br /><br /> foreach ( $custom_fields_to_copy as $meta_key ) {<br /> if ( array_key_exists( $meta_key, $custom_fields ) ) {<br /> $values = isset( $custom_fields[ $meta_key ] )<br /> && ! empty( $custom_fields[ $meta_key ] )<br /> ? [ $custom_fields[ $meta_key ] ]<br /> : [];<br /><br /> $values = apply_filters(<br /> 'wpml_custom_field_values',<br /> $values,<br /> [<br /> 'post_id' => $post_id,<br /> 'meta_key' => $meta_key,<br /> 'custom_fields_translation' => WPML_COPY_ONCE_CUSTOM_FIELD,<br /> ]<br /> );<br /><br /> if ( empty( $values ) && $source_element_id ) {<br /> $this->sitepress->sync_custom_field( $source_element_id, $post_id, $meta_key );<br /> }<br /> }<br /> }<br />}
If this solution does not resolve your issue or seems irrelevant due to updates or different circumstances, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
This topic contains 7 replies, has 2 voices.
Last updated by 1 month, 3 weeks ago.
Assisted by: Dražen Duvnjak.