ADVANCED

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/fonts`List all fonts with their font faces
`POST``/font-hero/v1/fonts`Create a new font
`DELETE``/font-hero/v1/fonts/{id}`Delete a font and its files
`PATCH``/font-hero/v1/fonts/{id}/toggle`Enable or disable a font
`PATCH``/font-hero/v1/fonts/{id}/rename`Rename a font
`POST``/font-hero/v1/fonts/reorder`Update font sort order
`POST``/font-hero/v1/fonts/save`Bulk save all font faces (transactional)
`POST``/font-hero/v1/fonts/upload`Upload a font file

Font Faces

MethodEndpointDescription
`POST``/font-hero/v1/fonts/{id}/faces`Add 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}/toggle`Enable or disable a font face

Settings

MethodEndpointDescription
`GET``/font-hero/v1/settings`Get all plugin settings (plus capability flags such as `hasElementor`)
`POST``/font-hero/v1/settings`Save settings

Font Stacks

MethodEndpointDescription
`GET``/font-hero/v1/font-stacks`Get all font stacks
`POST``/font-hero/v1/font-stacks`Save font stacks

Google Fonts

MethodEndpointDescription
`GET``/font-hero/v1/google-fonts-list`Get the full Google Fonts catalog
`POST``/font-hero/v1/google-fonts/import`Import a Google Font

Adobe Fonts (Typekit)

MethodEndpointDescription
`POST``/font-hero/v1/typekit/fetch`Fetch fonts from a Typekit project
`POST``/font-hero/v1/typekit/import`Import selected Typekit fonts

Font Pairing

MethodEndpointDescription
`POST``/font-hero/v1/font-pairing/import`Import a font pairing set

External Font Sources

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

Migration

MethodEndpointDescription
`POST``/font-hero/v1/migration/run`Migrate fonts from Swiss Knife Pro

License

MethodEndpointDescription
`POST``/font-hero/v1/license/activate`Activate an EDD license key
`POST``/font-hero/v1/license/deactivate`Deactivate 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_fonts, fh_in_admin, fh_system_fonts — Loading toggles
  • fh_disable_gfonts, fh_disable_elem_fonts — Google Fonts toggles
  • fh_override — Disable block theme fonts toggle
  • fh_typekit_id, fh_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_DIR`Plugin directory path
`DP_FH_URL`Plugin directory URL
`DP_FH_PLUGINVERSION`Current plugin version
`DP_FH_UPDATER`Main plugin file path (used by updater logic)
`DPLUGINS_FH_ADMIN_SLUG`Admin 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.