Is there a way to disable the edit shortcut buttons that was added in WordPress 4.7?
I noticed they have a class customize-partial-edit-shortcut-button
and I can add display:none
in css but trying to find a solution in php.
2 s
The simplest way to disable edit shortcuts without unwanted side effects is to no-op override the JS function that generates them in the first place. You can do this from PHP as follows:
add_action( 'wp_enqueue_scripts', function () {
$js="wp.customize.selectiveRefresh.Partial.prototype.createEditShortcutForPlacement = function() {};";
wp_add_inline_script( 'customize-selective-refresh', $js );
} );
This will work for any theme.