Skip to content

Instantly share code, notes, and snippets.

@brandonbarringer
Created May 23, 2024 12:31
Show Gist options
  • Save brandonbarringer/0af7d9f2241a7c4652e46d68360740e2 to your computer and use it in GitHub Desktop.
Save brandonbarringer/0af7d9f2241a7c4652e46d68360740e2 to your computer and use it in GitHub Desktop.
Fix WP stripping tags in multisite
<?php
// In WP multisite, WP strips out things like script tags and embeds from the
// editor for non-super-admins. This filter allows editors to use these tags.
add_filter('map_meta_cap', function ($caps, $cap, $user_id, $args) {
if (
$cap === 'unfiltered_html'
&& (user_can($user_id, 'editor') || user_can($user_id, 'administrator'))
) {
$caps = ['unfiltered_html'];
}
return $caps;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment