Created
January 16, 2013 06:14
-
-
Save mjangda/4545052 to your computer and use it in GitHub Desktop.
Allow limiting deletion of terms.
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 | |
add_action( 'registered_taxonomy', 'cms_modify_default_delete_term_caps', 10, 3 ); | |
function cms_modify_default_delete_term_caps( $taxonomy, $object_type, $args ) { | |
global $wp_taxonomies; | |
if ( 'category' == $taxonomy ) { | |
$wp_taxonomies[ $taxonomy ]->cap->delete_terms = 'cms-delete-terms'; | |
} | |
} | |
add_filter('map_meta_cap', 'cms_map_meta_cap', 10, 4 ); | |
function cms_map_meta_cap( $caps, $cap, $user_id, $args ) { | |
switch ($cap) { | |
case 'cbs-delete-terms': | |
$caps[] = 'do_not_allow'; | |
break; | |
} | |
return $caps; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment