Making WordPress.org

Changeset 5374


Ignore:
Timestamp:
04/19/2017 07:52:02 PM (9 years ago)
Author:
coreymckrill
Message:

WordCamp: Adjust task CPT capability mapping

The capabilities were mapped incorrectly, making it so that only
super admins could see the Planning Checklist tasks. map_meta_cap
claims another victim (me).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-mentors/includes/tasks.php

    r5336 r5374  
    8181        'publicly_queryable'    => false,
    8282        'rewrite'               => false,
    83         'capability_type'       => 'task',
     83        'capabilities' => array(
     84            'edit_post'          => Mentors\ORGANIZER_CAP,
     85            'read_post'          => Mentors\ORGANIZER_CAP,
     86            'delete_post'        => Mentors\MENTOR_CAP,
     87            'edit_posts'         => Mentors\ORGANIZER_CAP,
     88            'edit_others_posts'  => Mentors\ORGANIZER_CAP,
     89            'publish_posts'      => Mentors\MENTOR_CAP,
     90            'read_private_posts' => Mentors\MENTOR_CAP,
     91            'create_posts'       => Mentors\ORGANIZER_CAP,
     92        ),
    8493        'show_in_rest'          => true,
    8594        'rest_controller_class' => __NAMESPACE__ . '\Controller',
     
    8796
    8897    register_post_type( Mentors\PREFIX . '_task', $args );
    89 
    90     add_filter( 'map_meta_cap', __NAMESPACE__ . '\map_task_caps', 10, 2 );
    91 }
    92 
    93 /**
    94  * Map CPT capabilities.
    95  *
    96  * @since 1.0.0
    97  *
    98  * @param array  $caps The user's actual capabilities.
    99  * @param string $cap  Capability name.
    100  *
    101  * @return array
    102  */
    103 function map_task_caps( $caps, $cap ) {
    104     switch ( $cap ) {
    105         case 'edit_task' :
    106         case 'edit_tasks' :
    107         case 'edit_others_tasks' :
    108         case 'read_task' :
    109             $caps[] = Mentors\ORGANIZER_CAP;
    110             break;
    111 
    112         case 'read_private_tasks' :
    113         case 'publish_tasks' :
    114         case 'delete_task' :
    115             $caps[] = Mentors\MENTOR_CAP;
    116             break;
    117     }
    118 
    119     return $caps;
    12098}
    12199
Note: See TracChangeset for help on using the changeset viewer.