Created
May 23, 2024 12:31
-
-
Save brandonbarringer/0af7d9f2241a7c4652e46d68360740e2 to your computer and use it in GitHub Desktop.
Fix WP stripping tags in multisite
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 | |
// 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