Last active
August 29, 2015 14:20
-
-
Save sftsk/60ab35f3cad9fe9c94aa to your computer and use it in GitHub Desktop.
hacky trigger for wpml translation re-save
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For wpml woocommerce interface. Had to re-save all translations. This opens them one after another and clicks the save button.