How to Add Codebox Button to Admin Bar with wpcodebox,
- create a PHP snippet
- run snippet on page load
- insert at admin_head
The snippet checks if logged in and only runs if true
How to Add Codebox Button to Admin Bar with wpcodebox,
The snippet checks if logged in and only runs if true
//a little button to open codebox editor | |
function add_wpcodebox_link_to_admin_bar($wp_admin_bar) | |
{ | |
if (is_user_logged_in()) { | |
$args = [ | |
"id" => "wpcodebox-link", | |
"title" => | |
'<img src="' . | |
esc_url(site_url("wp-content/plugins/wpcodebox2//logo.svg")) . | |
'" alt="WPCodeBox Logo" style="width: 20px; height: 20px; padding-top: 5px; display="block">', | |
"href" => site_url("/wp-admin/admin.php?page=wpcodebox2"), | |
"meta" => [ | |
"class" => "wpcodebox-link", | |
"title" => "Open WPCodeBox", | |
], | |
]; | |
$wp_admin_bar->add_node($args); | |
} | |
} | |
add_action("admin_bar_menu", "add_wpcodebox_link_to_admin_bar", 999); |