Skip to content

Commit

Permalink
Fix lesson translation for the course outline (#7496)
Browse files Browse the repository at this point in the history
* Fix an issue with using an object as array
* Update lesson relations for existing lessons as well
  • Loading branch information
merkushin authored Feb 22, 2024
1 parent b1fa0e6 commit 8ccec4d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions includes/wpml/class-sensei-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ public function update_lesson_properties_on_course_translation_created( $new_cou
if ( ! $is_translated ) {
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'wpml_admin_make_post_duplicates', $lesson_id );
}

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$translations = apply_filters( 'wpml_post_duplicates', $lesson_id );
foreach ( $translations as $translated_lesson_id ) {
$this->update_lesson_course( (int) $translated_lesson_id, $new_course_id );
$this->update_translated_lesson_taxonomies( (int) $translated_lesson_id, $lesson_id );
}
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$translations = apply_filters( 'wpml_post_duplicates', $lesson_id );
foreach ( $translations as $translated_lesson_id ) {
$this->update_lesson_course( (int) $translated_lesson_id, $new_course_id );
$this->update_translated_lesson_taxonomies( (int) $translated_lesson_id, $lesson_id );
}

// Sync lesson course field across translations.
Expand Down Expand Up @@ -348,6 +348,7 @@ private function update_translated_lesson_taxonomies( $new_lesson_id, $master_le
return;
}

$details = (array) $details;
if ( empty( $master_lesson_id ) ) {
if ( empty( $details['source_language_code'] ) ) {
return;
Expand Down

0 comments on commit 8ccec4d

Please sign in to comment.