Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/patrik-csak/fa-wp-admin-menu-icons. Font Awesome icons for WordPress custom post types and custom m wordpress.org/plugins/fa-wp-admin-menu-icons
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485<?php
namespace Fawpami;
use Exception;
require_once 'AdminNotices.php';require_once 'Icon.php';require_once 'Scripts.php';
class Hooks{ /** * Replace Font Awesome class string with icon SVG data URI * * @throws Exception */ public static function filterRegisterPostTypeArgs(array $args, string $name): array { if ( !isset($args['menu_icon']) || !$icon = Icon::fromClass($args['menu_icon']) ) { return $args; }
Scripts::registerPostType($name);
try { $args['menu_icon'] = $icon->getSvgDataUri(); } catch (Exception $exception) { if (defined('WP_DEBUG') && WP_DEBUG) { throw $exception; }
AdminNotices::add($exception->getMessage(), 'error');
try { $args['menu_icon'] = Icon ::fromClass('fa-solid fa-triangle-exclamation') ->getSvgDataUri(); } catch (Exception $exception) { AdminNotices::add($exception->getMessage(), 'error'); } }
return $args; }
/** * Replace Font Awesome class string with icon SVG data URI * * @throws Exception */ public static function filterSetUrlScheme(string $url): string { if (!$icon = Icon::fromClass($url)) { return $url; }
// The most recently registered menu page should be this one global $admin_page_hooks; Scripts::registerMenuPage(array_key_last($admin_page_hooks));
try { return $icon->getSvgDataUri(); } catch (Exception $exception) { if (defined('WP_DEBUG') && WP_DEBUG) { throw $exception; }
AdminNotices::add($exception->getMessage(), 'error');
try { return Icon::fromClass('fa-solid fa-triangle-exclamation') ->getSvgDataUri(); } catch (Exception $exception) { AdminNotices::add($exception->getMessage(), 'error');
return $url; } } }}