ACF_WPML_Compatibility::verify_ajaxpublicACF 5.2.3

verify_ajax

Sets the correct language during AJAX requests.

Method of the class: ACF_WPML_Compatibility{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ACF_WPML_Compatibility = new ACF_WPML_Compatibility();
$ACF_WPML_Compatibility->verify_ajax();

Changelog

Since 5.2.3 Introduced.

ACF_WPML_Compatibility::verify_ajax() code ACF 6.0.4

function verify_ajax() {

	// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere.
	// set the language for this AJAX request
	// this will allow get_posts to work as expected (load posts from the correct language)
	if ( isset( $_REQUEST['lang'] ) ) {
		global $sitepress;
		$sitepress->switch_lang( sanitize_text_field( $_REQUEST['lang'] ) );
	}
	// phpcs:enable WordPress.Security.NonceVerification.Recommended
}