wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_process_translation_update_selection › WordPress Function

Since7.2.0
Deprecatedn/a
› wp_process_translation_update_selection ( $translation_update_ids, $selected_translation_update_ids )
Parameters: (2)
  • (string[]) $translation_update_ids Sanitized identifiers of updates included in the form.
    Required: Yes
  • (string[]) $selected_translation_update_ids Sanitized identifiers of selected updates.
    Required: Yes
Returns:
  • (object[]|false) Selected current translation updates keyed by identifier, an empty array
    if all updates in the form were deferred, or false if the form contains
    no currently available updates. On false, stored deferrals are unchanged.
Defined at:
Codex:

Processes a translation update selection and stores the deferred updates.

Only currently available updates included in the submitted form can be selected or deferred. Previously deferred updates outside the form remain deferred, while newly available updates outside the form are left unchanged. The caller must check capabilities and the nonce before calling this function.


Source

function wp_process_translation_update_selection( $translation_update_ids, $selected_translation_update_ids ) {
	if ( empty( $translation_update_ids ) ) {
		return false;
	}

	$current_translation_updates = wp_get_translation_updates_by_id();
	$translation_updates         = array_intersect_key( $current_translation_updates, array_flip( $translation_update_ids ) );

	if ( empty( $translation_updates ) ) {
		return false;
	}

	$selected_translation_updates  = array_intersect_key( $translation_updates, array_flip( $selected_translation_update_ids ) );
	$deferred_translation_updates  = array_intersect_key(
		$current_translation_updates,
		wp_get_deferred_translation_updates()
	);
	$deferred_translation_updates  = array_diff_key( $deferred_translation_updates, $translation_updates );
	$deferred_translation_updates += array_diff_key( $translation_updates, $selected_translation_updates );

	wp_set_deferred_translation_updates( $deferred_translation_updates );

	return $selected_translation_updates;
}