Making WordPress.org


Ignore:
Timestamp:
01/15/2015 07:48:24 PM (10 years ago)
Author:
obenland
Message:

Theme Directory: Only super admins are allowed to add terms.

See #745.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r1115 r1145  
    109109            }
    110110            break;
     111
     112        case 'delete_categories':
     113        case 'edit_categories':
     114        case 'manage_categories':
     115
     116            if ( ! is_super_admin() ) {
     117                $caps[] = 'do_not_allow';
     118            }
     119            break;
    111120    }
    112121
     
    114123}
    115124add_filter( 'map_meta_cap', 'wporg_themes_map_meta_cap', 10, 4 );
     125
     126/**
     127 * Checks if ther current users is a super admin before allowing terms to be added.
     128 *
     129 * @param string           $term The term to add or update.
     130 * @return string|WP_Error The term to add or update or WP_Error on failure.
     131 */
     132function wporg_themes_pre_insert_term( $term ) {
     133    if ( ! is_super_admin() ) {
     134        $term = new WP_Error( 'not-allowed', __( 'You are not allowed to add terms.', 'wporg-themes' ) );
     135    }
     136
     137    return $term;
     138}
     139add_filter( 'pre_insert_term', 'wporg_themes_pre_insert_term' );
    116140
    117141/**
Note: See TracChangeset for help on using the changeset viewer.