Skip to content

Commit

Permalink
Tweak - Ajax WPML handling.
Browse files Browse the repository at this point in the history
Closes #498
  • Loading branch information
mikejolley committed Aug 19, 2015
1 parent b3757fd commit 57fc30b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions readme.txt
Expand Up @@ -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.
Expand Down
15 changes: 14 additions & 1 deletion wp-job-manager-functions.php
Expand Up @@ -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 );
Expand Down Expand Up @@ -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' );

0 comments on commit 57fc30b

Please sign in to comment.