public function onMapMetaCap($caps, $cap, $user_id, $args)
  {
    // post type object
    // ----------------

    $post_type_object = get_post_type_object($this->name);

    if (is_null($post_type_object)) {
      return $caps;
    }

    if (
      $post_type_object->capability_type === 'post' ||
      $post_type_object->capability_type === 'page'
    ) {
      return $caps;
    }

    // meta caps
    // ---------

    $edit_post = $post_type_object->cap->edit_post;
    $delete_post = $post_type_object->cap->delete_post;
    $read_post = $post_type_object->cap->read_post;

    // receiving meta caps?
    // --------------------

    if (
      $cap === $edit_post ||
      $cap === $delete_post ||
      $cap === $read_post
    ) {
      $post = get_post($args[0]);

      // map meta caps
      // -------------

      switch ($cap) {
      case $edit_post:
        return $this->onCheckedMapMetaCapEditPost($user_id, $post, $post_type_object);
      case $delete_post:
        return $this->onCheckedMapMetaCapDeletePost($user_id, $post, $post_type_object);
      case $read_post:
        return $this->onCheckedMapMetaCapReadPost($user_id, $post, $post_type_object);
      }
    }

    // default
    // -------

    return $caps;
  }
public function onMapMetaCap($caps, $cap, $user_id, $args)
  {
    // post type object
    // ----------------

    $post_type_object = get_post_type_object($this->name);

    if (is_null($post_type_object)) {
      return $caps;
    }

    if (
      $post_type_object->capability_type === 'post' ||
      $post_type_object->capability_type === 'page'
    ) {
      return $caps;
    }

    // meta caps
    // ---------

    $edit_post = $post_type_object->cap->edit_post;
    $delete_post = $post_type_object->cap->delete_post;
    $read_post = $post_type_object->cap->read_post;

    // receiving meta caps?
    // --------------------

    if (
      $cap === $edit_post ||
      $cap === $delete_post ||
      $cap === $read_post
    ) {
      $post = get_post($args[0]);

      // map meta caps
      // -------------

      switch ($cap) {
      case $edit_post:
        return $this->onCheckedMapMetaCapEditPost($user_id, $post, $post_type_object);
      case $delete_post:
        return $this->onCheckedMapMetaCapDeletePost($user_id, $post, $post_type_object);
      case $read_post:
        return $this->onCheckedMapMetaCapReadPost($user_id, $post, $post_type_object);
      }
    }

    // default
    // -------

    return $caps;
  }
public function onMapMetaCap ( $ caps , $ cap , $ user_id , $ args ) { // post type object // ---------------- $ post_type_object = get_post_type_object ( $ this -> name ) ; if ( is_null ( $ post_type_object ) ) { return $ caps ; } if ( $ post_type_object -> capability_type === 'post' || $ post_type_object -> capability_type === 'page' ) { return $ caps ; } // meta caps // --------- $ edit_post = $ post_type_object -> cap -> edit_post ; $ delete_post = $ post_type_object -> cap -> delete_post ; $ read_post = $ post_type_object -> cap -> read_post ; // receiving meta caps? // -------------------- if ( $ cap === $ edit_post || $ cap === $ delete_post || $ cap === $ read_post ) { $ post = get_post ( $ args [ 0 ] ) ; // map meta caps // ------------- switch ( $ cap ) { case $ edit_post : return $ this -> onCheckedMapMetaCapEditPost ( $ user_id , $ post , $ post_type_object ) ; case $ delete_post : return $ this -> onCheckedMapMetaCapDeletePost ( $ user_id , $ post , $ post_type_object ) ; case $ read_post : return $ this -> onCheckedMapMetaCapReadPost ( $ user_id , $ post , $ post_type_object ) ; } } // default // ------- return $ caps ; }
map meta cap
map meta cap