Skip to content

Instantly share code, notes, and snippets.

@westcoastdigital
Last active May 18, 2021 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westcoastdigital/386c918c5f2dd33f3874f26e24430278 to your computer and use it in GitHub Desktop.
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
<?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);
}
@westcoastdigital
Copy link
Author

Updated to add in the admin bar and also check that user has edit_theme_options rights

@westcoastdigital
Copy link
Author

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