Syllable Hyphenator WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA
Server-side hyphenation for WordPress with Syllable library.
Install
Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/joppuyo/syllable-hyphenator/releases/download/v1.1.0/syllable-hyphenator.zip
Server-side hyphenation for WordPress with Syllable library. It works by inserting ­ or "soft hyphen" characters to your strings so browsers will hyphenate the words correctly for you.
Compatiblity
- PHP 7 +
- WordPress 5.0 +
- (Optional) Timber 1.10.0 +
- (Optional) Polylang
Installation
- Download latest version on the Releases page.
- Upload plugin on the WordPress plugin admin page.
- Activate plugin.
- See section below on how to use the plugin in your theme
Usage
You can use the syllable_hyphenate WordPress filter to hyphenate text.
echo '<h1>' . apply_filters('syllable_hyphenate', get_the_title($post)) . '</h1>';
If you are using Timber, you can also use the hyphenate Twig filter,
<h1>{{ post.title | hyphenate }}</h1>
You can use the syllable_hyphenate_html filter to hyphenate a HTML string. For example, let's say you want to hyphenate output of Heading Gutenberg blocks. You can do it with the following code:
add_filter('render_block', function ($content, $block) {
if ($block['blockName'] === 'core/heading') {
$content = apply_filters('syllable_hyphenate_html', $content);
}
return $content;
}, 10, 2);
Filters
Minimum word length
syllable_hyphenator_min_word_length
By default, minimum word length for hyphenation is set to 12 characters. This prevents awkward hyphenation of very short words.
add_filter('syllable_hyphenator_min_word_length', function () {
return 6;
});
WordPress locale
syllable_hyphenator_wp_locale
Language used for hyphenation. By default this is the language specified in the WordPress settings page. This can be overridden using this filter. The locale should be in WordPress locale format, for example en_US.
add_filter('syllable_hyphenator_wp_locale', function () {
return 'en_US';
});
Current language
syllable_hyphenator_current_locale
This overrides the WordPress language. This is useful if you have different language content on your site. If Polylang is installed, the current Polylang post language will be used. Return value should be in Syllable library format, for example en-us.
add_filter('syllable_hyphenator_current_locale', function () {
return 'en-us';
});Releases
5 releases. Each count is every asset in that release; expand a row for the breakdown.
Active-site estimate ≈10 comes from the median of recent superseded releases. Method.