For Developers

Font Hero provides a REST API and integrates with standard WordPress hooks. If you’re building a theme, plugin, or custom integration, here’s what’s available.

REST API

All endpoints live under the font-hero/v1 namespace and require the manage_options capability (WordPress administrators only).

Fonts

MethodEndpointDescription
GET/font-hero/v1/fontsList all fonts with their font faces
POST/font-hero/v1/fontsCreate a new font
DELETE/font-hero/v1/fonts/{id}Delete a font and its files
PATCH/font-hero/v1/fonts/{id}/toggleEnable or disable a font
PATCH/font-hero/v1/fonts/{id}/renameRename a font
POST/font-hero/v1/fonts/reorderUpdate font sort order
POST/font-hero/v1/fonts/saveBulk save all font faces (transactional)
POST/font-hero/v1/fonts/uploadUpload a font file

Font Faces

MethodEndpointDescription
POST/font-hero/v1/fonts/{id}/facesAdd a font face to a font
PUT/font-hero/v1/font-faces/{id}Update a font face
DELETE/font-hero/v1/font-faces/{id}Delete a font face
PATCH/font-hero/v1/font-faces/{id}/toggleEnable or disable a font face

Settings

MethodEndpointDescription
GET/font-hero/v1/settingsGet all plugin settings (plus capability flags such as hasElementor)
POST/font-hero/v1/settingsSave settings

Font Stacks

MethodEndpointDescription
GET/font-hero/v1/font-stacksGet all font stacks
POST/font-hero/v1/font-stacksSave font stacks

Google Fonts

MethodEndpointDescription
GET/font-hero/v1/google-fonts-listGet the full Google Fonts catalog
POST/font-hero/v1/google-fonts/importImport a Google Font

Adobe Fonts (Typekit)

MethodEndpointDescription
POST/font-hero/v1/typekit/fetchFetch fonts from a Typekit project
POST/font-hero/v1/typekit/importImport selected Typekit fonts

Font Pairing

MethodEndpointDescription
POST/font-hero/v1/font-pairing/importImport a font pairing set

External Font Sources

MethodEndpointDescription
GET/font-hero/v1/gutenberg-fontsList fonts from block themes / WordPress Font Library
GET/font-hero/v1/bricks-fontsList fonts from Bricks Builder
GET/font-hero/v1/oxygen-fontsList fonts from Oxygen Builder

Migration

MethodEndpointDescription
POST/font-hero/v1/migration/runMigrate fonts from Swiss Knife Pro

License

MethodEndpointDescription
POST/font-hero/v1/license/activateActivate an EDD license key
POST/font-hero/v1/license/deactivateDeactivate the current license

API Authentication

All endpoints use WordPress cookie authentication via the REST API nonce. When making requests from JavaScript within the WordPress admin, use @wordpress/api-fetch which handles authentication automatically:

import apiFetch from '@wordpress/api-fetch';

// Get all fonts
const fonts = await apiFetch({ path: '/font-hero/v1/fonts' });

// Toggle a font
await apiFetch({
    path: '/font-hero/v1/fonts/42/toggle',
    method: 'PATCH',
});

For external requests, pass the X-WP-Nonce header with a valid nonce.

WordPress Hooks

Font Hero uses standard WordPress hooks. You can interact with Font Hero’s behavior by hooking into these.

Frontend Font Loading

Font Hero registers its frontend CSS on the wp_enqueue_scripts action. To add styles that depend on Font Hero’s fonts:

add_action('wp_enqueue_scripts', function () {
    // Your styles that depend on Font Hero fonts
    wp_enqueue_style('my-font-styles', '...', ['font-hero-custom-fonts']);
}, 20);

Disable Google Fonts Programmatically

If you want to ensure Google Fonts are blocked regardless of the setting:

add_action(‘wp_enqueue_scripts’, function () { wp_dequeue_style(‘google-fonts’); }, 100);

Working with Font Hero Data

Font Hero stores its data in two custom database tables and several WordPress options:

Options:

  • fh_font_stacks — JSON array of font stacks
  • fh_inline_fontsfh_in_adminfh_system_fonts — Loading toggles
  • fh_disable_gfontsfh_disable_elem_fonts — Google Fonts toggles
  • fh_override — Disable block theme fonts toggle
  • fh_typekit_idfh_typekit_fonts — Adobe Fonts project data/cache
  • DP_FH_license_status — License status (valid or empty)

Helper class:

use FontHero\Helpers\FontUtils;

// Get all enabled fonts
$fonts = FontUtils::getEnabledFonts();

// Get font faces grouped by font ID
$faces = FontUtils::getEnabledFacesByFont();

Constants

Font Hero defines these PHP constants you can reference:

ConstantDescription
DP_FH_DIRPlugin directory path
DP_FH_URLPlugin directory URL
DP_FH_PLUGINVERSIONCurrent plugin version
DP_FH_UPDATERMain plugin file path (used by updater logic)
DPLUGINS_FH_ADMIN_SLUGAdmin page slug (dp_font_hero)

Generated CSS File

Font Hero generates a CSS file at:

/wp-content/uploads/font-hero/font-hero.css

This file is regenerated whenever fonts are saved. It contains:

  • @font-face declarations for all enabled fonts
  • CSS custom properties (:root variables) for each font and font stack
  • Optional CSS selector rules for fonts with assigned selectors

CSS Custom Properties

Font Hero generates CSS variables for each font and font stack:

:root {
    --fh-montserrat: 'Montserrat';
    --fh-heading-stack: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

You can use these variables in your own CSS:

.my-element {
    font-family: var(--fh-montserrat);
}

Building a Custom Integration

If you’re building a theme or plugin that needs to register Font Hero’s fonts in a custom font picker, follow this pattern:

add_action('init', function () {
    if (!class_exists('FontHero\Helpers\FontUtils')) {
        return; // Font Hero not active
    }

    $fonts = \FontHero\Helpers\FontUtils::getEnabledFonts();
    $faces = \FontHero\Helpers\FontUtils::getEnabledFacesByFont();

    foreach ($fonts as $font) {
        $fontFaces = $faces[$font->id] ?? [];
        $weights = array_column($fontFaces, 'font_weight');

        // Register with your font picker
        my_register_font($font->font_name, $weights);
    }
});

This gives you access to all enabled fonts and their available weights/styles.