#38652 closed enhancement (fixed)
Introduce singular capabilities for activating and deactivating individual plugins
| Reported by: | 
  
     | 
      Owned by: | 
  
     | 
    
|---|---|---|---|
| Milestone: | 4.9 | Priority: | normal | 
| Severity: | normal | Version: | |
| Component: | Role/Capability | Keywords: | has-patch has-unit-tests granular-capabilities has-dev-note | 
| Focuses: | Cc: | 
Description (last modified by )
As we did in #35614 for taxonomy terms, singular capabilities should be introduced for managing individual plugins.
This would allow fine-grained cap checks such as current_user_can( 'activate_plugin', $plugin_file ).
This ticket covers activating and deactivating plugins.
Attachments (1)
Change History (13)
    
      
        
        
This ticket was mentioned in Slack in #core-multisite by johnbillion. View the logs.
      
      
3 years ago
    
    
  
              
    
      
    #3
  
    
        
          
            
 @
            
3 years ago
        
    
  
  
  - Description modified (diff)
 - Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
 - Milestone changed from Future Release to 4.8
 - Owner set to johnbillion
 - Status changed from new to accepted
 - Summary changed from Introduce singular capabilities for managing individual plugins to Introduce singular capabilities for activating and deactivating individual plugins
 
    
      
    #5
  
    
        
          
            
 @
            
3 years ago
        
    
  
  
    
38652.activate-deactivate.diff covers the following situations:
- Activate/Deactivate links on the Plugins listing screen.
 - Actual activation and deactivation cap check, including bulk activation and deactivation.
 - The 'Activate' link shown after a shiny plugin installation.
 - The 'Activate Plugin' link shown after a non-shiny (ie. fallback) plugin update.
 - Plugin error scraping.
 
It does not cover network activation/deactivation. This can be handled separately.
    
      
    #6
  
    
        
          
            
 @
            
3 years ago
        
    
  
  
    
For clarity, the newly introduced activate_plugin, deactivate_plugin, and deactivate_plugins meta capabilities all map to the existing activate_plugins primitive capability, so there is of course no change in existing behaviour.
    
      
    #9
  
    
        
          
            
 @
            
3 years ago
        
    
  
  
  - Keywords changed from has-patch, has-unit-tests, granular-capabilities to has-patch has-unit-tests granular-capabilities
 - Milestone changed from Future Release to 4.9
 
    
      
    #12
  
    
        
          
            
 @
            
2 years ago
        
    
  
  
  - Keywords has-dev-note added; needs-dev-note removed
 
This is included in the https://make.wordpress.org/core/2017/10/15/improvements-for-roles-and-capabilities-in-4-9/ dev note. Thanks @flixos90!
I decided to split this up a bit to avoid huge patches. This ticket now only addresses activating and deactivating plugins, and we can open other tickets for plugin editing, deletion, installation, etc, as necessary.
Patch attached.