Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /*
  2. Plugin Name: Name of Plugin
  3. Plugin URI: Link to plugin information
  4. Description: Plugin Description
  5. [...]
  6. Network: Optional. Specify "Network: true" to require that a plugin is activated
  7. across all sites in an installation. This will prevent a plugin from being
  8. activated on a single site when Multisite is enabled.
  9. */
  10.  
  11. add_filter( 'all_plugins', 'wpse257256_hide_my_plugin' );
  12. function wpse257256_hide_my_plugin( $plugins ) {
  13. if ( is_multisite() && ! is_network_admin() ) {
  14. unset( $plugins['my-plugin-name/my-plugin-file.php'] );
  15. }
  16. return $plugins;
  17. }
  18.  
  19. register_activation_hook( __FILE__, function () {
  20. if ( is_multisite() && ! strpos( $_SERVER['REQUEST_URI'], 'wp-admin/network/plugins.php' ) ) {
  21. die ( __( '<script>alert("Activate this plugin only from the NETWORK DASHBOARD.");</script>') );
  22. }
  23. // ...............
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement