bb_get_plugins

The BuddyPress bb get plugins function.

Description

bb_get_plugins( (string) $location = 'all', (string) $type = 'normal', (string) $status = 'all' ); 

Parameters (3)

0. $location — Optional. (string) => 'all'
The location.
1. $type — Optional. (string) => 'normal'
The type.
2. $status — Optional. (string) => 'all'
The status.

Usage

  1. if ( !function_exists( 'bb_get_plugins' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-plugin.php'; 
  3.  
  4. // The location. 
  5. $location = 'all'; 
  6.  
  7. // The type. 
  8. $type = 'normal'; 
  9.  
  10. // The status. 
  11. $status = 'all'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_get_plugins($location, $type, $status); 
  15.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-admin/includes/functions.bb-plugin.php  
  1. function bb_get_plugins( $location = 'all', $type = 'normal', $status = 'all' ) 
  2. static $plugin_cache = array(); 
  3.  
  4. if ( !in_array( $type, array( 'all', 'autoload', 'normal' ) ) ) { 
  5. $type = 'normal'; 
  6.  
  7. if ( 'autoload' === $type || !in_array( $status, array( 'all', 'active', 'inactive' ) ) ) { 
  8. $status = 'all'; 
  9.  
  10. if ( isset( $plugin_cache[$location][$type][$status] ) ) { 
  11. return $plugin_cache[$location][$type][$status]; 
  12.  
  13. global $bb; 
  14. $directories = array(); 
  15. if ( 'all' === $location ) { 
  16. foreach ( $bb->plugin_locations as $_data ) { 
  17. $directories[] = $_data['dir']; 
  18. } elseif ( isset( $bb->plugin_locations[$location]['dir'] ) ) { 
  19. $directories[] = $bb->plugin_locations[$location]['dir']; 
  20.  
  21. require_once( BB_PATH . BB_INC . 'class.bb-dir-map.php' ); 
  22.  
  23. $plugin_arrays = array(); 
  24. foreach ( $directories as $directory ) { 
  25. $dir_map = new BB_Dir_Map
  26. $directory,  
  27. array( 
  28. 'callback' => 'bb_get_plugins_callback',  
  29. 'callback_args' => array( $type ),  
  30. 'recurse' => 1 
  31. ); 
  32. $dir_plugins = $dir_map->get_results(); 
  33. $dir_plugins = is_wp_error( $dir_plugins ) ? array() : $dir_plugins; 
  34. $plugin_arrays[] = $dir_plugins; 
  35. unset($dir_map, $dir_plugins); 
  36.  
  37. $plugins = array(); 
  38. foreach ($plugin_arrays as $plugin_array) { 
  39. $plugins = array_merge($plugins, $plugin_array); 
  40.  
  41. $active_plugins = (array) bb_get_option( 'active_plugins' ); 
  42.  
  43. $adjusted_plugins = array(); 
  44. foreach ($plugins as $plugin => $plugin_data) { 
  45. $_id = $plugin_data['location'] . '#' . $plugin; 
  46. $plugin_data['active'] = 0; 
  47. if ( 'autoload' === $type || in_array( $_id, $active_plugins ) ) { 
  48. $plugin_data['active'] = 1; 
  49. if ( 
  50. 'active' === $status && $plugin_data['active'] || 
  51. 'inactive' === $status && !$plugin_data['active'] || 
  52. 'all' === $status 
  53. ) { 
  54. $adjusted_plugins[$_id] = $plugin_data; 
  55.  
  56. uasort( $adjusted_plugins, 'bb_plugins_sort' ); 
  57.  
  58. $plugin_cache[$location][$type][$status] = $adjusted_plugins; 
  59.  
  60. return $adjusted_plugins;