Last active
May 18, 2021 03:36
-
-
Save westcoastdigital/386c918c5f2dd33f3874f26e24430278 to your computer and use it in GitHub Desktop.
Adds back customizer link to Appearance in admin and admin bar when using the Full Site Editing in Gutenberg due out in WP 5.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WCD Add Customizer Back | |
*/ | |
function wcd_add_customizer_back() | |
{ | |
if (!gutenberg_is_fse_theme()) { | |
return; | |
} | |
if (is_admin() || current_user_can('edit_theme_options')): | |
global $submenu; | |
$customize_url = add_query_arg( | |
'return', | |
urlencode(wp_unslash($_SERVER['REQUEST_URI'])), | |
'customize.php' | |
); | |
add_submenu_page( | |
'themes.php', | |
__('Customize'), | |
__('Customize'), | |
'customize', | |
esc_url($customize_url), | |
'' | |
); | |
endif; | |
} | |
function add_toolbar_items($admin_bar) | |
{ | |
if (!gutenberg_is_fse_theme()) { | |
return; | |
} | |
if (is_admin() || current_user_can('edit_theme_options')): | |
$customize_url = get_admin_url('', 'customize.php'); | |
$admin_bar->add_menu(array( | |
'id' => 'customize', | |
'title' => 'Customize', | |
'href' => $customize_url, | |
'meta' => array( | |
'title' => __('Customize'), | |
), | |
)); | |
endif; | |
} | |
if (function_exists('gutenberg_is_fse_theme')) { | |
add_action('admin_bar_menu', 'add_toolbar_items', 100); | |
add_action('admin_menu', 'wcd_add_customizer_back', 999); | |
} |
Just tidied up a bit so as to check that the gutenberg full site editing is actually installed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to add in the admin bar and also check that user has edit_theme_options rights