Skip to content

Instantly share code, notes, and snippets.

@sftsk
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sftsk/60ab35f3cad9fe9c94aa to your computer and use it in GitHub Desktop.
Save sftsk/60ab35f3cad9fe9c94aa to your computer and use it in GitHub Desktop.
hacky trigger for wpml translation re-save
var saveTranslations = function (el) {
var popupId = '#' + el.attr('id').replace('-', '-popup-');
el.trigger('click');
jQuery(jQuery(popupId).find('.term-save')).trigger('click');
var waitForClose = window.setInterval(function () {
if (jQuery(popupId).text() === '') {
window.clearInterval(waitForClose);
var nextRow = jQuery('#' + el.attr('id')).closest('tr').next('tr');
if (nextRow.length > 0) {
console.log('next row');
saveTranslations(jQuery(jQuery(nextRow).find('td')[1]).find('a'));
} else {
console.log('at the end');
jQuery('#wpml-taxonomy-translation-terms-nav .next-page').trigger('click');
saveTranslations(jQuery(jQuery(jQuery('#wpml-taxonomy-translation-terms-table #tax-table-terms tbody').find('tr')[0]).find('td')[1]).find('a'));
}
}
}, 500);
}
// pass in the id of the first link
saveTranslations(jQuery('#422-it'));
@sftsk
Copy link
Author

sftsk commented Apr 29, 2015

For wpml woocommerce interface. Had to re-save all translations. This opens them one after another and clicks the save button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment