Skip to content

Instantly share code, notes, and snippets.

@alpipego
Last active December 13, 2019 20:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alpipego/ffae1dbbb7e0a84f02d35a321b7149ae to your computer and use it in GitHub Desktop.
Save alpipego/ffae1dbbb7e0a84f02d35a321b7149ae to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: alpipego
* Date: 03.05.18
* Time: 18:01
*/
//return;
add_filter('ACFFA_get_icons', function (array $icons) : array {
$findIcons = function ($manifest) {
$loader = new ACFFA_Loader_5();
$icons = [
'list' => [],
'details' => [],
];
foreach ($manifest as $icon => $details) {
if (isset($details['styles'])) {
foreach ($details['styles'] as $style) {
$prefix = apply_filters('ACFFA_icon_prefix', [$loader, 'get_prefix'], $style);
if ($prefix === 'fal' && $icon === 'heartbeat') {
}
if ( ! isset($icons['list'][$prefix])) {
$icons['list'][$prefix] = [];
}
$icons['list'][$prefix][$prefix . ' fa-' . $icon] = '<i class="' . $prefix . '">&#x' . $details['unicode'] . ';</i> ' . $icon;
$icons['details'][$prefix][$prefix . ' fa-' . $icon] = [
'hex' => '\\' . $details['unicode'],
'unicode' => '&#x' . $details['unicode'] . ';',
];
}
}
}
return $icons;
};
require_once WP_PLUGIN_DIR . '/advanced-custom-fields-font-awesome/assets/inc/spyc/spyc.php';
$parsed_icons = spyc_load(file_get_contents(__DIR__ . '/icons.yml'));
if (is_array($parsed_icons) && ! empty($parsed_icons)) {
$icons = $findIcons($parsed_icons);
if ( ! empty($icons['details'])) {
$fa_icons = [
'5.0.12-pro' => $icons,
];
update_option('ACFFA_icon_data', $fa_icons, true);
return $icons;
}
}
return $icons;
});
add_action('admin_head', function () {
echo '<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.0.12/css/all.css" integrity="XXXX" crossorigin="anonymous">';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment