WPML_Integration::localize_autogenerated_series( bool $updated, int $post_id )

Sets the correct language details for auto-generated Series following their creation.


Parameters

$updated

(bool) (Required) Whether the Event custom tables data was updated correctly or not.

$post_id

(int) (Required) The ID of the Event post.


Top ↑

Return

(bool) Whether the Event custom tables data was updated correctly or not.


Top ↑

Source

File: src/Events_Pro/Custom_Tables/V1/Integrations/WPML/WPML_Integration.php

	public function localize_autogenerated_series( $updated, $post_id ) {
		if ( ! is_numeric( $post_id ) ) {
			return $updated;
		}

		$series_post_type = Post_Type::POSTTYPE;
		$post             = get_post( $post_id );

		if ( ! ( $post instanceof WP_Post && $post->post_type === TEC::POSTTYPE ) ) {
			return $updated;
		}

		$series = Series_Relationship::where( 'event_post_id', $post_id )->first();

		if ( ! $series instanceof Series_Relationship ) {
			return $updated;
		}

		$is_autogenerated = tribe_is_truthy(
			get_post_meta( $series->series_post_id, Autogenerated_Series::FLAG_META_KEY, true )
		);

		if ( ! $is_autogenerated ) {
			return $updated;
		}

		$language_details = apply_filters( 'wpml_post_language_details', null, $post->ID );

		if ( ! is_array( $language_details ) || empty ( $language_details ) ) {
			do_action( 'tribe_log', 'error', __CLASS__, [
				'message'        => 'WPML event language details not found',
				'event_post_id'  => $post->ID,
				'series_post_id' => $series->series_post_id,
			] );

			return $updated;
		}
		$language_details['element_id']   = $series->series_post_id;
		$language_details['element_type'] = 'post_' . $series_post_type;
		// There is not one yet, create a new translation.
		$language_details['trid'] = false;

		do_action( 'wpml_set_element_language_details', $language_details );

		return $updated;
	}

Top ↑

Changelog

Changelog
Version Description
6.0.11 Introduced.