Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/images/menu-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion includes/Admin/class-admin-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function add_menus(): void
'escalated_ticket_view',
'escalated',
[new Admin_Tickets, 'render_list'],
'dashicons-tickets-alt',
self::menu_icon_data_uri(),
30
);

Expand All @@ -35,6 +35,23 @@ public function add_menus(): void
add_submenu_page('escalated', __('Settings', 'escalated'), __('Settings', 'escalated'), 'escalated_settings_view', 'escalated-settings', [new Admin_Settings, 'render']);
}

/**
* Inline-SVG data URI for the wp-admin sidebar menu icon. Using a
* data URI rather than a file URL keeps the icon working on
* installs that lock down the uploads dir from script access. The
* SVG uses `currentColor` so wp-admin's own CSS can swap it
* between active/inactive sidebar states without two assets.
*/
private static function menu_icon_data_uri(): string
{
$svg = file_get_contents(ESCALATED_PLUGIN_DIR.'assets/images/menu-icon.svg');
if ($svg === false) {
return 'dashicons-tickets-alt';
}

return 'data:image/svg+xml;base64,'.base64_encode($svg);
}

public function enqueue_assets(string $hook): void
{
// Only enqueue on Escalated pages
Expand Down
Loading