- //has_cap(capability_or_role_name) or
- //has_cap('edit_post', post_id)
- function has_cap($cap) {
- if ( is_numeric($cap) )
- $cap = $this->translate_level_to_cap($cap);
-
- $args = array_slice(func_get_args(), 1);
- $args = array_merge(array($cap, $this->ID), $args);
- $caps = call_user_func_array('map_meta_cap', $args);
+ /**
+ * Whether user has capability or role name.
+ *
+ * This is useful for looking up whether the user has a specific role
+ * assigned to the user. The second optional parameter can also be used to
+ * check for capabilities against a specfic post.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string|int $cap Capability or role name to search.
+ * @param int $post_id Optional. Post ID to check capability against specific post.
+ * @return bool True, if user has capability; false, if user does not have capability.
+ */
+ function has_cap( $cap ) {
+ if ( is_numeric( $cap ) )
+ $cap = $this->translate_level_to_cap( $cap );
+
+ $args = array_slice( func_get_args(), 1 );
+ $args = array_merge( array( $cap, $this->ID ), $args );
+ $caps = call_user_func_array( 'map_meta_cap', $args );