Home

Hyphenopoly js to WordPress site

Download files and add them to your child theme folder. This example, they are in js/hyp folder.
Hyphenopoly in Git

Add following code to theme functions.php file. ICL_LANGUAGE_CODE is WPML plugins language global variable. This is used to put right config in place.
In classnames part of config you haw to tell some classes that use hyphenation. Without this all tags that inglude .hyphenate class are hyphenated.

function hyphenopoly_loader(){
	?>
	<script>      
			if(window.self === window.top) {
				var Hyphenopoly = {
					require: {
						<?php if(ICL_LANGUAGE_CODE === "fi") : ?>
						"fi": "Supercalifragilisticexpialidocious"
						<?php else : ?>
						"en-US": "Supercalifragilisticexpialidocious"
						<?php endif; ?>
					},
					paths: {
						patterndir: "<?php echo get_stylesheet_directory_uri(); ?>/js/hyp/patterns/",
						maindir: "<?php echo get_stylesheet_directory_uri(); ?>/js/hyp/"
					},
					setup: {
						classnames: {
							"entry-header": {},
							"site-content": {}
						}
					}
				};      
			}
	</script>
	<script src="<?php echo get_stylesheet_directory_uri(); ?>/js/hyp/Hyphenopoly_Loader.js"></script>
	<?php
}
add_action('wp_head', 'hyphenopoly_loader');

One comment on “Hyphenopoly js to WordPress site”

Leave a Reply

Your email address will not be published.