PHPackages                             mickey-kay/better-font-awesome-library - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mickey-kay/better-font-awesome-library

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mickey-kay/better-font-awesome-library
======================================

Better Font Awesome Library for WordPress

2.0.3(3y ago)371.8k13[6 PRs](https://github.com/MickeyKay/better-font-awesome-library/pulls)1GPL-2.0-or-laterPHP

Since Jun 3Pushed 3y ago3 watchersCompare

[ Source](https://github.com/MickeyKay/better-font-awesome-library)[ Packagist](https://packagist.org/packages/mickey-kay/better-font-awesome-library)[ RSS](/packages/mickey-kay-better-font-awesome-library/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)DependenciesVersions (30)Used By (1)

Better Font Awesome Library
===========================

[](#better-font-awesome-library)

*The easiest way to integrate Font Awesome into your WordPress project.*

Table of contents
-----------------

[](#table-of-contents)

1. [Introduction](https://github.com/MickeyKay/better-font-awesome-library#introduction)
2. [Features](https://github.com/MickeyKay/better-font-awesome-library#features)
3. [Installation](https://github.com/MickeyKay/better-font-awesome-library#installation)
4. [Usage](https://github.com/MickeyKay/better-font-awesome-library#usage)
5. [Initialization Parameters](https://github.com/MickeyKay/better-font-awesome-library#initialization-parameters-args)
6. [Shortcode](https://github.com/MickeyKay/better-font-awesome-library#shortcode)
7. [The Better Font Awesome Library Object](https://github.com/MickeyKay/better-font-awesome-library#the-better-font-awesome-library-object)
8. [Filters](https://github.com/MickeyKay/better-font-awesome-library#filters)
9. [To Do](https://github.com/MickeyKay/better-font-awesome-library#to-do)
10. [Credits](https://github.com/MickeyKay/better-font-awesome-library#credits)

Introduction
------------

[](#introduction)

The Better Font Awesome Library allows you to automatically integrate the latest available version of [Font Awesome](http://fontawesome.io/) into your WordPress project, along with accompanying CSS, shortcode, and TinyMCE icon shortcode generator. Furthermore, it generates all the data you need to create new functionality of your own.

Features
--------

[](#features)

- Automatically fetches the most recent available version of Font Awesome, meaning you no longer need to manually update the version included in your theme/plugin.
- Generates an easy-to-use [PHP object](#the-better-font-awesome-library-object) that contains all relevant info for the version of Font Awesome you're using, including: version, stylesheet URL, array of available icons, and prefix used (`icon` or `fa`).
- CDN speeds - Font Awesome CSS is pulled from the super-fast and reliable [jsDelivr CDN](http://www.jsdelivr.com/#!fontawesome).
- Includes a TinyMCE drop-down shortcode generator.
- Includes a local copy of Font Awesome to use as a fallback in case the remote fetch fails (or you can specify your own with the [`bfa_fallback_directory_path`](https://github.com/MickeyKay/better-font-awesome-library#bfa_fallback_directory_path) filter).
- Utilizes transients to optimize for speed and performance.

Installation
------------

[](#installation)

The Better Font Awesome Library should ideally be installed via Composer:

```
composer require mickey-kay/better-font-awesome-library

```

Alternately, you can install the library manually, which can be useful for development and/or custom builds:

```
git clone https://github.com/MickeyKay/better-font-awesome-library.git
cd better-font-awesome-library
npm run build

```

Usage
-----

[](#usage)

1. Copy the /better-font-awesome-library folder into your project.
2. Add the following code to your main plugin file or your theme's functions.php file.

```
add_action( 'init', 'my_prefix_load_bfa' );
    /**
    * Initialize the Better Font Awesome Library.
    *
    * (see usage notes below on proper hook priority)
    */
    function my_prefix_load_bfa() {

    // Include the main library file. Make sure to modify the path to match your directory structure.
    require_once ( dirname( __FILE__ ) . '/better-font-awesome-library/better-font-awesome-library.php' );

    // Set the library initialization args (defaults shown).
    $args = array(
      'include_v4_shim'     => false,
      'remove_existing_fa'  => false,
      'load_styles'         => true,
      'load_admin_styles'   => true,
      'load_shortcode'      => true,
      'load_tinymce_plugin' => true,
    );

    // Initialize the Better Font Awesome Library.
    Better_Font_Awesome_Library::get_instance( $args );
}
```

3. If desired, use the [Better Font Awesome Library object](#the-better-font-awesome-library-object) to manually include Font Awesome CSS, output lists of available icons, create your own shortcodes, and much more.

#### Usage Notes

[](#usage-notes)

The Better Font Awesome Library is designed to work in conjunction with the [Better Font Awesome](https://wordpress.org/plugins/better-font-awesome/) WordPress plugin. The plugin initializes this library (with its own initialization args) on the `init` hook, priority `5`. When using the Better Font Awesome Library in your project, you have two options:

1. Initialize later, to ensure that any Better Font Awesome plugin settings override yours (this is the default behavior, shown above by initializing the library on the `init` hook with default priority `10`.
2. Initialize earlier, to "take over" and prevent Better Font Awesome settings from having an effect.

Initialization Parameters ($args)
---------------------------------

[](#initialization-parameters-args)

The following arguments can be used to initialize the library using `Better_Font_Awesome_Library::get_instance( $args )`:

#### $args\['include\_v4\_shim'\]

[](#argsinclude_v4_shim)

(boolean) Include the [Font Awesome v4 shim CSS stylesheet](https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4) to support legacy icon.

- `true`
- `false` (default)

#### $args\['remove\_existing\_fa'\]

[](#argsremove_existing_fa)

(boolean) Attempts to remove existing Font Awesome styles and shortcodes. This can be useful to prevent conflicts with other themes/plugins, but is no guarantee.

- `true`
- `false` (default)

#### $args\['load\_styles'\]

[](#argsload_styles)

(boolean) Automatically loads Font Awesome CSS on the **front-end** of your site using `wp_enqueue_scripts()`.

- `true` (default)
- `false` - use this if you don't want to load the Font Awesome CSS on the front-end, or wish to do it yourself.

#### $args\['load\_admin\_styles'\]

[](#argsload_admin_styles)

(boolean) Automatically loads Font Awesome CSS on the **admin** of your site using `admin_enqueue_scripts()`.

- `true` (default)
- `false` - use this if you don't want to load the Font Awesome CSS in the admin, or wish to do it yourself.

#### $args\['load\_shortcode'\]

[](#argsload_shortcode)

(boolean) Loads the included `[icon]` [shortcode](https://github.com/MickeyKay/better-font-awesome-library#shortcode).

- `true` (default)
- `false`

#### load\_tinymce\_plugin

[](#load_tinymce_plugin)

(boolean) Loads a TinyMCE drop-down list of available icons (based on the active Font Awesome version), which generates an `[icon]` shortcode.

- `true` (default)
- `false`

### Deprecated

[](#deprecated)

#### $args\['version'\] (2.0.0)

[](#argsversion-200)

*The library now always defaults to the latest available version of Font Awesome.*

(string) Which version of Font Awesome you want to use.

- `'latest'` (default) - always use the latest available version.
- `'3.2.1'` - any existing Font Awesome version number.

#### $args\['minified'\] (2.0.0)

[](#argsminified-200)

*The library now always defaults to minified CSS.*

(boolean) Use minified Font Awesome CSS.

- `true` (default) - uses minifed CSS.
- `false` - uses unminified CSS.

Shortcode
---------

[](#shortcode)

If either the `$args['load_shortcode']` or `$args['load_tinymce_plugin']` initialization arg is set to `true`, then the Better Font Awesome Library will include an `[icon]` shortcode that can be used as follows:

```
[icon name="star" class="2x spin" unprefixed_class="my-custom-class"]

```

#### name

[](#name)

The unprefixed icon name (e.g. star). The version-specific prefix will be automatically prepended.

#### class

[](#class)

Unprefixed [Font Awesome icon classes](http://fortawesome.github.io/Font-Awesome/examples/). The version-specific prefix will be automatically prepended to each class.

#### unprefixed\_class

[](#unprefixed_class)

Any additional classes that you wish to remain unprefixed (e.g. my-custom-class).

#### style

[](#style)

The specific icon style (e.g. `brand` vs. `solid`) to use.

### Shortcode Output

[](#shortcode-output)

The following shortcode:

```
[icon name="moon" style="solid" class="2x spin" unprefixed_class="my-custom-class"]

```

. . . will produce the following HTML:

```

```

The Better Font Awesome Library Object
--------------------------------------

[](#the-better-font-awesome-library-object)

The Better Font Awesome Library object can be accessed with the following code: `Better_Font_Awesome_Library::get_instance();`

The object has the following public methods:

#### get\_version()

[](#get_version)

(string) Returns the active version of Font Awesome being used.

#### get\_stylesheet\_url()

[](#get_stylesheet_url)

(string) Returns the Font Awesome stylesheet URL.

#### get\_stylesheet\_url\_v4\_shim()

[](#get_stylesheet_url_v4_shim)

(string) Returns the Font Awesome v4 shim stylesheet URL.

#### get\_icons()

[](#get_icons)

(array) Returns an associative array of icon hex values (index, e.g. \\f000) and unprefixed icon names (values, e.g. rocket) for all available icons in the active Font Awesome version.

#### get\_release\_icons()

[](#get_release_icons)

(array) Returns icon data in the exact format provided by the Font Awesome GraphQL API.

#### get\_release\_assets()

[](#get_release_assets)

(array) Returns icon asset (CSS/JS) data for the latest Font Awesome version.

#### get\_prefix()

[](#get_prefix)

(string) Returns the version-dependent prefix ('fa' or 'icon') that is used in the icons' CSS classes.

#### get\_errors()

[](#get_errors)

(array) Returns all library errors, including API and CDN fetch failures.

### Deprecated

[](#deprecated-1)

#### get\_api\_data() (2.0.0)

[](#get_api_data-200)

*The library no longe relies on the jsDelivr CDN.*

(object) Returns version data for the remote jsDelivr CDN (uses [jsDelivr API](https://github.com/jsdelivr/api)). Includes all available versions and latest version.

### Example:

[](#example)

```
// Initialize the library with custom args.
Better_Font_Awesome_Library::get_instance( $args );

// Get the active Better Font Awesome Library Object.
$my_bfa = Better_Font_Awesome_Library::get_instance();

// Get info on the Better Font Awesome Library object.
$version = $my_bfa->get_version();
$stylesheet_url = $my_bfa->get_stylesheet_url();
$prefix = $my_bfa->get_prefix();
$icons = $my_bfa->get_icons();

// Output all available icons.
foreach ( $icons as $icon ) {
    echo $icon . '';
}
```

Filters
-------

[](#filters)

The Better Font Awesome Library applies the following filters:

#### bfa\_init\_args

[](#bfa_init_args)

Applied to the initialization arguments after they have been parsed with default args, but before they are used to fetch any Font Awesome data.

**Parameters**

- `$init_args` (array)

#### bfa\_wp\_remote\_get\_args

[](#bfa_wp_remote_get_args)

Applied to arguments passed to all `wp_remote_get()` calls (useful for adjusting the timeout if needed).

**Parameters**

- `$wp_remote_get_args` (array)

#### bfa\_fallback\_release\_data\_path

[](#bfa_fallback_release_data_path)

Applied to the path for the fallback release data JSON file. Can be used to specify an alternate fallback data file.

**Parameters**

- `$fallback_release_data_path` (string)

#### bfa\_release\_data\_transient\_expiration

[](#bfa_release_data_transient_expiration)

This value controls how often the plugin will check for the latest updated version of Font Awesome. Can be used to increase/decrease the frequency of this check as desired.

**Parameters**

- `$api_expiration` (int) (default: `WEEK_IN_SECONDS`)

#### bfa\_icon\_list

[](#bfa_icon_list)

Applied to the icon array after it has been generated from the Font Awesome stylesheet, and before it is assigned to the Better Font Awesome Library object's `$icons` property.

**Parameters**

- `$icons` (array)

#### bfa\_icon\_class

[](#bfa_icon_class)

Applied to the classes that are output on each icon's `` element.

**Parameters**

- `$class` (string)

#### bfa\_icon\_tag

[](#bfa_icon_tag)

Applied to the tag that is output for each icon. Defaults is 'i', which outputs ``.

**Parameters**

- `$tag` (string)

#### bfa\_icon

[](#bfa_icon)

Applied to the entire `` element that is output for each icon.

**Parameters**

- `$output` (string)

#### bfa\_show\_errors

[](#bfa_show_errors)

Applied to the boolean that determines whether or not to suppress all Font Awesome warnings that normally display in the admin.

**Parameters**

- `$show_errors` (true)

### Deprecated

[](#deprecated-2)

#### bfa\_fallback\_directory\_path

[](#bfa_fallback_directory_path)

*This is now replaced by the similar `bfa_fallback_release_data_path` filter.*Applied to the fallback directory path before setting up any fallback CSS info. Can be used to specify an alternate fallback directory to replace the default fallback directory.

*The path must be to a local, non-remote, directory.*

**Parameters**

- `$path` (string)

#### bfa\_api\_transient\_expiration (2.0.0)

[](#bfa_api_transient_expiration-200)

*This data now comes from the GraphQL API. The new `bfa_release_data_transient_expiration` replaces this legacy filter.*

Applied to the API (version information) transient [expiration](http://codex.wordpress.org/Transients_API#Using_Transients). Can be used to increase/decrease the expiration as desired.

**Parameters**

- `$api_expiration` (int)

#### bfa\_css\_transient\_expiration (2.0.0)

[](#bfa_css_transient_expiration-200)

*This data is now no longer necessary.*

Applied to the CSS stylesheet data transient [expiration](http://codex.wordpress.org/Transients_API#Using_Transients). Can be used to increase/decrease the expiration as desired.

**Parameters**

- `$css_expiration` (int)

#### bfa\_force\_fallback (2.0.0)

[](#bfa_force_fallback-200)

*There should no longer be a need to force a fallback.*

Applied to the boolean that determines whether or not to force the included fallback version of Font Awesome to load. This can be useful if you're having trouble with delays or timeouts.

**Parameters**

- `$force_fallback` (false)

#### bfa\_prefix (2.0.0)

[](#bfa_prefix-200)

*Given the update to v5+ always, there should be no need to modify the icon prefix.*

Applied to the Font Awesome prefix ('fa' or 'icon') before it is assigned to the Better Font Awesome Library object's `$prefix` property.

**Parameters**

- `$prefix` (string)

To Do
-----

[](#to-do)

Ideas? File an issue or add a pull request!

- Add README section on manually updating the fallback version.
- Remove existing FA? - move to later hook so that it works for styles enqueued via shortcode (= wp\_footer basically)

Credits
-------

[](#credits)

Special thanks to the following folks and their plugins for inspiration and support:

- [Font Awesome Icons](http://wordpress.org/plugins/font-awesome/ "Font Awesome Icons") by [Rachel Baker](http://rachelbaker.me/ "Rachel Baker")
- [Font Awesome More Icons](https://wordpress.org/plugins/font-awesome-more-icons/ "Font Awesome More Icons") by [Web Guys](http://webguysaz.com/ "Web Guys")
- [Font Awesome Shortcodes](https://wordpress.org/plugins/font-awesome-shortcodes/) by [FoolsRun](https://profiles.wordpress.org/foolsrun/ "FoolsRun")
- Dmitriy Akulov and the awesome folks at [jsDelivr](http://www.jsdelivr.com/)

And many thanks to the following folks who helped with testing and QA:

- [Jeffrey Dubinksy](http://vanishingforests.org/)
- [Neil Gee](https://twitter.com/_neilgee)
- [Michael Beil](https://twitter.com/MichaelBeil)
- [Rob Neue](https://twitter.com/rob_neu)
- [Gary Jones](https://twitter.com/GaryJ)
- [Jan Hoek](https://twitter.com/JanHoekdotCom)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 99.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~135 days

Recently: every ~166 days

Total

16

Last Release

1234d ago

Major Versions

v1.4.6 → v2.0.0-beta12018-04-09

1.4.7 → 2.0.0-beta52021-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/0995fb85aa1971a73670bfccd67ef9b3c6891d2aacce0b6bbbba17bbb063271c?d=identicon)[McGuive7](/maintainers/McGuive7)

---

Top Contributors

[![MickeyKay](https://avatars.githubusercontent.com/u/3189678?v=4)](https://github.com/MickeyKay "MickeyKay (241 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![HongPong](https://avatars.githubusercontent.com/u/114027?v=4)](https://github.com/HongPong "HongPong (1 commits)")

### Embed Badge

![Health badge](/badges/mickey-kay-better-font-awesome-library/health.svg)

```
[![Health](https://phpackages.com/badges/mickey-kay-better-font-awesome-library/health.svg)](https://phpackages.com/packages/mickey-kay-better-font-awesome-library)
```

###  Alternatives

[sylvainjule/kirby-multilist

Quickly manage lists with multiple fields in Kirby

542.1k](/packages/sylvainjule-kirby-multilist)[latrell/qqwry

纯真 IP 库 Laravel 版 。

274.7k](/packages/latrell-qqwry)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
