diff --git a/readme.txt b/readme.txt index 5d462469d..49f4bcb57 100644 --- a/readme.txt +++ b/readme.txt @@ -145,6 +145,7 @@ You can view (and contribute) translations via the [Transifex project here](http * Fix - 4.3 issue showing "Description is a required field" due to editor field. * Tweak - Default job_manager_delete_expired_jobs to false. Set to true to have expired jobs deleted automatically. More sensible default. * Tweak - job_manager_term_select_field_wp_dropdown_categories_args filter. +* Tweak - Ajax WPML handling. = 1.23.6 = * Fix - job_manager_ajax_filters -> job_manager_ajax_file_upload in file upload script. diff --git a/wp-job-manager-functions.php b/wp-job-manager-functions.php index b61b7b9d8..48c363e7a 100644 --- a/wp-job-manager-functions.php +++ b/wp-job-manager-functions.php @@ -118,7 +118,7 @@ function get_job_listings( $args = array() ) { $query_args = apply_filters( 'get_job_listings_query_args', $query_args, $args ); // Generate hash - $to_hash = defined( 'ICL_LANGUAGE_CODE' ) ? json_encode( $query_args ) . ICL_LANGUAGE_CODE : json_encode( $query_args ); + $to_hash = json_encode( $query_args ) . apply_filters( 'wpml_current_language', '' ); $query_args_hash = 'jm_' . md5( $to_hash ) . WP_Job_Manager_Cache_Helper::get_transient_version( 'get_job_listings' ); do_action( 'before_get_job_listings', $query_args, $args ); @@ -701,3 +701,16 @@ function calculate_job_expiry( $job_id ) { return ''; } + +/** + * Set the current language of the ajax request + * @param string $lang + * @return string + */ +function job_manager_set_ajax_language( $lang ) { + if ( ( strstr( $_SERVER['REQUEST_URI'], '/jm-ajax/' ) || ! empty( $_GET['jm-ajax'] ) ) && isset( $_POST['lang'] ) ) { + $lang = sanitize_text_field( $_POST['lang'] ); + } + return $lang; +} +add_filter( 'icl_current_language', 'job_manager_set_ajax_language' );