Version: 3.0.0 Requires WordPress: 5.6+ Requires PHP: 7.4+ License: GPLv2 or later Author: MENJ Plugin URI: https://github.com/menj/auto-justify-content
Professional typography toolkit for WordPress. Automatic text justification and decorative drop caps for posts, pages, and Elementor content.
| Requirement | Minimum |
|---|---|
| WordPress | 5.6 |
| PHP | 7.4 |
| MySQL | 5.6 / MariaDB 10.1 |
PHP 7.4 is required for typed class properties (private array, private const) used throughout the plugin class.
- Download the
.zipfrom the releases page. - Go to Plugins β Add New β Upload Plugin.
- Upload the
.zipand click Install Now. - Activate the plugin.
- Configure at Settings β Auto Justify.
- Extract the zip and upload the
auto-justify-content/folder to/wp-content/plugins/. - Activate from Plugins β Installed Plugins.
wp plugin install auto-justify-content --activateauto-justify-content/
βββ auto-justify-content.php # Main plugin class (AutoJustifyContent)
βββ uninstall.php # Cleans up all DB options on uninstall
βββ readme.txt # WordPress.org repository readme
βββ README.md # This file β technical documentation
βββ CHANGELOG.md # Full version history
βββ UPGRADING.md # Upgrade notes and future roadmap
βββ assets/
β βββ css/admin.css # Settings page styles (includes colour picker overrides)
β βββ js/admin.js # Settings page interactions and live preview
βββ templates/
β βββ settings-page.php # Settings page HTML template
βββ languages/
βββ auto-justify-content.pot # Translation template
All options are stored in the WordPress wp_options table. No custom tables are created.
| Option Key | Type | Default | Description |
|---|---|---|---|
ajc_enabled |
boolean | true |
Master justification on/off toggle |
ajc_scope |
string | blog_only |
blog_only or entire_site |
ajc_hyphen |
boolean | true |
Enable CSS hyphenation |
ajc_mobile |
boolean | false |
Wrap justification in @media (min-width: 768px) |
ajc_fallback |
boolean | false |
Add article p/li fallback selectors |
ajc_exclude |
string | .elementor-testimonial |
Comma-separated CSS selectors excluded from all typography features |
| Option Key | Type | Default | Description |
|---|---|---|---|
ajc_dc_enabled |
boolean | false |
Master drop cap on/off toggle |
ajc_dc_style |
string | drop |
drop (descends) or raised (sits on baseline) |
ajc_dc_lines |
integer | 3 |
Line span: 2, 3, or 4 |
ajc_dc_mobile |
boolean | false |
Wrap drop cap in @media (min-width: 768px) |
ajc_dc_font |
string | playfair |
Font key from get_drop_cap_fonts() registry |
ajc_dc_custom_font |
string | '' |
Raw CSS font-family value when ajc_dc_font is custom |
ajc_dc_color |
string | #1e293b |
Hex colour for the drop cap letter |
All 13 options are removed cleanly on plugin uninstall via uninstall.php.
The plugin uses wp_add_inline_style() throughout β no external stylesheets are loaded by the plugin itself. CSS is generated in PHP and injected inline on each page load.
Enqueued when ajc_enabled is true and the current page matches the configured scope. blog_only fires only on is_singular('post').
Core selectors (always):
.entry-content p, .entry-content li,
.wp-block-post-content p, .wp-block-post-content li,
.elementor-widget-text-editor p, .elementor-widget-text-editor li,
.elementor-widget-theme-post-content p, .elementor-widget-theme-post-content liWith ajc_fallback enabled, additionally:
article p, article liWith ajc_hyphen enabled:
-webkit-hyphens: auto; -ms-hyphens: auto; hyphens: auto; overflow-wrap: break-word;With ajc_mobile enabled, all CSS is wrapped in:
@media (min-width: 768px) { ... }Enqueued when ajc_dc_enabled is true, subject to the same scope rules as justification.
Targets ::first-letter on the first paragraph in standard WordPress content wrappers, plus a .ajc-drop-cap class used by the [dropcap] shortcode:
.entry-content > p:first-of-type::first-letter,
.wp-block-post-content > p:first-of-type::first-letter,
... { font-family: ...; font-size: ...; color: ...; float: left; ... }
span.ajc-drop-cap { /* same rules, for shortcode use */ }Font sizes by line span: 2 lines β 2.8em, 3 lines β 4.0em, 4 lines β 5.4em.
Drop style uses line-height: 0.83, raised style uses line-height: 1.0.
When a Google Font is selected, the plugin enqueues it on the frontend via:
wp_enqueue_style( 'ajc-dropcap-font', 'https://fonts.googleapis.com/css2?family=...' );Only the selected font is loaded. If inherit or custom is selected, no external request is made.
The ajc_exclude option applies to both justification and drop caps. Each excluded selector receives:
{selector}, {selector} p, {selector} li {
text-align: inherit !important;
hyphens: manual !important;
}[dropcap]Word[/dropcap]
Wraps the first character of the enclosed text in <span class="ajc-drop-cap">. Works in the Classic Editor, text widgets, and anywhere WordPress shortcodes are processed.
The shortcode applies drop cap styling whether or not ajc_dc_enabled is on. If drop caps are disabled globally, a minimal inline style is output so the shortcode still renders visibly.
Filters the curated font registry before it is used anywhere (settings page dropdown, CSS generation, admin JS data). Use this to add custom fonts or build add-on font packs.
add_filter( 'ajc_drop_cap_fonts', function( array $fonts ): array {
$fonts['my_font'] = [
'label' => 'My Custom Font',
'google' => null, // null = no Google Fonts request
'stack' => '"My Custom Font", serif',
];
return $fonts;
} );To add a Google Font:
$fonts['eb_garamond'] = [
'label' => 'EB Garamond',
'google' => 'EB+Garamond:wght@700', // passed directly to the Google Fonts API URL
'stack' => '"EB Garamond", Georgia, serif',
];When a Google-hosted font is selected, the plugin hooks add_google_fonts_preconnect() into wp_resource_hints at priority 10. This injects <link rel="preconnect"> hints for fonts.googleapis.com and fonts.gstatic.com, overlapping DNS/TLS connection time with HTML parsing. Reduces first-visit font latency by 100β300ms (LCP improvement).
When a Google-hosted font is selected, output_google_font_link() is hooked to wp_head at priority 1. It outputs a non-blocking preload tag:
<link rel="preload" href="https://fonts.googleapis.com/css2?family=...&display=optional"
as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="..."></noscript>The font is fetched at high priority without blocking the critical rendering path. display=optional is used instead of display=swap to prevent the layout shift a large decorative cap causes when swapping fonts at 3β5em (CLS improvement).
| Asset | WordPress Dependency |
|---|---|
ajc-admin (CSS) |
wp-color-picker |
ajc-admin (JS) |
wp-color-picker, jQuery (implicit) |
The admin JS receives current settings and the font registry via wp_localize_script:
ajcData = {
fonts: { /* font registry object, keyed by font slug */ },
currentFont: 'playfair',
currentColor: '#1e293b',
currentLines: 3,
currentStyle: 'drop',
customFont: ''
}This data drives the live preview on the Drop Cap settings tab.
- Text domain:
auto-justify-content .potfile:languages/auto-justify-content.pot- Loaded via
load_plugin_textdomain()on theinitaction
To regenerate the .pot file:
wp i18n make-pot . languages/auto-justify-content.potTargets WordPress Coding Standards:
!defined('ABSPATH')guard at top of every PHP fileesc_url(),esc_attr(),esc_html(),sanitize_hex_color(),sanitize_text_field()used throughout- All settings registered via
register_setting()with explicitsanitize_callback - Admin assets scoped to
settings_page_auto-justify-contenthook only - No direct DB queries β all data via WordPress options API
composer require --dev wp-coding-standards/wpcs
./vendor/bin/phpcs --standard=WordPress auto-justify-content.phpOpen an issue at: https://github.com/menj/auto-justify-content/issues