-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle-wp-admin-bar.php
More file actions
28 lines (26 loc) · 952 Bytes
/
toggle-wp-admin-bar.php
File metadata and controls
28 lines (26 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/*
Plugin Name: Toggle WP Admin Bar
Plugin URI: http://watch.this/space
Description: Hide the pesky WP Admin Bar with Ctrl+Shift+L. Show it again if you really, really want.
Author: DM Seaton
Version: 1.0.0
Author URI: http://bigspring.co.uk
*/
if (!function_exists('twpab_load_script')) {
add_action('wp_enqueue_scripts', 'twpab_load_script');
function twpab_load_script() {
if (is_user_logged_in() && is_admin_bar_showing()) {
$css = '<style>' . twpab_get_css() . '</style>';
wp_register_script('toggle-wp-admin-bar-js', plugins_url('assets/main.js', __FILE__), array('jquery'), false, true);
wp_localize_script('toggle-wp-admin-bar-js', 'css', $css);
wp_enqueue_script('toggle-wp-admin-bar-js');
}
}
}
if (!function_exists('twpab_get_css')) {
function twpab_get_css()
{
return file_get_contents(plugin_dir_path(__FILE__).'assets/main.css');
}
}