Created
November 20, 2015 14:22
-
-
Save deepak-rajpal/66d94baf31ee8aeb1811 to your computer and use it in GitHub Desktop.
Unfiltered HTML plugin selected code to allow admin/editor js/script etc code in WPMU
This file contains 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 | |
/* To allow unfiltered html for admin and editor */ | |
function um_unfilter_roles() { | |
// Makes sure $wp_roles is initialized | |
get_role( 'administrator' ); | |
global $wp_roles; | |
// Dont use get_role() wrapper, it doesn't work as a one off. | |
// (get_role does not properly return as reference) | |
$wp_roles->role_objects['administrator']->add_cap( 'unfiltered_html' ); | |
$wp_roles->role_objects['editor']->add_cap( 'unfiltered_html' ); | |
} | |
add_action( 'admin_init', 'um_unfilter_roles'); | |
// Add the unfiltered_html capability back in to WordPress 3.0 multisite. | |
function um_unfilter_multisite( $caps, $cap, $user_id, $args ) { | |
if ( $cap == 'unfiltered_html' ) { | |
unset( $caps ); | |
$caps[] = $cap; | |
} | |
return $caps; | |
} | |
add_filter( 'map_meta_cap', 'um_unfilter_multisite', 10, 4 ); | |
/* To allow unfiltered html for admin and editor - ends */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment