Last active
December 19, 2019 10:48
-
-
Save robstoll/e446eaae27759c51eb0626ada64d4a87 to your computer and use it in GitHub Desktop.
update translations for worpress
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 wpblocks = wp.data.select('core/block-editor').getBlocks(); a.split('\n').map(x => x.split(';')).filter(x => x[0]!='').forEach(x => { | |
var blocks = wpblocks.filter(y => y.attributes.content != null && y.attributes.content.replace(/\n/g, ' ') == x[0]); | |
if (blocks.length > 1) { | |
console.error("zu viele", blocks); | |
} else if(blocks.length == 1) { | |
wp.data.dispatch('core/block-editor').updateBlockAttributes(blocks[0].clientId, {'content': x[1] }) | |
} else if(wp.data.select('core/editor').getEditedPostAttribute('title') == x[0]) { | |
wp.data.dispatch('core/editor').editPost({ title: x[1] }) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment