#20: map_meta_cap

The map_meta_cap filter allows you to modify which primitive capabilities are mapped to which meta capabilities. That is to say, allow a specific user or users to have or not have a capability in a specific context.

It is evaluated in map_meta_cap() in the wp-includes/capabilities.php file.

map_meta_cap accepts 4 arguments:

  1. array $caps An array of primitive capabilities matched to the provided meta $cap
  2. string $cap The name of the meta capability to map to
  3. int $user_id The current user’s id or a specified one
  4. array $args An array of extra arguments for the meta capability. Sometimes empty

Example:

Let’s say you only want to allow super admins to upload files in your Multisite installation (for some reason). The following returns do_not_allow for any non-super admin on the upload_files cap.

View the code example on Gist.

#9: teeny_mce_buttons

The teeny_mce_buttons filter allows you to add or remove buttons from the teeny mce buttons row used in Press This.

It is evaluated in the _WP_Editors::editor_settings() method in the wp-includes/class-wp-editor.phpv file. The _WP_Editors class is publicly instantiated via wp_editor().

Please note: Adding a button via teeny_mce_buttons will only register the button. In order to implement functionality for it, take a look at the teeny_mce_plugins filter in the same file.

Example:

The following example registers a new button in the teeny mce buttons row.